*** C:\Lang\Projects\curses\python\src\_cursesmodule.c Fri Aug 6 16:46:05 2004 --- C:\Lang\Projects\curses\python\_cursesmodule.c Fri Aug 6 17:34:37 2004 *************** *** 244,250 **** #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) \ --- 244,252 ---- #define Window_NoArgTrueFalseFunction(X) \ static PyObject * PyCursesWindow_ ## X (PyCursesWindowObject *self) \ { \ ! int code = X (self->win); \ ! if (code == ERR) {return PyCursesCheckERR(code, # X);} \ ! if (code == FALSE) { Py_INCREF(Py_False); return Py_False; } \ else { Py_INCREF(Py_True); return Py_True; } } #define Window_NoArgNoReturnVoidFunction(X) \ *************** *** 333,339 **** --- 335,349 ---- Window_TwoArgNoReturnFunction(mvderwin, int, "ii;y,x") Window_TwoArgNoReturnFunction(wmove, int, "ii;y,x") #ifndef STRICT_SYSV_CURSES + #ifndef PDCURSES Window_TwoArgNoReturnFunction(wresize, int, "ii;lines,columns") + #else + static PyObject * PyCursesWindow_wresize(PyCursesWindowObject *self, PyObject *args) { + int lines, columns; + if (!PyArg_Parse(args,"ii;lines,columns", &lines, &columns)) return NULL; + return PyCursesCheckERR(wresize(&self->win, lines, columns), "wresize"); + } + #endif #endif /* Allocation and deallocation of Window Objects */ *************** *** 553,559 **** } wbkgdset(self->win, bkgd | attr); ! return PyCursesCheckERR(0, "bkgdset"); } static PyObject * --- 563,569 ---- } wbkgdset(self->win, bkgd | attr); ! return PyCursesCheckERR(OK, "bkgdset"); } static PyObject * *************** *** 1220,1225 **** --- 1230,1236 ---- } } + #ifndef PDCURSES static PyObject * PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *args) { *************** *** 1234,1239 **** --- 1245,1251 ---- return PyCursesCheckERR(putwin(self->win, PyFile_AsFile(temp)), "putwin"); } + #endif /* PDCURSES */ static PyObject * PyCursesWindow_RedrawLine(PyCursesWindowObject *self, PyObject *args) *************** *** 1471,1477 **** --- 1483,1491 ---- {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS}, {"overwrite", (PyCFunction)PyCursesWindow_Overwrite, METH_VARARGS}, + #ifndef PDCURSES {"putwin", (PyCFunction)PyCursesWindow_PutWin, METH_VARARGS}, + #endif {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine}, {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin, METH_NOARGS}, {"refresh", (PyCFunction)PyCursesWindow_Refresh, METH_VARARGS}, *************** *** 1558,1566 **** --- 1572,1584 ---- NoArgTrueFalseFunction(has_ic) NoArgTrueFalseFunction(has_il) NoArgTrueFalseFunction(isendwin) + #ifndef PDCURSES NoArgNoReturnVoidFunction(filter) + #endif NoArgNoReturnVoidFunction(flushinp) + #ifndef PDCURSES NoArgNoReturnVoidFunction(noqiflush) + #endif static PyObject * PyCurses_Color_Content(PyObject *self, PyObject *args) *************** *** 1680,1685 **** --- 1698,1704 ---- } #endif + #ifndef PDCURSES static PyObject * PyCurses_GetWin(PyCursesWindowObject *self, PyObject *temp) { *************** *** 1701,1706 **** --- 1720,1726 ---- return PyCursesWindow_New(win); } + #endif /* PDCURSES */ static PyObject * PyCurses_HalfDelay(PyObject *self, PyObject *args) *************** *** 1875,1880 **** --- 1895,1901 ---- return (PyObject *)PyCursesWindow_New(win); } + #ifndef PDCURSES static PyObject * PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds) { *************** *** 1926,1931 **** --- 1947,1953 ---- Py_INCREF(Py_None); return Py_None; } + #endif /* PDCURSES */ static PyObject * PyCurses_IntrFlush(PyObject *self, PyObject *args) *************** *** 1943,1949 **** return NULL; } ! return PyCursesCheckERR(intrflush(NULL,ch), "intrflush"); } #if !defined(__NetBSD__) --- 1965,1971 ---- return NULL; } ! return PyCursesCheckERR(intrflush(stdscr, ch), "intrflush"); } #if !defined(__NetBSD__) *************** *** 2133,2138 **** --- 2155,2161 ---- return PyInt_FromLong((long) ((n & A_COLOR) >> 8)); } + #ifndef PDCURSES static PyObject * PyCurses_Putp(PyObject *self, PyObject *args) { *************** *** 2165,2170 **** --- 2188,2194 ---- return NULL; } } + #endif /* PDCURSES */ static PyObject * PyCurses_setsyx(PyObject *self, PyObject *args) *************** *** 2206,2216 **** Py_INCREF(Py_None); return Py_None; } else { ! PyErr_SetString(PyCursesError, "start_color() returned ERR"); ! return NULL; } } static PyObject * PyCurses_tigetflag(PyObject *self, PyObject *args) { --- 2230,2240 ---- Py_INCREF(Py_None); return Py_None; } else { ! return PyCursesCheckERR(code, "start_color"); } } + #ifndef PDCURSES static PyObject * PyCurses_tigetflag(PyObject *self, PyObject *args) { *************** *** 2274,2279 **** --- 2298,2304 ---- return PyString_FromString(result); } + #endif /* PDCURSES */ static PyObject * PyCurses_TypeAhead(PyObject *self, PyObject *args) *************** *** 2347,2375 **** PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument"); return NULL; } use_env(flag); Py_INCREF(Py_None); return Py_None; } #ifndef STRICT_SYSV_CURSES static PyObject * PyCurses_Use_Default_Colors(PyObject *self) { - int code; PyCursesInitialised PyCursesInitialisedColor ! code = use_default_colors(); ! if (code != ERR) { ! Py_INCREF(Py_None); ! return Py_None; ! } else { ! PyErr_SetString(PyCursesError, "use_default_colors() returned ERR"); ! return NULL; ! } } #endif /* STRICT_SYSV_CURSES */ /* List of functions defined in the module */ --- 2372,2396 ---- PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument"); return NULL; } + #ifndef PDCURSES use_env(flag); + #endif Py_INCREF(Py_None); return Py_None; } #ifndef STRICT_SYSV_CURSES + #ifndef PDCURSES static PyObject * PyCurses_Use_Default_Colors(PyObject *self) { PyCursesInitialised PyCursesInitialisedColor ! return PyCursesCheckERR(use_default_colors(), "use_default_colors"); } + #endif /* PDCURSES */ #endif /* STRICT_SYSV_CURSES */ /* List of functions defined in the module */ *************** *** 2389,2395 **** --- 2410,2418 ---- {"echo", (PyCFunction)PyCurses_echo, METH_VARARGS}, {"endwin", (PyCFunction)PyCurses_endwin, METH_NOARGS}, {"erasechar", (PyCFunction)PyCurses_EraseChar, METH_NOARGS}, + #ifndef PDCURSES {"filter", (PyCFunction)PyCurses_filter, METH_NOARGS}, + #endif {"flash", (PyCFunction)PyCurses_flash, METH_NOARGS}, {"flushinp", (PyCFunction)PyCurses_flushinp, METH_NOARGS}, #ifdef NCURSES_MOUSE_VERSION *************** *** 2397,2403 **** --- 2420,2428 ---- {"ungetmouse", (PyCFunction)PyCurses_UngetMouse, METH_VARARGS}, #endif {"getsyx", (PyCFunction)PyCurses_getsyx, METH_NOARGS}, + #ifndef PDCURSES {"getwin", (PyCFunction)PyCurses_GetWin, METH_O}, + #endif {"has_colors", (PyCFunction)PyCurses_has_colors, METH_NOARGS}, {"has_ic", (PyCFunction)PyCurses_has_ic, METH_NOARGS}, {"has_il", (PyCFunction)PyCurses_has_il, METH_NOARGS}, *************** *** 2427,2460 **** --- 2452,2495 ---- {"nocbreak", (PyCFunction)PyCurses_nocbreak, METH_NOARGS}, {"noecho", (PyCFunction)PyCurses_noecho, METH_NOARGS}, {"nonl", (PyCFunction)PyCurses_nonl, METH_NOARGS}, + #ifndef PDCURSES {"noqiflush", (PyCFunction)PyCurses_noqiflush, METH_NOARGS}, + #endif {"noraw", (PyCFunction)PyCurses_noraw, METH_NOARGS}, {"pair_content", (PyCFunction)PyCurses_Pair_Content, METH_VARARGS}, {"pair_number", (PyCFunction)PyCurses_pair_number, METH_VARARGS}, + #ifndef PDCURSES {"putp", (PyCFunction)PyCurses_Putp, METH_VARARGS}, {"qiflush", (PyCFunction)PyCurses_QiFlush, METH_VARARGS}, + #endif {"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}, {"savetty", (PyCFunction)PyCurses_savetty, METH_NOARGS}, {"setsyx", (PyCFunction)PyCurses_setsyx, METH_VARARGS}, + #ifndef PDCURSES {"setupterm", (PyCFunction)PyCurses_setupterm, METH_VARARGS|METH_KEYWORDS}, + #endif {"start_color", (PyCFunction)PyCurses_Start_Color, METH_NOARGS}, {"termattrs", (PyCFunction)PyCurses_termattrs, METH_NOARGS}, {"termname", (PyCFunction)PyCurses_termname, METH_NOARGS}, + #ifndef PDCURSES {"tigetflag", (PyCFunction)PyCurses_tigetflag, METH_VARARGS}, {"tigetnum", (PyCFunction)PyCurses_tigetnum, METH_VARARGS}, {"tigetstr", (PyCFunction)PyCurses_tigetstr, METH_VARARGS}, {"tparm", (PyCFunction)PyCurses_tparm, METH_VARARGS}, + #endif {"typeahead", (PyCFunction)PyCurses_TypeAhead, METH_VARARGS}, {"unctrl", (PyCFunction)PyCurses_UnCtrl, METH_VARARGS}, {"ungetch", (PyCFunction)PyCurses_UngetCh, METH_VARARGS}, {"use_env", (PyCFunction)PyCurses_Use_Env, METH_VARARGS}, #ifndef STRICT_SYSV_CURSES + #ifndef PDCURSES {"use_default_colors", (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS}, #endif + #endif {NULL, NULL} /* sentinel */ }; *************** *** 2496,2501 **** --- 2531,2543 ---- PyDict_SetItemString(d, "version", v); PyDict_SetItemString(d, "__version__", v); Py_DECREF(v); + #ifdef PDCURSES + v = PyString_FromString("PDCurses M"); + PyDict_SetItemString(d, "_C_API_NAME", v); + Py_DECREF(v); + + SetDictInt("_C_API_VERSION", PDC_BUILD); + #endif /* PDCURSES */ SetDictInt("ERR", ERR); SetDictInt("OK", OK);