Apollo 10.0
自动驾驶开放平台
screen.h
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
17#ifndef TOOLS_CVT_MONITOR_SCREEN_H_
18#define TOOLS_CVT_MONITOR_SCREEN_H_
19
20#include <map>
21#include <string>
22#include <vector>
23
24#ifndef CTRL
25#define CTRL(c) ((c)&0x1F)
26#endif
27
29
30class Screen final {
31 public:
32 static const char InteractiveCmdStr[];
33
34 enum ColorPair { // foreground color - background color
41 };
42 static Screen* Instance(void);
43
44 ~Screen(void);
45
46 void Init(void);
47 void Run(void);
48 void Resize();
49 void Stop(void) { canRun_ = false; }
50
51 int Width(void) const;
52 int Height(void) const;
53
54 void AddStr(int x, int y, ColorPair color, const char* str) const;
55
56 ColorPair Color(void) const { return current_color_pair_; }
57 void SetCurrentColor(ColorPair color) const;
58 void AddStr(int x, int y, const char* str) const;
59 void AddStr(const char* str) const;
60 void MoveOffsetXY(int offsetX, int offsetY) const;
61 void ClearCurrentColor(void) const;
62
64 if (render_obj) {
65 current_render_obj_ = render_obj;
66 }
67 }
68
69 private:
70 explicit Screen();
71 Screen(const Screen&) = delete;
72 Screen& operator=(const Screen&) = delete;
73
74 int SwitchState(int ch);
75 void HighlightLine(int line_no);
76
77 void ShowInteractiveCmd(int ch);
78 void ShowRenderMessage(int ch);
79
80 bool IsInit(void) const;
81
82 enum class State { RenderMessage, RenderInterCmdInfo };
83
84 mutable ColorPair current_color_pair_;
85 bool canRun_;
86 State current_state_;
87 int highlight_direction_;
88 RenderableMessage* current_render_obj_;
89};
90
91#endif // TOOLS_CVT_MONITOR_SCREEN_H_
void MoveOffsetXY(int offsetX, int offsetY) const
Definition screen.cc:160
void AddStr(int x, int y, ColorPair color, const char *str) const
Definition screen.cc:152
void Init(void)
Definition screen.cc:94
void Run(void)
Definition screen.cc:210
ColorPair Color(void) const
Definition screen.h:56
int Height(void) const
Definition screen.cc:122
int Width(void) const
Definition screen.cc:120
void Resize()
Definition screen.cc:242
void SetCurrentRenderMessage(RenderableMessage *const render_obj)
Definition screen.h:63
static const char InteractiveCmdStr[]
Definition screen.h:32
void SetCurrentColor(ColorPair color) const
Definition screen.cc:124
void Stop(void)
Definition screen.h:49
void ClearCurrentColor(void) const
Definition screen.cc:145
~Screen(void)
Definition screen.cc:87
static Screen * Instance(void)
Definition screen.cc:39
ColorPair
Definition screen.h:34
@ BLACK_WHITE
Definition screen.h:40
@ INVALID
Definition screen.h:35
@ WHITE_BLACK
Definition screen.h:39
@ GREEN_BLACK
Definition screen.h:36
@ YELLOW_BLACK
Definition screen.h:37
@ RED_BLACK
Definition screen.h:38