public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb/testing/tui: add new _csi_{L,S,T}
@ 2022-04-01 15:23 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2022-04-01 15:23 UTC (permalink / raw)
  To: gdb-cvs

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

commit fd46a69ed42ce16fbbf5a20dffca9228a3647019
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Wed Jan 26 18:41:59 2022 +0000

    gdb/testing/tui: add new _csi_{L,S,T}
    
    This patch was original part of this series:
    
      https://sourceware.org/pipermail/gdb-patches/2022-March/186429.html
      https://sourceware.org/pipermail/gdb-patches/2022-March/186433.html
    
    I've pulled this out as it might be useful ahead of the bigger series
    being merged.
    
    This commit adds:
    
      _csi_L - insert line
      _csi_S - pan down
      _csi_T - pan up

Diff:
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 85 +++++++++++++++++++++++++++++++++++
 gdb/testsuite/lib/tuiterm.exp     | 95 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 180 insertions(+)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index c82db21a92b..98f1cd7fe8c 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -179,6 +179,60 @@ proc test_insert_characters { } {
     } 0 1
 }
 
+proc test_pan_down { } {
+    Term::_move_cursor 1 2
+    Term::_csi_S
+    check "pan down, default arg" {
+	"ijklmnop"
+	"qrstuvwx"
+	"yz01234 "
+	"        "
+    } 1 2
+
+    Term::_csi_S 2
+    check "pan down, explicit arg" {
+	"yz01234 "
+	"        "
+	"        "
+	"        "
+    } 1 2
+
+    Term::_csi_S 100
+    check "pan down, excessive arg" {
+	"        "
+	"        "
+	"        "
+	"        "
+    } 1 2
+}
+
+proc test_pan_up { } {
+    Term::_move_cursor 1 2
+    Term::_csi_T
+    check "pan down, default arg" {
+	"        "
+	"abcdefgh"
+	"ijklmnop"
+	"qrstuvwx"
+    } 1 2
+
+    Term::_csi_T 2
+    check "pan down, explicit arg" {
+	"        "
+	"        "
+	"        "
+	"abcdefgh"
+    } 1 2
+
+    Term::_csi_T 100
+    check "pan down, excessive arg" {
+	"        "
+	"        "
+	"        "
+	"        "
+    } 1 2
+}
+
 proc test_cursor_up { } {
     Term::_move_cursor 2 3
 
@@ -594,6 +648,34 @@ proc test_vertical_line_position_absolute { } {
     } 2 3
 }
 
+proc test_insert_line { } {
+    Term::_move_cursor 2 1
+    Term::_csi_L
+    check "insert line, default param" {
+	"abcdefgh"
+	"        "
+	"ijklmnop"
+	"qrstuvwx"
+    } 2 1
+
+    Term::_move_cursor 2 0
+    Term::_csi_L 2
+    check "insert line, explicit param" {
+	"        "
+	"        "
+	"abcdefgh"
+	"        "
+    } 2 0
+
+    Term::_csi_L 12
+    check "insert line, insert more lines than display has" {
+	"        "
+	"        "
+	"        "
+	"        "
+    } 2 0
+}
+
 # Run proc TEST_PROC_NAME with a "small" terminal.
 
 proc run_one_test_small { test_proc_name } {
@@ -632,6 +714,9 @@ foreach_with_prefix test {
     test_erase_character
     test_repeat
     test_vertical_line_position_absolute
+    test_insert_line
+    test_pan_up
+    test_pan_down
 } {
     run_one_test_small $test
 }
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 9053f7dba6a..e660840eed9 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -324,6 +324,33 @@ namespace eval Term {
 	}
     }
 
+    # Insert Line
+    #
+    # https://vt100.net/docs/vt510-rm/IL.html
+    proc _csi_L {args} {
+	set arg [_default [lindex $args 0] 1]
+
+	_log_cur "Insert Line ($arg)" {
+	    variable _cur_col
+	    variable _cur_row
+	    variable _rows
+	    variable _cols
+	    variable _chars
+
+	    set y [expr $_rows - 2]
+	    set next_y [expr $y + $arg]
+	    while {$y >= $_cur_row} {
+		for {set x 0} {$x < $_cols} {incr x} {
+		    set _chars($x,$next_y) $_chars($x,$y)
+		}
+		incr y -1
+		incr next_y -1
+	    }
+
+	    _clear_lines $_cur_row [expr $_cur_row + $arg]
+	}
+    }
+
     # Delete line.
     #
     # https://vt100.net/docs/vt510-rm/DL.html
@@ -376,6 +403,74 @@ namespace eval Term {
 	}
     }
 
+    # Pan Down
+    #
+    # https://vt100.net/docs/vt510-rm/SU.html
+    proc _csi_S {args} {
+	set count [_default [lindex $args 0] 1]
+
+	_log_cur "Pan Down ($count)" {
+	    variable _cur_col
+	    variable _cur_row
+	    variable _cols
+	    variable _rows
+	    variable _chars
+
+	    # The following code is written without consideration for
+	    # the scroll margins.  At this time this comment was
+	    # written the tuiterm library doesn't support the scroll
+	    # margins.  If/when that changes, then the following will
+	    # need to be updated.
+
+	    set dy 0
+	    set y $count
+
+	    while {$y < $_rows} {
+		for {set x 0} {$x < $_cols} {incr x} {
+		    set _chars($x,$dy) $_chars($x,$y)
+		}
+		incr y 1
+		incr dy 1
+	    }
+
+	    _clear_lines $dy $_rows
+	}
+    }
+
+    # Pan Up
+    #
+    # https://vt100.net/docs/vt510-rm/SD.html
+    proc _csi_T {args} {
+	set count [_default [lindex $args 0] 1]
+
+	_log_cur "Pan Up ($count)" {
+	    variable _cur_col
+	    variable _cur_row
+	    variable _cols
+	    variable _rows
+	    variable _chars
+
+	    # The following code is written without consideration for
+	    # the scroll margins.  At this time this comment was
+	    # written the tuiterm library doesn't support the scroll
+	    # margins.  If/when that changes, then the following will
+	    # need to be updated.
+
+	    set y [expr $_rows - $count]
+	    set dy $_rows
+
+	    while {$dy >= $count} {
+		for {set x 0} {$x < $_cols} {incr x} {
+		    set _chars($x,$dy) $_chars($x,$y)
+		}
+		incr y -1
+		incr dy -1
+	    }
+
+	    _clear_lines 0 $count
+	}
+    }
+
     # Erase chars.
     #
     # https://vt100.net/docs/vt510-rm/ECH.html


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-01 15:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 15:23 [binutils-gdb] gdb/testing/tui: add new _csi_{L,S,T} Andrew Burgess

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).