Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 56bf235

Browse files
committed
Lance's release 1.1 -- fixes some problems with 1.0
1 parent fbea2f3 commit 56bf235

1 file changed

Lines changed: 52 additions & 36 deletions

File tree

Modules/_cursesmodule.c

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2323
******************************************************************/
2424

2525
/******************************************************************
26-
This is a curses implimentation. I have tried to be as complete
26+
This is a curses implementation. I have tried to be as complete
2727
as possible. If there are functions you need that are not included,
2828
please let me know and/or send me some diffs.
2929
@@ -178,12 +178,19 @@ PyObject *PyCurses_ERR;
178178
179179
Change Log:
180180
181+
Version 1.1: 94/08/31:
182+
Minor fixes given by Guido.
183+
Changed 'ncurses' to 'curses'
184+
Changed '__version__' to 'version'
185+
Added PyErr_Clear() where needed
186+
Moved ACS_* attribute initialization to PyCurses_InitScr() to fix
187+
crash on SGI
181188
Version 1.0: 94/08/30:
182189
This is the first release of this software.
183190
Released to the Internet via [email protected]
184191
185192
******************************************************************/
186-
char *PyCursesVersion = "1.0 first release"
193+
char *PyCursesVersion = "1.1";
187194

188195
/* ------------- SCREEN routines --------------- */
189196
#ifdef NOT_YET
@@ -405,6 +412,7 @@ PyCursesWindow_DelCh(self,arg)
405412
int use_xy = TRUE;
406413
if (!PyArg_Parse(arg,"(ii);y,x", &y, &x))
407414
use_xy = FALSE;
415+
PyErr_Clear();
408416
if (use_xy == TRUE)
409417
rtn = mvwdelch(self->win,y,x);
410418
else
@@ -750,6 +758,7 @@ PyCursesWindow_GetCh(self,arg)
750758
int rtn;
751759
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
752760
use_xy = FALSE;
761+
PyErr_Clear();
753762
if (use_xy == TRUE)
754763
rtn = mvwgetch(self->win,y,x);
755764
else
@@ -768,6 +777,7 @@ PyCursesWindow_GetStr(self,arg)
768777
int rtn2;
769778
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
770779
use_xy = FALSE;
780+
PyErr_Clear();
771781
if (use_xy == TRUE)
772782
rtn2 = mvwgetstr(self->win,y,x,rtn);
773783
else
@@ -787,6 +797,7 @@ PyCursesWindow_InCh(self,arg)
787797
int rtn;
788798
if (!PyArg_Parse(arg,"(ii);y,x",&y,&x))
789799
use_xy = FALSE;
800+
PyErr_Clear();
790801
if (use_xy == TRUE)
791802
rtn = mvwinch(self->win,y,x);
792803
else
@@ -1028,14 +1039,49 @@ PyCurses_InitScr(self, args)
10281039
PyObject * args;
10291040
{
10301041
static int already_inited = FALSE;
1042+
WINDOW *win;
10311043
if (!PyArg_NoArgs(args))
10321044
return (PyObject *)NULL;
10331045
if (already_inited == TRUE) {
10341046
wrefresh(stdscr);
10351047
return (PyObject *)PyCursesWindow_New(stdscr);
10361048
}
10371049
already_inited = TRUE;
1038-
return (PyObject *)PyCursesWindow_New(initscr());
1050+
1051+
win = initscr();
1052+
1053+
/* This was moved from initcurses() because core dumped on SGI */
1054+
#define SetDictChar(string,ch) \
1055+
PyDict_SetItemString(d,string,PyInt_FromLong(ch));
1056+
1057+
/* Here are some graphic symbols you can use */
1058+
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
1059+
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
1060+
SetDictChar("ACS_LLCORNER",(ACS_LLCORNER));
1061+
SetDictChar("ACS_URCORNER",(ACS_URCORNER));
1062+
SetDictChar("ACS_LRCORNER",(ACS_LRCORNER));
1063+
SetDictChar("ACS_RTEE", (ACS_RTEE));
1064+
SetDictChar("ACS_LTEE", (ACS_LTEE));
1065+
SetDictChar("ACS_BTEE", (ACS_BTEE));
1066+
SetDictChar("ACS_TTEE", (ACS_TTEE));
1067+
SetDictChar("ACS_HLINE", (ACS_HLINE));
1068+
SetDictChar("ACS_VLINE", (ACS_VLINE));
1069+
SetDictChar("ACS_PLUS", (ACS_PLUS));
1070+
SetDictChar("ACS_S1", (ACS_S1));
1071+
SetDictChar("ACS_S9", (ACS_S9));
1072+
SetDictChar("ACS_DIAMOND", (ACS_DIAMOND));
1073+
SetDictChar("ACS_CKBOARD", (ACS_CKBOARD));
1074+
SetDictChar("ACS_DEGREE", (ACS_DEGREE));
1075+
SetDictChar("ACS_PLMINUS", (ACS_PLMINUS));
1076+
SetDictChar("ACS_BULLET", (ACS_BULLET));
1077+
SetDictChar("ACS_LARROW", (ACS_RARROW));
1078+
SetDictChar("ACS_DARROW", (ACS_DARROW));
1079+
SetDictChar("ACS_UARROW", (ACS_UARROW));
1080+
SetDictChar("ACS_BOARD", (ACS_BOARD));
1081+
SetDictChar("ACS_LANTERN", (ACS_LANTERN));
1082+
SetDictChar("ACS_BLOCK", (ACS_BLOCK));
1083+
1084+
return (PyObject *)PyCursesWindow_New(win);
10391085
}
10401086

10411087
static PyObject *
@@ -1328,12 +1374,12 @@ static PyMethodDef PyCurses_methods[] = {
13281374
/* Initialization function for the module */
13291375

13301376
void
1331-
initncurses()
1377+
initcurses()
13321378
{
13331379
PyObject *m, *d, *x;
13341380

13351381
/* Create the module and add the functions */
1336-
m = Py_InitModule("ncurses", PyCurses_methods);
1382+
m = Py_InitModule("curses", PyCurses_methods);
13371383

13381384
PyCurses_OK = Py_True;
13391385
PyCurses_ERR = Py_False;
@@ -1343,43 +1389,13 @@ initncurses()
13431389
d = PyModule_GetDict(m);
13441390

13451391
/* Make the version available */
1346-
PyDict_SetItemString(d,"__version__",
1392+
PyDict_SetItemString(d,"version",
13471393
PyString_FromString(PyCursesVersion));
13481394

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

1353-
#define SetDictChar(string,ch) \
1354-
PyDict_SetItemString(d,string,PyInt_FromLong(ch));
1355-
1356-
/* Here are some graphic symbols you can use */
1357-
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
1358-
SetDictChar("ACS_ULCORNER",(ACS_ULCORNER));
1359-
SetDictChar("ACS_LLCORNER",(ACS_LLCORNER));
1360-
SetDictChar("ACS_URCORNER",(ACS_URCORNER));
1361-
SetDictChar("ACS_LRCORNER",(ACS_LRCORNER));
1362-
SetDictChar("ACS_RTEE", (ACS_RTEE));
1363-
SetDictChar("ACS_LTEE", (ACS_LTEE));
1364-
SetDictChar("ACS_BTEE", (ACS_BTEE));
1365-
SetDictChar("ACS_TTEE", (ACS_TTEE));
1366-
SetDictChar("ACS_HLINE", (ACS_HLINE));
1367-
SetDictChar("ACS_VLINE", (ACS_VLINE));
1368-
SetDictChar("ACS_PLUS", (ACS_PLUS));
1369-
SetDictChar("ACS_S1", (ACS_S1));
1370-
SetDictChar("ACS_S9", (ACS_S9));
1371-
SetDictChar("ACS_DIAMOND", (ACS_DIAMOND));
1372-
SetDictChar("ACS_CKBOARD", (ACS_CKBOARD));
1373-
SetDictChar("ACS_DEGREE", (ACS_DEGREE));
1374-
SetDictChar("ACS_PLMINUS", (ACS_PLMINUS));
1375-
SetDictChar("ACS_BULLET", (ACS_BULLET));
1376-
SetDictChar("ACS_LARROW", (ACS_RARROW));
1377-
SetDictChar("ACS_DARROW", (ACS_DARROW));
1378-
SetDictChar("ACS_UARROW", (ACS_UARROW));
1379-
SetDictChar("ACS_BOARD", (ACS_BOARD));
1380-
SetDictChar("ACS_LANTERN", (ACS_LANTERN));
1381-
SetDictChar("ACS_BLOCK", (ACS_BLOCK));
1382-
13831399
/* Here are some attributes you can add to chars to print */
13841400
PyDict_SetItemString(d, "A_NORMAL", PyInt_FromLong(A_NORMAL));
13851401
PyDict_SetItemString(d, "A_STANDOUT", PyInt_FromLong(A_STANDOUT));

0 commit comments

Comments
 (0)