From 17410ee4539bb5216421bb9f9dc287b1f678b6cd Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Tue, 10 May 2011 10:55:21 +0200 Subject: qemu-char.h, console.h: upstream integration Change-Id: Ibd11e84a4d48c1d6c4a168056869a7480bc89930 --- console.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'console.c') diff --git a/console.c b/console.c index 73371fb..18d1dc2 100644 --- a/console.c +++ b/console.c @@ -137,6 +137,7 @@ struct TextConsole { TextAttributes t_attrib; /* currently active text attributes */ TextCell *cells; int text_x[2], text_y[2], cursor_invalidate; + int echo; int update_x0; int update_y0; @@ -1069,8 +1070,10 @@ void console_select(unsigned int index) if (index >= MAX_CONSOLES) return; + if (active_console) { active_console->g_width = ds_get_width(active_console->ds); active_console->g_height = ds_get_height(active_console->ds); + } s = consoles[index]; if (s) { DisplayState *ds = s->ds; @@ -1184,9 +1187,15 @@ void kbd_put_keysym(int keysym) *q++ = '\033'; *q++ = '['; *q++ = keysym & 0xff; + } else if (s->echo && (keysym == '\r' || keysym == '\n')) { + console_puts(s->chr, (const uint8_t *) "\r", 1); + *q++ = '\n'; } else { *q++ = keysym; } + if (s->echo) { + console_puts(s->chr, buf, q - buf); + } if (s->chr->chr_read) { qemu_fifo_write(&s->out_fifo, buf, q - buf); kbd_send_chars(s); @@ -1443,6 +1452,13 @@ static int n_text_consoles; static CharDriverState *text_consoles[128]; static QemuOpts *text_console_opts[128]; +static void text_console_set_echo(CharDriverState *chr, bool echo) +{ + TextConsole *s = chr->opaque; + + s->echo = echo; +} + static void text_console_do_init(CharDriverState *chr, DisplayState *ds, QemuOpts *opts) { TextConsole *s; @@ -1526,6 +1542,9 @@ static void text_console_do_init(CharDriverState *chr, DisplayState *ds, QemuOpt CharDriverState *text_console_init(QemuOpts *opts) { CharDriverState *chr; + TextConsole *s; + unsigned width; + unsigned height; chr = qemu_mallocz(sizeof(CharDriverState)); @@ -1537,6 +1556,30 @@ CharDriverState *text_console_init(QemuOpts *opts) text_console_opts[n_text_consoles] = opts; n_text_consoles++; + width = qemu_opt_get_number(opts, "width", 0); + if (width == 0) + width = qemu_opt_get_number(opts, "cols", 0) * FONT_WIDTH; + + height = qemu_opt_get_number(opts, "height", 0); + if (height == 0) + height = qemu_opt_get_number(opts, "rows", 0) * FONT_HEIGHT; + + if (width == 0 || height == 0) { + s = new_console(NULL, TEXT_CONSOLE); + } else { + s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE); + } + + if (!s) { + free(chr); + return NULL; + } + + s->chr = chr; + s->g_width = width; + s->g_height = height; + chr->opaque = s; + chr->chr_set_echo = text_console_set_echo; return chr; } -- cgit v1.1