Skip to content

Commit

Permalink
Lance's release 1.1 -- fixes some problems with 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Aug 31, 1994
1 parent fbea2f3 commit 56bf235
Showing 1 changed file with 52 additions and 36 deletions.
88 changes: 52 additions & 36 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
******************************************************************/

/******************************************************************
This is a curses implimentation. I have tried to be as complete
This is a curses implementation. I have tried to be as complete
as possible. If there are functions you need that are not included,
please let me know and/or send me some diffs.
Expand Down Expand Up @@ -178,12 +178,19 @@ PyObject *PyCurses_ERR;
Change Log:
Version 1.1: 94/08/31:
Minor fixes given by Guido.
Changed 'ncurses' to 'curses'
Changed '__version__' to 'version'
Added PyErr_Clear() where needed
Moved ACS_* attribute initialization to PyCurses_InitScr() to fix
crash on SGI
Version 1.0: 94/08/30:
This is the first release of this software.
Released to the Internet via [email protected]
******************************************************************/
char *PyCursesVersion = "1.0 first release"
char *PyCursesVersion = "1.1";

/* ------------- SCREEN routines --------------- */
#ifdef NOT_YET
Expand Down Expand Up @@ -405,6 +412,7 @@ PyCursesWindow_DelCh(self,arg)
int use_xy = TRUE;
if (!PyArg_Parse(arg,"(ii);y,x", &y, &x))
use_xy = FALSE;
PyErr_Clear();
if (use_xy == TRUE)
rtn = mvwdelch(self->win,y,x);
else
Expand Down Expand Up @@ -750,6 +758,7 @@ PyCursesWindow_GetCh(self,arg)
int rtn;
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
use_xy = FALSE;
PyErr_Clear();
if (use_xy == TRUE)
rtn = mvwgetch(self->win,y,x);
else
Expand All @@ -768,6 +777,7 @@ PyCursesWindow_GetStr(self,arg)
int rtn2;
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
use_xy = FALSE;
PyErr_Clear();
if (use_xy == TRUE)
rtn2 = mvwgetstr(self->win,y,x,rtn);
else
Expand All @@ -787,6 +797,7 @@ PyCursesWindow_InCh(self,arg)
int rtn;
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
use_xy = FALSE;
PyErr_Clear();
if (use_xy == TRUE)
rtn = mvwinch(self->win,y,x);
else
Expand Down Expand Up @@ -1028,14 +1039,49 @@ PyCurses_InitScr(self, args)
PyObject * args;
{
static int already_inited = FALSE;
WINDOW *win;
if (!PyArg_NoArgs(args))
return (PyObject *)NULL;
if (already_inited == TRUE) {
wrefresh(stdscr);
return (PyObject *)PyCursesWindow_New(stdscr);
}
already_inited = TRUE;
return (PyObject *)PyCursesWindow_New(initscr());

win = initscr();

/* This was moved from initcurses() because core dumped on SGI */
#define SetDictChar(string,ch) \
PyDict_SetItemString(d,string,PyInt_FromLong(ch));

/* Here are some graphic symbols you can use */
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
SetDictChar("ACS_LLCORNER",(ACS_LLCORNER));
SetDictChar("ACS_URCORNER",(ACS_URCORNER));
SetDictChar("ACS_LRCORNER",(ACS_LRCORNER));
SetDictChar("ACS_RTEE", (ACS_RTEE));
SetDictChar("ACS_LTEE", (ACS_LTEE));
SetDictChar("ACS_BTEE", (ACS_BTEE));
SetDictChar("ACS_TTEE", (ACS_TTEE));
SetDictChar("ACS_HLINE", (ACS_HLINE));
SetDictChar("ACS_VLINE", (ACS_VLINE));
SetDictChar("ACS_PLUS", (ACS_PLUS));
SetDictChar("ACS_S1", (ACS_S1));
SetDictChar("ACS_S9", (ACS_S9));
SetDictChar("ACS_DIAMOND", (ACS_DIAMOND));
SetDictChar("ACS_CKBOARD", (ACS_CKBOARD));
SetDictChar("ACS_DEGREE", (ACS_DEGREE));
SetDictChar("ACS_PLMINUS", (ACS_PLMINUS));
SetDictChar("ACS_BULLET", (ACS_BULLET));
SetDictChar("ACS_LARROW", (ACS_RARROW));
SetDictChar("ACS_DARROW", (ACS_DARROW));
SetDictChar("ACS_UARROW", (ACS_UARROW));
SetDictChar("ACS_BOARD", (ACS_BOARD));
SetDictChar("ACS_LANTERN", (ACS_LANTERN));
SetDictChar("ACS_BLOCK", (ACS_BLOCK));

return (PyObject *)PyCursesWindow_New(win);
}

static PyObject *
Expand Down Expand Up @@ -1328,12 +1374,12 @@ static PyMethodDef PyCurses_methods[] = {
/* Initialization function for the module */

void
initncurses()
initcurses()
{
PyObject *m, *d, *x;

/* Create the module and add the functions */
m = Py_InitModule("ncurses", PyCurses_methods);
m = Py_InitModule("curses", PyCurses_methods);

PyCurses_OK = Py_True;
PyCurses_ERR = Py_False;
Expand All @@ -1343,43 +1389,13 @@ initncurses()
d = PyModule_GetDict(m);

/* Make the version available */
PyDict_SetItemString(d,"__version__",
PyDict_SetItemString(d,"version",
PyString_FromString(PyCursesVersion));

/* Here are some defines */
PyDict_SetItemString(d,"OK", PyCurses_OK);
PyDict_SetItemString(d,"ERR",PyCurses_ERR);

#define SetDictChar(string,ch) \
PyDict_SetItemString(d,string,PyInt_FromLong(ch));

/* Here are some graphic symbols you can use */
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
SetDictChar("ACS_LLCORNER",(ACS_LLCORNER));
SetDictChar("ACS_URCORNER",(ACS_URCORNER));
SetDictChar("ACS_LRCORNER",(ACS_LRCORNER));
SetDictChar("ACS_RTEE", (ACS_RTEE));
SetDictChar("ACS_LTEE", (ACS_LTEE));
SetDictChar("ACS_BTEE", (ACS_BTEE));
SetDictChar("ACS_TTEE", (ACS_TTEE));
SetDictChar("ACS_HLINE", (ACS_HLINE));
SetDictChar("ACS_VLINE", (ACS_VLINE));
SetDictChar("ACS_PLUS", (ACS_PLUS));
SetDictChar("ACS_S1", (ACS_S1));
SetDictChar("ACS_S9", (ACS_S9));
SetDictChar("ACS_DIAMOND", (ACS_DIAMOND));
SetDictChar("ACS_CKBOARD", (ACS_CKBOARD));
SetDictChar("ACS_DEGREE", (ACS_DEGREE));
SetDictChar("ACS_PLMINUS", (ACS_PLMINUS));
SetDictChar("ACS_BULLET", (ACS_BULLET));
SetDictChar("ACS_LARROW", (ACS_RARROW));
SetDictChar("ACS_DARROW", (ACS_DARROW));
SetDictChar("ACS_UARROW", (ACS_UARROW));
SetDictChar("ACS_BOARD", (ACS_BOARD));
SetDictChar("ACS_LANTERN", (ACS_LANTERN));
SetDictChar("ACS_BLOCK", (ACS_BLOCK));

/* Here are some attributes you can add to chars to print */
PyDict_SetItemString(d, "A_NORMAL", PyInt_FromLong(A_NORMAL));
PyDict_SetItemString(d, "A_STANDOUT", PyInt_FromLong(A_STANDOUT));
Expand Down

0 comments on commit 56bf235

Please sign in to comment.