#include "cli/cli-cmds.h"
#include "cli/cli-style.h"
#include "source-cache.h"
+#include "observable.h"
/* True if styling is enabled. */
-#if defined(_WIN32) || defined (__CYGWIN__)
+#if defined (__MSDOS__) || defined (__CYGWIN__)
int cli_styling = 0;
#else
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",
set_style_enabled (const char *args, int from_tty, struct cmd_list_element *c)
{
g_source_cache.clear ();
+ gdb::observers::source_styling_changed.notify ();
}
static void
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 ()
{
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, \