bug-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CDK & Terminal Resizing


From: Thomas Dickey
Subject: Re: CDK & Terminal Resizing
Date: Sat, 9 Apr 2011 20:58:33 -0400 (EDT)

On Sat, 9 Apr 2011, Marc Smith wrote:

Thanks for the quick reply.

So, for now, I'm not too worried about making the widgets look right
if the user resizes (to something smaller). However, I would like to
make my program able to "recover" if the user shrinks the terminal to
something smaller than the original.

I'm new to ncurses and CDK, so maybe this is something simple I'm
missing. Lets say on my screen I have all my widgets up and then the
user makes the terminal say 1x1 and then expands it back to the
original size (or greater). I've tried calling refreshCDKScreen()
after the screen is back to the original size, but that doesn't seem
to fix the widgets. Any ideas?

yes - same issues, more details. CDK doesn't know about resizable screens. It could be modified to re-layout its widgets to fit in a smaller screen, or to increase a widget. (I haven't done it - usual reason - time). ncurses resizes some of the "easy" cases, to be helpful,
but that doesn't give a complete solution - the application (CDK) has to
do work.

Supposing that it were modified to be resizable, it would have to ensure that the data would be presented in roughly the same way (for example, the same current line in a selection list). It would also have to have some way to tell it that some widgets have limits on their intended size (and what part has to be visible on a 1x1 screen).



--Marc


On Fri, Apr 8, 2011 at 8:29 PM, Thomas Dickey <address@hidden> wrote:
On Fri, 8 Apr 2011, Marc Smith wrote:

Hi,

I didn't see a separate list for "ncurses user questions", so I'm
assuming this list is for that as well. If not, I'd appreciate it if
anyone could redirect me to the right place.

So, I'm using CDK (5.0.20081105) (ncurses 5.7) to develop a text user
interface. Resizing terminals doesn't seem to play nice with the CDK
widgets -- the text on the screen is messed up after resizing the
terminal to something smaller than what was started with and then back
to the original size (or bigger).

yes - it doesn't do that...

I'd done this more/less for dialog.  It was much simpler than CDK would be.

I've experimented with other ncurses related things (mc, dialog, etc.)
and they seem to resize correctly. I understand I can catch the
SIGWINCH via KEY_RESIZE / getch() and I am able to do that, but I'm
not sure how I can make the widgets resize "nicely". I've tried using
refreshCDKScreen() and others, but I can't get it.

There's more than one thing which would have to be done.
When the keypad() function is enabled (which it is), then
the ncurses getch/wgetch returns KEY_RESIZE when it has updated
stdscr/curscr to respond to the SIGWINCH.

At that point, in dialog, I provided for a jump back to the initialization
region of a widget, so it would then fall into the getch-loop.

CDK wraps calls to wgetch in getchCDKObject.  Some are buried down a level
or two, making it impractical to "jump back" (other than a setjmp).

I think, that to make SIGWINCH work here, CDK would have to be reorganized
to use some sort of event-loop (keeping the wgetch's at that level), and to
add a list of the widgets, which the event-loop function could adjust in one
place.

Alternatively (closer to how CDK is done now), it could have a method added
to each widget to tell it to resize.

I'm sure this is something that could be modified in CDK for the
widgets to resize nicely, but how can I do this in my own program
without modifying CDK? Any ideas?

You'd have to (in effect) write your own resize functions and register them
as callbacks.  It's probably doable (since the WINDOW's are exposed in the
widget structures), but rather tedious to implement for the whole
library.

--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net



--
Thomas E. Dickey
http://invisible-island.net
ftp://invisible-island.net

reply via email to

[Prev in Thread] Current Thread [Next in Thread]