diff options
author | Walter Dörwald <walter@livinglogic.de> | 2006-06-19 08:07:50 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2006-06-19 08:07:50 (GMT) |
commit | 4994d9546c723c01c2f4b34a401c544c859d3404 (patch) | |
tree | 92805448d61e0ad9ae61452c93e01522d40a9acc /Modules | |
parent | 43bc3788c0333b5d6230a5a28885b2fa70b42a86 (diff) | |
download | cpython-4994d9546c723c01c2f4b34a401c544c859d3404.zip cpython-4994d9546c723c01c2f4b34a401c544c859d3404.tar.gz cpython-4994d9546c723c01c2f4b34a401c544c859d3404.tar.bz2 |
Patch #1506645: add Python wrappers for the curses functions
is_term_resized, resize_term and resizeterm. This uses three
separate configure checks (one for each function).
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 71d7a69..f74cfd5 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -44,7 +44,7 @@ unsupported functions: mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm - resizeterm restartterm ripoffline scr_dump + restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm tgetent tgetflag tgetnum tgetstr tgoto timeout tputs vidattr vidputs waddchnstr waddchstr wchgat @@ -1950,6 +1950,29 @@ PyCurses_IntrFlush(PyObject *self, PyObject *args) return PyCursesCheckERR(intrflush(NULL,ch), "intrflush"); } +#ifdef HAVE_CURSES_IS_TERM_RESIZED +static PyObject * +PyCurses_Is_Term_Resized(PyObject *self, PyObject *args) +{ + int lines; + int columns; + int result; + + PyCursesInitialised + + if (!PyArg_ParseTuple(args,"ii:is_term_resized", &lines, &columns)) + return NULL; + result = is_term_resized(lines, columns); + if (result == TRUE) { + Py_INCREF(Py_True); + return Py_True; + } else { + Py_INCREF(Py_False); + return Py_False; + } +} +#endif /* HAVE_CURSES_IS_TERM_RESIZED */ + #if !defined(__NetBSD__) static PyObject * PyCurses_KeyName(PyObject *self, PyObject *args) @@ -2170,6 +2193,39 @@ PyCurses_QiFlush(PyObject *self, PyObject *args) } } +#ifdef HAVE_CURSES_RESIZETERM +static PyObject * +PyCurses_ResizeTerm(PyObject *self, PyObject *args) +{ + int lines; + int columns; + + PyCursesInitialised + + if (!PyArg_ParseTuple(args,"ii:resizeterm", &lines, &columns)) + return NULL; + + return PyCursesCheckERR(resizeterm(lines, columns), "resizeterm"); +} + +#endif + +#ifdef HAVE_CURSES_RESIZE_TERM +static PyObject * +PyCurses_Resize_Term(PyObject *self, PyObject *args) +{ + int lines; + int columns; + + PyCursesInitialised + + if (!PyArg_ParseTuple(args,"ii:resize_term", &lines, &columns)) + return NULL; + + return PyCursesCheckERR(resize_term(lines, columns), "resize_term"); +} +#endif /* HAVE_CURSES_RESIZE_TERM */ + static PyObject * PyCurses_setsyx(PyObject *self, PyObject *args) { @@ -2414,6 +2470,9 @@ static PyMethodDef PyCurses_methods[] = { {"initscr", (PyCFunction)PyCurses_InitScr, METH_NOARGS}, {"intrflush", (PyCFunction)PyCurses_IntrFlush, METH_VARARGS}, {"isendwin", (PyCFunction)PyCurses_isendwin, METH_NOARGS}, +#ifdef HAVE_CURSES_IS_TERM_RESIZED + {"is_term_resized", (PyCFunction)PyCurses_Is_Term_Resized, METH_VARARGS}, +#endif #if !defined(__NetBSD__) {"keyname", (PyCFunction)PyCurses_KeyName, METH_VARARGS}, #endif @@ -2441,6 +2500,12 @@ static PyMethodDef PyCurses_methods[] = { {"reset_prog_mode", (PyCFunction)PyCurses_reset_prog_mode, METH_NOARGS}, {"reset_shell_mode", (PyCFunction)PyCurses_reset_shell_mode, METH_NOARGS}, {"resetty", (PyCFunction)PyCurses_resetty, METH_NOARGS}, +#ifdef HAVE_CURSES_RESIZETERM + {"resizeterm", (PyCFunction)PyCurses_ResizeTerm, METH_VARARGS}, +#endif +#ifdef HAVE_CURSES_RESIZE_TERM + {"resize_term", (PyCFunction)PyCurses_Resize_Term, METH_VARARGS}, +#endif {"savetty", (PyCFunction)PyCurses_savetty, METH_NOARGS}, {"setsyx", (PyCFunction)PyCurses_setsyx, METH_VARARGS}, {"setupterm", (PyCFunction)PyCurses_setupterm, |