public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 2/6] [gdb/testsuite] Factor out Term::_wrap_cursor
Date: Mon, 22 May 2023 15:15:41 +0200	[thread overview]
Message-ID: <20230522131545.12291-4-tdevries@suse.de> (raw)
In-Reply-To: <20230522131545.12291-1-tdevries@suse.de>

Factor out new proc Term::_wrap_cursor out of proc Term::_insert.

Tested on x86_64-linux.
---
 gdb/testsuite/lib/tuiterm.exp | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 5c0be85ee73..e52cb3e5b6d 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -609,6 +609,18 @@ namespace eval Term {
 	}
     }
 
+    # Set cursor to col 0 on the next line.  If we run off screen, error out.
+    proc _wrap_cursor {} {
+	variable _cur_col
+	variable _cur_row
+	variable _rows
+	set _cur_col 0
+	incr _cur_row
+	if {$_cur_row >= $_rows} {
+	    error "FIXME scroll"
+	}
+    }
+
     # Insert string at the cursor location.
     proc _insert {str} {
 	_log_cur "Inserted string '$str'" {
@@ -616,7 +628,6 @@ namespace eval Term {
 
 	    variable _cur_col
 	    variable _cur_row
-	    variable _rows
 	    variable _cols
 	    variable _attrs
 	    variable _chars
@@ -626,11 +637,7 @@ namespace eval Term {
 		    set _chars($_cur_col,$_cur_row) [list $char $lattr]
 		    incr _cur_col
 		    if {$_cur_col >= $_cols} {
-			set _cur_col 0
-			incr _cur_row
-			if {$_cur_row >= $_rows} {
-			    error "FIXME scroll"
-			}
+			_wrap_cursor
 		    }
 		}
 	    }
-- 
2.35.3


  parent reply	other threads:[~2023-05-22 13:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22 13:15 [PATCH 0/6] [gdb/tui] Introduce ansi-for-tui Tom de Vries
2023-05-22 13:15 ` [PATCH 1/6] [gdb/testsuite] Use TERM=dummy in gdb.tui/tuiterm.exp Tom de Vries
2023-05-22 13:15 ` [PATCH] [gdb/tui] Add set style tui-status-window Tom de Vries
2023-05-22 13:47   ` Eli Zaretskii
2023-05-22 14:22     ` Tom de Vries
2023-05-22 15:50       ` Eli Zaretskii
2023-05-22 13:15 ` Tom de Vries [this message]
2023-05-22 13:15 ` [PATCH 3/6] [gdb/contrib] Add ansi-for-tui.sh Tom de Vries
2023-05-22 13:15 ` [PATCH 4/6] [gdb/testsuite] Make ansi-for-tui available in with_tuiterm Tom de Vries
2023-05-22 13:15 ` [PATCH 5/6] [gdb/testsuite] Implement the newline glitch in tuiterm Tom de Vries
2023-05-22 13:15 ` [PATCH 6/6] [gdb/testsuite] Use ansi-for-tui " 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=20230522131545.12291-4-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).