aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-style.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2019-03-08 13:54:07 -0700
committerTom Tromey <tromey@adacore.com>2019-03-14 05:47:11 -0600
commitd085f98901ccd6c9764b93d3983f3c7797addc4f (patch)
treebdd1be3d6e40f4b72782ae0db0da3fc80dfe93c2 /gdb/cli/cli-style.c
parent6f11e6824e15bd40fe1e7b245a22865c6ef8c7bd (diff)
downloadgdb-d085f98901ccd6c9764b93d3983f3c7797addc4f.zip
gdb-d085f98901ccd6c9764b93d3983f3c7797addc4f.tar.gz
gdb-d085f98901ccd6c9764b93d3983f3c7797addc4f.tar.bz2
Add the "set style source" command
This adds "set style source" (and "show style source") commands. This gives the user control over whether source code is highlighted. gdb/ChangeLog 2019-03-14 Tom Tromey <tromey@adacore.com> * NEWS: Add item for "style sources" commands. * source-cache.c (source_cache::get_source_lines): Check source_styling. * cli/cli-style.c (source_styling): New global. (_initialize_cli_style): Add "style sources" commands. (show_style_sources): New function. * cli/cli-style.h (source_styling): Declare. gdb/doc/ChangeLog 2019-03-14 Tom Tromey <tromey@adacore.com> * gdb.texinfo (Output Styling): Document "set style source" and "show style source". gdb/testsuite/ChangeLog 2019-03-14 Tom Tromey <tromey@adacore.com> * gdb.base/style.exp: Add "set style sources" test.
Diffstat (limited to 'gdb/cli/cli-style.c')
-rw-r--r--gdb/cli/cli-style.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index fc91504..f6f6c7b 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -31,6 +31,11 @@ int cli_styling = 0;
int cli_styling = 1;
#endif
+/* True if source styling is enabled. Note that this is only
+ consulted when cli_styling is true. */
+
+int source_styling = 1;
+
/* Name of colors; must correspond to ui_file_style::basic_color. */
static const char * const cli_colors[] = {
"none",
@@ -230,6 +235,16 @@ show_style_enabled (struct ui_file *file, int from_tty,
fprintf_filtered (file, _("CLI output styling is disabled.\n"));
}
+static void
+show_style_sources (struct ui_file *file, int from_tty,
+ struct cmd_list_element *c, const char *value)
+{
+ if (source_styling)
+ fprintf_filtered (file, _("Source code styling is enabled.\n"));
+ else
+ fprintf_filtered (file, _("Source code styling is disabled.\n"));
+}
+
void
_initialize_cli_style ()
{
@@ -249,6 +264,20 @@ If enabled, output to the terminal is styled."),
set_style_enabled, show_style_enabled,
&style_set_list, &style_show_list);
+ add_setshow_boolean_cmd ("sources", no_class, &source_styling, _("\
+Set whether source code styling is enabled."), _("\
+Show whether source code styling is enabled."), _("\
+If enabled, source code is styled.\n"
+#ifdef HAVE_SOURCE_HIGHLIGHT
+"Note that source styling only works if styling in general is enabled,\n\
+see \"show style enabled\"."
+#else
+"Source highlighting is disabled in this installation of gdb, because\n\
+it was not linked against GNU Source Highlight."
+#endif
+ ), set_style_enabled, show_style_sources,
+ &style_set_list, &style_show_list);
+
#define STYLE_ADD_SETSHOW_COMMANDS(STYLE, NAME, PREFIX_DOC) \
STYLE.add_setshow_commands (NAME, no_class, PREFIX_DOC, \
&style_set_list, \