Skip to content

Commit

Permalink
py39: Automatically call resize_term(0, 0) for get{ch,key,_wch}()
Browse files Browse the repository at this point in the history
Hand-hacked the patch file from a previous commit to get these results
roughly like so:

1. git format-patch -1 30ca08b
2. $EDITOR $OUTPUT.patch
3. (remove all the changes except the py38 ones)
4. s/py38/py39/g
5. git am $OUTPUT.patch

Built and tested against Python 3.9rc1 on Windows 10 using
Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29111 for x64.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
  • Loading branch information
mbolivar-nordic authored and carlescufi committed Nov 3, 2020
1 parent 76cd5b3 commit e81c42e
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion py39/_cursesmodule.c
Expand Up @@ -1280,6 +1280,12 @@ _curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1,
else {
rtn = mvwgetch(self->win, y, x);
}

// windows-curses hack to make resizing work the same as in ncurses. See
// PDCurses' documentation for resize_term().
if (rtn == KEY_RESIZE)
resize_term(0, 0);

Py_END_ALLOW_THREADS

return rtn;
Expand Down Expand Up @@ -1317,6 +1323,12 @@ _curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1,
else {
rtn = mvwgetch(self->win, y, x);
}

// windows-curses hack to make resizing work the same as in ncurses. See
// PDCurses' documentation for resize_term().
if (rtn == KEY_RESIZE)
resize_term(0, 0);

Py_END_ALLOW_THREADS

if (rtn == ERR) {
Expand Down Expand Up @@ -1384,8 +1396,14 @@ _curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1,
PyErr_SetString(PyCursesError, "no input");
return NULL;
}
if (ct == KEY_CODE_YES)
if (ct == KEY_CODE_YES) {
// windows-curses hack to make resizing work the same as in ncurses. See
// PDCurses' documentation for resize_term().
if (rtn == KEY_RESIZE)
resize_term(0, 0);

return PyLong_FromLong(rtn);
}
else
return PyUnicode_FromOrdinal(rtn);
}
Expand Down

0 comments on commit e81c42e

Please sign in to comment.