cli-style.h 4.2 KB

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