[gdb/tui] Add set style tui-status-window
Commit Message
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(-)
base-commit: 5a8f5960fd8fc5136fc24ddaf08a25c73f9c8329
Comments
> Cc: Tom Tromey <tom@tromey.com>
> Date: Mon, 22 May 2023 15:15:40 +0200
> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
>
> --- 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
This use of @ref is not recommended. It looks better in the HTML
version of the manual, but in Info and in PDF it looks like a typo or
editing error. I suggest to use @pxref instead, like this:
The values for mode are the same as for tui border-mode (@pxref{set
tui border-mode}) and tui active-border-mode.
It might look less elegant in HTML, but much better in other formats.
> +standout, and the foreground and background colors are none.
^^^^
"@code{none}", perhaps?
> +@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
If you go with my suggestion above about @pxref, you don't need the
second one of these @anchor's.
Thanks.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
On 5/22/23 15:47, Eli Zaretskii wrote:
>> Cc: Tom Tromey <tom@tromey.com>
>> Date: Mon, 22 May 2023 15:15:40 +0200
>> From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
>>
>> --- 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
>
> This use of @ref is not recommended. It looks better in the HTML
> version of the manual, but in Info and in PDF it looks like a typo or
> editing error. I suggest to use @pxref instead, like this:
>
> The values for mode are the same as for tui border-mode (@pxref{set
> tui border-mode}) and tui active-border-mode.
>
> It might look less elegant in HTML, but much better in other formats.
>
Done.
>> +standout, and the foreground and background colors are none.
> ^^^^
> "@code{none}", perhaps?
>
Done.
>> +@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
>
> If you go with my suggestion above about @pxref, you don't need the
> second one of these @anchor's.
>
Done.
Thanks for the review, updated patch attached.
Thanks,
- Tom
> Date: Mon, 22 May 2023 16:22:32 +0200
> Cc: gdb-patches@sourceware.org, Tom Tromey <tom@tromey.com>
> From: Tom de Vries <tdevries@suse.de>
>
> Thanks for the review, updated patch attached.
OK for the documentation part, thanks.
@@ -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."),
@@ -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;
@@ -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
@@ -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"
@@ -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);
}
@@ -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 ();
+}
/* 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;
}
@@ -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);