4912
|
1 |
This patch adds wget_wch support to the curses module. It may be contributed
|
|
2 |
upstream at some point, but the suitability (or lack thereof) has not yet
|
|
3 |
been determined.
|
|
4 |
|
|
5 |
--- Python-3.5.0a4/Modules/_cursesmodule.c.~1~ 2015-04-20 00:37:52.000000000 -0700
|
|
6 |
+++ Python-3.5.0a4/Modules/_cursesmodule.c 2015-04-20 13:48:38.959560525 -0700
|
|
7 |
@@ -1124,6 +1124,37 @@
|
|
8 |
}
|
|
9 |
|
|
10 |
static PyObject *
|
|
11 |
+PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args)
|
|
12 |
+{
|
|
13 |
+ int x, y;
|
|
14 |
+ int ct;
|
|
15 |
+ wint_t rtn;
|
|
16 |
+
|
|
17 |
+ switch (PyTuple_Size(args)) {
|
|
18 |
+ case 0:
|
|
19 |
+ Py_BEGIN_ALLOW_THREADS
|
|
20 |
+ ct = wget_wch(self->win,&rtn);
|
|
21 |
+ Py_END_ALLOW_THREADS
|
|
22 |
+ break;
|
|
23 |
+ case 2:
|
|
24 |
+ if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
|
|
25 |
+ return NULL;
|
|
26 |
+ Py_BEGIN_ALLOW_THREADS
|
|
27 |
+ ct = mvwget_wch(self->win,y,x,&rtn);
|
|
28 |
+ Py_END_ALLOW_THREADS
|
|
29 |
+ break;
|
|
30 |
+ default:
|
|
31 |
+ PyErr_SetString(PyExc_TypeError, "get_wch requires 0 or 2 arguments");
|
|
32 |
+ return NULL;
|
|
33 |
+ }
|
|
34 |
+ if (ct == ERR) {
|
|
35 |
+ PyErr_SetString(PyCursesError, "get_wch failed");
|
|
36 |
+ return NULL;
|
|
37 |
+ }
|
|
38 |
+ return PyLong_FromLong((long)rtn);
|
|
39 |
+}
|
|
40 |
+
|
|
41 |
+static PyObject *
|
|
42 |
PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
|
|
43 |
{
|
|
44 |
int x, y;
|
|
45 |
@@ -1996,6 +2027,7 @@
|
|
46 |
{"getbegyx", (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS},
|
|
47 |
{"getbkgd", (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS},
|
|
48 |
{"getch", (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS},
|
|
49 |
+ {"get_wch", (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
|
|
50 |
{"getkey", (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS},
|
|
51 |
#ifdef HAVE_NCURSESW
|
|
52 |
{"get_wch", (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS},
|