Curses and resizing windows

C

Chris Share

I've been writing an application using curses, and have been trying to
handle resizing the terminal, if running in xterm or similar. Increasing
the window size is working perfectly, however shrinking it is not
working at all. No matter how much I shrink the window, the size
returned by getmaxyx() does not change. However as soon as I increase it
again, it works fine.

I've tracked the problem down to the fact I have created a window
derived from stdscr. A small script showing the effect is at the end of
this post.

Can anyone suggest how to solve this problem, that doesn't involve not
making a derwin of stdscr?

I've been googling for hours, but found nothing to help.

Python version is 2.3.4 on debian testing.

chris

#!/usr/bin/python
import curses, sys

def init_display(stdscr):
stdscr.clear()
stdscr.refresh()
size = stdscr.getmaxyx()
sys.stderr.write("Now %u x %u\n" % (size[1],size[0]))
rootwin = stdscr.derwin(20, 50, 0, 0)
return rootwin

def main(stdscr):
rootwin = init_display(stdscr)
while 1:
input = rootwin.getch()
if ( input == curses.KEY_RESIZE):
init_display(stdscr)
elif input == ord("q"):
sys.exit()
rootwin.refresh()

curses.wrapper(main)
 
T

Thomas Dickey

Chris Share said:
I've been writing an application using curses, and have been trying to
handle resizing the terminal, if running in xterm or similar. Increasing
the window size is working perfectly, however shrinking it is not
working at all. No matter how much I shrink the window, the size
returned by getmaxyx() does not change. However as soon as I increase it
again, it works fine.
I've tracked the problem down to the fact I have created a window
derived from stdscr. A small script showing the effect is at the end of
this post.

odd (thanks for the example - I don't know if this is a problem in
ncurses or in the python interface to it, but will check/see).
Can anyone suggest how to solve this problem, that doesn't involve not
making a derwin of stdscr?
I've been googling for hours, but found nothing to help.
Python version is 2.3.4 on debian testing.

probably should report it as a bug (so it's not overlooked).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top