Jacek Caban : conhost: Force using relative cursor positioning in update_read_output.
Alexandre Julliard
julliard at winehq.org
Mon Sep 21 15:12:16 CDT 2020
Module: wine
Branch: master
Commit: fc408f3d4376722dbe173495be10ef2ce34874d1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=fc408f3d4376722dbe173495be10ef2ce34874d1
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Sep 21 17:06:03 2020 +0200
conhost: Force using relative cursor positioning in update_read_output.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
programs/conhost/conhost.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c
index 97855e5e32..3f7b5fb914 100644
--- a/programs/conhost/conhost.c
+++ b/programs/conhost/conhost.c
@@ -309,6 +309,27 @@ static void set_tty_cursor( struct console *console, unsigned int x, unsigned in
tty_write( console, buf, strlen(buf) );
}
+static void set_tty_cursor_relative( struct console *console, unsigned int x, unsigned int y )
+{
+ if (y < console->tty_cursor_y)
+ {
+ char buf[64];
+ sprintf( buf, "\x1b[%uA", console->tty_cursor_y - y );
+ tty_write( console, buf, strlen(buf) );
+ console->tty_cursor_y = y;
+ }
+ else
+ {
+ while (console->tty_cursor_y < y)
+ {
+ console->tty_cursor_x = 0;
+ console->tty_cursor_y++;
+ tty_write( console, "\r\n", 2 );
+ }
+ }
+ set_tty_cursor( console, x, y );
+}
+
static void set_tty_attr( struct console *console, unsigned int attr )
{
char buf[8];
@@ -1216,7 +1237,16 @@ static void update_read_output( struct console *console )
}
}
- update_output( screen_buffer, &update_rect );
+ /* always try to use relative cursor positions in UNIX mode so that it works even if cursor
+ * position is out of sync */
+ if (update_rect.left <= update_rect.right && update_rect.top <= update_rect.bottom)
+ {
+ if (console->is_unix)
+ set_tty_cursor_relative( screen_buffer->console, update_rect.left, update_rect.top );
+ update_output( screen_buffer, &update_rect );
+ }
+ if (console->is_unix)
+ set_tty_cursor_relative( screen_buffer->console, screen_buffer->cursor_x, screen_buffer->cursor_y );
tty_sync( screen_buffer->console );
}
More information about the wine-cvs
mailing list