public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb/testsuite/tui: implement _csi_P proc
Date: Thu, 31 Mar 2022 16:55:40 +0000 (GMT)	[thread overview]
Message-ID: <20220331165540.39CEC3857C42@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7820b634f74e4df874a00fe08afdb7ecc3d4747c

commit 7820b634f74e4df874a00fe08afdb7ecc3d4747c
Author: Simon Marchi <simon.marchi@efficios.com>
Date:   Tue Mar 29 20:58:58 2022 -0400

    gdb/testsuite/tui: implement _csi_P proc
    
    Since commit 3cd522938792 ("Change the pager to a ui_file"), I see these
    errors when running gdb.tui/scroll.exp:
    
        ERROR: invalid command name "_csi_P"
            while executing
        "::gdb_tcl_unknown _csi_P 2"
            ("uplevel" body line 1)
            invoked from within
        "uplevel 1 ::gdb_tcl_unknown $args"
            (procedure "::unknown" line 5)
            invoked from within
        "_csi_P 2"
            ("eval" body line 1)
            invoked from within
        "eval _csi_$cmd $params"
    
    It looks like GDB is emitting a CSI that it did not emit before, the
    "Delete character" one:
    
      https://vt100.net/docs/vt510-rm/DCH.html
    
    Implement it.
    
    Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
    Change-Id: I5bf86b6104d51b0623a26a69df83d1ca9a4851b7

Diff:
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 29 +++++++++++++++++++++++++++++
 gdb/testsuite/lib/tuiterm.exp     | 27 +++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index 6b1b044535a..c82db21a92b 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -492,6 +492,34 @@ proc test_delete_line { } {
     } 3 0
 }
 
+proc test_delete_character { } {
+    Term::_move_cursor 2 1
+
+    Term::_csi_P
+    check "delete character, default param" {
+	"abcdefgh"
+	"ijlmnop "
+	"qrstuvwx"
+	"yz01234 "
+    } 2 1
+
+    Term::_csi_P 3
+    check "delete character, explicit param" {
+	"abcdefgh"
+	"ijop    "
+	"qrstuvwx"
+	"yz01234 "
+    } 2 1
+
+    Term::_csi_P 12
+    check "delete character, more than number of columns" {
+	"abcdefgh"
+	"ij      "
+	"qrstuvwx"
+	"yz01234 "
+    } 2 1
+}
+
 proc test_erase_character { } {
     Term::_move_cursor 3 2
     Term::_csi_X
@@ -600,6 +628,7 @@ foreach_with_prefix test {
     test_erase_in_display
     test_erase_in_line
     test_delete_line
+    test_delete_character
     test_erase_character
     test_repeat
     test_vertical_line_position_absolute
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 7696fea4c7e..9053f7dba6a 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -349,6 +349,33 @@ namespace eval Term {
 	}
     }
 
+    # Delete Character.
+    #
+    # https://vt100.net/docs/vt510-rm/DCH.html
+    proc _csi_P {args} {
+	set count [_default [lindex $args 0] 1]
+
+	_log_cur "Delete character ($count)" {
+	    variable _cur_row
+	    variable _cur_col
+	    variable _chars
+	    variable _cols
+
+	    # Move all characters right of the cursor N positions left.
+	    set out_col [expr $_cur_col]
+	    set in_col [expr $_cur_col + $count]
+
+	    while {$in_col < $_cols} {
+		set _chars($out_col,$_cur_row) $_chars($in_col,$_cur_row)
+		incr in_col
+		incr out_col
+	    }
+
+	    # Clear the rest of the line.
+	    _clear_in_line $out_col $_cols $_cur_row
+	}
+    }
+
     # Erase chars.
     #
     # https://vt100.net/docs/vt510-rm/ECH.html


                 reply	other threads:[~2022-03-31 16:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220331165540.39CEC3857C42@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).