summaryrefslogtreecommitdiff
path: root/Modules/_cursesmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r--Modules/_cursesmodule.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 092fb69fb2..6d720245a7 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -105,10 +105,6 @@ char *PyCursesVersion = "2.2";
#include "Python.h"
-#ifdef __osf__
-#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
-#endif
-
#ifdef __hpux
#define STRICT_SYSV_CURSES
#endif
@@ -910,6 +906,40 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
}
}
+#ifdef HAVE_NCURSESW
+static PyObject *
+PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args)
+{
+ int x, y;
+ int ct;
+ wint_t rtn;
+
+ switch (PyTuple_Size(args)) {
+ case 0:
+ Py_BEGIN_ALLOW_THREADS
+ ct = wget_wch(self->win,&rtn);
+ Py_END_ALLOW_THREADS
+ break;
+ case 2:
+ if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
+ return NULL;
+ Py_BEGIN_ALLOW_THREADS
+ ct = mvwget_wch(self->win,y,x,&rtn);
+ Py_END_ALLOW_THREADS
+ break;
+ default:
+ PyErr_SetString(PyExc_TypeError, "get_wch requires 0 or 2 arguments");
+ return NULL;
+ }
+ if (ct == ERR) {
+ /* get_wch() returns ERR in nodelay mode */
+ PyErr_SetString(PyCursesError, "no input");
+ return NULL;
+ }
+ return PyLong_FromLong(rtn);
+}
+#endif
+
static PyObject *
PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args)
{
@@ -1608,6 +1638,9 @@ static PyMethodDef PyCursesWindow_Methods[] = {
{"getbkgd", (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
{"getch", (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
{"getkey", (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
+#ifdef HAVE_NCURSESW
+ {"get_wch", (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
+#endif
{"getmaxyx", (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS},
{"getparyx", (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS},
{"getstr", (PyCFunction)PyCursesWindow_GetStr, METH_VARARGS},