From af3a9031061251fbbee2c1f06b876c3732cfee71 Mon Sep 17 00:00:00 2001 From: ths Date: Wed, 11 Jul 2007 23:14:59 +0000 Subject: [PATCH] New features for QEMU text console, by Stefan Weil. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3068 c046a42c-6fe2-441c-8c8c-71466251a162 --- console.c | 61 ++++++++++++++++++++++++++++++++++++++------------- qemu-doc.texi | 11 ++++++++-- vl.c | 8 ++++--- vl.h | 2 +- 4 files changed, 61 insertions(+), 21 deletions(-) diff --git a/console.c b/console.c index a53b301774..f4b8dc58ed 100644 --- a/console.c +++ b/console.c @@ -104,10 +104,16 @@ int qemu_fifo_read(QEMUFIFO *f, uint8_t *buf, int len1) return len1; } +typedef enum { + GRAPHIC_CONSOLE, + TEXT_CONSOLE, + TEXT_CONSOLE_FIXED_SIZE +} console_type_t; + /* ??? This is mis-named. It is used for both text and graphical consoles. */ struct TextConsole { - int text_console; /* true if text console */ + console_type_t console_type; DisplayState *ds; /* Graphic console state. */ vga_hw_update_ptr hw_update; @@ -587,7 +593,7 @@ static void console_scroll(int ydelta) int i, y1; s = active_console; - if (!s || !s->text_console) + if (!s || (s->console_type == GRAPHIC_CONSOLE)) return; if (ydelta > 0) { @@ -990,13 +996,17 @@ void console_select(unsigned int index) s = consoles[index]; if (s) { active_console = s; - if (s->text_console) { + if (s->console_type != GRAPHIC_CONSOLE) { if (s->g_width != s->ds->width || s->g_height != s->ds->height) { + if (s->console_type == TEXT_CONSOLE_FIXED_SIZE) { + dpy_resize(s->ds, s->g_width, s->g_height); + } else { s->g_width = s->ds->width; s->g_height = s->ds->height; text_console_resize(s); } + } console_refresh(s); } else { vga_hw_invalidate(); @@ -1062,7 +1072,7 @@ void kbd_put_keysym(int keysym) int c; s = active_console; - if (!s || !s->text_console) + if (!s || (s->console_type == GRAPHIC_CONSOLE)) return; switch(keysym) { @@ -1104,7 +1114,7 @@ void kbd_put_keysym(int keysym) } } -static TextConsole *new_console(DisplayState *ds, int text) +static TextConsole *new_console(DisplayState *ds, console_type_t console_type) { TextConsole *s; int i; @@ -1115,16 +1125,18 @@ static TextConsole *new_console(DisplayState *ds, int text) if (!s) { return NULL; } - if (!active_console || (active_console->text_console && !text)) + if (!active_console || ((active_console->console_type != GRAPHIC_CONSOLE) && + (console_type == GRAPHIC_CONSOLE))) { active_console = s; + } s->ds = ds; - s->text_console = text; - if (text) { + s->console_type = console_type; + if (console_type != GRAPHIC_CONSOLE) { consoles[nb_consoles++] = s; } else { /* HACK: Put graphical consoles before text consoles. */ for (i = nb_consoles; i > 0; i--) { - if (!consoles[i - 1]->text_console) + if (consoles[i - 1]->console_type == GRAPHIC_CONSOLE) break; consoles[i] = consoles[i - 1]; } @@ -1140,7 +1152,7 @@ TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update, { TextConsole *s; - s = new_console(ds, 0); + s = new_console(ds, GRAPHIC_CONSOLE); if (!s) return NULL; s->hw_update = update; @@ -1152,20 +1164,22 @@ TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update, int is_graphic_console(void) { - return !active_console->text_console; + return active_console->console_type == GRAPHIC_CONSOLE; } -CharDriverState *text_console_init(DisplayState *ds) +CharDriverState *text_console_init(DisplayState *ds, const char *p) { CharDriverState *chr; TextConsole *s; int i,j; + unsigned width; + unsigned height; static int color_inited; chr = qemu_mallocz(sizeof(CharDriverState)); if (!chr) return NULL; - s = new_console(ds, 1); + s = new_console(ds, (p == 0) ? TEXT_CONSOLE : TEXT_CONSOLE_FIXED_SIZE); if (!s) { free(chr); return NULL; @@ -1193,8 +1207,25 @@ CharDriverState *text_console_init(DisplayState *ds) s->total_height = DEFAULT_BACKSCROLL; s->x = 0; s->y = 0; - s->g_width = s->ds->width; - s->g_height = s->ds->height; + width = s->ds->width; + height = s->ds->height; + if (p != 0) { + width = strtoul(p, (char **)&p, 10); + if (*p == 'C') { + p++; + width *= FONT_WIDTH; + } + if (*p == 'x') { + p++; + height = strtoul(p, (char **)&p, 10); + if (*p == 'C') { + p++; + height *= FONT_HEIGHT; + } + } + } + s->g_width = width; + s->g_height = height; /* Set text attribute defaults */ s->t_attrib_default.bold = 0; diff --git a/qemu-doc.texi b/qemu-doc.texi index 0f33f78231..67b78cdcda 100644 --- a/qemu-doc.texi +++ b/qemu-doc.texi @@ -555,8 +555,15 @@ Use @code{-serial none} to disable all serial ports. Available character devices are: @table @code -@item vc -Virtual console +@item vc[:WxH] +Virtual console. Optionally, a width and height can be given in pixel with +@example +vc:800x600 +@end example +It is also possible to specify width or height in characters: +@example +vc:80Cx24C +@end example @item pty [Linux only] Pseudo TTY (a new PTY is automatically allocated) @item none diff --git a/vl.c b/vl.c index 0d059f40f2..497a1e5fac 100644 --- a/vl.c +++ b/vl.c @@ -2923,7 +2923,9 @@ CharDriverState *qemu_chr_open(const char *filename) const char *p; if (!strcmp(filename, "vc")) { - return text_console_init(&display_state); + return text_console_init(&display_state, 0); + } else if (strstart(filename, "vc:", &p)) { + return text_console_init(&display_state, p); } else if (!strcmp(filename, "null")) { return qemu_chr_open_null(); } else @@ -7970,7 +7972,7 @@ int main(int argc, char **argv) devname); exit(1); } - if (!strcmp(devname, "vc")) + if (strstart(devname, "vc", 0)) qemu_chr_printf(serial_hds[i], "serial%d console\r\n", i); } } @@ -7984,7 +7986,7 @@ int main(int argc, char **argv) devname); exit(1); } - if (!strcmp(devname, "vc")) + if (strstart(devname, "vc", 0)) qemu_chr_printf(parallel_hds[i], "parallel%d console\r\n", i); } } diff --git a/vl.h b/vl.h index 85014cd15f..6627bcef0a 100644 --- a/vl.h +++ b/vl.h @@ -351,7 +351,7 @@ void vga_hw_invalidate(void); void vga_hw_screen_dump(const char *filename); int is_graphic_console(void); -CharDriverState *text_console_init(DisplayState *ds); +CharDriverState *text_console_init(DisplayState *ds, const char *p); void console_select(unsigned int index); /* serial ports */ -- GitLab