[PATCHv2,1/8] gdb/testsuite: fix line feed scrolling in tuiterm.exp

Message ID 11b615e8de660b1fb12ded842d8fe6aaafc58e38.1674648473.git.aburgess@redhat.com
State Committed
Commit efe1b6507b7e6ae5ee45af5b1568b910a3170750
Headers
Series Mixed bag of TUI tests and fixes |

Commit Message

Andrew Burgess Jan. 25, 2023, 12:08 p.m. UTC
  In a following commit I managed to trigger the line feed scrolling
case in tuiterm.exp.  This case is currently unhandled, and this
commit fills in this missing functionality.

The implementation is pretty simple, just scroll all the content up
one line at a time until the cursor is back on the screen (a single
line of scroll is all that should be needed).

This change is untested in this commit, but is required by the next
commit.
---
 gdb/testsuite/lib/tuiterm.exp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
  

Comments

Tom Tromey Jan. 25, 2023, 7:46 p.m. UTC | #1
>>>>> "Andrew" == Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> writes:

Andrew> In a following commit I managed to trigger the line feed scrolling
Andrew> case in tuiterm.exp.  This case is currently unhandled, and this
Andrew> commit fills in this missing functionality.

Andrew> The implementation is pretty simple, just scroll all the content up
Andrew> one line at a time until the cursor is back on the screen (a single
Andrew> line of scroll is all that should be needed).

Andrew> This change is untested in this commit, but is required by the next
Andrew> commit.

Looks good to me.  Thanks for doing this.  The terminal code just
implements the subset of escape sequences I happened to run into while
writing tests -- there's no reason other than laziness that some are
missing.

Tom
  

Patch

diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index c38ccbbdbd7..8a3f7a48acc 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -99,10 +99,24 @@  namespace eval Term {
 	_log_cur "Line feed" {
 	    variable _cur_row
 	    variable _rows
+	    variable _cols
+	    variable _chars
 
 	    incr _cur_row 1
-	    if {$_cur_row >= $_rows} {
-		error "FIXME scroll"
+	    while {$_cur_row >= $_rows} {
+		# Scroll the display contents.  We scroll one line at
+		# a time here; as _cur_row was only increased by one,
+		# a single line scroll should be enough to put the
+		# cursor back on the screen.  But we wrap the
+		# scrolling inside a while loop just to be on the safe
+		# side.
+		for {set y 0} {$y < [expr $_rows - 1]} {incr y} {
+		    set next_y [expr $y + 1]
+		    for {set x 0} {$x < $_cols} {incr x} {
+			set _chars($x,$y) $_chars($x,$next_y)
+		    }
+		    incr _cur_row -1
+		}
 	    }
 	}
     }