GDB (xrefs)
Loading...
Searching...
No Matches
cli-style.h
Go to the documentation of this file.
1/* CLI stylizing
2
3 Copyright (C) 2018-2023 Free Software Foundation, Inc.
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
20#ifndef CLI_CLI_STYLE_H
21#define CLI_CLI_STYLE_H
22
23#include "ui-file.h"
24#include "command.h"
25#include "gdbsupport/observable.h"
26
27/* A single CLI style option. */
29{
30public:
31
32 /* Construct a CLI style option with a foreground color. */
35
36 /* Construct a CLI style option with an intensity. */
38
39 /* Return a ui_file_style corresponding to the settings in this CLI
40 style. */
41 ui_file_style style () const;
42
43 /* Return the style name. */
44 const char *name () { return m_name; };
45
46 /* Call once to register this CLI style with the CLI engine. Returns
47 the set/show prefix commands for the style. */
49 const char *prefix_doc,
52 bool skip_intensity);
53
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; };
57
58 /* Same as SET_LIST but for the show command list. */
59 struct cmd_list_element *show_list () { return m_show_list; };
60
61 /* This style can be observed for any changes. */
62 gdb::observers::observable<> changed;
63
64private:
65
66 /* The style name. */
67 const char *m_name;
68
69 /* The foreground. */
70 const char *m_foreground;
71 /* The background. */
72 const char *m_background;
73 /* The intensity. */
74 const char *m_intensity;
75
76 /* Storage for command lists needed when registering
77 subcommands. */
78 struct cmd_list_element *m_set_list = nullptr;
79 struct cmd_list_element *m_show_list = nullptr;
80
81 /* Callback to notify the observable. */
82 static void do_set_value (const char *ignore, int from_tty,
83 struct cmd_list_element *cmd);
84
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,
88 const char *value);
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,
92 const char *value);
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,
96 const char *value);
97};
98
99/* The file name style. */
101
102/* The function name style. */
104
105/* The variable name style. */
107
108/* The address style. */
110
111/* The highlight style. */
113
114/* The title style. */
116
117/* The metadata style. */
119
120/* The disassembler style for mnemonics or assembler directives
121 (e.g. '.byte', etc). */
123
124/* The disassembler style for register names. */
126
127/* The disassembler style for numerical values that are not addresses, this
128 includes immediate operands (e.g. in, an add instruction), but also
129 address offsets (e.g. in a load instruction). */
131
132/* The disassembler style for comments. */
134
135/* The border style of a TUI window that does not have the focus. */
137
138/* The border style of a TUI window that does have the focus. */
140
141/* The style to use for the GDB version string. */
143
144/* True if source styling is enabled. */
145extern bool source_styling;
146
147/* True if disassembler styling is enabled. */
148extern bool disassembler_styling;
149
150/* True if styling is enabled. */
151extern bool cli_styling;
152
153#endif /* CLI_CLI_STYLE_H */
const char * m_name
Definition cli-style.h:67
static void do_show_intensity(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
Definition cli-style.c:235
gdb::observers::observable changed
Definition cli-style.h:62
const char * m_intensity
Definition cli-style.h:74
ui_file_style style() const
Definition cli-style.c:169
struct cmd_list_element * m_set_list
Definition cli-style.h:78
set_show_commands add_setshow_commands(enum command_class theclass, const char *prefix_doc, struct cmd_list_element **set_list, struct cmd_list_element **show_list, bool skip_intensity)
Definition cli-style.c:245
struct cmd_list_element * set_list()
Definition cli-style.h:56
struct cmd_list_element * m_show_list
Definition cli-style.h:79
static void do_show_background(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
Definition cli-style.c:225
static void do_set_value(const char *ignore, int from_tty, struct cmd_list_element *cmd)
Definition cli-style.c:190
static void do_show_foreground(struct ui_file *file, int from_tty, struct cmd_list_element *cmd, const char *value)
Definition cli-style.c:215
const char * m_background
Definition cli-style.h:72
cli_style_option(const char *name, ui_file_style::basic_color fg, ui_file_style::intensity=ui_file_style::NORMAL)
Definition cli-style.c:130
const char * m_foreground
Definition cli-style.h:70
struct cmd_list_element * show_list()
Definition cli-style.h:59
const char * name()
Definition cli-style.h:44
cli_style_option address_style
cli_style_option tui_active_border_style
cli_style_option highlight_style
cli_style_option function_name_style
bool source_styling
Definition cli-style.c:39
cli_style_option disasm_mnemonic_style
cli_style_option disasm_register_style
cli_style_option variable_name_style
bool disassembler_styling
Definition cli-style.c:44
cli_style_option title_style
cli_style_option tui_border_style
cli_style_option file_name_style
cli_style_option metadata_style
cli_style_option disasm_immediate_style
cli_style_option disasm_comment_style
bool cli_styling
Definition cli-style.c:33
cli_style_option version_style
command_class
Definition command.h:43
Definition value.h:130