[Top][All Lists]

[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: Fri, 8 Apr 2011 20:29:58 -0400 (EDT)

On Fri, 8 Apr 2011, Marc Smith wrote:


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

Thomas E. Dickey

reply via email to

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