aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2025-07-24 12:06:40 +0200
committerTom de Vries <tdevries@suse.de>2025-07-24 12:06:40 +0200
commit6638cfadb9b78db0da1bf6cd01c2f11e2bc22e74 (patch)
tree42bb0e64805827caf62e1dbe560d23c5c3f82cbb
parent6d8ace9ffd8e9e8cc7fd36d7a06c2da885705eee (diff)
downloadbinutils-6638cfadb9b78db0da1bf6cd01c2f11e2bc22e74.zip
binutils-6638cfadb9b78db0da1bf6cd01c2f11e2bc22e74.tar.gz
binutils-6638cfadb9b78db0da1bf6cd01c2f11e2bc22e74.tar.bz2
[gdb/testsuite] Add Term::get_string_with_attrs in tuiterm
While reading a gdb.log for test-case gdb.tui/main-2.exp, I noticed that this line was somewhat hard to read: ... screen line 6: '<fg:cyan><intensity:bold>|<fg:default><intensity:normal>B+> 21 <reverse:1> return 0;<reverse:0> <fg:cyan><intensity:bold>|<fg:default><intensity:normal>' ... because of the border attributes. Then I realized that the test-case is only interested in the text between the borders, so I added a proc Term::get_string_with_attrs that allows me to drop the borders, getting us instead: ... screen line 6: 'B+> 21 <reverse:1> return 0;<reverse:0> ' ... Tested on aarch64-linux.
-rw-r--r--gdb/testsuite/gdb.tui/main-2.exp2
-rw-r--r--gdb/testsuite/lib/tuiterm.exp23
2 files changed, 19 insertions, 6 deletions
diff --git a/gdb/testsuite/gdb.tui/main-2.exp b/gdb/testsuite/gdb.tui/main-2.exp
index 2b0fb6b..71ad03b 100644
--- a/gdb/testsuite/gdb.tui/main-2.exp
+++ b/gdb/testsuite/gdb.tui/main-2.exp
@@ -41,7 +41,7 @@ if {![Term::enter_tui]} {
set line " return 0;"
set nr [gdb_get_line_number $line]
-set screen_line [Term::get_line_with_attrs 6]
+set screen_line [Term::get_string_with_attrs 6 1 79]
verbose -log "screen line 6: '$screen_line'"
gdb_assert { [regexp "$nr <reverse:1>$line<reverse:0>" $screen_line] } \
"highlighted line in middle of source window"
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 8ea8ebe..cc8e852 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -1009,10 +1009,10 @@ namespace eval Term {
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} {
+ # Return the text of screen line N. Lines are 0-based. Start at column
+ # X. If C is non-empty, stop before column C. Columns are also
+ # zero-based. If ATTRS, annotate with attributes.
+ proc get_string {n x c {attrs 0}} {
variable _rows
# This can happen during resizing, if the cursor seems to
# temporarily be off-screen.
@@ -1024,7 +1024,6 @@ namespace eval Term {
variable _cols
variable _chars
set c [_default $c $_cols]
- set x 0
if { $attrs } {
_reset_attrs line_attrs
}
@@ -1044,6 +1043,20 @@ namespace eval Term {
return $result
}
+ # Return the text of screen line N. Lines are 0-based. Start at column
+ # X. If C is non-empty, stop before column C. Columns are also
+ # zero-based. Annotate with attributes.
+ proc get_string_with_attrs { n x c } {
+ return [get_string $n $x $c 1]
+ }
+
+ # Return the text of screen line N. Lines are 0-based. If C is
+ # non-empty, stop before column C. Columns are also zero-based. If
+ # ATTRS, annotate with attributes.
+ proc get_line_1 {n c attrs} {
+ return [get_string $n 0 $c $attrs]
+ }
+
# 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.