* [Qemu-devel] [PATCH] ui/console: add escape sequence \e[5,6n
@ 2016-03-05 16:08 Ren Kimura
0 siblings, 0 replies; 4+ messages in thread
From: Ren Kimura @ 2016-03-05 16:08 UTC (permalink / raw)
To: kraxel; +Cc: qemu-devel
Signed-off-by: Ren Kimura <rkx1209dev@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH] ui/console: add escape sequence \e[5,6n
@ 2016-03-05 16:50 Ren Kimura
2016-03-06 9:49 ` Peter Maydell
0 siblings, 1 reply; 4+ messages in thread
From: Ren Kimura @ 2016-03-05 16:50 UTC (permalink / raw)
To: kraxel; +Cc: qemu-devel
This patch add support of escape sequence "\e[5,6n".
This implementation similar to that of linux tty driver.
Signed-off-by: Ren Kimura <rkx1209dev@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] ui/console: add escape sequence \e[5,6n
2016-03-05 16:50 Ren Kimura
@ 2016-03-06 9:49 ` Peter Maydell
2016-03-06 10:04 ` Ren Kimura
0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-03-06 9:49 UTC (permalink / raw)
To: Ren Kimura; +Cc: Gerd Hoffmann, QEMU Developers
On 5 March 2016 at 23:50, Ren Kimura <rkx1209dev@gmail.com> wrote:
> This patch add support of escape sequence "\e[5,6n".
> This implementation similar to that of linux tty driver.
Could you describe what the escape sequences do, please?
(both in the commit message and in a comment in the code).
thanks
-- PMM
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] ui/console: add escape sequence \e[5,6n
2016-03-06 9:49 ` Peter Maydell
@ 2016-03-06 10:04 ` Ren Kimura
0 siblings, 0 replies; 4+ messages in thread
From: Ren Kimura @ 2016-03-06 10:04 UTC (permalink / raw)
To: Peter Maydell; +Cc: Gerd Hoffmann, QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 477 bytes --]
Oh OK. I'll send version2 of this patch that contains comment about these.
2016-03-06 18:49 GMT+09:00 Peter Maydell <peter.maydell@linaro.org>:
> On 5 March 2016 at 23:50, Ren Kimura <rkx1209dev@gmail.com> wrote:
> > This patch add support of escape sequence "\e[5,6n".
> > This implementation similar to that of linux tty driver.
>
> Could you describe what the escape sequences do, please?
> (both in the commit message and in a comment in the code).
>
> thanks
> -- PMM
>
[-- Attachment #2: Type: text/html, Size: 897 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-06 10:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-05 16:08 [Qemu-devel] [PATCH] ui/console: add escape sequence \e[5,6n Ren Kimura
-- strict thread matches above, loose matches on Subject: below --
2016-03-05 16:50 Ren Kimura
2016-03-06 9:49 ` Peter Maydell
2016-03-06 10:04 ` Ren Kimura
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).