qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Roman Penyaev" <r.peniaev@gmail.com>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	qemu-devel@nongnu.org
Subject: [PATCH v2 3/5] ui/console-vc: report cursor position in the screen not in the scroll buffer
Date: Wed, 26 Feb 2025 08:59:09 +0100	[thread overview]
Message-ID: <20250226075913.353676-4-r.peniaev@gmail.com> (raw)
In-Reply-To: <20250226075913.353676-1-r.peniaev@gmail.com>

The format of the CSI cursor position report is `ESC[row;columnR`,
where `row` is a row of a cursor in the screen, not in the scrollback
buffer. What's the difference? Let's say the terminal screen has 24
lines, no matter how long the scrollback buffer may be, the last line
is the 24th.

For example the following command can be executed in xterm on the last
screen line:

   $ echo -en '\e[6n'; IFS='[;' read -sdR _ row col; echo $row:$col
   24:1

It shows the cursor position on the current screen and not relative
to the backscroll buffer.

Before this change the row number was always increasing for the QEMU
VC and represents the cursor position relative to the backscroll
buffer.

Signed-off-by: Roman Penyaev <r.peniaev@gmail.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>
Cc: qemu-devel@nongnu.org
---
 ui/console-vc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/ui/console-vc.c b/ui/console-vc.c
index d512f57e10a9..87f57f1c52c6 100644
--- a/ui/console-vc.c
+++ b/ui/console-vc.c
@@ -827,8 +827,7 @@ static void vc_putchar(VCChardev *vc, int ch)
                 case 6:
                     /* report cursor position */
                     response = g_strdup_printf("\033[%d;%dR",
-                           (s->y_base + s->y) % s->total_height + 1,
-                            s->x + 1);
+                                               s->y + 1, s->x + 1);
                     vc_respond_str(vc, response);
                     break;
                 }
-- 
2.43.0



  parent reply	other threads:[~2025-02-26  8:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-26  7:59 [PATCH v2 0/5] ui/console-vc: various fixes and improvements Roman Penyaev
2025-02-26  7:59 ` [PATCH v2 1/5] ui/console-vc: introduce parsing of the 'ESC ( <ch>' sequence Roman Penyaev
2025-02-26  7:59 ` [PATCH v2 2/5] ui/console-vc: report to the application instead of screen rendering Roman Penyaev
2025-02-26  7:59 ` Roman Penyaev [this message]
2025-02-26  7:59 ` [PATCH v2 4/5] ui/console-vc: add support for cursor DECSC and DECRC commands Roman Penyaev
2025-02-26  7:59 ` [PATCH v2 5/5] ui/console-vc: implement DCH (delete) and ICH (insert) commands Roman Penyaev
2025-02-26 10:06 ` [PATCH v2 0/5] ui/console-vc: various fixes and improvements Marc-André Lureau
2025-03-04  8:48   ` Roman Penyaev

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=20250226075913.353676-4-r.peniaev@gmail.com \
    --to=r.peniaev@gmail.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.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 NNTP newsgroup(s).