From patchwork Mon May 8 14:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 68908 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6987A3854159 for ; Mon, 8 May 2023 14:11:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6987A3854159 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1683555073; bh=5Q1Sj6beMVK95FDbmZDbMhWia5MHPcWJRkpN1UAf9dM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=h8GD5WiVRF+la2T9peAU0QTH5q3VGG6KpwsLTAvT1qc0xOnj4SOly8UNvNk8xzCNO GcrRx1gxztx5em4yrUpINS6y0ObfiDwZZQuhIO5ZMMeiJ6MHKDLUibWbLAHlTsSjx2 1t34KJvE7dr106w23xS+j60Fz/sjQzPXy9Jad024= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 148573858C2B for ; Mon, 8 May 2023 14:10:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 148573858C2B 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-out2.suse.de (Postfix) with ESMTPS id 4C5C91FF37; Mon, 8 May 2023 14:10:40 +0000 (UTC) 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 D0E001346B; Mon, 8 May 2023 14:10:39 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cFnVLt8CWWSpAwAAMHmgww (envelope-from ); Mon, 08 May 2023 14:10:39 +0000 To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 3/3] [gdb/tui] Add tui border-kind active-ascii Date: Mon, 8 May 2023 16:10:36 +0200 Message-Id: <20230508141036.22723-4-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230508141036.22723-1-tdevries@suse.de> References: <20230508141036.22723-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tom de Vries via Gdb-patches From: Tom de Vries Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" I noticed that after configuring TUI to just use plain ascii borders: ... (gdb) show tui tui active-border-mode: The attribute mode to use for the active TUI window \ border is "normal". tui border-kind: The kind of border for TUI windows is "ascii". tui border-mode: The attribute mode to use for the TUI window borders is \ "normal". ... there was no longer something to identify whether a window has focus. Add a new border-kind active-ascii, that's like border-kind ascii for inactive windows but uses '+' as hline and vline (instead of '-' and '|') for an active window. In other words, this border for an inactive window: ... +-+ | | +-+ ... and this border for an active window: ... +++ + + +++ ... Tested on x86_64-linux. Reviewed-By: Eli Zaretskii --- gdb/doc/gdb.texinfo | 4 ++ gdb/testsuite/gdb.tui/tui-focus.exp | 7 +++- gdb/testsuite/lib/tuiterm.exp | 49 ++++++++++++++----------- gdb/tui/tui-win.c | 57 ++++++++++++++++++++++++++--- gdb/tui/tui-win.h | 6 +++ gdb/tui/tui-wingeneral.c | 17 ++++++--- 6 files changed, 107 insertions(+), 33 deletions(-) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 8c4177c1901..f5fda5f57a8 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -30267,6 +30267,10 @@ Use a space character to draw the border. @item ascii Use @sc{ascii} characters @samp{+}, @samp{-} and @samp{|} to draw the border. +@item active-ascii +Use @sc{ascii} character @samp{+} to draw the border of an active +window, otherwise as border-kind @code{ascii}. + @item acs Use the Alternate Character Set to draw the border. The border is drawn using character line graphics if the terminal supports them. diff --git a/gdb/testsuite/gdb.tui/tui-focus.exp b/gdb/testsuite/gdb.tui/tui-focus.exp index 72f80523af3..42629821888 100644 --- a/gdb/testsuite/gdb.tui/tui-focus.exp +++ b/gdb/testsuite/gdb.tui/tui-focus.exp @@ -41,6 +41,10 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \ unsupported "TUI not supported" return } + gdb_test_no_output "set tui border-kind active-ascii" + + # Initial value, will be effective if "focus $window" fails. + set src_focus 1 Term::command_no_prompt_prefix "focus $window" @@ -53,6 +57,7 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \ } else { Term::check_region_contents "check focus message" 0 16 80 1 \ "^Focus set to $window window\\.\\s*" + set src_focus [string equal $window "src"] } } else { if {$window == "unknown"} { @@ -64,7 +69,7 @@ foreach spec {{src true} {cmd true} {status true} {regs false} \ } } - Term::check_box "check src box" 0 0 80 15 + Term::check_box "check src box" 0 0 80 15 $src_focus # At one point the following 'focus prev' command would trigger a # crash in GDB, GDB was allowing users to set focus to the 'status' diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 5e4235da942..ef89d0a8a2c 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -928,30 +928,33 @@ namespace eval Term { # Helper function for check_box. Returns empty string if the box # is found, description of why not otherwise. - proc _check_box {x y width height} { + proc _check_box {x y width height hline vline corner} { set x2 [expr {$x + $width - 1}] set y2 [expr {$y + $height - 1}] - verbose -log "_check_box x=$x, y=$y, x2=$x2, y2=$y2, width=$width, height=$height" + verbose -log [join [list _check_box x=$x y=$y x2=$x2 y2=$y2 \ + width=$width height=$height \ + hline=$hline vline=$vline \ + corner=$corner] ", "] set c [get_char $x $y] - if {$c != "+"} { - return "ul corner is $c, not +" + if {$c != $corner} { + return "ul corner is $c, not $corner" } set c [get_char $x $y2] - if {$c != "+"} { - return "ll corner is $c, not +" + if {$c != $corner} { + return "ll corner is $c, not $corner" } set c [get_char $x2 $y] - if {$c != "+"} { - return "ur corner is $c, not +" + if {$c != $corner} { + return "ur corner is $c, not $corner" } set c [get_char $x2 $y2] if {$c != "+"} { - return "lr corner is $c, not +" + return "lr corner is $c, not $corner" } # Note we do not check the full horizonal borders of the box. @@ -960,25 +963,25 @@ namespace eval Term { # title should appear as '+-VERY LONG TITLE-+', so we can # check for the '+-' on the left, and '-+' on the right. set c [get_char [expr {$x + 1}] $y] - if {$c != "-"} { - return "ul title padding is $c, not -" + if {$c != $hline} { + return "ul title padding is $c, not $hline" } set c [get_char [expr {$x2 - 1}] $y] - if {$c != "-"} { - return "ul title padding is $c, not -" + if {$c != $hline} { + return "ul title padding is $c, not $hline" } # Now check the vertical borders. for {set i [expr {$y + 1}]} {$i < $y2 - 1} {incr i} { set c [get_char $x $i] - if {$c != "|"} { - return "left side $i is $c, not |" + if {$c != $vline} { + return "left side $i is $c, not $vline" } set c [get_char $x2 $i] - if {$c != "|"} { - return "right side $i is $c, not |" + if {$c != $vline} { + return "right side $i is $c, not $vline" } } @@ -986,9 +989,13 @@ namespace eval Term { } # Check for a box at the given coordinates. - proc check_box {test_name x y width height} { + proc check_box {test_name x y width height {active 0}} { dump_box $x $y $width $height - set why [_check_box $x $y $width $height] + if { $active } { + set why [_check_box $x $y $width $height "+" "+" "+"] + } else { + set why [_check_box $x $y $width $height "-" "|" "+"] + } if {$why == ""} { pass $test_name } else { @@ -996,7 +1003,7 @@ namespace eval Term { } } - # Check whether the text contents of the terminal match the +# Check whether the text contents of the terminal match the # regular expression. Note that text styling is not considered. proc check_contents {test_name regexp} { dump_screen @@ -1058,7 +1065,7 @@ namespace eval Term { variable _chars dump_box $x $y $width $height - set why [_check_box $x $y $width $height] + set why [_check_box $x $y $width $height "-" "|" "+"] if {$why != ""} { fail "$test_name (box check: $why)" return diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index fedcac4b560..ef8cb120657 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -93,6 +93,7 @@ static void parse_scrolling_args (const char *, static const char *const tui_border_kind_enums[] = { "space", "ascii", + "active-ascii", "acs", NULL }; @@ -137,6 +138,7 @@ static struct tui_translate tui_border_mode_translate[] = { static struct tui_translate tui_border_kind_translate_vline[] = { { "space", ' ' }, { "ascii", '|' }, + { "active-ascii", '+' }, { "acs", -1 }, { 0, 0 }, { "ascii", '|' } @@ -145,6 +147,7 @@ static struct tui_translate tui_border_kind_translate_vline[] = { static struct tui_translate tui_border_kind_translate_hline[] = { { "space", ' ' }, { "ascii", '-' }, + { "active-ascii", '+' }, { "acs", -1 }, { 0, 0 }, { "ascii", '-' } @@ -153,6 +156,7 @@ static struct tui_translate tui_border_kind_translate_hline[] = { static struct tui_translate tui_border_kind_translate_ulcorner[] = { { "space", ' ' }, { "ascii", '+' }, + { "active-ascii", '+' }, { "acs", -1 }, { 0, 0 }, { "ascii", '+' } @@ -161,6 +165,7 @@ static struct tui_translate tui_border_kind_translate_ulcorner[] = { static struct tui_translate tui_border_kind_translate_urcorner[] = { { "space", ' ' }, { "ascii", '+' }, + { "active-ascii", '+' }, { "acs", -1 }, { 0, 0 }, { "ascii", '+' } @@ -169,6 +174,7 @@ static struct tui_translate tui_border_kind_translate_urcorner[] = { static struct tui_translate tui_border_kind_translate_llcorner[] = { { "space", ' ' }, { "ascii", '+' }, + { "active-ascii", '+' }, { "acs", -1 }, { 0, 0 }, { "ascii", '+' } @@ -177,6 +183,7 @@ static struct tui_translate tui_border_kind_translate_llcorner[] = { static struct tui_translate tui_border_kind_translate_lrcorner[] = { { "space", ' ' }, { "ascii", '+' }, + { "active-ascii", '+' }, { "acs", -1 }, { 0, 0 }, { "ascii", '+' } @@ -253,6 +260,12 @@ chtype tui_border_ulcorner; chtype tui_border_urcorner; chtype tui_border_llcorner; chtype tui_border_lrcorner; +chtype tui_active_border_vline; +chtype tui_active_border_hline; +chtype tui_active_border_ulcorner; +chtype tui_active_border_urcorner; +chtype tui_active_border_llcorner; +chtype tui_active_border_lrcorner; int tui_border_attrs; int tui_active_border_attrs; @@ -323,30 +336,61 @@ tui_update_variables () set_border_attrs (&tui_active_border_attrs, tui_active_border_mode, tui_border_mode_translate, &need_redraw); + /* For inactive borders, active-ascii is the same as ascii. */ + const char *tui_inactive_border_kind + = ((strcmp (tui_border_kind, "active-ascii") == 0) + ? "ascii" + : tui_border_kind); + const char *tui_active_border_kind = tui_border_kind; + /* The ACS characters are determined at run time by curses terminal management. */ - set_border_kind_item (&tui_border_lrcorner, tui_border_kind, + set_border_kind_item (&tui_border_lrcorner, tui_inactive_border_kind, + tui_border_kind_translate_lrcorner, ACS_LRCORNER, + &need_redraw); + + set_border_kind_item (&tui_border_llcorner, tui_inactive_border_kind, + tui_border_kind_translate_llcorner, ACS_LLCORNER, + &need_redraw); + + set_border_kind_item (&tui_border_ulcorner, tui_inactive_border_kind, + tui_border_kind_translate_ulcorner, ACS_ULCORNER, + &need_redraw); + + set_border_kind_item (&tui_border_urcorner, tui_inactive_border_kind, + tui_border_kind_translate_urcorner, ACS_URCORNER, + &need_redraw); + + set_border_kind_item (&tui_border_hline, tui_inactive_border_kind, + tui_border_kind_translate_hline, ACS_HLINE, + &need_redraw); + + set_border_kind_item (&tui_border_vline, tui_inactive_border_kind, + tui_border_kind_translate_vline, ACS_VLINE, + &need_redraw); + + set_border_kind_item (&tui_active_border_lrcorner, tui_active_border_kind, tui_border_kind_translate_lrcorner, ACS_LRCORNER, &need_redraw); - set_border_kind_item (&tui_border_llcorner, tui_border_kind, + set_border_kind_item (&tui_active_border_llcorner, tui_active_border_kind, tui_border_kind_translate_llcorner, ACS_LLCORNER, &need_redraw); - set_border_kind_item (&tui_border_ulcorner, tui_border_kind, + set_border_kind_item (&tui_active_border_ulcorner, tui_active_border_kind, tui_border_kind_translate_ulcorner, ACS_ULCORNER, &need_redraw); - set_border_kind_item (&tui_border_urcorner, tui_border_kind, + set_border_kind_item (&tui_active_border_urcorner, tui_active_border_kind, tui_border_kind_translate_urcorner, ACS_URCORNER, &need_redraw); - set_border_kind_item (&tui_border_hline, tui_border_kind, + set_border_kind_item (&tui_active_border_hline, tui_active_border_kind, tui_border_kind_translate_hline, ACS_HLINE, &need_redraw); - set_border_kind_item (&tui_border_vline, tui_border_kind, + set_border_kind_item (&tui_active_border_vline, tui_active_border_kind, tui_border_kind_translate_vline, ACS_VLINE, &need_redraw); @@ -1244,6 +1288,7 @@ Show the kind of border for TUI windows."), _("\ This variable controls the border of TUI windows:\n\ space use a white space\n\ ascii use ascii characters + - | for the border\n\ + active-ascii use ascii character + for the active border, otherwise as ascii\n\ acs use the Alternate Character Set"), tui_set_var_cmd, show_tui_border_kind, diff --git a/gdb/tui/tui-win.h b/gdb/tui/tui-win.h index 3d35f1dfb7f..0c02cc3e2e9 100644 --- a/gdb/tui/tui-win.h +++ b/gdb/tui/tui-win.h @@ -35,6 +35,12 @@ extern chtype tui_border_lrcorner; extern chtype tui_border_llcorner; extern chtype tui_border_vline; extern chtype tui_border_hline; +extern chtype tui_active_border_vline; +extern chtype tui_active_border_hline; +extern chtype tui_active_border_ulcorner; +extern chtype tui_active_border_urcorner; +extern chtype tui_active_border_llcorner; +extern chtype tui_active_border_lrcorner; extern int tui_border_attrs; extern int tui_active_border_attrs; diff --git a/gdb/tui/tui-wingeneral.c b/gdb/tui/tui-wingeneral.c index 82a023d09fe..ac07195c81f 100644 --- a/gdb/tui/tui-wingeneral.c +++ b/gdb/tui/tui-wingeneral.c @@ -99,12 +99,19 @@ box_win (struct tui_win_info *win_info, : tui_border_style.style ())); wattron (win, attrs); #ifdef HAVE_WBORDER - wborder (win, tui_border_vline, tui_border_vline, - tui_border_hline, tui_border_hline, - tui_border_ulcorner, tui_border_urcorner, - tui_border_llcorner, tui_border_lrcorner); + wborder (win, + highlight_flag ? tui_active_border_vline : tui_border_vline, + highlight_flag ? tui_active_border_vline : tui_border_vline, + highlight_flag ? tui_active_border_hline : tui_border_hline, + highlight_flag ? tui_active_border_hline : tui_border_hline, + highlight_flag ? tui_active_border_ulcorner : tui_border_ulcorner, + highlight_flag ? tui_active_border_urcorner : tui_border_urcorner, + highlight_flag ? tui_active_border_llcorner : tui_border_llcorner, + highlight_flag ? tui_active_border_lrcorner : tui_border_lrcorner); #else - box (win, tui_border_vline, tui_border_hline); + box (win, + highlight_flag ? tui_active_border_vline : tui_border_vline, + highlight_flag ? tui_active_border_hline : tui_border_hline); #endif if (!win_info->title.empty ()) {