Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b38bbc79
Commit
b38bbc79
authored
May 23, 2000
by
Andrew M. Kuchling
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Oliver Andrich's ncurses-specific curses module, version 1.5b1
parent
1c06036d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1624 additions
and
965 deletions
+1624
-965
Modules/_cursesmodule.c
Modules/_cursesmodule.c
+1624
-965
No files found.
Modules/_cursesmodule.c
View file @
b38bbc79
/***********************************************************
/*
Copyright 1994 by Lance Ellinghouse,
* This is a curses implementation for Python.
Cathedral City, California Republic, United States of America.
*
* Based on a prior work by Lance Ellinghaus
All Rights Reserved
* (version 1.2 of this module
* Copyright 1994 by Lance Ellinghouse,
Permission to use, copy, modify, and distribute this software and its
* Cathedral City, California Republic, United States of America.)
documentation for any purpose and without fee is hereby granted,
* Updated, fixed and heavily extended by Oliver Andrich
provided that the above copyright notice appear in all copies and that
*
both that copyright notice and this permission notice appear in
* Copyright 1996,1997 by Oliver Andrich,
supporting documentation, and that the name of Lance Ellinghouse
* Koblenz, Germany
not be used in advertising or publicity pertaining to distribution
*
of the software without specific, written prior permission.
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this source file to use, copy, modify, merge, or publish it
LANCE ELLINGHOUSE DISCLAIMS ALL WARRANTIES WITH REGARD TO
* subject to the following conditions:
THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
*
FITNESS, IN NO EVENT SHALL LANCE ELLINGHOUSE BE LIABLE FOR ANY SPECIAL,
* The above copyright notice and this permission notice shall be included
INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* in all copies or in any new file that contains a substantial portion of
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* this file.
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
*
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* THE AUTHOR MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF
* THE SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT
******************************************************************/
* EXPRESS OR IMPLIED WARRANTY. THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
/******************************************************************
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
This is a curses implementation. I have tried to be as complete
* NON-INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE
as possible. If there are functions you need that are not included,
* AUTHOR BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL,
please let me know and/or send me some diffs.
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, STRICT LIABILITY OR
There are 3 basic types exported by this module:
* ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1) Screen - This is not currently used
* PERFORMANCE OF THIS SOFTWARE.
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
--------------------------------------------------------------------------
StringObject version A string representing the current
version of this module.
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?
None doupdate() Updates screen
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
--------------------------------------------------------------------------
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
WindowObject subwin(nlines,ncols,begin_y,begin_x)
subwin(begin_y,begin_x)
None addch(y,x,ch,attr)
addch(y,x,ch)
addch(ch,attr)
addch(ch)
None insch(y,x,ch,attr)
insch(y,x,ch)
insch(ch,attr)
insch(ch)
None delch(y,x)
delch()
None echochar(ch,attr)
echochar(ch)
None addstr(y,x,str,attr)
addstr(y,x,str)
addstr(str,attr)
addstr(str)
None attron(attr)
None attroff(attr)
None attrset(sttr)
None standend()
None standout()
None border(ls,rs,ts,bs,tl,tr,bl,br) (accepts 0-8 INT args)
None box(vertch,horch) vertch and horch are INTS
box()
None hline(y,x,ch,n)
hline(ch,n)
None vline(y,x,ch,n)
vline(ch,n)
None erase()
None deleteln()
None insertln()
(y,x) getyx()
(y,x) getbegyx()
(y,x) getmaxyx()
None clear()
None clrtobot()
None clrtoeol()
None scroll()
scroll(nlines)
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)
None keypad(int) int=0 or int=1
None nodelay(int) int=0 or int=1
None notimeout(int) int=0 or int=1
******************************************************************/
/* curses module */
#include "Python.h"
/* CVS: $Id$ */
#ifdef HAVE_NCURSES_H
/* Release Number */
/* Now let's hope there aren't systems that have a broken ncurses.h */
#include <ncurses.h>
#else
#include <curses.h>
#endif
typedef
struct
{
char
*
PyCursesVersion
=
"1.5b1"
;
PyObject_HEAD
SCREEN
*
scr
;
}
PyCursesScreenObject
;
typedef
struct
{
/* Includes */
PyObject_HEAD
WINDOW
*
win
;
WINDOW
*
parent
;
}
PyCursesWindowObject
;
typedef
struct
{
#include "Python.h"
PyObject_HEAD
#include <curses.h>
WINDOW
*
pad
;
}
PyCursesPadObject
;
#if 0
#ifdef __sgi__
staticforward PyTypeObject PyCursesScreen_Type;
/* No attr_t type is available */
#endif
typedef
chtype
attr_t
;
staticforward
PyTypeObject
PyCursesWindow_Type
;
#if 0
staticforward PyTypeObject PyCursesPad_Type;
#endif
#endif
#define PyCursesScreen_Check(v) ((v)->ob_type == &PyCursesScreen_Type)
/* Definition of exception curses.error */
#define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
#define PyCursesPad_Check(v) ((v)->ob_type == &PyCursesPad_Type)
/* Defines */
static
PyObject
*
PyCursesError
;
static
PyObject
*
PyCursesError
;
/* For exception curses.error */
/*
Catch-al
l error messages */
/*
genera
l error messages */
static
char
*
catchall_ERR
=
"curses function returned ERR"
;
static
char
*
catchall_ERR
=
"curses function returned ERR"
;
static
char
*
catchall_NULL
=
"curses function returned NULL"
;
static
char
*
catchall_NULL
=
"curses function returned NULL"
;
/* Tells whether initscr() has been called to initialise curses */
/* Tells whether initscr() has been called to initialise curses
.
*/
static
int
initialised
=
FALSE
;
static
int
initialised
=
FALSE
;
/* Tells whether start_color() has been called to initialise colorusage. */
static
int
initialisedcolors
=
FALSE
;
/* Utility Macros */
#define ARG_COUNT(X) \
#define ARG_COUNT(X) \
(((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1))
(((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1))
/******************************************************************
#define PyCursesInitialised \
if (initialised != TRUE) { \
Change Log:
PyErr_SetString(PyCursesError, \
"must call initscr() first"); \
return NULL; }
Version 1.2: 95/02/23 (Steve Clift)
#define PyCursesInitialisedColor \
Fixed several potential core-dumping bugs.
if (initialisedcolors != TRUE) { \
Reworked arg parsing where variable arg lists are used.
PyErr_SetString(PyCursesError, \
Generate exceptions when ERR or NULL is returned by curses functions.
"must call start_color() first"); \
Changed return types to match SysV Curses manual descriptions.
return NULL; }
Added keypad() to window method list.
Added border(), hline() and vline() window methods.
Version 1.1: 94/08/31:
/* Utility Functions */
Minor fixes given by Guido.
Changed 'ncurses' to 'curses'
Changed '__version__' to 'version'
Added PyErr_Clear() where needed
Moved ACS_* attribute initialization to PyCurses_InitScr() to fix
crash on SGI
Version 1.0: 94/08/30:
This is the first release of this software.
Released to the Internet via python-list@cwi.nl
******************************************************************/
static
char
*
PyCursesVersion
=
"1.2"
;
/*
/*
* Check the return code from a curses function and return None
* Check the return code from a curses function and return None
...
@@ -249,51 +106,162 @@ PyCursesCheckERR(code, fname)
...
@@ -249,51 +106,162 @@ PyCursesCheckERR(code, fname)
}
}
}
}
int
static
int
PyCurses_ConvertToChtype
(
obj
,
ch
)
PyCursesInitialised
()
PyObject
*
obj
;
chtype
*
ch
;
{
{
if
(
initialised
==
TRUE
)
if
(
PyInt_Check
(
obj
))
{
return
1
;
*
ch
=
(
chtype
)
PyInt_AsLong
(
obj
);
else
{
}
else
if
(
PyString_Check
(
obj
)
&
PyErr_SetString
(
PyCursesError
,
"must call initscr() first"
);
(
PyString_Size
(
obj
)
==
1
))
{
*
ch
=
(
chtype
)
*
PyString_AsString
(
obj
);
}
else
{
return
0
;
return
0
;
}
}
return
1
;
}
}
/*****************************************************************************
The Window Object
******************************************************************************/
/*
------------- SCREEN routines ---------------
*/
/*
Definition of the window object and window type
*/
#ifdef NOT_YET
typedef
struct
{
static
PyObject
*
PyObject_HEAD
PyCursesScreen_New
(
arg
)
WINDOW
*
win
;
PyObject
*
arg
;
}
PyCursesWindowObject
;
{
char
*
term_type
;
PyTypeObject
PyCursesWindow_Type
;
PyFileObject
*
in_fo
;
PyFileObject
*
out_fo
;
#define PyCursesWindow_Check(v) ((v)->ob_type == &PyCursesWindow_Type)
PyCursesScreenObject
*
xp
;
xp
=
PyObject_New
(
PyCursesScreenObject
,
&
PyCursesScreen_Type
);
if
(
xp
==
NULL
)
return
NULL
;
return
(
PyObject
*
)
xp
;
}
#endif
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
X - function name
TYPE - parameter Type
ERGSTR - format string for construction of the return value
PARSESTR - format string for argument parsing
*/
#define Window_NoArgNoReturnFunction(X) \
static PyObject *PyCursesWindow_ ## X (self, arg) \
PyCursesWindowObject * self; PyObject * arg; \
{ if (!PyArg_NoArgs(arg)) return NULL; \
return PyCursesCheckERR(X(self->win), # X); }
#define Window_NoArgTrueFalseFunction(X) \
static PyObject * PyCursesWindow_ ## X (self,arg) \
PyCursesWindowObject * self; PyObject * arg; \
{ \
if (!PyArg_NoArgs(arg)) return NULL; \
if (X (self->win) == FALSE) { Py_INCREF(Py_False); return Py_False; } \
else { Py_INCREF(Py_True); return Py_True; } }
#define Window_NoArgNoReturnVoidFunction(X) \
static PyObject * PyCursesWindow_ ## X (self,arg) \
PyCursesWindowObject * self; \
PyObject * arg; \
{ \
if (!PyArg_NoArgs(arg)) return NULL; \
X(self->win); Py_INCREF(Py_None); return Py_None; }
#define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR) \
static PyObject * PyCursesWindow_ ## X (self, arg) \
PyCursesWindowObject *self; \
PyObject * arg; \
{ \
TYPE arg1, arg2; \
if (!PyArg_NoArgs(arg)) return NULL; \
X(self->win,arg1,arg2); return Py_BuildValue(ERGSTR, arg1, arg2); }
#define Window_OneArgNoReturnVoidFunction(X, TYPE, PARSESTR) \
static PyObject * PyCursesWindow_ ## X (self, arg) \
PyCursesWindowObject *self; \
PyObject * arg; \
{ \
TYPE arg1; \
if (!PyArg_Parse(arg, PARSESTR, &arg1)) return NULL; \
X(self->win,arg1); Py_INCREF(Py_None); return Py_None; }
#define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \
static PyObject * PyCursesWindow_ ## X (self, arg) \
PyCursesWindowObject *self; \
PyObject * arg; \
{ \
TYPE arg1; \
if (!PyArg_Parse(arg,PARSESTR, &arg1)) return NULL; \
return PyCursesCheckERR(X(self->win, arg1), # X); }
#define Window_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \
static PyObject * PyCursesWindow_ ## X (self, arg) \
PyCursesWindowObject *self; \
PyObject * arg; \
{ \
TYPE arg1, arg2; \
if (!PyArg_Parse(arg,PARSESTR, &arg1, &arg2)) return NULL; \
return PyCursesCheckERR(X(self->win, arg1, arg2), # X); }
/* ------------- WINDOW routines --------------- */
/* ------------- WINDOW routines --------------- */
Window_NoArgNoReturnFunction
(
untouchwin
)
Window_NoArgNoReturnFunction
(
touchwin
)
Window_NoArgNoReturnFunction
(
redrawwin
)
Window_NoArgNoReturnFunction
(
winsertln
)
Window_NoArgNoReturnFunction
(
werase
)
Window_NoArgNoReturnFunction
(
wdeleteln
)
Window_NoArgTrueFalseFunction
(
is_wintouched
)
Window_NoArgNoReturnVoidFunction
(
wsyncup
)
Window_NoArgNoReturnVoidFunction
(
wsyncdown
)
Window_NoArgNoReturnVoidFunction
(
wstandend
)
Window_NoArgNoReturnVoidFunction
(
wstandout
)
Window_NoArgNoReturnVoidFunction
(
wcursyncup
)
Window_NoArgNoReturnVoidFunction
(
wclrtoeol
)
Window_NoArgNoReturnVoidFunction
(
wclrtobot
)
Window_NoArgNoReturnVoidFunction
(
wclear
)
Window_OneArgNoReturnVoidFunction
(
idcok
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnVoidFunction
(
immedok
,
int
,
"i;True(1) or False(0)"
)
Window_NoArg2TupleReturnFunction
(
getyx
,
int
,
"(ii)"
)
Window_NoArg2TupleReturnFunction
(
getbegyx
,
int
,
"(ii)"
)
Window_NoArg2TupleReturnFunction
(
getmaxyx
,
int
,
"(ii)"
)
Window_NoArg2TupleReturnFunction
(
getparyx
,
int
,
"(ii)"
)
Window_OneArgNoReturnFunction
(
wattron
,
attr_t
,
"l;attr"
)
Window_OneArgNoReturnFunction
(
wattroff
,
attr_t
,
"l;attr"
)
Window_OneArgNoReturnFunction
(
wattrset
,
attr_t
,
"l;attr"
)
Window_OneArgNoReturnFunction
(
clearok
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnFunction
(
idlok
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnFunction
(
keypad
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnFunction
(
leaveok
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnFunction
(
nodelay
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnFunction
(
notimeout
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnFunction
(
scrollok
,
int
,
"i;True(1) or False(0)"
)
Window_OneArgNoReturnFunction
(
winsdelln
,
int
,
"i;cnt"
)
Window_OneArgNoReturnFunction
(
syncok
,
int
,
"i;True(1) or False(0)"
)
Window_TwoArgNoReturnFunction
(
mvwin
,
int
,
"(ii);y,x"
)
Window_TwoArgNoReturnFunction
(
mvderwin
,
int
,
"(ii);y,x"
)
Window_TwoArgNoReturnFunction
(
wmove
,
int
,
"(ii);y,x"
)
#ifndef __sgi__
Window_TwoArgNoReturnFunction
(
wresize
,
int
,
"(ii);lines,columns"
)
#endif
/* Allocation and Deallocation of Window Objects */
static
PyObject
*
static
PyObject
*
PyCursesWindow_New
(
win
)
PyCursesWindow_New
(
win
)
WINDOW
*
win
;
WINDOW
*
win
;
{
{
PyCursesWindowObject
*
wo
;
PyCursesWindowObject
*
wo
;
wo
=
PyObject_New
(
PyCursesWindowObject
,
&
PyCursesWindow_Type
);
wo
=
PyObject_NEW
(
PyCursesWindowObject
,
&
PyCursesWindow_Type
);
if
(
wo
==
NULL
)
if
(
wo
==
NULL
)
return
NULL
;
return
NULL
;
wo
->
win
=
win
;
wo
->
win
=
win
;
wo
->
parent
=
(
WINDOW
*
)
NULL
;
return
(
PyObject
*
)
wo
;
return
(
PyObject
*
)
wo
;
}
}
...
@@ -301,186 +269,249 @@ static void
...
@@ -301,186 +269,249 @@ static void
PyCursesWindow_Dealloc
(
wo
)
PyCursesWindow_Dealloc
(
wo
)
PyCursesWindowObject
*
wo
;
PyCursesWindowObject
*
wo
;
{
{
if
(
wo
->
win
!=
stdscr
)
if
(
wo
->
win
!=
stdscr
)
delwin
(
wo
->
win
);
delwin
(
wo
->
win
);
PyMem_DEL
(
wo
);
PyObject_Del
(
wo
);
}
}
static
PyObject
*
/* Addch, Addstr, Addnstr */
PyCursesWindow_Refresh
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
PyCursesCheckERR
(
wrefresh
(
self
->
win
),
"wrefresh"
);
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
NoOutRefres
h
(
self
,
arg
)
PyCursesWindow_
AddC
h
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
int
rtn
,
x
,
y
,
use_xy
=
FALSE
;
PyObject
*
temp
;
chtype
ch
=
0
;
attr_t
attr
=
A_NORMAL
;
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"O;ch or int"
,
&
temp
))
return
NULL
;
break
;
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(Ol);ch or int,attr"
,
&
temp
,
&
attr
))
return
NULL
;
break
;
case
3
:
if
(
!
PyArg_Parse
(
arg
,
"(iiO);y,x,ch or int"
,
&
y
,
&
x
,
&
temp
))
return
NULL
;
use_xy
=
TRUE
;
break
;
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(iiOl);y,x,ch or int, attr"
,
&
y
,
&
x
,
&
temp
,
&
attr
))
return
NULL
;
use_xy
=
TRUE
;
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"addch requires 1 or 4 arguments"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
wnoutrefresh
(
self
->
win
),
"wnoutrefresh"
);
}
}
static
PyObject
*
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
PyCursesWindow_MoveWin
(
self
,
arg
)
PyErr_SetString
(
PyExc_TypeError
,
"argument 1 or 3 must be a ch or an int"
);
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
int
x
,
y
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
mvwin
(
self
->
win
,
y
,
x
),
"mvwin"
);
}
if
(
use_xy
==
TRUE
)
rtn
=
mvwaddch
(
self
->
win
,
y
,
x
,
ch
|
attr
);
else
{
rtn
=
waddch
(
self
->
win
,
ch
|
attr
);
}
return
PyCursesCheckERR
(
rtn
,
"addch"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
Move
(
self
,
arg
)
PyCursesWindow_
AddStr
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
int
x
,
y
;
int
x
,
y
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
char
*
str
;
attr_t
attr
=
A_NORMAL
,
attr_old
=
A_NORMAL
;
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
,
"(sl);str,attr"
,
&
str
,
&
attr
))
return
NULL
;
use_attr
=
TRUE
;
break
;
case
3
:
if
(
!
PyArg_Parse
(
arg
,
"(iis);int,int,str"
,
&
y
,
&
x
,
&
str
))
return
NULL
;
use_xy
=
TRUE
;
break
;
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(iisl);int,int,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
;
return
NULL
;
return
PyCursesCheckERR
(
wmove
(
self
->
win
,
y
,
x
),
"wmove"
);
}
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
);
return
PyCursesCheckERR
(
rtn
,
"addstr"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
SubWin
(
self
,
arg
)
PyCursesWindow_
AddNStr
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
WINDOW
*
win
;
int
rtn
,
x
,
y
,
n
;
PyCursesWindowObject
*
rtn_win
;
char
*
str
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
attr_t
attr
=
A_NORMAL
,
attr_old
=
A_NORMAL
;
int
use_xy
=
FALSE
,
use_attr
=
FALSE
;
nlines
=
0
;
ncols
=
0
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);begin_y,begin_x"
,
&
begin_y
,
&
begin_x
))
if
(
!
PyArg_Parse
(
arg
,
"(si);str,n"
,
&
str
,
&
n
))
return
NULL
;
break
;
case
3
:
if
(
!
PyArg_Parse
(
arg
,
"(sil);str,n,attr"
,
&
str
,
&
n
,
&
attr
))
return
NULL
;
return
NULL
;
use_attr
=
TRUE
;
break
;
break
;
case
4
:
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(iiii);nlines,ncols,begin_y,begin_x"
,
if
(
!
PyArg_Parse
(
arg
,
"(iisi);y,x,str,n"
,
&
y
,
&
x
,
&
str
,
&
n
))
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
return
NULL
;
use_xy
=
TRUE
;
break
;
case
5
:
if
(
!
PyArg_Parse
(
arg
,
"(iisil);y,x,str,n,attr"
,
&
y
,
&
x
,
&
str
,
&
n
,
&
attr
))
return
NULL
;
return
NULL
;
use_xy
=
use_attr
=
TRUE
;
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"
subwin requires 2 or 4
arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"
addnstr requires 2 to 5
arguments"
);
return
NULL
;
return
NULL
;
}
}
win
=
subwin
(
self
->
win
,
nlines
,
ncols
,
begin_y
,
begin_x
);
if
(
win
==
NULL
)
{
if
(
use_attr
==
TRUE
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
attr_old
=
getattrs
(
self
->
win
);
return
NULL
;
wattrset
(
self
->
win
,
attr
)
;
}
}
rtn_win
=
(
PyCursesWindowObject
*
)
PyCursesWindow_New
(
win
);
if
(
use_xy
==
TRUE
)
rtn_win
->
parent
=
self
->
win
;
rtn
=
mvwaddnstr
(
self
->
win
,
y
,
x
,
str
,
n
);
return
(
PyObject
*
)
rtn_win
;
else
rtn
=
waddnstr
(
self
->
win
,
str
,
n
);
if
(
use_attr
==
TRUE
)
wattrset
(
self
->
win
,
attr_old
);
return
PyCursesCheckERR
(
rtn
,
"addnstr"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
AddCh
(
self
,
arg
)
PyCursesWindow_
Bkgd
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
PyObject
*
temp
;
int
x
,
y
;
chtype
bkgd
;
int
ch
;
attr_t
attr
=
A_NORMAL
;
int
attr
,
attr_old
=
0
;
int
use_xy
=
FALSE
,
use_attr
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"
i;ch"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"
O;ch or int"
,
&
temp
))
return
NULL
;
return
NULL
;
break
;
break
;
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
if
(
!
PyArg_Parse
(
arg
,
"(Ol);ch or int,attr"
,
&
temp
,
&
attr
))
return
NULL
;
use_attr
=
TRUE
;
break
;
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
;
return
NULL
;
use_xy
=
use_attr
=
TRUE
;
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"
addch requires 1 to 4
arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"
bkgd requires 1 or 2
arguments"
);
return
NULL
;
return
NULL
;
}
}
if
(
use_attr
==
TRUE
)
{
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
bkgd
)
)
{
attr_old
=
getattrs
(
self
->
win
);
PyErr_SetString
(
PyExc_TypeError
,
"argument 1 or 3 must be a ch or an int"
);
wattrset
(
self
->
win
,
attr
)
;
return
NULL
;
}
}
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
);
return
PyCursesCheckERR
(
rtn
,
"[mv]waddch
"
);
return
PyCursesCheckERR
(
wbkgd
(
self
->
win
,
bkgd
|
A_NORMAL
),
"bkgd
"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
InsCh
(
self
,
arg
)
PyCursesWindow_
BkgdSet
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
PyObject
*
temp
;
int
x
,
y
;
chtype
bkgd
;
int
ch
;
attr_t
attr
=
A_NORMAL
;
int
attr
,
attr_old
=
0
;
int
use_xy
=
TRUE
,
use_attr
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"
i;ch"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"
O;ch or int"
,
&
temp
))
return
NULL
;
return
NULL
;
break
;
break
;
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
if
(
!
PyArg_Parse
(
arg
,
"(Ol);ch or int,attr"
,
&
temp
,
&
attr
))
return
NULL
;
use_attr
=
TRUE
;
break
;
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
;
return
NULL
;
use_xy
=
use_attr
=
TRUE
;
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"
insch requires 1 to 4
arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"
bkgdset requires 1 or 2
arguments"
);
return
NULL
;
return
NULL
;
}
}
if
(
use_attr
==
TRUE
)
{
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
bkgd
)
)
{
attr_old
=
getattrs
(
self
->
win
);
PyErr_SetString
(
PyExc_TypeError
,
"argument 1 or 3 must be a ch or an int"
);
wattrset
(
self
->
win
,
attr
)
;
return
NULL
;
}
}
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
);
return
PyCursesCheckERR
(
rtn
,
"[mv]winsch"
);
wbkgdset
(
self
->
win
,
bkgd
|
attr
);
return
PyCursesCheckERR
(
0
,
"bkgdset"
);
}
static
PyObject
*
PyCursesWindow_Border
(
self
,
args
)
PyCursesWindowObject
*
self
;
PyObject
*
args
;
{
chtype
ls
,
rs
,
ts
,
bs
,
tl
,
tr
,
bl
,
br
;
ls
=
rs
=
ts
=
bs
=
tl
=
tr
=
bl
=
br
=
0
;
if
(
!
PyArg_Parse
(
args
,
"|llllllll;ls,rs,ts,bs,tl,tr,bl,br"
,
&
ls
,
&
rs
,
&
ts
,
&
bs
,
&
tl
,
&
tr
,
&
bl
,
&
br
))
return
NULL
;
wborder
(
self
->
win
,
ls
,
rs
,
ts
,
bs
,
tl
,
tr
,
bl
,
br
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
PyCursesWindow_Box
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
chtype
ch1
=
0
,
ch2
=
0
;
if
(
!
PyArg_NoArgs
(
arg
))
{
PyErr_Clear
();
if
(
!
PyArg_Parse
(
arg
,
"(ll);vertint,horint"
,
&
ch1
,
&
ch2
))
return
NULL
;
}
box
(
self
->
win
,
ch1
,
ch2
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -504,512 +535,550 @@ PyCursesWindow_DelCh(self,arg)
...
@@ -504,512 +535,550 @@ PyCursesWindow_DelCh(self,arg)
PyErr_SetString
(
PyExc_TypeError
,
"delch requires 0 or 2 arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"delch requires 0 or 2 arguments"
);
return
NULL
;
return
NULL
;
}
}
return
PyCursesCheckERR
(
rtn
,
"[mv]wdelch"
);
return
PyCursesCheckERR
(
rtn
,
"[mv]wdelch"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
EchoChar
(
self
,
arg
)
PyCursesWindow_
DerWin
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
WINDOW
*
win
;
int
ch
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
int
attr
,
attr_old
;
nlines
=
0
;
ncols
=
0
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"
i;ch"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"
(ii);begin_y,begin_x"
,
&
begin_y
,
&
begin_x
))
return
NULL
;
return
NULL
;
rtn
=
wechochar
(
self
->
win
,
ch
);
break
;
break
;
case
2
:
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
if
(
!
PyArg_Parse
(
arg
,
"(iiii);nlines,ncols,begin_y,begin_x"
,
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
return
NULL
;
return
NULL
;
attr_old
=
getattrs
(
self
->
win
);
wattrset
(
self
->
win
,
attr
);
rtn
=
wechochar
(
self
->
win
,
ch
);
wattrset
(
self
->
win
,
attr_old
);
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"echochar requires 1 or 2 arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"derwin requires 2 or 4 arguments"
);
return
NULL
;
}
win
=
derwin
(
self
->
win
,
nlines
,
ncols
,
begin_y
,
begin_x
);
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
return
NULL
;
}
}
return
PyCursesCheckERR
(
rtn
,
"wechochar"
);
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
AddSt
r
(
self
,
arg
)
PyCursesWindow_
EchoCha
r
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
PyObject
*
temp
;
int
x
,
y
;
chtype
ch
;
char
*
str
;
attr_t
attr
=
A_NORMAL
;
int
attr
,
attr_old
=
0
;
int
use_xy
=
FALSE
,
use_attr
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"
s;str"
,
&
str
))
if
(
!
PyArg_Parse
(
arg
,
"
O;ch or int"
,
&
temp
))
return
NULL
;
return
NULL
;
break
;
break
;
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(si);str,attr"
,
&
str
,
&
attr
))
if
(
!
PyArg_Parse
(
arg
,
"(Ol);ch or int,attr"
,
&
temp
,
&
attr
))
return
NULL
;
use_attr
=
TRUE
;
break
;
case
3
:
if
(
!
PyArg_Parse
(
arg
,
"(iis);y,x,str"
,
&
y
,
&
x
,
&
str
))
return
NULL
;
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
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"addstr requires 1 to 4 arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"echochar requires 1 or 2 arguments"
);
return
NULL
;
return
NULL
;
}
}
if
(
use_attr
==
TRUE
)
{
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
)
)
{
attr_old
=
getattrs
(
self
->
win
);
PyErr_SetString
(
PyExc_TypeError
,
"argument 1 must be a ch or an int"
);
wattrset
(
self
->
win
,
attr
)
;
return
NULL
;
}
}
if
(
use_xy
==
TRUE
)
rtn
=
mvwaddstr
(
self
->
win
,
y
,
x
,
str
);
if
(
self
->
win
->
_flags
&
_ISPAD
)
return
PyCursesCheckERR
(
pechochar
(
self
->
win
,
ch
|
attr
),
"echochar"
);
else
else
rtn
=
waddstr
(
self
->
win
,
str
);
return
PyCursesCheckERR
(
wechochar
(
self
->
win
,
ch
|
attr
),
if
(
use_attr
==
TRUE
)
"echochar"
);
wattrset
(
self
->
win
,
attr_old
);
return
PyCursesCheckERR
(
rtn
,
"[mv]waddstr"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
AttrOn
(
self
,
arg
)
PyCursesWindow_
GetBkgd
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch
;
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
return
NULL
;
return
NULL
;
return
PyInt_FromLong
((
long
)
getbkgd
(
self
->
win
));
wattron
(
self
->
win
,
ch
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
AttrOff
(
self
,
arg
)
PyCursesWindow_
GetCh
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch
;
int
x
,
y
;
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
chtype
rtn
;
return
NULL
;
wattroff
(
self
->
win
,
ch
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
switch
(
ARG_COUNT
(
arg
))
{
PyCursesWindow_AttrSet
(
self
,
arg
)
case
0
:
PyCursesWindowObject
*
self
;
rtn
=
wgetch
(
self
->
win
);
PyObject
*
arg
;
break
;
{
case
2
:
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
return
NULL
;
return
NULL
;
wattrset
(
self
->
win
,
ch
);
rtn
=
mvwgetch
(
self
->
win
,
y
,
x
);
Py_INCREF
(
Py_None
);
break
;
return
Py_None
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"getch requires 0 or 2 arguments"
);
return
NULL
;
}
return
PyInt_FromLong
(
rtn
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
StandEnd
(
self
,
arg
)
PyCursesWindow_
GetKey
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
int
x
,
y
;
return
NULL
;
chtype
rtn
;
wstandend
(
self
->
win
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
switch
(
ARG_COUNT
(
arg
))
{
PyCursesWindow_StandOut
(
self
,
arg
)
case
0
:
PyCursesWindowObject
*
self
;
rtn
=
wgetch
(
self
->
win
)
;
PyObject
*
arg
;
break
;
{
case
2
:
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
return
NULL
;
wstandout
(
self
->
win
);
rtn
=
mvwgetch
(
self
->
win
,
y
,
x
);
Py_INCREF
(
Py_None
);
break
;
return
Py_None
;
default:
}
PyErr_SetString
(
PyExc_TypeError
,
"getch requires 0 or 2 arguments"
);
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
;
return
NULL
;
wborder
(
self
->
win
,
ls
,
rs
,
ts
,
bs
,
tl
,
tr
,
bl
,
br
);
}
Py_INCREF
(
Py_None
);
if
(
rtn
<=
255
)
return
Py_None
;
return
Py_BuildValue
(
"c"
,
rtn
);
else
return
PyString_FromString
((
char
*
)
keyname
(
rtn
));
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
Box
(
self
,
arg
)
PyCursesWindow_
GetStr
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch1
=
0
,
ch2
=
0
;
int
x
,
y
,
n
;
if
(
!
PyArg_NoArgs
(
arg
))
{
char
rtn
[
1024
];
/* This should be big enough.. I hope */
PyErr_Clear
();
int
rtn2
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);vertch,horch"
,
&
ch1
,
&
ch2
))
return
NULL
;
}
box
(
self
->
win
,
ch1
,
ch2
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
switch
(
ARG_COUNT
(
arg
))
{
PyCursesWindow_Hline
(
self
,
args
)
case
0
:
PyCursesWindowObject
*
self
;
rtn2
=
wgetstr
(
self
->
win
,
rtn
);
PyObject
*
args
;
break
;
{
case
1
:
int
ch
,
n
,
x
,
y
,
code
=
OK
;
if
(
!
PyArg_Parse
(
arg
,
"i;n"
,
&
n
))
switch
(
ARG_COUNT
(
args
))
{
return
NULL
;
rtn2
=
wgetnstr
(
self
->
win
,
rtn
,
n
);
break
;
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
s
,
"(ii);ch,n"
,
&
ch
,
&
n
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
return
NULL
;
rtn2
=
mvwgetstr
(
self
->
win
,
y
,
x
,
rtn
);
break
;
break
;
case
4
:
case
3
:
if
(
!
PyArg_Parse
(
arg
s
,
"(iiii);y,x,ch,n"
,
&
y
,
&
x
,
&
ch
,
&
n
))
if
(
!
PyArg_Parse
(
arg
,
"(iii);y,x,n"
,
&
y
,
&
x
,
&
n
))
return
NULL
;
return
NULL
;
code
=
wmove
(
self
->
win
,
y
,
x
);
#ifdef __sgi__
/* Untested */
rtn2
=
wmove
(
self
->
win
,
y
,
x
)
==
ERR
?
ERR
:
wgetnstr
(
self
->
win
,
rtn
,
n
);
#else
rtn2
=
mvwgetnstr
(
self
->
win
,
y
,
x
,
rtn
,
n
);
#endif
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"
hline requires 2 or 4
arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"
getstr requires 0 to 2
arguments"
);
return
NULL
;
return
NULL
;
}
}
if
(
code
!
=
ERR
)
if
(
rtn2
=
=
ERR
)
whline
(
self
->
win
,
ch
,
n
)
;
rtn
[
0
]
=
0
;
return
Py
CursesCheckERR
(
code
,
"wmove"
);
return
Py
String_FromString
(
rtn
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
V
line
(
self
,
args
)
PyCursesWindow_
H
line
(
self
,
args
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
args
;
PyObject
*
args
;
{
{
int
ch
,
n
,
x
,
y
,
code
=
OK
;
PyObject
*
temp
;
chtype
ch
;
int
n
,
x
,
y
,
code
=
OK
;
attr_t
attr
=
A_NORMAL
;
switch
(
ARG_COUNT
(
args
))
{
switch
(
ARG_COUNT
(
args
))
{
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
args
,
"(ii);ch,n"
,
&
ch
,
&
n
))
if
(
!
PyArg_Parse
(
args
,
"(Oi);ch or int,n"
,
&
temp
,
&
n
))
return
NULL
;
break
;
case
3
:
if
(
!
PyArg_Parse
(
args
,
"(Oil);ch or int,n,attr"
,
&
temp
,
&
n
,
&
attr
))
return
NULL
;
return
NULL
;
break
;
break
;
case
4
:
case
4
:
if
(
!
PyArg_Parse
(
args
,
"(ii
ii);y,x,ch,n"
,
&
y
,
&
x
,
&
ch
,
&
n
))
if
(
!
PyArg_Parse
(
args
,
"(ii
Oi);y,x,ch o int,n"
,
&
y
,
&
x
,
&
temp
,
&
n
))
return
NULL
;
return
NULL
;
code
=
wmove
(
self
->
win
,
y
,
x
);
code
=
wmove
(
self
->
win
,
y
,
x
);
break
;
break
;
case
5
:
if
(
!
PyArg_Parse
(
args
,
"(iiOil); y,x,ch or int,n,attr"
,
&
y
,
&
x
,
&
temp
,
&
n
,
&
attr
))
return
NULL
;
code
=
wmove
(
self
->
win
,
y
,
x
);
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"
vline requires 2 or 4
arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"
hline requires 2 or 5
arguments"
);
return
NULL
;
return
NULL
;
}
}
if
(
code
!=
ERR
)
wvline
(
self
->
win
,
ch
,
n
);
return
PyCursesCheckERR
(
code
,
"wmove"
);
}
static
PyObject
*
PyCursesWindow_Erase
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
werase
(
self
->
win
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
PyCursesWindow_DeleteLine
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
PyCursesCheckERR
(
wdeleteln
(
self
->
win
),
"wdeleteln"
);
}
static
PyObject
*
PyCursesWindow_InsertLine
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
PyCursesCheckERR
(
winsertln
(
self
->
win
),
"winsertln"
);
}
static
PyObject
*
PyCursesWindow_GetYX
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
int
x
,
y
;
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
getyx
(
self
->
win
,
y
,
x
);
return
Py_BuildValue
(
"(ii)"
,
y
,
x
);
}
static
PyObject
*
PyCursesWindow_GetBegYX
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
int
x
,
y
;
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
getbegyx
(
self
->
win
,
y
,
x
);
return
Py_BuildValue
(
"(ii)"
,
y
,
x
);
}
static
PyObject
*
if
(
code
!=
ERR
)
{
PyCursesWindow_GetMaxYX
(
self
,
arg
)
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
PyCursesWindowObject
*
self
;
PyErr_SetString
(
PyExc_TypeError
,
PyObject
*
arg
;
"argument 1 or 3 must be a ch or an int"
);
{
int
x
,
y
;
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
NULL
;
getmaxyx
(
self
->
win
,
y
,
x
);
}
return
Py_BuildValue
(
"(ii)"
,
y
,
x
);
return
PyCursesCheckERR
(
whline
(
self
->
win
,
ch
|
attr
,
n
),
"hline"
);
}
else
return
PyCursesCheckERR
(
code
,
"wmove"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
Clear
(
self
,
arg
)
PyCursesWindow_
InsCh
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
int
rtn
,
x
,
y
,
use_xy
=
FALSE
;
PyObject
*
temp
;
chtype
ch
=
0
;
attr_t
attr
=
A_NORMAL
;
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"O;ch or int"
,
&
temp
))
return
NULL
;
return
NULL
;
wclear
(
self
->
win
);
break
;
Py_INCREF
(
Py_None
);
case
2
:
return
Py_None
;
if
(
!
PyArg_Parse
(
arg
,
"(Ol);ch or int,attr"
,
&
temp
,
&
attr
))
}
static
PyObject
*
PyCursesWindow_ClearToBottom
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
NULL
;
wclrtobot
(
self
->
win
);
break
;
Py_INCREF
(
Py_None
);
case
3
:
return
Py_None
;
if
(
!
PyArg_Parse
(
arg
,
"(iiO);y,x,ch or int"
,
&
y
,
&
x
,
&
temp
))
}
static
PyObject
*
PyCursesWindow_ClearToEOL
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
NULL
;
wclrtoeol
(
self
->
win
);
use_xy
=
TRUE
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
PyCursesWindow_Scroll
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
int
nlines
;
int
use_nlines
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
case
0
:
break
;
break
;
case
1
:
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"i;nlines"
,
&
nlines
))
if
(
!
PyArg_Parse
(
arg
,
"(iiOl);y,x,ch or int, attr"
,
&
y
,
&
x
,
&
temp
,
&
attr
))
return
NULL
;
return
NULL
;
use_
nlines
=
TRUE
;
use_
xy
=
TRUE
;
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"
scroll requires 0 or 1
arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"
insch requires 1 or 4
arguments"
);
return
NULL
;
return
NULL
;
}
}
if
(
use_nlines
)
return
PyCursesCheckERR
(
wscrl
(
self
->
win
,
nlines
),
"scroll"
);
else
return
PyCursesCheckERR
(
scroll
(
self
->
win
),
"scroll"
);
}
static
PyObject
*
PyCursesWindow_TouchWin
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
PyCursesCheckERR
(
touchwin
(
self
->
win
),
"touchwin"
);
}
static
PyObject
*
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
PyCursesWindow_TouchLine
(
self
,
arg
)
PyErr_SetString
(
PyExc_TypeError
,
PyCursesWindowObject
*
self
;
"argument 1 or 3 must be a ch or an int"
);
PyObject
*
arg
;
return
NULL
;
{
}
int
st
,
cnt
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);start,count"
,
&
st
,
&
cnt
))
if
(
use_xy
==
TRUE
)
return
NULL
;
rtn
=
mvwinsch
(
self
->
win
,
y
,
x
,
ch
|
attr
);
return
PyCursesCheckERR
(
touchline
(
self
->
win
,
st
,
cnt
),
"touchline"
);
else
{
rtn
=
winsch
(
self
->
win
,
ch
|
attr
);
}
return
PyCursesCheckERR
(
rtn
,
"insch"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
Get
Ch
(
self
,
arg
)
PyCursesWindow_
In
Ch
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
x
,
y
;
int
x
,
y
,
rtn
;
int
rtn
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
0
:
case
0
:
rtn
=
w
get
ch
(
self
->
win
);
rtn
=
w
in
ch
(
self
->
win
);
break
;
break
;
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
return
NULL
;
rtn
=
mvw
get
ch
(
self
->
win
,
y
,
x
);
rtn
=
mvw
in
ch
(
self
->
win
,
y
,
x
);
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"
get
ch requires 0 or 2 arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"
in
ch requires 0 or 2 arguments"
);
return
NULL
;
return
NULL
;
}
}
return
PyInt_FromLong
((
long
)
rtn
);
return
PyInt_FromLong
((
long
)
rtn
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
Get
Str
(
self
,
arg
)
PyCursesWindow_
In
Str
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
x
,
y
;
int
x
,
y
,
n
;
char
rtn
[
1024
];
/* This should be big enough.. I hope */
char
rtn
[
1024
];
/* This should be big enough.. I hope */
int
rtn2
;
int
rtn2
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
0
:
case
0
:
rtn2
=
wgetstr
(
self
->
win
,
rtn
);
rtn2
=
winstr
(
self
->
win
,
rtn
);
break
;
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;n"
,
&
n
))
return
NULL
;
rtn2
=
winnstr
(
self
->
win
,
rtn
,
n
);
break
;
break
;
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
return
NULL
;
rtn2
=
mvw
get
str
(
self
->
win
,
y
,
x
,
rtn
);
rtn2
=
mvw
in
str
(
self
->
win
,
y
,
x
,
rtn
);
break
;
break
;
default:
case
3
:
PyErr_SetString
(
PyExc_TypeError
,
"getstr requires 0 or 2 arguments"
);
if
(
!
PyArg_Parse
(
arg
,
"(iii);y,x,n"
,
&
y
,
&
x
,
&
n
))
return
NULL
;
rtn2
=
mvwinnstr
(
self
->
win
,
y
,
x
,
rtn
,
n
);
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"instr requires 0 or 3 arguments"
);
return
NULL
;
return
NULL
;
}
}
if
(
rtn2
==
ERR
)
if
(
rtn2
==
ERR
)
rtn
[
0
]
=
0
;
rtn
[
0
]
=
0
;
return
PyString_FromString
(
rtn
);
return
PyString_FromString
(
rtn
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_In
Ch
(
self
,
arg
)
PyCursesWindow_In
sStr
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
x
,
y
,
rtn
;
int
rtn
;
int
x
,
y
;
char
*
str
;
attr_t
attr
=
A_NORMAL
,
attr_old
=
A_NORMAL
;
int
use_xy
=
FALSE
,
use_attr
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
0
:
case
1
:
rtn
=
winch
(
self
->
win
);
if
(
!
PyArg_Parse
(
arg
,
"s;str"
,
&
str
))
return
NULL
;
break
;
break
;
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(
ii);y,x"
,
&
y
,
&
x
))
if
(
!
PyArg_Parse
(
arg
,
"(
sl);str,attr"
,
&
str
,
&
attr
))
return
NULL
;
return
NULL
;
rtn
=
mvwinch
(
self
->
win
,
y
,
x
);
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
,
"(iisl);y,x,str,attr"
,
&
y
,
&
x
,
&
str
,
&
attr
))
return
NULL
;
use_xy
=
use_attr
=
TRUE
;
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"in
ch requires 0 or 2
arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"in
sstr requires 1 to 4
arguments"
);
return
NULL
;
return
NULL
;
}
}
return
PyInt_FromLong
((
long
)
rtn
);
if
(
use_attr
==
TRUE
)
{
attr_old
=
getattrs
(
self
->
win
);
wattrset
(
self
->
win
,
attr
);
}
if
(
use_xy
==
TRUE
)
rtn
=
mvwinsstr
(
self
->
win
,
y
,
x
,
str
);
else
rtn
=
winsstr
(
self
->
win
,
str
);
if
(
use_attr
==
TRUE
)
wattrset
(
self
->
win
,
attr_old
);
return
PyCursesCheckERR
(
rtn
,
"insstr"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
ClearOk
(
self
,
arg
)
PyCursesWindow_
InsNStr
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
val
;
int
rtn
,
x
,
y
,
n
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
char
*
str
;
attr_t
attr
=
A_NORMAL
,
attr_old
=
A_NORMAL
;
int
use_xy
=
FALSE
,
use_attr
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(si);str,n"
,
&
str
,
&
n
))
return
NULL
;
break
;
case
3
:
if
(
!
PyArg_Parse
(
arg
,
"(sil);str,n,attr"
,
&
str
,
&
n
,
&
attr
))
return
NULL
;
use_attr
=
TRUE
;
break
;
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(iisi);y,x,str,n"
,
&
y
,
&
x
,
&
str
,
&
n
))
return
NULL
;
use_xy
=
TRUE
;
break
;
case
5
:
if
(
!
PyArg_Parse
(
arg
,
"(iisil);y,x,str,n,attr"
,
&
y
,
&
x
,
&
str
,
&
n
,
&
attr
))
return
NULL
;
use_xy
=
use_attr
=
TRUE
;
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"insnstr requires 2 to 5 arguments"
);
return
NULL
;
return
NULL
;
clearok
(
self
->
win
,
val
);
}
Py_INCREF
(
Py_None
);
return
Py_None
;
if
(
use_attr
==
TRUE
)
{
attr_old
=
getattrs
(
self
->
win
);
wattrset
(
self
->
win
,
attr
);
}
if
(
use_xy
==
TRUE
)
rtn
=
mvwinsnstr
(
self
->
win
,
y
,
x
,
str
,
n
);
else
rtn
=
winsnstr
(
self
->
win
,
str
,
n
);
if
(
use_attr
==
TRUE
)
wattrset
(
self
->
win
,
attr_old
);
return
PyCursesCheckERR
(
rtn
,
"insnstr"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_I
dlOk
(
self
,
arg
)
PyCursesWindow_I
s_LineTouched
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
val
;
int
line
,
erg
;
if
(
!
PyArg_Parse
(
arg
,
"i;
True(1) or False(0)"
,
&
val
))
if
(
!
PyArg_Parse
(
arg
,
"i;
line"
,
&
line
))
return
NULL
;
return
NULL
;
idlok
(
self
->
win
,
val
);
erg
=
is_linetouched
(
self
->
win
,
line
);
Py_INCREF
(
Py_None
);
if
(
erg
==
ERR
)
{
return
Py_None
;
PyErr_SetString
(
PyExc_TypeError
,
"is_linetouched: line number outside of boundaries"
);
return
NULL
;
}
else
if
(
erg
==
FALSE
)
{
Py_INCREF
(
Py_False
);
return
Py_False
;
}
else
{
Py_INCREF
(
Py_True
);
return
Py_True
;
}
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
LeaveOk
(
self
,
arg
)
PyCursesWindow_
NoOutRefresh
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
val
;
int
pminrow
,
pmincol
,
sminrow
,
smincol
,
smaxrow
,
smaxcol
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
if
(
self
->
win
->
_flags
&
_ISPAD
)
{
switch
(
ARG_COUNT
(
arg
))
{
case
6
:
if
(
!
PyArg_Parse
(
arg
,
"(iiiiii);"
\
"pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol"
,
&
pminrow
,
&
pmincol
,
&
sminrow
,
&
smincol
,
&
smaxrow
,
&
smaxcol
))
return
NULL
;
return
PyCursesCheckERR
(
pnoutrefresh
(
self
->
win
,
pminrow
,
pmincol
,
sminrow
,
smincol
,
smaxrow
,
smaxcol
),
"pnoutrefresh"
);
default:
PyErr_SetString
(
PyCursesError
,
"noutrefresh was called for a pad;"
\
"requires 6 arguments"
);
return
NULL
;
}
}
else
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
PyCursesCheckERR
(
wnoutrefresh
(
self
->
win
),
"wnoutrefresh"
);
}
}
static
PyObject
*
PyCursesWindow_PutWin
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
PyObject
*
temp
;
if
(
!
PyArg_Parse
(
arg
,
"O;fileobj"
,
&
temp
))
return
NULL
;
return
NULL
;
leaveok
(
self
->
win
,
val
);
if
(
!
PyFile_Check
(
temp
))
{
Py_INCREF
(
Py_None
);
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a file object"
);
return
Py_None
;
return
NULL
;
}
return
PyCursesCheckERR
(
putwin
(
self
->
win
,
PyFile_AsFile
(
temp
)),
"putwin"
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
ScrollOk
(
self
,
arg
)
PyCursesWindow_
RedrawLine
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
val
;
int
beg
,
num
;
if
(
!
PyArg_Parse
(
arg
,
"
i;True(1) or False(0)"
,
&
val
))
if
(
!
PyArg_Parse
(
arg
,
"
(ii);beg,num"
,
&
beg
,
&
num
))
return
NULL
;
return
NULL
;
scrollok
(
self
->
win
,
val
);
return
PyCursesCheckERR
(
wredrawln
(
self
->
win
,
beg
,
num
),
"redrawln"
);
Py_INCREF
(
Py_None
);
}
return
Py_None
;
static
PyObject
*
PyCursesWindow_Refresh
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
int
pminrow
,
pmincol
,
sminrow
,
smincol
,
smaxrow
,
smaxcol
;
if
(
self
->
win
->
_flags
&
_ISPAD
)
{
switch
(
ARG_COUNT
(
arg
))
{
case
6
:
if
(
!
PyArg_Parse
(
arg
,
"(iiiiii);"
\
"pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol"
,
&
pminrow
,
&
pmincol
,
&
sminrow
,
&
smincol
,
&
smaxrow
,
&
smaxcol
))
return
NULL
;
return
PyCursesCheckERR
(
prefresh
(
self
->
win
,
pminrow
,
pmincol
,
sminrow
,
smincol
,
smaxrow
,
smaxcol
),
"prefresh"
);
default:
PyErr_SetString
(
PyCursesError
,
"refresh was called for a pad; requires 6 arguments"
);
return
NULL
;
}
}
else
{
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
return
PyCursesCheckERR
(
wrefresh
(
self
->
win
),
"wrefresh"
);
}
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1024,87 +1093,191 @@ PyCursesWindow_SetScrollRegion(self,arg)
...
@@ -1024,87 +1093,191 @@ PyCursesWindow_SetScrollRegion(self,arg)
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
KeyPad
(
self
,
arg
)
PyCursesWindow_
SubWin
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch
;
WINDOW
*
win
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
int
nlines
,
ncols
,
begin_y
,
begin_x
;
if
(
!
PyArg_Parse
(
arg
,
"(iiii);nlines,ncols,begin_y,begin_x"
,
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
return
NULL
;
return
NULL
;
keypad
(
self
->
win
,
ch
);
Py_INCREF
(
Py_None
);
if
(
self
->
win
->
_flags
&
_ISPAD
)
return
Py_None
;
win
=
subpad
(
self
->
win
,
nlines
,
ncols
,
begin_y
,
begin_x
);
else
win
=
subwin
(
self
->
win
,
nlines
,
ncols
,
begin_y
,
begin_x
);
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
}
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
NoDelay
(
self
,
arg
)
PyCursesWindow_
Scroll
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch
;
int
lines
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
switch
(
ARG_COUNT
(
arg
))
{
case
0
:
return
PyCursesCheckERR
(
scroll
(
self
->
win
),
"scroll"
);
break
;
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;lines"
,
&
lines
))
return
NULL
;
return
PyCursesCheckERR
(
wscrl
(
self
->
win
,
lines
),
"scroll"
);
default:
PyErr_SetString
(
PyExc_TypeError
,
"scroll requires 0 or 1 arguments"
);
return
NULL
;
return
NULL
;
nodelay
(
self
->
win
,
ch
);
}
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
PyCursesWindow_
NoTimeout
(
self
,
arg
)
PyCursesWindow_
TouchLine
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch
;
int
st
,
cnt
,
val
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
switch
(
ARG_COUNT
(
arg
))
{
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);start,count"
,
&
st
,
&
cnt
))
return
NULL
;
return
PyCursesCheckERR
(
touchline
(
self
->
win
,
st
,
cnt
),
"touchline"
);
break
;
case
3
:
if
(
!
PyArg_Parse
(
arg
,
"(iii);start,count,val"
,
&
st
,
&
cnt
,
&
val
))
return
NULL
;
return
PyCursesCheckERR
(
wtouchln
(
self
->
win
,
st
,
cnt
,
val
),
"touchline"
);
default:
PyErr_SetString
(
PyExc_TypeError
,
"touchline requires 2 or 3 arguments"
);
return
NULL
;
return
NULL
;
notimeout
(
self
->
win
,
ch
);
}
Py_INCREF
(
Py_None
);
}
return
Py_None
;
static
PyObject
*
PyCursesWindow_Vline
(
self
,
args
)
PyCursesWindowObject
*
self
;
PyObject
*
args
;
{
PyObject
*
temp
;
chtype
ch
;
int
n
,
x
,
y
,
code
=
OK
;
attr_t
attr
=
A_NORMAL
;
switch
(
ARG_COUNT
(
args
))
{
case
2
:
if
(
!
PyArg_Parse
(
args
,
"(Oi);ch or int,n"
,
&
temp
,
&
n
))
return
NULL
;
break
;
case
3
:
if
(
!
PyArg_Parse
(
args
,
"(Oil);ch or int,n,attr"
,
&
temp
,
&
n
,
&
attr
))
return
NULL
;
break
;
case
4
:
if
(
!
PyArg_Parse
(
args
,
"(iiOi);y,x,ch o int,n"
,
&
y
,
&
x
,
&
temp
,
&
n
))
return
NULL
;
code
=
wmove
(
self
->
win
,
y
,
x
);
break
;
case
5
:
if
(
!
PyArg_Parse
(
args
,
"(iiOil); y,x,ch or int,n,attr"
,
&
y
,
&
x
,
&
temp
,
&
n
,
&
attr
))
return
NULL
;
code
=
wmove
(
self
->
win
,
y
,
x
);
default:
PyErr_SetString
(
PyExc_TypeError
,
"vline requires 2 or 5 arguments"
);
return
NULL
;
}
if
(
code
!=
ERR
)
{
if
(
!
PyCurses_ConvertToChtype
(
temp
,
&
ch
))
{
PyErr_SetString
(
PyExc_TypeError
,
"argument 1 or 3 must be a ch or an int"
);
return
NULL
;
}
return
PyCursesCheckERR
(
whline
(
self
->
win
,
ch
|
attr
,
n
),
"vline"
);
}
else
return
PyCursesCheckERR
(
code
,
"wmove"
);
}
}
static
PyMethodDef
PyCursesWindow_Methods
[]
=
{
static
PyMethodDef
PyCursesWindow_Methods
[]
=
{
{
"refresh"
,
(
PyCFunction
)
PyCursesWindow_Refresh
},
{
"nooutrefresh"
,
(
PyCFunction
)
PyCursesWindow_NoOutRefresh
},
{
"mvwin"
,
(
PyCFunction
)
PyCursesWindow_MoveWin
},
{
"move"
,
(
PyCFunction
)
PyCursesWindow_Move
},
{
"subwin"
,
(
PyCFunction
)
PyCursesWindow_SubWin
},
{
"addch"
,
(
PyCFunction
)
PyCursesWindow_AddCh
},
{
"addch"
,
(
PyCFunction
)
PyCursesWindow_AddCh
},
{
"insch"
,
(
PyCFunction
)
PyCursesWindow_InsCh
},
{
"addnstr"
,
(
PyCFunction
)
PyCursesWindow_AddNStr
},
{
"delch"
,
(
PyCFunction
)
PyCursesWindow_DelCh
},
{
"echochar"
,
(
PyCFunction
)
PyCursesWindow_EchoChar
},
{
"addstr"
,
(
PyCFunction
)
PyCursesWindow_AddStr
},
{
"addstr"
,
(
PyCFunction
)
PyCursesWindow_AddStr
},
{
"attron"
,
(
PyCFunction
)
PyCursesWindow_AttrOn
},
{
"attron"
,
(
PyCFunction
)
PyCursesWindow_wattron
},
{
"attroff"
,
(
PyCFunction
)
PyCursesWindow_AttrOff
},
{
"attr_on"
,
(
PyCFunction
)
PyCursesWindow_wattron
},
{
"attrset"
,
(
PyCFunction
)
PyCursesWindow_AttrSet
},
{
"attroff"
,
(
PyCFunction
)
PyCursesWindow_wattroff
},
{
"standend"
,
(
PyCFunction
)
PyCursesWindow_StandEnd
},
{
"attr_off"
,
(
PyCFunction
)
PyCursesWindow_wattroff
},
{
"standout"
,
(
PyCFunction
)
PyCursesWindow_StandOut
},
{
"attrset"
,
(
PyCFunction
)
PyCursesWindow_wattrset
},
{
"attr_set"
,
(
PyCFunction
)
PyCursesWindow_wattrset
},
{
"bkgd"
,
(
PyCFunction
)
PyCursesWindow_Bkgd
},
{
"bkgdset"
,
(
PyCFunction
)
PyCursesWindow_BkgdSet
},
{
"border"
,
(
PyCFunction
)
PyCursesWindow_Border
,
METH_VARARGS
},
{
"border"
,
(
PyCFunction
)
PyCursesWindow_Border
,
METH_VARARGS
},
{
"box"
,
(
PyCFunction
)
PyCursesWindow_Box
},
{
"box"
,
(
PyCFunction
)
PyCursesWindow_Box
},
{
"hline"
,
(
PyCFunction
)
PyCursesWindow_Hline
},
{
"clear"
,
(
PyCFunction
)
PyCursesWindow_wclear
},
{
"vline"
,
(
PyCFunction
)
PyCursesWindow_Vline
},
{
"clearok"
,
(
PyCFunction
)
PyCursesWindow_clearok
},
{
"erase"
,
(
PyCFunction
)
PyCursesWindow_Erase
},
{
"clrtobot"
,
(
PyCFunction
)
PyCursesWindow_wclrtobot
},
{
"deleteln"
,
(
PyCFunction
)
PyCursesWindow_DeleteLine
},
{
"clrtoeol"
,
(
PyCFunction
)
PyCursesWindow_wclrtoeol
},
{
"insertln"
,
(
PyCFunction
)
PyCursesWindow_InsertLine
},
{
"cursyncup"
,
(
PyCFunction
)
PyCursesWindow_wcursyncup
},
{
"getyx"
,
(
PyCFunction
)
PyCursesWindow_GetYX
},
{
"delch"
,
(
PyCFunction
)
PyCursesWindow_DelCh
},
{
"getbegyx"
,
(
PyCFunction
)
PyCursesWindow_GetBegYX
},
{
"deleteln"
,
(
PyCFunction
)
PyCursesWindow_wdeleteln
},
{
"getmaxyx"
,
(
PyCFunction
)
PyCursesWindow_GetMaxYX
},
{
"derwin"
,
(
PyCFunction
)
PyCursesWindow_DerWin
},
{
"clear"
,
(
PyCFunction
)
PyCursesWindow_Clear
},
{
"echochar"
,
(
PyCFunction
)
PyCursesWindow_EchoChar
},
{
"clrtobot"
,
(
PyCFunction
)
PyCursesWindow_ClearToBottom
},
{
"erase"
,
(
PyCFunction
)
PyCursesWindow_werase
},
{
"clrtoeol"
,
(
PyCFunction
)
PyCursesWindow_ClearToEOL
},
{
"getbegyx"
,
(
PyCFunction
)
PyCursesWindow_getbegyx
},
{
"scroll"
,
(
PyCFunction
)
PyCursesWindow_Scroll
},
{
"getbkgd"
,
(
PyCFunction
)
PyCursesWindow_GetBkgd
},
{
"touchwin"
,
(
PyCFunction
)
PyCursesWindow_TouchWin
},
{
"touchline"
,
(
PyCFunction
)
PyCursesWindow_TouchLine
},
{
"getch"
,
(
PyCFunction
)
PyCursesWindow_GetCh
},
{
"getch"
,
(
PyCFunction
)
PyCursesWindow_GetCh
},
{
"getkey"
,
(
PyCFunction
)
PyCursesWindow_GetKey
},
{
"getmaxyx"
,
(
PyCFunction
)
PyCursesWindow_getmaxyx
},
{
"getparyx"
,
(
PyCFunction
)
PyCursesWindow_getparyx
},
{
"getstr"
,
(
PyCFunction
)
PyCursesWindow_GetStr
},
{
"getstr"
,
(
PyCFunction
)
PyCursesWindow_GetStr
},
{
"getyx"
,
(
PyCFunction
)
PyCursesWindow_getyx
},
{
"hline"
,
(
PyCFunction
)
PyCursesWindow_Hline
},
{
"idlok"
,
(
PyCFunction
)
PyCursesWindow_idlok
},
{
"idcok"
,
(
PyCFunction
)
PyCursesWindow_idcok
},
{
"immedok"
,
(
PyCFunction
)
PyCursesWindow_immedok
},
{
"inch"
,
(
PyCFunction
)
PyCursesWindow_InCh
},
{
"inch"
,
(
PyCFunction
)
PyCursesWindow_InCh
},
{
"clearok"
,
(
PyCFunction
)
PyCursesWindow_ClearOk
},
{
"insch"
,
(
PyCFunction
)
PyCursesWindow_InsCh
},
{
"idlok"
,
(
PyCFunction
)
PyCursesWindow_IdlOk
},
{
"insdelln"
,
(
PyCFunction
)
PyCursesWindow_winsdelln
},
{
"leaveok"
,
(
PyCFunction
)
PyCursesWindow_LeaveOk
},
{
"insertln"
,
(
PyCFunction
)
PyCursesWindow_winsertln
},
{
"scrollok"
,
(
PyCFunction
)
PyCursesWindow_ScrollOk
},
{
"insnstr"
,
(
PyCFunction
)
PyCursesWindow_InsNStr
},
{
"insstr"
,
(
PyCFunction
)
PyCursesWindow_InsStr
},
{
"instr"
,
(
PyCFunction
)
PyCursesWindow_InStr
},
{
"is_linetouched"
,
(
PyCFunction
)
PyCursesWindow_Is_LineTouched
},
{
"is_wintouched"
,
(
PyCFunction
)
PyCursesWindow_is_wintouched
},
{
"keypad"
,
(
PyCFunction
)
PyCursesWindow_keypad
},
{
"leaveok"
,
(
PyCFunction
)
PyCursesWindow_leaveok
},
{
"move"
,
(
PyCFunction
)
PyCursesWindow_wmove
},
{
"mvwin"
,
(
PyCFunction
)
PyCursesWindow_mvwin
},
{
"mvderwin"
,
(
PyCFunction
)
PyCursesWindow_mvderwin
},
{
"nodelay"
,
(
PyCFunction
)
PyCursesWindow_nodelay
},
{
"noutrefresh"
,
(
PyCFunction
)
PyCursesWindow_NoOutRefresh
},
{
"notimeout"
,
(
PyCFunction
)
PyCursesWindow_notimeout
},
{
"putwin"
,
(
PyCFunction
)
PyCursesWindow_PutWin
},
{
"redrawwin"
,
(
PyCFunction
)
PyCursesWindow_redrawwin
},
{
"redrawln"
,
(
PyCFunction
)
PyCursesWindow_RedrawLine
},
{
"refresh"
,
(
PyCFunction
)
PyCursesWindow_Refresh
},
#ifndef __sgi__
{
"resize"
,
(
PyCFunction
)
PyCursesWindow_wresize
},
#endif
{
"scroll"
,
(
PyCFunction
)
PyCursesWindow_Scroll
},
{
"scrollok"
,
(
PyCFunction
)
PyCursesWindow_scrollok
},
{
"setscrreg"
,
(
PyCFunction
)
PyCursesWindow_SetScrollRegion
},
{
"setscrreg"
,
(
PyCFunction
)
PyCursesWindow_SetScrollRegion
},
{
"keypad"
,
(
PyCFunction
)
PyCursesWindow_KeyPad
},
{
"standend"
,
(
PyCFunction
)
PyCursesWindow_wstandend
},
{
"nodelay"
,
(
PyCFunction
)
PyCursesWindow_NoDelay
},
{
"standout"
,
(
PyCFunction
)
PyCursesWindow_wstandout
},
{
"notimeout"
,
(
PyCFunction
)
PyCursesWindow_NoTimeout
},
{
"subpad"
,
(
PyCFunction
)
PyCursesWindow_SubWin
},
{
"subwin"
,
(
PyCFunction
)
PyCursesWindow_SubWin
},
{
"syncdown"
,
(
PyCFunction
)
PyCursesWindow_wsyncdown
},
{
"syncok"
,
(
PyCFunction
)
PyCursesWindow_syncok
},
{
"syncup"
,
(
PyCFunction
)
PyCursesWindow_wsyncup
},
{
"touchline"
,
(
PyCFunction
)
PyCursesWindow_TouchLine
},
{
"touchwin"
,
(
PyCFunction
)
PyCursesWindow_touchwin
},
{
"untouchwin"
,
(
PyCFunction
)
PyCursesWindow_untouchwin
},
{
"vline"
,
(
PyCFunction
)
PyCursesWindow_Vline
},
{
NULL
,
NULL
}
/* sentinel */
{
NULL
,
NULL
}
/* sentinel */
};
};
...
@@ -1116,48 +1289,9 @@ PyCursesWindow_GetAttr(self, name)
...
@@ -1116,48 +1289,9 @@ PyCursesWindow_GetAttr(self, name)
return
Py_FindMethod
(
PyCursesWindow_Methods
,
(
PyObject
*
)
self
,
name
);
return
Py_FindMethod
(
PyCursesWindow_Methods
,
(
PyObject
*
)
self
,
name
);
}
}
/* --------------- PAD routines ---------------- */
#ifdef NOT_YET
static
PyObject
*
PyCursesPad_New
(
pad
)
WINDOW
*
pad
;
{
PyCursesPadObject
*
po
;
po
=
PyObject_New
(
PyCursesPadObject
,
&
PyCursesPad_Type
);
if
(
po
==
NULL
)
return
NULL
;
po
->
pad
=
pad
;
return
(
PyObject
*
)
po
;
}
#endif
/* -------------------------------------------------------*/
/* -------------------------------------------------------*/
#if 0
PyTypeObject
PyCursesWindow_Type
=
{
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*/
};
#endif
static
PyTypeObject
PyCursesWindow_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/*ob_size*/
0
,
/*ob_size*/
"curses window"
,
/*tp_name*/
"curses window"
,
/*tp_name*/
...
@@ -1176,31 +1310,354 @@ static PyTypeObject PyCursesWindow_Type = {
...
@@ -1176,31 +1310,354 @@ static PyTypeObject PyCursesWindow_Type = {
0
,
/*tp_hash*/
0
,
/*tp_hash*/
};
};
#if 0
/*********************************************************************
static PyTypeObject PyCursesPad_Type = {
Global Functions
PyObject_HEAD_INIT(&PyType_Type)
**********************************************************************/
0, /*ob_size*/
"curses pad", /*tp_name*/
static
PyObject
*
ModDict
;
sizeof(PyCursesPadObject), /*tp_basicsize*/
0, /*tp_itemsize*/
/* Function Prototype Macros - They are ugly but very, very useful. ;-)
/* methods */
(destructor)0 /*PyCursesPad_Dealloc*/, /*tp_dealloc*/
X - function name
0, /*tp_print*/
TYPE - parameter Type
(getattrfunc)0, /*tp_getattr*/
ERGSTR - format string for construction of the return value
(setattrfunc)0, /*tp_setattr*/
PARSESTR - format string for argument parsing
0, /*tp_compare*/
*/
0, /*tp_repr*/
0, /*tp_as_number*/
#define NoArgNoReturnFunction(X) \
0, /*tp_as_sequence*/
static PyObject *PyCurses_ ## X (self, arg) \
0, /*tp_as_mapping*/
PyObject * self; \
0, /*tp_hash*/
PyObject * arg; \
};
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(arg)) return NULL; \
return PyCursesCheckERR(X(), # X); }
#define NoArgOrFlagNoReturnFunction(X) \
static PyObject *PyCurses_ ## X (self, arg) \
PyObject * self; \
PyObject * arg; \
{ \
int flag = 0; \
PyCursesInitialised \
switch(ARG_COUNT(arg)) { \
case 0: \
return PyCursesCheckERR(X(), # X); \
case 1: \
if (!PyArg_Parse(arg, "i;True(1) or False(0)", &flag)) return NULL; \
if (flag) return PyCursesCheckERR(X(), # X); \
else return PyCursesCheckERR(no ## X (), # X); \
default: \
PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 argument"); \
return NULL; } }
#define NoArgReturnIntFunction(X) \
static PyObject *PyCurses_ ## X (self, arg) \
PyObject * self; \
PyObject * arg; \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(arg)) return NULL; \
return PyInt_FromLong((long) X()); }
#define NoArgReturnStringFunction(X) \
static PyObject *PyCurses_ ## X (self, arg) \
PyObject * self; \
PyObject * arg; \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(arg)) return NULL; \
return PyString_FromString(X()); }
#define NoArgTrueFalseFunction(X) \
static PyObject * PyCurses_ ## X (self,arg) \
PyObject * self; \
PyObject * arg; \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(arg)) return NULL; \
if (X () == FALSE) { \
Py_INCREF(Py_False); \
return Py_False; \
} \
Py_INCREF(Py_True); \
return Py_True; }
#define NoArgNoReturnVoidFunction(X) \
static PyObject * PyCurses_ ## X (self,arg) \
PyObject * self; \
PyObject * arg; \
{ \
PyCursesInitialised \
if (!PyArg_NoArgs(arg)) return NULL; \
X(); \
Py_INCREF(Py_None); \
return Py_None; }
NoArgNoReturnFunction
(
beep
)
NoArgNoReturnFunction
(
def_prog_mode
)
NoArgNoReturnFunction
(
def_shell_mode
)
NoArgNoReturnFunction
(
doupdate
)
NoArgNoReturnFunction
(
endwin
)
NoArgNoReturnFunction
(
flash
)
NoArgNoReturnFunction
(
nocbreak
)
NoArgNoReturnFunction
(
noecho
)
NoArgNoReturnFunction
(
nonl
)
NoArgNoReturnFunction
(
noraw
)
NoArgNoReturnFunction
(
reset_prog_mode
)
NoArgNoReturnFunction
(
reset_shell_mode
)
NoArgNoReturnFunction
(
resetty
)
NoArgNoReturnFunction
(
savetty
)
NoArgOrFlagNoReturnFunction
(
cbreak
)
NoArgOrFlagNoReturnFunction
(
echo
)
NoArgOrFlagNoReturnFunction
(
nl
)
NoArgOrFlagNoReturnFunction
(
raw
)
NoArgReturnIntFunction
(
baudrate
)
NoArgReturnIntFunction
(
termattrs
)
NoArgReturnStringFunction
(
termname
)
NoArgReturnStringFunction
(
longname
)
NoArgTrueFalseFunction
(
can_change_color
)
NoArgTrueFalseFunction
(
has_colors
)
NoArgTrueFalseFunction
(
has_ic
)
NoArgTrueFalseFunction
(
has_il
)
NoArgTrueFalseFunction
(
isendwin
)
NoArgNoReturnVoidFunction
(
filter
)
NoArgNoReturnVoidFunction
(
flushinp
)
NoArgNoReturnVoidFunction
(
noqiflush
)
static
PyObject
*
PyCurses_Color_Content
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
short
color
,
r
,
g
,
b
;
PyCursesInitialised
PyCursesInitialisedColor
if
(
ARG_COUNT
(
arg
)
!=
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"color_content requires 1 argument"
);
return
NULL
;
}
if
(
!
PyArg_Parse
(
arg
,
"h;color"
,
&
color
))
return
NULL
;
if
(
color_content
(
color
,
&
r
,
&
g
,
&
b
)
!=
ERR
)
return
Py_BuildValue
(
"(iii)"
,
r
,
g
,
b
);
else
{
PyErr_SetString
(
PyCursesError
,
"Argument 1 was out of range. Check value of COLORS."
);
return
NULL
;
}
}
static
PyObject
*
PyCurses_COLOR_PAIR
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
int
n
;
PyCursesInitialised
PyCursesInitialisedColor
if
(
ARG_COUNT
(
arg
)
!=
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"COLOR_PAIR requires 1 argument"
);
return
NULL
;
}
if
(
!
PyArg_Parse
(
arg
,
"i;number"
,
&
n
))
return
NULL
;
return
PyInt_FromLong
((
long
)
(
n
<<
8
));
}
static
PyObject
*
PyCurses_Curs_Set
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
int
vis
,
erg
;
PyCursesInitialised
if
(
ARG_COUNT
(
arg
)
==
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"curs_set requires 1 argument"
);
return
NULL
;
}
if
(
!
PyArg_Parse
(
arg
,
"i;int"
,
&
vis
))
return
NULL
;
erg
=
curs_set
(
vis
);
if
(
erg
==
ERR
)
return
PyCursesCheckERR
(
erg
,
"curs_set"
);
return
PyInt_FromLong
((
long
)
erg
);
}
static
PyObject
*
PyCurses_Delay_Output
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
int
ms
;
PyCursesInitialised
if
(
ARG_COUNT
(
arg
)
==
1
)
{
PyErr_SetString
(
PyExc_TypeError
,
"delay_output requires 1 argument"
);
return
NULL
;
}
if
(
!
PyArg_Parse
(
arg
,
"i;ms"
,
&
ms
))
return
NULL
;
return
PyCursesCheckERR
(
delay_output
(
ms
),
"delay_output"
);
}
static
PyObject
*
PyCurses_EraseChar
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
char
ch
;
PyCursesInitialised
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
ch
=
erasechar
();
return
PyString_FromString
(
&
ch
);
}
static
PyObject
*
PyCurses_getsyx
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
int
x
,
y
;
PyCursesInitialised
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
getsyx
(
y
,
x
);
return
Py_BuildValue
(
"(ii)"
,
y
,
x
);
}
static
PyObject
*
PyCurses_GetWin
(
self
,
arg
)
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
{
WINDOW
*
win
;
PyObject
*
temp
;
PyCursesInitialised
if
(
!
PyArg_Parse
(
arg
,
"O;fileobj"
,
&
temp
))
return
NULL
;
if
(
!
PyFile_Check
(
temp
))
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a file object"
);
return
NULL
;
}
win
=
getwin
(
PyFile_AsFile
(
temp
));
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
}
return
PyCursesWindow_New
(
win
);
}
static
PyObject
*
PyCurses_HalfDelay
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
unsigned
char
tenths
;
PyCursesInitialised
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"b;tenths"
,
&
tenths
))
return
NULL
;
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"halfdelay requires 1 argument"
);
return
NULL
;
}
return
PyCursesCheckERR
(
halfdelay
(
tenths
),
"halfdelay"
);
}
#ifndef __sgi__
/* No has_key! */
static
PyObject
*
PyCurses_has_key
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
int
ch
;
PyCursesInitialised
if
(
!
PyArg_Parse
(
arg
,
"i"
,
&
ch
))
return
NULL
;
if
(
has_key
(
ch
)
==
FALSE
)
{
Py_INCREF
(
Py_False
);
return
Py_False
;
}
Py_INCREF
(
Py_True
);
return
Py_True
;
}
#endif
#endif
static
PyObject
*
PyCurses_Init_Color
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
short
color
,
r
,
g
,
b
;
/* -------------------------------------------------------*/
PyCursesInitialised
PyCursesInitialisedColor
static
PyObject
*
ModDict
;
switch
(
ARG_COUNT
(
arg
))
{
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(hhhh);color,r,g,b"
,
&
color
,
&
r
,
&
g
,
&
b
))
return
NULL
;
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"init_color requires 4 arguments"
);
return
NULL
;
}
return
PyCursesCheckERR
(
init_color
(
color
,
r
,
g
,
b
),
"init_color"
);
}
static
PyObject
*
PyCurses_Init_Pair
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
short
pair
,
f
,
b
;
PyCursesInitialised
PyCursesInitialisedColor
if
(
ARG_COUNT
(
arg
)
==
3
)
{
PyErr_SetString
(
PyExc_TypeError
,
"init_pair requires 3 arguments"
);
return
NULL
;
}
if
(
!
PyArg_Parse
(
arg
,
"(hhh);pair, f, b"
,
&
pair
,
&
f
,
&
b
))
return
NULL
;
return
PyCursesCheckERR
(
init_pair
(
pair
,
f
,
b
),
"init_pair"
);
}
static
PyObject
*
static
PyObject
*
PyCurses_InitScr
(
self
,
args
)
PyCurses_InitScr
(
self
,
args
)
...
@@ -1208,14 +1665,17 @@ PyCurses_InitScr(self, args)
...
@@ -1208,14 +1665,17 @@ PyCurses_InitScr(self, args)
PyObject
*
args
;
PyObject
*
args
;
{
{
WINDOW
*
win
;
WINDOW
*
win
;
if
(
!
PyArg_NoArgs
(
args
))
PyObject
*
lines
,
*
cols
;
return
NULL
;
if
(
!
PyArg_NoArgs
(
args
))
return
NULL
;
if
(
initialised
==
TRUE
)
{
if
(
initialised
==
TRUE
)
{
wrefresh
(
stdscr
);
wrefresh
(
stdscr
);
return
(
PyObject
*
)
PyCursesWindow_New
(
stdscr
);
return
(
PyObject
*
)
PyCursesWindow_New
(
stdscr
);
}
}
win
=
initscr
();
win
=
initscr
();
if
(
win
==
NULL
)
{
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
return
NULL
;
...
@@ -1223,75 +1683,110 @@ PyCurses_InitScr(self, args)
...
@@ -1223,75 +1683,110 @@ PyCurses_InitScr(self, args)
initialised
=
TRUE
;
initialised
=
TRUE
;
/* This was moved from initcurses() because core dumped on SGI */
lines
=
PyInt_FromLong
((
long
)
LINES
);
/* Also, they are probably not defined until you've called initscr() */
PyDict_SetItemString
(
ModDict
,
"LINES"
,
lines
);
#define SetDictInt(string,ch) \
Py_DECREF
(
lines
);
PyDict_SetItemString(ModDict,string,PyInt_FromLong((long) (ch)));
cols
=
PyInt_FromLong
((
long
)
COLS
);
PyDict_SetItemString
(
ModDict
,
"COLS"
,
cols
);
/* Here are some graphic symbols you can use */
Py_DECREF
(
cols
);
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_LARROW
));
SetDictInt
(
"ACS_RARROW"
,
(
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
));
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
}
}
static
PyObject
*
PyCurses_EndWin
(
self
,
args
)
static
PyObject
*
PyCurses_IntrFlush
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
s
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
args
)
||
!
PyCursesInitialised
())
int
ch
;
PyCursesInitialised
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
return
NULL
;
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"intrflush requires 1 argument"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
endwin
(),
"endwin"
);
}
return
PyCursesCheckERR
(
intrflush
(
NULL
,
ch
),
"intrflush"
);
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
IsEndWin
(
self
,
args
)
PyCurses_
KeyName
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
args
;
PyObject
*
arg
;
{
const
char
*
knp
;
int
ch
;
PyCursesInitialised
if
(
!
PyArg_Parse
(
arg
,
"i"
,
&
ch
))
return
NULL
;
knp
=
keyname
(
ch
);
return
PyString_FromString
((
knp
==
NULL
)
?
""
:
(
char
*
)
knp
);
}
static
PyObject
*
PyCurses_KillChar
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
char
ch
;
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
ch
=
killchar
();
return
PyString_FromString
(
&
ch
);
}
static
PyObject
*
PyCurses_Meta
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
args
))
int
ch
;
PyCursesInitialised
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
return
NULL
;
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"meta requires 1 argument"
);
return
NULL
;
return
NULL
;
if
(
isendwin
()
==
FALSE
)
{
Py_INCREF
(
Py_False
);
return
Py_False
;
}
}
Py_INCREF
(
Py_True
);
return
Py
_True
;
return
Py
CursesCheckERR
(
meta
(
stdscr
,
ch
),
"meta"
)
;
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
DoUpdate
(
self
,
arg
)
PyCurses_
NewPad
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
WINDOW
*
win
;
int
nlines
,
ncols
;
PyCursesInitialised
if
(
!
PyArg_Parse
(
arg
,
"(ii);nlines,ncols"
,
&
nlines
,
&
ncols
))
return
NULL
;
win
=
newpad
(
nlines
,
ncols
);
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
doupdate
(),
"doupdate"
);
}
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1302,25 +1797,25 @@ PyCurses_NewWindow(self,arg)
...
@@ -1302,25 +1797,25 @@ PyCurses_NewWindow(self,arg)
WINDOW
*
win
;
WINDOW
*
win
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
if
(
!
PyCursesInitialised
())
PyCursesInitialised
return
NULL
;
nlines
=
ncols
=
0
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
2
:
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);
begin)_y,begin_x"
,
&
begin_y
,
&
begin_x
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);
nlines,ncols"
,
&
nlines
,
&
ncols
))
return
NULL
;
return
NULL
;
win
=
newpad
(
nlines
,
ncols
);
break
;
break
;
case
4
:
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(iiii);nlines,ncols,begin_y,begin_x"
,
if
(
!
PyArg_Parse
(
arg
,
"(iiii);nlines,ncols,begin_y,begin_x"
,
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
return
NULL
;
return
NULL
;
win
=
newwin
(
nlines
,
ncols
,
begin_y
,
begin_x
);
break
;
break
;
default:
default:
PyErr_SetString
(
PyExc_TypeError
,
"newwin requires 2 or 4 arguments"
);
PyErr_SetString
(
PyExc_TypeError
,
"newwin requires 2 or 4 arguments"
);
return
NULL
;
return
NULL
;
}
}
win
=
newwin
(
nlines
,
ncols
,
begin_y
,
begin_x
);
if
(
win
==
NULL
)
{
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
return
NULL
;
...
@@ -1330,216 +1825,281 @@ PyCurses_NewWindow(self,arg)
...
@@ -1330,216 +1825,281 @@ PyCurses_NewWindow(self,arg)
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
Beep
(
self
,
arg
)
PyCurses_
Pair_Content
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
short
pair
,
f
,
b
;
return
NULL
;
beep
();
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
PyCursesInitialised
PyCurses_Flash
(
self
,
arg
)
PyCursesInitialisedColor
PyObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
return
NULL
;
flash
();
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
switch
(
ARG_COUNT
(
arg
))
{
PyCurses_UngetCh
(
self
,
arg
)
case
1
:
PyObject
*
self
;
if
(
!
PyArg_Parse
(
arg
,
"h;pair"
,
&
pair
))
return
NULL
;
PyObject
*
arg
;
break
;
{
default:
int
ch
;
PyErr_SetString
(
PyExc_TypeError
,
"pair_content requires 1 argument"
);
if
(
!
PyArg_Parse
(
arg
,
"i;integer"
,
&
ch
)
||
!
PyCursesInitialised
())
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
ungetch
(
ch
),
"ungetch"
);
}
}
static
PyObject
*
if
(
!
pair_content
(
pair
,
&
f
,
&
b
))
{
PyCurses_FlushInp
(
self
,
arg
)
PyErr_SetString
(
PyCursesError
,
PyObject
*
self
;
"Argument 1 was out of range. (1..COLOR_PAIRS-1)"
);
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
return
NULL
;
return
NULL
;
flushinp
();
}
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
PyObject
*
return
Py_BuildValue
(
"(ii)"
,
f
,
b
);
PyCurses_CBreak
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
return
NULL
;
return
PyCursesCheckERR
(
cbreak
(),
"cbreak"
);
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
NoCBreak
(
self
,
arg
)
PyCurses_
PAIR_NUMBER
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
int
n
;
return
NULL
;
return
PyCursesCheckERR
(
nocbreak
(),
"nocbreak"
);
}
static
PyObject
*
PyCursesInitialised
PyCurses_Echo
(
self
,
arg
)
PyCursesInitialisedColor
PyObject
*
self
;
PyObject
*
arg
;
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
return
NULL
;
return
PyCursesCheckERR
(
echo
(),
"echo"
);
}
static
PyObject
*
switch
(
ARG_COUNT
(
arg
))
{
PyCurses_NoEcho
(
self
,
arg
)
case
1
:
PyObject
*
self
;
if
(
!
PyArg_Parse
(
arg
,
"i;pairvalue"
,
&
n
))
return
NULL
;
PyObject
*
arg
;
break
;
{
default:
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
PyErr_SetString
(
PyExc_TypeError
,
"PAIR_NUMBER requires 1 argument"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
noecho
(),
"noecho"
);
}
return
PyInt_FromLong
((
long
)
((
n
&
A_COLOR
)
>>
8
));
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
Nl
(
self
,
arg
)
PyCurses_
Putp
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
char
*
str
;
return
NULL
;
return
PyCursesCheckERR
(
nl
(),
"nl"
);
if
(
!
PyArg_Parse
(
arg
,
"s;str"
,
&
str
))
return
NULL
;
return
PyCursesCheckERR
(
putp
(
str
),
"putp"
);
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
NoNl
(
self
,
arg
)
PyCurses_
QiFlush
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
int
flag
=
0
;
PyCursesInitialised
switch
(
ARG_COUNT
(
arg
))
{
case
0
:
qiflush
();
Py_INCREF
(
Py_None
);
return
Py_None
;
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
flag
))
return
NULL
;
if
(
flag
)
qiflush
();
else
noqiflush
();
Py_INCREF
(
Py_None
);
return
Py_None
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"nl requires 0 or 1 argument"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
nonl
(),
"nonl"
);
}
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
Raw
(
self
,
arg
)
PyCurses_
setsyx
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
int
y
,
x
;
PyCursesInitialised
if
(
ARG_COUNT
(
arg
)
!=
3
)
{
PyErr_SetString
(
PyExc_TypeError
,
"curs_set requires 3 argument"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
raw
(),
"raw"
);
}
if
(
!
PyArg_Parse
(
arg
,
"(ii);y, x"
,
&
y
,
&
x
))
return
NULL
;
setsyx
(
y
,
x
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
NoRaw
(
self
,
arg
)
PyCurses_
Start_Color
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
)
||
!
PyCursesInitialised
())
int
code
;
PyObject
*
c
,
*
cp
;
PyCursesInitialised
if
(
!
PyArg_NoArgs
(
arg
))
return
NULL
;
code
=
start_color
();
if
(
code
!=
ERR
)
{
initialisedcolors
=
TRUE
;
c
=
PyInt_FromLong
((
long
)
COLORS
);
PyDict_SetItemString
(
ModDict
,
"COLORS"
,
c
);
Py_DECREF
(
c
);
cp
=
PyInt_FromLong
((
long
)
COLOR_PAIRS
);
PyDict_SetItemString
(
ModDict
,
"COLOR_PAIRS"
,
cp
);
Py_DECREF
(
cp
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
else
{
PyErr_SetString
(
PyCursesError
,
"start_color() returned ERR"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
noraw
(),
"noraw"
);
}
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
IntrFlush
(
self
,
arg
)
PyCurses_
UnCtrl
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch
;
PyObject
*
temp
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
chtype
ch
;
PyCursesInitialised
if
(
!
PyArg_Parse
(
arg
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
PyInt_Check
(
temp
))
ch
=
(
chtype
)
PyInt_AsLong
(
temp
);
else
if
(
PyString_Check
(
temp
))
ch
=
(
chtype
)
*
PyString_AsString
(
temp
);
else
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
intrflush
(
NULL
,
ch
),
"intrflush"
);
}
return
PyString_FromString
(
unctrl
(
ch
));
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
Meta
(
self
,
arg
)
PyCurses_
UngetCh
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
ch
;
PyObject
*
temp
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
)
||
!
PyCursesInitialised
())
chtype
ch
;
PyCursesInitialised
if
(
!
PyArg_Parse
(
arg
,
"O;ch or int"
,
&
temp
))
return
NULL
;
if
(
PyInt_Check
(
temp
))
ch
=
(
chtype
)
PyInt_AsLong
(
temp
);
else
if
(
PyString_Check
(
temp
))
ch
=
(
chtype
)
*
PyString_AsString
(
temp
);
else
{
PyErr_SetString
(
PyExc_TypeError
,
"argument must be a ch or an int"
);
return
NULL
;
return
NULL
;
return
PyCursesCheckERR
(
meta
(
stdscr
,
ch
),
"meta"
);
}
return
PyCursesCheckERR
(
ungetch
(
ch
),
"ungetch"
);
}
}
static
PyObject
*
static
PyObject
*
PyCurses_
KeyName
(
self
,
arg
)
PyCurses_
Use_Env
(
self
,
arg
)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
const
char
*
knp
;
int
flag
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i"
,
&
ch
))
return
NULL
;
knp
=
keyname
(
ch
);
return
PyString_FromString
((
knp
==
NULL
)
?
""
:
knp
);
}
#ifdef NOT_YET
PyCursesInitialised
static
PyObject
*
PyCurses_NewTerm
(
self
,
args
)
PyObject
*
self
;
PyObject
*
args
;
{
}
static
PyObject
*
switch
(
ARG_COUNT
(
arg
))
{
PyCurses_SetTerm
(
self
,
args
)
case
1
:
PyObject
*
self
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
flag
))
PyObject
*
args
;
return
NULL
;
{
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"use_env requires 1 argument"
);
return
NULL
;
}
use_env
(
flag
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
#endif
/* List of functions defined in the module */
/* List of functions defined in the module */
static
PyMethodDef
PyCurses_methods
[]
=
{
static
PyMethodDef
PyCurses_methods
[]
=
{
{
"initscr"
,
(
PyCFunction
)
PyCurses_InitScr
},
{
"baudrate"
,
(
PyCFunction
)
PyCurses_baudrate
},
{
"endwin"
,
(
PyCFunction
)
PyCurses_EndWin
},
{
"beep"
,
(
PyCFunction
)
PyCurses_beep
},
{
"isendwin"
,
(
PyCFunction
)
PyCurses_IsEndWin
},
{
"can_change_color"
,
(
PyCFunction
)
PyCurses_can_change_color
},
{
"doupdate"
,
(
PyCFunction
)
PyCurses_DoUpdate
},
{
"cbreak"
,
(
PyCFunction
)
PyCurses_cbreak
},
{
"newwin"
,
(
PyCFunction
)
PyCurses_NewWindow
},
{
"color_content"
,
(
PyCFunction
)
PyCurses_Color_Content
},
{
"beep"
,
(
PyCFunction
)
PyCurses_Beep
},
{
"COLOR_PAIR"
,
(
PyCFunction
)
PyCurses_COLOR_PAIR
},
{
"flash"
,
(
PyCFunction
)
PyCurses_Flash
},
{
"curs_set"
,
(
PyCFunction
)
PyCurses_Curs_Set
},
{
"ungetch"
,
(
PyCFunction
)
PyCurses_UngetCh
},
{
"def_prog_mode"
,
(
PyCFunction
)
PyCurses_def_prog_mode
},
{
"flushinp"
,
(
PyCFunction
)
PyCurses_FlushInp
},
{
"def_shell_mode"
,
(
PyCFunction
)
PyCurses_def_shell_mode
},
{
"cbreak"
,
(
PyCFunction
)
PyCurses_CBreak
},
{
"delay_output"
,
(
PyCFunction
)
PyCurses_Delay_Output
},
{
"nocbreak"
,
(
PyCFunction
)
PyCurses_NoCBreak
},
{
"doupdate"
,
(
PyCFunction
)
PyCurses_doupdate
},
{
"echo"
,
(
PyCFunction
)
PyCurses_Echo
},
{
"echo"
,
(
PyCFunction
)
PyCurses_echo
},
{
"noecho"
,
(
PyCFunction
)
PyCurses_NoEcho
},
{
"endwin"
,
(
PyCFunction
)
PyCurses_endwin
},
{
"nl"
,
(
PyCFunction
)
PyCurses_Nl
},
{
"erasechar"
,
(
PyCFunction
)
PyCurses_EraseChar
},
{
"nonl"
,
(
PyCFunction
)
PyCurses_NoNl
},
{
"filter"
,
(
PyCFunction
)
PyCurses_filter
},
{
"raw"
,
(
PyCFunction
)
PyCurses_Raw
},
{
"flash"
,
(
PyCFunction
)
PyCurses_flash
},
{
"noraw"
,
(
PyCFunction
)
PyCurses_NoRaw
},
{
"flushinp"
,
(
PyCFunction
)
PyCurses_flushinp
},
{
"intrflush"
,
(
PyCFunction
)
PyCurses_IntrFlush
},
{
"getsyx"
,
(
PyCFunction
)
PyCurses_getsyx
},
{
"meta"
,
(
PyCFunction
)
PyCurses_Meta
},
{
"getwin"
,
(
PyCFunction
)
PyCurses_GetWin
},
{
"keyname"
,
(
PyCFunction
)
PyCurses_KeyName
},
{
"has_colors"
,
(
PyCFunction
)
PyCurses_has_colors
},
#ifdef NOT_YET
{
"has_ic"
,
(
PyCFunction
)
PyCurses_has_ic
},
{
"newterm"
,
(
PyCFunction
)
PyCurses_NewTerm
},
{
"has_il"
,
(
PyCFunction
)
PyCurses_has_il
},
{
"set_term"
,
(
PyCFunction
)
PyCurses_SetTerm
},
#ifndef __sgi__
{
"has_key"
,
(
PyCFunction
)
PyCurses_has_key
},
#endif
#endif
{
NULL
,
NULL
}
/* sentinel */
{
"halfdelay"
,
(
PyCFunction
)
PyCurses_HalfDelay
},
{
"init_color"
,
(
PyCFunction
)
PyCurses_Init_Color
},
{
"init_pair"
,
(
PyCFunction
)
PyCurses_Init_Pair
},
{
"initscr"
,
(
PyCFunction
)
PyCurses_InitScr
},
{
"intrflush"
,
(
PyCFunction
)
PyCurses_IntrFlush
},
{
"isendwin"
,
(
PyCFunction
)
PyCurses_isendwin
},
{
"keyname"
,
(
PyCFunction
)
PyCurses_KeyName
},
{
"killchar"
,
(
PyCFunction
)
PyCurses_KillChar
},
{
"longname"
,
(
PyCFunction
)
PyCurses_longname
},
{
"meta"
,
(
PyCFunction
)
PyCurses_Meta
},
{
"newpad"
,
(
PyCFunction
)
PyCurses_NewPad
},
{
"newwin"
,
(
PyCFunction
)
PyCurses_NewWindow
},
{
"nl"
,
(
PyCFunction
)
PyCurses_nl
},
{
"nocbreak"
,
(
PyCFunction
)
PyCurses_nocbreak
},
{
"noecho"
,
(
PyCFunction
)
PyCurses_noecho
},
{
"nonl"
,
(
PyCFunction
)
PyCurses_nonl
},
{
"noqiflush"
,
(
PyCFunction
)
PyCurses_noqiflush
},
{
"noraw"
,
(
PyCFunction
)
PyCurses_noraw
},
{
"pair_content"
,
(
PyCFunction
)
PyCurses_Pair_Content
},
{
"PAIR_NUMBER"
,
(
PyCFunction
)
PyCurses_PAIR_NUMBER
},
{
"putp"
,
(
PyCFunction
)
PyCurses_Putp
},
{
"qiflush"
,
(
PyCFunction
)
PyCurses_QiFlush
},
{
"raw"
,
(
PyCFunction
)
PyCurses_raw
},
{
"reset_prog_mode"
,
(
PyCFunction
)
PyCurses_reset_prog_mode
},
{
"reset_shell_mode"
,
(
PyCFunction
)
PyCurses_reset_shell_mode
},
{
"setsyx"
,
(
PyCFunction
)
PyCurses_setsyx
},
{
"start_color"
,
(
PyCFunction
)
PyCurses_Start_Color
},
{
"termattrs"
,
(
PyCFunction
)
PyCurses_termattrs
},
{
"termname"
,
(
PyCFunction
)
PyCurses_termname
},
{
"unctrl"
,
(
PyCFunction
)
PyCurses_UnCtrl
},
{
"ungetch"
,
(
PyCFunction
)
PyCurses_UngetCh
},
{
"use_env"
,
(
PyCFunction
)
PyCurses_Use_Env
},
{
NULL
,
NULL
}
/* sentinel */
};
};
/* Initialization function for the module */
/* Initialization function for the module */
DL_EXPORT
(
void
)
void
initcurses
()
initcurses
()
{
{
PyObject
*
m
,
*
d
,
*
v
;
PyObject
*
m
,
*
d
,
*
v
;
...
@@ -1552,7 +2112,7 @@ initcurses()
...
@@ -1552,7 +2112,7 @@ initcurses()
ModDict
=
d
;
/* For PyCurses_InitScr */
ModDict
=
d
;
/* For PyCurses_InitScr */
/* For exception curses.error */
/* For exception curses.error */
PyCursesError
=
Py
Err_NewException
(
"curses.error"
,
NULL
,
NULL
);
PyCursesError
=
Py
String_FromString
(
"curses.error"
);
PyDict_SetItemString
(
d
,
"error"
,
PyCursesError
);
PyDict_SetItemString
(
d
,
"error"
,
PyCursesError
);
/* Make the version available */
/* Make the version available */
...
@@ -1562,14 +2122,107 @@ initcurses()
...
@@ -1562,14 +2122,107 @@ initcurses()
Py_DECREF
(
v
);
Py_DECREF
(
v
);
/* Here are some attributes you can add to chars to print */
/* Here are some attributes you can add to chars to print */
SetDictInt
(
"A_NORMAL"
,
A_NORMAL
);
SetDictInt
(
"A_STANDOUT"
,
A_STANDOUT
);
#define SetDictInt(string,ch) \
SetDictInt
(
"A_UNDERLINE"
,
A_UNDERLINE
);
PyDict_SetItemString(ModDict,string,PyInt_FromLong((long) (ch)));
SetDictInt
(
"A_REVERSE"
,
A_REVERSE
);
SetDictInt
(
"A_BLINK"
,
A_BLINK
);
#ifndef __sgi__
SetDictInt
(
"A_DIM"
,
A_DIM
);
/* On IRIX 5.3, the ACS characters aren't available until initscr() has been called. */
SetDictInt
(
"A_BOLD"
,
A_BOLD
);
SetDictInt
(
"ACS_ULCORNER"
,
(
ACS_ULCORNER
));
SetDictInt
(
"A_ALTCHARSET"
,
A_ALTCHARSET
);
SetDictInt
(
"ACS_LLCORNER"
,
(
ACS_LLCORNER
));
SetDictInt
(
"ACS_URCORNER"
,
(
ACS_URCORNER
));
SetDictInt
(
"ACS_LRCORNER"
,
(
ACS_LRCORNER
));
SetDictInt
(
"ACS_LTEE"
,
(
ACS_LTEE
));
SetDictInt
(
"ACS_RTEE"
,
(
ACS_RTEE
));
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_LARROW
));
SetDictInt
(
"ACS_RARROW"
,
(
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
));
#ifndef __sgi__
/* The following are never available on IRIX 5.3 */
SetDictInt
(
"ACS_S3"
,
(
ACS_S3
));
SetDictInt
(
"ACS_LEQUAL"
,
(
ACS_LEQUAL
));
SetDictInt
(
"ACS_GEQUAL"
,
(
ACS_GEQUAL
));
SetDictInt
(
"ACS_PI"
,
(
ACS_PI
));
SetDictInt
(
"ACS_NEQUAL"
,
(
ACS_NEQUAL
));
SetDictInt
(
"ACS_STERLING"
,
(
ACS_STERLING
));
#endif
SetDictInt
(
"ACS_BSSB"
,
(
ACS_ULCORNER
));
SetDictInt
(
"ACS_SSBB"
,
(
ACS_LLCORNER
));
SetDictInt
(
"ACS_BBSS"
,
(
ACS_URCORNER
));
SetDictInt
(
"ACS_SBBS"
,
(
ACS_LRCORNER
));
SetDictInt
(
"ACS_SBSS"
,
(
ACS_RTEE
));
SetDictInt
(
"ACS_SSSB"
,
(
ACS_LTEE
));
SetDictInt
(
"ACS_SSBS"
,
(
ACS_BTEE
));
SetDictInt
(
"ACS_BSSS"
,
(
ACS_TTEE
));
SetDictInt
(
"ACS_BSBS"
,
(
ACS_HLINE
));
SetDictInt
(
"ACS_SBSB"
,
(
ACS_VLINE
));
SetDictInt
(
"ACS_SSSS"
,
(
ACS_PLUS
));
#endif
SetDictInt
(
"A_ATTRIBUTES"
,
A_ATTRIBUTES
);
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
);
SetDictInt
(
"A_INVIS"
,
A_INVIS
);
SetDictInt
(
"A_PROTECT"
,
A_PROTECT
);
#ifndef __sgi__
SetDictInt
(
"A_HORIZONTAL"
,
A_HORIZONTAL
);
SetDictInt
(
"A_LEFT"
,
A_LEFT
);
SetDictInt
(
"A_LOW"
,
A_LOW
);
SetDictInt
(
"A_RIGHT"
,
A_RIGHT
);
SetDictInt
(
"A_TOP"
,
A_TOP
);
SetDictInt
(
"A_VERTICAL"
,
A_VERTICAL
);
#endif
SetDictInt
(
"A_CHARTEXT"
,
A_CHARTEXT
);
SetDictInt
(
"A_COLOR"
,
A_COLOR
);
#ifndef __sgi__
SetDictInt
(
"WA_ATTRIBUTES"
,
WA_ATTRIBUTES
);
SetDictInt
(
"WA_NORMAL"
,
WA_NORMAL
);
SetDictInt
(
"WA_STANDOUT"
,
WA_STANDOUT
);
SetDictInt
(
"WA_UNDERLINE"
,
WA_UNDERLINE
);
SetDictInt
(
"WA_REVERSE"
,
WA_REVERSE
);
SetDictInt
(
"WA_BLINK"
,
WA_BLINK
);
SetDictInt
(
"WA_DIM"
,
WA_DIM
);
SetDictInt
(
"WA_BOLD"
,
WA_BOLD
);
SetDictInt
(
"WA_ALTCHARSET"
,
WA_ALTCHARSET
);
SetDictInt
(
"WA_INVIS"
,
WA_INVIS
);
SetDictInt
(
"WA_PROTECT"
,
WA_PROTECT
);
SetDictInt
(
"WA_HORIZONTAL"
,
WA_HORIZONTAL
);
SetDictInt
(
"WA_LEFT"
,
WA_LEFT
);
SetDictInt
(
"WA_LOW"
,
WA_LOW
);
SetDictInt
(
"WA_RIGHT"
,
WA_RIGHT
);
SetDictInt
(
"WA_TOP"
,
WA_TOP
);
SetDictInt
(
"WA_VERTICAL"
,
WA_VERTICAL
);
#endif
SetDictInt
(
"COLOR_BLACK"
,
COLOR_BLACK
);
SetDictInt
(
"COLOR_RED"
,
COLOR_RED
);
SetDictInt
(
"COLOR_GREEN"
,
COLOR_GREEN
);
SetDictInt
(
"COLOR_YELLOW"
,
COLOR_YELLOW
);
SetDictInt
(
"COLOR_BLUE"
,
COLOR_BLUE
);
SetDictInt
(
"COLOR_MAGENTA"
,
COLOR_MAGENTA
);
SetDictInt
(
"COLOR_CYAN"
,
COLOR_CYAN
);
SetDictInt
(
"COLOR_WHITE"
,
COLOR_WHITE
);
/* Now set everything up for KEY_ variables */
/* Now set everything up for KEY_ variables */
{
{
...
@@ -1602,4 +2255,10 @@ initcurses()
...
@@ -1602,4 +2255,10 @@ initcurses()
SetDictInt
(
"KEY_MIN"
,
KEY_MIN
);
SetDictInt
(
"KEY_MIN"
,
KEY_MIN
);
SetDictInt
(
"KEY_MAX"
,
KEY_MAX
);
SetDictInt
(
"KEY_MAX"
,
KEY_MAX
);
}
}
/* Check for errors */
if
(
PyErr_Occurred
())
Py_FatalError
(
"can't initialize module curses"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment