From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acFQ1-0007V8-3a for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:51:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acFPx-0001cy-0u for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:51:05 -0500 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]:36164) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acFPw-0001cu-P6 for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:51:00 -0500 Received: by mail-pa0-x233.google.com with SMTP id fi3so50750342pac.3 for ; Sat, 05 Mar 2016 08:51:00 -0800 (PST) From: Ren Kimura Date: Sun, 6 Mar 2016 01:50:53 +0900 Message-Id: <1457196653-9541-1-git-send-email-rkx1209dev@gmail.com> Subject: [Qemu-devel] [PATCH] ui/console: add escape sequence \e[5,6n List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kraxel@redhat.com Cc: qemu-devel@nongnu.org This patch add support of escape sequence "\e[5,6n". This implementation similar to that of linux tty driver. Signed-off-by: Ren Kimura --- 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