diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2001-10-20 16:05:52 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2001-10-20 16:05:52 (GMT) |
commit | 16e65a023eb7f7d0d091d0ce914b8a9c2e4b8f82 (patch) | |
tree | 1f1c3a1dc4d390b3515c7cf70b999c9a605a1751 /Modules | |
parent | 0c156a5130905c45aa45b0a3d9faa65923d92bad (diff) | |
download | cpython-16e65a023eb7f7d0d091d0ce914b8a9c2e4b8f82.zip cpython-16e65a023eb7f7d0d091d0ce914b8a9c2e4b8f82.tar.gz cpython-16e65a023eb7f7d0d091d0ce914b8a9c2e4b8f82.tar.bz2 |
Add two forgotten 'break' statements
Allow passing strings to the .border() method
Correct some error messages ("1 or 4" -> "1 to 4")
Bump version number
Tweak code formatting
Update my e-mail address
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 6f79aa0..092f658 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -8,7 +8,8 @@ * Version 1.5b1, heavily extended for ncurses by Oliver Andrich: * Copyright 1996,1997 by Oliver Andrich, Koblenz, Germany. * - * Tidied for Python 1.6, and currently maintained by AMK (amk1@bigfoot.com) + * Tidied for Python 1.6, and currently maintained by + * <akuchlin@mems-exchange.org>. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this source file to use, copy, modify, merge, or publish it @@ -95,7 +96,7 @@ Form extension (ncurses and probably SYSV): /* Release Number */ -char *PyCursesVersion = "2.1"; +char *PyCursesVersion = "2.2"; /* Includes */ @@ -388,7 +389,7 @@ PyCursesWindow_AddCh(PyCursesWindowObject *self, PyObject *args) use_xy = TRUE; break; default: - PyErr_SetString(PyExc_TypeError, "addch requires 1 or 4 arguments"); + PyErr_SetString(PyExc_TypeError, "addch requires 1 to 4 arguments"); return NULL; } @@ -560,12 +561,32 @@ PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args) static PyObject * PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args) { - chtype ls, rs, ts, bs, tl, tr, bl, br; - ls = rs = ts = bs = tl = tr = bl = br = 0; - if (!PyArg_Parse(args,"|llllllll;ls,rs,ts,bs,tl,tr,bl,br", - &ls, &rs, &ts, &bs, &tl, &tr, &bl, &br)) + PyObject *temp[8]; + chtype ch[8]; + int i; + + /* Clear the array of parameters */ + for(i=0; i<8; i++) { + temp[i] = NULL; + 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])) return NULL; - wborder(self->win, ls, rs, ts, bs, tl, tr, bl, br); + + for(i=0; i<8; i++) { + if (temp[i] != NULL && !PyCurses_ConvertToChtype(temp[i], &ch[i])) { + PyErr_Format(PyExc_TypeError, + "argument %i must be a ch or an int", i+1); + return NULL; + } + } + + 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; } @@ -834,8 +855,9 @@ PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args) &y, &x, &temp, &n, &attr)) return NULL; code = wmove(self->win, y, x); + break; default: - PyErr_SetString(PyExc_TypeError, "hline requires 2 or 5 arguments"); + PyErr_SetString(PyExc_TypeError, "hline requires 2 to 5 arguments"); return NULL; } @@ -1360,8 +1382,9 @@ PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args) &y, &x, &temp, &n, &attr)) return NULL; code = wmove(self->win, y, x); + break; default: - PyErr_SetString(PyExc_TypeError, "vline requires 2 or 5 arguments"); + PyErr_SetString(PyExc_TypeError, "vline requires 2 to 5 arguments"); return NULL; } @@ -1431,8 +1454,9 @@ static PyMethodDef PyCursesWindow_Methods[] = { {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, /* Backward compatibility alias -- remove in Python 2.1 */ {"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh}, - {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS}, - {"overwrite", (PyCFunction)PyCursesWindow_Overwrite, METH_VARARGS}, + {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS}, + {"overwrite", (PyCFunction)PyCursesWindow_Overwrite, + METH_VARARGS}, {"putwin", (PyCFunction)PyCursesWindow_PutWin}, {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine}, {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin}, @@ -1455,7 +1479,7 @@ static PyMethodDef PyCursesWindow_Methods[] = { {"touchwin", (PyCFunction)PyCursesWindow_touchwin}, {"untouchwin", (PyCFunction)PyCursesWindow_untouchwin}, {"vline", (PyCFunction)PyCursesWindow_Vline}, - {NULL, NULL} /* sentinel */ + {NULL, NULL} /* sentinel */ }; static PyObject * @@ -2444,7 +2468,8 @@ static PyMethodDef PyCurses_methods[] = { {"resetty", (PyCFunction)PyCurses_resetty}, {"savetty", (PyCFunction)PyCurses_savetty}, {"setsyx", (PyCFunction)PyCurses_setsyx}, - {"setupterm", (PyCFunction)PyCurses_setupterm, METH_VARARGS|METH_KEYWORDS}, + {"setupterm", (PyCFunction)PyCurses_setupterm, + METH_VARARGS|METH_KEYWORDS}, {"start_color", (PyCFunction)PyCurses_Start_Color}, {"termattrs", (PyCFunction)PyCurses_termattrs}, {"termname", (PyCFunction)PyCurses_termname}, @@ -2456,7 +2481,7 @@ static PyMethodDef PyCurses_methods[] = { {"unctrl", (PyCFunction)PyCurses_UnCtrl}, {"ungetch", (PyCFunction)PyCurses_UngetCh}, {"use_env", (PyCFunction)PyCurses_Use_Env}, - {NULL, NULL} /* sentinel */ + {NULL, NULL} /* sentinel */ }; /* Initialization function for the module */ |