From 35b33395b45affa707059df48dbeab85efb00e38 Mon Sep 17 00:00:00 2001 From: Tom de Vries 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 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 "^$re_noattr*$" $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 (); +} /* 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