diff -r c7638be1e430 Lib/test/test_curses.py --- a/Lib/test/test_curses.py Thu Dec 08 00:33:14 2011 +0100 +++ b/Lib/test/test_curses.py Thu Dec 08 00:43:45 2011 +0100 @@ -160,7 +160,7 @@ curses.nocbreak, curses.noecho, curses.nonl, curses.noqiflush, curses.noraw, curses.reset_prog_mode, curses.termattrs, - curses.termname, curses.erasechar, curses.getsyx]: + curses.termname, curses.erasechar]: func() # Functions that actually need arguments @@ -186,7 +186,6 @@ curses.putp(b'abc') curses.qiflush() curses.raw() ; curses.raw(1) - curses.setsyx(5,5) curses.tigetflag('hc') curses.tigetnum('co') curses.tigetstr('cr') diff -r c7638be1e430 Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Thu Dec 08 00:33:14 2011 +0100 +++ b/Modules/_cursesmodule.c Thu Dec 08 00:43:45 2011 +0100 @@ -125,11 +125,21 @@ #include #endif -#if !defined(HAVE_NCURSES_H) && (defined(sgi) || defined(__sun) || defined(SCO5)) +#if (defined(sgi) || defined(__sun) || defined(SCO5)) +#define SOLARIS +#endif + +#if !defined(HAVE_NCURSES_H) && defined(SOLARIS) + +#undef WINDOW_HAS_FLAGS + #define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#ifndef _XOPEN_CURSES typedef chtype attr_t; /* No attr_t type is available */ #endif +#endif + #if defined(_AIX) #define STRICT_SYSV_CURSES #endif @@ -630,11 +640,12 @@ type = PyCurses_ConvertToCchar_t(self, chobj, &ch); #endif if (type == 1) { + chtype ch_attr = ch | attr; funcname = "addch"; - if (use_xy == TRUE) - rtn = mvwaddch(self->win,y,x, ch | attr); - else { - rtn = waddch(self->win, ch | attr); + if (use_xy == TRUE) { + rtn = mvwaddch(self->win, y, x, ch_attr); + } else { + rtn = waddch(self->win, ch_attr); } } else { @@ -692,7 +703,6 @@ if (strtype == 0) return NULL; if (use_attr == TRUE) { - attr_old = getattrs(self->win); (void)wattrset(self->win,attr); } #ifdef HAVE_NCURSESW @@ -715,8 +725,6 @@ rtn = waddstr(self->win,str); Py_DECREF(bytesobj); } - if (use_attr == TRUE) - (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } @@ -769,7 +777,6 @@ return NULL; if (use_attr == TRUE) { - attr_old = getattrs(self->win); (void)wattrset(self->win,attr); } #ifdef HAVE_NCURSESW @@ -792,8 +799,6 @@ rtn = waddnstr(self->win,str,n); Py_DECREF(bytesobj); } - if (use_attr == TRUE) - (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } @@ -1458,7 +1463,6 @@ return NULL; if (use_attr == TRUE) { - attr_old = getattrs(self->win); (void)wattrset(self->win,attr); } #ifdef HAVE_NCURSESW @@ -1481,8 +1485,6 @@ rtn = winsstr(self->win,str); Py_DECREF(bytesobj); } - if (use_attr == TRUE) - (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } @@ -1536,7 +1538,6 @@ return NULL; if (use_attr == TRUE) { - attr_old = getattrs(self->win); (void)wattrset(self->win,attr); } #ifdef HAVE_NCURSESW @@ -1559,8 +1560,6 @@ rtn = winsnstr(self->win,str,n); Py_DECREF(bytesobj); } - if (use_attr == TRUE) - (void)wattrset(self->win,attr_old); return PyCursesCheckERR(rtn, funcname); } @@ -2213,19 +2212,6 @@ return PyBytes_FromStringAndSize(&ch, 1); } -static PyObject * -PyCurses_getsyx(PyObject *self) -{ - int x = 0; - int y = 0; - - PyCursesInitialised; - - getsyx(y, x); - - return Py_BuildValue("(ii)", y, x); -} - #ifdef NCURSES_MOUSE_VERSION static PyObject * PyCurses_GetMouse(PyObject *self) @@ -2909,26 +2895,6 @@ #endif /* HAVE_CURSES_RESIZE_TERM */ static PyObject * -PyCurses_setsyx(PyObject *self, PyObject *args) -{ - 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; -} - -static PyObject * PyCurses_Start_Color(PyObject *self) { int code; @@ -3194,7 +3160,6 @@ {"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}, @@ -3245,7 +3210,6 @@ {"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}, @@ -3413,6 +3377,15 @@ int key; char *key_n; char *key_n2; + +#if !defined(KEY_MIN) & defined(__KEY_MIN) +# define KEY_MIN (__KEY_MIN) +#endif + +#if !defined(KEY_MAX) & defined(__KEY_MAX) +# define KEY_MAX (__KEY_MAX) +#endif + #if !defined(__NetBSD__) for (key=KEY_MIN;key < KEY_MAX; key++) { key_n = (char *)keyname(key); diff -r c7638be1e430 setup.py --- a/setup.py Thu Dec 08 00:33:14 2011 +0100 +++ b/setup.py Thu Dec 08 00:43:45 2011 +0100 @@ -1170,7 +1170,11 @@ # provided by the ncurses library. curses_defines = [] curses_includes = [] + curses_library_dirs = [] panel_library = 'panel' + if platform == 'sunos5': + curses_includes.append('/usr/xpg4/include') + curses_library_dirs.append('/usr/xpg4/lib') if curses_library == 'ncursesw': curses_defines.append(('HAVE_NCURSESW', '1')) curses_includes.append('/usr/include/ncursesw') @@ -1183,7 +1187,9 @@ exts.append( Extension('_curses', ['_cursesmodule.c'], include_dirs=curses_includes, define_macros=curses_defines, - libraries = curses_libs) ) + library_dirs=curses_library_dirs, + runtime_library_dirs=curses_library_dirs, + libraries=curses_libs) ) elif curses_library == 'curses' and platform != 'darwin': # OSX has an old Berkeley curses, not good enough for # the _curses module. @@ -1195,7 +1201,10 @@ curses_libs = ['curses'] exts.append( Extension('_curses', ['_cursesmodule.c'], + include_dirs=curses_includes, define_macros=curses_defines, + library_dirs=curses_library_dirs, + runtime_library_dirs=curses_library_dirs, libraries = curses_libs) ) else: missing.append('_curses') @@ -1205,6 +1214,8 @@ self.compiler.find_library_file(lib_dirs, panel_library)): exts.append( Extension('_curses_panel', ['_curses_panel.c'], include_dirs=curses_includes, + library_dirs=curses_library_dirs, + runtime_library_dirs=curses_library_dirs, libraries = [panel_library] + curses_libs) ) else: missing.append('_curses_panel')