classification
Title: curses: getmaxyx() breaks when the window shrinks
Type: behavior Stage: test needed
Components: Extension Modules Versions: Python 2.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, akuchling, doko (3)
Priority: normal Keywords

Created on 2004-07-04 11:33 by doko, last changed 2009-02-14 12:58 by ajaksu2.

Messages (3)
msg21400 - (view) Author: Matthias Klose (doko) Date: 2004-07-04 11:33
[forwarded from http://bugs.debian.org/257472]

When derived windows of stdscr have been created,
shrinking the terminal produces a KEY_RESIZE event, but
getmaxyx() returns the previous terminal size. Only by
increasing the window size does it return the correct
terminal dimensions.

A minimal script to show this effect is included below.

#!/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)


msg21401 - (view) Author: A.M. Kuchling (akuchling) Date: 2004-07-07 13:19
Logged In: YES 
user_id=11375

Confirmed.  I suspect this is a problem in ncurses, and will
write a C equivalent of the test program to verify this. 
The ncurses man page for derwin says: "The  subwindow 
functions  (subwin,  derwin, ...) are flaky,   incompletely
implemented, and not well tested," so an ncurses bug seems
likely.

msg82043 - (view) Author: Daniel Diniz (ajaksu2) Date: 2009-02-14 12:58
I get a different behavior, with shrinking reporting correct sizes, but
quiting with a "_curses.error: curses function returned NULL", on trunk,
KDE 3.5's Konsole._curses.error: curses function returned NULL
History
Date User Action Args
2009-02-14 12:58:57ajaksu2setnosy: + ajaksu2
stage: test needed
type: behavior
messages: + msg82043
versions: + Python 2.6, - Python 2.3
2004-07-04 11:33:05dokocreate