From patchwork Sat Mar 5 16:08:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ren Kimura X-Patchwork-Id: 592482 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E251F1402A0 for ; Sun, 6 Mar 2016 10:22:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=nvPJbR5J; dkim-atps=neutral Received: from localhost ([::1]:48361 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acLWV-00029w-0w for incoming@patchwork.ozlabs.org; Sat, 05 Mar 2016 18:22:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acEkd-0008So-Oi for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:08:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1acEkZ-0000la-OY for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:08:19 -0500 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]:33766) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1acEkZ-0000lI-HI for qemu-devel@nongnu.org; Sat, 05 Mar 2016 11:08:15 -0500 Received: by mail-pa0-x22a.google.com with SMTP id fl4so52431993pad.0 for ; Sat, 05 Mar 2016 08:08:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=W0LdGzCRaWlQtCi7UvC4A7k1kMs1VU0gt/EvwBV26/k=; b=nvPJbR5JPmwQPGISQDHraGGAoEpLCRKsSyX75G3+ydvnbKKwiYcagWRFUWVjLvtFUL Rm1Z44tCRxQ+ozCnuKMLsaTz8HFprwSxEej/17tKa0I73GF362Ykvktd8bWOl6VDSYpv NiR4pLkIIcNTrSZIokjX7P6r+mpuW42XGc8vSuC5R3sc47neXXbyYAPYt8W5WV6W3PDz JRtp890IHcjAy0i/x3+8g7Gr+OePLjaU4Ava38VJj/VAz7P19oP6qLiM515x7cPNgqaX iQMGGsWOTUVFFQFUW2I8U7biX/eTWG2PX36aBQPpw/R6wg9cZ4psVwffKaddEj9OfiPC NdOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=W0LdGzCRaWlQtCi7UvC4A7k1kMs1VU0gt/EvwBV26/k=; b=PDrSHoBO4+mQV6uh0io+kWN/ttnD231l02oH7Xg0JNk9g2aM6b3GMuzLmryVjCLaDj 4mFScoID0BqXh5/bo2+3RBScUbCM90xpHpbrYhroNXqEjDAADPFxZ0p2S27QSXoZoEDF MV5TWk4p32jsQ6PZNjoLV770hazfs0IwsknWAXJZYwIc3htpMYriR0wlHwtkePUUgyF3 H5lbOb2Np0ck9DXx0lpnVJLpxP7SW5+er30bQ9JAFLaL/8OoUvUmjPODPCJtzaRasfcr j9YeRU6OxqPLBHBgP3lXSmefNUC4LvTzNjWpUVLINIC5MRmvtrPmX58/P4V7o4180x7i aKpg== X-Gm-Message-State: AD7BkJJIdooT8L3D56u6OZInIvKkqJmA/XjdE75sfDsYgTK3Jr6AkVXYW+z4IONoFwPxIg== X-Received: by 10.66.118.198 with SMTP id ko6mr20939464pab.11.1457194094590; Sat, 05 Mar 2016 08:08:14 -0800 (PST) Received: from localhost.localdomain (112-70-0-137f1.hyg1.eonet.ne.jp. [112.70.0.137]) by smtp.googlemail.com with ESMTPSA id x64sm13321936pfa.72.2016.03.05.08.08.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Mar 2016 08:08:13 -0800 (PST) From: Ren Kimura To: kraxel@redhat.com Date: Sun, 6 Mar 2016 01:08:02 +0900 Message-Id: <1457194082-9023-1-git-send-email-rkx1209dev@gmail.com> X-Mailer: git-send-email 2.5.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::22a X-Mailman-Approved-At: Sat, 05 Mar 2016 18:21:50 -0500 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] ui/console: add escape sequence \e[5,6n X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 */