Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm
Date: Fri, 18 Jul 2025 15:01:50 +0200	[thread overview]
Message-ID: <20250718130153.24989-5-tdevries@suse.de> (raw)
In-Reply-To: <20250718130153.24989-1-tdevries@suse.de>

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.
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 13 +++++++++++--
 gdb/testsuite/lib/tuiterm.exp     | 32 ++++++++++++++++++++++++++++---
 2 files changed, 40 insertions(+), 5 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 0e03bfaa8ea..e58de688ef2 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 4364ff8d05c..451fccc6693 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -90,14 +90,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
 	}
     }
 
-- 
2.43.0


  parent reply	other threads:[~2025-07-18 13:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-18 13:01 [PATCH 0/7] [gdb/testsuite] Fix TUI tests for freebsd Tom de Vries
2025-07-18 13:01 ` [PATCH 1/7] [gdb/testsuite] Fix Cursor Horizontal Absolute clipping Tom de Vries
2025-07-18 13:01 ` [PATCH 2/7] [gdb/testsuite] Handle Horizontal Position Absolute in tuiterm Tom de Vries
2025-07-18 13:01 ` [PATCH 3/7] [gdb/testsuite] Log on return in Term::_log_cur Tom de Vries
2025-07-23 18:28   ` Tom Tromey
2025-07-24  7:18     ` Tom de Vries
2025-07-18 13:01 ` Tom de Vries [this message]
2025-07-23 18:36   ` [PATCH 4/7] [gdb/testsuite] Handle auto_left_margin in tuiterm Tom Tromey
2025-07-18 13:01 ` [PATCH 5/7] [gdb/testsuite] Fix Term::_csi_m with no args Tom de Vries
2025-07-23 18:30   ` Tom Tromey
2025-07-23 20:34     ` Tom de Vries
2025-07-24  1:17       ` Tom Tromey
2025-07-18 13:01 ` [PATCH 6/7] [gdb/testsuite] Use TERM=ansiw in tuiterm for bsd Tom de Vries
2025-07-23 18:34   ` Tom Tromey
2025-07-24  9:47     ` Tom de Vries
2025-07-18 13:01 ` [PATCH 7/7] [gdb/testsuite] Add Term::get_string_with_attrs in tuiterm Tom de Vries
2025-07-23 18:36   ` Tom Tromey
2025-07-24 10:07     ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250718130153.24989-5-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox