* [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode>
2023-05-16 8:43 [PATCH 0/3] [gdb/tui] Allow highlighting in windows contents to be switched off Tom de Vries
@ 2023-05-16 8:43 ` Tom de Vries
2023-05-16 15:01 ` Eli Zaretskii
2023-05-19 19:11 ` Tom Tromey
2023-05-16 8:43 ` [PATCH 2/3] [gdb/tui] Use ">" marker in register window Tom de Vries
2023-05-16 8:43 ` [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off Tom de Vries
2 siblings, 2 replies; 8+ messages in thread
From: Tom de Vries @ 2023-05-16 8:43 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
Currently, the status window attributes are hardcoded to standout.
Add a new command "set tui status-window-mode <mode>" that controls the
attributes for the status window, using the same <mode> options as used
for "set tui border-mode" and "set tui active-border-mode".
The default is standout, so there's no change in behaviour.
Tested on x86_64-linux.
---
gdb/doc/gdb.texinfo | 6 +++
gdb/testsuite/gdb.tui/basic.exp | 13 +++++
gdb/testsuite/lib/tuiterm.exp | 84 +++++++++++++++++++++++++--------
gdb/tui/tui-stack.c | 10 ++--
gdb/tui/tui-win.c | 56 ++++++++++++++++++++++
gdb/tui/tui-win.h | 3 ++
6 files changed, 146 insertions(+), 26 deletions(-)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 531147f6e6b..77bc4323912 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -30302,6 +30302,12 @@ Use extra bright or bold mode.
Use extra bright or bold and standout mode.
@end table
+@item set tui status-window-mode @var{mode}
+@kindex set tui status-window-mode
+Select the display attributes for the contents of the status window.
+The @var{mode} is as for @code{set tui border-mode} and
+@code{set tui border-active-mode}. The default is standout mode.
+
@item set tui tab-width @var{nchars}
@kindex set tui tab-width
@kindex tabset
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index ec1e9945e8f..4cff8ea41d7 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -106,3 +106,16 @@ Term::check_contents "split layout contents" \
Term::check_box "source box in split layout" 0 0 80 8
Term::check_box "asm box in split layout" 0 7 80 8
+
+set re_noattr "\[^<\]"
+
+set status_window_line 15
+
+set status [Term::get_line_with_attrs $status_window_line]
+gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \
+ "status window: reverse"
+
+Term::command "set tui status-window-mode normal"
+
+set status [Term::get_line_with_attrs $status_window_line]
+gdb_assert { [regexp "^$re_noattr*$" $status] == 1} "status window: normal"
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 5e4235da942..8305e83e982 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -547,6 +547,18 @@ namespace eval Term {
}
}
+ # Reset the attributes in attributes array UPVAR_NAME to the default values.
+ proc reset_attrs { upvar_name } {
+ upvar $upvar_name var
+ array set var {
+ intensity normal
+ fg default
+ bg default
+ underline 0
+ reverse 0
+ }
+ }
+
# Select Graphic Rendition.
#
# https://vt100.net/docs/vt510-rm/SGR.html
@@ -557,11 +569,7 @@ namespace eval Term {
foreach item $args {
switch -exact -- $item {
"" - 0 {
- set _attrs(intensity) normal
- set _attrs(fg) default
- set _attrs(bg) default
- set _attrs(underline) 0
- set _attrs(reverse) 0
+ reset_attrs _attrs
}
1 {
set _attrs(intensity) bold
@@ -666,13 +674,7 @@ namespace eval Term {
set _cur_col 0
set _cur_row 0
set _resize_count 0
- array set _attrs {
- intensity normal
- fg default
- bg default
- underline 0
- reverse 0
- }
+ reset_attrs _attrs
_clear_lines 0 $_rows
}
@@ -873,10 +875,25 @@ namespace eval Term {
wait_for "^$str"
}
- # Return the text of screen line N, without attributes. Lines are
- # 0-based. If C is given, stop before column C. Columns are also
- # zero-based.
- proc get_line {n {c ""}} {
+ # Apply the attribute list in ATTRS to attributes array UPVAR_NAME.
+ # Return a string annotating the changed attributes.
+ proc apply_attrs { upvar_name attrs } {
+ set res ""
+ upvar $upvar_name var
+ foreach { attr val } $attrs {
+ if { $var($attr) != $val } {
+ append res "<$attr:$val>"
+ set var($attr) $val
+ }
+ }
+
+ return $res
+ }
+
+ # Return the text of screen line N. Lines are 0-based. If C is given,
+ # stop before column C. Columns are also zero-based. If ATTRS, annotate
+ # with attributes.
+ proc get_line_1 {n c attrs} {
variable _rows
# This can happen during resizing, if the cursor seems to
# temporarily be off-screen.
@@ -889,13 +906,37 @@ namespace eval Term {
variable _chars
set c [_default $c $_cols]
set x 0
+ if { $attrs } {
+ reset_attrs line_attrs
+ }
while {$x < $c} {
+ if { $attrs } {
+ set char_attrs [lindex $_chars($x,$n) 1]
+ append result [apply_attrs line_attrs $char_attrs]
+ }
append result [lindex $_chars($x,$n) 0]
incr x
}
+ if { $attrs } {
+ reset_attrs zero_attrs
+ set char_attrs [array get zero_attrs]
+ append result [apply_attrs line_attrs $char_attrs]
+ }
return $result
}
+ # Return the text of screen line N, without attributes. Lines are
+ # 0-based. If C is given, stop before column C. Columns are also
+ # zero-based.
+ proc get_line {n {c ""} } {
+ return [get_line_1 $n $c 0]
+ }
+
+ # As get_line, but annotate with attributes.
+ proc get_line_with_attrs {n {c ""}} {
+ return [get_line_1 $n $c 1]
+ }
+
# Get just the character at (X, Y).
proc get_char {x y} {
variable _chars
@@ -1069,8 +1110,8 @@ namespace eval Term {
}
# A debugging function to dump the current screen, with line
- # numbers.
- proc dump_screen {} {
+ # numbers. If ATTRS, annotate with attributes.
+ proc dump_screen { {attrs 0} } {
variable _rows
variable _cols
variable _cur_row
@@ -1080,10 +1121,15 @@ namespace eval Term {
for {set y 0} {$y < $_rows} {incr y} {
set fmt [format %5d $y]
- verbose -log "$fmt [get_line $y]"
+ verbose -log "$fmt [get_line_1 $y "" $attrs]"
}
}
+ # As dump_screen, but with attributes annotation.
+ proc dump_screen_with_attrs {} {
+ return [dump_screen 1]
+ }
+
# A debugging function to dump a box from the current screen, with line
# numbers.
proc dump_box { x y width height } {
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 76b8f066abb..153a285f37c 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -37,6 +37,7 @@
#include "tui/tui-winsource.h"
#include "tui/tui-file.h"
#include "tui/tui-location.h"
+#include "tui/tui-win.h"
#include "gdb_curses.h"
@@ -234,15 +235,10 @@ tui_locator_window::rerender ()
std::string string = make_status_line ();
scrollok (handle.get (), FALSE);
wmove (handle.get (), 0, 0);
- /* We ignore the return value from wstandout and wstandend, casting them
- 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 these
- macro to expand to code that causes the compiler to generate an
- unused-value warning. */
- (void) wstandout (handle.get ());
+ wattron (handle.get (), tui_status_window_attrs);
waddstr (handle.get (), string.c_str ());
wclrtoeol (handle.get ());
- (void) wstandend (handle.get ());
+ wattroff (handle.get (), tui_status_window_attrs);
refresh_window ();
wmove (handle.get (), 0, 0);
}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 6710b3e17e5..7926e2d7a18 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -346,6 +346,42 @@ tui_set_var_cmd (const char *null_args,
tui_rehighlight_all ();
}
+/* Value of "tui status-window-mode". */
+
+static const char *tui_status_window_mode = "standout";
+
+/* See tui-win.h. */
+
+int tui_status_window_attrs;
+
+/* Show value of "tui status-window-mode". */
+
+static void
+show_tui_status_window_mode (struct ui_file *file,
+ int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ gdb_printf (file, _("\
+The attribute mode to use for the TUI status window is \"%s\".\n"),
+ value);
+}
+
+/* Set value of "tui status-window-mode". */
+
+static void
+set_tui_status_window_mode (const char *null_args,
+ int from_tty, struct cmd_list_element *c)
+{
+ struct tui_translate *entry
+ = translate (tui_status_window_mode, tui_border_mode_translate);
+ if (tui_status_window_attrs == entry->value)
+ return;
+
+ tui_status_window_attrs = entry->value;
+ if (tui_active)
+ tui_show_locator_content ();
+}
\f
/* True if TUI resizes should print a message. This is used by the
@@ -1251,6 +1287,22 @@ This variable controls the attributes to use for the active window border:\n\
show_tui_active_border_mode,
&tui_setlist, &tui_showlist);
+ add_setshow_enum_cmd ("status-window-mode", no_class, tui_border_mode_enums,
+ &tui_status_window_mode, _("\
+Set the attribute mode to use for the TUI status window."), _("\
+Show the attribute mode to use for the TUI status window."), _("\
+This variable controls the attributes to use for the status window:\n\
+ normal normal display\n\
+ standout use highlight mode of terminal\n\
+ reverse use reverse video mode\n\
+ half use half bright\n\
+ half-standout use half bright and standout mode\n\
+ bold use extra bright or bold\n\
+ bold-standout use extra bright or bold with standout mode"),
+ set_tui_status_window_mode,
+ show_tui_status_window_mode,
+ &tui_setlist, &tui_showlist);
+
add_setshow_zuinteger_cmd ("tab-width", no_class,
&internal_tab_width, _("\
Set the tab width, in characters, for the TUI."), _("\
@@ -1305,4 +1357,8 @@ When enabled, the left margin will use '_' and '0' instead of spaces."),
tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
+
+ /* Assign default value. */
+ tui_status_window_attrs
+ = translate (tui_status_window_mode, tui_border_mode_translate)->value;
}
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 3d35f1dfb7f..5ace83a742a 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -38,6 +38,9 @@ extern chtype tui_border_hline;
extern int tui_border_attrs;
extern int tui_active_border_attrs;
+/* Attributes for the contents of the status window. */
+extern int tui_status_window_attrs;
+
extern bool tui_update_variables ();
extern void tui_initialize_win (void);
--
2.35.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode>
2023-05-16 8:43 ` [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode> Tom de Vries
@ 2023-05-16 15:01 ` Eli Zaretskii
2023-05-19 19:11 ` Tom Tromey
1 sibling, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2023-05-16 15:01 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches, tom
> Cc: Tom Tromey <tom@tromey.com>
> Date: Tue, 16 May 2023 10:43:50 +0200
> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
>
> Currently, the status window attributes are hardcoded to standout.
>
> Add a new command "set tui status-window-mode <mode>" that controls the
> attributes for the status window, using the same <mode> options as used
> for "set tui border-mode" and "set tui active-border-mode".
>
> The default is standout, so there's no change in behaviour.
>
> Tested on x86_64-linux.
> ---
> gdb/doc/gdb.texinfo | 6 +++
> gdb/testsuite/gdb.tui/basic.exp | 13 +++++
> gdb/testsuite/lib/tuiterm.exp | 84 +++++++++++++++++++++++++--------
> gdb/tui/tui-stack.c | 10 ++--
> gdb/tui/tui-win.c | 56 ++++++++++++++++++++++
> gdb/tui/tui-win.h | 3 ++
> 6 files changed, 146 insertions(+), 26 deletions(-)
Thanks, the documentation part is okay.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode>
2023-05-16 8:43 ` [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode> Tom de Vries
2023-05-16 15:01 ` Eli Zaretskii
@ 2023-05-19 19:11 ` Tom Tromey
2023-05-22 12:15 ` Tom de Vries
1 sibling, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2023-05-19 19:11 UTC (permalink / raw)
To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries, Tom Tromey
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> Currently, the status window attributes are hardcoded to standout.
Tom> Add a new command "set tui status-window-mode <mode>" that controls the
Tom> attributes for the status window, using the same <mode> options as used
Tom> for "set tui border-mode" and "set tui active-border-mode".
Tom> The default is standout, so there's no change in behaviour.
It seems a bit unfortunate to use the old TUI style system here.
Would it be possible to use the 'set style' system instead?
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode>
2023-05-19 19:11 ` Tom Tromey
@ 2023-05-22 12:15 ` Tom de Vries
0 siblings, 0 replies; 8+ messages in thread
From: Tom de Vries @ 2023-05-22 12:15 UTC (permalink / raw)
To: Tom Tromey, Tom de Vries via Gdb-patches
[-- Attachment #1: Type: text/plain, Size: 663 bytes --]
On 5/19/23 21:11, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
>
> Tom> Currently, the status window attributes are hardcoded to standout.
> Tom> Add a new command "set tui status-window-mode <mode>" that controls the
> Tom> attributes for the status window, using the same <mode> options as used
> Tom> for "set tui border-mode" and "set tui active-border-mode".
>
> Tom> The default is standout, so there's no change in behaviour.
>
> It seems a bit unfortunate to use the old TUI style system here.
> Would it be possible to use the 'set style' system instead?
I've given that a try.
Thanks,
- Tom
[-- Attachment #2: 0001-gdb-tui-Add-set-style-tui-status-window.patch --]
[-- Type: text/x-patch, Size: 9725 bytes --]
From 35b33395b45affa707059df48dbeab85efb00e38 Mon Sep 17 00:00:00 2001
From: Tom de Vries <tdevries@suse.de>
Date: Sat, 13 May 2023 20:52:55 +0200
Subject: [PATCH] [gdb/tui] Add set style tui-status-window
Currently, the status window attributes are hardcoded to standout.
Add a new command "set style tui-status-window foreground/background/mode"
that controls the foreground and background colors, and the attributes for the
status window, where the attributes use the same <mode> options as used
for "set tui border-mode" and "set tui active-border-mode".
The default is none/none/standout, so there's no change in behaviour.
Tested on x86_64-linux.
---
gdb/cli/cli-style.c | 12 +++++++
gdb/cli/cli-style.h | 10 ++++++
gdb/doc/gdb.texinfo | 9 +++++
gdb/testsuite/gdb.tui/basic.exp | 5 +++
gdb/tui/tui-stack.c | 16 +++++----
gdb/tui/tui-win.c | 58 +++++++++++++++++++++++++++++++++
gdb/tui/tui-win.h | 3 ++
7 files changed, 106 insertions(+), 7 deletions(-)
diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c
index cd510b440db..29aa2d92cd3 100644
--- a/gdb/cli/cli-style.c
+++ b/gdb/cli/cli-style.c
@@ -101,6 +101,10 @@ cli_style_option tui_active_border_style ("tui-active-border",
/* See cli-style.h. */
+cli_style_option tui_status_window_style ("tui-status-window", ui_file_style::NONE);
+
+/* See cli-style.h. */
+
cli_style_option metadata_style ("metadata", ui_file_style::DIM);
/* See cli-style.h. */
@@ -469,6 +473,14 @@ TUI window that does have the focus."),
&style_show_list,
true);
+ tui_status_window_style.add_setshow_commands (no_class, _("\
+TUI status window styling.\n\
+Configure TUI status window colors\n\
+The \"tui-status-window\" style is used when GDB displays the status window."),
+ &style_set_list,
+ &style_show_list,
+ true);
+
version_style.add_setshow_commands (no_class, _("\
Version string display styling.\n\
Configure colors used to display the GDB version string."),
diff --git a/gdb/cli/cli-style.h b/gdb/cli/cli-style.h
index f315241ccb4..b00c798caec 100644
--- a/gdb/cli/cli-style.h
+++ b/gdb/cli/cli-style.h
@@ -58,6 +58,13 @@ class cli_style_option
/* Same as SET_LIST but for the show command list. */
struct cmd_list_element *show_list () { return m_show_list; };
+ /* Return the 'set style NAME' command list, that can be used
+ to add commands to. */
+ struct cmd_list_element **modifiable_set_list () { return &m_set_list; };
+
+ /* Same as MODIFIABLE_SET_LIST but for the show command list. */
+ struct cmd_list_element **modifiable_show_list () { return &m_show_list; };
+
/* This style can be observed for any changes. */
gdb::observers::observable<> changed;
@@ -138,6 +145,9 @@ extern cli_style_option tui_border_style;
/* The border style of a TUI window that does have the focus. */
extern cli_style_option tui_active_border_style;
+/* The style of a TUI status window. */
+extern cli_style_option tui_status_window_style;
+
/* The style to use for the GDB version string. */
extern cli_style_option version_style;
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f23bcc5f3f8..c0e33c951b4 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27300,6 +27300,13 @@ general styling to @value{GDBN}. @xref{TUI Configuration}.
Control the styling of the active TUI border; that is, the TUI window
that has the focus.
+@item tui-status-window
+Control the styling of the TUI status window. Note that, unlike other
+styling options, the tui-border has a mode rather than an intensity.
+The values for mode are the same as for @ref{set tui border-mode} and
+@ref{set tui active-border-mode}. By default, this style's mode is
+standout, and the foreground and background colors are none.
+
@item disassembler comment
Control the styling of comments in the disassembler output. These are
managed with the @code{set style disassembler comment} family of
@@ -30273,8 +30280,10 @@ Use the Alternate Character Set to draw the border. The border is
drawn using character line graphics if the terminal supports them.
@end table
+@anchor{set tui border-mode}
@item set tui border-mode @var{mode}
@kindex set tui border-mode
+@anchor{set tui active-border-mode}
@itemx set tui active-border-mode @var{mode}
@kindex set tui active-border-mode
Select the display attributes for the borders of the inactive windows
diff --git a/gdb/testsuite/gdb.tui/basic.exp b/gdb/testsuite/gdb.tui/basic.exp
index 2c55c2b95bc..1bfcec21256 100644
--- a/gdb/testsuite/gdb.tui/basic.exp
+++ b/gdb/testsuite/gdb.tui/basic.exp
@@ -114,3 +114,8 @@ set status_window_line 15
set status [Term::get_line_with_attrs $status_window_line]
gdb_assert { [regexp "^<reverse:1>$re_noattr*<reverse:0>$" $status] == 1} \
"status window: reverse"
+
+Term::command "set style tui-status-window mode normal"
+
+set status [Term::get_line_with_attrs $status_window_line]
+gdb_assert { [regexp "^$re_noattr*$" $status] == 1} "status window: normal"
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 76b8f066abb..46504b90f98 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -37,6 +37,9 @@
#include "tui/tui-winsource.h"
#include "tui/tui-file.h"
#include "tui/tui-location.h"
+#include "tui/tui-win.h"
+#include "tui/tui-io.h"
+#include "cli/cli-style.h"
#include "gdb_curses.h"
@@ -234,15 +237,14 @@ tui_locator_window::rerender ()
std::string string = make_status_line ();
scrollok (handle.get (), FALSE);
wmove (handle.get (), 0, 0);
- /* We ignore the return value from wstandout and wstandend, casting them
- 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 these
- macro to expand to code that causes the compiler to generate an
- unused-value warning. */
- (void) wstandout (handle.get ());
+
+ if (cli_styling)
+ tui_apply_style (handle.get (), tui_status_window_style.style ());
+ wattron (handle.get (), tui_status_window_attrs);
waddstr (handle.get (), string.c_str ());
wclrtoeol (handle.get ());
- (void) wstandend (handle.get ());
+ wattroff (handle.get (), tui_status_window_attrs);
+ tui_apply_style (handle.get (), ui_file_style ());
refresh_window ();
wmove (handle.get (), 0, 0);
}
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 6710b3e17e5..875149cd38b 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -346,6 +346,42 @@ tui_set_var_cmd (const char *null_args,
tui_rehighlight_all ();
}
+/* Value of "tui status-window-mode". */
+
+static const char *tui_status_window_mode = "standout";
+
+/* See tui-win.h. */
+
+int tui_status_window_attrs;
+
+/* Show value of "tui status-window-mode". */
+
+static void
+show_tui_status_window_mode (struct ui_file *file,
+ int from_tty,
+ struct cmd_list_element *c,
+ const char *value)
+{
+ gdb_printf (file, _("\
+The attribute mode to use for the TUI status window is \"%s\".\n"),
+ value);
+}
+
+/* Set value of "tui status-window-mode". */
+
+static void
+set_tui_status_window_mode (const char *null_args,
+ int from_tty, struct cmd_list_element *c)
+{
+ struct tui_translate *entry
+ = translate (tui_status_window_mode, tui_border_mode_translate);
+ if (tui_status_window_attrs == entry->value)
+ return;
+
+ tui_status_window_attrs = entry->value;
+ if (tui_active)
+ tui_show_locator_content ();
+}
\f
/* True if TUI resizes should print a message. This is used by the
@@ -1251,6 +1287,23 @@ This variable controls the attributes to use for the active window border:\n\
show_tui_active_border_mode,
&tui_setlist, &tui_showlist);
+ add_setshow_enum_cmd ("mode", no_class, tui_border_mode_enums,
+ &tui_status_window_mode, _("\
+Set the attribute mode to use for the TUI status window."), _("\
+Show the attribute mode to use for the TUI status window."), _("\
+This variable controls the attributes to use for the status window:\n\
+ normal normal display\n\
+ standout use highlight mode of terminal\n\
+ reverse use reverse video mode\n\
+ half use half bright\n\
+ half-standout use half bright and standout mode\n\
+ bold use extra bright or bold\n\
+ bold-standout use extra bright or bold with standout mode"),
+ set_tui_status_window_mode,
+ show_tui_status_window_mode,
+ tui_status_window_style.modifiable_set_list (),
+ tui_status_window_style.modifiable_show_list ());
+
add_setshow_zuinteger_cmd ("tab-width", no_class,
&internal_tab_width, _("\
Set the tab width, in characters, for the TUI."), _("\
@@ -1305,4 +1358,9 @@ When enabled, the left margin will use '_' and '0' instead of spaces."),
tui_border_style.changed.attach (tui_rehighlight_all, "tui-win");
tui_active_border_style.changed.attach (tui_rehighlight_all, "tui-win");
+ tui_status_window_style.changed.attach (tui_show_locator_content, "tui-win");
+
+ /* Assign default value. */
+ tui_status_window_attrs
+ = translate (tui_status_window_mode, tui_border_mode_translate)->value;
}
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 3d35f1dfb7f..5ace83a742a 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -38,6 +38,9 @@ extern chtype tui_border_hline;
extern int tui_border_attrs;
extern int tui_active_border_attrs;
+/* Attributes for the contents of the status window. */
+extern int tui_status_window_attrs;
+
extern bool tui_update_variables ();
extern void tui_initialize_win (void);
base-commit: 5a8f5960fd8fc5136fc24ddaf08a25c73f9c8329
--
2.35.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] [gdb/tui] Use ">" marker in register window
2023-05-16 8:43 [PATCH 0/3] [gdb/tui] Allow highlighting in windows contents to be switched off Tom de Vries
2023-05-16 8:43 ` [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode> Tom de Vries
@ 2023-05-16 8:43 ` Tom de Vries
2023-05-16 8:43 ` [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off Tom de Vries
2 siblings, 0 replies; 8+ messages in thread
From: Tom de Vries @ 2023-05-16 8:43 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
In TUI's source and assembly windows, we show the current execution point
using both:
- highlighting, and
- a ">" marker.
In TUI's register window, we show changed registers just using highlighting.
Make behaviour more similar by also using a ">" marker for changed registers.
This in preparation for a "set tui contents-highlight on/off" that optionally
disables the highlighting, leaving just the ">" markers.
Tested on x86_64-linux.
---
gdb/testsuite/gdb.tui/regs-2.c | 36 +++++++++++++++++
gdb/testsuite/gdb.tui/regs-2.exp | 66 ++++++++++++++++++++++++++++++++
gdb/tui/tui-regs.c | 45 +++++++++++++++++++++-
3 files changed, 145 insertions(+), 2 deletions(-)
create mode 100644 gdb/testsuite/gdb.tui/regs-2.c
create mode 100644 gdb/testsuite/gdb.tui/regs-2.exp
diff --git a/gdb/testsuite/gdb.tui/regs-2.c b/gdb/testsuite/gdb.tui/regs-2.c
new file mode 100644
index 00000000000..d65293e31b2
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/regs-2.c
@@ -0,0 +1,36 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ 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/>. */
+
+int
+foo (void)
+{
+ return 1;
+}
+
+int
+bar (void)
+{
+ return 2;
+}
+
+int
+main (void)
+{
+ foo ();
+ bar ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.tui/regs-2.exp b/gdb/testsuite/gdb.tui/regs-2.exp
new file mode 100644
index 00000000000..50f3d48512d
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/regs-2.exp
@@ -0,0 +1,66 @@
+# 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/>.
+
+# Test of ">" marker in TUI register window.
+
+require allow_tui_tests
+require {!is_remote host}
+require is_x86_64_m64_target
+
+tuiterm_env
+
+standard_testfile
+
+if { [build_executable "failed to prepare" ${testfile} ${srcfile}] == -1 } {
+ return -1
+}
+
+set cols 80
+set lines 24
+set reg_lines 8
+set screen_dim [list $lines $cols]
+set reg_box [list 0 0 $cols $reg_lines]
+
+Term::clean_restart {*}$screen_dim $testfile
+
+if {![runto_main]} {
+ perror "test suppressed"
+ return
+}
+
+if {![Term::enter_tui]} {
+ unsupported "TUI not supported"
+ return
+}
+
+Term::command "layout regs"
+Term::check_box "register box" {*}$reg_box
+
+set re_border "\\|"
+set re_ws " "
+set re_any "\[^\r\n\]"
+
+set re "B\\+>$re_ws*$decimal$re_ws*foo \\(\\);$re_ws*"
+Term::check_contents "before call to foo" "$re_border$re$re_border"
+
+# Step over foo, set rax to 1.
+Term::command "next"
+set re "rax$re_ws*0x1$re_ws$re_any*"
+Term::check_contents "rax after foo" "$re_border$re$re_border"
+
+# Step over bar, set rax to 2. Check that the ">" marker is used.
+Term::command "next"
+set re "rax$re_ws*>0x2$re_ws$re_any*"
+Term::check_contents "rax after bar" "$re_border$re$re_border"
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index 50a238401df..af3b21b0f9d 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -494,8 +494,49 @@ tui_data_item_window::rerender (WINDOW *handle, int field_width)
to code that causes the compiler to generate an unused-value
warning. */
(void) wstandout (handle);
-
- mvwaddnstr (handle, y, x, content.c_str (), field_width - 1);
+
+ const char *s = content.c_str ();
+ int print_width = field_width - 1;
+ if (highlight)
+ {
+ off_t last_space_offset;
+
+ /* Calculate last_space_offset. */
+ {
+ const char *i = s;
+ const char *last_space = nullptr;
+ /* Skip register name. */
+ while (*i != ' ')
+ i++;
+ /* Find last space before value. */
+ while (*i == ' ')
+ {
+ last_space = i;
+ i++;
+ }
+ last_space_offset = last_space - s;
+ }
+
+ /* Write the bit before the last space. */
+ int total = 0;
+ int n = last_space_offset;
+ n = std::min (n, print_width);
+ mvwaddnstr (handle, y, x, s, n);
+ total += n;
+ print_width -= n;
+
+ /* Replace the last space with ">". */
+ n = 1;
+ n = std::min (n, print_width);
+ waddnstr (handle, ">", n);
+ total += n;
+ print_width -= n;
+
+ /* Write the rest. */
+ waddnstr (handle, s + total, print_width);
+ }
+ else
+ mvwaddnstr (handle, y, x, s, print_width);
if (content.size () < field_width)
waddstr (handle, n_spaces (field_width - content.size ()));
--
2.35.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off
2023-05-16 8:43 [PATCH 0/3] [gdb/tui] Allow highlighting in windows contents to be switched off Tom de Vries
2023-05-16 8:43 ` [PATCH 1/3] [gdb/tui] Add set tui status-window-mode <mode> Tom de Vries
2023-05-16 8:43 ` [PATCH 2/3] [gdb/tui] Use ">" marker in register window Tom de Vries
@ 2023-05-16 8:43 ` Tom de Vries
2023-05-16 15:02 ` Eli Zaretskii
2 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2023-05-16 8:43 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 77bc4323912..836cf9623ad 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -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
diff --git a/gdb/testsuite/gdb.tui/source.exp b/gdb/testsuite/gdb.tui/source.exp
new file mode 100644
index 00000000000..d6b231dc43f
--- /dev/null
+++ b/gdb/testsuite/gdb.tui/source.exp
@@ -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"
diff --git a/gdb/tui/tui-regs.c b/gdb/tui/tui-regs.c
index af3b21b0f9d..43724d9dd14 100644
--- a/gdb/tui/tui-regs.c
+++ b/gdb/tui/tui-regs.c
@@ -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
diff --git a/gdb/tui/tui-regs.h b/gdb/tui/tui-regs.h
index 5adff6300aa..e0f299d4410 100644
--- a/gdb/tui/tui-regs.h
+++ b/gdb/tui/tui-regs.h
@@ -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'
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index 7926e2d7a18..e0ad6551c59 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -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."),
diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h
index 5ace83a742a..ab1a4e177a9 100644
--- a/gdb/tui/tui-win.h
+++ b/gdb/tui/tui-win.h
@@ -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 */
diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c
index 3c4ce501e5e..f245eecc965 100644
--- a/gdb/tui/tui-winsource.c
+++ b/gdb/tui/tui-winsource.c
@@ -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);
}
--
2.35.3
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off
2023-05-16 8:43 ` [PATCH 3/3] [gdb/tui] Add set tui contents-highlight on/off Tom de Vries
@ 2023-05-16 15:02 ` Eli Zaretskii
0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2023-05-16 15:02 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches, tom
> 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>
^ permalink raw reply [flat|nested] 8+ messages in thread