From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id B3BDA3857359 for ; Tue, 16 May 2023 08:43:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B3BDA3857359 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id D821D21B49; Tue, 16 May 2023 08:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684226637; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7vwYs+Z9kn+N1LWyJ6u7XuoyZ33ji0fzCDUGo4lBwTE=; b=KkFUJG71c7Tpd1ASlEQ7sMiQb5sp30P6myeagA5IssuFtCcYbq57SJQkr8hj5rNzD/U0bF /cZIUHOrh1Wh7bEdGc1gmJzL/SMl4isVgMF79tnN124Q+OP3NtF6hBlbGF4KiGsAxaGtqg JyCjqkTvsmD+kD/jOAlDco+guRHcLKs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684226637; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7vwYs+Z9kn+N1LWyJ6u7XuoyZ33ji0fzCDUGo4lBwTE=; b=gk4ng2Dd4LHWzOHCE65fLFvpya09DdqO1lhTohuGAtzRBk09Em8pMVlaNAVsFcYonSr2a7 JPjGNxJR5vAujFDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C121513A12; Tue, 16 May 2023 08:43:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MO46Lk1CY2SiMwAAMHmgww (envelope-from ); Tue, 16 May 2023 08:43:57 +0000 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/3] [gdb/tui] Add set tui status-window-mode Date: Tue, 16 May 2023 10:43:50 +0200 Message-Id: <20230516084352.27225-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230516084352.27225-1-tdevries@suse.de> References: <20230516084352.27225-1-tdevries@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,KAM_DMARC_STATUS,KAM_SHORT,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Currently, the status window attributes are hardcoded to standout. Add a new command "set tui status-window-mode " that controls the attributes for the status window, using the same 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 "^$re_noattr*$" $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 (); +} /* 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