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
8573847a
Commit
8573847a
authored
Feb 17, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Steve Clifts version
parent
256cbd74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
434 additions
and
406 deletions
+434
-406
Modules/_cursesmodule.c
Modules/_cursesmodule.c
+434
-406
No files found.
Modules/_cursesmodule.c
View file @
8573847a
...
@@ -40,15 +40,14 @@ in the curses module:
...
@@ -40,15 +40,14 @@ in the curses module:
Return Value Func/Attr Description
Return Value Func/Attr Description
--------------------------------------------------------------------------
--------------------------------------------------------------------------
StringObject
__version__ This returns a string representing
StringObject
version A string representing the current
the current version of this module
version of this module.
WindowObject initscr() This initializes the screen for use
WindowObject initscr() This initializes the screen for use
None endwin() Closes down the screen and returns
None endwin() Closes down the screen and returns
things as they were before calling
things as they were before calling
initscr()
initscr()
True/FalseObject isendwin() Has endwin() been called?
True/FalseObject isendwin() Has endwin() been called?
IntObject doupdate() Updates screen and returns number
None doupdate() Updates screen
of bytes written to screen
WindowObject newwin(nlines,ncols,begin_y,begin_x)
WindowObject newwin(nlines,ncols,begin_y,begin_x)
newwin(begin_y,begin_x)
newwin(begin_y,begin_x)
newwin() creates and returns
newwin() creates and returns
...
@@ -79,34 +78,34 @@ in the WindowObject:
...
@@ -79,34 +78,34 @@ in the WindowObject:
Return Value Func/Attr Description
Return Value Func/Attr Description
--------------------------------------------------------------------------
--------------------------------------------------------------------------
IntObject
refresh() Do refresh
None
refresh() Do refresh
IntObject
nooutrefresh() Mark for refresh but wait
None
nooutrefresh() Mark for refresh but wait
True/False
mvwin(new_y,new_x) Move Window
None
mvwin(new_y,new_x) Move Window
True/False
move(new_y,new_x) Move Cursor
None
move(new_y,new_x) Move Cursor
WindowObject subwin(nlines,ncols,begin_y,begin_x)
WindowObject subwin(nlines,ncols,begin_y,begin_x)
subwin(begin_y,begin_x)
subwin(begin_y,begin_x)
True/False
addch(y,x,ch,attr)
None
addch(y,x,ch,attr)
addch(y,x,ch)
addch(y,x,ch)
addch(ch,attr)
addch(ch,attr)
addch(ch)
addch(ch)
True/False
insch(y,x,ch,attr)
None
insch(y,x,ch,attr)
insch(y,x,ch)
insch(y,x,ch)
insch(ch,attr)
insch(ch,attr)
insch(ch)
insch(ch)
True/False
delch(y,x)
None
delch(y,x)
delch()
delch()
True/False
echochar(ch,attr)
None
echochar(ch,attr)
echochar(ch)
echochar(ch)
True/False
addstr(y,x,str,attr)
None
addstr(y,x,str,attr)
addstr(y,x,str)
addstr(y,x,str)
addstr(str,attr)
addstr(str,attr)
addstr(str)
addstr(str)
True/False
attron(attr)
None
attron(attr)
True/False
attroff(attr)
None
attroff(attr)
True/False
attrset(sttr)
None
attrset(sttr)
True/False
standend()
None
standend()
True/False
standout()
None
standout()
True/False
box(vertch,horch) vertch and horch are INTS
None
box(vertch,horch) vertch and horch are INTS
box()
box()
None erase()
None erase()
None deleteln()
None deleteln()
...
@@ -131,6 +130,7 @@ None idlok(int) int=0 or int=1
...
@@ -131,6 +130,7 @@ None idlok(int) int=0 or int=1
None leaveok(int) int=0 or int=1
None leaveok(int) int=0 or int=1
None scrollok(int) int=0 or int=1
None scrollok(int) int=0 or int=1
None setscrreg(top,bottom)
None setscrreg(top,bottom)
None keypad(int) int=0 or int=1
None nodelay(int) int=0 or int=1
None nodelay(int) int=0 or int=1
None notimeout(int) int=0 or int=1
None notimeout(int) int=0 or int=1
******************************************************************/
******************************************************************/
...
@@ -167,13 +167,26 @@ staticforward PyTypeObject PyCursesPad_Type;
...
@@ -167,13 +167,26 @@ staticforward PyTypeObject PyCursesPad_Type;
#define PyCursesPad_Check(v) ((v)->ob_type == &PyCursesPad_Type)
#define PyCursesPad_Check(v) ((v)->ob_type == &PyCursesPad_Type)
/* Defines */
/* Defines */
PyObject
*
PyCurses_OK
;
static
PyObject
*
PyCursesError
;
/* For exception curses.error */
PyObject
*
PyCurses_ERR
;
/* Catch-all error messages */
static
char
*
catchall_ERR
=
"curses function returned ERR"
;
static
char
*
catchall_NULL
=
"curses function returned NULL"
;
#define ARG_COUNT(X) \
(((X) == NULL) ? 0 : (PyTuple_Check(X) ? PyTuple_Size(X) : 1))
/******************************************************************
/******************************************************************
Change Log:
Change Log:
Version 1.2: 95/02/17 (Steve Clift)
Fixed several potential core-dumping bugs.
Reworked arg parsing where variable arg lists are used.
Generate exceptions when ERR or NULL is returned by curses functions.
Changed return types to match SysV Curses manual descriptions.
Added keypad() to window method list doco above.
Version 1.1: 94/08/31:
Version 1.1: 94/08/31:
Minor fixes given by Guido.
Minor fixes given by Guido.
Changed 'ncurses' to 'curses'
Changed 'ncurses' to 'curses'
...
@@ -181,14 +194,45 @@ Version 1.1: 94/08/31:
...
@@ -181,14 +194,45 @@ Version 1.1: 94/08/31:
Added PyErr_Clear() where needed
Added PyErr_Clear() where needed
Moved ACS_* attribute initialization to PyCurses_InitScr() to fix
Moved ACS_* attribute initialization to PyCurses_InitScr() to fix
crash on SGI
crash on SGI
Version 1.0: 94/08/30:
Version 1.0: 94/08/30:
This is the first release of this software.
This is the first release of this software.
Released to the Internet via python-list@cwi.nl
Released to the Internet via python-list@cwi.nl
******************************************************************/
******************************************************************/
char
*
PyCursesVersion
=
"1.1"
;
char
*
PyCursesVersion
=
"1.1"
;
/*
* Check the return code from a curses function and return None
* or raise an exception as appropriate.
*/
static
PyObject
*
PyCursesCheckERR
(
code
,
fname
)
int
code
;
char
*
fname
;
{
char
buf
[
100
];
if
(
code
!=
ERR
)
{
Py_INCREF
(
Py_None
);
return
Py_None
;
}
else
{
if
(
fname
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_ERR
);
}
else
{
strcpy
(
buf
,
fname
);
strcat
(
buf
,
"() returned ERR"
);
PyErr_SetString
(
PyCursesError
,
buf
);
}
return
NULL
;
}
}
/* ------------- SCREEN routines --------------- */
/* ------------- SCREEN routines --------------- */
#ifdef NOT_YET
#ifdef NOT_YET
static
PyObject
*
static
PyObject
*
PyCursesScreen_New
(
arg
)
PyCursesScreen_New
(
arg
)
...
@@ -198,19 +242,23 @@ PyCursesScreen_New(arg)
...
@@ -198,19 +242,23 @@ PyCursesScreen_New(arg)
PyFileObject
*
in_fo
;
PyFileObject
*
in_fo
;
PyFileObject
*
out_fo
;
PyFileObject
*
out_fo
;
PyCursesScreenObject
*
xp
;
PyCursesScreenObject
*
xp
;
xp
=
(
PyObject
*
)
PyObject_NEW
(
PyCursesScreenObject
,
&
PyCursesScreen_Type
);
xp
=
PyObject_NEW
(
PyCursesScreenObject
,
&
PyCursesScreen_Type
);
if
(
xp
==
NULL
)
if
(
xp
==
NULL
)
return
NULL
;
return
NULL
;
return
(
PyObject
*
)
xp
;
return
(
PyObject
*
)
xp
;
}
}
#endif
#endif
/* ------------- WINDOW routines --------------- */
/* ------------- WINDOW routines --------------- */
static
PyObject
*
static
PyObject
*
PyCursesWindow_New
(
win
)
PyCursesWindow_New
(
win
)
WINDOW
*
win
;
WINDOW
*
win
;
{
{
PyCursesWindowObject
*
wo
;
PyCursesWindowObject
*
wo
;
wo
=
(
PyCursesWindowObject
*
)
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
;
...
@@ -233,8 +281,8 @@ PyCursesWindow_Refresh(self,arg)
...
@@ -233,8 +281,8 @@ PyCursesWindow_Refresh(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
return
(
PyObject
*
)
PyInt_FromLong
(
wrefresh
(
self
->
win
)
);
return
PyCursesCheckERR
(
wrefresh
(
self
->
win
),
"wrefresh"
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -243,8 +291,8 @@ PyCursesWindow_NoOutRefresh(self,arg)
...
@@ -243,8 +291,8 @@ PyCursesWindow_NoOutRefresh(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
return
(
PyObject
*
)
PyInt_FromLong
(
wnoutrefresh
(
self
->
win
)
);
return
PyCursesCheckERR
(
wnoutrefresh
(
self
->
win
),
"wnoutrefresh"
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -252,17 +300,10 @@ PyCursesWindow_MoveWin(self,arg)
...
@@ -252,17 +300,10 @@ PyCursesWindow_MoveWin(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
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
rtn
=
mvwin
(
self
->
win
,
y
,
x
);
return
PyCursesCheckERR
(
mvwin
(
self
->
win
,
y
,
x
),
"mvwin"
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
PyCurses_OK
);
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -270,17 +311,10 @@ PyCursesWindow_Move(self,arg)
...
@@ -270,17 +311,10 @@ PyCursesWindow_Move(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
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
rtn
=
wmove
(
self
->
win
,
y
,
x
);
return
PyCursesCheckERR
(
wmove
(
self
->
win
,
y
,
x
),
"wmove"
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
PyCurses_OK
);
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -291,18 +325,27 @@ PyCursesWindow_SubWin(self,arg)
...
@@ -291,18 +325,27 @@ PyCursesWindow_SubWin(self,arg)
WINDOW
*
win
;
WINDOW
*
win
;
PyCursesWindowObject
*
rtn_win
;
PyCursesWindowObject
*
rtn_win
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
nlines
=
0
;
nlines
=
0
;
ncols
=
0
;
ncols
=
0
;
if
(
!
PyArg_Parse
(
arg
,
switch
(
ARG_COUNT
(
arg
))
{
"(iiii);nlines,ncols,begin_y,begin_x"
,
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);begin_y,begin_x"
,
&
begin_y
,
&
begin_x
))
return
NULL
;
break
;
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(iiii);nlines,ncols,begin_y,begin_x"
,
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
PyErr_Clear
();
return
NULL
;
if
(
!
PyArg_Parse
(
arg
,
"(ii)"
,
&
begin_y
,
&
begin_x
))
break
;
return
(
PyObject
*
)
NULL
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"subwin requires 2 or 4 arguments"
);
return
NULL
;
}
win
=
subwin
(
self
->
win
,
nlines
,
ncols
,
begin_y
,
begin_x
);
win
=
subwin
(
self
->
win
,
nlines
,
ncols
,
begin_y
,
begin_x
);
if
(
win
==
NULL
)
{
if
(
win
==
NULL
)
{
Py
_INCREF
(
Py_None
);
Py
Err_SetString
(
PyCursesError
,
catchall_NULL
);
return
(
PyObject
*
)
Py_None
;
return
NULL
;
}
}
rtn_win
=
(
PyCursesWindowObject
*
)
PyCursesWindow_New
(
win
);
rtn_win
=
(
PyCursesWindowObject
*
)
PyCursesWindow_New
(
win
);
rtn_win
->
parent
=
self
->
win
;
rtn_win
->
parent
=
self
->
win
;
...
@@ -317,29 +360,34 @@ PyCursesWindow_AddCh(self,arg)
...
@@ -317,29 +360,34 @@ PyCursesWindow_AddCh(self,arg)
int
rtn
;
int
rtn
;
int
x
,
y
;
int
x
,
y
;
int
ch
;
int
ch
;
int
attr
;
int
attr
,
attr_old
;
int
attr_old
;
int
use_xy
=
FALSE
,
use_attr
=
FALSE
;
int
use_xy
=
TRUE
;
int
use_attr
=
TRUE
;
switch
(
ARG_COUNT
(
arg
))
{
switch
(
PyTuple_Size
(
arg
))
{
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;ch"
,
&
ch
))
return
NULL
;
break
;
case
2
:
case
2
:
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
return
NULL
;
use_attr
=
TRUE
;
use_attr
=
TRUE
;
break
;
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
;
use_xy
=
use_attr
=
TRUE
;
break
;
default:
default:
use_attr
=
FALSE
;
PyErr_SetString
(
PyExc_TypeError
,
"addch requires 1 to 4 arguments"
);
}
return
NULL
;
if
(
!
PyArg_Parse
(
arg
,
"(iiii);y,x,ch,attr"
,
&
y
,
&
x
,
&
ch
,
&
attr
))
{
PyErr_Clear
();
if
(
!
PyArg_Parse
(
arg
,
"(iii);y,x,ch"
,
&
y
,
&
x
,
&
ch
))
{
PyErr_Clear
();
use_xy
=
FALSE
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
PyErr_Clear
();
if
(
!
PyArg_Parse
(
arg
,
"i;ch"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
}
}
}
if
(
use_attr
==
TRUE
)
{
if
(
use_attr
==
TRUE
)
{
attr_old
=
getattrs
(
self
->
win
);
attr_old
=
getattrs
(
self
->
win
);
wattrset
(
self
->
win
,
attr
);
wattrset
(
self
->
win
,
attr
);
...
@@ -350,12 +398,8 @@ PyCursesWindow_AddCh(self,arg)
...
@@ -350,12 +398,8 @@ PyCursesWindow_AddCh(self,arg)
rtn
=
waddch
(
self
->
win
,
ch
);
rtn
=
waddch
(
self
->
win
,
ch
);
if
(
use_attr
==
TRUE
)
if
(
use_attr
==
TRUE
)
wattrset
(
self
->
win
,
attr_old
);
wattrset
(
self
->
win
,
attr_old
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
PyCurses_OK
);
return
PyCursesCheckERR
(
rtn
,
"[mv]waddch"
);
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -366,27 +410,34 @@ PyCursesWindow_InsCh(self,arg)
...
@@ -366,27 +410,34 @@ PyCursesWindow_InsCh(self,arg)
int
rtn
;
int
rtn
;
int
x
,
y
;
int
x
,
y
;
int
ch
;
int
ch
;
int
use_xy
=
TRUE
;
int
attr
,
attr_old
;
int
attr
,
attr_old
,
use_attr
=
FALSE
;
int
use_xy
=
TRUE
,
use_attr
=
FALSE
;
switch
(
PyTuple_Size
(
arg
))
{
switch
(
ARG_COUNT
(
arg
))
{
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;ch"
,
&
ch
))
return
NULL
;
break
;
case
2
:
case
2
:
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
return
NULL
;
use_attr
=
TRUE
;
use_attr
=
TRUE
;
break
;
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
;
use_xy
=
use_attr
=
TRUE
;
break
;
default:
default:
use_attr
=
FALSE
;
PyErr_SetString
(
PyExc_TypeError
,
"insch requires 1 to 4 arguments"
);
}
return
NULL
;
if
(
!
PyArg_Parse
(
arg
,
"(iiii);y,x,ch,attr"
,
&
y
,
&
x
,
&
ch
,
&
attr
))
{
PyErr_Clear
();
if
(
!
PyArg_Parse
(
arg
,
"(iii);y,x,ch"
,
&
y
,
&
x
,
&
ch
))
{
PyErr_Clear
();
use_xy
=
FALSE
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
PyErr_Clear
();
if
(
!
PyArg_Parse
(
arg
,
"i;ch"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
}
}
}
if
(
use_attr
==
TRUE
)
{
if
(
use_attr
==
TRUE
)
{
attr_old
=
getattrs
(
self
->
win
);
attr_old
=
getattrs
(
self
->
win
);
wattrset
(
self
->
win
,
attr
);
wattrset
(
self
->
win
,
attr
);
...
@@ -397,12 +448,8 @@ PyCursesWindow_InsCh(self,arg)
...
@@ -397,12 +448,8 @@ PyCursesWindow_InsCh(self,arg)
rtn
=
winsch
(
self
->
win
,
ch
);
rtn
=
winsch
(
self
->
win
,
ch
);
if
(
use_attr
==
TRUE
)
if
(
use_attr
==
TRUE
)
wattrset
(
self
->
win
,
attr_old
);
wattrset
(
self
->
win
,
attr_old
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
PyCurses_OK
);
return
PyCursesCheckERR
(
rtn
,
"[mv]winsch"
);
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -412,20 +459,22 @@ PyCursesWindow_DelCh(self,arg)
...
@@ -412,20 +459,22 @@ PyCursesWindow_DelCh(self,arg)
{
{
int
rtn
;
int
rtn
;
int
x
,
y
;
int
x
,
y
;
int
use_xy
=
TRUE
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
switch
(
ARG_COUNT
(
arg
))
{
use_xy
=
FALSE
;
case
0
:
PyErr_Clear
();
if
(
use_xy
==
TRUE
)
rtn
=
mvwdelch
(
self
->
win
,
y
,
x
);
else
rtn
=
wdelch
(
self
->
win
);
rtn
=
wdelch
(
self
->
win
);
if
(
rtn
==
OK
)
{
break
;
Py_INCREF
(
PyCurses_OK
);
case
2
:
return
(
PyObject
*
)
PyCurses_OK
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
rtn
=
mvwdelch
(
self
->
win
,
y
,
x
);
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"delch requires 0 or 2 arguments"
);
return
NULL
;
}
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
return
PyCursesCheckERR
(
rtn
,
"[mv]wdelch"
)
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -435,26 +484,28 @@ PyCursesWindow_EchoChar(self,arg)
...
@@ -435,26 +484,28 @@ PyCursesWindow_EchoChar(self,arg)
{
{
int
rtn
;
int
rtn
;
int
ch
;
int
ch
;
int
attr
,
attr_old
,
use_attr
=
TRUE
;
int
attr
,
attr_old
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
{
PyErr_Clear
();
switch
(
ARG_COUNT
(
arg
))
{
use_attr
=
FALSE
;
case
1
:
if
(
!
PyArg_Parse
(
arg
,
"i;ch"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;ch"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
}
rtn
=
wechochar
(
self
->
win
,
ch
);
if
(
use_attr
==
TRUE
)
{
break
;
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);ch,attr"
,
&
ch
,
&
attr
))
return
NULL
;
attr_old
=
getattrs
(
self
->
win
);
attr_old
=
getattrs
(
self
->
win
);
wattrset
(
self
->
win
,
attr
);
wattrset
(
self
->
win
,
attr
);
}
rtn
=
wechochar
(
self
->
win
,
ch
);
rtn
=
wechochar
(
self
->
win
,
ch
);
if
(
use_attr
==
TRUE
)
wattrset
(
self
->
win
,
attr_old
);
wattrset
(
self
->
win
,
attr_old
);
if
(
rtn
==
OK
)
{
break
;
Py_INCREF
(
PyCurses_OK
);
default:
return
(
PyObject
*
)
PyCurses_OK
;
PyErr_SetString
(
PyExc_TypeError
,
"echochar requires 1 or 2 arguments"
);
return
NULL
;
}
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
return
PyCursesCheckERR
(
rtn
,
"wechochar"
)
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -465,27 +516,34 @@ PyCursesWindow_AddStr(self,arg)
...
@@ -465,27 +516,34 @@ PyCursesWindow_AddStr(self,arg)
int
rtn
;
int
rtn
;
int
x
,
y
;
int
x
,
y
;
char
*
str
;
char
*
str
;
int
use_xy
=
TRUE
;
int
attr
,
attr_old
;
int
attr
,
attr_old
,
use_attr
=
TRUE
;
int
use_xy
=
FALSE
,
use_attr
=
FALSE
;
switch
(
PyTuple_Size
(
arg
))
{
case
2
:
switch
(
ARG_COUNT
(
arg
))
{
case
4
:
case
1
:
use_attr
=
TRUE
;
if
(
!
PyArg_Parse
(
arg
,
"s;str"
,
&
str
))
break
;
return
NULL
;
default:
break
;
use_attr
=
FALSE
;
case
2
:
}
if
(
!
PyArg_Parse
(
arg
,
"(si);str,attr"
,
&
str
,
&
attr
))
if
(
!
PyArg_Parse
(
arg
,
"(iisi);y,x,str,attr"
,
&
y
,
&
x
,
&
str
,
&
attr
))
{
return
NULL
;
PyErr_Clear
();
use_attr
=
TRUE
;
if
(
!
PyArg_Parse
(
arg
,
"(iis);y,x,str"
,
&
y
,
&
x
,
&
str
))
{
break
;
PyErr_Clear
();
case
3
:
use_xy
=
FALSE
;
if
(
!
PyArg_Parse
(
arg
,
"(iis);y,x,str"
,
&
y
,
&
x
,
&
str
))
if
(
!
PyArg_Parse
(
arg
,
"(si);str,attr"
,
&
str
,
&
attr
))
return
NULL
;
PyErr_Clear
();
use_xy
=
TRUE
;
if
(
!
PyArg_Parse
(
arg
,
"s;str"
,
&
str
))
break
;
return
(
PyObject
*
)
NULL
;
case
4
:
}
if
(
!
PyArg_Parse
(
arg
,
"(iisi);y,x,str,attr"
,
&
y
,
&
x
,
&
str
,
&
attr
))
return
NULL
;
use_xy
=
use_attr
=
TRUE
;
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"addstr requires 1 to 4 arguments"
);
return
NULL
;
}
}
if
(
use_attr
==
TRUE
)
{
if
(
use_attr
==
TRUE
)
{
attr_old
=
getattrs
(
self
->
win
);
attr_old
=
getattrs
(
self
->
win
);
wattrset
(
self
->
win
,
attr
);
wattrset
(
self
->
win
,
attr
);
...
@@ -496,12 +554,8 @@ PyCursesWindow_AddStr(self,arg)
...
@@ -496,12 +554,8 @@ PyCursesWindow_AddStr(self,arg)
rtn
=
waddstr
(
self
->
win
,
str
);
rtn
=
waddstr
(
self
->
win
,
str
);
if
(
use_attr
==
TRUE
)
if
(
use_attr
==
TRUE
)
wattrset
(
self
->
win
,
attr_old
);
wattrset
(
self
->
win
,
attr_old
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
PyCurses_OK
);
return
PyCursesCheckERR
(
rtn
,
"[mv]waddstr"
);
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -509,17 +563,12 @@ PyCursesWindow_AttrOn(self,arg)
...
@@ -509,17 +563,12 @@ PyCursesWindow_AttrOn(self,arg)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
rtn
=
wattron
(
self
->
win
,
ch
);
wattron
(
self
->
win
,
ch
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
Py_None
);
Py_INCREF
(
PyCurses_OK
);
return
Py_None
;
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -527,17 +576,12 @@ PyCursesWindow_AttrOff(self,arg)
...
@@ -527,17 +576,12 @@ PyCursesWindow_AttrOff(self,arg)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
rtn
=
wattroff
(
self
->
win
,
ch
);
wattroff
(
self
->
win
,
ch
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
Py_None
);
Py_INCREF
(
PyCurses_OK
);
return
Py_None
;
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -545,17 +589,12 @@ PyCursesWindow_AttrSet(self,arg)
...
@@ -545,17 +589,12 @@ PyCursesWindow_AttrSet(self,arg)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;attr"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
rtn
=
wattrset
(
self
->
win
,
ch
);
wattrset
(
self
->
win
,
ch
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
Py_None
);
Py_INCREF
(
PyCurses_OK
);
return
Py_None
;
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -563,16 +602,11 @@ PyCursesWindow_StandEnd(self,arg)
...
@@ -563,16 +602,11 @@ PyCursesWindow_StandEnd(self,arg)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
rtn
=
wstandend
(
self
->
win
);
wstandend
(
self
->
win
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
Py_None
);
Py_INCREF
(
PyCurses_OK
);
return
Py_None
;
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -580,16 +614,11 @@ PyCursesWindow_StandOut(self,arg)
...
@@ -580,16 +614,11 @@ PyCursesWindow_StandOut(self,arg)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
rtn
=
wstandout
(
self
->
win
);
wstandout
(
self
->
win
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
Py_None
);
Py_INCREF
(
PyCurses_OK
);
return
Py_None
;
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -597,17 +626,12 @@ PyCursesWindow_Box(self,arg)
...
@@ -597,17 +626,12 @@ PyCursesWindow_Box(self,arg)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
rtn
;
int
ch1
=
0
,
ch2
=
0
;
int
ch1
=
0
,
ch2
=
0
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);vertch,horch"
,
&
ch1
,
&
ch2
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);vertch,horch"
,
&
ch1
,
&
ch2
))
PyErr_Clear
();
PyErr_Clear
();
rtn
=
box
(
self
->
win
,
ch1
,
ch2
);
box
(
self
->
win
,
ch1
,
ch2
);
if
(
rtn
==
OK
)
{
Py_INCREF
(
Py_None
);
Py_INCREF
(
PyCurses_OK
);
return
Py_None
;
return
(
PyObject
*
)
PyCurses_OK
;
}
Py_INCREF
(
PyCurses_ERR
);
return
(
PyObject
*
)
PyCurses_ERR
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -616,10 +640,10 @@ PyCursesWindow_Erase(self,arg)
...
@@ -616,10 +640,10 @@ PyCursesWindow_Erase(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
werase
(
self
->
win
);
werase
(
self
->
win
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -628,10 +652,8 @@ PyCursesWindow_DeleteLine(self,arg)
...
@@ -628,10 +652,8 @@ PyCursesWindow_DeleteLine(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
wdeleteln
(
self
->
win
);
return
PyCursesCheckERR
(
wdeleteln
(
self
->
win
),
"wdeleteln"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -640,10 +662,8 @@ PyCursesWindow_InsertLine(self,arg)
...
@@ -640,10 +662,8 @@ PyCursesWindow_InsertLine(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
winsertln
(
self
->
win
);
return
PyCursesCheckERR
(
winsertln
(
self
->
win
),
"winsertln"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -653,9 +673,9 @@ PyCursesWindow_GetYX(self,arg)
...
@@ -653,9 +673,9 @@ PyCursesWindow_GetYX(self,arg)
{
{
int
x
,
y
;
int
x
,
y
;
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
getyx
(
self
->
win
,
y
,
x
);
getyx
(
self
->
win
,
y
,
x
);
return
(
PyObject
*
)
Py_BuildValue
(
"(ii)"
,
y
,
x
);
return
Py_BuildValue
(
"(ii)"
,
y
,
x
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -665,9 +685,9 @@ PyCursesWindow_GetBegYX(self,arg)
...
@@ -665,9 +685,9 @@ PyCursesWindow_GetBegYX(self,arg)
{
{
int
x
,
y
;
int
x
,
y
;
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
getbegyx
(
self
->
win
,
y
,
x
);
getbegyx
(
self
->
win
,
y
,
x
);
return
(
PyObject
*
)
Py_BuildValue
(
"(ii)"
,
y
,
x
);
return
Py_BuildValue
(
"(ii)"
,
y
,
x
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -677,9 +697,9 @@ PyCursesWindow_GetMaxYX(self,arg)
...
@@ -677,9 +697,9 @@ PyCursesWindow_GetMaxYX(self,arg)
{
{
int
x
,
y
;
int
x
,
y
;
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
getmaxyx
(
self
->
win
,
y
,
x
);
getmaxyx
(
self
->
win
,
y
,
x
);
return
(
PyObject
*
)
Py_BuildValue
(
"(ii)"
,
y
,
x
);
return
Py_BuildValue
(
"(ii)"
,
y
,
x
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -688,10 +708,10 @@ PyCursesWindow_Clear(self,arg)
...
@@ -688,10 +708,10 @@ PyCursesWindow_Clear(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
wclear
(
self
->
win
);
wclear
(
self
->
win
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -700,10 +720,10 @@ PyCursesWindow_ClearToBottom(self,arg)
...
@@ -700,10 +720,10 @@ PyCursesWindow_ClearToBottom(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
wclrtobot
(
self
->
win
);
wclrtobot
(
self
->
win
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -712,10 +732,10 @@ PyCursesWindow_ClearToEOL(self,arg)
...
@@ -712,10 +732,10 @@ PyCursesWindow_ClearToEOL(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
wclrtoeol
(
self
->
win
);
wclrtoeol
(
self
->
win
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -724,10 +744,8 @@ PyCursesWindow_Scroll(self,arg)
...
@@ -724,10 +744,8 @@ PyCursesWindow_Scroll(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
scroll
(
self
->
win
);
return
PyCursesCheckERR
(
scroll
(
self
->
win
),
"scroll"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -736,10 +754,8 @@ PyCursesWindow_TouchWin(self,arg)
...
@@ -736,10 +754,8 @@ PyCursesWindow_TouchWin(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
touchwin
(
self
->
win
);
return
PyCursesCheckERR
(
touchwin
(
self
->
win
),
"touchwin"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -748,11 +764,9 @@ PyCursesWindow_TouchLine(self,arg)
...
@@ -748,11 +764,9 @@ PyCursesWindow_TouchLine(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
st
,
cnt
;
int
st
,
cnt
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);start, count"
,
&
st
,
&
cnt
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);start,count"
,
&
st
,
&
cnt
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
touchline
(
self
->
win
,
st
,
cnt
);
return
PyCursesCheckERR
(
touchline
(
self
->
win
,
st
,
cnt
),
"touchline"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -761,16 +775,23 @@ PyCursesWindow_GetCh(self,arg)
...
@@ -761,16 +775,23 @@ PyCursesWindow_GetCh(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
x
,
y
;
int
x
,
y
;
int
use_xy
=
TRUE
;
int
rtn
;
int
rtn
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
use_xy
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
PyErr_Clear
();
case
0
:
if
(
use_xy
==
TRUE
)
rtn
=
mvwgetch
(
self
->
win
,
y
,
x
);
else
rtn
=
wgetch
(
self
->
win
);
rtn
=
wgetch
(
self
->
win
);
return
(
PyObject
*
)
PyInt_FromLong
(
rtn
);
break
;
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
rtn
=
mvwgetch
(
self
->
win
,
y
,
x
);
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"getch requires 0 or 2 arguments"
);
return
NULL
;
}
return
PyInt_FromLong
((
long
)
rtn
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -779,19 +800,26 @@ PyCursesWindow_GetStr(self,arg)
...
@@ -779,19 +800,26 @@ PyCursesWindow_GetStr(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
x
,
y
;
int
x
,
y
;
int
use_xy
=
TRUE
;
char
rtn
[
1024
];
/* This should be big enough.. I hope */
char
rtn
[
1024
];
/* This should be big enough.. I hope */
int
rtn2
;
int
rtn2
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
use_xy
=
FALSE
;
switch
(
ARG_COUNT
(
arg
))
{
PyErr_Clear
();
case
0
:
if
(
use_xy
==
TRUE
)
rtn2
=
mvwgetstr
(
self
->
win
,
y
,
x
,
rtn
);
else
rtn2
=
wgetstr
(
self
->
win
,
rtn
);
rtn2
=
wgetstr
(
self
->
win
,
rtn
);
break
;
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
rtn2
=
mvwgetstr
(
self
->
win
,
y
,
x
,
rtn
);
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"getstr requires 0 or 2 arguments"
);
return
NULL
;
}
if
(
rtn2
==
ERR
)
if
(
rtn2
==
ERR
)
rtn
[
0
]
=
0
;
rtn
[
0
]
=
0
;
return
(
PyObject
*
)
PyString_FromString
(
rtn
);
return
PyString_FromString
(
rtn
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -799,17 +827,23 @@ PyCursesWindow_InCh(self,arg)
...
@@ -799,17 +827,23 @@ PyCursesWindow_InCh(self,arg)
PyCursesWindowObject
*
self
;
PyCursesWindowObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
int
x
,
y
;
int
x
,
y
,
rtn
;
int
use_xy
=
TRUE
;
int
rtn
;
switch
(
ARG_COUNT
(
arg
))
{
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
case
0
:
use_xy
=
FALSE
;
PyErr_Clear
();
if
(
use_xy
==
TRUE
)
rtn
=
mvwinch
(
self
->
win
,
y
,
x
);
else
rtn
=
winch
(
self
->
win
);
rtn
=
winch
(
self
->
win
);
return
(
PyObject
*
)
PyInt_FromLong
(
rtn
);
break
;
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);y,x"
,
&
y
,
&
x
))
return
NULL
;
rtn
=
mvwinch
(
self
->
win
,
y
,
x
);
break
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"inch requires 0 or 2 arguments"
);
return
NULL
;
}
return
PyInt_FromLong
((
long
)
rtn
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -819,10 +853,10 @@ PyCursesWindow_ClearOk(self,arg)
...
@@ -819,10 +853,10 @@ PyCursesWindow_ClearOk(self,arg)
{
{
int
val
;
int
val
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
clearok
(
self
->
win
,
val
);
clearok
(
self
->
win
,
val
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -832,10 +866,10 @@ PyCursesWindow_IdlOk(self,arg)
...
@@ -832,10 +866,10 @@ PyCursesWindow_IdlOk(self,arg)
{
{
int
val
;
int
val
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
idlok
(
self
->
win
,
val
);
idlok
(
self
->
win
,
val
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -845,10 +879,10 @@ PyCursesWindow_LeaveOk(self,arg)
...
@@ -845,10 +879,10 @@ PyCursesWindow_LeaveOk(self,arg)
{
{
int
val
;
int
val
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
leaveok
(
self
->
win
,
val
);
leaveok
(
self
->
win
,
val
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -858,10 +892,10 @@ PyCursesWindow_ScrollOk(self,arg)
...
@@ -858,10 +892,10 @@ PyCursesWindow_ScrollOk(self,arg)
{
{
int
val
;
int
val
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1) or False(0)"
,
&
val
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
scrollok
(
self
->
win
,
val
);
scrollok
(
self
->
win
,
val
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -871,10 +905,8 @@ PyCursesWindow_SetScrollRegion(self,arg)
...
@@ -871,10 +905,8 @@ PyCursesWindow_SetScrollRegion(self,arg)
{
{
int
x
,
y
;
int
x
,
y
;
if
(
!
PyArg_Parse
(
arg
,
"(ii);top, bottom"
,
&
y
,
&
x
))
if
(
!
PyArg_Parse
(
arg
,
"(ii);top, bottom"
,
&
y
,
&
x
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
wsetscrreg
(
self
->
win
,
y
,
x
);
return
PyCursesCheckERR
(
wsetscrreg
(
self
->
win
,
y
,
x
),
"wsetscrreg"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -884,10 +916,10 @@ PyCursesWindow_KeyPad(self,arg)
...
@@ -884,10 +916,10 @@ PyCursesWindow_KeyPad(self,arg)
{
{
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
keypad
(
self
->
win
,
ch
);
keypad
(
self
->
win
,
ch
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -897,10 +929,10 @@ PyCursesWindow_NoDelay(self,arg)
...
@@ -897,10 +929,10 @@ PyCursesWindow_NoDelay(self,arg)
{
{
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
nodelay
(
self
->
win
,
ch
);
nodelay
(
self
->
win
,
ch
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -910,10 +942,10 @@ PyCursesWindow_NoTimeout(self,arg)
...
@@ -910,10 +942,10 @@ PyCursesWindow_NoTimeout(self,arg)
{
{
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
notimeout
(
self
->
win
,
ch
);
notimeout
(
self
->
win
,
ch
);
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyMethodDef
PyCursesWindow_Methods
[]
=
{
static
PyMethodDef
PyCursesWindow_Methods
[]
=
{
...
@@ -967,20 +999,26 @@ PyCursesWindow_GetAttr(self, name)
...
@@ -967,20 +999,26 @@ PyCursesWindow_GetAttr(self, name)
return
Py_FindMethod
(
PyCursesWindow_Methods
,
(
PyObject
*
)
self
,
name
);
return
Py_FindMethod
(
PyCursesWindow_Methods
,
(
PyObject
*
)
self
,
name
);
}
}
/* --------------- PAD routines ---------------- */
/* --------------- PAD routines ---------------- */
#ifdef NOT_YET
static
PyObject
*
static
PyObject
*
PyCursesPad_New
(
pad
)
PyCursesPad_New
(
pad
)
WINDOW
*
pad
;
WINDOW
*
pad
;
{
{
PyCursesPadObject
*
po
;
PyCursesPadObject
*
po
;
po
=
(
PyCursesPadObject
*
)
PyObject_NEW
(
PyCursesPadObject
,
&
PyCursesPad_Type
);
po
=
PyObject_NEW
(
PyCursesPadObject
,
&
PyCursesPad_Type
);
if
(
po
==
NULL
)
if
(
po
==
NULL
)
return
NULL
;
return
NULL
;
po
->
pad
=
pad
;
po
->
pad
=
pad
;
return
(
PyObject
*
)
po
;
return
(
PyObject
*
)
po
;
}
}
#endif
/* -------------------------------------------------------*/
/* -------------------------------------------------------*/
static
PyTypeObject
PyCursesScreen_Type
=
{
static
PyTypeObject
PyCursesScreen_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/*ob_size*/
0
,
/*ob_size*/
...
@@ -1038,6 +1076,7 @@ static PyTypeObject PyCursesPad_Type = {
...
@@ -1038,6 +1076,7 @@ static PyTypeObject PyCursesPad_Type = {
0
,
/*tp_hash*/
0
,
/*tp_hash*/
};
};
/* -------------------------------------------------------*/
/* -------------------------------------------------------*/
static
PyObject
*
ModDict
;
static
PyObject
*
ModDict
;
...
@@ -1050,45 +1089,51 @@ PyCurses_InitScr(self, args)
...
@@ -1050,45 +1089,51 @@ PyCurses_InitScr(self, args)
static
int
already_inited
=
FALSE
;
static
int
already_inited
=
FALSE
;
WINDOW
*
win
;
WINDOW
*
win
;
if
(
!
PyArg_NoArgs
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
if
(
already_inited
==
TRUE
)
{
if
(
already_inited
==
TRUE
)
{
wrefresh
(
stdscr
);
wrefresh
(
stdscr
);
return
(
PyObject
*
)
PyCursesWindow_New
(
stdscr
);
return
(
PyObject
*
)
PyCursesWindow_New
(
stdscr
);
}
}
already_inited
=
TRUE
;
win
=
initscr
();
win
=
initscr
();
if
(
win
==
NULL
)
{
PyErr_SetString
(
PyCursesError
,
catchall_NULL
);
return
NULL
;
}
already_inited
=
TRUE
;
/* This was moved from initcurses() because core dumped on SGI */
/* This was moved from initcurses() because core dumped on SGI */
#define SetDictChar(string,ch) \
/* Also, they are probably not defined until you've called initscr() */
PyDict_SetItemString(ModDict,string,PyInt_FromLong(ch));
#define SetDictInt(string,ch) \
PyDict_SetItemString(ModDict,string,PyInt_FromLong((long) (ch)));
/* Here are some graphic symbols you can use */
/* Here are some graphic symbols you can use */
SetDict
Char
(
"ACS_ULCORNER"
,(
ACS_ULCORNER
));
SetDict
Int
(
"ACS_ULCORNER"
,(
ACS_ULCORNER
));
SetDict
Char
(
"ACS_ULCORNER"
,(
ACS_ULCORNER
));
SetDict
Int
(
"ACS_ULCORNER"
,(
ACS_ULCORNER
));
SetDict
Char
(
"ACS_LLCORNER"
,(
ACS_LLCORNER
));
SetDict
Int
(
"ACS_LLCORNER"
,(
ACS_LLCORNER
));
SetDict
Char
(
"ACS_URCORNER"
,(
ACS_URCORNER
));
SetDict
Int
(
"ACS_URCORNER"
,(
ACS_URCORNER
));
SetDict
Char
(
"ACS_LRCORNER"
,(
ACS_LRCORNER
));
SetDict
Int
(
"ACS_LRCORNER"
,(
ACS_LRCORNER
));
SetDict
Char
(
"ACS_RTEE"
,
(
ACS_RTEE
));
SetDict
Int
(
"ACS_RTEE"
,
(
ACS_RTEE
));
SetDict
Char
(
"ACS_LTEE"
,
(
ACS_LTEE
));
SetDict
Int
(
"ACS_LTEE"
,
(
ACS_LTEE
));
SetDict
Char
(
"ACS_BTEE"
,
(
ACS_BTEE
));
SetDict
Int
(
"ACS_BTEE"
,
(
ACS_BTEE
));
SetDict
Char
(
"ACS_TTEE"
,
(
ACS_TTEE
));
SetDict
Int
(
"ACS_TTEE"
,
(
ACS_TTEE
));
SetDict
Char
(
"ACS_HLINE"
,
(
ACS_HLINE
));
SetDict
Int
(
"ACS_HLINE"
,
(
ACS_HLINE
));
SetDict
Char
(
"ACS_VLINE"
,
(
ACS_VLINE
));
SetDict
Int
(
"ACS_VLINE"
,
(
ACS_VLINE
));
SetDict
Char
(
"ACS_PLUS"
,
(
ACS_PLUS
));
SetDict
Int
(
"ACS_PLUS"
,
(
ACS_PLUS
));
SetDict
Char
(
"ACS_S1"
,
(
ACS_S1
));
SetDict
Int
(
"ACS_S1"
,
(
ACS_S1
));
SetDict
Char
(
"ACS_S9"
,
(
ACS_S9
));
SetDict
Int
(
"ACS_S9"
,
(
ACS_S9
));
SetDict
Char
(
"ACS_DIAMOND"
,
(
ACS_DIAMOND
));
SetDict
Int
(
"ACS_DIAMOND"
,
(
ACS_DIAMOND
));
SetDict
Char
(
"ACS_CKBOARD"
,
(
ACS_CKBOARD
));
SetDict
Int
(
"ACS_CKBOARD"
,
(
ACS_CKBOARD
));
SetDict
Char
(
"ACS_DEGREE"
,
(
ACS_DEGREE
));
SetDict
Int
(
"ACS_DEGREE"
,
(
ACS_DEGREE
));
SetDict
Char
(
"ACS_PLMINUS"
,
(
ACS_PLMINUS
));
SetDict
Int
(
"ACS_PLMINUS"
,
(
ACS_PLMINUS
));
SetDict
Char
(
"ACS_BULLET"
,
(
ACS_BULLET
));
SetDict
Int
(
"ACS_BULLET"
,
(
ACS_BULLET
));
SetDict
Char
(
"ACS_LARROW"
,
(
ACS_RARROW
));
SetDict
Int
(
"ACS_LARROW"
,
(
ACS_RARROW
));
SetDict
Char
(
"ACS_DARROW"
,
(
ACS_DARROW
));
SetDict
Int
(
"ACS_DARROW"
,
(
ACS_DARROW
));
SetDict
Char
(
"ACS_UARROW"
,
(
ACS_UARROW
));
SetDict
Int
(
"ACS_UARROW"
,
(
ACS_UARROW
));
SetDict
Char
(
"ACS_BOARD"
,
(
ACS_BOARD
));
SetDict
Int
(
"ACS_BOARD"
,
(
ACS_BOARD
));
SetDict
Char
(
"ACS_LANTERN"
,
(
ACS_LANTERN
));
SetDict
Int
(
"ACS_LANTERN"
,
(
ACS_LANTERN
));
SetDict
Char
(
"ACS_BLOCK"
,
(
ACS_BLOCK
));
SetDict
Int
(
"ACS_BLOCK"
,
(
ACS_BLOCK
));
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
}
}
...
@@ -1099,10 +1144,8 @@ PyCurses_EndWin(self, args)
...
@@ -1099,10 +1144,8 @@ PyCurses_EndWin(self, args)
PyObject
*
args
;
PyObject
*
args
;
{
{
if
(
!
PyArg_NoArgs
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
endwin
();
return
PyCursesCheckERR
(
endwin
(),
"endwin"
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1111,7 +1154,7 @@ PyCurses_IsEndWin(self, args)
...
@@ -1111,7 +1154,7 @@ PyCurses_IsEndWin(self, args)
PyObject
*
args
;
PyObject
*
args
;
{
{
if
(
!
PyArg_NoArgs
(
args
))
if
(
!
PyArg_NoArgs
(
args
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
if
(
isendwin
()
==
FALSE
)
{
if
(
isendwin
()
==
FALSE
)
{
Py_INCREF
(
Py_False
);
Py_INCREF
(
Py_False
);
return
Py_False
;
return
Py_False
;
...
@@ -1126,8 +1169,8 @@ PyCurses_DoUpdate(self,arg)
...
@@ -1126,8 +1169,8 @@ PyCurses_DoUpdate(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
return
(
PyObject
*
)
PyInt_FromLong
(
doupdate
()
);
return
PyCursesCheckERR
(
doupdate
(),
"doupdate"
);
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1137,19 +1180,29 @@ PyCurses_NewWindow(self,arg)
...
@@ -1137,19 +1180,29 @@ PyCurses_NewWindow(self,arg)
{
{
WINDOW
*
win
;
WINDOW
*
win
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
int
nlines
,
ncols
,
begin_y
,
begin_x
;
nlines
=
0
;
ncols
=
0
;
nlines
=
ncols
=
0
;
if
(
!
PyArg_Parse
(
arg
,
switch
(
ARG_COUNT
(
arg
))
{
"(iiii);nlines,ncols,begin_y,begin_x"
,
case
2
:
if
(
!
PyArg_Parse
(
arg
,
"(ii);begin)_y,begin_x"
,
&
begin_y
,
&
begin_x
))
return
NULL
;
break
;
case
4
:
if
(
!
PyArg_Parse
(
arg
,
"(iiii);nlines,ncols,begin_y,begin_x"
,
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
&
nlines
,
&
ncols
,
&
begin_y
,
&
begin_x
))
PyErr_Clear
();
return
NULL
;
if
(
!
PyArg_Parse
(
arg
,
"(ii)"
,
&
begin_y
,
&
begin_x
))
break
;
return
(
PyObject
*
)
NULL
;
default:
PyErr_SetString
(
PyExc_TypeError
,
"newwin requires 2 or 4 arguments"
);
return
NULL
;
}
win
=
newwin
(
nlines
,
ncols
,
begin_y
,
begin_x
);
win
=
newwin
(
nlines
,
ncols
,
begin_y
,
begin_x
);
if
(
win
==
NULL
)
{
if
(
win
==
NULL
)
{
Py
_INCREF
(
Py_None
);
Py
Err_SetString
(
PyCursesError
,
catchall_NULL
);
return
(
PyObject
*
)
Py_None
;
return
NULL
;
}
}
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
return
(
PyObject
*
)
PyCursesWindow_New
(
win
);
}
}
...
@@ -1159,10 +1212,10 @@ PyCurses_Beep(self,arg)
...
@@ -1159,10 +1212,10 @@ PyCurses_Beep(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
beep
();
beep
();
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1171,10 +1224,10 @@ PyCurses_Flash(self,arg)
...
@@ -1171,10 +1224,10 @@ PyCurses_Flash(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
flash
();
flash
();
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1184,10 +1237,8 @@ PyCurses_UngetCh(self,arg)
...
@@ -1184,10 +1237,8 @@ PyCurses_UngetCh(self,arg)
{
{
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;integer"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;integer"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
ungetch
(
ch
);
return
PyCursesCheckERR
(
ungetch
(
ch
),
"ungetch"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1196,10 +1247,10 @@ PyCurses_FlushInp(self,arg)
...
@@ -1196,10 +1247,10 @@ PyCurses_FlushInp(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
flushinp
();
flushinp
();
Py_INCREF
(
Py_None
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
return
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1208,10 +1259,8 @@ PyCurses_CBreak(self,arg)
...
@@ -1208,10 +1259,8 @@ PyCurses_CBreak(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
cbreak
();
return
PyCursesCheckERR
(
cbreak
(),
"cbreak"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1220,10 +1269,8 @@ PyCurses_NoCBreak(self,arg)
...
@@ -1220,10 +1269,8 @@ PyCurses_NoCBreak(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
nocbreak
();
return
PyCursesCheckERR
(
nocbreak
(),
"nocbreak"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1232,10 +1279,8 @@ PyCurses_Echo(self,arg)
...
@@ -1232,10 +1279,8 @@ PyCurses_Echo(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
echo
();
return
PyCursesCheckERR
(
echo
(),
"echo"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1244,10 +1289,8 @@ PyCurses_NoEcho(self,arg)
...
@@ -1244,10 +1289,8 @@ PyCurses_NoEcho(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
noecho
();
return
PyCursesCheckERR
(
noecho
(),
"noecho"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1256,10 +1299,8 @@ PyCurses_Nl(self,arg)
...
@@ -1256,10 +1299,8 @@ PyCurses_Nl(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
nl
();
return
PyCursesCheckERR
(
nl
(),
"nl"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1268,10 +1309,8 @@ PyCurses_NoNl(self,arg)
...
@@ -1268,10 +1309,8 @@ PyCurses_NoNl(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
nonl
();
return
PyCursesCheckERR
(
nonl
(),
"nonl"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1280,10 +1319,8 @@ PyCurses_Raw(self,arg)
...
@@ -1280,10 +1319,8 @@ PyCurses_Raw(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
raw
();
return
PyCursesCheckERR
(
raw
(),
"raw"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1292,10 +1329,8 @@ PyCurses_NoRaw(self,arg)
...
@@ -1292,10 +1329,8 @@ PyCurses_NoRaw(self,arg)
PyObject
*
arg
;
PyObject
*
arg
;
{
{
if
(
!
PyArg_NoArgs
(
arg
))
if
(
!
PyArg_NoArgs
(
arg
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
noraw
();
return
PyCursesCheckERR
(
noraw
(),
"noraw"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1305,10 +1340,8 @@ PyCurses_IntrFlush(self,arg)
...
@@ -1305,10 +1340,8 @@ PyCurses_IntrFlush(self,arg)
{
{
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
intrflush
(
NULL
,
ch
);
return
PyCursesCheckERR
(
intrflush
(
NULL
,
ch
),
"intrflush"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1318,10 +1351,8 @@ PyCurses_Meta(self,arg)
...
@@ -1318,10 +1351,8 @@ PyCurses_Meta(self,arg)
{
{
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i;True(1), False(0)"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
meta
(
NULL
,
ch
);
return
PyCursesCheckERR
(
meta
(
stdscr
,
ch
),
"meta"
);
Py_INCREF
(
Py_None
);
return
(
PyObject
*
)
Py_None
;
}
}
static
PyObject
*
static
PyObject
*
...
@@ -1329,10 +1360,12 @@ PyCurses_KeyName(self,arg)
...
@@ -1329,10 +1360,12 @@ PyCurses_KeyName(self,arg)
PyObject
*
self
;
PyObject
*
self
;
PyObject
*
arg
;
PyObject
*
arg
;
{
{
char
*
knp
;
int
ch
;
int
ch
;
if
(
!
PyArg_Parse
(
arg
,
"i"
,
&
ch
))
if
(
!
PyArg_Parse
(
arg
,
"i"
,
&
ch
))
return
(
PyObject
*
)
NULL
;
return
NULL
;
return
PyString_FromString
((
char
*
)
keyname
(
ch
));
knp
=
keyname
(
ch
);
return
PyString_FromString
((
knp
==
NULL
)
?
""
:
knp
);
}
}
#ifdef NOT_YET
#ifdef NOT_YET
...
@@ -1386,36 +1419,31 @@ static PyMethodDef PyCurses_methods[] = {
...
@@ -1386,36 +1419,31 @@ static PyMethodDef PyCurses_methods[] = {
void
void
initcurses
()
initcurses
()
{
{
PyObject
*
m
,
*
d
,
*
x
;
PyObject
*
m
,
*
d
;
/* Create the module and add the functions */
/* Create the module and add the functions */
m
=
Py_InitModule
(
"curses"
,
PyCurses_methods
);
m
=
Py_InitModule
(
"curses"
,
PyCurses_methods
);
PyCurses_OK
=
Py_True
;
PyCurses_ERR
=
Py_False
;
Py_INCREF
(
PyCurses_OK
);
Py_INCREF
(
PyCurses_ERR
);
/* Add some symbolic constants to the module */
/* Add some symbolic constants to the module */
d
=
PyModule_GetDict
(
m
);
d
=
PyModule_GetDict
(
m
);
ModDict
=
d
;
/* For PyCurses_InitScr */
ModDict
=
d
;
/* For PyCurses_InitScr */
/*
Make the version available
*/
/*
For exception curses.error
*/
Py
Dict_SetItemString
(
d
,
"version"
,
Py
CursesError
=
PyString_FromString
(
"curses.error"
);
PyString_FromString
(
PyCursesVersion
)
);
PyDict_SetItemString
(
d
,
"error"
,
PyCursesError
);
/* Here are some defines */
/* Make the version available */
PyDict_SetItemString
(
d
,
"OK"
,
PyCurses_OK
);
PyDict_SetItemString
(
d
,
"version"
,
PyString_FromString
(
PyCursesVersion
));
PyDict_SetItemString
(
d
,
"ERR"
,
PyCurses_ERR
);
/* Here are some attributes you can add to chars to print */
/* Here are some attributes you can add to chars to print */
PyDict_SetItemString
(
d
,
"A_NORMAL"
,
PyInt_FromLong
(
A_NORMAL
)
);
SetDictInt
(
"A_NORMAL"
,
A_NORMAL
);
PyDict_SetItemString
(
d
,
"A_STANDOUT"
,
PyInt_FromLong
(
A_STANDOUT
)
);
SetDictInt
(
"A_STANDOUT"
,
A_STANDOUT
);
PyDict_SetItemString
(
d
,
"A_UNDERLINE"
,
PyInt_FromLong
(
A_UNDERLINE
)
);
SetDictInt
(
"A_UNDERLINE"
,
A_UNDERLINE
);
PyDict_SetItemString
(
d
,
"A_REVERSE"
,
PyInt_FromLong
(
A_REVERSE
)
);
SetDictInt
(
"A_REVERSE"
,
A_REVERSE
);
PyDict_SetItemString
(
d
,
"A_BLINK"
,
PyInt_FromLong
(
A_BLINK
)
);
SetDictInt
(
"A_BLINK"
,
A_BLINK
);
PyDict_SetItemString
(
d
,
"A_DIM"
,
PyInt_FromLong
(
A_DIM
)
);
SetDictInt
(
"A_DIM"
,
A_DIM
);
PyDict_SetItemString
(
d
,
"A_BOLD"
,
PyInt_FromLong
(
A_BOLD
)
);
SetDictInt
(
"A_BOLD"
,
A_BOLD
);
PyDict_SetItemString
(
d
,
"A_ALTCHARSET"
,
PyInt_FromLong
(
A_ALTCHARSET
)
);
SetDictInt
(
"A_ALTCHARSET"
,
A_ALTCHARSET
);
/* Now set everything up for KEY_ variables */
/* Now set everything up for KEY_ variables */
{
{
...
@@ -1441,15 +1469,15 @@ initcurses()
...
@@ -1441,15 +1469,15 @@ initcurses()
*
p2
=
(
char
)
0
;
*
p2
=
(
char
)
0
;
}
else
}
else
key_n2
=
key_n
;
key_n2
=
key_n
;
PyDict_SetItemString
(
d
,
key_n2
,
PyInt_FromLong
(
key
));
PyDict_SetItemString
(
d
,
key_n2
,
PyInt_FromLong
(
(
long
)
key
));
if
(
key_n2
!=
key_n
)
if
(
key_n2
!=
key_n
)
free
(
key_n2
);
free
(
key_n2
);
}
}
SetDictChar
(
"KEY_MIN"
,
KEY_MIN
);
SetDictInt
(
"KEY_MIN"
,
KEY_MIN
);
SetDictChar
(
"KEY_MAX"
,
KEY_MAX
);
SetDictInt
(
"KEY_MAX"
,
KEY_MAX
);
}
}
/* Check for errors */
/* Check for errors */
if
(
PyErr_Occurred
())
if
(
PyErr_Occurred
())
Py_FatalError
(
"can't initialize module
syslog
"
);
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