conhost: Force using relative cursor positioning in update_read_output.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-09-21 17:06:03 +02:00 committed by Alexandre Julliard
parent aecf53d0f7
commit fc408f3d43
1 changed files with 31 additions and 1 deletions

View File

@ -309,6 +309,27 @@ static void set_tty_cursor( struct console *console, unsigned int x, unsigned in
tty_write( console, buf, strlen(buf) ); 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 ) static void set_tty_attr( struct console *console, unsigned int attr )
{ {
char buf[8]; char buf[8];
@ -1216,7 +1237,16 @@ static void update_read_output( struct console *console )
} }
} }
/* 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 ); 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 ); tty_sync( screen_buffer->console );
} }