Index: Include/py_curses.h =================================================================== --- Include/py_curses.h (revision 74555) +++ Include/py_curses.h (working copy) @@ -71,6 +71,7 @@ typedef struct { PyObject_HEAD WINDOW *win; + char *charset; } PyCursesWindowObject; #define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) Index: Modules/_cursesmodule.c =================================================================== --- Modules/_cursesmodule.c (revision 74555) +++ Modules/_cursesmodule.c (working copy) @@ -358,6 +358,7 @@ wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type); if (wo == NULL) return NULL; wo->win = win; + wo->charset = NULL; /* use default charset (utf8) */ return (PyObject *)wo; } @@ -365,6 +366,7 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo) { if (wo->win != stdscr) delwin(wo->win); + if (wo->charset) free(wo->charset); PyObject_DEL(wo); } @@ -431,22 +433,22 @@ switch (PyTuple_Size(args)) { case 1: - if (!PyArg_ParseTuple(args,"s;str", &str)) + if (!PyArg_ParseTuple(args,"es;str", self->charset, &str)) return NULL; break; case 2: - if (!PyArg_ParseTuple(args,"sl;str,attr", &str, &lattr)) + if (!PyArg_ParseTuple(args,"esl;str,attr", self->charset, &str, &lattr)) return NULL; attr = lattr; use_attr = TRUE; break; case 3: - if (!PyArg_ParseTuple(args,"iis;int,int,str", &y, &x, &str)) + if (!PyArg_ParseTuple(args,"iies;int,int,str", &y, &x, self->charset, &str)) return NULL; use_xy = TRUE; break; case 4: - if (!PyArg_ParseTuple(args,"iisl;int,int,str,attr", &y, &x, &str, &lattr)) + if (!PyArg_ParseTuple(args,"iiesl;int,int,str,attr", &y, &x, self->charset, &str, &lattr)) return NULL; attr = lattr; use_xy = use_attr = TRUE; @@ -1437,6 +1439,24 @@ } static PyObject * +PyCursesWindow_SetCharset(PyCursesWindowObject *self, PyObject *args) +{ + char *charset, *copy; + if (!PyArg_ParseTuple(args, "s;str", &charset)) + return NULL; + + copy = strdup(str); + if (copy == NULL) { + PyErr_NoMemory(); + return NULL; + } + if (self->charset) + free(self->charset); + self->charset = copy; + Py_RETURN_NONE; +} + +static PyObject * PyCursesWindow_SetScrollRegion(PyCursesWindowObject *self, PyObject *args) { int x, y; @@ -1635,6 +1655,7 @@ #endif {"scroll", (PyCFunction)PyCursesWindow_Scroll, METH_VARARGS}, {"scrollok", (PyCFunction)PyCursesWindow_scrollok, METH_VARARGS}, + {"setcharset", (PyCFunction)PyCursesWindow_SetCharset, METH_VARARGS}, {"setscrreg", (PyCFunction)PyCursesWindow_SetScrollRegion, METH_VARARGS}, {"standend", (PyCFunction)PyCursesWindow_wstandend, METH_NOARGS}, {"standout", (PyCFunction)PyCursesWindow_wstandout, METH_NOARGS},