diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2007-04-11 13:39:00 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2007-04-11 13:39:00 (GMT) |
commit | 400a49ba794b343a8ff46a6f736ad846be80454a (patch) | |
tree | 627eb99340a4fdcd911b143f078e25fde3e5f159 /Modules | |
parent | 781aef2d6beda314108ac3ad05098e2cbf9e2eab (diff) | |
download | cpython-400a49ba794b343a8ff46a6f736ad846be80454a.zip cpython-400a49ba794b343a8ff46a6f736ad846be80454a.tar.gz cpython-400a49ba794b343a8ff46a6f736ad846be80454a.tar.bz2 |
Add window.chgat() method, submitted via e-mail by Fabian Kreutz
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index d883680..eaeb3d8 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -39,15 +39,15 @@ A number of SysV or ncurses functions don't have wrappers yet; if you need a given function, add it and send a patch. Here's a list of currently unsupported functions: - addchnstr addchstr chgat color_set define_key + addchnstr addchstr color_set define_key del_curterm delscreen dupwin inchnstr inchstr innstr keyok - mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr - mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat + mcprint mvaddchnstr mvaddchstr mvcur mvinchnstr + mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwinchnstr mvwinchstr mvwinnstr newterm restartterm ripoffline scr_dump scr_init scr_restore scr_set scrl set_curterm set_term setterm tgetent tgetflag tgetnum tgetstr tgoto timeout tputs - vidattr vidputs waddchnstr waddchstr wchgat + vidattr vidputs waddchnstr waddchstr wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl Low-priority: @@ -620,6 +620,56 @@ int py_mvwdelch(WINDOW *w, int y, int x) } #endif +/* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */ + +static PyObject * +PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args) +{ + int rtn; + int x, y; + int num = -1; + short color; + attr_t attr = A_NORMAL; + int use_xy = FALSE; + + switch (PyTuple_Size(args)) { + case 1: + if (!PyArg_ParseTuple(args,"l;attr", &attr)) + return NULL; + break; + case 2: + if (!PyArg_ParseTuple(args,"il;n,attr", &num, &attr)) + return NULL; + break; + case 3: + if (!PyArg_ParseTuple(args,"iil;int,int,attr", &y, &x, &attr)) + return NULL; + use_xy = TRUE; + break; + case 4: + if (!PyArg_ParseTuple(args,"iiil;int,int,n,attr", &y, &x, &num, &attr)) + return NULL; + use_xy = TRUE; + break; + default: + PyErr_SetString(PyExc_TypeError, "chgat requires 1 to 4 arguments"); + return NULL; + } + + color = (short)((attr >> 8) & 0xff); + attr = attr - (color << 8); + + if (use_xy == TRUE) { + rtn = mvwchgat(self->win,y,x,num,attr,color,NULL); + touchline(self->win,y,1); + } else { + getyx(self->win,y,x); + rtn = wchgat(self->win,num,attr,color,NULL); + touchline(self->win,y,1); + } + return PyCursesCheckERR(rtn, "chgat"); +} + static PyObject * PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args) @@ -1428,6 +1478,7 @@ static PyMethodDef PyCursesWindow_Methods[] = { {"attron", (PyCFunction)PyCursesWindow_wattron, METH_VARARGS}, {"attrset", (PyCFunction)PyCursesWindow_wattrset, METH_VARARGS}, {"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS}, + {"chgat", (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS}, {"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS}, {"border", (PyCFunction)PyCursesWindow_Border, METH_VARARGS}, {"box", (PyCFunction)PyCursesWindow_Box, METH_VARARGS}, |