Commit | Line | Data |
---|---|---|
cbe56571 TT |
1 | /* CLI stylizing |
2 | ||
3666a048 | 3 | Copyright (C) 2018-2021 Free Software Foundation, Inc. |
cbe56571 TT |
4 | |
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
1a5c2598 TT |
20 | #ifndef CLI_CLI_STYLE_H |
21 | #define CLI_CLI_STYLE_H | |
cbe56571 TT |
22 | |
23 | #include "ui-file.h" | |
0d12e84c | 24 | #include "command.h" |
a2a7af0c | 25 | #include "gdbsupport/observable.h" |
cbe56571 TT |
26 | |
27 | /* A single CLI style option. */ | |
28 | class cli_style_option | |
29 | { | |
30 | public: | |
31 | ||
32 | /* Construct a CLI style option with a foreground color. */ | |
9d2d8a16 AB |
33 | cli_style_option (const char *name, ui_file_style::basic_color fg, |
34 | ui_file_style::intensity = ui_file_style::NORMAL); | |
9303eb2f PW |
35 | |
36 | /* Construct a CLI style option with an intensity. */ | |
37 | cli_style_option (const char *name, ui_file_style::intensity i); | |
cbe56571 TT |
38 | |
39 | /* Return a ui_file_style corresponding to the settings in this CLI | |
40 | style. */ | |
41 | ui_file_style style () const; | |
42 | ||
9303eb2f PW |
43 | /* Return the style name. */ |
44 | const char *name () { return m_name; }; | |
45 | ||
cbe56571 | 46 | /* Call once to register this CLI style with the CLI engine. */ |
9303eb2f | 47 | void add_setshow_commands (enum command_class theclass, |
cbe56571 | 48 | const char *prefix_doc, |
cbe56571 | 49 | struct cmd_list_element **set_list, |
d73cff18 | 50 | struct cmd_list_element **show_list, |
a2a7af0c | 51 | bool skip_intensity); |
d73cff18 PW |
52 | |
53 | /* Return the 'set style NAME' command list, that can be used | |
54 | to build a lambda DO_SET to call add_setshow_commands. */ | |
55 | struct cmd_list_element *set_list () { return m_set_list; }; | |
56 | ||
57 | /* Same as SET_LIST but for the show command list. */ | |
58 | struct cmd_list_element *show_list () { return m_show_list; }; | |
cbe56571 | 59 | |
a2a7af0c TT |
60 | /* This style can be observed for any changes. */ |
61 | gdb::observers::observable<> changed; | |
62 | ||
cbe56571 TT |
63 | private: |
64 | ||
9303eb2f PW |
65 | /* The style name. */ |
66 | const char *m_name; | |
67 | ||
cbe56571 TT |
68 | /* The foreground. */ |
69 | const char *m_foreground; | |
70 | /* The background. */ | |
71 | const char *m_background; | |
72 | /* The intensity. */ | |
73 | const char *m_intensity; | |
74 | ||
75 | /* Storage for prefixes needed when registering the commands. */ | |
76 | std::string m_show_prefix; | |
77 | std::string m_set_prefix; | |
78 | /* Storage for command lists needed when registering | |
79 | subcommands. */ | |
80 | struct cmd_list_element *m_set_list = nullptr; | |
81 | struct cmd_list_element *m_show_list = nullptr; | |
82 | ||
a2a7af0c TT |
83 | /* Callback to notify the observable. */ |
84 | static void do_set_value (const char *ignore, int from_tty, | |
85 | struct cmd_list_element *cmd); | |
86 | ||
cbe56571 TT |
87 | /* Callback to show the foreground. */ |
88 | static void do_show_foreground (struct ui_file *file, int from_tty, | |
89 | struct cmd_list_element *cmd, | |
90 | const char *value); | |
91 | /* Callback to show the background. */ | |
92 | static void do_show_background (struct ui_file *file, int from_tty, | |
93 | struct cmd_list_element *cmd, | |
94 | const char *value); | |
95 | /* Callback to show the intensity. */ | |
96 | static void do_show_intensity (struct ui_file *file, int from_tty, | |
97 | struct cmd_list_element *cmd, | |
98 | const char *value); | |
99 | }; | |
100 | ||
101 | /* The file name style. */ | |
102 | extern cli_style_option file_name_style; | |
103 | ||
104 | /* The function name style. */ | |
105 | extern cli_style_option function_name_style; | |
106 | ||
80ae2043 TT |
107 | /* The variable name style. */ |
108 | extern cli_style_option variable_name_style; | |
109 | ||
35fb8261 TT |
110 | /* The address style. */ |
111 | extern cli_style_option address_style; | |
112 | ||
9303eb2f PW |
113 | /* The highlight style. */ |
114 | extern cli_style_option highlight_style; | |
115 | ||
116 | /* The title style. */ | |
117 | extern cli_style_option title_style; | |
118 | ||
7f6aba03 TT |
119 | /* The metadata style. */ |
120 | extern cli_style_option metadata_style; | |
9303eb2f | 121 | |
a2a7af0c TT |
122 | /* The border style of a TUI window that does not have the focus. */ |
123 | extern cli_style_option tui_border_style; | |
124 | ||
125 | /* The border style of a TUI window that does have the focus. */ | |
126 | extern cli_style_option tui_active_border_style; | |
127 | ||
9d2d8a16 AB |
128 | /* The style to use for the GDB version string. */ |
129 | extern cli_style_option version_style; | |
130 | ||
d085f989 | 131 | /* True if source styling is enabled. */ |
491144b5 | 132 | extern bool source_styling; |
d085f989 | 133 | |
cbe56571 | 134 | /* True if styling is enabled. */ |
491144b5 | 135 | extern bool cli_styling; |
cbe56571 | 136 | |
1a5c2598 | 137 | #endif /* CLI_CLI_STYLE_H */ |