diff -r 395e190ead36 Include/py_curses.h --- a/Include/py_curses.h Mon May 04 22:45:47 2015 -0400 +++ b/Include/py_curses.h Tue May 05 12:30:07 2015 +0300 @@ -120,6 +120,11 @@ static PyObject *PyCurses_ ## X (PyObjec PyCursesInitialised \ return PyCursesCheckERR(X(), # X); } +#define NoArgNoReturnFunctionBody(X) \ +{ \ + PyCursesInitialised \ + return PyCursesCheckERR(X(), # X); } + #define NoArgOrFlagNoReturnFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ { \ @@ -142,6 +147,11 @@ static PyObject *PyCurses_ ## X (PyObjec PyCursesInitialised \ return PyLong_FromLong((long) X()); } +#define NoArgReturnIntFunctionBody(X) \ +{ \ + PyCursesInitialised \ + return PyLong_FromLong((long) X()); } + #define NoArgReturnStringFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self) \ @@ -149,24 +159,40 @@ static PyObject *PyCurses_ ## X (PyObjec PyCursesInitialised \ return PyBytes_FromString(X()); } +#define NoArgReturnStringFunctionBody(X) \ +{ \ + PyCursesInitialised \ + return PyBytes_FromString(X()); } + #define NoArgTrueFalseFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self) \ { \ PyCursesInitialised \ - if (X () == FALSE) { \ - Py_INCREF(Py_False); \ - return Py_False; \ - } \ - Py_INCREF(Py_True); \ - return Py_True; } + if (X () == FALSE) \ + Py_RETURN_FALSE; \ + else \ + Py_RETURN_TRUE; } + +#define NoArgTrueFalseFunctionBody(X) \ +{ \ + PyCursesInitialised \ + if (X () == FALSE) \ + Py_RETURN_FALSE; \ + else \ + Py_RETURN_TRUE; } #define NoArgNoReturnVoidFunction(X) \ static PyObject *PyCurses_ ## X (PyObject *self) \ { \ PyCursesInitialised \ X(); \ - Py_INCREF(Py_None); \ - return Py_None; } + Py_RETURN_NONE; } + +#define NoArgNoReturnVoidFunctionBody(X) \ +{ \ + PyCursesInitialised \ + X(); \ + Py_RETURN_NONE; } #ifdef __cplusplus } diff -r 395e190ead36 Modules/_curses_panel.c --- a/Modules/_curses_panel.c Mon May 04 22:45:47 2015 -0400 +++ b/Modules/_curses_panel.c Tue May 05 12:30:07 2015 +0300 @@ -59,8 +59,7 @@ static PyObject * PyCursesCheckERR(int code, char *fname) { if (code != ERR) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { if (fname == NULL) { PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR); @@ -163,6 +162,14 @@ find_po(PANEL *pan) return temp->po; } +/*[clinic input] +module _curses_panel +class _curses_panel.panel "PyCursesPanelObject *" "&PyCursesPanel_Type" +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=2f4ef263ca850a31]*/ + +#include "clinic/_curses_panel.c.h" + /* Function Prototype Macros - They are ugly but very, very useful. ;-) X - function name @@ -170,15 +177,18 @@ find_po(PANEL *pan) ERGSTR - format string for construction of the return value PARSESTR - format string for argument parsing */ -#define Panel_NoArgNoReturnFunction(X) \ +#define Panel_NoArgNoReturnFunction(X, doc) \ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ -{ return PyCursesCheckERR(X(self->pan), # X); } +{ return PyCursesCheckERR(X(self->pan), # X); } \ +PyDoc_STRVAR(PyCursesPanel_##X##_doc_, # X "below($self, /)\n--\n\n" doc); + + #define Panel_NoArgTrueFalseFunction(X) \ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ { \ - if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ - else { Py_INCREF(Py_True); return Py_True; } } + if (X (self->pan) == FALSE) Py_RETURN_FALSE; \ + else Py_RETURN_TRUE; } } #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ @@ -189,12 +199,15 @@ static PyObject *PyCursesPanel_##X(PyCur /* ------------- PANEL routines --------------- */ -Panel_NoArgNoReturnFunction(bottom_panel) -Panel_NoArgNoReturnFunction(hide_panel) -Panel_NoArgNoReturnFunction(show_panel) -Panel_NoArgNoReturnFunction(top_panel) -Panel_NoArgTrueFalseFunction(panel_hidden) -Panel_TwoArgNoReturnFunction(move_panel, int, "ii;y,x") +Panel_NoArgNoReturnFunction(bottom_panel, +"Push the panel to the bottom of the stack.") +Panel_NoArgNoReturnFunction(hide_panel, +"Hide the panel.\n\n" +"This does not delete the object, it just makes the window on screen invisible.") +Panel_NoArgNoReturnFunction(show_panel, +"Display the panel (which might have been hidden).") +Panel_NoArgNoReturnFunction(top_panel, +"Push panel to the top of the stack.") /* Allocation and deallocation of Panel Objects */ @@ -230,8 +243,15 @@ PyCursesPanel_Dealloc(PyCursesPanelObjec /* panel_above(NULL) returns the bottom panel in the stack. To get this behaviour we use curses.panel.bottom_panel(). */ +/*[clinic input] +_curses_panel.panel.above + +Returns the panel above the current panel. +[clinic start generated code]*/ + static PyObject * -PyCursesPanel_above(PyCursesPanelObject *self) +_curses_panel_panel_above_impl(PyCursesPanelObject *self) +/*[clinic end generated code: output=70ac06d25fd3b4da input=68587c4ccd4f903b]*/ { PANEL *pan; PyCursesPanelObject *po; @@ -240,8 +260,7 @@ PyCursesPanel_above(PyCursesPanelObject if (pan == NULL) { /* valid output, it means the calling panel is on top of the stack */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -255,8 +274,15 @@ PyCursesPanel_above(PyCursesPanelObject /* panel_below(NULL) returns the top panel in the stack. To get this behaviour we use curses.panel.top_panel(). */ +/*[clinic input] +_curses_panel.panel.below + +Returns the panel below the current panel. +[clinic start generated code]*/ + static PyObject * -PyCursesPanel_below(PyCursesPanelObject *self) +_curses_panel_panel_below_impl(PyCursesPanelObject *self) +/*[clinic end generated code: output=282861122e06e3de input=f6d8e7bf1160cae9]*/ { PANEL *pan; PyCursesPanelObject *po; @@ -265,8 +291,7 @@ PyCursesPanel_below(PyCursesPanelObject if (pan == NULL) { /* valid output, it means the calling panel is on the bottom of the stack */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -278,28 +303,70 @@ PyCursesPanel_below(PyCursesPanelObject return (PyObject *)po; } +/*[clinic input] +_curses_panel.panel.hidden + +Returns the panel below the current panel. +[clinic start generated code]*/ + static PyObject * -PyCursesPanel_window(PyCursesPanelObject *self) +_curses_panel_panel_hidden_impl(PyCursesPanelObject *self) +/*[clinic end generated code: output=66eebd1ab4501a71 input=0e11aa6f83ef9431]*/ +{ + if (panel_hidden(self->pan)) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +/*[clinic input] +_curses_panel.panel.move + + y: int + x: int + / + +Move the panel to the screen coordinates (y, x). +[clinic start generated code]*/ + +static PyObject * +_curses_panel_panel_move_impl(PyCursesPanelObject *self, int y, int x) +/*[clinic end generated code: output=d867535a89777415 input=e0b36b78acc03fba]*/ +{ + return PyCursesCheckERR(move_panel(self->pan, y, x), "move_panel"); +} + +/*[clinic input] +_curses_panel.panel.window + +Returns the window object associated with the panel. +[clinic start generated code]*/ + +static PyObject * +_curses_panel_panel_window_impl(PyCursesPanelObject *self) +/*[clinic end generated code: output=5f05940d4106b4cb input=4407c3e4f0bb1e5d]*/ { Py_INCREF(self->wo); return (PyObject *)self->wo; } +/*[clinic input] +_curses_panel.panel.replace + + win: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") + / + +Change the window associated with the panel to the window win. +[clinic start generated code]*/ + static PyObject * -PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args) +_curses_panel_panel_replace_impl(PyCursesPanelObject *self, + PyCursesWindowObject *win) +/*[clinic end generated code: output=2253a95f7b287255 input=4b1c4283987d9dfa]*/ { PyCursesPanelObject *po; - PyCursesWindowObject *temp; int rtn; - if (PyTuple_Size(args) != 1) { - PyErr_SetString(PyExc_TypeError, "replace requires one argument"); - return NULL; - } - if (!PyArg_ParseTuple(args, "O!;window object", - &PyCursesWindow_Type, &temp)) - return NULL; - po = find_po(self->pan); if (po == NULL) { PyErr_SetString(PyExc_RuntimeError, @@ -307,20 +374,29 @@ PyCursesPanel_replace_panel(PyCursesPane return NULL; } - rtn = replace_panel(self->pan, temp->win); + rtn = replace_panel(self->pan, win->win); if (rtn == ERR) { PyErr_SetString(_curses_panelstate_global->PyCursesError, "replace_panel() returned ERR"); return NULL; } Py_DECREF(po->wo); - po->wo = temp; + po->wo = win; Py_INCREF(po->wo); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } +/*[clinic input] +_curses_panel.panel.set_userptr + + obj: object + / + +Change the window associated with the panel to the window win. +[clinic start generated code]*/ + static PyObject * -PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *obj) +_curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyObject *obj) +/*[clinic end generated code: output=6fb145b3af88cf4a input=b3fd729019f44191]*/ { PyObject *oldobj; int rc; @@ -336,8 +412,15 @@ PyCursesPanel_set_panel_userptr(PyCurses return PyCursesCheckERR(rc, "set_panel_userptr"); } +/*[clinic input] +_curses_panel.panel.userptr + +Returns the user pointer for the panel. +[clinic start generated code]*/ + static PyObject * -PyCursesPanel_userptr(PyCursesPanelObject *self) +_curses_panel_panel_userptr_impl(PyCursesPanelObject *self) +/*[clinic end generated code: output=e849c307b5dc9237 input=8f8cbc321907051a]*/ { PyObject *obj; PyCursesInitialised; @@ -354,19 +437,22 @@ PyCursesPanel_userptr(PyCursesPanelObjec /* Module interface */ +#define METHOD_NOARGS_DEF(N, X) \ + {#N, (PyCFunction)PyCursesPanel_##X, METH_NOARGS, PyCursesPanel_##X##_doc_}, + static PyMethodDef PyCursesPanel_Methods[] = { - {"above", (PyCFunction)PyCursesPanel_above, METH_NOARGS}, - {"below", (PyCFunction)PyCursesPanel_below, METH_NOARGS}, - {"bottom", (PyCFunction)PyCursesPanel_bottom_panel, METH_NOARGS}, - {"hidden", (PyCFunction)PyCursesPanel_panel_hidden, METH_NOARGS}, - {"hide", (PyCFunction)PyCursesPanel_hide_panel, METH_NOARGS}, - {"move", (PyCFunction)PyCursesPanel_move_panel, METH_VARARGS}, - {"replace", (PyCFunction)PyCursesPanel_replace_panel, METH_VARARGS}, - {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_O}, - {"show", (PyCFunction)PyCursesPanel_show_panel, METH_NOARGS}, - {"top", (PyCFunction)PyCursesPanel_top_panel, METH_NOARGS}, - {"userptr", (PyCFunction)PyCursesPanel_userptr, METH_NOARGS}, - {"window", (PyCFunction)PyCursesPanel_window, METH_NOARGS}, + _CURSES_PANEL_PANEL_ABOVE_METHODDEF + _CURSES_PANEL_PANEL_BELOW_METHODDEF + METHOD_NOARGS_DEF(bottom, bottom_panel) + _CURSES_PANEL_PANEL_HIDDEN_METHODDEF + METHOD_NOARGS_DEF(hide, hide_panel) + _CURSES_PANEL_PANEL_MOVE_METHODDEF + _CURSES_PANEL_PANEL_REPLACE_METHODDEF + _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF + METHOD_NOARGS_DEF(show, show_panel) + METHOD_NOARGS_DEF(top, top_panel) + _CURSES_PANEL_PANEL_USERPTR_METHODDEF + _CURSES_PANEL_PANEL_WINDOW_METHODDEF {NULL, NULL} /* sentinel */ }; @@ -379,7 +465,7 @@ static PyType_Slot PyCursesPanel_Type_sl }; static PyType_Spec PyCursesPanel_Type_spec = { - "_curses_panel.curses panel", + "_curses_panel.panel", sizeof(PyCursesPanelObject), 0, Py_TPFLAGS_DEFAULT, @@ -390,8 +476,15 @@ static PyType_Spec PyCursesPanel_Type_sp panel of the stack, so it's renamed to bottom_panel(). panel.above() *requires* a panel object in the first place which may be undesirable. */ +/*[clinic input] +_curses_panel.bottom_panel + +Returns the bottom panel in the panel stack. +[clinic start generated code]*/ + static PyObject * -PyCurses_bottom_panel(PyObject *self) +_curses_panel_bottom_panel_impl(PyModuleDef *module) +/*[clinic end generated code: output=ac6c2673b006ad90 input=eae26cdb5c107da2]*/ { PANEL *pan; PyCursesPanelObject *po; @@ -402,8 +495,7 @@ PyCurses_bottom_panel(PyObject *self) if (pan == NULL) { /* valid output, it means there's no panel at all */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -415,15 +507,20 @@ PyCurses_bottom_panel(PyObject *self) return (PyObject *)po; } +/*[clinic input] +_curses_panel.new_panel + + win: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") + / + +Returns a panel object, associating it with the given window win. +[clinic start generated code]*/ + static PyObject * -PyCurses_new_panel(PyObject *self, PyObject *args) +_curses_panel_new_panel_impl(PyModuleDef *module, PyCursesWindowObject *win) +/*[clinic end generated code: output=6dc03418fc62c1f0 input=57f61486e959af6f]*/ { - PyCursesWindowObject *win; - PANEL *pan; - - if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) - return NULL; - pan = new_panel(win->win); + PANEL *pan = new_panel(win->win); if (pan == NULL) { PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_NULL); return NULL; @@ -436,8 +533,15 @@ PyCurses_new_panel(PyObject *self, PyObj of the stack, so it's renamed to top_panel(). panel.below() *requires* a panel object in the first place which may be undesirable. */ +/*[clinic input] +_curses_panel.top_panel + +Returns the top panel in the panel stack. +[clinic start generated code]*/ + static PyObject * -PyCurses_top_panel(PyObject *self) +_curses_panel_top_panel_impl(PyModuleDef *module) +/*[clinic end generated code: output=3dab35cd4202be7f input=1ee936f4218741d0]*/ { PANEL *pan; PyCursesPanelObject *po; @@ -448,8 +552,7 @@ PyCurses_top_panel(PyObject *self) if (pan == NULL) { /* valid output, it means there's no panel at all */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -461,22 +564,31 @@ PyCurses_top_panel(PyObject *self) return (PyObject *)po; } -static PyObject *PyCurses_update_panels(PyObject *self) +/*[clinic input] +_curses_panel.update_panels + +Updates the virtual screen after changes in the panel stack. + +This does not call curses.doupdate(), so you’ll have to do this yourself. +[clinic start generated code]*/ + +static PyObject * +_curses_panel_update_panels_impl(PyModuleDef *module) +/*[clinic end generated code: output=bbcfa74adaffedad input=a127069202b0a097]*/ { PyCursesInitialised; update_panels(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* List of functions defined in the module */ static PyMethodDef PyCurses_methods[] = { - {"bottom_panel", (PyCFunction)PyCurses_bottom_panel, METH_NOARGS}, - {"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS}, - {"top_panel", (PyCFunction)PyCurses_top_panel, METH_NOARGS}, - {"update_panels", (PyCFunction)PyCurses_update_panels, METH_NOARGS}, + _CURSES_PANEL_BOTTOM_PANEL_METHODDEF + _CURSES_PANEL_NEW_PANEL_METHODDEF + _CURSES_PANEL_TOP_PANEL_METHODDEF + _CURSES_PANEL_UPDATE_PANELS_METHODDEF {NULL, NULL} /* sentinel */ }; @@ -525,6 +637,9 @@ PyInit__curses_panel(void) PyDict_SetItemString(d, "version", v); PyDict_SetItemString(d, "__version__", v); Py_DECREF(v); + + Py_INCREF(_curses_panelstate(m)->PyCursesPanel_Type); + PyModule_AddObject(m, "panel", (PyObject *)_curses_panelstate(m)->PyCursesPanel_Type); return m; fail: Py_XDECREF(m); diff -r 395e190ead36 Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Mon May 04 22:45:47 2015 -0400 +++ b/Modules/_cursesmodule.c Tue May 05 12:30:07 2015 +0300 @@ -135,12 +135,11 @@ typedef chtype attr_t; /* No a #endif /*[clinic input] -module curses -class curses.window "PyCursesWindowObject *" "&PyCursesWindow_Type" +#output preset block +module _curses +class _curses.window "PyCursesWindowObject *" "&PyCursesWindow_Type" [clinic start generated code]*/ -/*[clinic end generated code: output=da39a3ee5e6b4b0d input=88c860abdbb50e0c]*/ - -#include "clinic/_cursesmodule.c.h" +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=7987f3e79370d906]*/ /* Definition of exception curses.error */ @@ -188,8 +187,7 @@ static PyObject * PyCursesCheckERR(int code, const char *fname) { if (code != ERR) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { if (fname == NULL) { PyErr_SetString(PyCursesError, catchall_ERR); @@ -411,18 +409,18 @@ PyTypeObject PyCursesWindow_Type; (PyCursesWindowObject *self, PyObject *args) \ { return PyCursesCheckERR(X(self->win), # X); } -#define Window_NoArgTrueFalseFunction(X) \ - static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self) \ - { \ - if (X (self->win) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ - else { Py_INCREF(Py_True); return Py_True; } } - -#define Window_NoArgNoReturnVoidFunction(X) \ - static PyObject * PyCursesWindow_ ## X \ - (PyCursesWindowObject *self) \ - { \ - X(self->win); Py_INCREF(Py_None); return Py_None; } +#define Window_NoArgTrueFalseFunction(X) \ + static PyObject * PyCursesWindow_ ## X \ + (PyCursesWindowObject *self) \ + { \ + if (!X (self->win)) { Py_RETURN_FALSE; } \ + else { Py_RETURN_TRUE; } } + +#define Window_NoArgNoReturnVoidFunction(X) \ + static PyObject * PyCursesWindow_ ## X \ + (PyCursesWindowObject *self) \ + { \ + X(self->win); Py_RETURN_NONE; } #define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR) \ static PyObject * PyCursesWindow_ ## X \ @@ -437,7 +435,7 @@ PyTypeObject PyCursesWindow_Type; { \ TYPE arg1; \ if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) return NULL; \ - X(self->win,arg1); Py_INCREF(Py_None); return Py_None; } + X(self->win,arg1); Py_RETURN_NONE; } #define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \ static PyObject * PyCursesWindow_ ## X \ @@ -558,26 +556,23 @@ PyCursesWindow_Dealloc(PyCursesWindowObj /* Addch, Addstr, Addnstr */ /*[clinic input] - -curses.window.addch +_curses.window.addch [ y: int - Y-coordinate. + Y-coordinate. x: int - X-coordinate. + X-coordinate. ] ch: object - Character to add. - - [ - attr: long - Attributes for the character. - ] + Character to add. + + attr: long(c_default="A_NORMAL") = A_NORMAL + Attributes for the character. / -Paint character ch at (y, x) with attributes attr. +Paint the character. Paint character ch at (y, x) with attributes attr, overwriting any character previously painted at that location. @@ -586,13 +581,11 @@ current settings for the window object. [clinic start generated code]*/ static PyObject * -curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, - int x, PyObject *ch, int group_right_1, long attr) -/*[clinic end generated code: output=99f7f85078ec06c3 input=5a41efb34a2de338]*/ +_curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, long attr) +/*[clinic end generated code: output=8196456d012bb871 input=13fdc4c8a67df061]*/ { - PyCursesWindowObject *cwself = (PyCursesWindowObject *)self; int coordinates_group = group_left_1; - int attr_group = group_right_1; int rtn; int type; chtype cch; @@ -601,30 +594,27 @@ curses_window_addch_impl(PyCursesWindowO #endif const char *funcname; - if (!attr_group) - attr = A_NORMAL; - #ifdef HAVE_NCURSESW - type = PyCurses_ConvertToCchar_t(cwself, ch, &cch, &wch); + type = PyCurses_ConvertToCchar_t(self, ch, &cch, &wch); if (type == 2) { funcname = "add_wch"; - wch.attr = attr; + wch.attr = (attr_t) attr; if (coordinates_group) - rtn = mvwadd_wch(cwself->win,y,x, &wch); + rtn = mvwadd_wch(self->win,y,x, &wch); else { - rtn = wadd_wch(cwself->win, &wch); + rtn = wadd_wch(self->win, &wch); } } else #else - type = PyCurses_ConvertToCchar_t(cwself, ch, &cch); + type = PyCurses_ConvertToCchar_t(self, ch, &cch); #endif if (type == 1) { funcname = "addch"; if (coordinates_group) - rtn = mvwaddch(cwself->win,y,x, cch | attr); + rtn = mvwaddch(self->win,y,x, cch | (attr_t) attr); else { - rtn = waddch(cwself->win, cch | attr); + rtn = waddch(self->win, cch | (attr_t) attr); } } else { @@ -633,62 +623,64 @@ curses_window_addch_impl(PyCursesWindowO return PyCursesCheckERR(rtn, funcname); } +/*[clinic input] +_curses.window.addstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + str: object + String to add. + + [ + attr: long + Attributes for characters. + ] + / + +Paint the string. + +Paint the string str at (y, x) with attributes attr, +overwriting anything previously on the display. +By default, the character position and attributes are the +current settings for the window object. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_AddStr(PyCursesWindowObject *self, PyObject *args) +_curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int group_right_1, + long attr) +/*[clinic end generated code: output=65a928ea85ff3115 input=ff6cbb91448a22a3]*/ { int rtn; - int x, y; int strtype; - PyObject *strobj, *bytesobj = NULL; + PyObject *bytesobj = NULL; #ifdef HAVE_NCURSESW wchar_t *wstr = NULL; #endif - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - long lattr; - int use_xy = FALSE, use_attr = FALSE; + attr_t attr_old = A_NORMAL; + int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"O;str", &strobj)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;str,attr", &strobj, &lattr)) - return NULL; - attr = lattr; - use_attr = TRUE; - break; - case 3: - if (!PyArg_ParseTuple(args,"iiO;int,int,str", &y, &x, &strobj)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiOl;int,int,str,attr", &y, &x, &strobj, &lattr)) - return NULL; - attr = lattr; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "addstr requires 1 to 4 arguments"); - return NULL; - } #ifdef HAVE_NCURSESW - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, &wstr); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, &wstr); #else - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, NULL); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL); #endif if (strtype == 0) return NULL; - if (use_attr == TRUE) { + if (use_attr) { attr_old = getattrs(self->win); (void)wattrset(self->win,attr); } #ifdef HAVE_NCURSESW if (strtype == 2) { funcname = "addwstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwaddwstr(self->win,y,x,wstr); else rtn = waddwstr(self->win,wstr); @@ -699,73 +691,79 @@ PyCursesWindow_AddStr(PyCursesWindowObje { char *str = PyBytes_AS_STRING(bytesobj); funcname = "addstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwaddstr(self->win,y,x,str); else rtn = waddstr(self->win,str); Py_DECREF(bytesobj); } - if (use_attr == TRUE) + if (use_attr) (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } +/*[clinic input] +_curses.window.addnstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + str: object + String to add. + + n: int + Maximal number of characters. + + [ + attr: long + Attributes for characters. + ] + / + +Paint at most n characters of the string. + +Paint at most n characters of the string str at (y, x) with +attributes attr, overwriting anything previously on the display. +By default, the character position and attributes are the +current settings for the window object. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_AddNStr(PyCursesWindowObject *self, PyObject *args) +_curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int n, + int group_right_1, long attr) +/*[clinic end generated code: output=6d21cee2ce6876d9 input=72718415c2744a2a]*/ { - int rtn, x, y, n; + int rtn; int strtype; - PyObject *strobj, *bytesobj = NULL; + PyObject *bytesobj = NULL; #ifdef HAVE_NCURSESW wchar_t *wstr = NULL; #endif - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - long lattr; - int use_xy = FALSE, use_attr = FALSE; + attr_t attr_old = A_NORMAL; + int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"Oi;str,n", &strobj, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args,"Oil;str,n,attr", &strobj, &n, &lattr)) - return NULL; - attr = lattr; - use_attr = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiOi;y,x,str,n", &y, &x, &strobj, &n)) - return NULL; - use_xy = TRUE; - break; - case 5: - if (!PyArg_ParseTuple(args,"iiOil;y,x,str,n,attr", &y, &x, &strobj, &n, &lattr)) - return NULL; - attr = lattr; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "addnstr requires 2 to 5 arguments"); - return NULL; - } #ifdef HAVE_NCURSESW - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, &wstr); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, &wstr); #else - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, NULL); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL); #endif if (strtype == 0) return NULL; - if (use_attr == TRUE) { + if (use_attr) { attr_old = getattrs(self->win); (void)wattrset(self->win,attr); } #ifdef HAVE_NCURSESW if (strtype == 2) { funcname = "addnwstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwaddnwstr(self->win,y,x,wstr,n); else rtn = waddnwstr(self->win,wstr,n); @@ -776,146 +774,208 @@ PyCursesWindow_AddNStr(PyCursesWindowObj { char *str = PyBytes_AS_STRING(bytesobj); funcname = "addnstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwaddnstr(self->win,y,x,str,n); else rtn = waddnstr(self->win,str,n); Py_DECREF(bytesobj); } - if (use_attr == TRUE) + if (use_attr) (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } +/*[clinic input] +_curses.window.bkgd + + ch: object + Background character. + attr: long(c_default="A_NORMAL") = A_NORMAL + Background attributes. + / + +Set the background property of the window. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Bkgd(PyCursesWindowObject *self, PyObject *args) +_curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, long attr) +/*[clinic end generated code: output=058290afb2cf4034 input=13e35fe755759462]*/ { - PyObject *temp; chtype bkgd; - attr_t attr = A_NORMAL; - long lattr; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr)) - return NULL; - attr = lattr; - break; - default: - PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments"); - return NULL; - } - - if (!PyCurses_ConvertToChtype(self, temp, &bkgd)) + + if (!PyCurses_ConvertToChtype(self, ch, &bkgd)) return NULL; return PyCursesCheckERR(wbkgd(self->win, bkgd | attr), "bkgd"); } +/*[clinic input] +_curses.window.attroff + + attr: long + / + +Remove attribute attr from the “background” set applied to all writes to the current window. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_AttrOff(PyCursesWindowObject *self, PyObject *args) +_curses_window_attroff_impl(PyCursesWindowObject *self, long attr) +/*[clinic end generated code: output=8a2fcd4df682fc64 input=093232ce6bacde80]*/ { - long lattr; - if (!PyArg_ParseTuple(args,"l;attr", &lattr)) - return NULL; - return PyCursesCheckERR(wattroff(self->win, (attr_t)lattr), "attroff"); + return PyCursesCheckERR(wattroff(self->win, (attr_t)attr), "attroff"); } +/*[clinic input] +_curses.window.attron + + attr: long + / + +Add attribute attr from the “background” set applied to all writes to the current window. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_AttrOn(PyCursesWindowObject *self, PyObject *args) +_curses_window_attron_impl(PyCursesWindowObject *self, long attr) +/*[clinic end generated code: output=7afea43b237fa870 input=7250e241d758aa2b]*/ { - long lattr; - if (!PyArg_ParseTuple(args,"l;attr", &lattr)) - return NULL; - return PyCursesCheckERR(wattron(self->win, (attr_t)lattr), "attron"); + return PyCursesCheckERR(wattron(self->win, (attr_t)attr), "attron"); } +/*[clinic input] +_curses.window.attrset + + attr: long + / + +Set the “background” set of attributes to attr. + +This set is initially 0 (no attributes). +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_AttrSet(PyCursesWindowObject *self, PyObject *args) +_curses_window_attrset_impl(PyCursesWindowObject *self, long attr) +/*[clinic end generated code: output=84e379bff20c0433 input=7971d394c79ea7e3]*/ { - long lattr; - if (!PyArg_ParseTuple(args,"l;attr", &lattr)) - return NULL; - return PyCursesCheckERR(wattrset(self->win, (attr_t)lattr), "attrset"); + return PyCursesCheckERR(wattrset(self->win, (attr_t)attr), "attrset"); } +/*[clinic input] +_curses.window.bkgdset + + ch: object + Background character. + attr: long(c_default="A_NORMAL") = A_NORMAL + Background attributes. + / + +Set the window’s background. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args) +_curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch, + long attr) +/*[clinic end generated code: output=8cb994fc4d7e2496 input=ddab1f47a774d3fc]*/ { - PyObject *temp; chtype bkgd; - attr_t attr = A_NORMAL; - long lattr; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr)) - return NULL; - attr = lattr; - break; - default: - PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments"); - return NULL; - } - - if (!PyCurses_ConvertToChtype(self, temp, &bkgd)) + + if (!PyCurses_ConvertToChtype(self, ch, &bkgd)) return NULL; wbkgdset(self->win, bkgd | attr); return PyCursesCheckERR(0, "bkgdset"); } +/*[clinic input] +_curses.window.border + + ls: object(c_default="NULL") = ACS_VLINE + Left side. + rs: object(c_default="NULL") = ACS_VLINE + Right side. + ts: object(c_default="NULL") = ACS_HLINE + Top side. + bs: object(c_default="NULL") = ACS_HLINE + Bottom side. + tl: object(c_default="NULL") = ACS_ULCORNER + Upper-left corner. + tr: object(c_default="NULL") = ACS_URCORNER + Upper-right corner. + bl: object(c_default="NULL") = ACS_LLCORNER + Bottom-left corner. + br: object(c_default="NULL") = ACS_LRCORNER + Bottom-right corner. + / + +Draw a border around the edges of the window. + +Each parameter specifies the character to use for a specific part of the +border. The characters can be specified as integers or as one-character +strings. A 0 value for any parameter will cause the default character to be +used for that parameter. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args) +_curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls, + PyObject *rs, PyObject *ts, PyObject *bs, + PyObject *tl, PyObject *tr, PyObject *bl, + PyObject *br) +/*[clinic end generated code: output=670ef38d3d7c2aa3 input=105d0e2208b9e2cc]*/ { - PyObject *temp[8]; chtype ch[8]; int i; /* Clear the array of parameters */ - for(i=0; i<8; i++) { - temp[i] = NULL; + for(i=0; i<8; i++) ch[i] = 0; - } - - if (!PyArg_ParseTuple(args,"|OOOOOOOO;ls,rs,ts,bs,tl,tr,bl,br", - &temp[0], &temp[1], &temp[2], &temp[3], - &temp[4], &temp[5], &temp[6], &temp[7])) + +#define CONVERTTOCHTYPE(obj, i) \ + if ((obj) != NULL && !PyCurses_ConvertToChtype(self, (obj), &ch[(i)])) \ return NULL; - for(i=0; i<8; i++) { - if (temp[i] != NULL && !PyCurses_ConvertToChtype(self, temp[i], &ch[i])) - return NULL; - } + CONVERTTOCHTYPE(ls, 0); + CONVERTTOCHTYPE(rs, 1); + CONVERTTOCHTYPE(ts, 2); + CONVERTTOCHTYPE(bs, 3); + CONVERTTOCHTYPE(tl, 4); + CONVERTTOCHTYPE(tr, 5); + CONVERTTOCHTYPE(bl, 6); + CONVERTTOCHTYPE(br, 7); + +#undef CONVERTTOCHTYPE wborder(self->win, ch[0], ch[1], ch[2], ch[3], ch[4], ch[5], ch[6], ch[7]); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } +/*[clinic input] +_curses.window.box + + [ + vertch: long + Left and right side. + hortch: long + Top and bottom side. + ] + / + +Draw a border around the edges of the window. + +Similar to border(), but both ls and rs are vertch and both ts and bs are +horch. The default corner characters are always used by this function. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args) +_curses_window_box_impl(PyCursesWindowObject *self, int group_right_1, + long vertch, long hortch) +/*[clinic end generated code: output=f7fc4334e355b5a9 input=efb3af679703a212]*/ { - chtype ch1=0,ch2=0; - switch(PyTuple_Size(args)){ - case 0: break; - default: - if (!PyArg_ParseTuple(args,"ll;vertint,horint", &ch1, &ch2)) - return NULL; - } - box(self->win,ch1,ch2); - Py_INCREF(Py_None); - return Py_None; + if (group_right_1) + box(self->win, (chtype)vertch, (chtype)hortch); + else + box(self->win, 0, 0); + Py_RETURN_NONE; } #if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION) @@ -932,6 +992,32 @@ int py_mvwdelch(WINDOW *w, int y, int x) /* chgat, added by Fabian Kreutz */ +/*[-clinic input] +_curses.window.chgat + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + num: int = -1 + Number of characters. + + attr: long + Attributes for characters. + / + +Set the attributes of characters. + +Set the attributes of num characters at the current cursor position, or at +position (y, x) if supplied. If no value of num is given or num = -1, the +attribute will be set on all the characters to the end of the line. This +function does not move the cursor. The changed line will be touched using +the touchline() method so that the contents will be redisplayed by the next +window refresh. +[-clinic start generated code]*/ static PyObject * PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args) { @@ -974,7 +1060,7 @@ PyCursesWindow_ChgAt(PyCursesWindowObjec color = (short)((attr >> 8) & 0xff); attr = attr - (color << 8); - if (use_xy == TRUE) { + if (use_xy) { rtn = mvwchgat(self->win,y,x,num,attr,color,NULL); touchline(self->win,y,1); } else { @@ -986,50 +1072,65 @@ PyCursesWindow_ChgAt(PyCursesWindowObjec } +/*[clinic input] +_curses.window.delch + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + / + +Delete any character at (y, x). +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args) +_curses_window_delch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x) +/*[clinic end generated code: output=22e77bb9fa11b461 input=d2f79e630a4fc6d0]*/ { int rtn; - int x, y; - - switch (PyTuple_Size(args)) { - case 0: + + if (!group_right_1) rtn = wdelch(self->win); - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x)) - return NULL; - rtn = py_mvwdelch(self->win,y,x); - break; - default: - PyErr_SetString(PyExc_TypeError, "delch requires 0 or 2 arguments"); - return NULL; - } + else + rtn = py_mvwdelch(self->win, y, x); return PyCursesCheckERR(rtn, "[mv]wdelch"); } +/*[clinic input] +_curses.window.derwin + + [ + nlines: int + Height. + ncols: int + Width. + ] + begin_y: int + Top side y-coordinate. + begin_x: int + Left side x-coordinate. + / + +Return a sub-window. + +derwin() is the same as calling subwin(), except that begin_y and begin_x +are relative to the origin of the window, rather than relative to the entire +screen. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_DerWin(PyCursesWindowObject *self, PyObject *args) +_curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1, + int nlines, int ncols, int begin_y, int begin_x) +/*[clinic end generated code: output=7924b112d9f70d6e input=477ad86381040d04]*/ { WINDOW *win; - int nlines, ncols, begin_y, begin_x; - - nlines = 0; - ncols = 0; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x", - &nlines,&ncols,&begin_y,&begin_x)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "derwin requires 2 or 4 arguments"); - return NULL; - } + + if (!group_left_1) + nlines = ncols = 0; win = derwin(self->win,nlines,ncols,begin_y,begin_x); @@ -1041,111 +1142,140 @@ PyCursesWindow_DerWin(PyCursesWindowObje return (PyObject *)PyCursesWindow_New(win, NULL); } +/*[clinic input] +_curses.window.echochar + + ch: object + Character to add. + + attr: long(c_default="A_NORMAL") = A_NORMAL + Attributes for the character. + / + +Add character ch with attribute attr, and immediately call refresh() on the window. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args) +_curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch, + long attr) +/*[clinic end generated code: output=13e7dd875d4b9642 input=f61989dd354b04f2]*/ { - PyObject *temp; - chtype ch; - attr_t attr = A_NORMAL; - long lattr; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;ch or int,attr", &temp, &lattr)) - return NULL; - attr = lattr; - break; - default: - PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments"); - - - return NULL; - } - - if (!PyCurses_ConvertToChtype(self, temp, &ch)) + chtype ch_; + + if (!PyCurses_ConvertToChtype(self, ch, &ch_)) return NULL; #ifdef WINDOW_HAS_FLAGS if (self->win->_flags & _ISPAD) - return PyCursesCheckERR(pechochar(self->win, ch | attr), + return PyCursesCheckERR(pechochar(self->win, ch_ | (attr_t)attr), "echochar"); else #endif - return PyCursesCheckERR(wechochar(self->win, ch | attr), + return PyCursesCheckERR(wechochar(self->win, ch_ | (attr_t)attr), "echochar"); } #ifdef NCURSES_MOUSE_VERSION -static PyObject * -PyCursesWindow_Enclose(PyCursesWindowObject *self, PyObject *args) +/*[clinic input] +_curses.window.enclose -> long + + y: int + Y-coordinate. + x: int + X-coordinate. + / + +Return True if the given pair of screen-relative character-cell coordinates are enclosed by the given window. +[clinic start generated code]*/ + +static long +_curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x) +/*[clinic end generated code: output=5251c961cbe3df63 input=0eab779591d9b4da]*/ { - int x, y; - if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x)) - return NULL; - - return PyLong_FromLong( wenclose(self->win,y,x) ); + return wenclose(self->win, y, x); } #endif +/*[clinic input] +_curses.window.getbkgd -> long + +Return the given window’s current background character/attribute pair. +[clinic start generated code]*/ + +static long +_curses_window_getbkgd_impl(PyCursesWindowObject *self) +/*[clinic end generated code: output=c52b25dc16b215c3 input=ccbbb791b01aaff5]*/ +{ + return (long) getbkgd(self->win); +} + +/*[clinic input] +_curses.window.getch -> int + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + / + +Get a character code. + +The integer returned does not have to be in ASCII range: function keys, +keypad keys and so on return numbers higher than 256. In no-delay mode, -1 +is returned if there is no input, else getch() waits until a key is pressed. +[clinic start generated code]*/ + +static int +_curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x) +/*[clinic end generated code: output=980aa6af0c0ca387 input=89db6233f4856256]*/ +{ + int rtn; + + Py_BEGIN_ALLOW_THREADS + if (!group_right_1) + rtn = wgetch(self->win); + else + rtn = mvwgetch(self->win, y, x); + Py_END_ALLOW_THREADS + + return rtn; +} + +/*[clinic input] +_curses.window.getkey + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + / + +Get a character (string). + +Returning a string instead of an integer, as getch() does. Function keys, +keypad keys and other special keys return a multibyte string containing the +key name. In no-delay mode, an exception is raised if there is no input. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_GetBkgd(PyCursesWindowObject *self) +_curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x) +/*[clinic end generated code: output=8490a182db46b10f input=570df29849bf47c8]*/ { - return PyLong_FromLong((long) getbkgd(self->win)); -} - -static PyObject * -PyCursesWindow_GetCh(PyCursesWindowObject *self, PyObject *args) -{ - int x, y; int rtn; - switch (PyTuple_Size(args)) { - case 0: - Py_BEGIN_ALLOW_THREADS + Py_BEGIN_ALLOW_THREADS + if (!group_right_1) rtn = wgetch(self->win); - Py_END_ALLOW_THREADS - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = mvwgetch(self->win,y,x); - Py_END_ALLOW_THREADS - break; - default: - PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments"); - return NULL; - } - return PyLong_FromLong((long)rtn); -} - -static PyObject * -PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args) -{ - int x, y; - int rtn; - - switch (PyTuple_Size(args)) { - case 0: - Py_BEGIN_ALLOW_THREADS - rtn = wgetch(self->win); - Py_END_ALLOW_THREADS - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = mvwgetch(self->win,y,x); - Py_END_ALLOW_THREADS - break; - default: - PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments"); - return NULL; - } + else + rtn = mvwgetch(self->win, y, x); + Py_END_ALLOW_THREADS + if (rtn == ERR) { /* getch() returns ERR in nodelay mode */ PyErr_CheckSignals(); @@ -1165,31 +1295,39 @@ PyCursesWindow_GetKey(PyCursesWindowObje } } +/*[clinic input] +_curses.window.get_wch + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + / + +Get a wide character. + +Return a character for most keys, or an integer for function keys, +keypad keys, and other special keys. +[clinic start generated code]*/ + +static PyObject * +_curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x) +/*[clinic end generated code: output=9f4f86e91fe50ef3 input=d6f292183c31f469]*/ #ifdef HAVE_NCURSESW -static PyObject * -PyCursesWindow_Get_WCh(PyCursesWindowObject *self, PyObject *args) { - int x, y; int ct; wint_t rtn; - switch (PyTuple_Size(args)) { - case 0: - Py_BEGIN_ALLOW_THREADS - ct = wget_wch(self->win,&rtn); - Py_END_ALLOW_THREADS - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - Py_BEGIN_ALLOW_THREADS - ct = mvwget_wch(self->win,y,x,&rtn); - Py_END_ALLOW_THREADS - break; - default: - PyErr_SetString(PyExc_TypeError, "get_wch requires 0 or 2 arguments"); - return NULL; - } + Py_BEGIN_ALLOW_THREADS + if (!group_right_1) + ct = wget_wch(self->win ,&rtn); + else + ct = mvwget_wch(self->win, y, x, &rtn); + Py_END_ALLOW_THREADS + if (ct == ERR) { if (PyErr_CheckSignals()) return NULL; @@ -1203,8 +1341,28 @@ PyCursesWindow_Get_WCh(PyCursesWindowObj else return PyUnicode_FromOrdinal(rtn); } +#else +{ + Py_RETURN_NONE; +} #endif +/*[-clinic input] +_curses.window.getstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + n: int = 1023 + Maximal number of characters. + / + +Read a string from the user, with primitive line editing capacity. +[-clinic start generated code]*/ + static PyObject * PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args) { @@ -1259,118 +1417,134 @@ PyCursesWindow_GetStr(PyCursesWindowObje return PyBytes_FromString(rtn); } +/*[clinic input] +_curses.window.hline + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + ch: object + Character to draw. + n: int + Line length. + + attr: long(c_default="A_NORMAL") = A_NORMAL + Attributes for the characters. + / + +Display a horizontal line starting at (y, x) with length n consisting of the character ch. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args) +_curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int n, long attr) +/*[clinic end generated code: output=a5864e3b6f17a4e0 input=2def1a6204560fa0]*/ { - PyObject *temp; - chtype ch; - int n, x, y, code = OK; - attr_t attr = A_NORMAL; - long lattr; - - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr)) - return NULL; - attr = lattr; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n)) - return NULL; - code = wmove(self->win, y, x); - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", - &y, &x, &temp, &n, &lattr)) - return NULL; - attr = lattr; - code = wmove(self->win, y, x); - break; - default: - PyErr_SetString(PyExc_TypeError, "hline requires 2 to 5 arguments"); + chtype ch_; + + if (!PyCurses_ConvertToChtype(self, ch, &ch_)) return NULL; + if (group_left_1) { + if (wmove(self->win, y, x) == ERR) + return PyCursesCheckERR(ERR, "wmove"); } - - if (code != ERR) { - if (!PyCurses_ConvertToChtype(self, temp, &ch)) - return NULL; - return PyCursesCheckERR(whline(self->win, ch | attr, n), "hline"); - } else - return PyCursesCheckERR(code, "wmove"); + return PyCursesCheckERR(whline(self->win, ch_ | (attr_t)attr, n), "hline"); } +/*[clinic input] +_curses.window.insch + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + ch: object + Character to insert. + + attr: long(c_default="A_NORMAL") = A_NORMAL + Attributes for the character. + / + +Paint character ch at (y, x) with attributes attr, moving the line from position x right by one character. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args) +_curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, long attr) +/*[clinic end generated code: output=ef62b13e0750e069 input=18a894a3fafab5e1]*/ { - int rtn, x, y, use_xy = FALSE; - PyObject *temp; - chtype ch = 0; - attr_t attr = A_NORMAL; - long lattr; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O;ch or int", &temp)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args, "Ol;ch or int,attr", &temp, &lattr)) - return NULL; - attr = lattr; - break; - case 3: - if (!PyArg_ParseTuple(args,"iiO;y,x,ch or int", &y, &x, &temp)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &lattr)) - return NULL; - attr = lattr; - use_xy = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "insch requires 1 or 4 arguments"); + int rtn; + chtype ch_ = 0; + + if (!PyCurses_ConvertToChtype(self, ch, &ch_)) return NULL; - } - - if (!PyCurses_ConvertToChtype(self, temp, &ch)) - return NULL; - - if (use_xy == TRUE) - rtn = mvwinsch(self->win,y,x, ch | attr); - else { - rtn = winsch(self->win, ch | attr); - } + + if (!group_left_1) + rtn = winsch(self->win, ch_ | (attr_t)attr); + else + rtn = mvwinsch(self->win, y, x, ch_ | (attr_t)attr); + return PyCursesCheckERR(rtn, "insch"); } -static PyObject * -PyCursesWindow_InCh(PyCursesWindowObject *self, PyObject *args) +/*[clinic input] +_curses.window.inch -> unsigned_long + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + / + +Return the character at the given position in the window. + +The bottom 8 bits are the character proper, and upper bits are the attributes. +[clinic start generated code]*/ + +static unsigned long +_curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x) +/*[clinic end generated code: output=6c4719fe978fe86a input=fac23ee11e3b3a66]*/ { - int x, y; unsigned long rtn; - switch (PyTuple_Size(args)) { - case 0: + if (!group_right_1) rtn = winch(self->win); - break; - case 2: - if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x)) - return NULL; - rtn = mvwinch(self->win,y,x); - break; - default: - PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments"); - return NULL; - } - return PyLong_FromUnsignedLong(rtn); + else + rtn = mvwinch(self->win, y, x); + + return rtn; } +/*[-clinic input] +_curses.window.instr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + n: int = 1023 + Maximal number of characters. + / + +Return a string of characters, extracted from the window. + +Return a string of characters, extracted from the window starting at the +current cursor position, or at y, x if specified. Attributes are stripped +from the characters. If n is specified, instr() returns a string at most +n characters long (exclusive of the trailing NUL). +[-clinic start generated code]*/ static PyObject * PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args) { @@ -1406,64 +1580,66 @@ PyCursesWindow_InStr(PyCursesWindowObjec return PyBytes_FromString(rtn); } +/*[clinic input] +_curses.window.insstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + str: object + String to insert. + + [ + attr: long + Attributes for characters. + ] + / + +Insert the string. + +Insert a character string (as many characters as will fit on the line) +before the character under the cursor. All characters to the right of +the cursor are shifted right, with the rightmost characters on the line +being lost. The cursor position does not change (after moving to y, x, +if specified). +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_InsStr(PyCursesWindowObject *self, PyObject *args) +_curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int group_right_1, + long attr) +/*[clinic end generated code: output=c259a5265ad0b777 input=19578f1d501d6cbd]*/ { int rtn; - int x, y; int strtype; - PyObject *strobj, *bytesobj = NULL; + PyObject *bytesobj = NULL; #ifdef HAVE_NCURSESW wchar_t *wstr = NULL; #endif - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - long lattr; - int use_xy = FALSE, use_attr = FALSE; + attr_t attr_old = A_NORMAL; + int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"O;str", &strobj)) - return NULL; - break; - case 2: - if (!PyArg_ParseTuple(args,"Ol;str,attr", &strobj, &lattr)) - return NULL; - attr = lattr; - use_attr = TRUE; - break; - case 3: - if (!PyArg_ParseTuple(args,"iiO;y,x,str", &y, &x, &strobj)) - return NULL; - use_xy = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiOl;y,x,str,attr", &y, &x, &strobj, &lattr)) - return NULL; - attr = lattr; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "insstr requires 1 to 4 arguments"); - return NULL; - } - #ifdef HAVE_NCURSESW - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, &wstr); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, &wstr); #else - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, NULL); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL); #endif if (strtype == 0) return NULL; - if (use_attr == TRUE) { + if (use_attr) { attr_old = getattrs(self->win); - (void)wattrset(self->win,attr); + (void)wattrset(self->win, (attr_t)attr); } #ifdef HAVE_NCURSESW if (strtype == 2) { funcname = "inswstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwins_wstr(self->win,y,x,wstr); else rtn = wins_wstr(self->win,wstr); @@ -1474,74 +1650,81 @@ PyCursesWindow_InsStr(PyCursesWindowObje { char *str = PyBytes_AS_STRING(bytesobj); funcname = "insstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwinsstr(self->win,y,x,str); else rtn = winsstr(self->win,str); Py_DECREF(bytesobj); } - if (use_attr == TRUE) + if (use_attr) (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } +/*[clinic input] +_curses.window.insnstr + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + str: object + String to insert. + + n: int + Maximal number of characters. + + [ + attr: long + Attributes for characters. + ] + / + +Insert at most n characters of the string. + +Insert a character string (as many characters as will fit on the line) +before the character under the cursor, up to n characters. If n is zero +or negative, the entire string is inserted. All characters to the right +of the cursor are shifted right, with the rightmost characters on the line +being lost. The cursor position does not change (after moving to y, x, if +specified). +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_InsNStr(PyCursesWindowObject *self, PyObject *args) +_curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int n, + int group_right_1, long attr) +/*[clinic end generated code: output=971a32ea6328ec8b input=70fa0cd543901a4c]*/ { - int rtn, x, y, n; + int rtn; int strtype; - PyObject *strobj, *bytesobj = NULL; + PyObject *bytesobj = NULL; #ifdef HAVE_NCURSESW wchar_t *wstr = NULL; #endif - attr_t attr = A_NORMAL , attr_old = A_NORMAL; - long lattr; - int use_xy = FALSE, use_attr = FALSE; + attr_t attr_old = A_NORMAL; + int use_xy = group_left_1, use_attr = group_right_1; const char *funcname; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"Oi;str,n", &strobj, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args,"Oil;str,n,attr", &strobj, &n, &lattr)) - return NULL; - attr = lattr; - use_attr = TRUE; - break; - case 4: - if (!PyArg_ParseTuple(args,"iiOi;y,x,str,n", &y, &x, &strobj, &n)) - return NULL; - use_xy = TRUE; - break; - case 5: - if (!PyArg_ParseTuple(args,"iiOil;y,x,str,n,attr", &y, &x, &strobj, &n, &lattr)) - return NULL; - attr = lattr; - use_xy = use_attr = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, "insnstr requires 2 to 5 arguments"); - return NULL; - } - #ifdef HAVE_NCURSESW - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, &wstr); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, &wstr); #else - strtype = PyCurses_ConvertToString(self, strobj, &bytesobj, NULL); + strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL); #endif if (strtype == 0) return NULL; - if (use_attr == TRUE) { + if (use_attr) { attr_old = getattrs(self->win); - (void)wattrset(self->win,attr); + (void)wattrset(self->win, (attr_t)attr); } #ifdef HAVE_NCURSESW if (strtype == 2) { funcname = "insn_wstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwins_nwstr(self->win,y,x,wstr,n); else rtn = wins_nwstr(self->win,wstr,n); @@ -1552,162 +1735,229 @@ PyCursesWindow_InsNStr(PyCursesWindowObj { char *str = PyBytes_AS_STRING(bytesobj); funcname = "insnstr"; - if (use_xy == TRUE) + if (use_xy) rtn = mvwinsnstr(self->win,y,x,str,n); else rtn = winsnstr(self->win,str,n); Py_DECREF(bytesobj); } - if (use_attr == TRUE) + if (use_attr) (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } +/*[clinic input] +_curses.window.is_linetouched + + line: int + Line number. + / + +Return True if the specified line was modified since the last call to refresh(); otherwise return False. + +Raise a curses.error exception if line is not valid for the given window. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Is_LineTouched(PyCursesWindowObject *self, PyObject *args) +_curses_window_is_linetouched_impl(PyCursesWindowObject *self, int line) +/*[clinic end generated code: output=ad4a4edfee2db08c input=e69c70af3b91d999]*/ { - int line, erg; - if (!PyArg_ParseTuple(args,"i;line", &line)) - return NULL; + int erg; erg = is_linetouched(self->win, line); if (erg == ERR) { PyErr_SetString(PyExc_TypeError, "is_linetouched: line number outside of boundaries"); return NULL; - } else - if (erg == FALSE) { - Py_INCREF(Py_False); - return Py_False; - } else { - Py_INCREF(Py_True); - return Py_True; + } + if (erg) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + +#ifdef WINDOW_HAS_FLAGS +/*[clinic input] +_curses.window.noutrefresh + + [ + pminrow: int + pmincol: int + sminrow: int + smincol: int + smaxrow: int + smaxcol: int + ] + / + +Mark for refresh but wait. + +This function updates the data structure representing the desired state of the +window, but does not force an update of the physical screen. To accomplish +that, call doupdate(). +[clinic start generated code]*/ + +static PyObject * +_curses_window_noutrefresh_impl(PyCursesWindowObject *self, + int group_right_1, int pminrow, int pmincol, + int sminrow, int smincol, int smaxrow, + int smaxcol) +/*[clinic end generated code: output=809a1f3c6a03e23e input=3e56898388cd739e]*/ +#else +/*[clinic input] +_curses.window.noutrefresh + +Mark for refresh but wait. + +This function updates the data structure representing the desired state of the +window, but does not force an update of the physical screen. To accomplish +that, call doupdate(). +[clinic start generated code]*/ + +static PyObject * +_curses_window_noutrefresh_impl(PyCursesWindowObject *self) +/*[clinic end generated code: output=6ef6dec666643fee input=876902e3fa431dbd]*/ +#endif +{ + int rtn; + +#ifdef WINDOW_HAS_FLAGS + if (self->win->_flags & _ISPAD) { + if (!group_right_1) { + PyErr_SetString(PyCursesError, + "noutrefresh() called for a pad " + "requires 6 arguments"); + return NULL; } -} - -static PyObject * -PyCursesWindow_NoOutRefresh(PyCursesWindowObject *self, PyObject *args) -{ - int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; - int rtn; - -#ifndef WINDOW_HAS_FLAGS - if (0) -#else - if (self->win->_flags & _ISPAD) -#endif - { - switch(PyTuple_Size(args)) { - case 6: - if (!PyArg_ParseTuple(args, - "iiiiii;" \ - "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol", - &pminrow, &pmincol, &sminrow, - &smincol, &smaxrow, &smaxcol)) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = pnoutrefresh(self->win, - pminrow, pmincol, sminrow, - smincol, smaxrow, smaxcol); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "pnoutrefresh"); - default: - PyErr_SetString(PyCursesError, - "noutrefresh() called for a pad " - "requires 6 arguments"); - return NULL; - } - } else { - if (!PyArg_ParseTuple(args, ":noutrefresh")) - return NULL; - - Py_BEGIN_ALLOW_THREADS - rtn = wnoutrefresh(self->win); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "wnoutrefresh"); - } -} - -static PyObject * -PyCursesWindow_Overlay(PyCursesWindowObject *self, PyObject *args) -{ - PyCursesWindowObject *temp; - int use_copywin = FALSE; - int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; - int rtn; - - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O!;window object", - &PyCursesWindow_Type, &temp)) - return NULL; - break; - case 7: - if (!PyArg_ParseTuple(args, "O!iiiiii;window object, int, int, int, int, int, int", - &PyCursesWindow_Type, &temp, &sminrow, &smincol, - &dminrow, &dmincol, &dmaxrow, &dmaxcol)) - return NULL; - use_copywin = TRUE; - break; - default: + Py_BEGIN_ALLOW_THREADS + rtn = pnoutrefresh(self->win, pminrow, pmincol, + sminrow, smincol, smaxrow, smaxcol); + Py_END_ALLOW_THREADS + return PyCursesCheckERR(rtn, "pnoutrefresh"); + } + if (group_right_1) { PyErr_SetString(PyExc_TypeError, - "overlay requires one or seven arguments"); + "noutrefresh() takes no arguments (6 given)"); return NULL; } - - if (use_copywin == TRUE) { - rtn = copywin(self->win, temp->win, sminrow, smincol, +#endif + Py_BEGIN_ALLOW_THREADS + rtn = wnoutrefresh(self->win); + Py_END_ALLOW_THREADS + return PyCursesCheckERR(rtn, "wnoutrefresh"); +} + +/*[clinic input] +_curses.window.overlay + + destwin: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") + + [ + sminrow: int + smincol: int + dminrow: int + dmincol: int + dmaxrow: int + dmaxcol: int + ] + / + +Overlay the window on top of destwin. + +The windows need not be the same size, only the overlapping region is copied. +This copy is non-destructive, which means that the current background +character does not overwrite the old contents of destwin. + +To get fine-grained control over the copied region, the second form of +overlay() can be used. sminrow and smincol are the upper-left coordinates +of the source window, and the other variables mark a rectangle in the +destination window. +[clinic start generated code]*/ + +static PyObject * +_curses_window_overlay_impl(PyCursesWindowObject *self, + PyCursesWindowObject *destwin, int group_right_1, + int sminrow, int smincol, int dminrow, + int dmincol, int dmaxrow, int dmaxcol) +/*[clinic end generated code: output=82bb2c4cb443ca58 input=7edd23ad22cc1984]*/ +{ + int rtn; + + if (group_right_1) { + rtn = copywin(self->win, destwin->win, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, TRUE); return PyCursesCheckERR(rtn, "copywin"); } else { - rtn = overlay(self->win, temp->win); + rtn = overlay(self->win, destwin->win); return PyCursesCheckERR(rtn, "overlay"); } } +/*[clinic input] +_curses.window.overwrite + + destwin: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") + + [ + sminrow: int + smincol: int + dminrow: int + dmincol: int + dmaxrow: int + dmaxcol: int + ] + / + +Overwrite the window on top of destwin. + +The windows need not be the same size, in which case only the overlapping +region is copied. This copy is destructive, which means that the current +background character overwrites the old contents of destwin. + +To get fine-grained control over the copied region, the second form of +overwrite() can be used. sminrow and smincol are the upper-left coordinates +of the source window, the other variables mark a rectangle in the destination +window. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args) +_curses_window_overwrite_impl(PyCursesWindowObject *self, + PyCursesWindowObject *destwin, + int group_right_1, int sminrow, int smincol, + int dminrow, int dmincol, int dmaxrow, + int dmaxcol) +/*[clinic end generated code: output=12ae007d1681be28 input=ea5de1b35cd948e0]*/ { - PyCursesWindowObject *temp; - int use_copywin = FALSE; - int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol; int rtn; - switch (PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "O!;window object", - &PyCursesWindow_Type, &temp)) - return NULL; - break; - case 7: - if (!PyArg_ParseTuple(args, "O!iiiiii;window object, int, int, int, int, int, int", - &PyCursesWindow_Type, &temp, &sminrow, &smincol, - &dminrow, &dmincol, &dmaxrow, &dmaxcol)) - return NULL; - use_copywin = TRUE; - break; - default: - PyErr_SetString(PyExc_TypeError, - "overwrite requires one or seven arguments"); - return NULL; - } - - if (use_copywin == TRUE) { - rtn = copywin(self->win, temp->win, sminrow, smincol, + if (group_right_1) { + rtn = copywin(self->win, destwin->win, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, FALSE); return PyCursesCheckERR(rtn, "copywin"); } else { - rtn = overwrite(self->win, temp->win); + rtn = overwrite(self->win, destwin->win); return PyCursesCheckERR(rtn, "overwrite"); } } +/*[clinic input] +_curses.window.putwin + + file: object + / + +Write all data associated with the window into the provided file object. + +This information can be later retrieved using the getwin() function. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream) +_curses_window_putwin(PyCursesWindowObject *self, PyObject *file) +/*[clinic end generated code: output=3a25e2a5e7a040ac input=0608648e09c8ea0a]*/ { /* We have to simulate this by writing to a temporary FILE*, - then reading back, then writing to the argument stream. */ + then reading back, then writing to the argument file. */ char fn[100]; int fd = -1; FILE *fp = NULL; @@ -1736,7 +1986,7 @@ PyCursesWindow_PutWin(PyCursesWindowObje if (n <= 0) break; Py_DECREF(res); - res = _PyObject_CallMethodId(stream, &PyId_write, "y#", buf, n); + res = _PyObject_CallMethodId(file, &PyId_write, "y#", buf, n); if (res == NULL) break; } @@ -1750,88 +2000,133 @@ exit: return res; } +/*[clinic input] +_curses.window.redrawln + + beg: int + num: int + / + +Indicate that the num screen lines, starting at line beg, are corrupted and should be completely redrawn on the next refresh() call. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_RedrawLine(PyCursesWindowObject *self, PyObject *args) +_curses_window_redrawln_impl(PyCursesWindowObject *self, int beg, int num) +/*[clinic end generated code: output=ea216e334f9ce1b4 input=226d984bf380379b]*/ { - int beg, num; - if (!PyArg_ParseTuple(args, "ii;beg,num", &beg, &num)) - return NULL; return PyCursesCheckERR(wredrawln(self->win,beg,num), "redrawln"); } +/*[clinic input] +_curses.window.refresh + + [ + pminrow: int + pmincol: int + sminrow: int + smincol: int + smaxrow: int + smaxcol: int + ] + / + +Update the display immediately (sync actual screen with previous drawing/deleting methods). + +The 6 optional arguments can only be specified when the window is a pad +created with newpad(). The additional parameters are needed to indicate +what part of the pad and screen are involved. pminrow and pmincol specify +the upper left-hand corner of the rectangle to be displayed in the pad. +sminrow, smincol, smaxrow, and smaxcol specify the edges of the rectangle to +be displayed on the screen. The lower right-hand corner of the rectangle to +be displayed in the pad is calculated from the screen coordinates, since the +rectangles must be the same size. Both rectangles must be entirely contained +within their respective structures. Negative values of pminrow, pmincol, +sminrow, or smincol are treated as if they were zero. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Refresh(PyCursesWindowObject *self, PyObject *args) +_curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1, + int pminrow, int pmincol, int sminrow, + int smincol, int smaxrow, int smaxcol) +/*[clinic end generated code: output=42199543115e6e63 input=4ffad3b5e16872d9]*/ { - int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol; int rtn; -#ifndef WINDOW_HAS_FLAGS - if (0) -#else - if (self->win->_flags & _ISPAD) +#ifdef WINDOW_HAS_FLAGS + if (self->win->_flags & _ISPAD) { + if (!group_right_1) { + PyErr_SetString(PyCursesError, + "refresh() for a pad requires 6 arguments"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + rtn = prefresh(self->win, pminrow, pmincol, + sminrow, smincol, smaxrow, smaxcol); + Py_END_ALLOW_THREADS + return PyCursesCheckERR(rtn, "prefresh"); + } #endif - { - switch(PyTuple_Size(args)) { - case 6: - if (!PyArg_ParseTuple(args, - "iiiiii;" \ - "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol", - &pminrow, &pmincol, &sminrow, - &smincol, &smaxrow, &smaxcol)) - return NULL; - - Py_BEGIN_ALLOW_THREADS - rtn = prefresh(self->win, - pminrow, pmincol, sminrow, - smincol, smaxrow, smaxcol); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "prefresh"); - default: - PyErr_SetString(PyCursesError, - "refresh() for a pad requires 6 arguments"); - return NULL; - } - } else { - if (!PyArg_ParseTuple(args, ":refresh")) - return NULL; - Py_BEGIN_ALLOW_THREADS - rtn = wrefresh(self->win); - Py_END_ALLOW_THREADS - return PyCursesCheckERR(rtn, "prefresh"); - } + if (group_right_1) { + PyErr_SetString(PyExc_TypeError, + "refresh() takes no arguments (6 given)"); + return NULL; + } + Py_BEGIN_ALLOW_THREADS + rtn = wrefresh(self->win); + Py_END_ALLOW_THREADS + return PyCursesCheckERR(rtn, "prefresh"); } +/*[clinic input] +_curses.window.setscrreg + + top: int + bottom: int + / + +Set the scrolling region from line top to line bottom. + +All scrolling actions will take place in this region. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_SetScrollRegion(PyCursesWindowObject *self, PyObject *args) +_curses_window_setscrreg_impl(PyCursesWindowObject *self, int top, + int bottom) +/*[clinic end generated code: output=486ab5db218d2b1a input=ad0103494803fd87]*/ { - int x, y; - if (!PyArg_ParseTuple(args,"ii;top, bottom",&y,&x)) - return NULL; - return PyCursesCheckERR(wsetscrreg(self->win,y,x), "wsetscrreg"); + return PyCursesCheckERR(wsetscrreg(self->win, top, bottom), "wsetscrreg"); } +/*[clinic input] +_curses.window.subwin + + [ + nlines: int + Height. + ncols: int + Width. + ] + begin_y: int + Top side y-coordinate. + begin_x: int + Left side x-coordinate. + / + +Return a sub-window. + +By default, the sub-window will extend from the specified position to the +lower right corner of the window. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_SubWin(PyCursesWindowObject *self, PyObject *args) +_curses_window_subwin_impl(PyCursesWindowObject *self, int group_left_1, + int nlines, int ncols, int begin_y, int begin_x) +/*[clinic end generated code: output=93e898afc348f59a input=9ecd7649287f3868]*/ { WINDOW *win; - int nlines, ncols, begin_y, begin_x; - - nlines = 0; - ncols = 0; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;begin_y,begin_x",&begin_y,&begin_x)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x", - &nlines,&ncols,&begin_y,&begin_x)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "subwin requires 2 or 4 arguments"); - return NULL; - } + + if (!group_left_1) + nlines = ncols = 0; /* printf("Subwin: %i %i %i %i \n", nlines, ncols, begin_y, begin_x); */ #ifdef WINDOW_HAS_FLAGS @@ -1849,84 +2144,91 @@ PyCursesWindow_SubWin(PyCursesWindowObje return (PyObject *)PyCursesWindow_New(win, self->encoding); } +/*[clinic input] +_curses.window.scroll + + [ + lines: int + ] + / + +Scroll the screen or scrolling region upward by lines lines. +[clinic start generated code]*/ + static PyObject * -PyCursesWindow_Scroll(PyCursesWindowObject *self, PyObject *args) +_curses_window_scroll_impl(PyCursesWindowObject *self, int group_right_1, + int lines) +/*[clinic end generated code: output=4541a8a11852d360 input=771194309d35b615]*/ { - int nlines; - switch(PyTuple_Size(args)) { - case 0: + if (!group_right_1) return PyCursesCheckERR(scroll(self->win), "scroll"); - case 1: - if (!PyArg_ParseTuple(args, "i;nlines", &nlines)) - return NULL; - return PyCursesCheckERR(wscrl(self->win, nlines), "scroll"); - default: - PyErr_SetString(PyExc_TypeError, "scroll requires 0 or 1 arguments"); + else + return PyCursesCheckERR(wscrl(self->win, lines), "scroll"); +} + +/*[clinic input] +_curses.window.touchline + + start: int + count: int + [ + changed: int + ] + / + +Pretend count lines have been changed, starting with line start. + +If changed is supplied, it specifies whether the affected lines are marked +as having been changed (changed=1) or unchanged (changed=0). +[clinic start generated code]*/ + +static PyObject * +_curses_window_touchline_impl(PyCursesWindowObject *self, int start, + int count, int group_right_1, int changed) +/*[clinic end generated code: output=65d05b3f7438c61d input=c760cfac402d00d6]*/ +{ + if (!group_right_1) + return PyCursesCheckERR(touchline(self->win, start, count), "touchline"); + else + return PyCursesCheckERR(wtouchln(self->win, start, count, changed), "touchline"); +} + +/*[clinic input] +_curses.window.vline + + [ + y: int + Y-coordinate. + x: int + X-coordinate. + ] + + ch: object + Character to draw. + n: int + Line length. + + attr: long(c_default="A_NORMAL") = A_NORMAL + Attributes for the character. + / + +Display a vertical line starting at (y, x) with length n consisting of the character ch. +[clinic start generated code]*/ + +static PyObject * +_curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int n, long attr) +/*[clinic end generated code: output=f9be259ded57effd input=9ac52aaae02fc48e]*/ +{ + chtype ch_; + + if (!PyCurses_ConvertToChtype(self, ch, &ch_)) return NULL; + if (group_left_1) { + if (wmove(self->win, y, x) == ERR) + return PyCursesCheckERR(ERR, "wmove"); } -} - -static PyObject * -PyCursesWindow_TouchLine(PyCursesWindowObject *self, PyObject *args) -{ - int st, cnt, val; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;start,count",&st,&cnt)) - return NULL; - return PyCursesCheckERR(touchline(self->win,st,cnt), "touchline"); - case 3: - if (!PyArg_ParseTuple(args, "iii;start,count,val", &st, &cnt, &val)) - return NULL; - return PyCursesCheckERR(wtouchln(self->win, st, cnt, val), "touchline"); - default: - PyErr_SetString(PyExc_TypeError, "touchline requires 2 or 3 arguments"); - return NULL; - } -} - -static PyObject * -PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args) -{ - PyObject *temp; - chtype ch; - int n, x, y, code = OK; - attr_t attr = A_NORMAL; - long lattr; - - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args, "Oi;ch or int,n", &temp, &n)) - return NULL; - break; - case 3: - if (!PyArg_ParseTuple(args, "Oil;ch or int,n,attr", &temp, &n, &lattr)) - return NULL; - attr = lattr; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n)) - return NULL; - code = wmove(self->win, y, x); - break; - case 5: - if (!PyArg_ParseTuple(args, "iiOil; y,x,ch or int,n,attr", - &y, &x, &temp, &n, &lattr)) - return NULL; - attr = lattr; - code = wmove(self->win, y, x); - break; - default: - PyErr_SetString(PyExc_TypeError, "vline requires 2 to 5 arguments"); - return NULL; - } - - if (code != ERR) { - if (!PyCurses_ConvertToChtype(self, temp, &ch)) - return NULL; - return PyCursesCheckERR(wvline(self->win, ch | attr, n), "vline"); - } else - return PyCursesCheckERR(code, "wmove"); + return PyCursesCheckERR(wvline(self->win, ch_ | (attr_t)attr, n), "vline"); } static PyObject * @@ -1967,55 +2269,52 @@ PyCursesWindow_set_encoding(PyCursesWind return 0; } +#include "clinic/_cursesmodule.c.h" static PyMethodDef PyCursesWindow_Methods[] = { - CURSES_WINDOW_ADDCH_METHODDEF - {"addnstr", (PyCFunction)PyCursesWindow_AddNStr, METH_VARARGS}, - {"addstr", (PyCFunction)PyCursesWindow_AddStr, METH_VARARGS}, - {"attroff", (PyCFunction)PyCursesWindow_AttrOff, METH_VARARGS}, - {"attron", (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS}, - {"attrset", (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS}, - {"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS}, + _CURSES_WINDOW_ADDCH_METHODDEF + _CURSES_WINDOW_ADDNSTR_METHODDEF + _CURSES_WINDOW_ADDSTR_METHODDEF + _CURSES_WINDOW_ATTROFF_METHODDEF + _CURSES_WINDOW_ATTRON_METHODDEF + _CURSES_WINDOW_ATTRSET_METHODDEF + _CURSES_WINDOW_BKGD_METHODDEF {"chgat", (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS}, - {"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS}, - {"border", (PyCFunction)PyCursesWindow_Border, METH_VARARGS}, - {"box", (PyCFunction)PyCursesWindow_Box, METH_VARARGS}, + _CURSES_WINDOW_BKGDSET_METHODDEF + _CURSES_WINDOW_BORDER_METHODDEF + _CURSES_WINDOW_BOX_METHODDEF {"clear", (PyCFunction)PyCursesWindow_wclear, METH_NOARGS}, {"clearok", (PyCFunction)PyCursesWindow_clearok, METH_VARARGS}, {"clrtobot", (PyCFunction)PyCursesWindow_wclrtobot, METH_NOARGS}, {"clrtoeol", (PyCFunction)PyCursesWindow_wclrtoeol, METH_NOARGS}, {"cursyncup", (PyCFunction)PyCursesWindow_wcursyncup, METH_NOARGS}, - {"delch", (PyCFunction)PyCursesWindow_DelCh, METH_VARARGS}, + _CURSES_WINDOW_DELCH_METHODDEF {"deleteln", (PyCFunction)PyCursesWindow_wdeleteln, METH_NOARGS}, - {"derwin", (PyCFunction)PyCursesWindow_DerWin, METH_VARARGS}, - {"echochar", (PyCFunction)PyCursesWindow_EchoChar, METH_VARARGS}, -#ifdef NCURSES_MOUSE_VERSION - {"enclose", (PyCFunction)PyCursesWindow_Enclose, METH_VARARGS}, -#endif + _CURSES_WINDOW_DERWIN_METHODDEF + _CURSES_WINDOW_ECHOCHAR_METHODDEF + _CURSES_WINDOW_ENCLOSE_METHODDEF {"erase", (PyCFunction)PyCursesWindow_werase, METH_NOARGS}, {"getbegyx", (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS}, - {"getbkgd", (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS}, - {"getch", (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS}, - {"getkey", (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS}, -#ifdef HAVE_NCURSESW - {"get_wch", (PyCFunction)PyCursesWindow_Get_WCh, METH_VARARGS}, -#endif + _CURSES_WINDOW_GETBKGD_METHODDEF + _CURSES_WINDOW_GETCH_METHODDEF + _CURSES_WINDOW_GETKEY_METHODDEF + _CURSES_WINDOW_GET_WCH_METHODDEF {"getmaxyx", (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS}, {"getparyx", (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS}, {"getstr", (PyCFunction)PyCursesWindow_GetStr, METH_VARARGS}, {"getyx", (PyCFunction)PyCursesWindow_getyx, METH_NOARGS}, - {"hline", (PyCFunction)PyCursesWindow_Hline, METH_VARARGS}, + _CURSES_WINDOW_HLINE_METHODDEF {"idcok", (PyCFunction)PyCursesWindow_idcok, METH_VARARGS}, {"idlok", (PyCFunction)PyCursesWindow_idlok, METH_VARARGS}, {"immedok", (PyCFunction)PyCursesWindow_immedok, METH_VARARGS}, - {"inch", (PyCFunction)PyCursesWindow_InCh, METH_VARARGS}, - {"insch", (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS}, + _CURSES_WINDOW_INCH_METHODDEF + _CURSES_WINDOW_INSCH_METHODDEF {"insdelln", (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS}, {"insertln", (PyCFunction)PyCursesWindow_winsertln, METH_NOARGS}, - {"insnstr", (PyCFunction)PyCursesWindow_InsNStr, METH_VARARGS}, - {"insstr", (PyCFunction)PyCursesWindow_InsStr, METH_VARARGS}, + _CURSES_WINDOW_INSNSTR_METHODDEF + _CURSES_WINDOW_INSSTR_METHODDEF {"instr", (PyCFunction)PyCursesWindow_InStr, METH_VARARGS}, - {"is_linetouched", (PyCFunction)PyCursesWindow_Is_LineTouched, METH_VARARGS}, + _CURSES_WINDOW_IS_LINETOUCHED_METHODDEF {"is_wintouched", (PyCFunction)PyCursesWindow_is_wintouched, METH_NOARGS}, {"keypad", (PyCFunction)PyCursesWindow_keypad, METH_VARARGS}, {"leaveok", (PyCFunction)PyCursesWindow_leaveok, METH_VARARGS}, @@ -2024,32 +2323,31 @@ static PyMethodDef PyCursesWindow_Method {"mvwin", (PyCFunction)PyCursesWindow_mvwin, METH_VARARGS}, {"nodelay", (PyCFunction)PyCursesWindow_nodelay, METH_VARARGS}, {"notimeout", (PyCFunction)PyCursesWindow_notimeout, METH_VARARGS}, - {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS}, - {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS}, - {"overwrite", (PyCFunction)PyCursesWindow_Overwrite, - METH_VARARGS}, - {"putwin", (PyCFunction)PyCursesWindow_PutWin, METH_O}, - {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine, METH_VARARGS}, + _CURSES_WINDOW_NOUTREFRESH_METHODDEF + _CURSES_WINDOW_OVERLAY_METHODDEF + _CURSES_WINDOW_OVERWRITE_METHODDEF + _CURSES_WINDOW_PUTWIN_METHODDEF + _CURSES_WINDOW_REDRAWLN_METHODDEF {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin, METH_NOARGS}, - {"refresh", (PyCFunction)PyCursesWindow_Refresh, METH_VARARGS}, + _CURSES_WINDOW_REFRESH_METHODDEF #ifndef STRICT_SYSV_CURSES {"resize", (PyCFunction)PyCursesWindow_wresize, METH_VARARGS}, #endif - {"scroll", (PyCFunction)PyCursesWindow_Scroll, METH_VARARGS}, + _CURSES_WINDOW_SCROLL_METHODDEF {"scrollok", (PyCFunction)PyCursesWindow_scrollok, METH_VARARGS}, - {"setscrreg", (PyCFunction)PyCursesWindow_SetScrollRegion, METH_VARARGS}, + _CURSES_WINDOW_SETSCRREG_METHODDEF {"standend", (PyCFunction)PyCursesWindow_wstandend, METH_NOARGS}, {"standout", (PyCFunction)PyCursesWindow_wstandout, METH_NOARGS}, - {"subpad", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS}, - {"subwin", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS}, + {"subpad", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__}, + _CURSES_WINDOW_SUBWIN_METHODDEF {"syncdown", (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS}, {"syncok", (PyCFunction)PyCursesWindow_syncok, METH_VARARGS}, {"syncup", (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS}, {"timeout", (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS}, - {"touchline", (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS}, + _CURSES_WINDOW_TOUCHLINE_METHODDEF {"touchwin", (PyCFunction)PyCursesWindow_touchwin, METH_NOARGS}, {"untouchwin", (PyCFunction)PyCursesWindow_untouchwin, METH_NOARGS}, - {"vline", (PyCFunction)PyCursesWindow_Vline, METH_VARARGS}, + _CURSES_WINDOW_VLINE_METHODDEF {NULL, NULL} /* sentinel */ }; @@ -2065,7 +2363,7 @@ static PyGetSetDef PyCursesWindow_getset PyTypeObject PyCursesWindow_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "_curses.curses window", /*tp_name*/ + "_curses window", /*tp_name*/ sizeof(PyCursesWindowObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ @@ -2100,62 +2398,107 @@ PyTypeObject PyCursesWindow_Type = { /********************************************************************* Global Functions **********************************************************************/ - -NoArgNoReturnFunction(beep) -NoArgNoReturnFunction(def_prog_mode) -NoArgNoReturnFunction(def_shell_mode) -NoArgNoReturnFunction(doupdate) -NoArgNoReturnFunction(endwin) -NoArgNoReturnFunction(flash) -NoArgNoReturnFunction(nocbreak) -NoArgNoReturnFunction(noecho) -NoArgNoReturnFunction(nonl) -NoArgNoReturnFunction(noraw) -NoArgNoReturnFunction(reset_prog_mode) -NoArgNoReturnFunction(reset_shell_mode) -NoArgNoReturnFunction(resetty) -NoArgNoReturnFunction(savetty) - -NoArgOrFlagNoReturnFunction(cbreak) -NoArgOrFlagNoReturnFunction(echo) -NoArgOrFlagNoReturnFunction(nl) -NoArgOrFlagNoReturnFunction(raw) - -NoArgReturnIntFunction(baudrate) -NoArgReturnIntFunction(termattrs) - -NoArgReturnStringFunction(termname) -NoArgReturnStringFunction(longname) - -NoArgTrueFalseFunction(can_change_color) -NoArgTrueFalseFunction(has_colors) -NoArgTrueFalseFunction(has_ic) -NoArgTrueFalseFunction(has_il) -NoArgTrueFalseFunction(isendwin) -NoArgNoReturnVoidFunction(flushinp) -NoArgNoReturnVoidFunction(noqiflush) +#define NoArgOrFlagNoReturnFunctionBody(X, flag) \ +{ \ + PyCursesInitialised \ + if (flag) \ + return PyCursesCheckERR(X(), # X); \ + else \ + return PyCursesCheckERR(no ## X(), # X); \ +} + +/*[clinic input] +_curses.filter + +[clinic start generated code]*/ static PyObject * -PyCurses_filter(PyObject *self) +_curses_filter_impl(PyModuleDef *module) +/*[clinic end generated code: output=0573bb2126de3900 input=668c75a6992d3624]*/ { /* not checking for PyCursesInitialised here since filter() must be called before initscr() */ filter(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } +/*[clinic input] +_curses.baudrate + +Return the output speed of the terminal in bits per second. +[clinic start generated code]*/ + static PyObject * -PyCurses_Color_Content(PyObject *self, PyObject *args) +_curses_baudrate_impl(PyModuleDef *module) +/*[clinic end generated code: output=c190b17176256bae input=921f022ed04a0fd9]*/ +NoArgReturnIntFunctionBody(baudrate) + +/*[clinic input] +_curses.beep + +Emit a short attention sound. +[clinic start generated code]*/ + +static PyObject * +_curses_beep_impl(PyModuleDef *module) +/*[clinic end generated code: output=8327a2a1e6190ce8 input=a35698ca7d0162bc]*/ +NoArgNoReturnFunctionBody(beep) + +/*[clinic input] +_curses.can_change_color + +Return True if the programmer can change the colors displayed by the terminal. +[clinic start generated code]*/ + +static PyObject * +_curses_can_change_color_impl(PyModuleDef *module) +/*[clinic end generated code: output=70786f0fd4a63cb9 input=d7718884de0092f2]*/ +NoArgTrueFalseFunctionBody(can_change_color) + +/*[clinic input] +_curses.cbreak + + flag: int(c_default="1") = True + If false, the effect is the same as calling nocbreak(). + / + +Enter cbreak mode. + +In cbreak mode (sometimes called “rare” mode) normal tty line buffering is +turned off and characters are available to be read one by one. However, +unlike raw mode, special characters (interrupt, quit, suspend, and flow +control) retain their effects on the tty driver and calling program. +Calling first raw() then cbreak() leaves the terminal in cbreak mode. +[clinic start generated code]*/ + +static PyObject * +_curses_cbreak_impl(PyModuleDef *module, int flag) +/*[clinic end generated code: output=fa35eff2547158ee input=6633422a270165a7]*/ +NoArgOrFlagNoReturnFunctionBody(cbreak, flag) + +/*[clinic input] +_curses.color_content + + color_number: short + The number of the color (0 - COLORS). + / + +Return the intensity of the red, green, and blue (RGB) components in the color color_number. + +A 3-tuple is returned, containing the R,G,B values for the given color, +which will be between 0 (no component) and 1000 (maximum amount of component). +[clinic start generated code]*/ + +static PyObject * +_curses_color_content_impl(PyModuleDef *module, short color_number) +/*[clinic end generated code: output=b762840965a2a5ff input=3fd5cd66c2ce0f3c]*/ { - short color,r,g,b; + short r,g,b; PyCursesInitialised; PyCursesInitialisedColor; - if (!PyArg_ParseTuple(args, "h:color_content", &color)) return NULL; - - if (color_content(color, &r, &g, &b) != ERR) + if (color_content(color_number, &r, &g, &b) != ERR) return Py_BuildValue("(iii)", r, g, b); else { PyErr_SetString(PyCursesError, @@ -2164,47 +2507,154 @@ PyCurses_Color_Content(PyObject *self, P } } +/*[clinic input] +_curses.color_pair + + color_number: short + The number of the color (0 - COLORS). + / + +Return the attribute value for displaying text in the specified color. + +This attribute value can be combined with A_STANDOUT, A_REVERSE, and the +other A_* attributes. pair_number() is the counterpart to this function. +[clinic start generated code]*/ + static PyObject * -PyCurses_color_pair(PyObject *self, PyObject *args) +_curses_color_pair_impl(PyModuleDef *module, short color_number) +/*[clinic end generated code: output=7fa4386048dc5e75 input=a9d3eb6f50e4dc12]*/ { - int n; - PyCursesInitialised; PyCursesInitialisedColor; - if (!PyArg_ParseTuple(args, "i:color_pair", &n)) return NULL; - return PyLong_FromLong((long) (n << 8)); + return PyLong_FromLong((long) (color_number << 8)); } +/*[clinic input] +_curses.curs_set + + visibility: int + 0 for invisible, 1 for normal visible, or 2 for very visible. + / + +Set the cursor state. + +If the terminal supports the visibility requested, the previous cursor +state is returned; otherwise, an exception is raised. On many terminals, +the “visible” mode is an underline cursor and the “very visible” mode is +a block cursor. +[clinic start generated code]*/ + static PyObject * -PyCurses_Curs_Set(PyObject *self, PyObject *args) +_curses_curs_set_impl(PyModuleDef *module, int visibility) +/*[clinic end generated code: output=409ef7998e2fe8b1 input=d5af1c5236f2626f]*/ { - int vis,erg; + int erg; PyCursesInitialised; - if (!PyArg_ParseTuple(args, "i:curs_set", &vis)) return NULL; - - erg = curs_set(vis); + erg = curs_set(visibility); if (erg == ERR) return PyCursesCheckERR(erg, "curs_set"); return PyLong_FromLong((long) erg); } +/*[clinic input] +_curses.def_prog_mode + +Save the current terminal mode as the “program” mode. + +The “program” mode is the mode when the running program is using curses. + +Subsequent calls to reset_prog_mode() will restore this mode. +[clinic start generated code]*/ + static PyObject * -PyCurses_Delay_Output(PyObject *self, PyObject *args) +_curses_def_prog_mode_impl(PyModuleDef *module) +/*[clinic end generated code: output=e057ce14da5c803b input=cb067201c42cd175]*/ +NoArgNoReturnFunctionBody(def_prog_mode) + +/*[clinic input] +_curses.def_shell_mode + +Save the current terminal mode as the “shell” mode. + +The “shell” mode is the mode when the running program is not using curses. + +Subsequent calls to reset_shell_mode() will restore this mode. +[clinic start generated code]*/ + +static PyObject * +_curses_def_shell_mode_impl(PyModuleDef *module) +/*[clinic end generated code: output=61c8d9b4db2f6c56 input=1ae767d6005ea690]*/ +NoArgNoReturnFunctionBody(def_shell_mode) + +/*[clinic input] +_curses.delay_output + + ms: int + / + +Insert an ms millisecond pause in output. +[clinic start generated code]*/ + +static PyObject * +_curses_delay_output_impl(PyModuleDef *module, int ms) +/*[clinic end generated code: output=15b71e330d34d2fc input=73de3743ba133361]*/ { - int ms; - PyCursesInitialised; - if (!PyArg_ParseTuple(args, "i:delay_output", &ms)) return NULL; - return PyCursesCheckERR(delay_output(ms), "delay_output"); } +/*[clinic input] +_curses.doupdate + +Update the physical screen to match the virtual screen. +[clinic start generated code]*/ + static PyObject * -PyCurses_EraseChar(PyObject *self) +_curses_doupdate_impl(PyModuleDef *module) +/*[clinic end generated code: output=c88003068c0cd9e7 input=8da80914432a6489]*/ +NoArgNoReturnFunctionBody(doupdate) + +/*[clinic input] +_curses.echo + + flag: int(c_default="1") = True + If false, the effect is the same as calling noecho(). + / + +Enter echo mode. + +In echo mode, each character input is echoed to the screen as it is entered. +[clinic start generated code]*/ + +static PyObject * +_curses_echo_impl(PyModuleDef *module, int flag) +/*[clinic end generated code: output=ad1730bc13260dfa input=b37eb5665d6882b1]*/ +NoArgOrFlagNoReturnFunctionBody(echo, flag) + +/*[clinic input] +_curses.endwin + +De-initialize the library, and return terminal to normal status. +[clinic start generated code]*/ + +static PyObject * +_curses_endwin_impl(PyModuleDef *module) +/*[clinic end generated code: output=6d655f43d2ab4187 input=e172cfa43062f3fa]*/ +NoArgNoReturnFunctionBody(endwin) + +/*[clinic input] +_curses.erasechar + +Return the user’s current erase character. +[clinic start generated code]*/ + +static PyObject * +_curses_erasechar_impl(PyModuleDef *module) +/*[clinic end generated code: output=31219d8bb4e93941 input=e84dddc105750ae3]*/ { char ch; @@ -2215,8 +2665,44 @@ PyCurses_EraseChar(PyObject *self) return PyBytes_FromStringAndSize(&ch, 1); } +/*[clinic input] +_curses.flash + +Flash the screen. + +That is, change it to reverse-video and then change it back in a short interval. +[clinic start generated code]*/ + static PyObject * -PyCurses_getsyx(PyObject *self) +_curses_flash_impl(PyModuleDef *module) +/*[clinic end generated code: output=7030737287106f49 input=02fdfb06c8fc3171]*/ +NoArgNoReturnFunctionBody(flash) + +/*[clinic input] +_curses.flushinp + +Flush all input buffers. + +This throws away any typeahead that has been typed by the user and has not +yet been processed by the program. +[clinic start generated code]*/ + +static PyObject * +_curses_flushinp_impl(PyModuleDef *module) +/*[clinic end generated code: output=66f466b0d2b51d3a input=59d042e705cef5ec]*/ +NoArgNoReturnVoidFunctionBody(flushinp) + +/*[clinic input] +_curses.getsyx + +Return the current coordinates of the virtual screen cursor in y and x. + +If leaveok is currently true, then -1,-1 is returned. +[clinic start generated code]*/ + +static PyObject * +_curses_getsyx_impl(PyModuleDef *module) +/*[clinic end generated code: output=740762d6ae891108 input=c35a0da595855c90]*/ { int x = 0; int y = 0; @@ -2229,8 +2715,18 @@ PyCurses_getsyx(PyObject *self) } #ifdef NCURSES_MOUSE_VERSION +/*[clinic input] +_curses.getmouse + +Retrieve the queued mouse event. + +After getch() returns KEY_MOUSE to signal a mouse event, this function +returns a 5-tuple (id, x, y, z, bstate). +[clinic start generated code]*/ + static PyObject * -PyCurses_GetMouse(PyObject *self) +_curses_getmouse_impl(PyModuleDef *module) +/*[clinic end generated code: output=d747109acdc7e49c input=5b756ee6f5b481b1]*/ { int rtn; MEVENT event; @@ -2248,24 +2744,53 @@ PyCurses_GetMouse(PyObject *self) (long) event.bstate); } +/*[clinic input] +_curses.ungetmouse + + id: short + x: int + y: int + z: int + bstate: long + / + +Push a KEY_MOUSE event onto the input queue, associating the given state data with it. +[clinic start generated code]*/ + static PyObject * -PyCurses_UngetMouse(PyObject *self, PyObject *args) +_curses_ungetmouse_impl(PyModuleDef *module, short id, int x, int y, int z, + long bstate) +/*[clinic end generated code: output=9c7155cde1be56e3 input=e79dd2c245fbb4d8]*/ { MEVENT event; + event.id = id, + event.x = x, + event.y = y, + event.z = z, + event.bstate = bstate; + PyCursesInitialised; - if (!PyArg_ParseTuple(args, "hiiil", - &event.id, - &event.x, &event.y, &event.z, - (int *) &event.bstate)) - return NULL; return PyCursesCheckERR(ungetmouse(&event), "ungetmouse"); } #endif +/*[clinic input] +_curses.getwin + + file: object + / + +Read window related data stored in the file by an earlier putwin() call. + +The routine then creates and initializes a new window using that data, +returning the new window object. +[clinic start generated code]*/ + static PyObject * -PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream) +_curses_getwin(PyModuleDef *module, PyObject *file) +/*[clinic end generated code: output=011511c4740a440f input=f713d2bba0e4c929]*/ { char fn[100]; int fd = -1; @@ -2290,7 +2815,7 @@ PyCurses_GetWin(PyCursesWindowObject *se goto error; } - data = _PyObject_CallMethodId(stream, &PyId_read, ""); + data = _PyObject_CallMethodId(file, &PyId_read, ""); if (data == NULL) goto error; if (!PyBytes_Check(data)) { @@ -2325,84 +2850,162 @@ error: return res; } +/*[clinic input] +_curses.halfdelay + + tenths: byte + Maximal blocking delay in tenths of seconds (1 - 255). + / + +Enter half-delay mode. + +Use nocbreak() to leave half-delay mode. +[clinic start generated code]*/ + static PyObject * -PyCurses_HalfDelay(PyObject *self, PyObject *args) +_curses_halfdelay_impl(PyModuleDef *module, unsigned char tenths) +/*[clinic end generated code: output=6e775740a49ca283 input=e42dce7259c15100]*/ { - unsigned char tenths; - PyCursesInitialised; - if (!PyArg_ParseTuple(args, "b:halfdelay", &tenths)) return NULL; - return PyCursesCheckERR(halfdelay(tenths), "halfdelay"); } +/*[clinic input] +_curses.has_colors + +Return True if the terminal can display colors; otherwise, return False. +[clinic start generated code]*/ + +static PyObject * +_curses_has_colors_impl(PyModuleDef *module) +/*[clinic end generated code: output=b8323b4323951d5b input=b2ec41b739d896c6]*/ +NoArgTrueFalseFunctionBody(has_colors) + +/*[clinic input] +_curses.has_ic + +Return True if the terminal has insert- and delete-character capabilities. +[clinic start generated code]*/ + +static PyObject * +_curses_has_ic_impl(PyModuleDef *module) +/*[clinic end generated code: output=66f05784529263c9 input=9bc2d3a797cc7324]*/ +NoArgTrueFalseFunctionBody(has_ic) + +/*[clinic input] +_curses.has_il + +Return True if the terminal has insert- and delete-line capabilities. +[clinic start generated code]*/ + +static PyObject * +_curses_has_il_impl(PyModuleDef *module) +/*[clinic end generated code: output=bd24094c947529b4 input=cd939d5607ee5427]*/ +NoArgTrueFalseFunctionBody(has_il) + #ifndef STRICT_SYSV_CURSES /* No has_key! */ -static PyObject * PyCurses_has_key(PyObject *self, PyObject *args) +/*[clinic input] +_curses.has_key + + key: int + Key number. + / + +Return True if the current terminal type recognizes a key with that value. +[clinic start generated code]*/ + +static PyObject * +_curses_has_key_impl(PyModuleDef *module, int key) +/*[clinic end generated code: output=8028bb702a575a0e input=78bd44acf1a4997c]*/ { - int ch; - PyCursesInitialised; - if (!PyArg_ParseTuple(args,"i",&ch)) return NULL; - - if (has_key(ch) == FALSE) { - Py_INCREF(Py_False); - return Py_False; - } - Py_INCREF(Py_True); - return Py_True; + if (has_key(key)) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; } #endif /* STRICT_SYSV_CURSES */ +/*[clinic input] +_curses.init_color + + color_number: short + The number of the color to be changed (0 - COLORS). + r: short + Red component (0 - 1000). + g: short + Green component (0 - 1000). + b: short + Blue component (0 - 1000). + / + +Change the definition of a color. + +When init_color() is used, all occurrences of that color on the screen +immediately change to the new definition. This function is a no-op on +most terminals; it is active only if can_change_color() returns 1. +[clinic start generated code]*/ + static PyObject * -PyCurses_Init_Color(PyObject *self, PyObject *args) +_curses_init_color_impl(PyModuleDef *module, short color_number, short r, + short g, short b) +/*[clinic end generated code: output=2f4518b58b5ac825 input=f3a05bd38f619175]*/ { - short color, r, g, b; - PyCursesInitialised; PyCursesInitialisedColor; - switch(PyTuple_Size(args)) { - case 4: - if (!PyArg_ParseTuple(args, "hhhh;color,r,g,b", &color, &r, &g, &b)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "init_color requires 4 arguments"); - return NULL; - } - - return PyCursesCheckERR(init_color(color, r, g, b), "init_color"); + return PyCursesCheckERR(init_color(color_number, r, g, b), "init_color"); } +/*[clinic input] +_curses.init_pair + + pair_number: short + The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)). + fg: short + Foreground color number (0 - COLORS). + bg: short + Background color number (0 - COLORS). + / + +Change the definition of a color-pair. + +If the color-pair was previously initialized, the screen is refreshed and +all occurrences of that color-pair are changed to the new definition. +[clinic start generated code]*/ + static PyObject * -PyCurses_Init_Pair(PyObject *self, PyObject *args) +_curses_init_pair_impl(PyModuleDef *module, short pair_number, short fg, + short bg) +/*[clinic end generated code: output=fa292616e7a0e445 input=c9f0b11b17a2ac6d]*/ { - short pair, f, b; - PyCursesInitialised; PyCursesInitialisedColor; - if (PyTuple_Size(args) != 3) { - PyErr_SetString(PyExc_TypeError, "init_pair requires 3 arguments"); - return NULL; - } - - if (!PyArg_ParseTuple(args, "hhh;pair, f, b", &pair, &f, &b)) return NULL; - - return PyCursesCheckERR(init_pair(pair, f, b), "init_pair"); + return PyCursesCheckERR(init_pair(pair_number, fg, bg), "init_pair"); } static PyObject *ModDict; +/*[clinic input] +_curses.initscr + +Initialize the library. + +Return a WindowObject which represents the whole screen. +[clinic start generated code]*/ + static PyObject * -PyCurses_InitScr(PyObject *self) +_curses_initscr_impl(PyModuleDef *module) +/*[clinic end generated code: output=f5a6b829c1c8bdba input=514f4bce1821f6b5]*/ { WINDOW *win; PyCursesWindowObject *winobj; - if (initialised == TRUE) { + if (initialised) { wrefresh(stdscr); return (PyObject *)PyCursesWindow_New(stdscr, NULL); } @@ -2501,19 +3104,24 @@ PyCurses_InitScr(PyObject *self) return (PyObject *)winobj; } +/*[clinic input] +_curses.setupterm + + term: str(accept={str, NoneType}) = NULL + Terminal name. + If omitted, the value of the TERM environment variable will be used. + fd: int = -1 + File descriptor to which any initialization sequences will be sent. + If not supplied, the file descriptor for sys.stdout will be used. + +Initialize the terminal. +[clinic start generated code]*/ + static PyObject * -PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds) +_curses_setupterm_impl(PyModuleDef *module, const char *term, int fd) +/*[clinic end generated code: output=d6bc2366147da789 input=8ac5f78ec6268be3]*/ { - int fd = -1; int err; - char* termstr = NULL; - - static char *kwlist[] = {"term", "fd", NULL}; - - if (!PyArg_ParseTupleAndKeywords( - args, keywds, "|zi:setupterm", kwlist, &termstr, &fd)) { - return NULL; - } if (fd == -1) { PyObject* sys_stdout; @@ -2534,7 +3142,7 @@ PyCurses_setupterm(PyObject* self, PyObj } } - if (!initialised_setupterm && setupterm(termstr,fd,&err) == ERR) { + if (!initialised_setupterm && setupterm((char *)term, fd, &err) == ERR) { char* s = "setupterm: unknown error"; if (err == 0) { @@ -2549,75 +3157,105 @@ PyCurses_setupterm(PyObject* self, PyObj initialised_setupterm = TRUE; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } +/*[clinic input] +_curses.intrflush + + flag: int + True(1), False(0) + / + +[clinic start generated code]*/ + static PyObject * -PyCurses_IntrFlush(PyObject *self, PyObject *args) +_curses_intrflush_impl(PyModuleDef *module, int flag) +/*[clinic end generated code: output=994e5e25b0f15d67 input=3a677488ad6bd183]*/ { - int ch; - PyCursesInitialised; - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "intrflush requires 1 argument"); - return NULL; - } - - return PyCursesCheckERR(intrflush(NULL,ch), "intrflush"); + return PyCursesCheckERR(intrflush(NULL, flag), "intrflush"); } +/*[clinic input] +_curses.isendwin + +Return True if endwin() has been called (that is, the curses library has been deinitialized). +[clinic start generated code]*/ + +static PyObject * +_curses_isendwin_impl(PyModuleDef *module) +/*[clinic end generated code: output=9c452f6e829dc227 input=9b7635c9dc2c9493]*/ +NoArgTrueFalseFunctionBody(isendwin) + #ifdef HAVE_CURSES_IS_TERM_RESIZED +/*[clinic input] +_curses.is_term_resized + + nlines: int + Height. + ncols: int + Width. + / + +Return True if resize_term() would modify the window structure, False otherwise. +[clinic start generated code]*/ + static PyObject * -PyCurses_Is_Term_Resized(PyObject *self, PyObject *args) +_curses_is_term_resized_impl(PyModuleDef *module, int nlines, int ncols) +/*[clinic end generated code: output=116c24ed2bebc898 input=ca9c0bd0fb8ab444]*/ { - int lines; - int columns; int result; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"ii:is_term_resized", &lines, &columns)) - return NULL; - result = is_term_resized(lines, columns); - if (result == TRUE) { - Py_INCREF(Py_True); - return Py_True; - } else { - Py_INCREF(Py_False); - return Py_False; - } + result = is_term_resized(nlines, ncols); + if (result) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; } #endif /* HAVE_CURSES_IS_TERM_RESIZED */ #if !defined(__NetBSD__) +/*[clinic input] +_curses.keyname + + key: int + Key number. + / + +Return the name of specified key. +[clinic start generated code]*/ + static PyObject * -PyCurses_KeyName(PyObject *self, PyObject *args) +_curses_keyname_impl(PyModuleDef *module, int key) +/*[clinic end generated code: output=db7bf53447da8735 input=ee4b1d0f243a2a2b]*/ { const char *knp; - int ch; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"i",&ch)) return NULL; - - if (ch < 0) { + if (key < 0) { PyErr_SetString(PyExc_ValueError, "invalid key number"); return NULL; } - knp = keyname(ch); + knp = keyname(key); return PyBytes_FromString((knp == NULL) ? "" : knp); } #endif +/*[clinic input] +_curses.killchar + +Return the user’s current line kill character. +[clinic start generated code]*/ + static PyObject * -PyCurses_KillChar(PyObject *self) +_curses_killchar_impl(PyModuleDef *module) +/*[clinic end generated code: output=f4bf1c18048038a4 input=b47714b1d6843d5f]*/ { char ch; @@ -2626,73 +3264,123 @@ PyCurses_KillChar(PyObject *self) return PyBytes_FromStringAndSize(&ch, 1); } +/*[clinic input] +_curses.longname + +Return a string containing the terminfo long name field describing the current terminal. + +The maximum length of a verbose description is 128 characters. It is defined +only after the call to initscr(). +[clinic start generated code]*/ + static PyObject * -PyCurses_Meta(PyObject *self, PyObject *args) +_curses_longname_impl(PyModuleDef *module) +/*[clinic end generated code: output=c0f9cb71b0bc5657 input=872e0c56b0939215]*/ +NoArgReturnStringFunctionBody(longname) + +/*[clinic input] +_curses.meta + + yes: int + True(1), False(0) + / + +If yes is 1, allow 8-bit characters to be input. If yes is 0, allow only 7-bit chars. +[clinic start generated code]*/ + +static PyObject * +_curses_meta_impl(PyModuleDef *module, int yes) +/*[clinic end generated code: output=ced37b2218afe820 input=533da0c00979ab78]*/ { - int ch; - PyCursesInitialised; - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&ch)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "meta requires 1 argument"); - return NULL; - } - - return PyCursesCheckERR(meta(stdscr, ch), "meta"); + return PyCursesCheckERR(meta(stdscr, yes), "meta"); } #ifdef NCURSES_MOUSE_VERSION +/*[clinic input] +_curses.mouseinterval + + interval: int + / + +Set the maximum time in milliseconds that can elapse between press and release events in order for them to be recognized as a click, and return the previous interval value. +[clinic start generated code]*/ + static PyObject * -PyCurses_MouseInterval(PyObject *self, PyObject *args) +_curses_mouseinterval_impl(PyModuleDef *module, int interval) +/*[clinic end generated code: output=f13878c225a00b64 input=1e66e3e625dd34a6]*/ { - int interval; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"i;interval",&interval)) - return NULL; return PyCursesCheckERR(mouseinterval(interval), "mouseinterval"); } +/*[clinic input] +_curses.mousemask + + newmask: int + / + +Set the mouse events to be reported, and return a tuple (availmask, oldmask). + +Return a tuple (availmask, oldmask). availmask indicates which of the +specified mouse events can be reported; on complete failure it returns 0. +oldmask is the previous value of the given window’s mouse event mask. +If this function is never called, no mouse events are ever reported. +[clinic start generated code]*/ + static PyObject * -PyCurses_MouseMask(PyObject *self, PyObject *args) +_curses_mousemask_impl(PyModuleDef *module, int newmask) +/*[clinic end generated code: output=4f5fc0297478280c input=dc98a330a2c12193]*/ { - int newmask; mmask_t oldmask, availmask; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"i;mousemask",&newmask)) - return NULL; availmask = mousemask(newmask, &oldmask); return Py_BuildValue("(ll)", (long)availmask, (long)oldmask); } #endif +/*[clinic input] +_curses.napms + + ms: int + / + +Sleep for ms milliseconds. +[clinic start generated code]*/ + static PyObject * -PyCurses_Napms(PyObject *self, PyObject *args) +_curses_napms_impl(PyModuleDef *module, int ms) +/*[clinic end generated code: output=500487ede8e14cdd input=aa242a130c82f5b2]*/ { - int ms; - PyCursesInitialised; - if (!PyArg_ParseTuple(args, "i;ms", &ms)) return NULL; return Py_BuildValue("i", napms(ms)); } +/*[clinic input] +_curses.newpad + + nlines: int + Height. + ncols: int + Width. + / + +Create and return a pointer to a new pad data structure. +[clinic start generated code]*/ + static PyObject * -PyCurses_NewPad(PyObject *self, PyObject *args) +_curses_newpad_impl(PyModuleDef *module, int nlines, int ncols) +/*[clinic end generated code: output=9010f5dd00944d33 input=93f1272f240d8894]*/ { WINDOW *win; - int nlines, ncols; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols)) return NULL; - win = newpad(nlines, ncols); if (win == NULL) { @@ -2703,28 +3391,38 @@ PyCurses_NewPad(PyObject *self, PyObject return (PyObject *)PyCursesWindow_New(win, NULL); } +/*[clinic input] +_curses.newwin + + nlines: int + Height. + ncols: int + Width. + [ + begin_y: int + Top side y-coordinate. + begin_x: int + Left side x-coordinate. + ] + / + +Return a new window. + +By default, the window will extend from the specified position to the lower +right corner of the screen. +[clinic start generated code]*/ + static PyObject * -PyCurses_NewWindow(PyObject *self, PyObject *args) +_curses_newwin_impl(PyModuleDef *module, int nlines, int ncols, + int group_right_1, int begin_y, int begin_x) +/*[clinic end generated code: output=df885ad501d96639 input=1a702b2f903b33ff]*/ { WINDOW *win; - int nlines, ncols, begin_y=0, begin_x=0; PyCursesInitialised; - switch (PyTuple_Size(args)) { - case 2: - if (!PyArg_ParseTuple(args,"ii;nlines,ncols",&nlines,&ncols)) - return NULL; - break; - case 4: - if (!PyArg_ParseTuple(args, "iiii;nlines,ncols,begin_y,begin_x", - &nlines,&ncols,&begin_y,&begin_x)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "newwin requires 2 or 4 arguments"); - return NULL; - } + if (!group_right_1) + begin_y = begin_x = 0; win = newwin(nlines,ncols,begin_y,begin_x); if (win == NULL) { @@ -2735,24 +3433,108 @@ PyCurses_NewWindow(PyObject *self, PyObj return (PyObject *)PyCursesWindow_New(win, NULL); } +/*[clinic input] +_curses.nl + + flag: int(c_default="1") = True + If false, the effect is the same as calling nonl(). + / + +Enter newline mode. + +This mode translates the return key into newline on input, and translates +newline into return and line-feed on output. Newline mode is initially on. +[clinic start generated code]*/ + static PyObject * -PyCurses_Pair_Content(PyObject *self, PyObject *args) +_curses_nl_impl(PyModuleDef *module, int flag) +/*[clinic end generated code: output=1e27f4437d17dce4 input=665ff4c0f080f05a]*/ +NoArgOrFlagNoReturnFunctionBody(nl, flag) + +/*[clinic input] +_curses.nocbreak + +Leave cbreak mode. + +Return to normal “cooked” mode with line buffering. +[clinic start generated code]*/ + +static PyObject * +_curses_nocbreak_impl(PyModuleDef *module) +/*[clinic end generated code: output=9a97ab66e2796363 input=645b1f281457fd05]*/ +NoArgNoReturnFunctionBody(nocbreak) + +/*[clinic input] +_curses.noecho + +Leave echo mode. + +Echoing of input characters is turned off. +[clinic start generated code]*/ + +static PyObject * +_curses_noecho_impl(PyModuleDef *module) +/*[clinic end generated code: output=2f5ece4aa408e1b1 input=76714df529e614c3]*/ +NoArgNoReturnFunctionBody(noecho) + +/*[clinic input] +_curses.nonl + +Leave newline mode. + +Disable translation of return into newline on input, and disable low-level +translation of newline into newline/return on output. +[clinic start generated code]*/ + +static PyObject * +_curses_nonl_impl(PyModuleDef *module) +/*[clinic end generated code: output=85be42c88d94b172 input=9d37dd122d3022fc]*/ +NoArgNoReturnFunctionBody(nonl) + +/*[clinic input] +_curses.noqiflush + +When the noqiflush() routine is used, normal flush of input and output queues associated with the INTR, QUIT and SUSP characters will not be done. You may want to call noqiflush() in a signal handler if you want output to continue as though the interrupt had not occurred, after the handler exits. +[clinic start generated code]*/ + +static PyObject * +_curses_noqiflush_impl(PyModuleDef *module) +/*[clinic end generated code: output=aa062543ee4d99a7 input=fdcc83b2cc143bbc]*/ +NoArgNoReturnVoidFunctionBody(noqiflush) + +/*[clinic input] +_curses.noraw + +Leave raw mode. + +Return to normal “cooked” mode with line buffering. +[clinic start generated code]*/ + +static PyObject * +_curses_noraw_impl(PyModuleDef *module) +/*[clinic end generated code: output=5ca0044df59c60ce input=abc08dca62acba21]*/ +NoArgNoReturnFunctionBody(noraw) + +/*[clinic input] +_curses.pair_content + + pair_number: short + The number of the color pair (1 - (COLOR_PAIRS-1)). + / + +Return a tuple (fg, bg) containing the colors for the requested color pair. +[clinic start generated code]*/ + +static PyObject * +_curses_pair_content_impl(PyModuleDef *module, short pair_number) +/*[clinic end generated code: output=d0fa65853cd4fabe input=f4d7fec5643b976b]*/ { - short pair,f,b; + short f, b; PyCursesInitialised; PyCursesInitialisedColor; - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "h;pair", &pair)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "pair_content requires 1 argument"); - return NULL; - } - - if (pair_content(pair, &f, &b)==ERR) { + if (pair_content(pair_number, &f, &b)==ERR) { PyErr_SetString(PyCursesError, "Argument 1 was out of range. (1..COLOR_PAIRS-1)"); return NULL; @@ -2761,59 +3543,66 @@ PyCurses_Pair_Content(PyObject *self, Py return Py_BuildValue("(ii)", f, b); } +/*[clinic input] +_curses.pair_number + + attr: int + / + +Return the number of the color-pair set by the attribute value attr. + +color_pair() is the counterpart to this function. +[clinic start generated code]*/ + static PyObject * -PyCurses_pair_number(PyObject *self, PyObject *args) +_curses_pair_number_impl(PyModuleDef *module, int attr) +/*[clinic end generated code: output=24845815dec02346 input=4545b1c8d89a8a18]*/ { - int n; - PyCursesInitialised; PyCursesInitialisedColor; - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args, "i;pairvalue", &n)) return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, - "pair_number requires 1 argument"); - return NULL; - } - - return PyLong_FromLong((long) ((n & A_COLOR) >> 8)); + return PyLong_FromLong((long) ((attr & A_COLOR) >> 8)); } +/*[clinic input] +_curses.putp + + string: str(accept={robuffer}) + / + +Emit the value of a specified terminfo capability for the current terminal. + +Note that the output of putp() always goes to standard output. +[clinic start generated code]*/ + static PyObject * -PyCurses_Putp(PyObject *self, PyObject *args) +_curses_putp_impl(PyModuleDef *module, const char *string) +/*[clinic end generated code: output=526aef2b7ffc186b input=1601faa828b44cb3]*/ { - char *str; - - if (!PyArg_ParseTuple(args,"y;str", &str)) - return NULL; - return PyCursesCheckERR(putp(str), "putp"); + return PyCursesCheckERR(putp(string), "putp"); } +/*[clinic input] +_curses.qiflush + + flag: int(c_default="1") = True + If false, the effect is the same as calling noqiflush(). + / + +The queues will be flushed when these control characters are read. +[clinic start generated code]*/ + static PyObject * -PyCurses_QiFlush(PyObject *self, PyObject *args) +_curses_qiflush_impl(PyModuleDef *module, int flag) +/*[clinic end generated code: output=9b6a96ada569b540 input=c69fa53209b10b37]*/ { - int flag = 0; - PyCursesInitialised; - switch(PyTuple_Size(args)) { - case 0: + if (flag) qiflush(); - Py_INCREF(Py_None); - return Py_None; - case 1: - if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; - if (flag) qiflush(); - else noqiflush(); - Py_INCREF(Py_None); - return Py_None; - default: - PyErr_SetString(PyExc_TypeError, "qiflush requires 0 or 1 arguments"); - return NULL; - } + else + noqiflush(); + Py_RETURN_NONE; } /* Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES @@ -2867,28 +3656,97 @@ update_lines_cols(void) return 1; } +/*[clinic input] +_curses.update_lines_cols -> int + +[clinic start generated code]*/ + +static int +_curses_update_lines_cols_impl(PyModuleDef *module) +/*[clinic end generated code: output=a6ff75f33ba6eb1d input=3a87760f7d5197f0]*/ +{ + return update_lines_cols(); +} + +#endif + +/*[clinic input] +_curses.raw + + flag: int(c_default="1") = True + If false, the effect is the same as calling noraw(). + / + +Enter raw mode. + +In raw mode, normal line buffering and processing of interrupt, quit, +suspend, and flow control keys are turned off; characters are presented to +curses input functions one by one. +[clinic start generated code]*/ + static PyObject * -PyCurses_update_lines_cols(PyObject *self) +_curses_raw_impl(PyModuleDef *module, int flag) +/*[clinic end generated code: output=b7ee3420a32bc8cd input=1293f4275a594031]*/ +NoArgOrFlagNoReturnFunctionBody(raw, flag) + +/*[clinic input] +_curses.reset_prog_mode + +Restore the terminal to “program” mode, as previously saved by def_prog_mode(). +[clinic start generated code]*/ + +static PyObject * +_curses_reset_prog_mode_impl(PyModuleDef *module) +/*[clinic end generated code: output=371e5d732f65fee1 input=dc099a32dbf14d74]*/ +NoArgNoReturnFunctionBody(reset_prog_mode) + +/*[clinic input] +_curses.reset_shell_mode + +Restore the terminal to “shell” mode, as previously saved by def_shell_mode(). +[clinic start generated code]*/ + +static PyObject * +_curses_reset_shell_mode_impl(PyModuleDef *module) +/*[clinic end generated code: output=2245b7d5cf9a7d6a input=bc7d464e0ed40bb2]*/ +NoArgNoReturnFunctionBody(reset_shell_mode) + +/*[clinic input] +_curses.resetty + +Restore the state of the terminal modes to what it was at the last call to savetty(). +[clinic start generated code]*/ + +static PyObject * +_curses_resetty_impl(PyModuleDef *module) +/*[clinic end generated code: output=a80f42f8d0523a02 input=beb9acd834f56fa9]*/ +NoArgNoReturnFunctionBody(resetty) + +#ifdef HAVE_CURSES_RESIZETERM +/*[clinic input] +_curses.resizeterm + + nlines: int + Height. + ncols: int + Width. + / + +Resize the standard and current windows to the specified dimensions. + +Adjusts other bookkeeping data used by the curses library that record the +window dimensions (in particular the SIGWINCH handler). +[clinic start generated code]*/ + +static PyObject * +_curses_resizeterm_impl(PyModuleDef *module, int nlines, int ncols) +/*[clinic end generated code: output=d062a08431ee1080 input=0fca02ebad5ffa82]*/ { - return PyLong_FromLong((long) update_lines_cols()); -} - -#endif - -#ifdef HAVE_CURSES_RESIZETERM -static PyObject * -PyCurses_ResizeTerm(PyObject *self, PyObject *args) -{ - int lines; - int columns; PyObject *result; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"ii:resizeterm", &lines, &columns)) - return NULL; - - result = PyCursesCheckERR(resizeterm(lines, columns), "resizeterm"); + result = PyCursesCheckERR(resizeterm(nlines, ncols), "resizeterm"); if (!result) return NULL; if (!update_lines_cols()) @@ -2899,20 +3757,33 @@ PyCurses_ResizeTerm(PyObject *self, PyOb #endif #ifdef HAVE_CURSES_RESIZE_TERM +/*[clinic input] +_curses.resize_term + + nlines: int + Height. + ncols: int + Width. + / + +Backend function used by resizeterm(), performing most of the work. + +When resizing the windows, resize_term() blank-fills the areas that are +extended. The calling application should fill in these areas with appropriate +data. The resize_term() function attempts to resize all windows. However, +due to the calling convention of pads, it is not possible to resize these +without additional interaction with the application. +[clinic start generated code]*/ + static PyObject * -PyCurses_Resize_Term(PyObject *self, PyObject *args) +_curses_resize_term_impl(PyModuleDef *module, int nlines, int ncols) +/*[clinic end generated code: output=a3127e01e5ae6678 input=2197edd05b049ed4]*/ { - int lines; - int columns; - PyObject *result; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"ii:resize_term", &lines, &columns)) - return NULL; - - result = PyCursesCheckERR(resize_term(lines, columns), "resize_term"); + result = PyCursesCheckERR(resize_term(nlines, ncols), "resize_term"); if (!result) return NULL; if (!update_lines_cols()) @@ -2921,28 +3792,58 @@ PyCurses_Resize_Term(PyObject *self, PyO } #endif /* HAVE_CURSES_RESIZE_TERM */ +/*[clinic input] +_curses.savetty + +Save the current state of the terminal modes in a buffer, usable by resetty(). +[clinic start generated code]*/ + static PyObject * -PyCurses_setsyx(PyObject *self, PyObject *args) +_curses_savetty_impl(PyModuleDef *module) +/*[clinic end generated code: output=825cdee26c635fc3 input=e7cbe23a2de3e5a1]*/ +NoArgNoReturnFunctionBody(savetty) + +/*[clinic input] +_curses.setsyx + + y: int + Y-coordinate. + x: int + X-coordinate. + / + +Set the virtual screen cursor to y, x. + +If y and x are both -1, then leaveok is set. +[clinic start generated code]*/ + +static PyObject * +_curses_setsyx_impl(PyModuleDef *module, int y, int x) +/*[clinic end generated code: output=898017faaa5dc762 input=e8842a956b0dc9ed]*/ { - int y,x; - PyCursesInitialised; - if (PyTuple_Size(args)!=2) { - PyErr_SetString(PyExc_TypeError, "setsyx requires 2 arguments"); - return NULL; - } - - if (!PyArg_ParseTuple(args, "ii;y, x", &y, &x)) return NULL; - setsyx(y,x); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } +/*[clinic input] +_curses.start_color + +Initializes eight basic colors and global variables COLORS and COLOR_PAIRS. + +Must be called if the programmer wants to use colors, and before any other +color manipulation routine is called. It is good practice to call this +routine right after initscr(). + +It also restores the colors on the terminal to the values they had when the +terminal was just turned on. +[clinic start generated code]*/ + static PyObject * -PyCurses_Start_Color(PyObject *self) +_curses_start_color_impl(PyModuleDef *module) +/*[clinic end generated code: output=13ad82f44c7163d5 input=0ca0ecb2b77e1a12]*/ { int code; PyObject *c, *cp; @@ -2962,74 +3863,134 @@ PyCurses_Start_Color(PyObject *self) return NULL; PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp); Py_DECREF(cp); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { PyErr_SetString(PyCursesError, "start_color() returned ERR"); return NULL; } } +/*[clinic input] +_curses.termattrs + +Return a logical OR of all video attributes supported by the terminal. +[clinic start generated code]*/ + static PyObject * -PyCurses_tigetflag(PyObject *self, PyObject *args) +_curses_termattrs_impl(PyModuleDef *module) +/*[clinic end generated code: output=d2dcf58593ce6aaa input=0559882a04f84d1d]*/ +NoArgReturnIntFunctionBody(termattrs) + +/*[clinic input] +_curses.termname + +Return the value of the environment variable TERM, truncated to 14 characters. +[clinic start generated code]*/ + +static PyObject * +_curses_termname_impl(PyModuleDef *module) +/*[clinic end generated code: output=6f4fed13eb9d4a0d input=33c08d000944f33f]*/ +NoArgReturnStringFunctionBody(termname) + +/*[clinic input] +_curses.tigetflag + + capname: str + The terminfo capability name. + / + +Return the value of the Boolean capability. + +The value -1 is returned if capname is not a Boolean capability, or 0 if +it is canceled or absent from the terminal description. +[clinic start generated code]*/ + +static PyObject * +_curses_tigetflag_impl(PyModuleDef *module, const char *capname) +/*[clinic end generated code: output=2d98cc52089ff5a4 input=b0787af9e3e9a6ce]*/ { - char *capname; - PyCursesSetupTermCalled; - if (!PyArg_ParseTuple(args, "s", &capname)) - return NULL; - return PyLong_FromLong( (long) tigetflag( capname ) ); } +/*[clinic input] +_curses.tigetnum + + capname: str + The terminfo capability name. + / + +Return the value of the numeric capability. + +The value -2 is returned if capname is not a numeric capability, or -1 if +it is canceled or absent from the terminal description. +[clinic start generated code]*/ + static PyObject * -PyCurses_tigetnum(PyObject *self, PyObject *args) +_curses_tigetnum_impl(PyModuleDef *module, const char *capname) +/*[clinic end generated code: output=451aff7d9207feba input=5cdf2f410b109720]*/ { - char *capname; - PyCursesSetupTermCalled; - if (!PyArg_ParseTuple(args, "s", &capname)) - return NULL; - return PyLong_FromLong( (long) tigetnum( capname ) ); } +/*[clinic input] +_curses.tigetstr + + capname: str + The terminfo capability name. + / + +Return the value of the string capability. + +None is returned if capname is not a string capability, or is canceled or +absent from the terminal description. +[clinic start generated code]*/ + static PyObject * -PyCurses_tigetstr(PyObject *self, PyObject *args) +_curses_tigetstr_impl(PyModuleDef *module, const char *capname) +/*[clinic end generated code: output=4baea5b12eb8c355 input=36644df25c73c0a7]*/ { - char *capname; - PyCursesSetupTermCalled; - if (!PyArg_ParseTuple(args, "s", &capname)) - return NULL; - capname = tigetstr( capname ); - if (capname == 0 || capname == (char*) -1) { - Py_INCREF(Py_None); - return Py_None; - } + if (capname == 0 || capname == (char*) -1) + Py_RETURN_NONE; + return PyBytes_FromString( capname ); } +/*[clinic input] +_curses.tparm + + str: str(accept={robuffer}) + Parameterized string obtained from the terminfo database. + i1: int = 0 + i2: int = 0 + i3: int = 0 + i4: int = 0 + i5: int = 0 + i6: int = 0 + i7: int = 0 + i8: int = 0 + i9: int = 0 + / + +Instantiate the string str with the supplied parameters. +[clinic start generated code]*/ + static PyObject * -PyCurses_tparm(PyObject *self, PyObject *args) +_curses_tparm_impl(PyModuleDef *module, const char *str, int i1, int i2, + int i3, int i4, int i5, int i6, int i7, int i8, int i9) +/*[clinic end generated code: output=498370213b2872bc input=6b7bde702b071b3e]*/ { - char* fmt; char* result = NULL; - int i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0,i9=0; PyCursesSetupTermCalled; - if (!PyArg_ParseTuple(args, "y|iiiiiiiii:tparm", - &fmt, &i1, &i2, &i3, &i4, - &i5, &i6, &i7, &i8, &i9)) { - return NULL; - } - - result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); + result = tparm(str,i1,i2,i3,i4,i5,i6,i7,i8,i9); if (!result) { PyErr_SetString(PyCursesError, "tparm() returned NULL"); return NULL; @@ -3038,49 +3999,74 @@ PyCurses_tparm(PyObject *self, PyObject return PyBytes_FromString(result); } +/*[clinic input] +_curses.typeahead + + fd: int + File descriptor. + / + +Specify that the file descriptor fd be used for typeahead checking. + +If fd is -1, then no typeahead checking is done. +[clinic start generated code]*/ + static PyObject * -PyCurses_TypeAhead(PyObject *self, PyObject *args) +_curses_typeahead_impl(PyModuleDef *module, int fd) +/*[clinic end generated code: output=0f8900c6b0c34c1e input=f2968d8e1805051b]*/ { - int fd; - PyCursesInitialised; - if (!PyArg_ParseTuple(args,"i;fd",&fd)) return NULL; - return PyCursesCheckERR(typeahead( fd ), "typeahead"); } +/*[clinic input] +_curses.unctrl + + ch: object + / + +Return a string which is a printable representation of the character ch. + +Control characters are displayed as a caret followed by the character, +for example as ^C. Printing characters are left as they are. +[clinic start generated code]*/ + static PyObject * -PyCurses_UnCtrl(PyObject *self, PyObject *args) +_curses_unctrl(PyModuleDef *module, PyObject *ch) +/*[clinic end generated code: output=9ab49345cf09ef16 input=cd1e35e16cd1ace4]*/ { - PyObject *temp; - chtype ch; + chtype ch_; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL; - - if (!PyCurses_ConvertToChtype(NULL, temp, &ch)) + if (!PyCurses_ConvertToChtype(NULL, ch, &ch_)) return NULL; - return PyBytes_FromString(unctrl(ch)); + return PyBytes_FromString(unctrl(ch_)); } +/*[clinic input] +_curses.ungetch + + ch: object + / + +Push ch so the next getch() will return it. +[clinic start generated code]*/ + static PyObject * -PyCurses_UngetCh(PyObject *self, PyObject *args) +_curses_ungetch(PyModuleDef *module, PyObject *ch) +/*[clinic end generated code: output=b5cae66028173a7d input=6681e6ae4c42e5eb]*/ { - PyObject *temp; - chtype ch; + chtype ch_; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) + if (!PyCurses_ConvertToChtype(NULL, ch, &ch_)) return NULL; - if (!PyCurses_ConvertToChtype(NULL, temp, &ch)) - return NULL; - - return PyCursesCheckERR(ungetch(ch), "ungetch"); + return PyCursesCheckERR(ungetch(ch_), "ungetch"); } #ifdef HAVE_NCURSESW @@ -3131,45 +4117,68 @@ PyCurses_ConvertToWchar_t(PyObject *obj, } } +/*[clinic input] +_curses.unget_wch + + ch: object + / + +Push ch so the next get_wch() will return it. +[clinic start generated code]*/ + static PyObject * -PyCurses_Unget_Wch(PyObject *self, PyObject *args) +_curses_unget_wch(PyModuleDef *module, PyObject *ch) +/*[clinic end generated code: output=d7b7210e3987ec41 input=0d56dc65a46feebb]*/ { - PyObject *obj; wchar_t wch; PyCursesInitialised; - if (!PyArg_ParseTuple(args,"O", &obj)) - return NULL; - - if (!PyCurses_ConvertToWchar_t(obj, &wch)) + if (!PyCurses_ConvertToWchar_t(ch, &wch)) return NULL; return PyCursesCheckERR(unget_wch(wch), "unget_wch"); } #endif +/*[clinic input] +_curses.use_env + + flag: int + True(1), False(0) + / + +Use environment variables LINES and COLUMNS. + +If used, this function should be called before initscr() or newterm() are called. + +When flag is False, the values of lines and columns specified in the terminfo +database will be used, even if environment variables LINES and COLUMNS (used +by default) are set, or if curses is running in a window (in which case +default behavior would be to use the window size if LINES and COLUMNS are +not set). +[clinic start generated code]*/ + static PyObject * -PyCurses_Use_Env(PyObject *self, PyObject *args) +_curses_use_env_impl(PyModuleDef *module, int flag) +/*[clinic end generated code: output=b271271f139f1e9c input=e487c450b320901f]*/ { - int flag; - - switch(PyTuple_Size(args)) { - case 1: - if (!PyArg_ParseTuple(args,"i;True(1), False(0)",&flag)) - return NULL; - break; - default: - PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument"); - return NULL; - } use_env(flag); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #ifndef STRICT_SYSV_CURSES +/*[clinic input] +_curses.use_default_colors + +Allow use of default values for colors on terminals supporting this feature. + +Use this to support transparency in your application. The default color +is assigned to the color number -1. +[clinic start generated code]*/ + static PyObject * -PyCurses_Use_Default_Colors(PyObject *self) +_curses_use_default_colors_impl(PyModuleDef *module) +/*[clinic end generated code: output=833323b470c4dca2 input=656844367470e8fc]*/ { int code; @@ -3178,8 +4187,7 @@ PyCurses_Use_Default_Colors(PyObject *se code = use_default_colors(); if (code != ERR) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { PyErr_SetString(PyCursesError, "use_default_colors() returned ERR"); return NULL; @@ -3190,101 +4198,80 @@ PyCurses_Use_Default_Colors(PyObject *se /* List of functions defined in the module */ static PyMethodDef PyCurses_methods[] = { - {"baudrate", (PyCFunction)PyCurses_baudrate, METH_NOARGS}, - {"beep", (PyCFunction)PyCurses_beep, METH_NOARGS}, - {"can_change_color", (PyCFunction)PyCurses_can_change_color, METH_NOARGS}, - {"cbreak", (PyCFunction)PyCurses_cbreak, METH_VARARGS}, - {"color_content", (PyCFunction)PyCurses_Color_Content, METH_VARARGS}, - {"color_pair", (PyCFunction)PyCurses_color_pair, METH_VARARGS}, - {"curs_set", (PyCFunction)PyCurses_Curs_Set, METH_VARARGS}, - {"def_prog_mode", (PyCFunction)PyCurses_def_prog_mode, METH_NOARGS}, - {"def_shell_mode", (PyCFunction)PyCurses_def_shell_mode, METH_NOARGS}, - {"delay_output", (PyCFunction)PyCurses_Delay_Output, METH_VARARGS}, - {"doupdate", (PyCFunction)PyCurses_doupdate, METH_NOARGS}, - {"echo", (PyCFunction)PyCurses_echo, METH_VARARGS}, - {"endwin", (PyCFunction)PyCurses_endwin, METH_NOARGS}, - {"erasechar", (PyCFunction)PyCurses_EraseChar, METH_NOARGS}, - {"filter", (PyCFunction)PyCurses_filter, METH_NOARGS}, - {"flash", (PyCFunction)PyCurses_flash, METH_NOARGS}, - {"flushinp", (PyCFunction)PyCurses_flushinp, METH_NOARGS}, -#ifdef NCURSES_MOUSE_VERSION - {"getmouse", (PyCFunction)PyCurses_GetMouse, METH_NOARGS}, - {"ungetmouse", (PyCFunction)PyCurses_UngetMouse, METH_VARARGS}, -#endif - {"getsyx", (PyCFunction)PyCurses_getsyx, METH_NOARGS}, - {"getwin", (PyCFunction)PyCurses_GetWin, METH_O}, - {"has_colors", (PyCFunction)PyCurses_has_colors, METH_NOARGS}, - {"has_ic", (PyCFunction)PyCurses_has_ic, METH_NOARGS}, - {"has_il", (PyCFunction)PyCurses_has_il, METH_NOARGS}, -#ifndef STRICT_SYSV_CURSES - {"has_key", (PyCFunction)PyCurses_has_key, METH_VARARGS}, -#endif - {"halfdelay", (PyCFunction)PyCurses_HalfDelay, METH_VARARGS}, - {"init_color", (PyCFunction)PyCurses_Init_Color, METH_VARARGS}, - {"init_pair", (PyCFunction)PyCurses_Init_Pair, METH_VARARGS}, - {"initscr", (PyCFunction)PyCurses_InitScr, METH_NOARGS}, - {"intrflush", (PyCFunction)PyCurses_IntrFlush, METH_VARARGS}, - {"isendwin", (PyCFunction)PyCurses_isendwin, METH_NOARGS}, -#ifdef HAVE_CURSES_IS_TERM_RESIZED - {"is_term_resized", (PyCFunction)PyCurses_Is_Term_Resized, METH_VARARGS}, -#endif -#if !defined(__NetBSD__) - {"keyname", (PyCFunction)PyCurses_KeyName, METH_VARARGS}, -#endif - {"killchar", (PyCFunction)PyCurses_KillChar, METH_NOARGS}, - {"longname", (PyCFunction)PyCurses_longname, METH_NOARGS}, - {"meta", (PyCFunction)PyCurses_Meta, METH_VARARGS}, -#ifdef NCURSES_MOUSE_VERSION - {"mouseinterval", (PyCFunction)PyCurses_MouseInterval, METH_VARARGS}, - {"mousemask", (PyCFunction)PyCurses_MouseMask, METH_VARARGS}, -#endif - {"napms", (PyCFunction)PyCurses_Napms, METH_VARARGS}, - {"newpad", (PyCFunction)PyCurses_NewPad, METH_VARARGS}, - {"newwin", (PyCFunction)PyCurses_NewWindow, METH_VARARGS}, - {"nl", (PyCFunction)PyCurses_nl, METH_VARARGS}, - {"nocbreak", (PyCFunction)PyCurses_nocbreak, METH_NOARGS}, - {"noecho", (PyCFunction)PyCurses_noecho, METH_NOARGS}, - {"nonl", (PyCFunction)PyCurses_nonl, METH_NOARGS}, - {"noqiflush", (PyCFunction)PyCurses_noqiflush, METH_NOARGS}, - {"noraw", (PyCFunction)PyCurses_noraw, METH_NOARGS}, - {"pair_content", (PyCFunction)PyCurses_Pair_Content, METH_VARARGS}, - {"pair_number", (PyCFunction)PyCurses_pair_number, METH_VARARGS}, - {"putp", (PyCFunction)PyCurses_Putp, METH_VARARGS}, - {"qiflush", (PyCFunction)PyCurses_QiFlush, METH_VARARGS}, - {"raw", (PyCFunction)PyCurses_raw, METH_VARARGS}, - {"reset_prog_mode", (PyCFunction)PyCurses_reset_prog_mode, METH_NOARGS}, - {"reset_shell_mode", (PyCFunction)PyCurses_reset_shell_mode, METH_NOARGS}, - {"resetty", (PyCFunction)PyCurses_resetty, METH_NOARGS}, -#ifdef HAVE_CURSES_RESIZETERM - {"resizeterm", (PyCFunction)PyCurses_ResizeTerm, METH_VARARGS}, -#endif -#ifdef HAVE_CURSES_RESIZE_TERM - {"resize_term", (PyCFunction)PyCurses_Resize_Term, METH_VARARGS}, -#endif - {"savetty", (PyCFunction)PyCurses_savetty, METH_NOARGS}, - {"setsyx", (PyCFunction)PyCurses_setsyx, METH_VARARGS}, - {"setupterm", (PyCFunction)PyCurses_setupterm, - METH_VARARGS|METH_KEYWORDS}, - {"start_color", (PyCFunction)PyCurses_Start_Color, METH_NOARGS}, - {"termattrs", (PyCFunction)PyCurses_termattrs, METH_NOARGS}, - {"termname", (PyCFunction)PyCurses_termname, METH_NOARGS}, - {"tigetflag", (PyCFunction)PyCurses_tigetflag, METH_VARARGS}, - {"tigetnum", (PyCFunction)PyCurses_tigetnum, METH_VARARGS}, - {"tigetstr", (PyCFunction)PyCurses_tigetstr, METH_VARARGS}, - {"tparm", (PyCFunction)PyCurses_tparm, METH_VARARGS}, - {"typeahead", (PyCFunction)PyCurses_TypeAhead, METH_VARARGS}, - {"unctrl", (PyCFunction)PyCurses_UnCtrl, METH_VARARGS}, - {"ungetch", (PyCFunction)PyCurses_UngetCh, METH_VARARGS}, -#if defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM) - {"update_lines_cols", (PyCFunction)PyCurses_update_lines_cols, METH_NOARGS}, -#endif -#ifdef HAVE_NCURSESW - {"unget_wch", (PyCFunction)PyCurses_Unget_Wch, METH_VARARGS}, -#endif - {"use_env", (PyCFunction)PyCurses_Use_Env, METH_VARARGS}, -#ifndef STRICT_SYSV_CURSES - {"use_default_colors", (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS}, -#endif + _CURSES_BAUDRATE_METHODDEF + _CURSES_BEEP_METHODDEF + _CURSES_CAN_CHANGE_COLOR_METHODDEF + _CURSES_CBREAK_METHODDEF + _CURSES_COLOR_CONTENT_METHODDEF + _CURSES_COLOR_PAIR_METHODDEF + _CURSES_CURS_SET_METHODDEF + _CURSES_DEF_PROG_MODE_METHODDEF + _CURSES_DEF_SHELL_MODE_METHODDEF + _CURSES_DELAY_OUTPUT_METHODDEF + _CURSES_DOUPDATE_METHODDEF + _CURSES_ECHO_METHODDEF + _CURSES_ENDWIN_METHODDEF + _CURSES_ERASECHAR_METHODDEF + _CURSES_FILTER_METHODDEF + _CURSES_FLASH_METHODDEF + _CURSES_FLUSHINP_METHODDEF + _CURSES_GETMOUSE_METHODDEF + _CURSES_UNGETMOUSE_METHODDEF + _CURSES_GETSYX_METHODDEF + _CURSES_GETWIN_METHODDEF + _CURSES_HAS_COLORS_METHODDEF + _CURSES_HAS_IC_METHODDEF + _CURSES_HAS_IL_METHODDEF + _CURSES_HAS_KEY_METHODDEF + _CURSES_HALFDELAY_METHODDEF + _CURSES_INIT_COLOR_METHODDEF + _CURSES_INIT_PAIR_METHODDEF + _CURSES_INITSCR_METHODDEF + _CURSES_INTRFLUSH_METHODDEF + _CURSES_ISENDWIN_METHODDEF + _CURSES_IS_TERM_RESIZED_METHODDEF + _CURSES_KEYNAME_METHODDEF + _CURSES_KILLCHAR_METHODDEF + _CURSES_LONGNAME_METHODDEF + _CURSES_META_METHODDEF + _CURSES_MOUSEINTERVAL_METHODDEF + _CURSES_MOUSEMASK_METHODDEF + _CURSES_NAPMS_METHODDEF + _CURSES_NEWPAD_METHODDEF + _CURSES_NEWWIN_METHODDEF + _CURSES_NL_METHODDEF + _CURSES_NOCBREAK_METHODDEF + _CURSES_NOECHO_METHODDEF + _CURSES_NONL_METHODDEF + _CURSES_NOQIFLUSH_METHODDEF + _CURSES_NORAW_METHODDEF + _CURSES_PAIR_CONTENT_METHODDEF + _CURSES_PAIR_NUMBER_METHODDEF + _CURSES_PUTP_METHODDEF + _CURSES_QIFLUSH_METHODDEF + _CURSES_RAW_METHODDEF + _CURSES_RESET_PROG_MODE_METHODDEF + _CURSES_RESET_SHELL_MODE_METHODDEF + _CURSES_RESETTY_METHODDEF + _CURSES_RESIZETERM_METHODDEF + _CURSES_RESIZE_TERM_METHODDEF + _CURSES_SAVETTY_METHODDEF + _CURSES_SETSYX_METHODDEF + _CURSES_SETUPTERM_METHODDEF + _CURSES_START_COLOR_METHODDEF + _CURSES_TERMATTRS_METHODDEF + _CURSES_TERMNAME_METHODDEF + _CURSES_TIGETFLAG_METHODDEF + _CURSES_TIGETNUM_METHODDEF + _CURSES_TIGETSTR_METHODDEF + _CURSES_TPARM_METHODDEF + _CURSES_TYPEAHEAD_METHODDEF + _CURSES_UNCTRL_METHODDEF + _CURSES_UNGETCH_METHODDEF + _CURSES_UPDATE_LINES_COLS_METHODDEF + _CURSES_UNGET_WCH_METHODDEF + _CURSES_USE_ENV_METHODDEF + _CURSES_USE_DEFAULT_COLORS_METHODDEF {NULL, NULL} /* sentinel */ }; @@ -3465,5 +4452,13 @@ PyInit__curses(void) SetDictInt("KEY_MIN", KEY_MIN); SetDictInt("KEY_MAX", KEY_MAX); } + + Py_INCREF(&PyCursesWindow_Type); + PyModule_AddObject(m, "window", (PyObject *)&PyCursesWindow_Type); return m; } + +/*[clinic input] +dump buffer +[clinic start generated code]*/ +/*[clinic end generated code: output=da39a3ee5e6b4b0d input=524ce2e021e4eba6]*/ diff -r 395e190ead36 Modules/clinic/_curses_panel.c.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Modules/clinic/_curses_panel.c.h Tue May 05 12:30:07 2015 +0300 @@ -0,0 +1,240 @@ +/*[clinic input] +preserve +[clinic start generated code]*/ + +PyDoc_STRVAR(_curses_panel_panel_above__doc__, +"above($self, /)\n" +"--\n" +"\n" +"Returns the panel above the current panel."); + +#define _CURSES_PANEL_PANEL_ABOVE_METHODDEF \ + {"above", (PyCFunction)_curses_panel_panel_above, METH_NOARGS, _curses_panel_panel_above__doc__}, + +static PyObject * +_curses_panel_panel_above_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_above(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_above_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_below__doc__, +"below($self, /)\n" +"--\n" +"\n" +"Returns the panel below the current panel."); + +#define _CURSES_PANEL_PANEL_BELOW_METHODDEF \ + {"below", (PyCFunction)_curses_panel_panel_below, METH_NOARGS, _curses_panel_panel_below__doc__}, + +static PyObject * +_curses_panel_panel_below_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_below(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_below_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_hidden__doc__, +"hidden($self, /)\n" +"--\n" +"\n" +"Returns the panel below the current panel."); + +#define _CURSES_PANEL_PANEL_HIDDEN_METHODDEF \ + {"hidden", (PyCFunction)_curses_panel_panel_hidden, METH_NOARGS, _curses_panel_panel_hidden__doc__}, + +static PyObject * +_curses_panel_panel_hidden_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_hidden(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_hidden_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_move__doc__, +"move($self, y, x, /)\n" +"--\n" +"\n" +"Move the panel to the screen coordinates (y, x)."); + +#define _CURSES_PANEL_PANEL_MOVE_METHODDEF \ + {"move", (PyCFunction)_curses_panel_panel_move, METH_VARARGS, _curses_panel_panel_move__doc__}, + +static PyObject * +_curses_panel_panel_move_impl(PyCursesPanelObject *self, int y, int x); + +static PyObject * +_curses_panel_panel_move(PyCursesPanelObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int y; + int x; + + if (!PyArg_ParseTuple(args, "ii:move", + &y, &x)) + goto exit; + return_value = _curses_panel_panel_move_impl(self, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_window__doc__, +"window($self, /)\n" +"--\n" +"\n" +"Returns the window object associated with the panel."); + +#define _CURSES_PANEL_PANEL_WINDOW_METHODDEF \ + {"window", (PyCFunction)_curses_panel_panel_window, METH_NOARGS, _curses_panel_panel_window__doc__}, + +static PyObject * +_curses_panel_panel_window_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_window(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_window_impl(self); +} + +PyDoc_STRVAR(_curses_panel_panel_replace__doc__, +"replace($self, win, /)\n" +"--\n" +"\n" +"Change the window associated with the panel to the window win."); + +#define _CURSES_PANEL_PANEL_REPLACE_METHODDEF \ + {"replace", (PyCFunction)_curses_panel_panel_replace, METH_O, _curses_panel_panel_replace__doc__}, + +static PyObject * +_curses_panel_panel_replace_impl(PyCursesPanelObject *self, + PyCursesWindowObject *win); + +static PyObject * +_curses_panel_panel_replace(PyCursesPanelObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *win; + + if (!PyArg_Parse(arg, "O!:replace", &PyCursesWindow_Type, &win)) + goto exit; + return_value = _curses_panel_panel_replace_impl(self, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_panel_set_userptr__doc__, +"set_userptr($self, obj, /)\n" +"--\n" +"\n" +"Change the window associated with the panel to the window win."); + +#define _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF \ + {"set_userptr", (PyCFunction)_curses_panel_panel_set_userptr, METH_O, _curses_panel_panel_set_userptr__doc__}, + +PyDoc_STRVAR(_curses_panel_panel_userptr__doc__, +"userptr($self, /)\n" +"--\n" +"\n" +"Returns the user pointer for the panel."); + +#define _CURSES_PANEL_PANEL_USERPTR_METHODDEF \ + {"userptr", (PyCFunction)_curses_panel_panel_userptr, METH_NOARGS, _curses_panel_panel_userptr__doc__}, + +static PyObject * +_curses_panel_panel_userptr_impl(PyCursesPanelObject *self); + +static PyObject * +_curses_panel_panel_userptr(PyCursesPanelObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_panel_userptr_impl(self); +} + +PyDoc_STRVAR(_curses_panel_bottom_panel__doc__, +"bottom_panel($module, /)\n" +"--\n" +"\n" +"Returns the bottom panel in the panel stack."); + +#define _CURSES_PANEL_BOTTOM_PANEL_METHODDEF \ + {"bottom_panel", (PyCFunction)_curses_panel_bottom_panel, METH_NOARGS, _curses_panel_bottom_panel__doc__}, + +static PyObject * +_curses_panel_bottom_panel_impl(PyModuleDef *module); + +static PyObject * +_curses_panel_bottom_panel(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_bottom_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_new_panel__doc__, +"new_panel($module, win, /)\n" +"--\n" +"\n" +"Returns a panel object, associating it with the given window win."); + +#define _CURSES_PANEL_NEW_PANEL_METHODDEF \ + {"new_panel", (PyCFunction)_curses_panel_new_panel, METH_O, _curses_panel_new_panel__doc__}, + +static PyObject * +_curses_panel_new_panel_impl(PyModuleDef *module, PyCursesWindowObject *win); + +static PyObject * +_curses_panel_new_panel(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *win; + + if (!PyArg_Parse(arg, "O!:new_panel", &PyCursesWindow_Type, &win)) + goto exit; + return_value = _curses_panel_new_panel_impl(module, win); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_panel_top_panel__doc__, +"top_panel($module, /)\n" +"--\n" +"\n" +"Returns the top panel in the panel stack."); + +#define _CURSES_PANEL_TOP_PANEL_METHODDEF \ + {"top_panel", (PyCFunction)_curses_panel_top_panel, METH_NOARGS, _curses_panel_top_panel__doc__}, + +static PyObject * +_curses_panel_top_panel_impl(PyModuleDef *module); + +static PyObject * +_curses_panel_top_panel(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_top_panel_impl(module); +} + +PyDoc_STRVAR(_curses_panel_update_panels__doc__, +"update_panels($module, /)\n" +"--\n" +"\n" +"Updates the virtual screen after changes in the panel stack.\n" +"\n" +"This does not call curses.doupdate(), so you’ll have to do this yourself."); + +#define _CURSES_PANEL_UPDATE_PANELS_METHODDEF \ + {"update_panels", (PyCFunction)_curses_panel_update_panels, METH_NOARGS, _curses_panel_update_panels__doc__}, + +static PyObject * +_curses_panel_update_panels_impl(PyModuleDef *module); + +static PyObject * +_curses_panel_update_panels(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_panel_update_panels_impl(module); +} +/*[clinic end generated code: output=b41d23d851a5865a input=a9049054013a1b77]*/ diff -r 395e190ead36 Modules/clinic/_cursesmodule.c.h --- a/Modules/clinic/_cursesmodule.c.h Mon May 04 22:45:47 2015 -0400 +++ b/Modules/clinic/_cursesmodule.c.h Tue May 05 12:30:07 2015 +0300 @@ -2,9 +2,9 @@ preserve [clinic start generated code]*/ -PyDoc_STRVAR(curses_window_addch__doc__, -"addch([y, x,] ch, [attr])\n" -"Paint character ch at (y, x) with attributes attr.\n" +PyDoc_STRVAR(_curses_window_addch__doc__, +"addch([y, x,] ch, attr=A_NORMAL)\n" +"Paint the character.\n" "\n" " y\n" " Y-coordinate.\n" @@ -20,52 +20,3580 @@ PyDoc_STRVAR(curses_window_addch__doc__, "By default, the character position and attributes are the\n" "current settings for the window object."); -#define CURSES_WINDOW_ADDCH_METHODDEF \ - {"addch", (PyCFunction)curses_window_addch, METH_VARARGS, curses_window_addch__doc__}, +#define _CURSES_WINDOW_ADDCH_METHODDEF \ + {"addch", (PyCFunction)_curses_window_addch, METH_VARARGS, _curses_window_addch__doc__}, static PyObject * -curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, - int x, PyObject *ch, int group_right_1, long attr); +_curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, long attr); static PyObject * -curses_window_addch(PyCursesWindowObject *self, PyObject *args) +_curses_window_addch(PyCursesWindowObject *self, PyObject *args) { PyObject *return_value = NULL; int group_left_1 = 0; int y = 0; int x = 0; PyObject *ch; + long attr = A_NORMAL; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) + goto exit; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) + goto exit; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_window_addch_impl(self, group_left_1, y, x, ch, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_addstr__doc__, +"addstr([y, x,] str, [attr])\n" +"Paint the string.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to add.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Paint the string str at (y, x) with attributes attr,\n" +"overwriting anything previously on the display.\n" +"By default, the character position and attributes are the\n" +"current settings for the window object."); + +#define _CURSES_WINDOW_ADDSTR_METHODDEF \ + {"addstr", (PyCFunction)_curses_window_addstr, METH_VARARGS, _curses_window_addstr__doc__}, + +static PyObject * +_curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int group_right_1, + long attr); + +static PyObject * +_curses_window_addstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; int group_right_1 = 0; long attr = 0; switch (PyTuple_GET_SIZE(args)) { case 1: - if (!PyArg_ParseTuple(args, "O:addch", &ch)) + if (!PyArg_ParseTuple(args, "O:addstr", &str)) goto exit; break; case 2: - if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) + if (!PyArg_ParseTuple(args, "Ol:addstr", &str, &attr)) goto exit; group_right_1 = 1; break; case 3: - if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) + if (!PyArg_ParseTuple(args, "iiO:addstr", &y, &x, &str)) goto exit; group_left_1 = 1; break; case 4: - if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) + if (!PyArg_ParseTuple(args, "iiOl:addstr", &y, &x, &str, &attr)) goto exit; group_right_1 = 1; group_left_1 = 1; break; default: - PyErr_SetString(PyExc_TypeError, "curses.window.addch requires 1 to 4 arguments"); + PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments"); goto exit; } - return_value = curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr); + return_value = _curses_window_addstr_impl(self, group_left_1, y, x, str, group_right_1, attr); exit: return return_value; } -/*[clinic end generated code: output=982b1e709577f3ec input=a9049054013a1b77]*/ + +PyDoc_STRVAR(_curses_window_addnstr__doc__, +"addnstr([y, x,] str, n, [attr])\n" +"Paint at most n characters of the string.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to add.\n" +" n\n" +" Maximal number of characters.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Paint at most n characters of the string str at (y, x) with\n" +"attributes attr, overwriting anything previously on the display.\n" +"By default, the character position and attributes are the\n" +"current settings for the window object."); + +#define _CURSES_WINDOW_ADDNSTR_METHODDEF \ + {"addnstr", (PyCFunction)_curses_window_addnstr, METH_VARARGS, _curses_window_addnstr__doc__}, + +static PyObject * +_curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int n, + int group_right_1, long attr); + +static PyObject * +_curses_window_addnstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; + int n; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Oi:addnstr", &str, &n)) + goto exit; + break; + case 3: + if (!PyArg_ParseTuple(args, "Oil:addnstr", &str, &n, &attr)) + goto exit; + group_right_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOi:addnstr", &y, &x, &str, &n)) + goto exit; + group_left_1 = 1; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:addnstr", &y, &x, &str, &n, &attr)) + goto exit; + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments"); + goto exit; + } + return_value = _curses_window_addnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_bkgd__doc__, +"bkgd($self, ch, attr=A_NORMAL, /)\n" +"--\n" +"\n" +"Set the background property of the window.\n" +"\n" +" ch\n" +" Background character.\n" +" attr\n" +" Background attributes."); + +#define _CURSES_WINDOW_BKGD_METHODDEF \ + {"bkgd", (PyCFunction)_curses_window_bkgd, METH_VARARGS, _curses_window_bkgd__doc__}, + +static PyObject * +_curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, long attr); + +static PyObject * +_curses_window_bkgd(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *ch; + long attr = A_NORMAL; + + if (!PyArg_ParseTuple(args, "O|l:bkgd", + &ch, &attr)) + goto exit; + return_value = _curses_window_bkgd_impl(self, ch, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_attroff__doc__, +"attroff($self, attr, /)\n" +"--\n" +"\n" +"Remove attribute attr from the “background” set applied to all writes to the current window."); + +#define _CURSES_WINDOW_ATTROFF_METHODDEF \ + {"attroff", (PyCFunction)_curses_window_attroff, METH_O, _curses_window_attroff__doc__}, + +static PyObject * +_curses_window_attroff_impl(PyCursesWindowObject *self, long attr); + +static PyObject * +_curses_window_attroff(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + long attr; + + if (!PyArg_Parse(arg, "l:attroff", &attr)) + goto exit; + return_value = _curses_window_attroff_impl(self, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_attron__doc__, +"attron($self, attr, /)\n" +"--\n" +"\n" +"Add attribute attr from the “background” set applied to all writes to the current window."); + +#define _CURSES_WINDOW_ATTRON_METHODDEF \ + {"attron", (PyCFunction)_curses_window_attron, METH_O, _curses_window_attron__doc__}, + +static PyObject * +_curses_window_attron_impl(PyCursesWindowObject *self, long attr); + +static PyObject * +_curses_window_attron(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + long attr; + + if (!PyArg_Parse(arg, "l:attron", &attr)) + goto exit; + return_value = _curses_window_attron_impl(self, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_attrset__doc__, +"attrset($self, attr, /)\n" +"--\n" +"\n" +"Set the “background” set of attributes to attr.\n" +"\n" +"This set is initially 0 (no attributes)."); + +#define _CURSES_WINDOW_ATTRSET_METHODDEF \ + {"attrset", (PyCFunction)_curses_window_attrset, METH_O, _curses_window_attrset__doc__}, + +static PyObject * +_curses_window_attrset_impl(PyCursesWindowObject *self, long attr); + +static PyObject * +_curses_window_attrset(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + long attr; + + if (!PyArg_Parse(arg, "l:attrset", &attr)) + goto exit; + return_value = _curses_window_attrset_impl(self, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_bkgdset__doc__, +"bkgdset($self, ch, attr=A_NORMAL, /)\n" +"--\n" +"\n" +"Set the window’s background.\n" +"\n" +" ch\n" +" Background character.\n" +" attr\n" +" Background attributes."); + +#define _CURSES_WINDOW_BKGDSET_METHODDEF \ + {"bkgdset", (PyCFunction)_curses_window_bkgdset, METH_VARARGS, _curses_window_bkgdset__doc__}, + +static PyObject * +_curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch, + long attr); + +static PyObject * +_curses_window_bkgdset(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *ch; + long attr = A_NORMAL; + + if (!PyArg_ParseTuple(args, "O|l:bkgdset", + &ch, &attr)) + goto exit; + return_value = _curses_window_bkgdset_impl(self, ch, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_border__doc__, +"border($self, ls=ACS_VLINE, rs=ACS_VLINE, ts=ACS_HLINE, bs=ACS_HLINE,\n" +" tl=ACS_ULCORNER, tr=ACS_URCORNER, bl=ACS_LLCORNER,\n" +" br=ACS_LRCORNER, /)\n" +"--\n" +"\n" +"Draw a border around the edges of the window.\n" +"\n" +" ls\n" +" Left side.\n" +" rs\n" +" Right side.\n" +" ts\n" +" Top side.\n" +" bs\n" +" Bottom side.\n" +" tl\n" +" Upper-left corner.\n" +" tr\n" +" Upper-right corner.\n" +" bl\n" +" Bottom-left corner.\n" +" br\n" +" Bottom-right corner.\n" +"\n" +"Each parameter specifies the character to use for a specific part of the\n" +"border. The characters can be specified as integers or as one-character\n" +"strings. A 0 value for any parameter will cause the default character to be\n" +"used for that parameter."); + +#define _CURSES_WINDOW_BORDER_METHODDEF \ + {"border", (PyCFunction)_curses_window_border, METH_VARARGS, _curses_window_border__doc__}, + +static PyObject * +_curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls, + PyObject *rs, PyObject *ts, PyObject *bs, + PyObject *tl, PyObject *tr, PyObject *bl, + PyObject *br); + +static PyObject * +_curses_window_border(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *ls = NULL; + PyObject *rs = NULL; + PyObject *ts = NULL; + PyObject *bs = NULL; + PyObject *tl = NULL; + PyObject *tr = NULL; + PyObject *bl = NULL; + PyObject *br = NULL; + + if (!PyArg_UnpackTuple(args, "border", + 0, 8, + &ls, &rs, &ts, &bs, &tl, &tr, &bl, &br)) + goto exit; + return_value = _curses_window_border_impl(self, ls, rs, ts, bs, tl, tr, bl, br); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_box__doc__, +"box([vertch, hortch])\n" +"Draw a border around the edges of the window.\n" +"\n" +" vertch\n" +" Left and right side.\n" +" hortch\n" +" Top and bottom side.\n" +"\n" +"Similar to border(), but both ls and rs are vertch and both ts and bs are\n" +"horch. The default corner characters are always used by this function."); + +#define _CURSES_WINDOW_BOX_METHODDEF \ + {"box", (PyCFunction)_curses_window_box, METH_VARARGS, _curses_window_box__doc__}, + +static PyObject * +_curses_window_box_impl(PyCursesWindowObject *self, int group_right_1, + long vertch, long hortch); + +static PyObject * +_curses_window_box(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + long vertch = 0; + long hortch = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ll:box", &vertch, &hortch)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.box requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_box_impl(self, group_right_1, vertch, hortch); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_delch__doc__, +"delch([y, x])\n" +"Delete any character at (y, x).\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate."); + +#define _CURSES_WINDOW_DELCH_METHODDEF \ + {"delch", (PyCFunction)_curses_window_delch, METH_VARARGS, _curses_window_delch__doc__}, + +static PyObject * +_curses_window_delch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_delch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:delch", &y, &x)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.delch requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_delch_impl(self, group_right_1, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_derwin__doc__, +"derwin([nlines, ncols,] begin_y, begin_x)\n" +"Return a sub-window.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +" begin_y\n" +" Top side y-coordinate.\n" +" begin_x\n" +" Left side x-coordinate.\n" +"\n" +"derwin() is the same as calling subwin(), except that begin_y and begin_x\n" +"are relative to the origin of the window, rather than relative to the entire\n" +"screen."); + +#define _CURSES_WINDOW_DERWIN_METHODDEF \ + {"derwin", (PyCFunction)_curses_window_derwin, METH_VARARGS, _curses_window_derwin__doc__}, + +static PyObject * +_curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1, + int nlines, int ncols, int begin_y, int begin_x); + +static PyObject * +_curses_window_derwin(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int nlines = 0; + int ncols = 0; + int begin_y; + int begin_x; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:derwin", &begin_y, &begin_x)) + goto exit; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiii:derwin", &nlines, &ncols, &begin_y, &begin_x)) + goto exit; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.derwin requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_window_derwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_echochar__doc__, +"echochar($self, ch, attr=A_NORMAL, /)\n" +"--\n" +"\n" +"Add character ch with attribute attr, and immediately call refresh() on the window.\n" +"\n" +" ch\n" +" Character to add.\n" +" attr\n" +" Attributes for the character."); + +#define _CURSES_WINDOW_ECHOCHAR_METHODDEF \ + {"echochar", (PyCFunction)_curses_window_echochar, METH_VARARGS, _curses_window_echochar__doc__}, + +static PyObject * +_curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch, + long attr); + +static PyObject * +_curses_window_echochar(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyObject *ch; + long attr = A_NORMAL; + + if (!PyArg_ParseTuple(args, "O|l:echochar", + &ch, &attr)) + goto exit; + return_value = _curses_window_echochar_impl(self, ch, attr); + +exit: + return return_value; +} + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_window_enclose__doc__, +"enclose($self, y, x, /)\n" +"--\n" +"\n" +"Return True if the given pair of screen-relative character-cell coordinates are enclosed by the given window.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate."); + +#define _CURSES_WINDOW_ENCLOSE_METHODDEF \ + {"enclose", (PyCFunction)_curses_window_enclose, METH_VARARGS, _curses_window_enclose__doc__}, + +static long +_curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x); + +static PyObject * +_curses_window_enclose(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int y; + int x; + long _return_value; + + if (!PyArg_ParseTuple(args, "ii:enclose", + &y, &x)) + goto exit; + _return_value = _curses_window_enclose_impl(self, y, x); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +PyDoc_STRVAR(_curses_window_getbkgd__doc__, +"getbkgd($self, /)\n" +"--\n" +"\n" +"Return the given window’s current background character/attribute pair."); + +#define _CURSES_WINDOW_GETBKGD_METHODDEF \ + {"getbkgd", (PyCFunction)_curses_window_getbkgd, METH_NOARGS, _curses_window_getbkgd__doc__}, + +static long +_curses_window_getbkgd_impl(PyCursesWindowObject *self); + +static PyObject * +_curses_window_getbkgd(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + long _return_value; + + _return_value = _curses_window_getbkgd_impl(self); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_getch__doc__, +"getch([y, x])\n" +"Get a character code.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"The integer returned does not have to be in ASCII range: function keys,\n" +"keypad keys and so on return numbers higher than 256. In no-delay mode, -1\n" +"is returned if there is no input, else getch() waits until a key is pressed."); + +#define _CURSES_WINDOW_GETCH_METHODDEF \ + {"getch", (PyCFunction)_curses_window_getch, METH_VARARGS, _curses_window_getch__doc__}, + +static int +_curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_getch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + int _return_value; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:getch", &y, &x)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.getch requires 0 to 2 arguments"); + goto exit; + } + _return_value = _curses_window_getch_impl(self, group_right_1, y, x); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_getkey__doc__, +"getkey([y, x])\n" +"Get a character (string).\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"Returning a string instead of an integer, as getch() does. Function keys,\n" +"keypad keys and other special keys return a multibyte string containing the\n" +"key name. In no-delay mode, an exception is raised if there is no input."); + +#define _CURSES_WINDOW_GETKEY_METHODDEF \ + {"getkey", (PyCFunction)_curses_window_getkey, METH_VARARGS, _curses_window_getkey__doc__}, + +static PyObject * +_curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_getkey(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:getkey", &y, &x)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.getkey requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_getkey_impl(self, group_right_1, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_get_wch__doc__, +"get_wch([y, x])\n" +"Get a wide character.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"Return a character for most keys, or an integer for function keys,\n" +"keypad keys, and other special keys."); + +#define _CURSES_WINDOW_GET_WCH_METHODDEF \ + {"get_wch", (PyCFunction)_curses_window_get_wch, METH_VARARGS, _curses_window_get_wch__doc__}, + +static PyObject * +_curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_get_wch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:get_wch", &y, &x)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.get_wch requires 0 to 2 arguments"); + goto exit; + } + return_value = _curses_window_get_wch_impl(self, group_right_1, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_hline__doc__, +"hline([y, x,] ch, n, attr=A_NORMAL)\n" +"Display a horizontal line starting at (y, x) with length n consisting of the character ch.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" ch\n" +" Character to draw.\n" +" n\n" +" Line length.\n" +" attr\n" +" Attributes for the characters."); + +#define _CURSES_WINDOW_HLINE_METHODDEF \ + {"hline", (PyCFunction)_curses_window_hline, METH_VARARGS, _curses_window_hline__doc__}, + +static PyObject * +_curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int n, long attr); + +static PyObject * +_curses_window_hline(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *ch; + int n; + long attr = A_NORMAL; + + switch (PyTuple_GET_SIZE(args)) { + case 3: + if (!PyArg_ParseTuple(args, "Oil:hline", &ch, &n, &attr)) + goto exit; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:hline", &y, &x, &ch, &n, &attr)) + goto exit; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.hline requires 3 to 5 arguments"); + goto exit; + } + return_value = _curses_window_hline_impl(self, group_left_1, y, x, ch, n, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_insch__doc__, +"insch([y, x,] ch, attr=A_NORMAL)\n" +"Paint character ch at (y, x) with attributes attr, moving the line from position x right by one character.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" ch\n" +" Character to insert.\n" +" attr\n" +" Attributes for the character."); + +#define _CURSES_WINDOW_INSCH_METHODDEF \ + {"insch", (PyCFunction)_curses_window_insch, METH_VARARGS, _curses_window_insch__doc__}, + +static PyObject * +_curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, long attr); + +static PyObject * +_curses_window_insch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *ch; + long attr = A_NORMAL; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Ol:insch", &ch, &attr)) + goto exit; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOl:insch", &y, &x, &ch, &attr)) + goto exit; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.insch requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_window_insch_impl(self, group_left_1, y, x, ch, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_inch__doc__, +"inch([y, x])\n" +"Return the character at the given position in the window.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"The bottom 8 bits are the character proper, and upper bits are the attributes."); + +#define _CURSES_WINDOW_INCH_METHODDEF \ + {"inch", (PyCFunction)_curses_window_inch, METH_VARARGS, _curses_window_inch__doc__}, + +static unsigned long +_curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1, + int y, int x); + +static PyObject * +_curses_window_inch(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int y = 0; + int x = 0; + unsigned long _return_value; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 2: + if (!PyArg_ParseTuple(args, "ii:inch", &y, &x)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.inch requires 0 to 2 arguments"); + goto exit; + } + _return_value = _curses_window_inch_impl(self, group_right_1, y, x); + if ((_return_value == (unsigned long)-1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromUnsignedLong(_return_value); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_insstr__doc__, +"insstr([y, x,] str, [attr])\n" +"Insert the string.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to insert.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Insert a character string (as many characters as will fit on the line)\n" +"before the character under the cursor. All characters to the right of\n" +"the cursor are shifted right, with the rightmost characters on the line\n" +"being lost. The cursor position does not change (after moving to y, x,\n" +"if specified)."); + +#define _CURSES_WINDOW_INSSTR_METHODDEF \ + {"insstr", (PyCFunction)_curses_window_insstr, METH_VARARGS, _curses_window_insstr__doc__}, + +static PyObject * +_curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int group_right_1, + long attr); + +static PyObject * +_curses_window_insstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O:insstr", &str)) + goto exit; + break; + case 2: + if (!PyArg_ParseTuple(args, "Ol:insstr", &str, &attr)) + goto exit; + group_right_1 = 1; + break; + case 3: + if (!PyArg_ParseTuple(args, "iiO:insstr", &y, &x, &str)) + goto exit; + group_left_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOl:insstr", &y, &x, &str, &attr)) + goto exit; + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.insstr requires 1 to 4 arguments"); + goto exit; + } + return_value = _curses_window_insstr_impl(self, group_left_1, y, x, str, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_insnstr__doc__, +"insnstr([y, x,] str, n, [attr])\n" +"Insert at most n characters of the string.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" str\n" +" String to insert.\n" +" n\n" +" Maximal number of characters.\n" +" attr\n" +" Attributes for characters.\n" +"\n" +"Insert a character string (as many characters as will fit on the line)\n" +"before the character under the cursor, up to n characters. If n is zero\n" +"or negative, the entire string is inserted. All characters to the right\n" +"of the cursor are shifted right, with the rightmost characters on the line\n" +"being lost. The cursor position does not change (after moving to y, x, if\n" +"specified)."); + +#define _CURSES_WINDOW_INSNSTR_METHODDEF \ + {"insnstr", (PyCFunction)_curses_window_insnstr, METH_VARARGS, _curses_window_insnstr__doc__}, + +static PyObject * +_curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *str, int n, + int group_right_1, long attr); + +static PyObject * +_curses_window_insnstr(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *str; + int n; + int group_right_1 = 0; + long attr = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "Oi:insnstr", &str, &n)) + goto exit; + break; + case 3: + if (!PyArg_ParseTuple(args, "Oil:insnstr", &str, &n, &attr)) + goto exit; + group_right_1 = 1; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiOi:insnstr", &y, &x, &str, &n)) + goto exit; + group_left_1 = 1; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:insnstr", &y, &x, &str, &n, &attr)) + goto exit; + group_right_1 = 1; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.insnstr requires 2 to 5 arguments"); + goto exit; + } + return_value = _curses_window_insnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_is_linetouched__doc__, +"is_linetouched($self, line, /)\n" +"--\n" +"\n" +"Return True if the specified line was modified since the last call to refresh(); otherwise return False.\n" +"\n" +" line\n" +" Line number.\n" +"\n" +"Raise a curses.error exception if line is not valid for the given window."); + +#define _CURSES_WINDOW_IS_LINETOUCHED_METHODDEF \ + {"is_linetouched", (PyCFunction)_curses_window_is_linetouched, METH_O, _curses_window_is_linetouched__doc__}, + +static PyObject * +_curses_window_is_linetouched_impl(PyCursesWindowObject *self, int line); + +static PyObject * +_curses_window_is_linetouched(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + int line; + + if (!PyArg_Parse(arg, "i:is_linetouched", &line)) + goto exit; + return_value = _curses_window_is_linetouched_impl(self, line); + +exit: + return return_value; +} + +#if defined(WINDOW_HAS_FLAGS) + +PyDoc_STRVAR(_curses_window_noutrefresh__doc__, +"noutrefresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n" +"Mark for refresh but wait.\n" +"\n" +"This function updates the data structure representing the desired state of the\n" +"window, but does not force an update of the physical screen. To accomplish\n" +"that, call doupdate()."); + +#define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \ + {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_VARARGS, _curses_window_noutrefresh__doc__}, + +static PyObject * +_curses_window_noutrefresh_impl(PyCursesWindowObject *self, + int group_right_1, int pminrow, int pmincol, + int sminrow, int smincol, int smaxrow, + int smaxcol); + +static PyObject * +_curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int pminrow = 0; + int pmincol = 0; + int sminrow = 0; + int smincol = 0; + int smaxrow = 0; + int smaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 6: + if (!PyArg_ParseTuple(args, "iiiiii:noutrefresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.noutrefresh requires 0 to 6 arguments"); + goto exit; + } + return_value = _curses_window_noutrefresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); + +exit: + return return_value; +} + +#endif /* defined(WINDOW_HAS_FLAGS) */ + +#if !defined(WINDOW_HAS_FLAGS) + +PyDoc_STRVAR(_curses_window_noutrefresh__doc__, +"noutrefresh($self, /)\n" +"--\n" +"\n" +"Mark for refresh but wait.\n" +"\n" +"This function updates the data structure representing the desired state of the\n" +"window, but does not force an update of the physical screen. To accomplish\n" +"that, call doupdate()."); + +#define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \ + {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_NOARGS, _curses_window_noutrefresh__doc__}, + +static PyObject * +_curses_window_noutrefresh_impl(PyCursesWindowObject *self); + +static PyObject * +_curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored)) +{ + return _curses_window_noutrefresh_impl(self); +} + +#endif /* !defined(WINDOW_HAS_FLAGS) */ + +PyDoc_STRVAR(_curses_window_overlay__doc__, +"overlay(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])\n" +"Overlay the window on top of destwin.\n" +"\n" +"The windows need not be the same size, only the overlapping region is copied.\n" +"This copy is non-destructive, which means that the current background\n" +"character does not overwrite the old contents of destwin.\n" +"\n" +"To get fine-grained control over the copied region, the second form of\n" +"overlay() can be used. sminrow and smincol are the upper-left coordinates\n" +"of the source window, and the other variables mark a rectangle in the\n" +"destination window."); + +#define _CURSES_WINDOW_OVERLAY_METHODDEF \ + {"overlay", (PyCFunction)_curses_window_overlay, METH_VARARGS, _curses_window_overlay__doc__}, + +static PyObject * +_curses_window_overlay_impl(PyCursesWindowObject *self, + PyCursesWindowObject *destwin, int group_right_1, + int sminrow, int smincol, int dminrow, + int dmincol, int dmaxrow, int dmaxcol); + +static PyObject * +_curses_window_overlay(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *destwin; + int group_right_1 = 0; + int sminrow = 0; + int smincol = 0; + int dminrow = 0; + int dmincol = 0; + int dmaxrow = 0; + int dmaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!:overlay", &PyCursesWindow_Type, &destwin)) + goto exit; + break; + case 7: + if (!PyArg_ParseTuple(args, "O!iiiiii:overlay", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.overlay requires 1 to 7 arguments"); + goto exit; + } + return_value = _curses_window_overlay_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_overwrite__doc__, +"overwrite(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow,\n" +" dmaxcol])\n" +"Overwrite the window on top of destwin.\n" +"\n" +"The windows need not be the same size, in which case only the overlapping\n" +"region is copied. This copy is destructive, which means that the current\n" +"background character overwrites the old contents of destwin.\n" +"\n" +"To get fine-grained control over the copied region, the second form of\n" +"overwrite() can be used. sminrow and smincol are the upper-left coordinates\n" +"of the source window, the other variables mark a rectangle in the destination\n" +"window."); + +#define _CURSES_WINDOW_OVERWRITE_METHODDEF \ + {"overwrite", (PyCFunction)_curses_window_overwrite, METH_VARARGS, _curses_window_overwrite__doc__}, + +static PyObject * +_curses_window_overwrite_impl(PyCursesWindowObject *self, + PyCursesWindowObject *destwin, + int group_right_1, int sminrow, int smincol, + int dminrow, int dmincol, int dmaxrow, + int dmaxcol); + +static PyObject * +_curses_window_overwrite(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + PyCursesWindowObject *destwin; + int group_right_1 = 0; + int sminrow = 0; + int smincol = 0; + int dminrow = 0; + int dmincol = 0; + int dmaxrow = 0; + int dmaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 1: + if (!PyArg_ParseTuple(args, "O!:overwrite", &PyCursesWindow_Type, &destwin)) + goto exit; + break; + case 7: + if (!PyArg_ParseTuple(args, "O!iiiiii:overwrite", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.overwrite requires 1 to 7 arguments"); + goto exit; + } + return_value = _curses_window_overwrite_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_putwin__doc__, +"putwin($self, file, /)\n" +"--\n" +"\n" +"Write all data associated with the window into the provided file object.\n" +"\n" +"This information can be later retrieved using the getwin() function."); + +#define _CURSES_WINDOW_PUTWIN_METHODDEF \ + {"putwin", (PyCFunction)_curses_window_putwin, METH_O, _curses_window_putwin__doc__}, + +PyDoc_STRVAR(_curses_window_redrawln__doc__, +"redrawln($self, beg, num, /)\n" +"--\n" +"\n" +"Indicate that the num screen lines, starting at line beg, are corrupted and should be completely redrawn on the next refresh() call."); + +#define _CURSES_WINDOW_REDRAWLN_METHODDEF \ + {"redrawln", (PyCFunction)_curses_window_redrawln, METH_VARARGS, _curses_window_redrawln__doc__}, + +static PyObject * +_curses_window_redrawln_impl(PyCursesWindowObject *self, int beg, int num); + +static PyObject * +_curses_window_redrawln(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int beg; + int num; + + if (!PyArg_ParseTuple(args, "ii:redrawln", + &beg, &num)) + goto exit; + return_value = _curses_window_redrawln_impl(self, beg, num); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_refresh__doc__, +"refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n" +"Update the display immediately (sync actual screen with previous drawing/deleting methods).\n" +"\n" +"The 6 optional arguments can only be specified when the window is a pad\n" +"created with newpad(). The additional parameters are needed to indicate\n" +"what part of the pad and screen are involved. pminrow and pmincol specify\n" +"the upper left-hand corner of the rectangle to be displayed in the pad.\n" +"sminrow, smincol, smaxrow, and smaxcol specify the edges of the rectangle to\n" +"be displayed on the screen. The lower right-hand corner of the rectangle to\n" +"be displayed in the pad is calculated from the screen coordinates, since the\n" +"rectangles must be the same size. Both rectangles must be entirely contained\n" +"within their respective structures. Negative values of pminrow, pmincol,\n" +"sminrow, or smincol are treated as if they were zero."); + +#define _CURSES_WINDOW_REFRESH_METHODDEF \ + {"refresh", (PyCFunction)_curses_window_refresh, METH_VARARGS, _curses_window_refresh__doc__}, + +static PyObject * +_curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1, + int pminrow, int pmincol, int sminrow, + int smincol, int smaxrow, int smaxcol); + +static PyObject * +_curses_window_refresh(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int pminrow = 0; + int pmincol = 0; + int sminrow = 0; + int smincol = 0; + int smaxrow = 0; + int smaxcol = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 0: + break; + case 6: + if (!PyArg_ParseTuple(args, "iiiiii:refresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.refresh requires 0 to 6 arguments"); + goto exit; + } + return_value = _curses_window_refresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_setscrreg__doc__, +"setscrreg($self, top, bottom, /)\n" +"--\n" +"\n" +"Set the scrolling region from line top to line bottom.\n" +"\n" +"All scrolling actions will take place in this region."); + +#define _CURSES_WINDOW_SETSCRREG_METHODDEF \ + {"setscrreg", (PyCFunction)_curses_window_setscrreg, METH_VARARGS, _curses_window_setscrreg__doc__}, + +static PyObject * +_curses_window_setscrreg_impl(PyCursesWindowObject *self, int top, + int bottom); + +static PyObject * +_curses_window_setscrreg(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int top; + int bottom; + + if (!PyArg_ParseTuple(args, "ii:setscrreg", + &top, &bottom)) + goto exit; + return_value = _curses_window_setscrreg_impl(self, top, bottom); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_subwin__doc__, +"subwin([nlines, ncols,] begin_y, begin_x)\n" +"Return a sub-window.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +" begin_y\n" +" Top side y-coordinate.\n" +" begin_x\n" +" Left side x-coordinate.\n" +"\n" +"By default, the sub-window will extend from the specified position to the\n" +"lower right corner of the window."); + +#define _CURSES_WINDOW_SUBWIN_METHODDEF \ + {"subwin", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__}, + +static PyObject * +_curses_window_subwin_impl(PyCursesWindowObject *self, int group_left_1, + int nlines, int ncols, int begin_y, int begin_x); + +static PyObject * +_curses_window_subwin(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int nlines = 0; + int ncols = 0; + int begin_y; + int begin_x; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:subwin", &begin_y, &begin_x)) + goto exit; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiii:subwin", &nlines, &ncols, &begin_y, &begin_x)) + goto exit; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.subwin requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_window_subwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_scroll__doc__, +"scroll([lines])\n" +"Scroll the screen or scrolling region upward by lines lines."); + +#define _CURSES_WINDOW_SCROLL_METHODDEF \ + {"scroll", (PyCFunction)_curses_window_scroll, METH_O, _curses_window_scroll__doc__}, + +static PyObject * +_curses_window_scroll_impl(PyCursesWindowObject *self, int group_right_1, + int lines); + +static PyObject * +_curses_window_scroll(PyCursesWindowObject *self, PyObject *arg) +{ + PyObject *return_value = NULL; + int group_right_1 = 0; + int lines = 0; + + if (!PyArg_Parse(arg, "i:scroll", &lines)) + goto exit; + return_value = _curses_window_scroll_impl(self, group_right_1, lines); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_touchline__doc__, +"touchline(start, count, [changed])\n" +"Pretend count lines have been changed, starting with line start.\n" +"\n" +"If changed is supplied, it specifies whether the affected lines are marked\n" +"as having been changed (changed=1) or unchanged (changed=0)."); + +#define _CURSES_WINDOW_TOUCHLINE_METHODDEF \ + {"touchline", (PyCFunction)_curses_window_touchline, METH_VARARGS, _curses_window_touchline__doc__}, + +static PyObject * +_curses_window_touchline_impl(PyCursesWindowObject *self, int start, + int count, int group_right_1, int changed); + +static PyObject * +_curses_window_touchline(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int start; + int count; + int group_right_1 = 0; + int changed = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:touchline", &start, &count)) + goto exit; + break; + case 3: + if (!PyArg_ParseTuple(args, "iii:touchline", &start, &count, &changed)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.touchline requires 2 to 3 arguments"); + goto exit; + } + return_value = _curses_window_touchline_impl(self, start, count, group_right_1, changed); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_window_vline__doc__, +"vline([y, x,] ch, n, attr=A_NORMAL)\n" +"Display a vertical line starting at (y, x) with length n consisting of the character ch.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +" ch\n" +" Character to draw.\n" +" n\n" +" Line length.\n" +" attr\n" +" Attributes for the character."); + +#define _CURSES_WINDOW_VLINE_METHODDEF \ + {"vline", (PyCFunction)_curses_window_vline, METH_VARARGS, _curses_window_vline__doc__}, + +static PyObject * +_curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1, + int y, int x, PyObject *ch, int n, long attr); + +static PyObject * +_curses_window_vline(PyCursesWindowObject *self, PyObject *args) +{ + PyObject *return_value = NULL; + int group_left_1 = 0; + int y = 0; + int x = 0; + PyObject *ch; + int n; + long attr = A_NORMAL; + + switch (PyTuple_GET_SIZE(args)) { + case 3: + if (!PyArg_ParseTuple(args, "Oil:vline", &ch, &n, &attr)) + goto exit; + break; + case 5: + if (!PyArg_ParseTuple(args, "iiOil:vline", &y, &x, &ch, &n, &attr)) + goto exit; + group_left_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 3 to 5 arguments"); + goto exit; + } + return_value = _curses_window_vline_impl(self, group_left_1, y, x, ch, n, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_filter__doc__, +"filter($module, /)\n" +"--\n" +"\n"); + +#define _CURSES_FILTER_METHODDEF \ + {"filter", (PyCFunction)_curses_filter, METH_NOARGS, _curses_filter__doc__}, + +static PyObject * +_curses_filter_impl(PyModuleDef *module); + +static PyObject * +_curses_filter(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_filter_impl(module); +} + +PyDoc_STRVAR(_curses_baudrate__doc__, +"baudrate($module, /)\n" +"--\n" +"\n" +"Return the output speed of the terminal in bits per second."); + +#define _CURSES_BAUDRATE_METHODDEF \ + {"baudrate", (PyCFunction)_curses_baudrate, METH_NOARGS, _curses_baudrate__doc__}, + +static PyObject * +_curses_baudrate_impl(PyModuleDef *module); + +static PyObject * +_curses_baudrate(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_baudrate_impl(module); +} + +PyDoc_STRVAR(_curses_beep__doc__, +"beep($module, /)\n" +"--\n" +"\n" +"Emit a short attention sound."); + +#define _CURSES_BEEP_METHODDEF \ + {"beep", (PyCFunction)_curses_beep, METH_NOARGS, _curses_beep__doc__}, + +static PyObject * +_curses_beep_impl(PyModuleDef *module); + +static PyObject * +_curses_beep(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_beep_impl(module); +} + +PyDoc_STRVAR(_curses_can_change_color__doc__, +"can_change_color($module, /)\n" +"--\n" +"\n" +"Return True if the programmer can change the colors displayed by the terminal."); + +#define _CURSES_CAN_CHANGE_COLOR_METHODDEF \ + {"can_change_color", (PyCFunction)_curses_can_change_color, METH_NOARGS, _curses_can_change_color__doc__}, + +static PyObject * +_curses_can_change_color_impl(PyModuleDef *module); + +static PyObject * +_curses_can_change_color(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_can_change_color_impl(module); +} + +PyDoc_STRVAR(_curses_cbreak__doc__, +"cbreak($module, flag=True, /)\n" +"--\n" +"\n" +"Enter cbreak mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling nocbreak().\n" +"\n" +"In cbreak mode (sometimes called “rare” mode) normal tty line buffering is\n" +"turned off and characters are available to be read one by one. However,\n" +"unlike raw mode, special characters (interrupt, quit, suspend, and flow\n" +"control) retain their effects on the tty driver and calling program.\n" +"Calling first raw() then cbreak() leaves the terminal in cbreak mode."); + +#define _CURSES_CBREAK_METHODDEF \ + {"cbreak", (PyCFunction)_curses_cbreak, METH_VARARGS, _curses_cbreak__doc__}, + +static PyObject * +_curses_cbreak_impl(PyModuleDef *module, int flag); + +static PyObject * +_curses_cbreak(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!PyArg_ParseTuple(args, "|i:cbreak", + &flag)) + goto exit; + return_value = _curses_cbreak_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_color_content__doc__, +"color_content($module, color_number, /)\n" +"--\n" +"\n" +"Return the intensity of the red, green, and blue (RGB) components in the color color_number.\n" +"\n" +" color_number\n" +" The number of the color (0 - COLORS).\n" +"\n" +"A 3-tuple is returned, containing the R,G,B values for the given color,\n" +"which will be between 0 (no component) and 1000 (maximum amount of component)."); + +#define _CURSES_COLOR_CONTENT_METHODDEF \ + {"color_content", (PyCFunction)_curses_color_content, METH_O, _curses_color_content__doc__}, + +static PyObject * +_curses_color_content_impl(PyModuleDef *module, short color_number); + +static PyObject * +_curses_color_content(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + short color_number; + + if (!PyArg_Parse(arg, "h:color_content", &color_number)) + goto exit; + return_value = _curses_color_content_impl(module, color_number); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_color_pair__doc__, +"color_pair($module, color_number, /)\n" +"--\n" +"\n" +"Return the attribute value for displaying text in the specified color.\n" +"\n" +" color_number\n" +" The number of the color (0 - COLORS).\n" +"\n" +"This attribute value can be combined with A_STANDOUT, A_REVERSE, and the\n" +"other A_* attributes. pair_number() is the counterpart to this function."); + +#define _CURSES_COLOR_PAIR_METHODDEF \ + {"color_pair", (PyCFunction)_curses_color_pair, METH_O, _curses_color_pair__doc__}, + +static PyObject * +_curses_color_pair_impl(PyModuleDef *module, short color_number); + +static PyObject * +_curses_color_pair(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + short color_number; + + if (!PyArg_Parse(arg, "h:color_pair", &color_number)) + goto exit; + return_value = _curses_color_pair_impl(module, color_number); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_curs_set__doc__, +"curs_set($module, visibility, /)\n" +"--\n" +"\n" +"Set the cursor state.\n" +"\n" +" visibility\n" +" 0 for invisible, 1 for normal visible, or 2 for very visible.\n" +"\n" +"If the terminal supports the visibility requested, the previous cursor\n" +"state is returned; otherwise, an exception is raised. On many terminals,\n" +"the “visible” mode is an underline cursor and the “very visible” mode is\n" +"a block cursor."); + +#define _CURSES_CURS_SET_METHODDEF \ + {"curs_set", (PyCFunction)_curses_curs_set, METH_O, _curses_curs_set__doc__}, + +static PyObject * +_curses_curs_set_impl(PyModuleDef *module, int visibility); + +static PyObject * +_curses_curs_set(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int visibility; + + if (!PyArg_Parse(arg, "i:curs_set", &visibility)) + goto exit; + return_value = _curses_curs_set_impl(module, visibility); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_def_prog_mode__doc__, +"def_prog_mode($module, /)\n" +"--\n" +"\n" +"Save the current terminal mode as the “program” mode.\n" +"\n" +"The “program” mode is the mode when the running program is using curses.\n" +"\n" +"Subsequent calls to reset_prog_mode() will restore this mode."); + +#define _CURSES_DEF_PROG_MODE_METHODDEF \ + {"def_prog_mode", (PyCFunction)_curses_def_prog_mode, METH_NOARGS, _curses_def_prog_mode__doc__}, + +static PyObject * +_curses_def_prog_mode_impl(PyModuleDef *module); + +static PyObject * +_curses_def_prog_mode(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_def_prog_mode_impl(module); +} + +PyDoc_STRVAR(_curses_def_shell_mode__doc__, +"def_shell_mode($module, /)\n" +"--\n" +"\n" +"Save the current terminal mode as the “shell” mode.\n" +"\n" +"The “shell” mode is the mode when the running program is not using curses.\n" +"\n" +"Subsequent calls to reset_shell_mode() will restore this mode."); + +#define _CURSES_DEF_SHELL_MODE_METHODDEF \ + {"def_shell_mode", (PyCFunction)_curses_def_shell_mode, METH_NOARGS, _curses_def_shell_mode__doc__}, + +static PyObject * +_curses_def_shell_mode_impl(PyModuleDef *module); + +static PyObject * +_curses_def_shell_mode(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_def_shell_mode_impl(module); +} + +PyDoc_STRVAR(_curses_delay_output__doc__, +"delay_output($module, ms, /)\n" +"--\n" +"\n" +"Insert an ms millisecond pause in output."); + +#define _CURSES_DELAY_OUTPUT_METHODDEF \ + {"delay_output", (PyCFunction)_curses_delay_output, METH_O, _curses_delay_output__doc__}, + +static PyObject * +_curses_delay_output_impl(PyModuleDef *module, int ms); + +static PyObject * +_curses_delay_output(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int ms; + + if (!PyArg_Parse(arg, "i:delay_output", &ms)) + goto exit; + return_value = _curses_delay_output_impl(module, ms); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_doupdate__doc__, +"doupdate($module, /)\n" +"--\n" +"\n" +"Update the physical screen to match the virtual screen."); + +#define _CURSES_DOUPDATE_METHODDEF \ + {"doupdate", (PyCFunction)_curses_doupdate, METH_NOARGS, _curses_doupdate__doc__}, + +static PyObject * +_curses_doupdate_impl(PyModuleDef *module); + +static PyObject * +_curses_doupdate(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_doupdate_impl(module); +} + +PyDoc_STRVAR(_curses_echo__doc__, +"echo($module, flag=True, /)\n" +"--\n" +"\n" +"Enter echo mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling noecho().\n" +"\n" +"In echo mode, each character input is echoed to the screen as it is entered."); + +#define _CURSES_ECHO_METHODDEF \ + {"echo", (PyCFunction)_curses_echo, METH_VARARGS, _curses_echo__doc__}, + +static PyObject * +_curses_echo_impl(PyModuleDef *module, int flag); + +static PyObject * +_curses_echo(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!PyArg_ParseTuple(args, "|i:echo", + &flag)) + goto exit; + return_value = _curses_echo_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_endwin__doc__, +"endwin($module, /)\n" +"--\n" +"\n" +"De-initialize the library, and return terminal to normal status."); + +#define _CURSES_ENDWIN_METHODDEF \ + {"endwin", (PyCFunction)_curses_endwin, METH_NOARGS, _curses_endwin__doc__}, + +static PyObject * +_curses_endwin_impl(PyModuleDef *module); + +static PyObject * +_curses_endwin(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_endwin_impl(module); +} + +PyDoc_STRVAR(_curses_erasechar__doc__, +"erasechar($module, /)\n" +"--\n" +"\n" +"Return the user’s current erase character."); + +#define _CURSES_ERASECHAR_METHODDEF \ + {"erasechar", (PyCFunction)_curses_erasechar, METH_NOARGS, _curses_erasechar__doc__}, + +static PyObject * +_curses_erasechar_impl(PyModuleDef *module); + +static PyObject * +_curses_erasechar(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_erasechar_impl(module); +} + +PyDoc_STRVAR(_curses_flash__doc__, +"flash($module, /)\n" +"--\n" +"\n" +"Flash the screen.\n" +"\n" +"That is, change it to reverse-video and then change it back in a short interval."); + +#define _CURSES_FLASH_METHODDEF \ + {"flash", (PyCFunction)_curses_flash, METH_NOARGS, _curses_flash__doc__}, + +static PyObject * +_curses_flash_impl(PyModuleDef *module); + +static PyObject * +_curses_flash(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_flash_impl(module); +} + +PyDoc_STRVAR(_curses_flushinp__doc__, +"flushinp($module, /)\n" +"--\n" +"\n" +"Flush all input buffers.\n" +"\n" +"This throws away any typeahead that has been typed by the user and has not\n" +"yet been processed by the program."); + +#define _CURSES_FLUSHINP_METHODDEF \ + {"flushinp", (PyCFunction)_curses_flushinp, METH_NOARGS, _curses_flushinp__doc__}, + +static PyObject * +_curses_flushinp_impl(PyModuleDef *module); + +static PyObject * +_curses_flushinp(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_flushinp_impl(module); +} + +PyDoc_STRVAR(_curses_getsyx__doc__, +"getsyx($module, /)\n" +"--\n" +"\n" +"Return the current coordinates of the virtual screen cursor in y and x.\n" +"\n" +"If leaveok is currently true, then -1,-1 is returned."); + +#define _CURSES_GETSYX_METHODDEF \ + {"getsyx", (PyCFunction)_curses_getsyx, METH_NOARGS, _curses_getsyx__doc__}, + +static PyObject * +_curses_getsyx_impl(PyModuleDef *module); + +static PyObject * +_curses_getsyx(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_getsyx_impl(module); +} + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_getmouse__doc__, +"getmouse($module, /)\n" +"--\n" +"\n" +"Retrieve the queued mouse event.\n" +"\n" +"After getch() returns KEY_MOUSE to signal a mouse event, this function\n" +"returns a 5-tuple (id, x, y, z, bstate)."); + +#define _CURSES_GETMOUSE_METHODDEF \ + {"getmouse", (PyCFunction)_curses_getmouse, METH_NOARGS, _curses_getmouse__doc__}, + +static PyObject * +_curses_getmouse_impl(PyModuleDef *module); + +static PyObject * +_curses_getmouse(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_getmouse_impl(module); +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_ungetmouse__doc__, +"ungetmouse($module, id, x, y, z, bstate, /)\n" +"--\n" +"\n" +"Push a KEY_MOUSE event onto the input queue, associating the given state data with it."); + +#define _CURSES_UNGETMOUSE_METHODDEF \ + {"ungetmouse", (PyCFunction)_curses_ungetmouse, METH_VARARGS, _curses_ungetmouse__doc__}, + +static PyObject * +_curses_ungetmouse_impl(PyModuleDef *module, short id, int x, int y, int z, + long bstate); + +static PyObject * +_curses_ungetmouse(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + short id; + int x; + int y; + int z; + long bstate; + + if (!PyArg_ParseTuple(args, "hiiil:ungetmouse", + &id, &x, &y, &z, &bstate)) + goto exit; + return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +PyDoc_STRVAR(_curses_getwin__doc__, +"getwin($module, file, /)\n" +"--\n" +"\n" +"Read window related data stored in the file by an earlier putwin() call.\n" +"\n" +"The routine then creates and initializes a new window using that data,\n" +"returning the new window object."); + +#define _CURSES_GETWIN_METHODDEF \ + {"getwin", (PyCFunction)_curses_getwin, METH_O, _curses_getwin__doc__}, + +PyDoc_STRVAR(_curses_halfdelay__doc__, +"halfdelay($module, tenths, /)\n" +"--\n" +"\n" +"Enter half-delay mode.\n" +"\n" +" tenths\n" +" Maximal blocking delay in tenths of seconds (1 - 255).\n" +"\n" +"Use nocbreak() to leave half-delay mode."); + +#define _CURSES_HALFDELAY_METHODDEF \ + {"halfdelay", (PyCFunction)_curses_halfdelay, METH_O, _curses_halfdelay__doc__}, + +static PyObject * +_curses_halfdelay_impl(PyModuleDef *module, unsigned char tenths); + +static PyObject * +_curses_halfdelay(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + unsigned char tenths; + + if (!PyArg_Parse(arg, "b:halfdelay", &tenths)) + goto exit; + return_value = _curses_halfdelay_impl(module, tenths); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_has_colors__doc__, +"has_colors($module, /)\n" +"--\n" +"\n" +"Return True if the terminal can display colors; otherwise, return False."); + +#define _CURSES_HAS_COLORS_METHODDEF \ + {"has_colors", (PyCFunction)_curses_has_colors, METH_NOARGS, _curses_has_colors__doc__}, + +static PyObject * +_curses_has_colors_impl(PyModuleDef *module); + +static PyObject * +_curses_has_colors(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_has_colors_impl(module); +} + +PyDoc_STRVAR(_curses_has_ic__doc__, +"has_ic($module, /)\n" +"--\n" +"\n" +"Return True if the terminal has insert- and delete-character capabilities."); + +#define _CURSES_HAS_IC_METHODDEF \ + {"has_ic", (PyCFunction)_curses_has_ic, METH_NOARGS, _curses_has_ic__doc__}, + +static PyObject * +_curses_has_ic_impl(PyModuleDef *module); + +static PyObject * +_curses_has_ic(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_has_ic_impl(module); +} + +PyDoc_STRVAR(_curses_has_il__doc__, +"has_il($module, /)\n" +"--\n" +"\n" +"Return True if the terminal has insert- and delete-line capabilities."); + +#define _CURSES_HAS_IL_METHODDEF \ + {"has_il", (PyCFunction)_curses_has_il, METH_NOARGS, _curses_has_il__doc__}, + +static PyObject * +_curses_has_il_impl(PyModuleDef *module); + +static PyObject * +_curses_has_il(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_has_il_impl(module); +} + +#if !defined(STRICT_SYSV_CURSES) + +PyDoc_STRVAR(_curses_has_key__doc__, +"has_key($module, key, /)\n" +"--\n" +"\n" +"Return True if the current terminal type recognizes a key with that value.\n" +"\n" +" key\n" +" Key number."); + +#define _CURSES_HAS_KEY_METHODDEF \ + {"has_key", (PyCFunction)_curses_has_key, METH_O, _curses_has_key__doc__}, + +static PyObject * +_curses_has_key_impl(PyModuleDef *module, int key); + +static PyObject * +_curses_has_key(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int key; + + if (!PyArg_Parse(arg, "i:has_key", &key)) + goto exit; + return_value = _curses_has_key_impl(module, key); + +exit: + return return_value; +} + +#endif /* !defined(STRICT_SYSV_CURSES) */ + +PyDoc_STRVAR(_curses_init_color__doc__, +"init_color($module, color_number, r, g, b, /)\n" +"--\n" +"\n" +"Change the definition of a color.\n" +"\n" +" color_number\n" +" The number of the color to be changed (0 - COLORS).\n" +" r\n" +" Red component (0 - 1000).\n" +" g\n" +" Green component (0 - 1000).\n" +" b\n" +" Blue component (0 - 1000).\n" +"\n" +"When init_color() is used, all occurrences of that color on the screen\n" +"immediately change to the new definition. This function is a no-op on\n" +"most terminals; it is active only if can_change_color() returns 1."); + +#define _CURSES_INIT_COLOR_METHODDEF \ + {"init_color", (PyCFunction)_curses_init_color, METH_VARARGS, _curses_init_color__doc__}, + +static PyObject * +_curses_init_color_impl(PyModuleDef *module, short color_number, short r, + short g, short b); + +static PyObject * +_curses_init_color(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + short color_number; + short r; + short g; + short b; + + if (!PyArg_ParseTuple(args, "hhhh:init_color", + &color_number, &r, &g, &b)) + goto exit; + return_value = _curses_init_color_impl(module, color_number, r, g, b); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_init_pair__doc__, +"init_pair($module, pair_number, fg, bg, /)\n" +"--\n" +"\n" +"Change the definition of a color-pair.\n" +"\n" +" pair_number\n" +" The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)).\n" +" fg\n" +" Foreground color number (0 - COLORS).\n" +" bg\n" +" Background color number (0 - COLORS).\n" +"\n" +"If the color-pair was previously initialized, the screen is refreshed and\n" +"all occurrences of that color-pair are changed to the new definition."); + +#define _CURSES_INIT_PAIR_METHODDEF \ + {"init_pair", (PyCFunction)_curses_init_pair, METH_VARARGS, _curses_init_pair__doc__}, + +static PyObject * +_curses_init_pair_impl(PyModuleDef *module, short pair_number, short fg, + short bg); + +static PyObject * +_curses_init_pair(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + short pair_number; + short fg; + short bg; + + if (!PyArg_ParseTuple(args, "hhh:init_pair", + &pair_number, &fg, &bg)) + goto exit; + return_value = _curses_init_pair_impl(module, pair_number, fg, bg); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_initscr__doc__, +"initscr($module, /)\n" +"--\n" +"\n" +"Initialize the library.\n" +"\n" +"Return a WindowObject which represents the whole screen."); + +#define _CURSES_INITSCR_METHODDEF \ + {"initscr", (PyCFunction)_curses_initscr, METH_NOARGS, _curses_initscr__doc__}, + +static PyObject * +_curses_initscr_impl(PyModuleDef *module); + +static PyObject * +_curses_initscr(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_initscr_impl(module); +} + +PyDoc_STRVAR(_curses_setupterm__doc__, +"setupterm($module, /, term=None, fd=-1)\n" +"--\n" +"\n" +"Initialize the terminal.\n" +"\n" +" term\n" +" Terminal name.\n" +" If omitted, the value of the TERM environment variable will be used.\n" +" fd\n" +" File descriptor to which any initialization sequences will be sent.\n" +" If not supplied, the file descriptor for sys.stdout will be used."); + +#define _CURSES_SETUPTERM_METHODDEF \ + {"setupterm", (PyCFunction)_curses_setupterm, METH_VARARGS|METH_KEYWORDS, _curses_setupterm__doc__}, + +static PyObject * +_curses_setupterm_impl(PyModuleDef *module, const char *term, int fd); + +static PyObject * +_curses_setupterm(PyModuleDef *module, PyObject *args, PyObject *kwargs) +{ + PyObject *return_value = NULL; + static char *_keywords[] = {"term", "fd", NULL}; + const char *term = NULL; + int fd = -1; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zi:setupterm", _keywords, + &term, &fd)) + goto exit; + return_value = _curses_setupterm_impl(module, term, fd); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_intrflush__doc__, +"intrflush($module, flag, /)\n" +"--\n" +"\n" +"\n" +"\n" +" flag\n" +" True(1), False(0)"); + +#define _CURSES_INTRFLUSH_METHODDEF \ + {"intrflush", (PyCFunction)_curses_intrflush, METH_O, _curses_intrflush__doc__}, + +static PyObject * +_curses_intrflush_impl(PyModuleDef *module, int flag); + +static PyObject * +_curses_intrflush(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int flag; + + if (!PyArg_Parse(arg, "i:intrflush", &flag)) + goto exit; + return_value = _curses_intrflush_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_isendwin__doc__, +"isendwin($module, /)\n" +"--\n" +"\n" +"Return True if endwin() has been called (that is, the curses library has been deinitialized)."); + +#define _CURSES_ISENDWIN_METHODDEF \ + {"isendwin", (PyCFunction)_curses_isendwin, METH_NOARGS, _curses_isendwin__doc__}, + +static PyObject * +_curses_isendwin_impl(PyModuleDef *module); + +static PyObject * +_curses_isendwin(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_isendwin_impl(module); +} + +#if defined(HAVE_CURSES_IS_TERM_RESIZED) + +PyDoc_STRVAR(_curses_is_term_resized__doc__, +"is_term_resized($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Return True if resize_term() would modify the window structure, False otherwise.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width."); + +#define _CURSES_IS_TERM_RESIZED_METHODDEF \ + {"is_term_resized", (PyCFunction)_curses_is_term_resized, METH_VARARGS, _curses_is_term_resized__doc__}, + +static PyObject * +_curses_is_term_resized_impl(PyModuleDef *module, int nlines, int ncols); + +static PyObject * +_curses_is_term_resized(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!PyArg_ParseTuple(args, "ii:is_term_resized", + &nlines, &ncols)) + goto exit; + return_value = _curses_is_term_resized_impl(module, nlines, ncols); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_IS_TERM_RESIZED) */ + +#if (!defined(__NetBSD__)) + +PyDoc_STRVAR(_curses_keyname__doc__, +"keyname($module, key, /)\n" +"--\n" +"\n" +"Return the name of specified key.\n" +"\n" +" key\n" +" Key number."); + +#define _CURSES_KEYNAME_METHODDEF \ + {"keyname", (PyCFunction)_curses_keyname, METH_O, _curses_keyname__doc__}, + +static PyObject * +_curses_keyname_impl(PyModuleDef *module, int key); + +static PyObject * +_curses_keyname(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int key; + + if (!PyArg_Parse(arg, "i:keyname", &key)) + goto exit; + return_value = _curses_keyname_impl(module, key); + +exit: + return return_value; +} + +#endif /* (!defined(__NetBSD__)) */ + +PyDoc_STRVAR(_curses_killchar__doc__, +"killchar($module, /)\n" +"--\n" +"\n" +"Return the user’s current line kill character."); + +#define _CURSES_KILLCHAR_METHODDEF \ + {"killchar", (PyCFunction)_curses_killchar, METH_NOARGS, _curses_killchar__doc__}, + +static PyObject * +_curses_killchar_impl(PyModuleDef *module); + +static PyObject * +_curses_killchar(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_killchar_impl(module); +} + +PyDoc_STRVAR(_curses_longname__doc__, +"longname($module, /)\n" +"--\n" +"\n" +"Return a string containing the terminfo long name field describing the current terminal.\n" +"\n" +"The maximum length of a verbose description is 128 characters. It is defined\n" +"only after the call to initscr()."); + +#define _CURSES_LONGNAME_METHODDEF \ + {"longname", (PyCFunction)_curses_longname, METH_NOARGS, _curses_longname__doc__}, + +static PyObject * +_curses_longname_impl(PyModuleDef *module); + +static PyObject * +_curses_longname(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_longname_impl(module); +} + +PyDoc_STRVAR(_curses_meta__doc__, +"meta($module, yes, /)\n" +"--\n" +"\n" +"If yes is 1, allow 8-bit characters to be input. If yes is 0, allow only 7-bit chars.\n" +"\n" +" yes\n" +" True(1), False(0)"); + +#define _CURSES_META_METHODDEF \ + {"meta", (PyCFunction)_curses_meta, METH_O, _curses_meta__doc__}, + +static PyObject * +_curses_meta_impl(PyModuleDef *module, int yes); + +static PyObject * +_curses_meta(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int yes; + + if (!PyArg_Parse(arg, "i:meta", &yes)) + goto exit; + return_value = _curses_meta_impl(module, yes); + +exit: + return return_value; +} + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_mouseinterval__doc__, +"mouseinterval($module, interval, /)\n" +"--\n" +"\n" +"Set the maximum time in milliseconds that can elapse between press and release events in order for them to be recognized as a click, and return the previous interval value."); + +#define _CURSES_MOUSEINTERVAL_METHODDEF \ + {"mouseinterval", (PyCFunction)_curses_mouseinterval, METH_O, _curses_mouseinterval__doc__}, + +static PyObject * +_curses_mouseinterval_impl(PyModuleDef *module, int interval); + +static PyObject * +_curses_mouseinterval(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int interval; + + if (!PyArg_Parse(arg, "i:mouseinterval", &interval)) + goto exit; + return_value = _curses_mouseinterval_impl(module, interval); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +#if defined(NCURSES_MOUSE_VERSION) + +PyDoc_STRVAR(_curses_mousemask__doc__, +"mousemask($module, newmask, /)\n" +"--\n" +"\n" +"Set the mouse events to be reported, and return a tuple (availmask, oldmask).\n" +"\n" +"Return a tuple (availmask, oldmask). availmask indicates which of the\n" +"specified mouse events can be reported; on complete failure it returns 0.\n" +"oldmask is the previous value of the given window’s mouse event mask.\n" +"If this function is never called, no mouse events are ever reported."); + +#define _CURSES_MOUSEMASK_METHODDEF \ + {"mousemask", (PyCFunction)_curses_mousemask, METH_O, _curses_mousemask__doc__}, + +static PyObject * +_curses_mousemask_impl(PyModuleDef *module, int newmask); + +static PyObject * +_curses_mousemask(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int newmask; + + if (!PyArg_Parse(arg, "i:mousemask", &newmask)) + goto exit; + return_value = _curses_mousemask_impl(module, newmask); + +exit: + return return_value; +} + +#endif /* defined(NCURSES_MOUSE_VERSION) */ + +PyDoc_STRVAR(_curses_napms__doc__, +"napms($module, ms, /)\n" +"--\n" +"\n" +"Sleep for ms milliseconds."); + +#define _CURSES_NAPMS_METHODDEF \ + {"napms", (PyCFunction)_curses_napms, METH_O, _curses_napms__doc__}, + +static PyObject * +_curses_napms_impl(PyModuleDef *module, int ms); + +static PyObject * +_curses_napms(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int ms; + + if (!PyArg_Parse(arg, "i:napms", &ms)) + goto exit; + return_value = _curses_napms_impl(module, ms); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_newpad__doc__, +"newpad($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Create and return a pointer to a new pad data structure.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width."); + +#define _CURSES_NEWPAD_METHODDEF \ + {"newpad", (PyCFunction)_curses_newpad, METH_VARARGS, _curses_newpad__doc__}, + +static PyObject * +_curses_newpad_impl(PyModuleDef *module, int nlines, int ncols); + +static PyObject * +_curses_newpad(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!PyArg_ParseTuple(args, "ii:newpad", + &nlines, &ncols)) + goto exit; + return_value = _curses_newpad_impl(module, nlines, ncols); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_newwin__doc__, +"newwin(nlines, ncols, [begin_y, begin_x])\n" +"Return a new window.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +" begin_y\n" +" Top side y-coordinate.\n" +" begin_x\n" +" Left side x-coordinate.\n" +"\n" +"By default, the window will extend from the specified position to the lower\n" +"right corner of the screen."); + +#define _CURSES_NEWWIN_METHODDEF \ + {"newwin", (PyCFunction)_curses_newwin, METH_VARARGS, _curses_newwin__doc__}, + +static PyObject * +_curses_newwin_impl(PyModuleDef *module, int nlines, int ncols, + int group_right_1, int begin_y, int begin_x); + +static PyObject * +_curses_newwin(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + int group_right_1 = 0; + int begin_y = 0; + int begin_x = 0; + + switch (PyTuple_GET_SIZE(args)) { + case 2: + if (!PyArg_ParseTuple(args, "ii:newwin", &nlines, &ncols)) + goto exit; + break; + case 4: + if (!PyArg_ParseTuple(args, "iiii:newwin", &nlines, &ncols, &begin_y, &begin_x)) + goto exit; + group_right_1 = 1; + break; + default: + PyErr_SetString(PyExc_TypeError, "_curses.newwin requires 2 to 4 arguments"); + goto exit; + } + return_value = _curses_newwin_impl(module, nlines, ncols, group_right_1, begin_y, begin_x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_nl__doc__, +"nl($module, flag=True, /)\n" +"--\n" +"\n" +"Enter newline mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling nonl().\n" +"\n" +"This mode translates the return key into newline on input, and translates\n" +"newline into return and line-feed on output. Newline mode is initially on."); + +#define _CURSES_NL_METHODDEF \ + {"nl", (PyCFunction)_curses_nl, METH_VARARGS, _curses_nl__doc__}, + +static PyObject * +_curses_nl_impl(PyModuleDef *module, int flag); + +static PyObject * +_curses_nl(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!PyArg_ParseTuple(args, "|i:nl", + &flag)) + goto exit; + return_value = _curses_nl_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_nocbreak__doc__, +"nocbreak($module, /)\n" +"--\n" +"\n" +"Leave cbreak mode.\n" +"\n" +"Return to normal “cooked” mode with line buffering."); + +#define _CURSES_NOCBREAK_METHODDEF \ + {"nocbreak", (PyCFunction)_curses_nocbreak, METH_NOARGS, _curses_nocbreak__doc__}, + +static PyObject * +_curses_nocbreak_impl(PyModuleDef *module); + +static PyObject * +_curses_nocbreak(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_nocbreak_impl(module); +} + +PyDoc_STRVAR(_curses_noecho__doc__, +"noecho($module, /)\n" +"--\n" +"\n" +"Leave echo mode.\n" +"\n" +"Echoing of input characters is turned off."); + +#define _CURSES_NOECHO_METHODDEF \ + {"noecho", (PyCFunction)_curses_noecho, METH_NOARGS, _curses_noecho__doc__}, + +static PyObject * +_curses_noecho_impl(PyModuleDef *module); + +static PyObject * +_curses_noecho(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_noecho_impl(module); +} + +PyDoc_STRVAR(_curses_nonl__doc__, +"nonl($module, /)\n" +"--\n" +"\n" +"Leave newline mode.\n" +"\n" +"Disable translation of return into newline on input, and disable low-level\n" +"translation of newline into newline/return on output."); + +#define _CURSES_NONL_METHODDEF \ + {"nonl", (PyCFunction)_curses_nonl, METH_NOARGS, _curses_nonl__doc__}, + +static PyObject * +_curses_nonl_impl(PyModuleDef *module); + +static PyObject * +_curses_nonl(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_nonl_impl(module); +} + +PyDoc_STRVAR(_curses_noqiflush__doc__, +"noqiflush($module, /)\n" +"--\n" +"\n" +"When the noqiflush() routine is used, normal flush of input and output queues associated with the INTR, QUIT and SUSP characters will not be done. You may want to call noqiflush() in a signal handler if you want output to continue as though the interrupt had not occurred, after the handler exits."); + +#define _CURSES_NOQIFLUSH_METHODDEF \ + {"noqiflush", (PyCFunction)_curses_noqiflush, METH_NOARGS, _curses_noqiflush__doc__}, + +static PyObject * +_curses_noqiflush_impl(PyModuleDef *module); + +static PyObject * +_curses_noqiflush(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_noqiflush_impl(module); +} + +PyDoc_STRVAR(_curses_noraw__doc__, +"noraw($module, /)\n" +"--\n" +"\n" +"Leave raw mode.\n" +"\n" +"Return to normal “cooked” mode with line buffering."); + +#define _CURSES_NORAW_METHODDEF \ + {"noraw", (PyCFunction)_curses_noraw, METH_NOARGS, _curses_noraw__doc__}, + +static PyObject * +_curses_noraw_impl(PyModuleDef *module); + +static PyObject * +_curses_noraw(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_noraw_impl(module); +} + +PyDoc_STRVAR(_curses_pair_content__doc__, +"pair_content($module, pair_number, /)\n" +"--\n" +"\n" +"Return a tuple (fg, bg) containing the colors for the requested color pair.\n" +"\n" +" pair_number\n" +" The number of the color pair (1 - (COLOR_PAIRS-1))."); + +#define _CURSES_PAIR_CONTENT_METHODDEF \ + {"pair_content", (PyCFunction)_curses_pair_content, METH_O, _curses_pair_content__doc__}, + +static PyObject * +_curses_pair_content_impl(PyModuleDef *module, short pair_number); + +static PyObject * +_curses_pair_content(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + short pair_number; + + if (!PyArg_Parse(arg, "h:pair_content", &pair_number)) + goto exit; + return_value = _curses_pair_content_impl(module, pair_number); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_pair_number__doc__, +"pair_number($module, attr, /)\n" +"--\n" +"\n" +"Return the number of the color-pair set by the attribute value attr.\n" +"\n" +"color_pair() is the counterpart to this function."); + +#define _CURSES_PAIR_NUMBER_METHODDEF \ + {"pair_number", (PyCFunction)_curses_pair_number, METH_O, _curses_pair_number__doc__}, + +static PyObject * +_curses_pair_number_impl(PyModuleDef *module, int attr); + +static PyObject * +_curses_pair_number(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int attr; + + if (!PyArg_Parse(arg, "i:pair_number", &attr)) + goto exit; + return_value = _curses_pair_number_impl(module, attr); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_putp__doc__, +"putp($module, string, /)\n" +"--\n" +"\n" +"Emit the value of a specified terminfo capability for the current terminal.\n" +"\n" +"Note that the output of putp() always goes to standard output."); + +#define _CURSES_PUTP_METHODDEF \ + {"putp", (PyCFunction)_curses_putp, METH_O, _curses_putp__doc__}, + +static PyObject * +_curses_putp_impl(PyModuleDef *module, const char *string); + +static PyObject * +_curses_putp(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *string; + + if (!PyArg_Parse(arg, "y:putp", &string)) + goto exit; + return_value = _curses_putp_impl(module, string); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_qiflush__doc__, +"qiflush($module, flag=True, /)\n" +"--\n" +"\n" +"The queues will be flushed when these control characters are read.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling noqiflush()."); + +#define _CURSES_QIFLUSH_METHODDEF \ + {"qiflush", (PyCFunction)_curses_qiflush, METH_VARARGS, _curses_qiflush__doc__}, + +static PyObject * +_curses_qiflush_impl(PyModuleDef *module, int flag); + +static PyObject * +_curses_qiflush(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!PyArg_ParseTuple(args, "|i:qiflush", + &flag)) + goto exit; + return_value = _curses_qiflush_impl(module, flag); + +exit: + return return_value; +} + +#if (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) + +PyDoc_STRVAR(_curses_update_lines_cols__doc__, +"update_lines_cols($module, /)\n" +"--\n" +"\n"); + +#define _CURSES_UPDATE_LINES_COLS_METHODDEF \ + {"update_lines_cols", (PyCFunction)_curses_update_lines_cols, METH_NOARGS, _curses_update_lines_cols__doc__}, + +static int +_curses_update_lines_cols_impl(PyModuleDef *module); + +static PyObject * +_curses_update_lines_cols(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + PyObject *return_value = NULL; + int _return_value; + + _return_value = _curses_update_lines_cols_impl(module); + if ((_return_value == -1) && PyErr_Occurred()) + goto exit; + return_value = PyLong_FromLong((long)_return_value); + +exit: + return return_value; +} + +#endif /* (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) */ + +PyDoc_STRVAR(_curses_raw__doc__, +"raw($module, flag=True, /)\n" +"--\n" +"\n" +"Enter raw mode.\n" +"\n" +" flag\n" +" If false, the effect is the same as calling noraw().\n" +"\n" +"In raw mode, normal line buffering and processing of interrupt, quit,\n" +"suspend, and flow control keys are turned off; characters are presented to\n" +"curses input functions one by one."); + +#define _CURSES_RAW_METHODDEF \ + {"raw", (PyCFunction)_curses_raw, METH_VARARGS, _curses_raw__doc__}, + +static PyObject * +_curses_raw_impl(PyModuleDef *module, int flag); + +static PyObject * +_curses_raw(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int flag = 1; + + if (!PyArg_ParseTuple(args, "|i:raw", + &flag)) + goto exit; + return_value = _curses_raw_impl(module, flag); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_reset_prog_mode__doc__, +"reset_prog_mode($module, /)\n" +"--\n" +"\n" +"Restore the terminal to “program” mode, as previously saved by def_prog_mode()."); + +#define _CURSES_RESET_PROG_MODE_METHODDEF \ + {"reset_prog_mode", (PyCFunction)_curses_reset_prog_mode, METH_NOARGS, _curses_reset_prog_mode__doc__}, + +static PyObject * +_curses_reset_prog_mode_impl(PyModuleDef *module); + +static PyObject * +_curses_reset_prog_mode(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_reset_prog_mode_impl(module); +} + +PyDoc_STRVAR(_curses_reset_shell_mode__doc__, +"reset_shell_mode($module, /)\n" +"--\n" +"\n" +"Restore the terminal to “shell” mode, as previously saved by def_shell_mode()."); + +#define _CURSES_RESET_SHELL_MODE_METHODDEF \ + {"reset_shell_mode", (PyCFunction)_curses_reset_shell_mode, METH_NOARGS, _curses_reset_shell_mode__doc__}, + +static PyObject * +_curses_reset_shell_mode_impl(PyModuleDef *module); + +static PyObject * +_curses_reset_shell_mode(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_reset_shell_mode_impl(module); +} + +PyDoc_STRVAR(_curses_resetty__doc__, +"resetty($module, /)\n" +"--\n" +"\n" +"Restore the state of the terminal modes to what it was at the last call to savetty()."); + +#define _CURSES_RESETTY_METHODDEF \ + {"resetty", (PyCFunction)_curses_resetty, METH_NOARGS, _curses_resetty__doc__}, + +static PyObject * +_curses_resetty_impl(PyModuleDef *module); + +static PyObject * +_curses_resetty(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_resetty_impl(module); +} + +#if defined(HAVE_CURSES_RESIZETERM) + +PyDoc_STRVAR(_curses_resizeterm__doc__, +"resizeterm($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Resize the standard and current windows to the specified dimensions.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +"\n" +"Adjusts other bookkeeping data used by the curses library that record the\n" +"window dimensions (in particular the SIGWINCH handler)."); + +#define _CURSES_RESIZETERM_METHODDEF \ + {"resizeterm", (PyCFunction)_curses_resizeterm, METH_VARARGS, _curses_resizeterm__doc__}, + +static PyObject * +_curses_resizeterm_impl(PyModuleDef *module, int nlines, int ncols); + +static PyObject * +_curses_resizeterm(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!PyArg_ParseTuple(args, "ii:resizeterm", + &nlines, &ncols)) + goto exit; + return_value = _curses_resizeterm_impl(module, nlines, ncols); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_RESIZETERM) */ + +#if defined(HAVE_CURSES_RESIZE_TERM) + +PyDoc_STRVAR(_curses_resize_term__doc__, +"resize_term($module, nlines, ncols, /)\n" +"--\n" +"\n" +"Backend function used by resizeterm(), performing most of the work.\n" +"\n" +" nlines\n" +" Height.\n" +" ncols\n" +" Width.\n" +"\n" +"When resizing the windows, resize_term() blank-fills the areas that are\n" +"extended. The calling application should fill in these areas with appropriate\n" +"data. The resize_term() function attempts to resize all windows. However,\n" +"due to the calling convention of pads, it is not possible to resize these\n" +"without additional interaction with the application."); + +#define _CURSES_RESIZE_TERM_METHODDEF \ + {"resize_term", (PyCFunction)_curses_resize_term, METH_VARARGS, _curses_resize_term__doc__}, + +static PyObject * +_curses_resize_term_impl(PyModuleDef *module, int nlines, int ncols); + +static PyObject * +_curses_resize_term(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int nlines; + int ncols; + + if (!PyArg_ParseTuple(args, "ii:resize_term", + &nlines, &ncols)) + goto exit; + return_value = _curses_resize_term_impl(module, nlines, ncols); + +exit: + return return_value; +} + +#endif /* defined(HAVE_CURSES_RESIZE_TERM) */ + +PyDoc_STRVAR(_curses_savetty__doc__, +"savetty($module, /)\n" +"--\n" +"\n" +"Save the current state of the terminal modes in a buffer, usable by resetty()."); + +#define _CURSES_SAVETTY_METHODDEF \ + {"savetty", (PyCFunction)_curses_savetty, METH_NOARGS, _curses_savetty__doc__}, + +static PyObject * +_curses_savetty_impl(PyModuleDef *module); + +static PyObject * +_curses_savetty(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_savetty_impl(module); +} + +PyDoc_STRVAR(_curses_setsyx__doc__, +"setsyx($module, y, x, /)\n" +"--\n" +"\n" +"Set the virtual screen cursor to y, x.\n" +"\n" +" y\n" +" Y-coordinate.\n" +" x\n" +" X-coordinate.\n" +"\n" +"If y and x are both -1, then leaveok is set."); + +#define _CURSES_SETSYX_METHODDEF \ + {"setsyx", (PyCFunction)_curses_setsyx, METH_VARARGS, _curses_setsyx__doc__}, + +static PyObject * +_curses_setsyx_impl(PyModuleDef *module, int y, int x); + +static PyObject * +_curses_setsyx(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + int y; + int x; + + if (!PyArg_ParseTuple(args, "ii:setsyx", + &y, &x)) + goto exit; + return_value = _curses_setsyx_impl(module, y, x); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_start_color__doc__, +"start_color($module, /)\n" +"--\n" +"\n" +"Initializes eight basic colors and global variables COLORS and COLOR_PAIRS.\n" +"\n" +"Must be called if the programmer wants to use colors, and before any other\n" +"color manipulation routine is called. It is good practice to call this\n" +"routine right after initscr().\n" +"\n" +"It also restores the colors on the terminal to the values they had when the\n" +"terminal was just turned on."); + +#define _CURSES_START_COLOR_METHODDEF \ + {"start_color", (PyCFunction)_curses_start_color, METH_NOARGS, _curses_start_color__doc__}, + +static PyObject * +_curses_start_color_impl(PyModuleDef *module); + +static PyObject * +_curses_start_color(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_start_color_impl(module); +} + +PyDoc_STRVAR(_curses_termattrs__doc__, +"termattrs($module, /)\n" +"--\n" +"\n" +"Return a logical OR of all video attributes supported by the terminal."); + +#define _CURSES_TERMATTRS_METHODDEF \ + {"termattrs", (PyCFunction)_curses_termattrs, METH_NOARGS, _curses_termattrs__doc__}, + +static PyObject * +_curses_termattrs_impl(PyModuleDef *module); + +static PyObject * +_curses_termattrs(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_termattrs_impl(module); +} + +PyDoc_STRVAR(_curses_termname__doc__, +"termname($module, /)\n" +"--\n" +"\n" +"Return the value of the environment variable TERM, truncated to 14 characters."); + +#define _CURSES_TERMNAME_METHODDEF \ + {"termname", (PyCFunction)_curses_termname, METH_NOARGS, _curses_termname__doc__}, + +static PyObject * +_curses_termname_impl(PyModuleDef *module); + +static PyObject * +_curses_termname(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_termname_impl(module); +} + +PyDoc_STRVAR(_curses_tigetflag__doc__, +"tigetflag($module, capname, /)\n" +"--\n" +"\n" +"Return the value of the Boolean capability.\n" +"\n" +" capname\n" +" The terminfo capability name.\n" +"\n" +"The value -1 is returned if capname is not a Boolean capability, or 0 if\n" +"it is canceled or absent from the terminal description."); + +#define _CURSES_TIGETFLAG_METHODDEF \ + {"tigetflag", (PyCFunction)_curses_tigetflag, METH_O, _curses_tigetflag__doc__}, + +static PyObject * +_curses_tigetflag_impl(PyModuleDef *module, const char *capname); + +static PyObject * +_curses_tigetflag(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *capname; + + if (!PyArg_Parse(arg, "s:tigetflag", &capname)) + goto exit; + return_value = _curses_tigetflag_impl(module, capname); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_tigetnum__doc__, +"tigetnum($module, capname, /)\n" +"--\n" +"\n" +"Return the value of the numeric capability.\n" +"\n" +" capname\n" +" The terminfo capability name.\n" +"\n" +"The value -2 is returned if capname is not a numeric capability, or -1 if\n" +"it is canceled or absent from the terminal description."); + +#define _CURSES_TIGETNUM_METHODDEF \ + {"tigetnum", (PyCFunction)_curses_tigetnum, METH_O, _curses_tigetnum__doc__}, + +static PyObject * +_curses_tigetnum_impl(PyModuleDef *module, const char *capname); + +static PyObject * +_curses_tigetnum(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *capname; + + if (!PyArg_Parse(arg, "s:tigetnum", &capname)) + goto exit; + return_value = _curses_tigetnum_impl(module, capname); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_tigetstr__doc__, +"tigetstr($module, capname, /)\n" +"--\n" +"\n" +"Return the value of the string capability.\n" +"\n" +" capname\n" +" The terminfo capability name.\n" +"\n" +"None is returned if capname is not a string capability, or is canceled or\n" +"absent from the terminal description."); + +#define _CURSES_TIGETSTR_METHODDEF \ + {"tigetstr", (PyCFunction)_curses_tigetstr, METH_O, _curses_tigetstr__doc__}, + +static PyObject * +_curses_tigetstr_impl(PyModuleDef *module, const char *capname); + +static PyObject * +_curses_tigetstr(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + const char *capname; + + if (!PyArg_Parse(arg, "s:tigetstr", &capname)) + goto exit; + return_value = _curses_tigetstr_impl(module, capname); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_tparm__doc__, +"tparm($module, str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0,\n" +" i9=0, /)\n" +"--\n" +"\n" +"Instantiate the string str with the supplied parameters.\n" +"\n" +" str\n" +" Parameterized string obtained from the terminfo database."); + +#define _CURSES_TPARM_METHODDEF \ + {"tparm", (PyCFunction)_curses_tparm, METH_VARARGS, _curses_tparm__doc__}, + +static PyObject * +_curses_tparm_impl(PyModuleDef *module, const char *str, int i1, int i2, + int i3, int i4, int i5, int i6, int i7, int i8, int i9); + +static PyObject * +_curses_tparm(PyModuleDef *module, PyObject *args) +{ + PyObject *return_value = NULL; + const char *str; + int i1 = 0; + int i2 = 0; + int i3 = 0; + int i4 = 0; + int i5 = 0; + int i6 = 0; + int i7 = 0; + int i8 = 0; + int i9 = 0; + + if (!PyArg_ParseTuple(args, "y|iiiiiiiii:tparm", + &str, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)) + goto exit; + return_value = _curses_tparm_impl(module, str, i1, i2, i3, i4, i5, i6, i7, i8, i9); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_typeahead__doc__, +"typeahead($module, fd, /)\n" +"--\n" +"\n" +"Specify that the file descriptor fd be used for typeahead checking.\n" +"\n" +" fd\n" +" File descriptor.\n" +"\n" +"If fd is -1, then no typeahead checking is done."); + +#define _CURSES_TYPEAHEAD_METHODDEF \ + {"typeahead", (PyCFunction)_curses_typeahead, METH_O, _curses_typeahead__doc__}, + +static PyObject * +_curses_typeahead_impl(PyModuleDef *module, int fd); + +static PyObject * +_curses_typeahead(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int fd; + + if (!PyArg_Parse(arg, "i:typeahead", &fd)) + goto exit; + return_value = _curses_typeahead_impl(module, fd); + +exit: + return return_value; +} + +PyDoc_STRVAR(_curses_unctrl__doc__, +"unctrl($module, ch, /)\n" +"--\n" +"\n" +"Return a string which is a printable representation of the character ch.\n" +"\n" +"Control characters are displayed as a caret followed by the character,\n" +"for example as ^C. Printing characters are left as they are."); + +#define _CURSES_UNCTRL_METHODDEF \ + {"unctrl", (PyCFunction)_curses_unctrl, METH_O, _curses_unctrl__doc__}, + +PyDoc_STRVAR(_curses_ungetch__doc__, +"ungetch($module, ch, /)\n" +"--\n" +"\n" +"Push ch so the next getch() will return it."); + +#define _CURSES_UNGETCH_METHODDEF \ + {"ungetch", (PyCFunction)_curses_ungetch, METH_O, _curses_ungetch__doc__}, + +#if defined(HAVE_NCURSESW) + +PyDoc_STRVAR(_curses_unget_wch__doc__, +"unget_wch($module, ch, /)\n" +"--\n" +"\n" +"Push ch so the next get_wch() will return it."); + +#define _CURSES_UNGET_WCH_METHODDEF \ + {"unget_wch", (PyCFunction)_curses_unget_wch, METH_O, _curses_unget_wch__doc__}, + +#endif /* defined(HAVE_NCURSESW) */ + +PyDoc_STRVAR(_curses_use_env__doc__, +"use_env($module, flag, /)\n" +"--\n" +"\n" +"Use environment variables LINES and COLUMNS.\n" +"\n" +" flag\n" +" True(1), False(0)\n" +"\n" +"If used, this function should be called before initscr() or newterm() are called.\n" +"\n" +"When flag is False, the values of lines and columns specified in the terminfo\n" +"database will be used, even if environment variables LINES and COLUMNS (used\n" +"by default) are set, or if curses is running in a window (in which case\n" +"default behavior would be to use the window size if LINES and COLUMNS are\n" +"not set)."); + +#define _CURSES_USE_ENV_METHODDEF \ + {"use_env", (PyCFunction)_curses_use_env, METH_O, _curses_use_env__doc__}, + +static PyObject * +_curses_use_env_impl(PyModuleDef *module, int flag); + +static PyObject * +_curses_use_env(PyModuleDef *module, PyObject *arg) +{ + PyObject *return_value = NULL; + int flag; + + if (!PyArg_Parse(arg, "i:use_env", &flag)) + goto exit; + return_value = _curses_use_env_impl(module, flag); + +exit: + return return_value; +} + +#if !defined(STRICT_SYSV_CURSES) + +PyDoc_STRVAR(_curses_use_default_colors__doc__, +"use_default_colors($module, /)\n" +"--\n" +"\n" +"Allow use of default values for colors on terminals supporting this feature.\n" +"\n" +"Use this to support transparency in your application. The default color\n" +"is assigned to the color number -1."); + +#define _CURSES_USE_DEFAULT_COLORS_METHODDEF \ + {"use_default_colors", (PyCFunction)_curses_use_default_colors, METH_NOARGS, _curses_use_default_colors__doc__}, + +static PyObject * +_curses_use_default_colors_impl(PyModuleDef *module); + +static PyObject * +_curses_use_default_colors(PyModuleDef *module, PyObject *Py_UNUSED(ignored)) +{ + return _curses_use_default_colors_impl(module); +} + +#endif /* !defined(STRICT_SYSV_CURSES) */ + +#ifndef _CURSES_WINDOW_ENCLOSE_METHODDEF + #define _CURSES_WINDOW_ENCLOSE_METHODDEF +#endif /* !defined(_CURSES_WINDOW_ENCLOSE_METHODDEF) */ + +#ifndef _CURSES_WINDOW_NOUTREFRESH_METHODDEF + #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF +#endif /* !defined(_CURSES_WINDOW_NOUTREFRESH_METHODDEF) */ + +#ifndef _CURSES_GETMOUSE_METHODDEF + #define _CURSES_GETMOUSE_METHODDEF +#endif /* !defined(_CURSES_GETMOUSE_METHODDEF) */ + +#ifndef _CURSES_UNGETMOUSE_METHODDEF + #define _CURSES_UNGETMOUSE_METHODDEF +#endif /* !defined(_CURSES_UNGETMOUSE_METHODDEF) */ + +#ifndef _CURSES_HAS_KEY_METHODDEF + #define _CURSES_HAS_KEY_METHODDEF +#endif /* !defined(_CURSES_HAS_KEY_METHODDEF) */ + +#ifndef _CURSES_IS_TERM_RESIZED_METHODDEF + #define _CURSES_IS_TERM_RESIZED_METHODDEF +#endif /* !defined(_CURSES_IS_TERM_RESIZED_METHODDEF) */ + +#ifndef _CURSES_KEYNAME_METHODDEF + #define _CURSES_KEYNAME_METHODDEF +#endif /* !defined(_CURSES_KEYNAME_METHODDEF) */ + +#ifndef _CURSES_MOUSEINTERVAL_METHODDEF + #define _CURSES_MOUSEINTERVAL_METHODDEF +#endif /* !defined(_CURSES_MOUSEINTERVAL_METHODDEF) */ + +#ifndef _CURSES_MOUSEMASK_METHODDEF + #define _CURSES_MOUSEMASK_METHODDEF +#endif /* !defined(_CURSES_MOUSEMASK_METHODDEF) */ + +#ifndef _CURSES_UPDATE_LINES_COLS_METHODDEF + #define _CURSES_UPDATE_LINES_COLS_METHODDEF +#endif /* !defined(_CURSES_UPDATE_LINES_COLS_METHODDEF) */ + +#ifndef _CURSES_RESIZETERM_METHODDEF + #define _CURSES_RESIZETERM_METHODDEF +#endif /* !defined(_CURSES_RESIZETERM_METHODDEF) */ + +#ifndef _CURSES_RESIZE_TERM_METHODDEF + #define _CURSES_RESIZE_TERM_METHODDEF +#endif /* !defined(_CURSES_RESIZE_TERM_METHODDEF) */ + +#ifndef _CURSES_UNGET_WCH_METHODDEF + #define _CURSES_UNGET_WCH_METHODDEF +#endif /* !defined(_CURSES_UNGET_WCH_METHODDEF) */ + +#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF + #define _CURSES_USE_DEFAULT_COLORS_METHODDEF +#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */ +/*[clinic end generated code: output=b96a9ff423de9dbe input=a9049054013a1b77]*/