components/python/python27/patches/15-get_wch.patch
author Rich Burridge <rich.burridge@oracle.com>
Tue, 02 May 2017 17:33:26 -0700
changeset 7964 d9801318ed3d
parent 7516 09c933391a1b
permissions -rw-r--r--
25981468 Build ilmbase and openexr with the GNU compilers

This patch adds wget_wch support to the curses module.  It may be contributed
upstream at some point, but the suitability (or lack thereof) has not yet
been determined.

--- Python-2.7.6/Modules/_cursesmodule.c.~1~	2013-11-09 23:36:41.000000000 -0800
+++ Python-2.7.6/Modules/_cursesmodule.c	2014-05-14 13:36:59.388642793 -0700
@@ -861,6 +861,37 @@
 }
 
 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) {
+        PyErr_SetString(PyCursesError, "get_wch failed");
+        return NULL;
+    }
+    return PyInt_FromLong((long)rtn);
+}
+
+static PyObject *
 PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
 {
     int x, y;
@@ -1588,6 +1619,7 @@
     {"getbegyx",        (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS},
     {"getbkgd",         (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
     {"getch",           (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
+    {"get_wch",         (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
     {"getkey",          (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
     {"getmaxyx",        (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS},
     {"getparyx",        (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS},