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()
|