* [Qemu-devel] [PATCH v2] curses: resize terminal to fit console size
@ 2008-05-01 7:52 Carlo Marcelo Arenas Belon
2008-05-01 14:15 ` Samuel Thibault
0 siblings, 1 reply; 2+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2008-05-01 7:52 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 574 bytes --]
The following patch, sends a resize escape character to the terminal used
when running under curses to try to change its geometry to match the console
size (as it is done with SDL).
As suggested, I'd added a check for the type of terminal used (currently only
blacklisting "linux", eventhough from my tests it was just ignoring the escape
sequence) which will need to be expanded to all known terminals which don't
support this sequence. As suggested as well, I'd moved the resizing to the
resize function so that it will be also called if the VGA mode is changed.
Carlo
[-- Attachment #2: qemu-curses-resize-v2.patch --]
[-- Type: text/plain, Size: 1077 bytes --]
Index: curses.c
===================================================================
--- curses.c (revision 4290)
+++ curses.c (working copy)
@@ -39,6 +39,7 @@
static console_ch_t screen[160 * 100];
static WINDOW *screenpad = NULL;
+static int term_resizable = 1;
static int width, height, gwidth, gheight, invalidate;
static int px, py, sminx, sminy, smaxx, smaxy;
@@ -98,6 +99,9 @@
if (w == gwidth && h == gheight)
return;
+ if (term_resizable && !is_graphic_console())
+ printf("\033[8;%d;%dt", h, w);
+
gwidth = w;
gheight = h;
@@ -334,6 +338,7 @@
void curses_display_init(DisplayState *ds, int full_screen)
{
+ const char *term;
#ifndef _WIN32
if (!isatty(1)) {
fprintf(stderr, "We need a terminal output\n");
@@ -367,6 +372,11 @@
invalidate = 1;
+ /* check type of console and if it can be resized */
+ term = getenv("TERM");
+ if (strcmp(term, "linux") == 0) {
+ term_resizable = 0;
+ }
/* Standard VGA initial text mode dimensions */
curses_resize(ds, 80, 25);
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-05-01 14:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-01 7:52 [Qemu-devel] [PATCH v2] curses: resize terminal to fit console size Carlo Marcelo Arenas Belon
2008-05-01 14:15 ` Samuel Thibault
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).