qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2] curses: resize terminal to fit console size
Date: Thu, 1 May 2008 02:52:40 -0500	[thread overview]
Message-ID: <20080501075240.GA7929@tapir> (raw)

[-- 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);
 }

             reply	other threads:[~2008-05-01  7:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-01  7:52 Carlo Marcelo Arenas Belon [this message]
2008-05-01 14:15 ` [Qemu-devel] [PATCH v2] curses: resize terminal to fit console size Samuel Thibault

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080501075240.GA7929@tapir \
    --to=carenas@sajinet.com.pe \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).