From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 15E183959C67; Wed, 16 Nov 2022 10:41:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15E183959C67 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668595281; bh=GusLLDqqBlZLSV5qg/XDRo7ZYZ9+Aw3wXRYSxgl0avU=; h=From:To:Subject:Date:From; b=bB4cRNmTseM1ZRbF0IkehEEPuNPy9Pxs79UjZlU091hqndUa/nLuYdaWGJQAjSbV/ 9t/tmeytBEAD50gm6QpdQyaLYhSPOPp7bXryG7Sm3hM5JoZSQUe0W4w8EF/qSlSntj hzVxrzWZH8IkDUEuAcNA8RJ1N5vjOFKbikdbvtmw= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: add "set style tui-current-position on|off", default to off X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: feb5926e8a85837e97c268af53db743b545957f5 X-Git-Newrev: 92c1d07de5f1d82421fcb78331d1e7c70a24ff23 Message-Id: <20221116104121.15E183959C67@sourceware.org> Date: Wed, 16 Nov 2022 10:41:21 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D92c1d07de5f1= d82421fcb78331d1e7c70a24ff23 commit 92c1d07de5f1d82421fcb78331d1e7c70a24ff23 Author: Pedro Alves Date: Tue Nov 1 16:45:30 2022 +0000 gdb: add "set style tui-current-position on|off", default to off =20 As discussed at: =20 https://sourceware.org/pipermail/gdb-patches/2020-June/169519.html =20 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. Diff: --- gdb/NEWS | 9 +++++++++ gdb/cli/cli-style.c | 4 ++-- gdb/doc/gdb.texinfo | 17 +++++++++++++++-- gdb/gdbcmd.h | 4 ++++ gdb/tui/tui-io.c | 13 ++++++++++++- gdb/tui/tui-win.c | 37 +++++++++++++++++++++++++++++++++++++ gdb/tui/tui-win.h | 4 ++++ 7 files changed, 83 insertions(+), 5 deletions(-) diff --git a/gdb/NEWS b/gdb/NEWS index 0642d7637b8..3f31515297c 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -73,6 +73,11 @@ For both /r and /b GDB is now better at using whitespace in order to align the disassembled instruction text. =20 +* The TUI no longer styles the source and assembly code highlighted by + the current position indicator by default. You can however + re-enable styling using the new "set style tui-current-position" + command. + * New commands =20 maintenance set ignore-prologue-end-flag on|off @@ -117,6 +122,10 @@ set debug infcall on|off show debug infcall Print additional debug messages about inferior function calls. =20 +set style tui-current-position [on|off] + Whether to style the source and assembly code highlighted by the + TUI's current position indicator. The default is off. + * Changed commands =20 document user-defined diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index abf685561fa..062347b27d0 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -296,8 +296,8 @@ cli_style_option::add_setshow_commands (enum command_cl= ass theclass, return prefix_cmds; } =20 -static cmd_list_element *style_set_list; -static cmd_list_element *style_show_list; +cmd_list_element *style_set_list; +cmd_list_element *style_show_list; =20 /* The command list for 'set style disassembler'. */ =20 diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index ea66f4ee42d..f5f664fd168 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -26602,6 +26602,15 @@ then it will be used. @item show style sources Show the current state of source code styling. =20 +@item set style tui-current-position @samp{on|off} +Enable or disable styling of the source and assembly code highlighted +by the TUI's current position indicator. The default is @samp{off}. +@xref{TUI, ,@value{GDBN} Text User Interface}. + +@item show style tui-current-position +Show whether the source and assembly code highlighted by the TUI's +current position indicator is styled. + @anchor{style_disassembler_enabled} @item set style disassembler enabled @samp{on|off} Enable or disable disassembler styling. This affects whether @@ -29163,8 +29172,12 @@ This window shows the processor registers. Regist= ers are highlighted when their values change. @end table =20 -The source and assembly windows show the current program position -by highlighting the current line and marking it with a @samp{>} marker. +The source and assembly windows show the current program position by +highlighting the current line and marking it with a @samp{>} marker. +By default, source and assembly code styling is disabled for the +highlighted text, but you can enable it with the @code{set style +tui-current-position on} command. @xref{Output Styling}. + Breakpoints are indicated with two markers. The first marker indicates the breakpoint type: =20 diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h index a05c68e52c2..c508870a930 100644 --- a/gdb/gdbcmd.h +++ b/gdb/gdbcmd.h @@ -65,4 +65,8 @@ extern void print_command_line (struct command_line *, un= signed int, extern void print_command_lines (struct ui_out *, struct command_line *, unsigned int); =20 +/* Chains containing all defined "set/show style" subcommands. */ +extern struct cmd_list_element *style_set_list; +extern struct cmd_list_element *style_show_list; + #endif /* !defined (GDBCMD_H) */ diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index a30000ef626..5278c380fc4 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) =20 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 =3D last_style; =20 reverse_mode_p =3D reverse; - style.set_reverse (reverse); =20 if (reverse) { reverse_save_bg =3D style.get_background (); reverse_save_fg =3D style.get_foreground (); + + if (!style_tui_current_position) + { + /* Switch to default style (reversed) while highlighting the + current position. */ + style =3D {}; + } } else { @@ -424,6 +433,8 @@ tui_set_reverse_mode (WINDOW *w, bool reverse) style.set_fg (reverse_save_fg); } =20 + style.set_reverse (reverse); + tui_apply_style (w, style); } =20 diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 31b6606636a..e24763c0072 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); } =20 +/* Implementation of the "set/show style tui-current-position" commands. = */ + +bool style_tui_current_position =3D 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 !=3D nullptr) + TUI_SRC_WIN->refill (); + if (TUI_DISASM_WIN !=3D nullptr) + TUI_DISASM_WIN->refill (); +} =20 /* 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); =20 + 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 indica= tor."), + _("\ +Show whether to style text highlighted by the TUI's current position indic= ator."), + _("\ +When enabled, the source and assembly code highlighted by the TUI's curren= t\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 9a92fa3a514..bdc6da034ef 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; =20 +/* 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 */