diff -r 6b70f16d585a Doc/library/curses.rst --- a/Doc/library/curses.rst Wed Apr 15 10:27:58 2015 -0400 +++ b/Doc/library/curses.rst Wed Apr 15 12:53:02 2015 -0400 @@ -599,6 +599,13 @@ Only one *ch* can be pushed before :meth:`getch` is called. +.. function:: update_lines_cols() + + Update :envvar:`LINES` and :envvar:`COLS`. Useful for detecting manual screen resize. + + .. versionadded:: 3.5 + + .. function:: unget_wch(ch) Push *ch* so the next :meth:`get_wch` will return it. diff -r 6b70f16d585a Doc/whatsnew/3.5.rst --- a/Doc/whatsnew/3.5.rst Wed Apr 15 10:27:58 2015 -0400 +++ b/Doc/whatsnew/3.5.rst Wed Apr 15 12:53:02 2015 -0400 @@ -289,6 +289,11 @@ don't provide any options to redirect it. (Contributed by Berker Peksag in :issue:`22389`.) +curses +------ +* The new :func:`curses.update_lines_cols` function updates the variables + :envvar:`curses.LINES` and :envvar:`curses.COLS`. + difflib ------- diff -r 6b70f16d585a Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Wed Apr 15 10:27:58 2015 -0400 +++ b/Modules/_cursesmodule.c Wed Apr 15 12:53:02 2015 -0400 @@ -2866,6 +2866,13 @@ Py_DECREF(m); return 1; } + +static PyObject * +PyCurses_update_lines_cols(PyObject *self) +{ + return PyLong_FromLong((long) update_lines_cols()); +} + #endif #ifdef HAVE_CURSES_RESIZETERM @@ -3268,6 +3275,9 @@ {"typeahead", (PyCFunction)PyCurses_TypeAhead, METH_VARARGS}, {"unctrl", (PyCFunction)PyCurses_UnCtrl, METH_VARARGS}, {"ungetch", (PyCFunction)PyCurses_UngetCh, METH_VARARGS}, +#if defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM) + {"update_lines_cols", (PyCFunction)PyCurses_update_lines_cols, METH_NOARGS}, +#endif #ifdef HAVE_NCURSESW {"unget_wch", (PyCFunction)PyCurses_Unget_Wch, METH_VARARGS}, #endif