components/python/python27/patches/15-get_wch.patch
author Rich Burridge <rich.burridge@oracle.com>
Mon, 01 Oct 2012 09:42:46 -0700
changeset 996 0698123e4e6b
child 1914 00e8dbcb9b1e
child 3367 ed5024e47b53
permissions -rw-r--r--
7194867 Need to patch python to support reading "wide" characters in the curses module
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
996
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     1
--- Python-2.7.3/Modules/_cursesmodule.c.orig	2012-09-27 10:17:54.934886883 -0700
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     2
+++ Python-2.7.3/Modules/_cursesmodule.c	2012-09-27 10:21:19.861160806 -0700
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     3
@@ -861,6 +861,37 @@
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
 }
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
 
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     6
 static PyObject *
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     7
+PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args)
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
+{
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     9
+    int x, y;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    10
+    int ct;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    11
+    wint_t rtn;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
+
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    13
+    switch (PyTuple_Size(args)) {
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    14
+    case 0:
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    15
+        Py_BEGIN_ALLOW_THREADS
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    16
+        ct = wget_wch(self->win,&rtn);
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    17
+        Py_END_ALLOW_THREADS
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    18
+        break;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    19
+    case 2:
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    20
+        if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    21
+            return NULL;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    22
+        Py_BEGIN_ALLOW_THREADS
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    23
+        ct = mvwget_wch(self->win,y,x,&rtn);
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    24
+        Py_END_ALLOW_THREADS
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    25
+        break;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    26
+    default:
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    27
+        PyErr_SetString(PyExc_TypeError, "get_wch requires 0 or 2 arguments");
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    28
+        return NULL;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
+    }
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    30
+    if (ct == ERR) {
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    31
+        PyErr_SetString(PyCursesError, "get_wch failed");
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    32
+        return NULL;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
+    }
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    34
+    return PyInt_FromLong((long)rtn);
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
+}
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
+
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    37
+static PyObject *
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    38
 PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
 {
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    40
     int x, y;
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    41
@@ -1570,6 +1601,7 @@
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    42
     {"getbegyx",        (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS},
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    43
     {"getbkgd",         (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    44
     {"getch",           (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    45
+    {"get_wch",         (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    46
     {"getkey",          (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    47
     {"getmaxyx",        (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS},
0698123e4e6b 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    48
     {"getparyx",        (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS},