classification
Title: window.getmaxyx() doesn't return updated height when window is resized
Type: behavior Stage:
Components: Extension Modules Versions: Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: nova
Priority: normal Keywords:

Created on 2020-01-28 09:43 by nova, last changed 2020-01-28 09:43 by nova.

Files
File name Uploaded Description Edit
bug_curses.mp4 nova, 2020-01-28 09:43 video demonstrating the effect
Messages (1)
msg360849 - (view) Author: Nova Parker (nova) Date: 2020-01-28 09:43
Package : python(v3.6.9)
Severity: normal

When a window object has been created using curses.newwin(), increasing
the terminal size produces the KEY_RESIZE events, but getmaxyx() returns
the previous terminal size. Only by decreasing the terminal size does it
return the correct terminal dimensions.

Attachment includes:
1. video demonstrating the effect

Following is the script to reproduce the effect:

import curses

def init_curses():
    curses.initscr()
    window = curses.newwin(curses.LINES - 1, curses.COLS, 0, 0)

    # window = curses.initscr()

    curses.raw()
    curses.noecho()
    curses.cbreak()
    window.keypad(True)

    return window

def restore_terminal(window):
    curses.noraw()
    curses.nocbreak()
    window.keypad(False)
    curses.echo()
    curses.endwin()

def main():
    try:
        window = init_curses()
        resize_no = 0
        maxy, maxx = window.getmaxyx()

        dimension_string = "resize_no: " + str(resize_no) + ". maxy: " + str(maxy) + "; maxx: " + str(maxx) + '\n'
        window.addstr(dimension_string)

        while True:
            ch = window.getch()
            window.clear()

            if ch == curses.KEY_RESIZE:
                resize_no += 1

                maxy, maxx = window.getmaxyx()
                dimension_string = "resize_no: " + str(resize_no) + ". maxy: " + str(maxy) + "; maxx: " + str(maxx) + '\n'
                window.addstr(dimension_string)


    finally:
        restore_terminal(window)

if __name__ == '__main__':
    main()
History
Date User Action Args
2020-01-28 09:43:09novacreate