aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2025-07-23 21:11:41 +0200
committerTom de Vries <tdevries@suse.de>2025-07-23 21:11:41 +0200
commit93e5d03100d2f1dbd2aa2521b758f4f8c551d168 (patch)
tree9149d01355eabe4b3469fc827f7b64ecb6c7de69
parentcff79e9708be8236211a33af46a215be9b5a91d5 (diff)
downloadbinutils-93e5d03100d2f1dbd2aa2521b758f4f8c551d168.zip
binutils-93e5d03100d2f1dbd2aa2521b758f4f8c551d168.tar.gz
binutils-93e5d03100d2f1dbd2aa2521b758f4f8c551d168.tar.bz2
[gdb/testsuite] Handle auto_left_margin in tuiterm
The terminal capability bw (aka as auto_left_margin) controls whether a backspace at the start of a line wraps to the last column of the previous line. For tuiterm, we use TERM=ansi, and on linux at least that capability is off. Consequently the current implementation of Term::_ctl_0x08 doesn't wrap. Add this capability in Term::_ctl_0x08, and add a unit test. Tested on aarch64-linux. Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r--gdb/testsuite/gdb.tui/tuiterm.exp13
-rw-r--r--gdb/testsuite/lib/tuiterm.exp32
2 files changed, 40 insertions, 5 deletions
diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 0e03bfa..e58de68 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -102,7 +102,7 @@ proc test_backspace {} {
Term::_move_cursor 1 2
- Term::_ctl_0x08
+ Term::_ctl_0x08 0
check "backspace one" {
"abcdefgh"
"ijklmnop"
@@ -111,13 +111,22 @@ proc test_backspace {} {
} 0 2
# Cursor should not move if it is already at column 0.
- Term::_ctl_0x08
+ Term::_ctl_0x08 0
check "backspace 2" {
"abcdefgh"
"ijklmnop"
"qrstuvwx"
"yz01234 "
} 0 2
+
+ # Cursor should wrap to previous line.
+ Term::_ctl_0x08 1
+ check "backspace 3" {
+ "abcdefgh"
+ "ijklmnop"
+ "qrstuvwx"
+ "yz01234 "
+ } 7 1
}
proc test_linefeed { } {
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 2268b1e..d4ba1ae 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -83,14 +83,40 @@ namespace eval Term {
proc _ctl_0x07 {} {
}
+ # Return 1 if tuiterm has the bw/auto_left_margin enabled.
+ proc _have_bw {} {
+ return 0
+ }
+
# Backspace.
- proc _ctl_0x08 {} {
- _log_cur "Backspace" {
+ proc _ctl_0x08 { {bw -1} } {
+ if { $bw == -1 } {
+ set bw [_have_bw]
+ }
+ _log_cur "Backspace, bw == $bw" {
variable _cur_col
+ variable _cur_row
+ variable _cols
- if {$_cur_col > 0} {
+ if { $_cur_col > 0 } {
+ # No wrapping needed.
incr _cur_col -1
+ return
}
+
+ if { ! $bw } {
+ # Wrapping not enabled.
+ return
+ }
+
+ if { $_cur_row == 0 } {
+ # Can't wrap.
+ return
+ }
+
+ # Wrap to previous line.
+ set _cur_col [expr $_cols - 1]
+ incr _cur_row -1
}
}