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