Signed-off-by: Ren Kimura <rkx1209...@gmail.com> --- ui/console.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/ui/console.c b/ui/console.c index ae61382..854ec98 100644 --- a/ui/console.c +++ b/ui/console.c @@ -757,6 +757,25 @@ static void console_clear_xy(QemuConsole *s, int x, int y) update_xy(s, x, y); } +static void console_respond_str(QemuConsole *s, const char *buf) +{ + TextCell *c; + int y1; + while (*buf) { + if (s->x >= s->width) { + s->x = 0; + console_put_lf(s); + } + y1 = (s->y_base + s->y) % s->total_height; + c = &s->cells[y1 * s->width + s->x]; + c->ch = *buf; + c->t_attrib = s->t_attrib; + update_xy(s, s->x, s->y); + s->x++; + buf++; + } +} + /* set cursor, checking bounds */ static void set_cursor(QemuConsole *s, int x, int y) { @@ -782,6 +801,7 @@ static void console_putchar(QemuConsole *s, int ch) TextCell *c; int y1, i; int x, y; + char response[40]; switch(s->state) { case TTY_STATE_NORM: @@ -957,7 +977,17 @@ static void console_putchar(QemuConsole *s, int ch) break; case 'n': /* report cursor position */ - /* TODO: send ESC[row;colR */ + switch (s->esc_params[0]) { + case 5: + console_respond_str(s, "\033[0n"); + break; + case 6: + sprintf(response, "\033[%d;%dR", + (s->y_base + s->y) % s->total_height + 1, + s->x + 1); + console_respond_str(s, response); + break; + } break; case 's': /* save cursor position */ -- 2.5.0