aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2022-11-01 16:45:30 +0000
committerAndrew Burgess <aburgess@redhat.com>2022-11-16 10:34:19 +0000
commit92c1d07de5f1d82421fcb78331d1e7c70a24ff23 (patch)
treec6861a7da09fcb25139470f766de4ba0fef97c50 /gdb/tui
parentfeb5926e8a85837e97c268af53db743b545957f5 (diff)
downloadfsf-binutils-gdb-92c1d07de5f1d82421fcb78331d1e7c70a24ff23.zip
fsf-binutils-gdb-92c1d07de5f1d82421fcb78331d1e7c70a24ff23.tar.gz
fsf-binutils-gdb-92c1d07de5f1d82421fcb78331d1e7c70a24ff23.tar.bz2
gdb: add "set style tui-current-position on|off", default to off
As discussed at: https://sourceware.org/pipermail/gdb-patches/2020-June/169519.html this patch disables source and assembly code highlighting for the text highlighted by the TUI's current position indicator, and adds a command to enable it back.
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui-io.c13
-rw-r--r--gdb/tui/tui-win.c37
-rw-r--r--gdb/tui/tui-win.h4
3 files changed, 53 insertions, 1 deletions
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index a30000e..5278c38 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -369,6 +369,9 @@ apply_ansi_escape (WINDOW *w, const char *buf)
if (reverse_mode_p)
{
+ if (!style_tui_current_position)
+ return n_read;
+
/* We want to reverse _only_ the default foreground/background
colors. If the foreground color is not the default (because
the text was styled), we want to leave it as is. If e.g.,
@@ -411,12 +414,18 @@ tui_set_reverse_mode (WINDOW *w, bool reverse)
ui_file_style style = last_style;
reverse_mode_p = reverse;
- style.set_reverse (reverse);
if (reverse)
{
reverse_save_bg = style.get_background ();
reverse_save_fg = style.get_foreground ();
+
+ if (!style_tui_current_position)
+ {
+ /* Switch to default style (reversed) while highlighting the
+ current position. */
+ style = {};
+ }
}
else
{
@@ -424,6 +433,8 @@ tui_set_reverse_mode (WINDOW *w, bool reverse)
style.set_fg (reverse_save_fg);
}
+ style.set_reverse (reverse);
+
tui_apply_style (w, style);
}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 31b6606..e24763c 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -218,6 +218,30 @@ show_tui_border_kind (struct ui_file *file,
value);
}
+/* Implementation of the "set/show style tui-current-position" commands. */
+
+bool style_tui_current_position = false;
+
+static void
+show_style_tui_current_position (ui_file *file,
+ int from_tty,
+ cmd_list_element *c,
+ const char *value)
+{
+ gdb_printf (file, _("\
+Styling the text highlighted by the TUI's current position indicator is %s.\n"),
+ value);
+}
+
+static void
+set_style_tui_current_position (const char *ignore, int from_tty,
+ cmd_list_element *c)
+{
+ if (TUI_SRC_WIN != nullptr)
+ TUI_SRC_WIN->refill ();
+ if (TUI_DISASM_WIN != nullptr)
+ TUI_DISASM_WIN->refill ();
+}
/* Tui internal configuration variables. These variables are updated
by tui_update_variables to reflect the tui configuration
@@ -1195,6 +1219,19 @@ the line numbers and uses less horizontal space."),
tui_set_compact_source, tui_show_compact_source,
&tui_setlist, &tui_showlist);
+ add_setshow_boolean_cmd ("tui-current-position", class_maintenance,
+ &style_tui_current_position, _("\
+Set whether to style text highlighted by the TUI's current position indicator."),
+ _("\
+Show whether to style text highlighted by the TUI's current position indicator."),
+ _("\
+When enabled, the source and assembly code highlighted by the TUI's current\n\
+position indicator is styled."),
+ set_style_tui_current_position,
+ show_style_tui_current_position,
+ &style_set_list,
+ &style_show_list);
+
tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
}
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 9a92fa3..bdc6da0 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -51,4 +51,8 @@ struct cmd_list_element **tui_get_cmd_list (void);
/* Whether compact source display should be used. */
extern bool compact_source;
+/* Whether to style the source and assembly code highlighted by the TUI's
+ current position indicator. */
+extern bool style_tui_current_position;
+
#endif /* TUI_TUI_WIN_H */