From patchwork Fri May 26 13:02:58 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: 70161 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 060C53857020 for ; Fri, 26 May 2023 13:03:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 060C53857020 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685106202; bh=hzal/mIYZWn2ABpeNvRwAMy5azjQ9xl9SNP7DCSZAt8=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ro5NfhJhtIxUN9bXV++oBS5aCbR51D5EH+bmXdFmxWf5GNvlpsFVaz77NDoLarSnf EZZKqe331o6aASC05UV1YHDLRaYDmx9lrKM514LKHrZyVl0ah8kD1X/b3LADUmSPSj pF/TsVhYQ1svzo6j2CI9n6uLdO5P/F17dN6C3baw= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 670FA3858C2C for ; Fri, 26 May 2023 13:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 670FA3858C2C Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 9EA6421A14 for ; Fri, 26 May 2023 13:02:48 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 8B68E13684 for ; Fri, 26 May 2023 13:02:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id V0kiIPitcGRHYAAAGKfGzw (envelope-from ) for ; Fri, 26 May 2023 13:02:48 +0000 To: gdb-patches@sourceware.org Subject: [pushed 1/3] [gdb/testsuite] Fix reverse attribute in tuiterm Date: Fri, 26 May 2023 15:02:58 +0200 Message-Id: <20230526130300.20974-1-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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 in proc Term::_csi_m arguments that while parameters 7 and 27 are supposed to set the reverse attribute to 1 and 0, in fact it's set to 1 in both cases: ... 7 { set _attrs(reverse) 1 } ... 27 { set _attrs(reverse) 1 } ... Fix this and add a regression test in gdb.tui/tuiterm.exp. Tested on x86_64-linux. --- gdb/testsuite/gdb.tui/tuiterm.exp | 36 +++++++++++++++++++++++++++++++ gdb/testsuite/lib/tuiterm.exp | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) base-commit: 86b96a79b81fa6fcbb3e136d8c720c4aa6df8eda diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp index 6cc6c628e73..ff0a3ac48ad 100644 --- a/gdb/testsuite/gdb.tui/tuiterm.exp +++ b/gdb/testsuite/gdb.tui/tuiterm.exp @@ -676,6 +676,40 @@ proc test_insert_line { } { } 2 0 } +proc test_attrs {} { + foreach { attr vals } { + reverse { + 7 1 + 27 0 + } + underline { + 4 1 + 24 0 + } + intensity { + 1 bold + 2 dim + 22 normal + } + } { + setup_terminal 8 1 + set re "" + foreach { arg val } $vals { + Term::_insert "a" + Term::_csi_m $arg + append re "a<$attr:$val>" + } + + Term::_insert "a" + append re "a" + + set re "^$re *$" + + set line [Term::get_line_with_attrs 0] + gdb_assert { [regexp $re $line] } "attribute: $attr" + } +} + # Run proc TEST_PROC_NAME with a "small" terminal. proc run_one_test_small { test_proc_name } { @@ -727,3 +761,5 @@ foreach_with_prefix test { } { run_one_test_large $test } + +test_attrs diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 5c0be85ee73..49ce79558c6 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -590,7 +590,7 @@ namespace eval Term { set _attrs(underline) 0 } 27 { - set _attrs(reverse) 1 + set _attrs(reverse) 0 } 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 { set _attrs(fg) $item From patchwork Fri May 26 13:02:59 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: 70163 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 88ECB3857735 for ; Fri, 26 May 2023 13:03:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 88ECB3857735 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685106229; bh=XugMVavaEOCPTcWZH4jo4QwdP7oAmbMlLkmCOYj0uPU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=r8ges6n33xH2bRfaeVepP9sDTsJGbYpWCq4F2U5jvDl8W2/49yA+v1q5IBhOGqx0X ZFv/JGBiOo5arTyn8vQk128s7OfWscNLgj8LtKDPwuM7DDoQTeauQc2R1w7p5o5fCU H16X31gXmBQJGBWgCd+HTDO5EA63jE7sgYMOUvyM= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id 8509E385842C for ; Fri, 26 May 2023 13:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8509E385842C Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 B5C2621B3E for ; Fri, 26 May 2023 13:02:48 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id A26BC13684 for ; Fri, 26 May 2023 13:02:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id UEunJvitcGRHYAAAGKfGzw (envelope-from ) for ; Fri, 26 May 2023 13:02:48 +0000 To: gdb-patches@sourceware.org Subject: [pushed 2/3] [gdb/testsuite] Add invisible and blinking attributes in tuiterm Date: Fri, 26 May 2023 15:02:59 +0200 Message-Id: <20230526130300.20974-2-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230526130300.20974-1-tdevries@suse.de> References: <20230526130300.20974-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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 curses using the invisible and blinking attributes. Add these in tuiterm. Tested on x86_64-linux. --- gdb/testsuite/gdb.tui/tuiterm.exp | 8 ++++++++ gdb/testsuite/lib/tuiterm.exp | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp index ff0a3ac48ad..bccb7ef445a 100644 --- a/gdb/testsuite/gdb.tui/tuiterm.exp +++ b/gdb/testsuite/gdb.tui/tuiterm.exp @@ -691,6 +691,14 @@ proc test_attrs {} { 2 dim 22 normal } + invisible { + 8 1 + 28 0 + } + blinking { + 5 1 + 25 0 + } } { setup_terminal 8 1 set re "" diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 49ce79558c6..90b885d7ab4 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -556,6 +556,8 @@ namespace eval Term { bg default underline 0 reverse 0 + invisible 0 + blinking 0 } } @@ -580,18 +582,30 @@ namespace eval Term { 4 { set _attrs(underline) 1 } + 5 { + set _attrs(blinking) 1 + } 7 { set _attrs(reverse) 1 } + 8 { + set _attrs(invisible) 1 + } 22 { set _attrs(intensity) normal } 24 { set _attrs(underline) 0 } + 25 { + set _attrs(blinking) 0 + } 27 { set _attrs(reverse) 0 } + 28 { + set _attrs(invisible) 0 + } 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 { set _attrs(fg) $item } From patchwork Fri May 26 13:03:00 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: 70162 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 2BD7D3857006 for ; Fri, 26 May 2023 13:03:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BD7D3857006 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685106207; bh=sTmmeyOiaZ7Ir4mlryS6T8Siz6p3FpPUHMMIVpO//7g=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=K2/S0sOCVGuZngMI0xr/QUVfAzs9Ef/1H0wC7cXePT0rXJ8sC13RWWSnOwD+iI8l/ 5V3KdcrBn0S3TFBy6UNTAMSbLbeb7py1Solbko6PxcSGvrjbZZDkGsHU1jhQuAb+t5 Nln/KvsfP8fAp6LSLNpk3VH8HoLcOBstybyb4C3Q= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 9A6F5385843E for ; Fri, 26 May 2023 13:02:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9A6F5385843E Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 CB3411FD66 for ; Fri, 26 May 2023 13:02:48 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id BA0F613684 for ; Fri, 26 May 2023 13:02:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id kKdkLPitcGRHYAAAGKfGzw (envelope-from ) for ; Fri, 26 May 2023 13:02:48 +0000 To: gdb-patches@sourceware.org Subject: [pushed 3/3] [gdb/testsuite] Add test-case gdb.tui/color-prompt.exp Date: Fri, 26 May 2023 15:03:00 +0200 Message-Id: <20230526130300.20974-3-tdevries@suse.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230526130300.20974-1-tdevries@suse.de> References: <20230526130300.20974-1-tdevries@suse.de> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 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" Add a test-case that sets a prompt with color in TUI. The line containing the prompt is shown by get_line_with_attrs as follows: ... (gdb) ... The 31 means red, but only for foreground colors, for background colors 41 means red. Make this more readable by using color names for both foreground and background, such that we have instead: .... (gdb) ... Tested on x86_64-linux. --- gdb/testsuite/gdb.tui/color-prompt.exp | 32 +++++++++++++++++++++++ gdb/testsuite/gdb.tui/tuiterm.exp | 24 +++++++++++++++++- gdb/testsuite/lib/tuiterm.exp | 35 ++++++++++++++++++++++++-- 3 files changed, 88 insertions(+), 3 deletions(-) create mode 100644 gdb/testsuite/gdb.tui/color-prompt.exp diff --git a/gdb/testsuite/gdb.tui/color-prompt.exp b/gdb/testsuite/gdb.tui/color-prompt.exp new file mode 100644 index 00000000000..8482e1b7695 --- /dev/null +++ b/gdb/testsuite/gdb.tui/color-prompt.exp @@ -0,0 +1,32 @@ +# 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 . + +# Check using a prompt with color in TUI. + +tuiterm_env + +Term::clean_restart 24 80 + +# Set colored prompt. +if {![Term::enter_tui]} { + unsupported "TUI not supported" + return +} + +Term::command "set prompt \\033\[31m(gdb) \\033\[0m" + +set line [Term::get_line_with_attrs $Term::_cur_row] +gdb_assert { [regexp "^$gdb_prompt *$" $line] } \ + "prompt with color" diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp index bccb7ef445a..c1751418130 100644 --- a/gdb/testsuite/gdb.tui/tuiterm.exp +++ b/gdb/testsuite/gdb.tui/tuiterm.exp @@ -699,8 +699,30 @@ proc test_attrs {} { 5 1 25 0 } + fg { + 30 black + 31 red + 32 green + 33 yellow + 34 blue + 35 magenta + 36 cyan + 37 white + 39 default + } + bg { + 40 black + 41 red + 42 green + 43 yellow + 44 blue + 45 magenta + 46 cyan + 47 white + 49 default + } } { - setup_terminal 8 1 + setup_terminal 12 1 set re "" foreach { arg val } $vals { Term::_insert "a" diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp index 90b885d7ab4..b7c877593b7 100644 --- a/gdb/testsuite/lib/tuiterm.exp +++ b/gdb/testsuite/lib/tuiterm.exp @@ -561,6 +561,37 @@ namespace eval Term { } } + # Translate the color numbers as used in proc _csi_m to a name. + proc _color_attr { n } { + switch -exact -- $n { + 0 { + return black + } + 1 { + return red + } + 2 { + return green + } + 3 { + return yellow + } + 4 { + return blue + } + 5 { + return magenta + } + 6 { + return cyan + } + 7 { + return white + } + default { error "unsupported color number: $n" } + } + } + # Select Graphic Rendition. # # https://vt100.net/docs/vt510-rm/SGR.html @@ -607,13 +638,13 @@ namespace eval Term { set _attrs(invisible) 0 } 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 { - set _attrs(fg) $item + set _attrs(fg) [_color_attr [expr $item - 30]] } 39 { set _attrs(fg) default } 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 { - set _attrs(bg) $item + set _attrs(bg) [_color_attr [expr $item - 40]] } 49 { set _attrs(bg) default