* [Qemu-devel] [PATCH] ncurses: resize console if required
@ 2008-04-28 3:54 Carlo Marcelo Arenas Belon
2008-04-28 8:58 ` Samuel Thibault
2008-04-28 10:14 ` Thiemo Seufer
0 siblings, 2 replies; 9+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2008-04-28 3:54 UTC (permalink / raw)
To: qemu-devel
The following patch instructs qemu to print an escape command to resize the
curses console to 80x25 if detected to have a different geometry (xterm and
friends use 80x24 by default).
Carlo
---
Index: curses.c
===================================================================
--- curses.c (revision 4274)
+++ curses.c (working copy)
@@ -367,6 +367,11 @@
invalidate = 1;
+ /* check size of console and try to adjust if needed */
+ getmaxyx(stdscr, gheight, gwidth);
+ if ((gwidth != 80) || (gheight != 25)) {
+ printf("\033[8;25;80t");
+ }
/* Standard VGA initial text mode dimensions */
curses_resize(ds, 80, 25);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 3:54 [Qemu-devel] [PATCH] ncurses: resize console if required Carlo Marcelo Arenas Belon
@ 2008-04-28 8:58 ` Samuel Thibault
2008-04-28 17:56 ` Carlo Marcelo Arenas Belon
2008-04-28 10:14 ` Thiemo Seufer
1 sibling, 1 reply; 9+ messages in thread
From: Samuel Thibault @ 2008-04-28 8:58 UTC (permalink / raw)
To: qemu-devel
Hello,
Carlo Marcelo Arenas Belon, le Sun 27 Apr 2008 22:54:45 -0500, a écrit :
> The following patch instructs qemu to print an escape command to resize the
> curses console to 80x25 if detected to have a different geometry (xterm and
> friends use 80x24 by default).
> + /* check size of console and try to adjust if needed */
> + getmaxyx(stdscr, gheight, gwidth);
> + if ((gwidth != 80) || (gheight != 25)) {
> + printf("\033[8;25;80t");
> + }
You can not just spit out escape sequences like this without know the
kind of terminal you're in, you know :)
At least check the TERM environment variable for those kind you know
support it. Also, this should probably go inside the curses_resize()
function, so that when the guest resizes to e.g. 80x50, the xterm window
gets resized too.
Samuel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 3:54 [Qemu-devel] [PATCH] ncurses: resize console if required Carlo Marcelo Arenas Belon
2008-04-28 8:58 ` Samuel Thibault
@ 2008-04-28 10:14 ` Thiemo Seufer
2008-04-28 17:31 ` Carlo Marcelo Arenas Belon
1 sibling, 1 reply; 9+ messages in thread
From: Thiemo Seufer @ 2008-04-28 10:14 UTC (permalink / raw)
To: Carlo Marcelo Arenas Belon; +Cc: qemu-devel
Carlo Marcelo Arenas Belon wrote:
> The following patch instructs qemu to print an escape command to resize the
> curses console to 80x25 if detected to have a different geometry (xterm and
> friends use 80x24 by default).
Sounds like this should be specific to the PC/VGA emulation.
Thiemo
> Carlo
>
> ---
> Index: curses.c
> ===================================================================
> --- curses.c (revision 4274)
> +++ curses.c (working copy)
> @@ -367,6 +367,11 @@
>
> invalidate = 1;
>
> + /* check size of console and try to adjust if needed */
> + getmaxyx(stdscr, gheight, gwidth);
> + if ((gwidth != 80) || (gheight != 25)) {
> + printf("\033[8;25;80t");
> + }
> /* Standard VGA initial text mode dimensions */
> curses_resize(ds, 80, 25);
> }
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 17:31 ` Carlo Marcelo Arenas Belon
@ 2008-04-28 17:20 ` Samuel Thibault
2008-04-28 19:17 ` andrzej zaborowski
1 sibling, 0 replies; 9+ messages in thread
From: Samuel Thibault @ 2008-04-28 17:20 UTC (permalink / raw)
To: qemu-devel
Carlo Marcelo Arenas Belon, le Mon 28 Apr 2008 12:31:13 -0500, a écrit :
> On Mon, Apr 28, 2008 at 11:14:15AM +0100, Thiemo Seufer wrote:
> > Carlo Marcelo Arenas Belon wrote:
> > > The following patch instructs qemu to print an escape command to resize the
> > > curses console to 80x25 if detected to have a different geometry (xterm and
> > > friends use 80x24 by default).
> >
> > Sounds like this should be specific to the PC/VGA emulation.
>
> not sure what you mean, but the curses.c emulation assumes (and is hardcoded)
> to a 80x25 console anyway.
Initial, yes. But it gets initialized early to the platform value by the
firmware (e.g. the VGA BIOS, but could be whatever else).
Samuel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 10:14 ` Thiemo Seufer
@ 2008-04-28 17:31 ` Carlo Marcelo Arenas Belon
2008-04-28 17:20 ` Samuel Thibault
2008-04-28 19:17 ` andrzej zaborowski
0 siblings, 2 replies; 9+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2008-04-28 17:31 UTC (permalink / raw)
To: Thiemo Seufer; +Cc: qemu-devel
On Mon, Apr 28, 2008 at 11:14:15AM +0100, Thiemo Seufer wrote:
> Carlo Marcelo Arenas Belon wrote:
> > The following patch instructs qemu to print an escape command to resize the
> > curses console to 80x25 if detected to have a different geometry (xterm and
> > friends use 80x24 by default).
>
> Sounds like this should be specific to the PC/VGA emulation.
not sure what you mean, but the curses.c emulation assumes (and is hardcoded)
to a 80x25 console anyway.
this patch only checks the window size of the console that is being used and
sends it an escape command to change its size to what the curses console will
use so that they match; otherwise if starting qemu from an 80x24 xterm with
-curses you won't be able to see the last line of the console until the window
is resized.
Carlo
> > ---
> > Index: curses.c
> > ===================================================================
> > --- curses.c (revision 4274)
> > +++ curses.c (working copy)
> > @@ -367,6 +367,11 @@
> >
> > invalidate = 1;
> >
> > + /* check size of console and try to adjust if needed */
> > + getmaxyx(stdscr, gheight, gwidth);
> > + if ((gwidth != 80) || (gheight != 25)) {
> > + printf("\033[8;25;80t");
> > + }
> > /* Standard VGA initial text mode dimensions */
> > curses_resize(ds, 80, 25);
> > }
> >
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 8:58 ` Samuel Thibault
@ 2008-04-28 17:56 ` Carlo Marcelo Arenas Belon
2008-04-28 23:16 ` Samuel Thibault
0 siblings, 1 reply; 9+ messages in thread
From: Carlo Marcelo Arenas Belon @ 2008-04-28 17:56 UTC (permalink / raw)
To: qemu-devel
On Mon, Apr 28, 2008 at 09:58:27AM +0100, Samuel Thibault wrote:
> Hello,
>
> Carlo Marcelo Arenas Belon, le Sun 27 Apr 2008 22:54:45 -0500, a écrit :
> > The following patch instructs qemu to print an escape command to resize the
> > curses console to 80x25 if detected to have a different geometry (xterm and
> > friends use 80x24 by default).
>
> > + /* check size of console and try to adjust if needed */
> > + getmaxyx(stdscr, gheight, gwidth);
> > + if ((gwidth != 80) || (gheight != 25)) {
> > + printf("\033[8;25;80t");
> > + }
>
> You can not just spit out escape sequences like this without know the
> kind of terminal you're in, you know :)
my original patch was checking the TERM variable for xterm or rxvt but since
CSI Window manipulation comes from dtterm I would expect most terminal
emulators to support that, do you have one that does not?
in the case of xterm with allowWindowOps = false the escape string gets just
ignored with no visible output, so expected the same from a terminal that
doesn't support it, but since it seems all the terminals I have access to do,
wasn't able to test that.
> At least check the TERM environment variable for those kind you know
> support it. Also, this should probably go inside the curses_resize()
> function, so that when the guest resizes to e.g. 80x50, the xterm window
> gets resized too.
from my tests, while booting a linux guest, curses_resize will be called with
a 66 x 3 geometry at least once, and a first attempt to make the guest use a
resized console of 80x50 didn't reflect correctly in the curses side either so
I settled for this different implementation as a starting point, and that
solves the problem with default sized xterm used as a curses console.
my intention with this patch was to propose a simple solution to this problem
and hopefully get someone else with more experience in curses and terminal
emulations intrigued enough to give it a more complete spin.
Carlo
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 17:31 ` Carlo Marcelo Arenas Belon
2008-04-28 17:20 ` Samuel Thibault
@ 2008-04-28 19:17 ` andrzej zaborowski
2008-04-28 23:18 ` Samuel Thibault
1 sibling, 1 reply; 9+ messages in thread
From: andrzej zaborowski @ 2008-04-28 19:17 UTC (permalink / raw)
To: qemu-devel
On 28/04/2008, Carlo Marcelo Arenas Belon <carenas@sajinet.com.pe> wrote:
> On Mon, Apr 28, 2008 at 11:14:15AM +0100, Thiemo Seufer wrote:
> > Carlo Marcelo Arenas Belon wrote:
> > > The following patch instructs qemu to print an escape command to resize the
> > > curses console to 80x25 if detected to have a different geometry (xterm and
> > > friends use 80x24 by default).
> >
> > Sounds like this should be specific to the PC/VGA emulation.
>
>
> not sure what you mean, but the curses.c emulation assumes (and is hardcoded)
> to a 80x25 console anyway.
It's only this way because SDL uses 640x400, but it can change when
the vga starts living. For example the text mode ms windows installer
(80x43 or something) worked fine for me with -curses.
>
> this patch only checks the window size of the console that is being used and
> sends it an escape command to change its size to what the curses console will
> use so that they match; otherwise if starting qemu from an 80x24 xterm with
> -curses you won't be able to see the last line of the console until the window
> is resized.
To be honest I wasn't aware that there's a sequence to request
terminal size change. "man console_codes" on my system doesn't list
this sequence and also it doesn't seem to have any effect in
gnome-terminal. This backend however is the curses backend, not
terminal backend and even if the sequence worked, we should only use
what curses can provide (this means that we don't even need a unix
terminal). It seems that curses generally wants programs to be aware
of the terminal size and conform, rather than have any say. So that
would be a policy change also.
Regards
--
Please do not print this email unless absolutely necessary. Spread
environmental awareness.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 17:56 ` Carlo Marcelo Arenas Belon
@ 2008-04-28 23:16 ` Samuel Thibault
0 siblings, 0 replies; 9+ messages in thread
From: Samuel Thibault @ 2008-04-28 23:16 UTC (permalink / raw)
To: qemu-devel
Carlo Marcelo Arenas Belon, le Mon 28 Apr 2008 12:56:31 -0500, a écrit :
> On Mon, Apr 28, 2008 at 09:58:27AM +0100, Samuel Thibault wrote:
> > Hello,
> >
> > Carlo Marcelo Arenas Belon, le Sun 27 Apr 2008 22:54:45 -0500, a écrit :
> > > + printf("\033[8;25;80t");
> >
> > You can not just spit out escape sequences like this without know the
> > kind of terminal you're in, you know :)
>
> my original patch was checking the TERM variable for xterm or rxvt but since
> CSI Window manipulation comes from dtterm I would expect most terminal
> emulators to support that, do you have one that does not?
My good old _real_ ampex232 TTY most probably doesn't (I can't check
right now).
> in the case of xterm with allowWindowOps = false the escape string gets just
> ignored with no visible output, so expected the same from a terminal that
> doesn't support it,
If it supports CSI sequences.
> > At least check the TERM environment variable for those kind you know
> > support it. Also, this should probably go inside the curses_resize()
> > function, so that when the guest resizes to e.g. 80x50, the xterm window
> > gets resized too.
>
> from my tests, while booting a linux guest, curses_resize will be called with
> a 66 x 3 geometry at least once,
When it goes in graphical mode, yes.
> and a first attempt to make the guest use a
> resized console of 80x50 didn't reflect correctly in the curses side either
Works fine for me.
> my intention with this patch was to propose a simple solution to this problem
> and hopefully get someone else with more experience in curses and terminal
> emulations intrigued enough to give it a more complete spin.
Ok.
Samuel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Qemu-devel] [PATCH] ncurses: resize console if required
2008-04-28 19:17 ` andrzej zaborowski
@ 2008-04-28 23:18 ` Samuel Thibault
0 siblings, 0 replies; 9+ messages in thread
From: Samuel Thibault @ 2008-04-28 23:18 UTC (permalink / raw)
To: qemu-devel
andrzej zaborowski, le Mon 28 Apr 2008 21:17:56 +0200, a écrit :
> we should only use what curses can provide (this means that we don't
> even need a unix terminal).
Curses doesn't provide this in the terminfo database.
> It seems that curses generally wants programs to be aware
> of the terminal size and conform, rather than have any say.
> So that would be a policy change also.
Well, the resizing sequence will trigger a SIGWINCH, which will make
ncurses adapt to the new size, so it's more a negociation.
Samuel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-04-28 23:18 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28 3:54 [Qemu-devel] [PATCH] ncurses: resize console if required Carlo Marcelo Arenas Belon
2008-04-28 8:58 ` Samuel Thibault
2008-04-28 17:56 ` Carlo Marcelo Arenas Belon
2008-04-28 23:16 ` Samuel Thibault
2008-04-28 10:14 ` Thiemo Seufer
2008-04-28 17:31 ` Carlo Marcelo Arenas Belon
2008-04-28 17:20 ` Samuel Thibault
2008-04-28 19:17 ` andrzej zaborowski
2008-04-28 23:18 ` 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).