[PATCHv3 04/15] gdb/testing/tui: add new functionality to tuiterm.exp
Andrew Burgess
aburgess@redhat.com
Mon Mar 7 22:13:36 GMT 2022
While working on later patches in this series, I was running into csi
control codes being emitted from ncurses that are not currently
handled by out gdb/testsuite/lib/tuiterm.exp.
This commit adds support for these additional control sequences.
The new sequences are 'Insert Line', 'Delete Characters', and 'Scroll
Down'.
There are no new tests in this commit, but I was running into these
sequences while developing later patches in this series. However,
which control sequences ncurses emits can vary wildly depending on the
screen contents. It is possible that I only hit some of these
sequences while debugging the later patches (i.e. printing extra
content to the terminal), some of these might no longer be needed
given the tests as now written.
Still, I think it is worth merging these to improve tuiterm.exp.
Additionally, I noticed a bug in 'Erase in Line' that this commit
fixes; in mode 1 the erase should be from the start of the line
through to the cursor, not to the character before the cursor. This
bug would mean that random characters would sometimes be left in the
terminal output.
---
gdb/testsuite/lib/tuiterm.exp | 82 ++++++++++++++++++++++++++++++++++-
1 file changed, 81 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 38948015e96..06d2e091ca5 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -317,13 +317,40 @@ namespace eval Term {
# From cursor to end.
_clear_in_line $_cur_col $_cols $_cur_row
} elseif {$arg == 1} {
- _clear_in_line 0 $_cur_col $_cur_row
+ _clear_in_line 0 [expr $_cur_col + 1] $_cur_row
} elseif {$arg == 2} {
_clear_in_line 0 $_cols $_cur_row
}
}
}
+ # 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 + 1]
+ 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 $_rows
+ }
+ }
+
# Delete line.
#
# https://vt100.net/docs/vt510-rm/DL.html
@@ -349,6 +376,59 @@ namespace eval Term {
}
}
+ # Delete Characters
+ #
+ # 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_col
+ variable _cur_row
+ variable _cols
+ variable _chars
+
+ set dx [expr $_cur_col + 1]
+ set sx [expr $_cur_col + 1 + $count]
+ set y $_cur_row
+
+ while {$sx < $_cols} {
+ set _chars($dx,$y) $_chars($sx,$y)
+ incr sx
+ incr dx
+ }
+ _clear_in_line $dx $sx $y
+ }
+ }
+
+ # 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
+
+ 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
+ }
+ }
+
# Erase chars.
#
# https://vt100.net/docs/vt510-rm/ECH.html
--
2.25.4
More information about the Gdb-patches
mailing list