> Cc: Tom Tromey <tom@tromey.com>
> Date: Tue, 16 May 2023 10:43:52 +0200
> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
>
> TUI highlights various parts of TUI windows:
> - highlighting of the current execution point in the assembly and source
> windows,
> - highlighting of changed registers in the register window.
>
> Add a new command "set tui contents-highlight on/off" that allows us to disable
> this.
>
> The default is on, so there's no change in behaviour.
>
> Note that the highlighting in all three windows is shadowed by the ">" marker,
> so we're not losing information by switching off the highlighting.
>
> Tested on x86_64-linux.
> ---
> gdb/doc/gdb.texinfo | 7 ++++
> gdb/testsuite/gdb.tui/source.exp | 59 ++++++++++++++++++++++++++++++++
> gdb/tui/tui-regs.c | 4 +--
> gdb/tui/tui-regs.h | 4 +--
> gdb/tui/tui-win.c | 39 +++++++++++++++++++++
> gdb/tui/tui-win.h | 4 +++
> gdb/tui/tui-winsource.c | 4 +--
> 7 files changed, 115 insertions(+), 6 deletions(-)
> create mode 100644 gdb/testsuite/gdb.tui/source.exp
The documentation part is OK, thanks.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
@@ -30322,6 +30322,13 @@ The default display uses more space for line numbers; the compact
display uses only as much space as is needed for the line numbers in
the current file.
+@item set tui contents-highlight @r{[}on@r{|}off@r{]}
+@kindex set tui contents-highlight
+Determine whether TUI windows contents is highlighted, such as highlighting
+of the current execution point in the assembly and source windows,
+and highlighting of changed registers in the register window. The
+default is @code{on}.
+
@kindex set debug tui
@item set debug tui @r{[}on|off@r{]}
Turn on or off display of @value{GDBN} internal debug messages relating
new file mode 100644
@@ -0,0 +1,59 @@
+# Copyright 2023 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Check that "set tui compact-source on" has the intended effect.
+
+require allow_tui_tests
+
+tuiterm_env
+
+standard_testfile main-one-line.c
+
+if {[build_executable "failed to prepare" ${testfile} ${srcfile}] == -1} {
+ return -1
+}
+
+Term::clean_restart 24 80 $binfile
+
+gdb_test_no_output "maint set tui-left-margin-verbose on"
+
+if { ![runto_main] } {
+ return -1
+}
+
+if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+}
+
+
+set screen_line_with_main 6
+set screen_line [Term::get_line_with_attrs $screen_line_with_main]
+
+set src_line_with_main [gdb_get_line_number "int main"]
+
+set re "int main () { return 0; }"
+set re "${src_line_with_main}_<reverse:1>$re<reverse:0>"
+set re [string_to_regexp $re]
+gdb_assert { [regexp $re $screen_line] == 1} "src line: reverse"
+
+Term::command "set tui contents-highlight off"
+Term::command "set style enabled off"
+set screen_line [Term::get_line_with_attrs $screen_line_with_main]
+
+set re "int main () { return 0; }"
+set re "${src_line_with_main}_$re "
+set re [string_to_regexp $re]
+gdb_assert { [regexp $re $screen_line] == 1} "src line: normal"
@@ -487,7 +487,7 @@ tui_data_window::check_register_values (frame_info_ptr frame)
void
tui_data_item_window::rerender (WINDOW *handle, int field_width)
{
- if (highlight)
+ if (tui_contents_highlight && highlight)
/* We ignore the return value, casting it to void in order to avoid
a compiler warning. The warning itself was introduced by a patch
to ncurses 5.7 dated 2009-08-29, changing this macro to expand
@@ -540,7 +540,7 @@ tui_data_item_window::rerender (WINDOW *handle, int field_width)
if (content.size () < field_width)
waddstr (handle, n_spaces (field_width - content.size ()));
- if (highlight)
+ if (tui_contents_highlight && highlight)
/* We ignore the return value, casting it to void in order to avoid
a compiler warning. The warning itself was introduced by a patch
to ncurses 5.7 dated 2009-08-29, changing this macro to expand
@@ -68,6 +68,8 @@ struct tui_data_window : public tui_win_info
return m_current_group;
}
+ void rerender () override;
+
protected:
void do_scroll_vertical (int num_to_scroll) override;
@@ -75,8 +77,6 @@ struct tui_data_window : public tui_win_info
{
}
- void rerender () override;
-
private:
/* Display the registers in the content from 'start_element_no'
@@ -916,6 +916,33 @@ tui_show_tab_width (struct ui_file *file, int from_tty,
/* See tui-win.h. */
+bool tui_contents_highlight = true;
+
+static void
+show_tui_contents_highlight (ui_file *file,
+ int from_tty,
+ cmd_list_element *c,
+ const char *value)
+{
+ gdb_printf (file, _("\
+Highlighting TUI windows content is %s.\n"),
+ value);
+}
+
+static void
+set_tui_contents_highlight (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 ();
+ if (TUI_DATA_WIN != nullptr)
+ TUI_DATA_WIN->rerender ();
+}
+
+/* See tui-win.h. */
+
bool compact_source = false;
/* Callback for "set tui compact-source". */
@@ -1330,6 +1357,18 @@ in a compact form. The compact form uses less horizontal space."),
tui_set_compact_source, tui_show_compact_source,
&tui_setlist, &tui_showlist);
+ add_setshow_boolean_cmd ("contents-highlight", class_tui,
+ &tui_contents_highlight, _("\
+Set whether TUI windows contents is highlighted."), _("\
+Show whether TUI windows contents is highlighted."), _("\
+Determine whether TUI windows contents is highlighted, such as highlighting\n\
+of the current execution point in the assembly and source windows,\n\
+highlighting of the status window, and highlighting of changed registers in\n\
+the register window."),
+ set_tui_contents_highlight,
+ show_tui_contents_highlight,
+ &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."),
@@ -61,4 +61,8 @@ extern bool style_tui_current_position;
/* Whether to replace the spaces in the left margin with '_' and '0'. */
extern bool tui_left_margin_verbose;
+/* Whether to highlight various parts of the windows content using standout
+ and reverse. */
+extern bool tui_contents_highlight;
+
#endif /* TUI_TUI_WIN_H */
@@ -301,13 +301,13 @@ tui_source_window_base::show_source_line (int lineno)
struct tui_source_element *line;
line = &m_content[lineno];
- if (line->is_exec_point)
+ if (tui_contents_highlight && line->is_exec_point)
tui_set_reverse_mode (m_pad.get (), true);
wmove (m_pad.get (), lineno, 0);
puts_to_pad_with_skip (line->line.c_str (), m_pad_offset);
- if (line->is_exec_point)
+ if (tui_contents_highlight && line->is_exec_point)
tui_set_reverse_mode (m_pad.get (), false);
}