| 1 | /* CLI stylizing |
| 2 | |
| 3 | Copyright (C) 2018-2020 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. */ |
| 28 | class cli_style_option |
| 29 | { |
| 30 | public: |
| 31 | |
| 32 | /* Construct a CLI style option with a foreground color. */ |
| 33 | cli_style_option (const char *name, ui_file_style::basic_color fg); |
| 34 | |
| 35 | /* Construct a CLI style option with an intensity. */ |
| 36 | cli_style_option (const char *name, ui_file_style::intensity i); |
| 37 | |
| 38 | /* Return a ui_file_style corresponding to the settings in this CLI |
| 39 | style. */ |
| 40 | ui_file_style style () const; |
| 41 | |
| 42 | /* Return the style name. */ |
| 43 | const char *name () { return m_name; }; |
| 44 | |
| 45 | /* Call once to register this CLI style with the CLI engine. */ |
| 46 | void add_setshow_commands (enum command_class theclass, |
| 47 | const char *prefix_doc, |
| 48 | struct cmd_list_element **set_list, |
| 49 | struct cmd_list_element **show_list, |
| 50 | bool skip_intensity); |
| 51 | |
| 52 | /* Return the 'set style NAME' command list, that can be used |
| 53 | to build a lambda DO_SET to call add_setshow_commands. */ |
| 54 | struct cmd_list_element *set_list () { return m_set_list; }; |
| 55 | |
| 56 | /* Same as SET_LIST but for the show command list. */ |
| 57 | struct cmd_list_element *show_list () { return m_show_list; }; |
| 58 | |
| 59 | /* This style can be observed for any changes. */ |
| 60 | gdb::observers::observable<> changed; |
| 61 | |
| 62 | private: |
| 63 | |
| 64 | /* The style name. */ |
| 65 | const char *m_name; |
| 66 | |
| 67 | /* The foreground. */ |
| 68 | const char *m_foreground; |
| 69 | /* The background. */ |
| 70 | const char *m_background; |
| 71 | /* The intensity. */ |
| 72 | const char *m_intensity; |
| 73 | |
| 74 | /* Storage for prefixes needed when registering the commands. */ |
| 75 | std::string m_show_prefix; |
| 76 | std::string m_set_prefix; |
| 77 | /* Storage for command lists needed when registering |
| 78 | subcommands. */ |
| 79 | struct cmd_list_element *m_set_list = nullptr; |
| 80 | struct cmd_list_element *m_show_list = nullptr; |
| 81 | |
| 82 | /* Callback to notify the observable. */ |
| 83 | static void do_set_value (const char *ignore, int from_tty, |
| 84 | struct cmd_list_element *cmd); |
| 85 | |
| 86 | /* Callback to show the foreground. */ |
| 87 | static void do_show_foreground (struct ui_file *file, int from_tty, |
| 88 | struct cmd_list_element *cmd, |
| 89 | const char *value); |
| 90 | /* Callback to show the background. */ |
| 91 | static void do_show_background (struct ui_file *file, int from_tty, |
| 92 | struct cmd_list_element *cmd, |
| 93 | const char *value); |
| 94 | /* Callback to show the intensity. */ |
| 95 | static void do_show_intensity (struct ui_file *file, int from_tty, |
| 96 | struct cmd_list_element *cmd, |
| 97 | const char *value); |
| 98 | }; |
| 99 | |
| 100 | /* The file name style. */ |
| 101 | extern cli_style_option file_name_style; |
| 102 | |
| 103 | /* The function name style. */ |
| 104 | extern cli_style_option function_name_style; |
| 105 | |
| 106 | /* The variable name style. */ |
| 107 | extern cli_style_option variable_name_style; |
| 108 | |
| 109 | /* The address style. */ |
| 110 | extern cli_style_option address_style; |
| 111 | |
| 112 | /* The highlight style. */ |
| 113 | extern cli_style_option highlight_style; |
| 114 | |
| 115 | /* The title style. */ |
| 116 | extern cli_style_option title_style; |
| 117 | |
| 118 | /* The metadata style. */ |
| 119 | extern cli_style_option metadata_style; |
| 120 | |
| 121 | /* The border style of a TUI window that does not have the focus. */ |
| 122 | extern cli_style_option tui_border_style; |
| 123 | |
| 124 | /* The border style of a TUI window that does have the focus. */ |
| 125 | extern cli_style_option tui_active_border_style; |
| 126 | |
| 127 | /* True if source styling is enabled. */ |
| 128 | extern bool source_styling; |
| 129 | |
| 130 | /* True if styling is enabled. */ |
| 131 | extern bool cli_styling; |
| 132 | |
| 133 | #endif /* CLI_CLI_STYLE_H */ |