From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JrTIU-0003FD-8d for qemu-devel@nongnu.org; Thu, 01 May 2008 03:33:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JrTIS-0003Co-Ld for qemu-devel@nongnu.org; Thu, 01 May 2008 03:33:41 -0400 Received: from [199.232.76.173] (port=37921 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JrTIS-0003CO-7R for qemu-devel@nongnu.org; Thu, 01 May 2008 03:33:40 -0400 Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JrTIS-0004E2-0k for qemu-devel@nongnu.org; Thu, 01 May 2008 03:33:40 -0400 Received: from tapir.sajinet.com.pe ([66.139.79.212]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JrTIQ-0002Qt-6d for qemu-devel@nongnu.org; Thu, 01 May 2008 03:33:38 -0400 Date: Thu, 1 May 2008 02:52:40 -0500 From: Carlo Marcelo Arenas Belon Message-ID: <20080501075240.GA7929@tapir> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="KsGdsel6WgEHnImy" Content-Disposition: inline Subject: [Qemu-devel] [PATCH v2] curses: resize terminal to fit console size Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --KsGdsel6WgEHnImy Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="qemu-curses-resize-v2.patch" 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); } --KsGdsel6WgEHnImy--