components/python/python27/patches/15-get_wch.patch
author Rich Burridge <rich.burridge@oracle.com>
Wed, 17 Oct 2012 05:24:33 -0700
branchs11-update
changeset 2386 4b1a9590af26
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:
2386
4b1a9590af26 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
4b1a9590af26 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
4b1a9590af26 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 @@
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     4
 }
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     5
 
4b1a9590af26 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 *
4b1a9590af26 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)
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
     8
+{
4b1a9590af26 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;
4b1a9590af26 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;
4b1a9590af26 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;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    12
+
4b1a9590af26 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)) {
4b1a9590af26 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:
4b1a9590af26 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
4b1a9590af26 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);
4b1a9590af26 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
4b1a9590af26 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;
4b1a9590af26 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:
4b1a9590af26 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))
4b1a9590af26 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;
4b1a9590af26 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
4b1a9590af26 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);
4b1a9590af26 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
4b1a9590af26 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;
4b1a9590af26 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:
4b1a9590af26 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");
4b1a9590af26 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;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    29
+    }
4b1a9590af26 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) {
4b1a9590af26 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");
4b1a9590af26 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;
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    33
+    }
4b1a9590af26 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);
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    35
+}
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    36
+
4b1a9590af26 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 *
4b1a9590af26 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)
4b1a9590af26 7194867 Need to patch python to support reading "wide" characters in the curses module
Rich Burridge <rich.burridge@oracle.com>
parents:
diff changeset
    39
 {
4b1a9590af26 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;
4b1a9590af26 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 @@
4b1a9590af26 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},
4b1a9590af26 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},
4b1a9590af26 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},
4b1a9590af26 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},
4b1a9590af26 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},
4b1a9590af26 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},
4b1a9590af26 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},