| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | /***********************************************************
 | 
					
						
							|  |  |  | Copyright 1994 by Lance Ellinghouse, | 
					
						
							|  |  |  | Cathedral City, California Republic, United States of America. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         All Rights Reserved | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Permission to use, copy, modify, and distribute this software and its  | 
					
						
							|  |  |  | documentation for any purpose and without fee is hereby granted,  | 
					
						
							|  |  |  | provided that the above copyright notice appear in all copies and that | 
					
						
							|  |  |  | both that copyright notice and this permission notice appear in  | 
					
						
							|  |  |  | supporting documentation, and that the name of Lance Ellinghouse | 
					
						
							|  |  |  | not be used in advertising or publicity pertaining to distribution  | 
					
						
							|  |  |  | of the software without specific, written prior permission. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO | 
					
						
							|  |  |  | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | 
					
						
							|  |  |  | FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL,  | 
					
						
							|  |  |  | INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING  | 
					
						
							|  |  |  | FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,  | 
					
						
							|  |  |  | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  | 
					
						
							|  |  |  | WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ******************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | /******************************************************************
 | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  | This is a curses implementation. I have tried to be as complete | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | as possible. If there are functions you need that are not included, | 
					
						
							|  |  |  | please let me know and/or send me some diffs. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | There are 3 basic types exported by this module: | 
					
						
							|  |  |  |    1) Screen - This is not currently used | 
					
						
							|  |  |  |    2) Window - This is the basic type. This is equivalent to "WINDOW *". | 
					
						
							|  |  |  |    3) Pad    - This is similar to Window, but works with Pads as defined | 
					
						
							|  |  |  |                in curses. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Most of the routines can be looked up using the curses man page. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Here is a list of the currently supported methods and attributes | 
					
						
							|  |  |  | in the curses module: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return Value      Func/Attr            Description | 
					
						
							|  |  |  | -------------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | StringObject      version              A string representing the current | 
					
						
							|  |  |  |                                        version of this module. | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | WindowObject      initscr()            This initializes the screen for use | 
					
						
							|  |  |  | None              endwin()             Closes down the screen and returns | 
					
						
							|  |  |  |                                        things as they were before calling | 
					
						
							|  |  |  |                                        initscr() | 
					
						
							|  |  |  | True/FalseObject  isendwin()           Has endwin() been called? | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              doupdate()           Updates screen | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | WindowObject      newwin(nlines,ncols,begin_y,begin_x) | 
					
						
							|  |  |  |                   newwin(begin_y,begin_x) | 
					
						
							|  |  |  |                                        newwin() creates and returns | 
					
						
							|  |  |  |                                        a new window. | 
					
						
							|  |  |  | None              beep()               Beep the screen if possible | 
					
						
							|  |  |  | None              flash()              Flash the screen if possible | 
					
						
							|  |  |  | None              ungetch(int)         Push the int back so next getch() | 
					
						
							|  |  |  |                                        will return it. | 
					
						
							|  |  |  |                                        Note: argument is an INT, not a CHAR | 
					
						
							|  |  |  | None              flushinp()           Flush all input buffers | 
					
						
							|  |  |  | None              cbreak()             Enter cbreak mode | 
					
						
							|  |  |  | None              nocbreak()           Leave cbreak mode | 
					
						
							|  |  |  | None              echo()               Enter echo mode | 
					
						
							|  |  |  | None              noecho()             Leave echo mode | 
					
						
							|  |  |  | None              nl()                 Enter nl mode | 
					
						
							|  |  |  | None              nonl()               Leave nl mode | 
					
						
							|  |  |  | None              raw()                Enter raw mode | 
					
						
							|  |  |  | None              noraw()              Leave raw mode | 
					
						
							|  |  |  | None              intrflush(int)       Set or reset interruptable flush | 
					
						
							|  |  |  |                                        mode, int=1 if set, 0 if notset. | 
					
						
							|  |  |  | None              meta(int)            Allow 8 bit or 7 bit chars. | 
					
						
							|  |  |  |                                        int=1 is 8 bit, int=0 is 7 bit | 
					
						
							|  |  |  | StringObject      keyname(int)         return the text representation | 
					
						
							|  |  |  |                                        of a KEY_ value. (see below) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Here is a list of the currently supported methods and attributes | 
					
						
							|  |  |  | in the WindowObject: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return Value      Func/Attr            Description | 
					
						
							|  |  |  | -------------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              refresh()            Do refresh | 
					
						
							|  |  |  | None              nooutrefresh()       Mark for refresh but wait | 
					
						
							|  |  |  | None              mvwin(new_y,new_x)   Move Window | 
					
						
							|  |  |  | None              move(new_y,new_x)    Move Cursor | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | WindowObject      subwin(nlines,ncols,begin_y,begin_x) | 
					
						
							|  |  |  |                   subwin(begin_y,begin_x) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              addch(y,x,ch,attr) | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  |                   addch(y,x,ch) | 
					
						
							|  |  |  |                   addch(ch,attr) | 
					
						
							|  |  |  |                   addch(ch) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              insch(y,x,ch,attr) | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  |                   insch(y,x,ch) | 
					
						
							|  |  |  |                   insch(ch,attr) | 
					
						
							|  |  |  |                   insch(ch) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              delch(y,x) | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  |                   delch() | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              echochar(ch,attr) | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  |                   echochar(ch) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              addstr(y,x,str,attr) | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  |                   addstr(y,x,str) | 
					
						
							|  |  |  |                   addstr(str,attr) | 
					
						
							|  |  |  |                   addstr(str) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              attron(attr) | 
					
						
							|  |  |  | None              attroff(attr) | 
					
						
							|  |  |  | None              attrset(sttr) | 
					
						
							|  |  |  | None              standend() | 
					
						
							|  |  |  | None              standout() | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | None              border(ls,rs,ts,bs,tl,tr,bl,br)   (accepts 0-8 INT args) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | None              box(vertch,horch)    vertch and horch are INTS | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  |                   box() | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | None              hline(y,x,ch,n) | 
					
						
							|  |  |  |                   hline(ch,n) | 
					
						
							|  |  |  | None              vline(y,x,ch,n) | 
					
						
							|  |  |  |                   vline(ch,n) | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | None              erase() | 
					
						
							|  |  |  | None              deleteln() | 
					
						
							|  |  |  | None              insertln() | 
					
						
							|  |  |  | (y,x)             getyx() | 
					
						
							|  |  |  | (y,x)             getbegyx() | 
					
						
							|  |  |  | (y,x)             getmaxyx() | 
					
						
							|  |  |  | None              clear() | 
					
						
							|  |  |  | None              clrtobot() | 
					
						
							|  |  |  | None              clrtoeol() | 
					
						
							|  |  |  | None              scroll() | 
					
						
							|  |  |  | None              touchwin() | 
					
						
							|  |  |  | None              touchline(start,count) | 
					
						
							|  |  |  | IntObject         getch(y,x) | 
					
						
							|  |  |  |                   getch() | 
					
						
							|  |  |  | StringObject      getstr(y,x) | 
					
						
							|  |  |  |                   getstr() | 
					
						
							|  |  |  | IntObject         inch(y,x) | 
					
						
							|  |  |  |                   inch() | 
					
						
							|  |  |  | None              clearok(int)      int=0 or int=1 | 
					
						
							|  |  |  | None              idlok(int)        int=0 or int=1 | 
					
						
							|  |  |  | None              leaveok(int)      int=0 or int=1 | 
					
						
							|  |  |  | None              scrollok(int)     int=0 or int=1 | 
					
						
							|  |  |  | None              setscrreg(top,bottom) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:54:04 +00:00
										 |  |  | None              keypad(int)       int=0 or int=1 | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | None              nodelay(int)      int=0 or int=1 | 
					
						
							|  |  |  | None              notimeout(int)    int=0 or int=1 | 
					
						
							|  |  |  | ******************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | /* curses module */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-14 13:32:22 +00:00
										 |  |  | #include "Python.h"
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include <curses.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	PyObject_HEAD | 
					
						
							|  |  |  | 	SCREEN *scr; | 
					
						
							|  |  |  | } PyCursesScreenObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	PyObject_HEAD | 
					
						
							|  |  |  | 	WINDOW *win; | 
					
						
							|  |  |  | 	WINDOW *parent; | 
					
						
							|  |  |  | } PyCursesWindowObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  | 	PyObject_HEAD | 
					
						
							|  |  |  | 	WINDOW *pad; | 
					
						
							|  |  |  | } PyCursesPadObject; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | staticforward PyTypeObject PyCursesScreen_Type; | 
					
						
							|  |  |  | staticforward PyTypeObject PyCursesWindow_Type; | 
					
						
							|  |  |  | staticforward PyTypeObject PyCursesPad_Type; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PyCursesScreen_Check(v)	 ((v)->ob_type == &PyCursesScreen_Type)
 | 
					
						
							|  |  |  | #define PyCursesWindow_Check(v)	 ((v)->ob_type == &PyCursesWindow_Type)
 | 
					
						
							|  |  |  | #define PyCursesPad_Check(v)	 ((v)->ob_type == &PyCursesPad_Type)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Defines */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | static PyObject *PyCursesError;		/* For exception curses.error */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Catch-all error messages */ | 
					
						
							|  |  |  | static char *catchall_ERR  = "curses function returned ERR"; | 
					
						
							|  |  |  | static char *catchall_NULL = "curses function returned NULL"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | /* Tells whether initscr() has been called to initialise curses  */ | 
					
						
							|  |  |  | static int initialised = FALSE; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | #define ARG_COUNT(X) \
 | 
					
						
							|  |  |  | 	(((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1)) | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | /******************************************************************
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Change Log: | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | Version 1.2: 95/02/23 (Steve Clift) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     Fixed several potential core-dumping bugs. | 
					
						
							|  |  |  |     Reworked arg parsing where variable arg lists are used. | 
					
						
							|  |  |  |     Generate exceptions when ERR or NULL is returned by curses functions. | 
					
						
							|  |  |  |     Changed return types to match SysV Curses manual descriptions. | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |     Added keypad() to window method list. | 
					
						
							|  |  |  |     Added border(), hline() and vline() window methods. | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  | 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 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | Version 1.0: 94/08/30: | 
					
						
							|  |  |  |     This is the first release of this software. | 
					
						
							|  |  |  |     Released to the Internet via python-list@cwi.nl | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ******************************************************************/ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:54:04 +00:00
										 |  |  | char *PyCursesVersion = "1.2"; | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * Check the return code from a curses function and return None  | 
					
						
							|  |  |  |  * or raise an exception as appropriate. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesCheckERR(code, fname) | 
					
						
							|  |  |  |      int code; | 
					
						
							|  |  |  |      char *fname; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   char buf[100]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (code != ERR) { | 
					
						
							|  |  |  |     Py_INCREF(Py_None); | 
					
						
							|  |  |  |     return Py_None; | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     if (fname == NULL) { | 
					
						
							|  |  |  |       PyErr_SetString(PyCursesError, catchall_ERR); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       strcpy(buf, fname); | 
					
						
							|  |  |  |       strcat(buf, "() returned ERR"); | 
					
						
							|  |  |  |       PyErr_SetString(PyCursesError, buf); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | static int | 
					
						
							|  |  |  | PyCursesInitialised() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (initialised == TRUE) | 
					
						
							|  |  |  |     return 1; | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     PyErr_SetString(PyCursesError, "must call initscr() first"); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | /* ------------- SCREEN routines --------------- */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | #ifdef NOT_YET
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesScreen_New(arg) | 
					
						
							|  |  |  | 	PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |         char *term_type; | 
					
						
							|  |  |  | 	PyFileObject *in_fo; | 
					
						
							|  |  |  | 	PyFileObject *out_fo; | 
					
						
							|  |  |  | 	PyCursesScreenObject *xp; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 	xp = PyObject_NEW(PyCursesScreenObject, &PyCursesScreen_Type); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 	if (xp == NULL) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	return (PyObject *)xp; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | /* ------------- WINDOW routines --------------- */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_New(win) | 
					
						
							|  |  |  | 	WINDOW *win; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyCursesWindowObject *wo; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 	if (wo == NULL) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	wo->win = win; | 
					
						
							|  |  |  | 	wo->parent = (WINDOW *)NULL; | 
					
						
							|  |  |  | 	return (PyObject *)wo; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | PyCursesWindow_Dealloc(wo) | 
					
						
							|  |  |  | 	PyCursesWindowObject *wo; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (wo->win != stdscr) | 
					
						
							|  |  |  |     delwin(wo->win); | 
					
						
							|  |  |  |   PyMem_DEL(wo); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Refresh(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(wrefresh(self->win), "wrefresh"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_NoOutRefresh(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(wnoutrefresh(self->win), "wnoutrefresh"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_MoveWin(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   if (!PyArg_Parse(arg,"(ii);y,x", &y, &x)) | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(mvwin(self->win,y,x), "mvwin"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Move(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   if (!PyArg_Parse(arg,"(ii);y,x", &y, &x)) | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(wmove(self->win,y,x), "wmove"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_SubWin(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   WINDOW *win; | 
					
						
							|  |  |  |   PyCursesWindowObject *rtn_win; | 
					
						
							|  |  |  |   int nlines, ncols, begin_y, begin_x; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   nlines = 0; | 
					
						
							|  |  |  |   ncols  = 0; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(ii);begin_y,begin_x",&begin_y,&begin_x)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 4: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg, "(iiii);nlines,ncols,begin_y,begin_x", | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 		   &nlines,&ncols,&begin_y,&begin_x)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "subwin requires 2 or 4 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   win = subwin(self->win,nlines,ncols,begin_y,begin_x); | 
					
						
							|  |  |  |   if (win == NULL) { | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     PyErr_SetString(PyCursesError, catchall_NULL); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   } | 
					
						
							|  |  |  |   rtn_win = (PyCursesWindowObject *)PyCursesWindow_New(win); | 
					
						
							|  |  |  |   rtn_win->parent = self->win; | 
					
						
							|  |  |  |   return (PyObject *)rtn_win; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_AddCh(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int rtn; | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   int ch; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   int attr, attr_old; | 
					
						
							|  |  |  |   int use_xy = FALSE, use_attr = FALSE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |     case 1: | 
					
						
							|  |  |  |       if (!PyArg_Parse(arg, "i;ch", &ch)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     case 2: | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       if (!PyArg_Parse(arg,"(ii);ch,attr", &ch, &attr)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |       use_attr = TRUE; | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     case 3: | 
					
						
							|  |  |  |       if (!PyArg_Parse(arg,"(iii);y,x,ch", &y, &x, &ch)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							|  |  |  |       use_xy = TRUE; | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case 4: | 
					
						
							|  |  |  |       if (!PyArg_Parse(arg,"(iiii);y,x,ch,attr", &y, &x, &ch, &attr)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							|  |  |  |       use_xy = use_attr = TRUE; | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     default: | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       PyErr_SetString(PyExc_TypeError, "addch requires 1 to 4 arguments"); | 
					
						
							|  |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   if (use_attr == TRUE) { | 
					
						
							|  |  |  |     attr_old = getattrs(self->win); | 
					
						
							|  |  |  |     wattrset(self->win,attr); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (use_xy == TRUE) | 
					
						
							|  |  |  |     rtn = mvwaddch(self->win,y,x,ch); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     rtn = waddch(self->win,ch); | 
					
						
							|  |  |  |   if (use_attr == TRUE) | 
					
						
							|  |  |  |     wattrset(self->win,attr_old); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return PyCursesCheckERR(rtn, "[mv]waddch"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_InsCh(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int rtn; | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   int ch; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   int attr, attr_old; | 
					
						
							|  |  |  |   int use_xy = TRUE, use_attr = FALSE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |     case 1: | 
					
						
							|  |  |  |       if (!PyArg_Parse(arg, "i;ch", &ch)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     case 2: | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       if (!PyArg_Parse(arg,"(ii);ch,attr", &ch, &attr)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |       use_attr = TRUE; | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     case 3: | 
					
						
							|  |  |  |       if (!PyArg_Parse(arg,"(iii);y,x,ch", &y, &x, &ch)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							|  |  |  |       use_xy = TRUE; | 
					
						
							|  |  |  |       break; | 
					
						
							|  |  |  |     case 4: | 
					
						
							|  |  |  |       if (!PyArg_Parse(arg,"(iiii);y,x,ch,attr", &y, &x, &ch, &attr)) | 
					
						
							|  |  |  |         return NULL; | 
					
						
							|  |  |  |       use_xy = use_attr = TRUE; | 
					
						
							|  |  |  |       break; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     default: | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       PyErr_SetString(PyExc_TypeError, "insch requires 1 to 4 arguments"); | 
					
						
							|  |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   if (use_attr == TRUE) { | 
					
						
							|  |  |  |     attr_old = getattrs(self->win); | 
					
						
							|  |  |  |     wattrset(self->win,attr); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (use_xy == TRUE) | 
					
						
							|  |  |  |     rtn = mvwinsch(self->win,y,x,ch); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     rtn = winsch(self->win,ch); | 
					
						
							|  |  |  |   if (use_attr == TRUE) | 
					
						
							|  |  |  |     wattrset(self->win,attr_old); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return PyCursesCheckERR(rtn, "[mv]winsch"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_DelCh(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int rtn; | 
					
						
							|  |  |  |   int x, y; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 0: | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     rtn = wdelch(self->win); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     break; | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(ii);y,x", &y, &x)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     rtn = mvwdelch(self->win,y,x); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "delch requires 0 or 2 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return PyCursesCheckERR(rtn, "[mv]wdelch"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_EchoChar(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int rtn; | 
					
						
							|  |  |  |   int ch; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   int attr, attr_old; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 1: | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     if (!PyArg_Parse(arg,"i;ch", &ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |     rtn = wechochar(self->win,ch); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(ii);ch,attr", &ch, &attr)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     attr_old = getattrs(self->win); | 
					
						
							|  |  |  |     wattrset(self->win,attr); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     rtn = wechochar(self->win,ch); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     wattrset(self->win,attr_old); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return PyCursesCheckERR(rtn, "wechochar"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_AddStr(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int rtn; | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   char *str; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   int attr, attr_old; | 
					
						
							|  |  |  |   int use_xy = FALSE, use_attr = FALSE; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 1: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"s;str", &str)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(si);str,attr", &str, &attr)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     use_attr = TRUE; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 3: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(iis);y,x,str", &y, &x, &str)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     use_xy = TRUE; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 4: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(iisi);y,x,str,attr", &y, &x, &str, &attr)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     use_xy = use_attr = TRUE; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "addstr requires 1 to 4 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   if (use_attr == TRUE) { | 
					
						
							|  |  |  |     attr_old = getattrs(self->win); | 
					
						
							|  |  |  |     wattrset(self->win,attr); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (use_xy == TRUE) | 
					
						
							|  |  |  |     rtn = mvwaddstr(self->win,y,x,str); | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     rtn = waddstr(self->win,str); | 
					
						
							|  |  |  |   if (use_attr == TRUE) | 
					
						
							|  |  |  |     wattrset(self->win,attr_old); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return PyCursesCheckERR(rtn, "[mv]waddstr"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_AttrOn(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;attr", &ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   wattron(self->win,ch); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_AttrOff(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;attr", &ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   wattroff(self->win,ch); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_AttrSet(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;attr", &ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   wattrset(self->win,ch); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_StandEnd(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   wstandend(self->win); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_StandOut(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   wstandout(self->win); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Border(self, args) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject *args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ls, rs, ts, bs, tl, tr, bl, br; | 
					
						
							|  |  |  |   ls = rs = ts = bs = tl = tr = bl = br = 0; | 
					
						
							|  |  |  |   if (!PyArg_ParseTuple(args,"|iiiiiiii;ls,rs,ts,bs,tl,tr,bl,br", | 
					
						
							|  |  |  |                         &ls, &rs, &ts, &bs, &tl, &tr, &bl, &br)) | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   wborder(self->win, ls, rs, ts, bs, tl, tr, bl, br); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Box(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch1=0,ch2=0; | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg)) { | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     PyErr_Clear(); | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |     if (!PyArg_Parse(arg,"(ii);vertch,horch", &ch1, &ch2)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   box(self->win,ch1,ch2); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							|  |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Hline(self, args) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject *args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch, n, x, y, code = OK; | 
					
						
							|  |  |  |   switch (ARG_COUNT(args)) { | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(args, "(ii);ch,n", &ch, &n)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 4: | 
					
						
							|  |  |  |     if (!PyArg_Parse(args, "(iiii);y,x,ch,n", &y, &x, &ch, &n)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     code = wmove(self->win, y, x); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "hline requires 2 or 4 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (code != ERR) | 
					
						
							|  |  |  |     whline(self->win, ch, n); | 
					
						
							|  |  |  |   return PyCursesCheckERR(code, "wmove"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Vline(self, args) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject *args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch, n, x, y, code = OK; | 
					
						
							|  |  |  |   switch (ARG_COUNT(args)) { | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(args, "(ii);ch,n", &ch, &n)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 4: | 
					
						
							|  |  |  |     if (!PyArg_Parse(args, "(iiii);y,x,ch,n", &y, &x, &ch, &n)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     code = wmove(self->win, y, x); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "vline requires 2 or 4 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if (code != ERR) | 
					
						
							|  |  |  |     wvline(self->win, ch, n); | 
					
						
							|  |  |  |   return PyCursesCheckERR(code, "wmove"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Erase(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   werase(self->win); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_DeleteLine(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(wdeleteln(self->win), "wdeleteln"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_InsertLine(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(winsertln(self->win), "winsertln"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_GetYX(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   getyx(self->win,y,x); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_BuildValue("(ii)", y, x); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_GetBegYX(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   getbegyx(self->win,y,x); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_BuildValue("(ii)", y, x); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_GetMaxYX(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   getmaxyx(self->win,y,x); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_BuildValue("(ii)", y, x); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Clear(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   wclear(self->win); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_ClearToBottom(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   wclrtobot(self->win); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_ClearToEOL(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   wclrtoeol(self->win); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_Scroll(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(scroll(self->win), "scroll"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_TouchWin(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(arg)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(touchwin(self->win), "touchwin"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_TouchLine(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int st, cnt; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   if (!PyArg_Parse(arg,"(ii);start,count",&st,&cnt)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(touchline(self->win,st,cnt), "touchline"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_GetCh(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   int rtn; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 0: | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     rtn = wgetch(self->win); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     break; | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     rtn = mvwgetch(self->win,y,x); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return PyInt_FromLong((long) rtn); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_GetStr(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   char rtn[1024]; /* This should be big enough.. I hope */ | 
					
						
							|  |  |  |   int rtn2; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 0: | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     rtn2 = wgetstr(self->win,rtn); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     break; | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     rtn2 = mvwgetstr(self->win,y,x,rtn); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "getstr requires 0 or 2 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   if (rtn2 == ERR) | 
					
						
							|  |  |  |     rtn[0] = 0; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return PyString_FromString(rtn); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_InCh(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   int x, y, rtn; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 0: | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     rtn = winch(self->win); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     break; | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(ii);y,x",&y,&x)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     rtn = mvwinch(self->win,y,x); | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return PyInt_FromLong((long) rtn); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_ClearOk(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int val; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1) or False(0)",&val)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   clearok(self->win,val); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_IdlOk(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int val; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1) or False(0)",&val)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   idlok(self->win,val); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_LeaveOk(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int val; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1) or False(0)",&val)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   leaveok(self->win,val); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_ScrollOk(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int val; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1) or False(0)",&val)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   scrollok(self->win,val); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_SetScrollRegion(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject *self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int x, y; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"(ii);top, bottom",&y,&x)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(wsetscrreg(self->win,y,x), "wsetscrreg"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_KeyPad(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1), False(0)",&ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   keypad(self->win,ch); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_NoDelay(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1), False(0)",&ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   nodelay(self->win,ch); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_NoTimeout(self,arg) | 
					
						
							|  |  |  |      PyCursesWindowObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1), False(0)",&ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   notimeout(self->win,ch); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef PyCursesWindow_Methods[] = { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  | 	{"refresh",         PyCursesWindow_Refresh}, | 
					
						
							|  |  |  | 	{"nooutrefresh",    PyCursesWindow_NoOutRefresh}, | 
					
						
							|  |  |  | 	{"mvwin",           PyCursesWindow_MoveWin}, | 
					
						
							|  |  |  | 	{"move",            PyCursesWindow_Move}, | 
					
						
							|  |  |  | 	{"subwin",          PyCursesWindow_SubWin}, | 
					
						
							|  |  |  | 	{"addch",           PyCursesWindow_AddCh}, | 
					
						
							|  |  |  | 	{"insch",           PyCursesWindow_InsCh}, | 
					
						
							|  |  |  | 	{"delch",           PyCursesWindow_DelCh}, | 
					
						
							|  |  |  | 	{"echochar",        PyCursesWindow_EchoChar}, | 
					
						
							|  |  |  | 	{"addstr",          PyCursesWindow_AddStr}, | 
					
						
							|  |  |  | 	{"attron",          PyCursesWindow_AttrOn}, | 
					
						
							|  |  |  | 	{"attroff",         PyCursesWindow_AttrOff}, | 
					
						
							|  |  |  | 	{"attrset",         PyCursesWindow_AttrSet}, | 
					
						
							|  |  |  | 	{"standend",        PyCursesWindow_StandEnd}, | 
					
						
							|  |  |  | 	{"standout",        PyCursesWindow_StandOut}, | 
					
						
							|  |  |  | 	{"border",          PyCursesWindow_Border, METH_VARARGS}, | 
					
						
							|  |  |  | 	{"box",             PyCursesWindow_Box}, | 
					
						
							|  |  |  | 	{"hline",           PyCursesWindow_Hline}, | 
					
						
							|  |  |  | 	{"vline",           PyCursesWindow_Vline}, | 
					
						
							|  |  |  | 	{"erase",           PyCursesWindow_Erase}, | 
					
						
							|  |  |  | 	{"deleteln",        PyCursesWindow_DeleteLine}, | 
					
						
							|  |  |  | 	{"insertln",        PyCursesWindow_InsertLine}, | 
					
						
							|  |  |  | 	{"getyx",           PyCursesWindow_GetYX}, | 
					
						
							|  |  |  | 	{"getbegyx",        PyCursesWindow_GetBegYX}, | 
					
						
							|  |  |  | 	{"getmaxyx",        PyCursesWindow_GetMaxYX}, | 
					
						
							|  |  |  | 	{"clear",           PyCursesWindow_Clear}, | 
					
						
							|  |  |  | 	{"clrtobot",        PyCursesWindow_ClearToBottom}, | 
					
						
							|  |  |  | 	{"clrtoeol",        PyCursesWindow_ClearToEOL}, | 
					
						
							|  |  |  | 	{"scroll",          PyCursesWindow_Scroll}, | 
					
						
							|  |  |  | 	{"touchwin",        PyCursesWindow_TouchWin}, | 
					
						
							|  |  |  | 	{"touchline",       PyCursesWindow_TouchLine}, | 
					
						
							|  |  |  | 	{"getch",           PyCursesWindow_GetCh}, | 
					
						
							|  |  |  | 	{"getstr",          PyCursesWindow_GetStr}, | 
					
						
							|  |  |  | 	{"inch",            PyCursesWindow_InCh}, | 
					
						
							|  |  |  | 	{"clearok",         PyCursesWindow_ClearOk}, | 
					
						
							|  |  |  | 	{"idlok",           PyCursesWindow_IdlOk}, | 
					
						
							|  |  |  | 	{"leaveok",         PyCursesWindow_LeaveOk}, | 
					
						
							|  |  |  | 	{"scrollok",        PyCursesWindow_ScrollOk}, | 
					
						
							|  |  |  | 	{"setscrreg",       PyCursesWindow_SetScrollRegion}, | 
					
						
							|  |  |  | 	{"keypad",          PyCursesWindow_KeyPad}, | 
					
						
							|  |  |  | 	{"nodelay",         PyCursesWindow_NoDelay}, | 
					
						
							|  |  |  | 	{"notimeout",       PyCursesWindow_NoTimeout}, | 
					
						
							|  |  |  | 	{NULL,		        NULL}   /* sentinel */ | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesWindow_GetAttr(self, name) | 
					
						
							|  |  |  | 	PyCursesWindowObject *self; | 
					
						
							|  |  |  | 	char *name; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-01-10 20:56:29 +00:00
										 |  |  |   return Py_FindMethod(PyCursesWindow_Methods, (PyObject *)self, name); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | /* --------------- PAD routines ---------------- */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef NOT_YET
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesPad_New(pad) | 
					
						
							|  |  |  | 	WINDOW *pad; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	PyCursesPadObject *po; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 	po = PyObject_NEW(PyCursesPadObject, &PyCursesPad_Type); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 	if (po == NULL) | 
					
						
							|  |  |  | 		return NULL; | 
					
						
							|  |  |  | 	po->pad = pad; | 
					
						
							|  |  |  | 	return (PyObject *)po; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------*/ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | static PyTypeObject PyCursesScreen_Type = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT(&PyType_Type) | 
					
						
							|  |  |  | 	0,			/*ob_size*/ | 
					
						
							|  |  |  | 	"curses screen",	/*tp_name*/ | 
					
						
							|  |  |  | 	sizeof(PyCursesScreenObject),	/*tp_basicsize*/ | 
					
						
							|  |  |  | 	0,			/*tp_itemsize*/ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	(destructor)0 /*PyCursesScreen_Dealloc*/, /*tp_dealloc*/ | 
					
						
							|  |  |  | 	0,			/*tp_print*/ | 
					
						
							|  |  |  | 	(getattrfunc)0, /*tp_getattr*/ | 
					
						
							|  |  |  | 	(setattrfunc)0, /*tp_setattr*/ | 
					
						
							|  |  |  | 	0,			/*tp_compare*/ | 
					
						
							|  |  |  | 	0,			/*tp_repr*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_number*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_sequence*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_mapping*/ | 
					
						
							|  |  |  | 	0,			/*tp_hash*/ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyTypeObject PyCursesWindow_Type = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT(&PyType_Type) | 
					
						
							|  |  |  | 	0,			/*ob_size*/ | 
					
						
							|  |  |  | 	"curses window",	/*tp_name*/ | 
					
						
							|  |  |  | 	sizeof(PyCursesWindowObject),	/*tp_basicsize*/ | 
					
						
							|  |  |  | 	0,			/*tp_itemsize*/ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	(destructor)PyCursesWindow_Dealloc, /*tp_dealloc*/ | 
					
						
							|  |  |  | 	0,			/*tp_print*/ | 
					
						
							|  |  |  | 	(getattrfunc)PyCursesWindow_GetAttr, /*tp_getattr*/ | 
					
						
							|  |  |  | 	(setattrfunc)0, /*tp_setattr*/ | 
					
						
							|  |  |  | 	0,			/*tp_compare*/ | 
					
						
							|  |  |  | 	0,			/*tp_repr*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_number*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_sequence*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_mapping*/ | 
					
						
							|  |  |  | 	0,			/*tp_hash*/ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyTypeObject PyCursesPad_Type = { | 
					
						
							|  |  |  | 	PyObject_HEAD_INIT(&PyType_Type) | 
					
						
							|  |  |  | 	0,			/*ob_size*/ | 
					
						
							|  |  |  | 	"curses pad",	/*tp_name*/ | 
					
						
							|  |  |  | 	sizeof(PyCursesPadObject),	/*tp_basicsize*/ | 
					
						
							|  |  |  | 	0,			/*tp_itemsize*/ | 
					
						
							|  |  |  | 	/* methods */ | 
					
						
							|  |  |  | 	(destructor)0 /*PyCursesPad_Dealloc*/, /*tp_dealloc*/ | 
					
						
							|  |  |  | 	0,			/*tp_print*/ | 
					
						
							|  |  |  | 	(getattrfunc)0, /*tp_getattr*/ | 
					
						
							|  |  |  | 	(setattrfunc)0, /*tp_setattr*/ | 
					
						
							|  |  |  | 	0,			/*tp_compare*/ | 
					
						
							|  |  |  | 	0,			/*tp_repr*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_number*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_sequence*/ | 
					
						
							|  |  |  | 	0,			/*tp_as_mapping*/ | 
					
						
							|  |  |  | 	0,			/*tp_hash*/ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | /* -------------------------------------------------------*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-09-07 14:32:49 +00:00
										 |  |  | static PyObject *ModDict; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | static PyObject *  | 
					
						
							|  |  |  | PyCurses_InitScr(self, args) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * args; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  |   WINDOW *win; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   if (!PyArg_NoArgs(args)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (initialised == TRUE) { | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |     wrefresh(stdscr); | 
					
						
							|  |  |  |     return (PyObject *)PyCursesWindow_New(stdscr); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   win = initscr(); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   if (win == NULL) { | 
					
						
							|  |  |  |     PyErr_SetString(PyCursesError, catchall_NULL); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   initialised = TRUE; | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* This was moved from initcurses() because core dumped on SGI */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | /* Also, they are probably not defined until you've called initscr() */ | 
					
						
							|  |  |  | #define SetDictInt(string,ch) \
 | 
					
						
							|  |  |  | 	PyDict_SetItemString(ModDict,string,PyInt_FromLong((long) (ch))); | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  |   | 
					
						
							|  |  |  | 	/* Here are some graphic symbols you can use */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |         SetDictInt("ACS_ULCORNER",(ACS_ULCORNER)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_ULCORNER",(ACS_ULCORNER)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_LLCORNER",(ACS_LLCORNER)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_URCORNER",(ACS_URCORNER)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_LRCORNER",(ACS_LRCORNER)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_RTEE",    (ACS_RTEE)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_LTEE",    (ACS_LTEE)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_BTEE",    (ACS_BTEE)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_TTEE",    (ACS_TTEE)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_HLINE",   (ACS_HLINE)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_VLINE",   (ACS_VLINE)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_PLUS",    (ACS_PLUS)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_S1",      (ACS_S1)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_S9",      (ACS_S9)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_DIAMOND", (ACS_DIAMOND)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_CKBOARD", (ACS_CKBOARD)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_DEGREE",  (ACS_DEGREE)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_PLMINUS", (ACS_PLMINUS)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_BULLET",  (ACS_BULLET)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_LARROW",  (ACS_RARROW)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_DARROW",  (ACS_DARROW)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_UARROW",  (ACS_UARROW)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_BOARD",   (ACS_BOARD)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_LANTERN", (ACS_LANTERN)); | 
					
						
							|  |  |  | 	SetDictInt("ACS_BLOCK",   (ACS_BLOCK)); | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return (PyObject *)PyCursesWindow_New(win); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *  | 
					
						
							|  |  |  | PyCurses_EndWin(self, args) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * args; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(args) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(endwin(), "endwin"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *  | 
					
						
							|  |  |  | PyCurses_IsEndWin(self, args) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (!PyArg_NoArgs(args)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   if (isendwin() == FALSE) { | 
					
						
							|  |  |  |     Py_INCREF(Py_False); | 
					
						
							|  |  |  |     return Py_False; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   Py_INCREF(Py_True); | 
					
						
							|  |  |  |   return Py_True; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_DoUpdate(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(doupdate(), "doupdate"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_NewWindow(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   WINDOW *win; | 
					
						
							|  |  |  |   int nlines, ncols, begin_y, begin_x; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyCursesInitialised()) | 
					
						
							|  |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   nlines = ncols = 0; | 
					
						
							|  |  |  |   switch (ARG_COUNT(arg)) { | 
					
						
							|  |  |  |   case 2: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg,"(ii);begin)_y,begin_x",&begin_y,&begin_x)) | 
					
						
							|  |  |  |       return NULL; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   case 4: | 
					
						
							|  |  |  |     if (!PyArg_Parse(arg, "(iiii);nlines,ncols,begin_y,begin_x", | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 		   &nlines,&ncols,&begin_y,&begin_x)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |       return NULL; | 
					
						
							|  |  |  |     break; | 
					
						
							|  |  |  |   default: | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "newwin requires 2 or 4 arguments"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   win = newwin(nlines,ncols,begin_y,begin_x); | 
					
						
							|  |  |  |   if (win == NULL) { | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     PyErr_SetString(PyCursesError, catchall_NULL); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   return (PyObject *)PyCursesWindow_New(win); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_Beep(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   beep(); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_Flash(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   flash(); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_UngetCh(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_Parse(arg,"i;integer",&ch) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(ungetch(ch), "ungetch"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_FlushInp(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   flushinp(); | 
					
						
							|  |  |  |   Py_INCREF(Py_None); | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   return Py_None; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_CBreak(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(cbreak(), "cbreak"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_NoCBreak(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(nocbreak(), "nocbreak"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_Echo(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(echo(), "echo"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_NoEcho(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(noecho(), "noecho"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_Nl(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(nl(), "nl"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_NoNl(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(nonl(), "nonl"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_Raw(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(raw(), "raw"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_NoRaw(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_NoArgs(arg) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(noraw(), "noraw"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_IntrFlush(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i;True(1), False(0)",&ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(intrflush(NULL,ch), "intrflush"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_Meta(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   int ch; | 
					
						
							| 
									
										
										
										
											1995-02-24 13:45:43 +00:00
										 |  |  |   if (!PyArg_Parse(arg,"i;True(1), False(0)",&ch) || !PyCursesInitialised()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   return PyCursesCheckERR(meta(stdscr, ch), "meta"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCurses_KeyName(self,arg) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * arg; | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |   char *knp; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  |   int ch; | 
					
						
							|  |  |  |   if (!PyArg_Parse(arg,"i",&ch)) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   knp = keyname(ch); | 
					
						
							|  |  |  |   return PyString_FromString((knp == NULL) ? "" : knp); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef NOT_YET
 | 
					
						
							|  |  |  | static PyObject *  | 
					
						
							|  |  |  | PyCurses_NewTerm(self, args) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *  | 
					
						
							|  |  |  | PyCurses_SetTerm(self, args) | 
					
						
							|  |  |  |      PyObject * self; | 
					
						
							|  |  |  |      PyObject * args; | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* List of functions defined in the module */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef PyCurses_methods[] = { | 
					
						
							|  |  |  | 	{"initscr",             (PyCFunction)PyCurses_InitScr}, | 
					
						
							|  |  |  | 	{"endwin",              (PyCFunction)PyCurses_EndWin}, | 
					
						
							|  |  |  | 	{"isendwin",            (PyCFunction)PyCurses_IsEndWin}, | 
					
						
							|  |  |  | 	{"doupdate",            (PyCFunction)PyCurses_DoUpdate}, | 
					
						
							|  |  |  | 	{"newwin",              (PyCFunction)PyCurses_NewWindow}, | 
					
						
							|  |  |  | 	{"beep",                (PyCFunction)PyCurses_Beep}, | 
					
						
							|  |  |  | 	{"flash",               (PyCFunction)PyCurses_Flash}, | 
					
						
							|  |  |  | 	{"ungetch",             (PyCFunction)PyCurses_UngetCh}, | 
					
						
							|  |  |  | 	{"flushinp",            (PyCFunction)PyCurses_FlushInp}, | 
					
						
							|  |  |  | 	{"cbreak",              (PyCFunction)PyCurses_CBreak}, | 
					
						
							|  |  |  | 	{"nocbreak",            (PyCFunction)PyCurses_NoCBreak}, | 
					
						
							|  |  |  | 	{"echo",                (PyCFunction)PyCurses_Echo}, | 
					
						
							|  |  |  | 	{"noecho",              (PyCFunction)PyCurses_NoEcho}, | 
					
						
							|  |  |  | 	{"nl",                  (PyCFunction)PyCurses_Nl}, | 
					
						
							|  |  |  | 	{"nonl",                (PyCFunction)PyCurses_NoNl}, | 
					
						
							|  |  |  | 	{"raw",                 (PyCFunction)PyCurses_Raw}, | 
					
						
							|  |  |  | 	{"noraw",               (PyCFunction)PyCurses_NoRaw}, | 
					
						
							|  |  |  | 	{"intrflush",           (PyCFunction)PyCurses_IntrFlush}, | 
					
						
							|  |  |  | 	{"meta",                (PyCFunction)PyCurses_Meta}, | 
					
						
							|  |  |  | 	{"keyname",             (PyCFunction)PyCurses_KeyName}, | 
					
						
							|  |  |  | #ifdef NOT_YET
 | 
					
						
							|  |  |  | 	{"newterm",             (PyCFunction)PyCurses_NewTerm}, | 
					
						
							|  |  |  | 	{"set_term",            (PyCFunction)PyCurses_SetTerm}, | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 	{NULL,		NULL}		/* sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Initialization function for the module */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  | initcurses() | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											1995-02-17 13:54:04 +00:00
										 |  |  | 	PyObject *m, *d, *v; | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Create the module and add the functions */ | 
					
						
							| 
									
										
										
										
											1994-08-31 22:06:24 +00:00
										 |  |  | 	m = Py_InitModule("curses", PyCurses_methods); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Add some symbolic constants to the module */ | 
					
						
							|  |  |  | 	d = PyModule_GetDict(m); | 
					
						
							| 
									
										
										
										
											1994-09-07 14:32:49 +00:00
										 |  |  | 	ModDict = d; /* For PyCurses_InitScr */ | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 	/* For exception curses.error */ | 
					
						
							|  |  |  | 	PyCursesError = PyString_FromString("curses.error"); | 
					
						
							|  |  |  | 	PyDict_SetItemString(d, "error", PyCursesError); | 
					
						
							| 
									
										
										
										
											1994-08-31 22:05:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 	/* Make the version available */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:54:04 +00:00
										 |  |  | 	v = PyString_FromString(PyCursesVersion); | 
					
						
							|  |  |  | 	PyDict_SetItemString(d, "version", v); | 
					
						
							|  |  |  | 	PyDict_SetItemString(d, "__version__", v); | 
					
						
							|  |  |  | 	Py_DECREF(v); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Here are some attributes you can add to chars to print */ | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 	SetDictInt("A_NORMAL",		A_NORMAL); | 
					
						
							|  |  |  | 	SetDictInt("A_STANDOUT",	A_STANDOUT); | 
					
						
							|  |  |  | 	SetDictInt("A_UNDERLINE",	A_UNDERLINE); | 
					
						
							|  |  |  | 	SetDictInt("A_REVERSE",		A_REVERSE); | 
					
						
							|  |  |  | 	SetDictInt("A_BLINK",		A_BLINK); | 
					
						
							|  |  |  | 	SetDictInt("A_DIM",		A_DIM); | 
					
						
							|  |  |  | 	SetDictInt("A_BOLD",		A_BOLD); | 
					
						
							|  |  |  | 	SetDictInt("A_ALTCHARSET",	A_ALTCHARSET); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Now set everything up for KEY_ variables */ | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 	  int key; | 
					
						
							|  |  |  | 	  char *key_n; | 
					
						
							|  |  |  | 	  char *key_n2; | 
					
						
							|  |  |  | 	  for (key=KEY_MIN;key < KEY_MAX; key++) { | 
					
						
							|  |  |  | 	    key_n = (char *)keyname(key); | 
					
						
							| 
									
										
										
										
											1995-02-07 15:38:32 +00:00
										 |  |  | 	    if (key_n == NULL || strcmp(key_n,"UNKNOWN KEY")==0) | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 	      continue; | 
					
						
							|  |  |  | 	    if (strncmp(key_n,"KEY_F(",6)==0) { | 
					
						
							|  |  |  | 	      char *p1, *p2; | 
					
						
							|  |  |  | 	      key_n2 = malloc(strlen(key_n)+1); | 
					
						
							|  |  |  | 	      p1 = key_n; | 
					
						
							|  |  |  | 	      p2 = key_n2; | 
					
						
							|  |  |  | 	      while (*p1) { | 
					
						
							|  |  |  | 		if (*p1 != '(' && *p1 != ')') { | 
					
						
							|  |  |  | 		  *p2 = *p1; | 
					
						
							|  |  |  | 		  p2++; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		p1++; | 
					
						
							|  |  |  | 	      } | 
					
						
							|  |  |  | 	      *p2 = (char)0; | 
					
						
							|  |  |  | 	    } else | 
					
						
							|  |  |  | 	      key_n2 = key_n; | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 	    PyDict_SetItemString(d,key_n2,PyInt_FromLong((long) key)); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 	    if (key_n2 != key_n) | 
					
						
							|  |  |  | 	      free(key_n2); | 
					
						
							|  |  |  | 	  } | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 	  SetDictInt("KEY_MIN", KEY_MIN); | 
					
						
							|  |  |  | 	  SetDictInt("KEY_MAX", KEY_MAX); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Check for errors */ | 
					
						
							|  |  |  | 	if (PyErr_Occurred()) | 
					
						
							| 
									
										
										
										
											1995-02-17 13:50:17 +00:00
										 |  |  | 		Py_FatalError("can't initialize module curses"); | 
					
						
							| 
									
										
										
										
											1994-08-30 12:25:20 +00:00
										 |  |  | } |