components/python/python34/patches/13-get_wch.patch
author John Beck <John.Beck@Oracle.COM>
Mon, 19 May 2014 07:37:20 -0700
changeset 1907 446472de62e9
permissions -rw-r--r--
PSARC 2014/151 Python 3.4 15819724 SUNBT7202228 python 3.4 18756157 upgrade setuptools to 0.9.6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1907
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     1
This patch adds wget_wch support to the curses module.  It may be contributed
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     2
upstream at some point, but the suitability (or lack thereof) has not yet
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     3
been determined.
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     4
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     5
--- Python-3.4.0/Modules/_cursesmodule.c.~1~	2014-03-16 19:31:31.000000000 -0700
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     6
+++ Python-3.4.0/Modules/_cursesmodule.c	2014-03-17 13:44:21.194828659 -0700
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     7
@@ -1187,6 +1187,37 @@
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     8
 }
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     9
 
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    10
 static PyObject *
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    11
+PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args)
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    12
+{
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    13
+    int x, y;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    14
+    int ct;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    15
+    wint_t rtn;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    16
+
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    17
+    switch (PyTuple_Size(args)) {
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    18
+    case 0:
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    19
+        Py_BEGIN_ALLOW_THREADS
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    20
+        ct = wget_wch(self->win,&rtn);
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    21
+        Py_END_ALLOW_THREADS
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    22
+        break;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    23
+    case 2:
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    24
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    25
+            return NULL;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    26
+        Py_BEGIN_ALLOW_THREADS
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    27
+        ct = mvwget_wch(self->win,y,x,&rtn);
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    28
+        Py_END_ALLOW_THREADS
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    29
+        break;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    30
+    default:
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    31
+        PyErr_SetString(PyExc_TypeError, "get_wch requires 0 or 2 arguments");
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    32
+        return NULL;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    33
+    }
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    34
+    if (ct == ERR) {
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    35
+        PyErr_SetString(PyCursesError, "get_wch failed");
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    36
+        return NULL;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    37
+    }
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    38
+    return PyLong_FromLong((long)rtn);
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    39
+}
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    40
+
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    41
+static PyObject *
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    42
 PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    43
 {
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    44
     int x, y;
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    45
@@ -2059,6 +2090,7 @@
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    46
     {"getbegyx",        (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS},
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    47
     {"getbkgd",         (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    48
     {"getch",           (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    49
+    {"get_wch",         (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    50
     {"getkey",          (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    51
 #ifdef HAVE_NCURSESW
446472de62e9 PSARC 2014/151 Python 3.4
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    52
     {"get_wch",         (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},