3 Copyright (C) 2018-2024 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
20 #ifndef GDB_CLI_CLI_STYLE_H
21 #define GDB_CLI_CLI_STYLE_H
25 #include "gdbsupport/observable.h"
27 /* A single CLI style option. */
28 class cli_style_option
32 /* Construct a CLI style option with a foreground color. */
33 cli_style_option (const char *name
, ui_file_style::basic_color fg
,
34 ui_file_style::intensity
= ui_file_style::NORMAL
);
36 /* Construct a CLI style option with an intensity. */
37 cli_style_option (const char *name
, ui_file_style::intensity i
);
39 /* Return a ui_file_style corresponding to the settings in this CLI
41 ui_file_style
style () const;
43 /* Return the style name. */
44 const char *name () { return m_name
; };
46 /* Call once to register this CLI style with the CLI engine. Returns
47 the set/show prefix commands for the style. */
48 set_show_commands
add_setshow_commands (enum command_class theclass
,
49 const char *prefix_doc
,
50 struct cmd_list_element
**set_list
,
51 struct cmd_list_element
**show_list
,
54 /* Return the 'set style NAME' command list, that can be used
55 to build a lambda DO_SET to call add_setshow_commands. */
56 struct cmd_list_element
*set_list () { return m_set_list
; };
58 /* Same as SET_LIST but for the show command list. */
59 struct cmd_list_element
*show_list () { return m_show_list
; };
61 /* This style can be observed for any changes. */
62 gdb::observers::observable
<> changed
;
70 ui_file_style::color m_foreground
;
72 ui_file_style::color m_background
;
74 const char *m_intensity
;
76 /* Storage for command lists needed when registering
78 struct cmd_list_element
*m_set_list
= nullptr;
79 struct cmd_list_element
*m_show_list
= nullptr;
81 /* Callback to notify the observable. */
82 static void do_set_value (const char *ignore
, int from_tty
,
83 struct cmd_list_element
*cmd
);
85 /* Callback to show the foreground. */
86 static void do_show_foreground (struct ui_file
*file
, int from_tty
,
87 struct cmd_list_element
*cmd
,
89 /* Callback to show the background. */
90 static void do_show_background (struct ui_file
*file
, int from_tty
,
91 struct cmd_list_element
*cmd
,
93 /* Callback to show the intensity. */
94 static void do_show_intensity (struct ui_file
*file
, int from_tty
,
95 struct cmd_list_element
*cmd
,
99 /* Chains containing all defined "set/show style" subcommands. */
100 extern struct cmd_list_element
*style_set_list
;
101 extern struct cmd_list_element
*style_show_list
;
103 /* The file name style. */
104 extern cli_style_option file_name_style
;
106 /* The function name style. */
107 extern cli_style_option function_name_style
;
109 /* The variable name style. */
110 extern cli_style_option variable_name_style
;
112 /* The address style. */
113 extern cli_style_option address_style
;
115 /* The highlight style. */
116 extern cli_style_option highlight_style
;
118 /* The title style. */
119 extern cli_style_option title_style
;
121 /* Style used for commands. */
122 extern cli_style_option command_style
;
124 /* The metadata style. */
125 extern cli_style_option metadata_style
;
127 /* The disassembler style for mnemonics or assembler directives
128 (e.g. '.byte', etc). */
129 extern cli_style_option disasm_mnemonic_style
;
131 /* The disassembler style for register names. */
132 extern cli_style_option disasm_register_style
;
134 /* The disassembler style for numerical values that are not addresses, this
135 includes immediate operands (e.g. in, an add instruction), but also
136 address offsets (e.g. in a load instruction). */
137 extern cli_style_option disasm_immediate_style
;
139 /* The disassembler style for comments. */
140 extern cli_style_option disasm_comment_style
;
142 /* The border style of a TUI window that does not have the focus. */
143 extern cli_style_option tui_border_style
;
145 /* The border style of a TUI window that does have the focus. */
146 extern cli_style_option tui_active_border_style
;
148 /* The style to use for the GDB version string. */
149 extern cli_style_option version_style
;
151 /* The style for a line number. */
152 extern cli_style_option line_number_style
;
154 /* True if source styling is enabled. */
155 extern bool source_styling
;
157 /* True if disassembler styling is enabled. */
158 extern bool disassembler_styling
;
160 /* True if styling is enabled. */
161 extern bool cli_styling
;
163 #endif /* GDB_CLI_CLI_STYLE_H */