Bug Summary

File:Modules/_cursesmodule.c
Location:line 468, column 15
Description:Access to field '_attrs' results in a dereference of a null pointer (loaded from field 'win')

Annotated Source Code

1/*
2 * This is a curses module for Python.
3 *
4 * Based on prior work by Lance Ellinghaus and Oliver Andrich
5 * Version 1.2 of this module: Copyright 1994 by Lance Ellinghouse,
6 * Cathedral City, California Republic, United States of America.
7 *
8 * Version 1.5b1, heavily extended for ncurses by Oliver Andrich:
9 * Copyright 1996,1997 by Oliver Andrich, Koblenz, Germany.
10 *
11 * Tidied for Python 1.6, and currently maintained by <amk@amk.ca>.
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining
14 * a copy of this source file to use, copy, modify, merge, or publish it
15 * subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or in any new file that contains a substantial portion of
19 * this file.
20 *
21 * THE AUTHOR MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF
22 * THE SOFTWARE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT
23 * EXPRESS OR IMPLIED WARRANTY. THE AUTHOR DISCLAIMS ALL WARRANTIES
24 * WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
25 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NON-INFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE
27 * AUTHOR BE LIABLE TO YOU OR ANY OTHER PARTY FOR ANY SPECIAL,
28 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
29 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, STRICT LIABILITY OR
30 * ANY OTHER ACTION ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31 * PERFORMANCE OF THIS SOFTWARE.
32 */
33
34/*
35
36 A number of SysV or ncurses functions don't have wrappers yet; if you
37 need a given function, add it and send a patch. See
38 http://www.python.org/dev/patches/ for instructions on how to submit
39 patches to Python.
40
41 Here's a list of currently unsupported functions:
42
43 addchnstr addchstr color_set define_key
44 del_curterm delscreen dupwin inchnstr inchstr innstr keyok
45 mcprint mvaddchnstr mvaddchstr mvcur mvinchnstr
46 mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr
47 mvwinchnstr mvwinchstr mvwinnstr newterm
48 restartterm ripoffline scr_dump
49 scr_init scr_restore scr_set scrl set_curterm set_term setterm
50 tgetent tgetflag tgetnum tgetstr tgoto timeout tputs
51 vidattr vidputs waddchnstr waddchstr
52 wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl
53
54 Low-priority:
55 slk_attr slk_attr_off slk_attr_on slk_attr_set slk_attroff
56 slk_attron slk_attrset slk_clear slk_color slk_init slk_label
57 slk_noutrefresh slk_refresh slk_restore slk_set slk_touch
58
59 Menu extension (ncurses and probably SYSV):
60 current_item free_item free_menu item_count item_description
61 item_index item_init item_name item_opts item_opts_off
62 item_opts_on item_term item_userptr item_value item_visible
63 menu_back menu_driver menu_fore menu_format menu_grey
64 menu_init menu_items menu_mark menu_opts menu_opts_off
65 menu_opts_on menu_pad menu_pattern menu_request_by_name
66 menu_request_name menu_spacing menu_sub menu_term menu_userptr
67 menu_win new_item new_menu pos_menu_cursor post_menu
68 scale_menu set_current_item set_item_init set_item_opts
69 set_item_term set_item_userptr set_item_value set_menu_back
70 set_menu_fore set_menu_format set_menu_grey set_menu_init
71 set_menu_items set_menu_mark set_menu_opts set_menu_pad
72 set_menu_pattern set_menu_spacing set_menu_sub set_menu_term
73 set_menu_userptr set_menu_win set_top_row top_row unpost_menu
74
75 Form extension (ncurses and probably SYSV):
76 current_field data_ahead data_behind dup_field
77 dynamic_fieldinfo field_arg field_back field_buffer
78 field_count field_fore field_index field_info field_init
79 field_just field_opts field_opts_off field_opts_on field_pad
80 field_status field_term field_type field_userptr form_driver
81 form_fields form_init form_opts form_opts_off form_opts_on
82 form_page form_request_by_name form_request_name form_sub
83 form_term form_userptr form_win free_field free_form
84 link_field link_fieldtype move_field new_field new_form
85 new_page pos_form_cursor post_form scale_form
86 set_current_field set_field_back set_field_buffer
87 set_field_fore set_field_init set_field_just set_field_opts
88 set_field_pad set_field_status set_field_term set_field_type
89 set_field_userptr set_fieldtype_arg set_fieldtype_choice
90 set_form_fields set_form_init set_form_opts set_form_page
91 set_form_sub set_form_term set_form_userptr set_form_win
92 set_max_field set_new_page unpost_form
93
94
95*/
96
97/* Release Number */
98
99char *PyCursesVersion = "2.2";
100
101/* Includes */
102
103#define PY_SSIZE_T_CLEAN
104
105#include "Python.h"
106
107
108#ifdef __osf__
109#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
110#endif
111
112#ifdef __hpux
113#define STRICT_SYSV_CURSES
114#endif
115
116#define CURSES_MODULE
117#include "py_curses.h"
118
119/* These prototypes are in <term.h>, but including this header
120 #defines many common symbols (such as "lines") which breaks the
121 curses module in other ways. So the code will just specify
122 explicit prototypes here. */
123extern int setupterm(char *,int,int *);
124#ifdef __sgi
125#include <term.h>
126#endif
127
128#if !defined(HAVE_NCURSES_H1) && (defined(sgi) || defined(__sun) || defined(SCO5))
129#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
130typedef chtype attr_t; /* No attr_t type is available */
131#endif
132
133#if defined(_AIX)
134#define STRICT_SYSV_CURSES
135#endif
136
137/* Definition of exception curses.error */
138
139static PyObject *PyCursesError;
140
141/* Tells whether setupterm() has been called to initialise terminfo. */
142static int initialised_setupterm = FALSE0;
143
144/* Tells whether initscr() has been called to initialise curses. */
145static int initialised = FALSE0;
146
147/* Tells whether start_color() has been called to initialise color usage. */
148static int initialisedcolors = FALSE0;
149
150/* Utility Macros */
151#define PyCursesSetupTermCalledif (initialised_setupterm != 1) { PyErr_SetString(PyCursesError
, "must call (at least) setupterm() first"); return 0; }
\
152 if (initialised_setupterm != TRUE1) { \
153 PyErr_SetString(PyCursesError, \
154 "must call (at least) setupterm() first"); \
155 return 0; }
156
157#define PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
\
158 if (initialised != TRUE1) { \
159 PyErr_SetString(PyCursesError, \
160 "must call initscr() first"); \
161 return 0; }
162
163#define PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
\
164 if (initialisedcolors != TRUE1) { \
165 PyErr_SetString(PyCursesError, \
166 "must call start_color() first"); \
167 return 0; }
168
169#ifndef MIN
170#define MIN(x,y)((x) < (y) ? (x) : (y)) ((x) < (y) ? (x) : (y))
171#endif
172
173/* Utility Functions */
174
175/*
176 * Check the return code from a curses function and return None
177 * or raise an exception as appropriate. These are exported using the
178 * capsule API.
179 */
180
181static PyObject *
182PyCursesCheckERR(int code, char *fname)
183{
184 if (code != ERR(-1)) {
185 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
186 return Py_None(&_Py_NoneStruct);
187 } else {
188 if (fname == NULL((void *)0)) {
189 PyErr_SetString(PyCursesError, catchall_ERR);
190 } else {
191 PyErr_Format(PyCursesError, "%s() returned ERR", fname);
192 }
193 return NULL((void *)0);
194 }
195}
196
197static int
198PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
199{
200 if (PyLong_CheckExact(obj)((((PyObject*)(obj))->ob_type) == &PyLong_Type)) {
201 int overflow;
202 /* XXX should the truncation by the cast also be reported
203 as an error? */
204 *ch = (chtype) PyLong_AsLongAndOverflow(obj, &overflow);
205 if (overflow)
206 return 0;
207 } else if(PyBytes_Check(obj)((((((PyObject*)(obj))->ob_type))->tp_flags & ((1L<<
27))) != 0)
208 && (PyBytes_Size(obj) == 1)) {
209 *ch = (chtype) *PyBytes_AsString(obj);
210 } else if (PyUnicode_Check(obj)((((((PyObject*)(obj))->ob_type))->tp_flags & ((1L<<
28))) != 0)
&& PyUnicode_GetSizePyUnicodeUCS2_GetSize(obj) == 1) {
211 *ch = (chtype) *PyUnicode_AS_UNICODE(obj)((__builtin_expect(!(((((((PyObject*)(obj))->ob_type))->
tp_flags & ((1L<<28))) != 0)), 0) ? __assert_rtn(__func__
, "/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c",
211, "PyUnicode_Check(obj)") : (void)0),(((PyUnicodeObject *
)(obj))->str))
;
212 } else {
213 return 0;
214 }
215 return 1;
216}
217
218/* Function versions of the 3 functions for testing whether curses has been
219 initialised or not. */
220
221static int func_PyCursesSetupTermCalled(void)
222{
223 PyCursesSetupTermCalledif (initialised_setupterm != 1) { PyErr_SetString(PyCursesError
, "must call (at least) setupterm() first"); return 0; }
;
224 return 1;
225}
226
227static int func_PyCursesInitialised(void)
228{
229 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
230 return 1;
231}
232
233static int func_PyCursesInitialisedColor(void)
234{
235 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
236 return 1;
237}
238
239/*****************************************************************************
240 The Window Object
241******************************************************************************/
242
243/* Definition of the window type */
244
245PyTypeObject PyCursesWindow_Type;
246
247/* Function prototype macros for Window object
248
249 X - function name
250 TYPE - parameter Type
251 ERGSTR - format string for construction of the return value
252 PARSESTR - format string for argument parsing
253*/
254
255#define Window_NoArgNoReturnFunction(X)static PyObject *PyCursesWindow_X (PyCursesWindowObject *self
, PyObject *args) { return PyCursesCheckERR(X(self->win), "X"
); }
\
256 static PyObject *PyCursesWindow_ ## X \
257 (PyCursesWindowObject *self, PyObject *args) \
258 { return PyCursesCheckERR(X(self->win), # X); }
259
260#define Window_NoArgTrueFalseFunction(X)static PyObject * PyCursesWindow_X (PyCursesWindowObject *self
) { if (X (self->win) == 0) { ( _Py_RefTotal++ , ((PyObject
*)(((PyObject *) &_Py_FalseStruct)))->ob_refcnt++); return
((PyObject *) &_Py_FalseStruct); } else { ( _Py_RefTotal
++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_TrueStruct); } }
\
261 static PyObject * PyCursesWindow_ ## X \
262 (PyCursesWindowObject *self) \
263 { \
264 if (X (self->win) == FALSE0) { Py_INCREF(Py_False)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_FalseStruct
)))->ob_refcnt++)
; return Py_False((PyObject *) &_Py_FalseStruct); } \
265 else { Py_INCREF(Py_True)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct
)))->ob_refcnt++)
; return Py_True((PyObject *) &_Py_TrueStruct); } }
266
267#define Window_NoArgNoReturnVoidFunction(X)static PyObject * PyCursesWindow_X (PyCursesWindowObject *self
) { X(self->win); ( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct
)))->ob_refcnt++); return (&_Py_NoneStruct); }
\
268 static PyObject * PyCursesWindow_ ## X \
269 (PyCursesWindowObject *self) \
270 { \
271 X(self->win); Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
; return Py_None(&_Py_NoneStruct); }
272
273#define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR)static PyObject * PyCursesWindow_X (PyCursesWindowObject *self
) { TYPE arg1, arg2; X(self->win,arg1,arg2); return _Py_BuildValue_SizeT
(ERGSTR, arg1, arg2); }
\
274 static PyObject * PyCursesWindow_ ## X \
275 (PyCursesWindowObject *self) \
276 { \
277 TYPE arg1, arg2; \
278 X(self->win,arg1,arg2); return Py_BuildValue_Py_BuildValue_SizeT(ERGSTR, arg1, arg2); }
279
280#define Window_OneArgNoReturnVoidFunction(X, TYPE, PARSESTR)static PyObject * PyCursesWindow_X (PyCursesWindowObject *self
, PyObject *args) { TYPE arg1; if (!_PyArg_ParseTuple_SizeT(args
, PARSESTR, &arg1)) return ((void *)0); X(self->win,arg1
); ( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->
ob_refcnt++); return (&_Py_NoneStruct); }
\
281 static PyObject * PyCursesWindow_ ## X \
282 (PyCursesWindowObject *self, PyObject *args) \
283 { \
284 TYPE arg1; \
285 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, PARSESTR, &arg1)) return NULL((void *)0); \
286 X(self->win,arg1); Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
; return Py_None(&_Py_NoneStruct); }
287
288#define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR)static PyObject * PyCursesWindow_X (PyCursesWindowObject *self
, PyObject *args) { TYPE arg1; if (!_PyArg_ParseTuple_SizeT(args
,PARSESTR, &arg1)) return ((void *)0); return PyCursesCheckERR
(X(self->win, arg1), "X"); }
\
289 static PyObject * PyCursesWindow_ ## X \
290 (PyCursesWindowObject *self, PyObject *args) \
291 { \
292 TYPE arg1; \
293 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,PARSESTR, &arg1)) return NULL((void *)0); \
294 return PyCursesCheckERR(X(self->win, arg1), # X); }
295
296#define Window_TwoArgNoReturnFunction(X, TYPE, PARSESTR)static PyObject * PyCursesWindow_X (PyCursesWindowObject *self
, PyObject *args) { TYPE arg1, arg2; if (!_PyArg_ParseTuple_SizeT
(args,PARSESTR, &arg1, &arg2)) return ((void *)0); return
PyCursesCheckERR(X(self->win, arg1, arg2), "X"); }
\
297 static PyObject * PyCursesWindow_ ## X \
298 (PyCursesWindowObject *self, PyObject *args) \
299 { \
300 TYPE arg1, arg2; \
301 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,PARSESTR, &arg1, &arg2)) return NULL((void *)0); \
302 return PyCursesCheckERR(X(self->win, arg1, arg2), # X); }
303
304/* ------------- WINDOW routines --------------- */
305
306Window_NoArgNoReturnFunction(untouchwin)static PyObject *PyCursesWindow_untouchwin (PyCursesWindowObject
*self, PyObject *args) { return PyCursesCheckERR(wtouchln((self
->win), 0, ((self->win) ? ((self->win)->_maxy + 1
) : (-1)), 0), "untouchwin"); }
307Window_NoArgNoReturnFunction(touchwin)static PyObject *PyCursesWindow_touchwin (PyCursesWindowObject
*self, PyObject *args) { return PyCursesCheckERR(wtouchln((self
->win), 0, ((self->win) ? ((self->win)->_maxy + 1
) : (-1)), 1), "touchwin"); }
308Window_NoArgNoReturnFunction(redrawwin)static PyObject *PyCursesWindow_redrawwin (PyCursesWindowObject
*self, PyObject *args) { return PyCursesCheckERR(wredrawln(self
->win, 0, (self->win)->_maxy+1), "redrawwin"); }
309Window_NoArgNoReturnFunction(winsertln)static PyObject *PyCursesWindow_winsertln (PyCursesWindowObject
*self, PyObject *args) { return PyCursesCheckERR(winsdelln(self
->win,1), "winsertln"); }
310Window_NoArgNoReturnFunction(werase)static PyObject *PyCursesWindow_werase (PyCursesWindowObject *
self, PyObject *args) { return PyCursesCheckERR(werase(self->
win), "werase"); }
311Window_NoArgNoReturnFunction(wdeleteln)static PyObject *PyCursesWindow_wdeleteln (PyCursesWindowObject
*self, PyObject *args) { return PyCursesCheckERR(winsdelln(self
->win,-1), "wdeleteln"); }
312
313Window_NoArgTrueFalseFunction(is_wintouched)static PyObject * PyCursesWindow_is_wintouched (PyCursesWindowObject
*self) { if (is_wintouched (self->win) == 0) { ( _Py_RefTotal
++ , ((PyObject*)(((PyObject *) &_Py_FalseStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_FalseStruct); } else { ( _Py_RefTotal
++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_TrueStruct); } }
314
315Window_NoArgNoReturnVoidFunction(wsyncup)static PyObject * PyCursesWindow_wsyncup (PyCursesWindowObject
*self) { wsyncup(self->win); ( _Py_RefTotal++ , ((PyObject
*)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
316Window_NoArgNoReturnVoidFunction(wsyncdown)static PyObject * PyCursesWindow_wsyncdown (PyCursesWindowObject
*self) { wsyncdown(self->win); ( _Py_RefTotal++ , ((PyObject
*)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
317Window_NoArgNoReturnVoidFunction(wstandend)static PyObject * PyCursesWindow_wstandend (PyCursesWindowObject
*self) { (((self->win)->_attrs = ((1U - 1U)))); ( _Py_RefTotal
++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt++); return
(&_Py_NoneStruct); }
318Window_NoArgNoReturnVoidFunction(wstandout)static PyObject * PyCursesWindow_wstandout (PyCursesWindowObject
*self) { (((self->win)->_attrs = (((1U) << ((8) +
8))))); ( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct
)))->ob_refcnt++); return (&_Py_NoneStruct); }
319Window_NoArgNoReturnVoidFunction(wcursyncup)static PyObject * PyCursesWindow_wcursyncup (PyCursesWindowObject
*self) { wcursyncup(self->win); ( _Py_RefTotal++ , ((PyObject
*)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
320Window_NoArgNoReturnVoidFunction(wclrtoeol)static PyObject * PyCursesWindow_wclrtoeol (PyCursesWindowObject
*self) { wclrtoeol(self->win); ( _Py_RefTotal++ , ((PyObject
*)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
321Window_NoArgNoReturnVoidFunction(wclrtobot)static PyObject * PyCursesWindow_wclrtobot (PyCursesWindowObject
*self) { wclrtobot(self->win); ( _Py_RefTotal++ , ((PyObject
*)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
322Window_NoArgNoReturnVoidFunction(wclear)static PyObject * PyCursesWindow_wclear (PyCursesWindowObject
*self) { wclear(self->win); ( _Py_RefTotal++ , ((PyObject
*)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
323
324Window_OneArgNoReturnVoidFunction(idcok, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_idcok (PyCursesWindowObject *
self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args, "i;True(1) or False(0)", &arg1)) return ((void *)0
); idcok(self->win,arg1); ( _Py_RefTotal++ , ((PyObject*)(
(&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
325Window_OneArgNoReturnVoidFunction(immedok, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_immedok (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args, "i;True(1) or False(0)", &arg1)) return ((void *)0
); immedok(self->win,arg1); ( _Py_RefTotal++ , ((PyObject*
)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
326Window_OneArgNoReturnVoidFunction(wtimeout, int, "i;delay")static PyObject * PyCursesWindow_wtimeout (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args, "i;delay", &arg1)) return ((void *)0); wtimeout(self
->win,arg1); ( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct
)))->ob_refcnt++); return (&_Py_NoneStruct); }
327
328Window_NoArg2TupleReturnFunction(getyx, int, "ii")static PyObject * PyCursesWindow_getyx (PyCursesWindowObject *
self) { int arg1, arg2; (arg1 = ((self->win) ? (self->win
)->_cury : (-1)), arg2 = ((self->win) ? (self->win)->
_curx : (-1))); return _Py_BuildValue_SizeT("ii", arg1, arg2)
; }
329Window_NoArg2TupleReturnFunction(getbegyx, int, "ii")static PyObject * PyCursesWindow_getbegyx (PyCursesWindowObject
*self) { int arg1, arg2; (arg1 = ((self->win) ? (self->
win)->_begy : (-1)), arg2 = ((self->win) ? (self->win
)->_begx : (-1))); return _Py_BuildValue_SizeT("ii", arg1,
arg2); }
330Window_NoArg2TupleReturnFunction(getmaxyx, int, "ii")static PyObject * PyCursesWindow_getmaxyx (PyCursesWindowObject
*self) { int arg1, arg2; (arg1 = ((self->win) ? ((self->
win)->_maxy + 1) : (-1)), arg2 = ((self->win) ? ((self->
win)->_maxx + 1) : (-1))); return _Py_BuildValue_SizeT("ii"
, arg1, arg2); }
331Window_NoArg2TupleReturnFunction(getparyx, int, "ii")static PyObject * PyCursesWindow_getparyx (PyCursesWindowObject
*self) { int arg1, arg2; (arg1 = ((self->win) ? (self->
win)->_pary : (-1)), arg2 = ((self->win) ? (self->win
)->_parx : (-1))); return _Py_BuildValue_SizeT("ii", arg1,
arg2); }
332
333Window_OneArgNoReturnFunction(clearok, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_clearok (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(clearok(self->win, arg1), "clearok"
); }
334Window_OneArgNoReturnFunction(idlok, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_idlok (PyCursesWindowObject *
self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(idlok(self->win, arg1), "idlok")
; }
335#if defined(__NetBSD__)
336Window_OneArgNoReturnVoidFunction(keypad, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_keypad (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args, "i;True(1) or False(0)", &arg1)) return ((void *)0
); keypad(self->win,arg1); ( _Py_RefTotal++ , ((PyObject*)
((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
337#else
338Window_OneArgNoReturnFunction(keypad, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_keypad (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(keypad(self->win, arg1), "keypad"
); }
339#endif
340Window_OneArgNoReturnFunction(leaveok, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_leaveok (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(leaveok(self->win, arg1), "leaveok"
); }
341#if defined(__NetBSD__)
342Window_OneArgNoReturnVoidFunction(nodelay, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_nodelay (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args, "i;True(1) or False(0)", &arg1)) return ((void *)0
); nodelay(self->win,arg1); ( _Py_RefTotal++ , ((PyObject*
)((&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
343#else
344Window_OneArgNoReturnFunction(nodelay, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_nodelay (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(nodelay(self->win, arg1), "nodelay"
); }
345#endif
346Window_OneArgNoReturnFunction(notimeout, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_notimeout (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(notimeout(self->win, arg1), "notimeout"
); }
347Window_OneArgNoReturnFunction(scrollok, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_scrollok (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(scrollok(self->win, arg1), "scrollok"
); }
348Window_OneArgNoReturnFunction(winsdelln, int, "i;nlines")static PyObject * PyCursesWindow_winsdelln (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;nlines", &arg1)) return ((void *)0); return PyCursesCheckERR
(winsdelln(self->win, arg1), "winsdelln"); }
349Window_OneArgNoReturnFunction(syncok, int, "i;True(1) or False(0)")static PyObject * PyCursesWindow_syncok (PyCursesWindowObject
*self, PyObject *args) { int arg1; if (!_PyArg_ParseTuple_SizeT
(args,"i;True(1) or False(0)", &arg1)) return ((void *)0)
; return PyCursesCheckERR(syncok(self->win, arg1), "syncok"
); }
350
351Window_TwoArgNoReturnFunction(mvwin, int, "ii;y,x")static PyObject * PyCursesWindow_mvwin (PyCursesWindowObject *
self, PyObject *args) { int arg1, arg2; if (!_PyArg_ParseTuple_SizeT
(args,"ii;y,x", &arg1, &arg2)) return ((void *)0); return
PyCursesCheckERR(mvwin(self->win, arg1, arg2), "mvwin"); }
352Window_TwoArgNoReturnFunction(mvderwin, int, "ii;y,x")static PyObject * PyCursesWindow_mvderwin (PyCursesWindowObject
*self, PyObject *args) { int arg1, arg2; if (!_PyArg_ParseTuple_SizeT
(args,"ii;y,x", &arg1, &arg2)) return ((void *)0); return
PyCursesCheckERR(mvderwin(self->win, arg1, arg2), "mvderwin"
); }
353Window_TwoArgNoReturnFunction(wmove, int, "ii;y,x")static PyObject * PyCursesWindow_wmove (PyCursesWindowObject *
self, PyObject *args) { int arg1, arg2; if (!_PyArg_ParseTuple_SizeT
(args,"ii;y,x", &arg1, &arg2)) return ((void *)0); return
PyCursesCheckERR(wmove(self->win, arg1, arg2), "wmove"); }
354#ifndef STRICT_SYSV_CURSES
355Window_TwoArgNoReturnFunction(wresize, int, "ii;lines,columns")static PyObject * PyCursesWindow_wresize (PyCursesWindowObject
*self, PyObject *args) { int arg1, arg2; if (!_PyArg_ParseTuple_SizeT
(args,"ii;lines,columns", &arg1, &arg2)) return ((void
*)0); return PyCursesCheckERR(wresize(self->win, arg1, arg2
), "wresize"); }
356#endif
357
358/* Allocation and deallocation of Window Objects */
359
360static PyObject *
361PyCursesWindow_New(WINDOW *win)
362{
363 PyCursesWindowObject *wo;
364
365 wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type)( (PyCursesWindowObject *) PyObject_Init( (PyObject *) _PyObject_DebugMalloc
( ( (&PyCursesWindow_Type)->tp_basicsize ) ), (&PyCursesWindow_Type
)) )
;
366 if (wo == NULL((void *)0)) return NULL((void *)0);
367 wo->win = win;
368 return (PyObject *)wo;
369}
370
371static void
372PyCursesWindow_Dealloc(PyCursesWindowObject *wo)
373{
374 if (wo->win != stdscr) delwin(wo->win);
375 PyObject_DEL_PyObject_DebugFree(wo);
376}
377
378/* Addch, Addstr, Addnstr */
379
380static PyObject *
381PyCursesWindow_AddCh(PyCursesWindowObject *self, PyObject *args)
382{
383 int rtn, x, y, use_xy = FALSE0;
384 PyObject *temp;
385 chtype ch = 0;
386 attr_t attr = A_NORMAL(1U - 1U);
387 long lattr;
388
389 switch (PyTuple_Size(args)) {
390 case 1:
391 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O;ch or int", &temp))
392 return NULL((void *)0);
393 break;
394 case 2:
395 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "Ol;ch or int,attr", &temp, &lattr))
396 return NULL((void *)0);
397 attr = lattr;
398 break;
399 case 3:
400 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iiO;y,x,ch or int", &y, &x, &temp))
401 return NULL((void *)0);
402 use_xy = TRUE1;
403 break;
404 case 4:
405 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iiOl;y,x,ch or int, attr",
406 &y, &x, &temp, &lattr))
407 return NULL((void *)0);
408 attr = lattr;
409 use_xy = TRUE1;
410 break;
411 default:
412 PyErr_SetString(PyExc_TypeError, "addch requires 1 to 4 arguments");
413 return NULL((void *)0);
414 }
415
416 if (!PyCurses_ConvertToChtype(temp, &ch)) {
417 PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
418 return NULL((void *)0);
419 }
420
421 if (use_xy == TRUE1)
422 rtn = mvwaddch(self->win,y,x, ch | attr)(wmove(self->win,y,x) == (-1) ? (-1) : waddch(self->win
,ch | attr))
;
423 else {
424 rtn = waddch(self->win, ch | attr);
425 }
426 return PyCursesCheckERR(rtn, "addch");
427}
428
429static PyObject *
430PyCursesWindow_AddStr(PyCursesWindowObject *self, PyObject *args)
431{
432 int rtn;
433 int x, y;
434 char *str;
435 attr_t attr = A_NORMAL(1U - 1U) , attr_old = A_NORMAL(1U - 1U);
436 long lattr;
437 int use_xy = FALSE0, use_attr = FALSE0;
438
439 switch (PyTuple_Size(args)) {
1
Control jumps to 'case 2:' at line 444
440 case 1:
441 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"s;str", &str))
442 return NULL((void *)0);
443 break;
444 case 2:
445 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"sl;str,attr", &str, &lattr))
2
Taking false branch
446 return NULL((void *)0);
447 attr = lattr;
448 use_attr = TRUE1;
449 break;
3
Execution continues on line 466
450 case 3:
451 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iis;int,int,str", &y, &x, &str))
452 return NULL((void *)0);
453 use_xy = TRUE1;
454 break;
455 case 4:
456 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iisl;int,int,str,attr", &y, &x, &str, &lattr))
457 return NULL((void *)0);
458 attr = lattr;
459 use_xy = use_attr = TRUE1;
460 break;
461 default:
462 PyErr_SetString(PyExc_TypeError, "addstr requires 1 to 4 arguments");
463 return NULL((void *)0);
464 }
465
466 if (use_attr == TRUE1) {
4
Taking true branch
467 attr_old = getattrs(self->win)((self->win) ? (self->win)->_attrs : (1U - 1U));
468 (void)wattrset(self->win,attr)((self->win)->_attrs = (attr));
5
Within the expansion of the macro 'wattrset':
a
Access to field '_attrs' results in a dereference of a null pointer (loaded from field 'win')
469 }
470 if (use_xy == TRUE1)
471 rtn = mvwaddstr(self->win,y,x,str)(wmove(self->win,y,x) == (-1) ? (-1) : waddnstr(self->win
,str,-1))
;
472 else
473 rtn = waddstr(self->win,str)waddnstr(self->win,str,-1);
474 if (use_attr == TRUE1)
475 (void)wattrset(self->win,attr_old)((self->win)->_attrs = (attr_old));
476 return PyCursesCheckERR(rtn, "addstr");
477}
478
479static PyObject *
480PyCursesWindow_AddNStr(PyCursesWindowObject *self, PyObject *args)
481{
482 int rtn, x, y, n;
483 char *str;
484 attr_t attr = A_NORMAL(1U - 1U) , attr_old = A_NORMAL(1U - 1U);
485 long lattr;
486 int use_xy = FALSE0, use_attr = FALSE0;
487
488 switch (PyTuple_Size(args)) {
489 case 2:
490 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"si;str,n", &str, &n))
491 return NULL((void *)0);
492 break;
493 case 3:
494 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"sil;str,n,attr", &str, &n, &lattr))
495 return NULL((void *)0);
496 attr = lattr;
497 use_attr = TRUE1;
498 break;
499 case 4:
500 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iisi;y,x,str,n", &y, &x, &str, &n))
501 return NULL((void *)0);
502 use_xy = TRUE1;
503 break;
504 case 5:
505 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
506 return NULL((void *)0);
507 attr = lattr;
508 use_xy = use_attr = TRUE1;
509 break;
510 default:
511 PyErr_SetString(PyExc_TypeError, "addnstr requires 2 to 5 arguments");
512 return NULL((void *)0);
513 }
514
515 if (use_attr == TRUE1) {
516 attr_old = getattrs(self->win)((self->win) ? (self->win)->_attrs : (1U - 1U));
517 (void)wattrset(self->win,attr)((self->win)->_attrs = (attr));
518 }
519 if (use_xy == TRUE1)
520 rtn = mvwaddnstr(self->win,y,x,str,n)(wmove(self->win,y,x) == (-1) ? (-1) : waddnstr(self->win
,str,n))
;
521 else
522 rtn = waddnstr(self->win,str,n);
523 if (use_attr == TRUE1)
524 (void)wattrset(self->win,attr_old)((self->win)->_attrs = (attr_old));
525 return PyCursesCheckERR(rtn, "addnstr");
526}
527
528static PyObject *
529PyCursesWindow_Bkgd(PyCursesWindowObject *self, PyObject *args)
530{
531 PyObject *temp;
532 chtype bkgd;
533 attr_t attr = A_NORMAL(1U - 1U);
534 long lattr;
535
536 switch (PyTuple_Size(args)) {
537 case 1:
538 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O;ch or int", &temp))
539 return NULL((void *)0);
540 break;
541 case 2:
542 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"Ol;ch or int,attr", &temp, &lattr))
543 return NULL((void *)0);
544 attr = lattr;
545 break;
546 default:
547 PyErr_SetString(PyExc_TypeError, "bkgd requires 1 or 2 arguments");
548 return NULL((void *)0);
549 }
550
551 if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
552 PyErr_SetString(PyExc_TypeError, "argument 1 or 3 must be a ch or an int");
553 return NULL((void *)0);
554 }
555
556 return PyCursesCheckERR(wbkgd(self->win, bkgd | attr), "bkgd");
557}
558
559static PyObject *
560PyCursesWindow_AttrOff(PyCursesWindowObject *self, PyObject *args)
561{
562 long lattr;
563 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"l;attr", &lattr))
564 return NULL((void *)0);
565 return PyCursesCheckERR(wattroff(self->win, (attr_t)lattr)wattr_off(self->win, (attr_t)((attr_t)lattr), ((void *)0)), "attroff");
566}
567
568static PyObject *
569PyCursesWindow_AttrOn(PyCursesWindowObject *self, PyObject *args)
570{
571 long lattr;
572 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"l;attr", &lattr))
573 return NULL((void *)0);
574 return PyCursesCheckERR(wattron(self->win, (attr_t)lattr)wattr_on(self->win, (attr_t)((attr_t)lattr), ((void *)0)), "attron");
575}
576
577static PyObject *
578PyCursesWindow_AttrSet(PyCursesWindowObject *self, PyObject *args)
579{
580 long lattr;
581 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"l;attr", &lattr))
582 return NULL((void *)0);
583 return PyCursesCheckERR(wattrset(self->win, (attr_t)lattr)((self->win)->_attrs = ((attr_t)lattr)), "attrset");
584}
585
586static PyObject *
587PyCursesWindow_BkgdSet(PyCursesWindowObject *self, PyObject *args)
588{
589 PyObject *temp;
590 chtype bkgd;
591 attr_t attr = A_NORMAL(1U - 1U);
592 long lattr;
593
594 switch (PyTuple_Size(args)) {
595 case 1:
596 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O;ch or int", &temp))
597 return NULL((void *)0);
598 break;
599 case 2:
600 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"Ol;ch or int,attr", &temp, &lattr))
601 return NULL((void *)0);
602 attr = lattr;
603 break;
604 default:
605 PyErr_SetString(PyExc_TypeError, "bkgdset requires 1 or 2 arguments");
606 return NULL((void *)0);
607 }
608
609 if (!PyCurses_ConvertToChtype(temp, &bkgd)) {
610 PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
611 return NULL((void *)0);
612 }
613
614 wbkgdset(self->win, bkgd | attr);
615 return PyCursesCheckERR(0, "bkgdset");
616}
617
618static PyObject *
619PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args)
620{
621 PyObject *temp[8];
622 chtype ch[8];
623 int i;
624
625 /* Clear the array of parameters */
626 for(i=0; i<8; i++) {
627 temp[i] = NULL((void *)0);
628 ch[i] = 0;
629 }
630
631 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"|OOOOOOOO;ls,rs,ts,bs,tl,tr,bl,br",
632 &temp[0], &temp[1], &temp[2], &temp[3],
633 &temp[4], &temp[5], &temp[6], &temp[7]))
634 return NULL((void *)0);
635
636 for(i=0; i<8; i++) {
637 if (temp[i] != NULL((void *)0) && !PyCurses_ConvertToChtype(temp[i], &ch[i])) {
638 PyErr_Format(PyExc_TypeError,
639 "argument %i must be a ch or an int", i+1);
640 return NULL((void *)0);
641 }
642 }
643
644 wborder(self->win,
645 ch[0], ch[1], ch[2], ch[3],
646 ch[4], ch[5], ch[6], ch[7]);
647 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
648 return Py_None(&_Py_NoneStruct);
649}
650
651static PyObject *
652PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args)
653{
654 chtype ch1=0,ch2=0;
655 switch(PyTuple_Size(args)){
656 case 0: break;
657 default:
658 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ll;vertint,horint", &ch1, &ch2))
659 return NULL((void *)0);
660 }
661 box(self->win,ch1,ch2)wborder(self->win, ch1, ch1, ch2, ch2, 0, 0, 0, 0);
662 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
663 return Py_None(&_Py_NoneStruct);
664}
665
666#if defined(HAVE_NCURSES_H1) || defined(MVWDELCH_IS_EXPRESSION1)
667#define py_mvwdelchmvwdelch mvwdelch
668#else
669int py_mvwdelch(WINDOW *w, int y, int x)(wmove(WINDOW *w,int y,int x) == (-1) ? (-1) : wdelch(WINDOW *
w))
670{
671 mvwdelch(w,y,x)(wmove(w,y,x) == (-1) ? (-1) : wdelch(w));
672 /* On HP/UX, mvwdelch already returns. On other systems,
673 we may well run into this return statement. */
674 return 0;
675}
676#endif
677
678/* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */
679
680static PyObject *
681PyCursesWindow_ChgAt(PyCursesWindowObject *self, PyObject *args)
682{
683 int rtn;
684 int x, y;
685 int num = -1;
686 short color;
687 attr_t attr = A_NORMAL(1U - 1U);
688 long lattr;
689 int use_xy = FALSE0;
690
691 switch (PyTuple_Size(args)) {
692 case 1:
693 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"l;attr", &lattr))
694 return NULL((void *)0);
695 attr = lattr;
696 break;
697 case 2:
698 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"il;n,attr", &num, &lattr))
699 return NULL((void *)0);
700 attr = lattr;
701 break;
702 case 3:
703 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iil;int,int,attr", &y, &x, &lattr))
704 return NULL((void *)0);
705 attr = lattr;
706 use_xy = TRUE1;
707 break;
708 case 4:
709 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iiil;int,int,n,attr", &y, &x, &num, &lattr))
710 return NULL((void *)0);
711 attr = lattr;
712 use_xy = TRUE1;
713 break;
714 default:
715 PyErr_SetString(PyExc_TypeError, "chgat requires 1 to 4 arguments");
716 return NULL((void *)0);
717 }
718
719 color = (short)((attr >> 8) & 0xff);
720 attr = attr - (color << 8);
721
722 if (use_xy == TRUE1) {
723 rtn = mvwchgat(self->win,y,x,num,attr,color,NULL)(wmove(self->win,y,x) == (-1) ? (-1) : wchgat(self->win
,num,attr,color,((void *)0)))
;
724 touchline(self->win,y,1)wtouchln((self->win), y, 1, 1);
725 } else {
726 getyx(self->win,y,x)(y = ((self->win) ? (self->win)->_cury : (-1)), x = (
(self->win) ? (self->win)->_curx : (-1)))
;
727 rtn = wchgat(self->win,num,attr,color,NULL((void *)0));
728 touchline(self->win,y,1)wtouchln((self->win), y, 1, 1);
729 }
730 return PyCursesCheckERR(rtn, "chgat");
731}
732
733
734static PyObject *
735PyCursesWindow_DelCh(PyCursesWindowObject *self, PyObject *args)
736{
737 int rtn;
738 int x, y;
739
740 switch (PyTuple_Size(args)) {
741 case 0:
742 rtn = wdelch(self->win);
743 break;
744 case 2:
745 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;y,x", &y, &x))
746 return NULL((void *)0);
747 rtn = py_mvwdelch(self->win,y,x)(wmove(self->win,y,x) == (-1) ? (-1) : wdelch(self->win
))
;
748 break;
749 default:
750 PyErr_SetString(PyExc_TypeError, "delch requires 0 or 2 arguments");
751 return NULL((void *)0);
752 }
753 return PyCursesCheckERR(rtn, "[mv]wdelch");
754}
755
756static PyObject *
757PyCursesWindow_DerWin(PyCursesWindowObject *self, PyObject *args)
758{
759 WINDOW *win;
760 int nlines, ncols, begin_y, begin_x;
761
762 nlines = 0;
763 ncols = 0;
764 switch (PyTuple_Size(args)) {
765 case 2:
766 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;begin_y,begin_x",&begin_y,&begin_x))
767 return NULL((void *)0);
768 break;
769 case 4:
770 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iiii;nlines,ncols,begin_y,begin_x",
771 &nlines,&ncols,&begin_y,&begin_x))
772 return NULL((void *)0);
773 break;
774 default:
775 PyErr_SetString(PyExc_TypeError, "derwin requires 2 or 4 arguments");
776 return NULL((void *)0);
777 }
778
779 win = derwin(self->win,nlines,ncols,begin_y,begin_x);
780
781 if (win == NULL((void *)0)) {
782 PyErr_SetString(PyCursesError, catchall_NULL);
783 return NULL((void *)0);
784 }
785
786 return (PyObject *)PyCursesWindow_New(win);
787}
788
789static PyObject *
790PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args)
791{
792 PyObject *temp;
793 chtype ch;
794 attr_t attr = A_NORMAL(1U - 1U);
795 long lattr;
796
797 switch (PyTuple_Size(args)) {
798 case 1:
799 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"O;ch or int", &temp))
800 return NULL((void *)0);
801 break;
802 case 2:
803 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"Ol;ch or int,attr", &temp, &lattr))
804 return NULL((void *)0);
805 attr = lattr;
806 break;
807 default:
808 PyErr_SetString(PyExc_TypeError, "echochar requires 1 or 2 arguments");
809
810
811 return NULL((void *)0);
812 }
813
814 if (!PyCurses_ConvertToChtype(temp, &ch)) {
815 PyErr_SetString(PyExc_TypeError, "argument 1 must be a ch or an int");
816 return NULL((void *)0);
817 }
818
819#ifdef WINDOW_HAS_FLAGS1
820 if (self->win->_flags & _ISPAD0x10)
821 return PyCursesCheckERR(pechochar(self->win, ch | attr),
822 "echochar");
823 else
824#endif
825 return PyCursesCheckERR(wechochar(self->win, ch | attr),
826 "echochar");
827}
828
829#ifdef NCURSES_MOUSE_VERSION1
830static PyObject *
831PyCursesWindow_Enclose(PyCursesWindowObject *self, PyObject *args)
832{
833 int x, y;
834 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;y,x", &y, &x))
835 return NULL((void *)0);
836
837 return PyLong_FromLong( wenclose(self->win,y,x) );
838}
839#endif
840
841static PyObject *
842PyCursesWindow_GetBkgd(PyCursesWindowObject *self)
843{
844 return PyLong_FromLong((long) getbkgd(self->win)((self->win)->_bkgd));
845}
846
847static PyObject *
848PyCursesWindow_GetCh(PyCursesWindowObject *self, PyObject *args)
849{
850 int x, y;
851 int rtn;
852
853 switch (PyTuple_Size(args)) {
854 case 0:
855 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
856 rtn = wgetch(self->win);
857 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
858 break;
859 case 2:
860 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;y,x",&y,&x))
861 return NULL((void *)0);
862 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
863 rtn = mvwgetch(self->win,y,x)(wmove(self->win,y,x) == (-1) ? (-1) : wgetch(self->win
))
;
864 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
865 break;
866 default:
867 PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments");
868 return NULL((void *)0);
869 }
870 return PyLong_FromLong((long)rtn);
871}
872
873static PyObject *
874PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args)
875{
876 int x, y;
877 int rtn;
878
879 switch (PyTuple_Size(args)) {
880 case 0:
881 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
882 rtn = wgetch(self->win);
883 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
884 break;
885 case 2:
886 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;y,x",&y,&x))
887 return NULL((void *)0);
888 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
889 rtn = mvwgetch(self->win,y,x)(wmove(self->win,y,x) == (-1) ? (-1) : wgetch(self->win
))
;
890 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
891 break;
892 default:
893 PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments");
894 return NULL((void *)0);
895 }
896 if (rtn == ERR(-1)) {
897 /* getch() returns ERR in nodelay mode */
898 PyErr_SetString(PyCursesError, "no input");
899 return NULL((void *)0);
900 } else if (rtn<=255) {
901 return Py_BuildValue_Py_BuildValue_SizeT("C", rtn);
902 } else {
903 const char *knp;
904#if defined(__NetBSD__)
905 knp = unctrl(rtn);
906#else
907 knp = keyname(rtn);
908#endif
909 return PyUnicode_FromStringPyUnicodeUCS2_FromString((knp == NULL((void *)0)) ? "" : knp);
910 }
911}
912
913static PyObject *
914PyCursesWindow_GetStr(PyCursesWindowObject *self, PyObject *args)
915{
916 int x, y, n;
917 char rtn[1024]; /* This should be big enough.. I hope */
918 int rtn2;
919
920 switch (PyTuple_Size(args)) {
921 case 0:
922 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
923 rtn2 = wgetnstr(self->win,rtn, 1023);
924 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
925 break;
926 case 1:
927 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;n", &n))
928 return NULL((void *)0);
929 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
930 rtn2 = wgetnstr(self->win,rtn,MIN(n, 1023)((n) < (1023) ? (n) : (1023)));
931 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
932 break;
933 case 2:
934 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;y,x",&y,&x))
935 return NULL((void *)0);
936 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
937#ifdef STRICT_SYSV_CURSES
938 rtn2 = wmove(self->win,y,x)==ERR(-1) ? ERR(-1) : wgetnstr(self->win, rtn, 1023);
939#else
940 rtn2 = mvwgetnstr(self->win,y,x,rtn, 1023)(wmove(self->win,y,x) == (-1) ? (-1) : wgetnstr(self->win
,rtn,1023))
;
941#endif
942 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
943 break;
944 case 3:
945 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iii;y,x,n", &y, &x, &n))
946 return NULL((void *)0);
947#ifdef STRICT_SYSV_CURSES
948 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
949 rtn2 = wmove(self->win,y,x)==ERR(-1) ? ERR(-1) :
950 wgetnstr(self->win, rtn, MIN(n, 1023)((n) < (1023) ? (n) : (1023)));
951 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
952#else
953 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
954 rtn2 = mvwgetnstr(self->win, y, x, rtn, MIN(n, 1023))(wmove(self->win,y,x) == (-1) ? (-1) : wgetnstr(self->win
,rtn,((n) < (1023) ? (n) : (1023))))
;
955 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
956#endif
957 break;
958 default:
959 PyErr_SetString(PyExc_TypeError, "getstr requires 0 to 3 arguments");
960 return NULL((void *)0);
961 }
962 if (rtn2 == ERR(-1))
963 rtn[0] = 0;
964 return PyBytes_FromString(rtn);
965}
966
967static PyObject *
968PyCursesWindow_Hline(PyCursesWindowObject *self, PyObject *args)
969{
970 PyObject *temp;
971 chtype ch;
972 int n, x, y, code = OK(0);
973 attr_t attr = A_NORMAL(1U - 1U);
974 long lattr;
975
976 switch (PyTuple_Size(args)) {
977 case 2:
978 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "Oi;ch or int,n", &temp, &n))
979 return NULL((void *)0);
980 break;
981 case 3:
982 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
983 return NULL((void *)0);
984 attr = lattr;
985 break;
986 case 4:
987 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
988 return NULL((void *)0);
989 code = wmove(self->win, y, x);
990 break;
991 case 5:
992 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iiOil; y,x,ch or int,n,attr",
993 &y, &x, &temp, &n, &lattr))
994 return NULL((void *)0);
995 attr = lattr;
996 code = wmove(self->win, y, x);
997 break;
998 default:
999 PyErr_SetString(PyExc_TypeError, "hline requires 2 to 5 arguments");
1000 return NULL((void *)0);
1001 }
1002
1003 if (code != ERR(-1)) {
1004 if (!PyCurses_ConvertToChtype(temp, &ch)) {
1005 PyErr_SetString(PyExc_TypeError,
1006 "argument 1 or 3 must be a ch or an int");
1007 return NULL((void *)0);
1008 }
1009 return PyCursesCheckERR(whline(self->win, ch | attr, n), "hline");
1010 } else
1011 return PyCursesCheckERR(code, "wmove");
1012}
1013
1014static PyObject *
1015PyCursesWindow_InsCh(PyCursesWindowObject *self, PyObject *args)
1016{
1017 int rtn, x, y, use_xy = FALSE0;
1018 PyObject *temp;
1019 chtype ch = 0;
1020 attr_t attr = A_NORMAL(1U - 1U);
1021 long lattr;
1022
1023 switch (PyTuple_Size(args)) {
1024 case 1:
1025 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O;ch or int", &temp))
1026 return NULL((void *)0);
1027 break;
1028 case 2:
1029 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "Ol;ch or int,attr", &temp, &lattr))
1030 return NULL((void *)0);
1031 attr = lattr;
1032 break;
1033 case 3:
1034 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iiO;y,x,ch or int", &y, &x, &temp))
1035 return NULL((void *)0);
1036 use_xy = TRUE1;
1037 break;
1038 case 4:
1039 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iiOl;y,x,ch or int, attr", &y, &x, &temp, &lattr))
1040 return NULL((void *)0);
1041 attr = lattr;
1042 use_xy = TRUE1;
1043 break;
1044 default:
1045 PyErr_SetString(PyExc_TypeError, "insch requires 1 or 4 arguments");
1046 return NULL((void *)0);
1047 }
1048
1049 if (!PyCurses_ConvertToChtype(temp, &ch)) {
1050 PyErr_SetString(PyExc_TypeError,
1051 "argument 1 or 3 must be a ch or an int");
1052 return NULL((void *)0);
1053 }
1054
1055 if (use_xy == TRUE1)
1056 rtn = mvwinsch(self->win,y,x, ch | attr)(wmove(self->win,y,x) == (-1) ? (-1) : winsch(self->win
,ch | attr))
;
1057 else {
1058 rtn = winsch(self->win, ch | attr);
1059 }
1060 return PyCursesCheckERR(rtn, "insch");
1061}
1062
1063static PyObject *
1064PyCursesWindow_InCh(PyCursesWindowObject *self, PyObject *args)
1065{
1066 int x, y, rtn;
1067
1068 switch (PyTuple_Size(args)) {
1069 case 0:
1070 rtn = winch(self->win);
1071 break;
1072 case 2:
1073 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;y,x",&y,&x))
1074 return NULL((void *)0);
1075 rtn = mvwinch(self->win,y,x)(wmove(self->win,y,x) == (-1) ? (chtype)((-1)) : winch(self
->win))
;
1076 break;
1077 default:
1078 PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments");
1079 return NULL((void *)0);
1080 }
1081 return PyLong_FromLong((long) rtn);
1082}
1083
1084static PyObject *
1085PyCursesWindow_InStr(PyCursesWindowObject *self, PyObject *args)
1086{
1087 int x, y, n;
1088 char rtn[1024]; /* This should be big enough.. I hope */
1089 int rtn2;
1090
1091 switch (PyTuple_Size(args)) {
1092 case 0:
1093 rtn2 = winnstr(self->win,rtn, 1023);
1094 break;
1095 case 1:
1096 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;n", &n))
1097 return NULL((void *)0);
1098 rtn2 = winnstr(self->win,rtn,MIN(n,1023)((n) < (1023) ? (n) : (1023)));
1099 break;
1100 case 2:
1101 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;y,x",&y,&x))
1102 return NULL((void *)0);
1103 rtn2 = mvwinnstr(self->win,y,x,rtn,1023)(wmove(self->win,y,x) == (-1) ? (-1) : winnstr(self->win
,rtn,1023))
;
1104 break;
1105 case 3:
1106 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iii;y,x,n", &y, &x, &n))
1107 return NULL((void *)0);
1108 rtn2 = mvwinnstr(self->win, y, x, rtn, MIN(n,1023))(wmove(self->win,y,x) == (-1) ? (-1) : winnstr(self->win
,rtn,((n) < (1023) ? (n) : (1023))))
;
1109 break;
1110 default:
1111 PyErr_SetString(PyExc_TypeError, "instr requires 0 or 3 arguments");
1112 return NULL((void *)0);
1113 }
1114 if (rtn2 == ERR(-1))
1115 rtn[0] = 0;
1116 return PyBytes_FromString(rtn);
1117}
1118
1119static PyObject *
1120PyCursesWindow_InsStr(PyCursesWindowObject *self, PyObject *args)
1121{
1122 int rtn;
1123 int x, y;
1124 char *str;
1125 attr_t attr = A_NORMAL(1U - 1U) , attr_old = A_NORMAL(1U - 1U);
1126 long lattr;
1127 int use_xy = FALSE0, use_attr = FALSE0;
1128
1129 switch (PyTuple_Size(args)) {
1130 case 1:
1131 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"s;str", &str))
1132 return NULL((void *)0);
1133 break;
1134 case 2:
1135 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"sl;str,attr", &str, &lattr))
1136 return NULL((void *)0);
1137 attr = lattr;
1138 use_attr = TRUE1;
1139 break;
1140 case 3:
1141 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iis;y,x,str", &y, &x, &str))
1142 return NULL((void *)0);
1143 use_xy = TRUE1;
1144 break;
1145 case 4:
1146 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iisl;y,x,str,attr", &y, &x, &str, &lattr))
1147 return NULL((void *)0);
1148 attr = lattr;
1149 use_xy = use_attr = TRUE1;
1150 break;
1151 default:
1152 PyErr_SetString(PyExc_TypeError, "insstr requires 1 to 4 arguments");
1153 return NULL((void *)0);
1154 }
1155
1156 if (use_attr == TRUE1) {
1157 attr_old = getattrs(self->win)((self->win) ? (self->win)->_attrs : (1U - 1U));
1158 (void)wattrset(self->win,attr)((self->win)->_attrs = (attr));
1159 }
1160 if (use_xy == TRUE1)
1161 rtn = mvwinsstr(self->win,y,x,str)(wmove(self->win,y,x) == (-1) ? (-1) : winsnstr(self->win
, str, -1))
;
1162 else
1163 rtn = winsstr(self->win,str)winsnstr(self->win, str, -1);
1164 if (use_attr == TRUE1)
1165 (void)wattrset(self->win,attr_old)((self->win)->_attrs = (attr_old));
1166 return PyCursesCheckERR(rtn, "insstr");
1167}
1168
1169static PyObject *
1170PyCursesWindow_InsNStr(PyCursesWindowObject *self, PyObject *args)
1171{
1172 int rtn, x, y, n;
1173 char *str;
1174 attr_t attr = A_NORMAL(1U - 1U) , attr_old = A_NORMAL(1U - 1U);
1175 long lattr;
1176 int use_xy = FALSE0, use_attr = FALSE0;
1177
1178 switch (PyTuple_Size(args)) {
1179 case 2:
1180 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"si;str,n", &str, &n))
1181 return NULL((void *)0);
1182 break;
1183 case 3:
1184 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"sil;str,n,attr", &str, &n, &lattr))
1185 return NULL((void *)0);
1186 attr = lattr;
1187 use_attr = TRUE1;
1188 break;
1189 case 4:
1190 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iisi;y,x,str,n", &y, &x, &str, &n))
1191 return NULL((void *)0);
1192 use_xy = TRUE1;
1193 break;
1194 case 5:
1195 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"iisil;y,x,str,n,attr", &y, &x, &str, &n, &lattr))
1196 return NULL((void *)0);
1197 attr = lattr;
1198 use_xy = use_attr = TRUE1;
1199 break;
1200 default:
1201 PyErr_SetString(PyExc_TypeError, "insnstr requires 2 to 5 arguments");
1202 return NULL((void *)0);
1203 }
1204
1205 if (use_attr == TRUE1) {
1206 attr_old = getattrs(self->win)((self->win) ? (self->win)->_attrs : (1U - 1U));
1207 (void)wattrset(self->win,attr)((self->win)->_attrs = (attr));
1208 }
1209 if (use_xy == TRUE1)
1210 rtn = mvwinsnstr(self->win,y,x,str,n)(wmove(self->win,y,x) == (-1) ? (-1) : winsnstr(self->win
,str,n))
;
1211 else
1212 rtn = winsnstr(self->win,str,n);
1213 if (use_attr == TRUE1)
1214 (void)wattrset(self->win,attr_old)((self->win)->_attrs = (attr_old));
1215 return PyCursesCheckERR(rtn, "insnstr");
1216}
1217
1218static PyObject *
1219PyCursesWindow_Is_LineTouched(PyCursesWindowObject *self, PyObject *args)
1220{
1221 int line, erg;
1222 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;line", &line))
1223 return NULL((void *)0);
1224 erg = is_linetouched(self->win, line);
1225 if (erg == ERR(-1)) {
1226 PyErr_SetString(PyExc_TypeError,
1227 "is_linetouched: line number outside of boundaries");
1228 return NULL((void *)0);
1229 } else
1230 if (erg == FALSE0) {
1231 Py_INCREF(Py_False)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_FalseStruct
)))->ob_refcnt++)
;
1232 return Py_False((PyObject *) &_Py_FalseStruct);
1233 } else {
1234 Py_INCREF(Py_True)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct
)))->ob_refcnt++)
;
1235 return Py_True((PyObject *) &_Py_TrueStruct);
1236 }
1237}
1238
1239static PyObject *
1240PyCursesWindow_NoOutRefresh(PyCursesWindowObject *self, PyObject *args)
1241{
1242 int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
1243 int rtn;
1244
1245#ifndef WINDOW_HAS_FLAGS1
1246 if (0)
1247#else
1248 if (self->win->_flags & _ISPAD0x10)
1249#endif
1250 {
1251 switch(PyTuple_Size(args)) {
1252 case 6:
1253 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,
1254 "iiiiii;" \
1255 "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol",
1256 &pminrow, &pmincol, &sminrow,
1257 &smincol, &smaxrow, &smaxcol))
1258 return NULL((void *)0);
1259 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
1260 rtn = pnoutrefresh(self->win,
1261 pminrow, pmincol, sminrow,
1262 smincol, smaxrow, smaxcol);
1263 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
1264 return PyCursesCheckERR(rtn, "pnoutrefresh");
1265 default:
1266 PyErr_SetString(PyCursesError,
1267 "noutrefresh() called for a pad "
1268 "requires 6 arguments");
1269 return NULL((void *)0);
1270 }
1271 } else {
1272 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, ":noutrefresh"))
1273 return NULL((void *)0);
1274
1275 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
1276 rtn = wnoutrefresh(self->win);
1277 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
1278 return PyCursesCheckERR(rtn, "wnoutrefresh");
1279 }
1280}
1281
1282static PyObject *
1283PyCursesWindow_Overlay(PyCursesWindowObject *self, PyObject *args)
1284{
1285 PyCursesWindowObject *temp;
1286 int use_copywin = FALSE0;
1287 int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
1288 int rtn;
1289
1290 switch (PyTuple_Size(args)) {
1291 case 1:
1292 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O!;window object",
1293 &PyCursesWindow_Type, &temp))
1294 return NULL((void *)0);
1295 break;
1296 case 7:
1297 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O!iiiiii;window object, int, int, int, int, int, int",
1298 &PyCursesWindow_Type, &temp, &sminrow, &smincol,
1299 &dminrow, &dmincol, &dmaxrow, &dmaxcol))
1300 return NULL((void *)0);
1301 use_copywin = TRUE1;
1302 break;
1303 default:
1304 PyErr_SetString(PyExc_TypeError,
1305 "overlay requires one or seven arguments");
1306 return NULL((void *)0);
1307 }
1308
1309 if (use_copywin == TRUE1) {
1310 rtn = copywin(self->win, temp->win, sminrow, smincol,
1311 dminrow, dmincol, dmaxrow, dmaxcol, TRUE1);
1312 return PyCursesCheckERR(rtn, "copywin");
1313 }
1314 else {
1315 rtn = overlay(self->win, temp->win);
1316 return PyCursesCheckERR(rtn, "overlay");
1317 }
1318}
1319
1320static PyObject *
1321PyCursesWindow_Overwrite(PyCursesWindowObject *self, PyObject *args)
1322{
1323 PyCursesWindowObject *temp;
1324 int use_copywin = FALSE0;
1325 int sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol;
1326 int rtn;
1327
1328 switch (PyTuple_Size(args)) {
1329 case 1:
1330 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O!;window object",
1331 &PyCursesWindow_Type, &temp))
1332 return NULL((void *)0);
1333 break;
1334 case 7:
1335 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "O!iiiiii;window object, int, int, int, int, int, int",
1336 &PyCursesWindow_Type, &temp, &sminrow, &smincol,
1337 &dminrow, &dmincol, &dmaxrow, &dmaxcol))
1338 return NULL((void *)0);
1339 use_copywin = TRUE1;
1340 break;
1341 default:
1342 PyErr_SetString(PyExc_TypeError,
1343 "overwrite requires one or seven arguments");
1344 return NULL((void *)0);
1345 }
1346
1347 if (use_copywin == TRUE1) {
1348 rtn = copywin(self->win, temp->win, sminrow, smincol,
1349 dminrow, dmincol, dmaxrow, dmaxcol, FALSE0);
1350 return PyCursesCheckERR(rtn, "copywin");
1351 }
1352 else {
1353 rtn = overwrite(self->win, temp->win);
1354 return PyCursesCheckERR(rtn, "overwrite");
1355 }
1356}
1357
1358static PyObject *
1359PyCursesWindow_PutWin(PyCursesWindowObject *self, PyObject *stream)
1360{
1361 /* We have to simulate this by writing to a temporary FILE*,
1362 then reading back, then writing to the argument stream. */
1363 char fn[100];
1364 int fd;
1365 FILE *fp;
1366 PyObject *res;
1367
1368 strcpy(fn, "/tmp/py.curses.putwin.XXXXXX")((__builtin_object_size (fn, 0) != (size_t) -1) ? __builtin___strcpy_chk
(fn, "/tmp/py.curses.putwin.XXXXXX", __builtin_object_size (
fn, 2 > 1)) : __inline_strcpy_chk (fn, "/tmp/py.curses.putwin.XXXXXX"
))
;
1369 fd = mkstemp(fn);
1370 if (fd < 0)
1371 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1372 fp = fdopen(fd, "wb+");
1373 if (fp == NULL((void *)0)) {
1374 close(fd);
1375 remove(fn);
1376 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1377 }
1378 res = PyCursesCheckERR(putwin(self->win, fp), "putwin");
1379 if (res == NULL((void *)0)) {
1380 fclose(fp);
1381 remove(fn);
1382 return res;
1383 }
1384 fseek(fp, 0, 0);
1385 while (1) {
1386 char buf[BUFSIZ1024];
1387 Py_ssize_t n = fread(buf, 1, BUFSIZ1024, fp);
1388 if (n <= 0)
1389 break;
1390 Py_DECREF(res)do { if (_Py_RefTotal-- , --((PyObject*)(res))->ob_refcnt !=
0) { if (((PyObject*)res)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 1390
, (PyObject *)(res)); } else _Py_Dealloc((PyObject *)(res)); }
while (0)
;
1391 res = PyObject_CallMethod_PyObject_CallMethod_SizeT(stream, "write", "y#", buf, n);
1392 if (res == NULL((void *)0))
1393 break;
1394 }
1395 fclose(fp);
1396 remove(fn);
1397 return res;
1398}
1399
1400static PyObject *
1401PyCursesWindow_RedrawLine(PyCursesWindowObject *self, PyObject *args)
1402{
1403 int beg, num;
1404 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "ii;beg,num", &beg, &num))
1405 return NULL((void *)0);
1406 return PyCursesCheckERR(wredrawln(self->win,beg,num), "redrawln");
1407}
1408
1409static PyObject *
1410PyCursesWindow_Refresh(PyCursesWindowObject *self, PyObject *args)
1411{
1412 int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
1413 int rtn;
1414
1415#ifndef WINDOW_HAS_FLAGS1
1416 if (0)
1417#else
1418 if (self->win->_flags & _ISPAD0x10)
1419#endif
1420 {
1421 switch(PyTuple_Size(args)) {
1422 case 6:
1423 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,
1424 "iiiiii;" \
1425 "pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol",
1426 &pminrow, &pmincol, &sminrow,
1427 &smincol, &smaxrow, &smaxcol))
1428 return NULL((void *)0);
1429
1430 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
1431 rtn = prefresh(self->win,
1432 pminrow, pmincol, sminrow,
1433 smincol, smaxrow, smaxcol);
1434 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
1435 return PyCursesCheckERR(rtn, "prefresh");
1436 default:
1437 PyErr_SetString(PyCursesError,
1438 "refresh() for a pad requires 6 arguments");
1439 return NULL((void *)0);
1440 }
1441 } else {
1442 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, ":refresh"))
1443 return NULL((void *)0);
1444 Py_BEGIN_ALLOW_THREADS{ PyThreadState *_save; _save = PyEval_SaveThread();
1445 rtn = wrefresh(self->win);
1446 Py_END_ALLOW_THREADSPyEval_RestoreThread(_save); }
1447 return PyCursesCheckERR(rtn, "prefresh");
1448 }
1449}
1450
1451static PyObject *
1452PyCursesWindow_SetScrollRegion(PyCursesWindowObject *self, PyObject *args)
1453{
1454 int x, y;
1455 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;top, bottom",&y,&x))
1456 return NULL((void *)0);
1457 return PyCursesCheckERR(wsetscrreg(self->win,y,x), "wsetscrreg");
1458}
1459
1460static PyObject *
1461PyCursesWindow_SubWin(PyCursesWindowObject *self, PyObject *args)
1462{
1463 WINDOW *win;
1464 int nlines, ncols, begin_y, begin_x;
1465
1466 nlines = 0;
1467 ncols = 0;
1468 switch (PyTuple_Size(args)) {
1469 case 2:
1470 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;begin_y,begin_x",&begin_y,&begin_x))
1471 return NULL((void *)0);
1472 break;
1473 case 4:
1474 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iiii;nlines,ncols,begin_y,begin_x",
1475 &nlines,&ncols,&begin_y,&begin_x))
1476 return NULL((void *)0);
1477 break;
1478 default:
1479 PyErr_SetString(PyExc_TypeError, "subwin requires 2 or 4 arguments");
1480 return NULL((void *)0);
1481 }
1482
1483 /* printf("Subwin: %i %i %i %i \n", nlines, ncols, begin_y, begin_x); */
1484#ifdef WINDOW_HAS_FLAGS1
1485 if (self->win->_flags & _ISPAD0x10)
1486 win = subpad(self->win, nlines, ncols, begin_y, begin_x);
1487 else
1488#endif
1489 win = subwin(self->win, nlines, ncols, begin_y, begin_x);
1490
1491 if (win == NULL((void *)0)) {
1492 PyErr_SetString(PyCursesError, catchall_NULL);
1493 return NULL((void *)0);
1494 }
1495
1496 return (PyObject *)PyCursesWindow_New(win);
1497}
1498
1499static PyObject *
1500PyCursesWindow_Scroll(PyCursesWindowObject *self, PyObject *args)
1501{
1502 int nlines;
1503 switch(PyTuple_Size(args)) {
1504 case 0:
1505 return PyCursesCheckERR(scroll(self->win)wscrl(self->win,1), "scroll");
1506 case 1:
1507 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i;nlines", &nlines))
1508 return NULL((void *)0);
1509 return PyCursesCheckERR(wscrl(self->win, nlines), "scroll");
1510 default:
1511 PyErr_SetString(PyExc_TypeError, "scroll requires 0 or 1 arguments");
1512 return NULL((void *)0);
1513 }
1514}
1515
1516static PyObject *
1517PyCursesWindow_TouchLine(PyCursesWindowObject *self, PyObject *args)
1518{
1519 int st, cnt, val;
1520 switch (PyTuple_Size(args)) {
1521 case 2:
1522 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;start,count",&st,&cnt))
1523 return NULL((void *)0);
1524 return PyCursesCheckERR(touchline(self->win,st,cnt)wtouchln((self->win), st, cnt, 1), "touchline");
1525 case 3:
1526 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iii;start,count,val", &st, &cnt, &val))
1527 return NULL((void *)0);
1528 return PyCursesCheckERR(wtouchln(self->win, st, cnt, val), "touchline");
1529 default:
1530 PyErr_SetString(PyExc_TypeError, "touchline requires 2 or 3 arguments");
1531 return NULL((void *)0);
1532 }
1533}
1534
1535static PyObject *
1536PyCursesWindow_Vline(PyCursesWindowObject *self, PyObject *args)
1537{
1538 PyObject *temp;
1539 chtype ch;
1540 int n, x, y, code = OK(0);
1541 attr_t attr = A_NORMAL(1U - 1U);
1542 long lattr;
1543
1544 switch (PyTuple_Size(args)) {
1545 case 2:
1546 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "Oi;ch or int,n", &temp, &n))
1547 return NULL((void *)0);
1548 break;
1549 case 3:
1550 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "Oil;ch or int,n,attr", &temp, &n, &lattr))
1551 return NULL((void *)0);
1552 attr = lattr;
1553 break;
1554 case 4:
1555 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iiOi;y,x,ch or int,n", &y, &x, &temp, &n))
1556 return NULL((void *)0);
1557 code = wmove(self->win, y, x);
1558 break;
1559 case 5:
1560 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iiOil; y,x,ch or int,n,attr",
1561 &y, &x, &temp, &n, &lattr))
1562 return NULL((void *)0);
1563 attr = lattr;
1564 code = wmove(self->win, y, x);
1565 break;
1566 default:
1567 PyErr_SetString(PyExc_TypeError, "vline requires 2 to 5 arguments");
1568 return NULL((void *)0);
1569 }
1570
1571 if (code != ERR(-1)) {
1572 if (!PyCurses_ConvertToChtype(temp, &ch)) {
1573 PyErr_SetString(PyExc_TypeError,
1574 "argument 1 or 3 must be a ch or an int");
1575 return NULL((void *)0);
1576 }
1577 return PyCursesCheckERR(wvline(self->win, ch | attr, n), "vline");
1578 } else
1579 return PyCursesCheckERR(code, "wmove");
1580}
1581
1582static PyMethodDef PyCursesWindow_Methods[] = {
1583 {"addch", (PyCFunction)PyCursesWindow_AddCh, METH_VARARGS0x0001},
1584 {"addnstr", (PyCFunction)PyCursesWindow_AddNStr, METH_VARARGS0x0001},
1585 {"addstr", (PyCFunction)PyCursesWindow_AddStr, METH_VARARGS0x0001},
1586 {"attroff", (PyCFunction)PyCursesWindow_AttrOff, METH_VARARGS0x0001},
1587 {"attron", (PyCFunction)PyCursesWindow_AttrOn, METH_VARARGS0x0001},
1588 {"attrset", (PyCFunction)PyCursesWindow_AttrSet, METH_VARARGS0x0001},
1589 {"bkgd", (PyCFunction)PyCursesWindow_Bkgd, METH_VARARGS0x0001},
1590 {"chgat", (PyCFunction)PyCursesWindow_ChgAt, METH_VARARGS0x0001},
1591 {"bkgdset", (PyCFunction)PyCursesWindow_BkgdSet, METH_VARARGS0x0001},
1592 {"border", (PyCFunction)PyCursesWindow_Border, METH_VARARGS0x0001},
1593 {"box", (PyCFunction)PyCursesWindow_Box, METH_VARARGS0x0001},
1594 {"clear", (PyCFunction)PyCursesWindow_wclear, METH_NOARGS0x0004},
1595 {"clearok", (PyCFunction)PyCursesWindow_clearok, METH_VARARGS0x0001},
1596 {"clrtobot", (PyCFunction)PyCursesWindow_wclrtobot, METH_NOARGS0x0004},
1597 {"clrtoeol", (PyCFunction)PyCursesWindow_wclrtoeol, METH_NOARGS0x0004},
1598 {"cursyncup", (PyCFunction)PyCursesWindow_wcursyncup, METH_NOARGS0x0004},
1599 {"delch", (PyCFunction)PyCursesWindow_DelCh, METH_VARARGS0x0001},
1600 {"deleteln", (PyCFunction)PyCursesWindow_wdeleteln, METH_NOARGS0x0004},
1601 {"derwin", (PyCFunction)PyCursesWindow_DerWin, METH_VARARGS0x0001},
1602 {"echochar", (PyCFunction)PyCursesWindow_EchoChar, METH_VARARGS0x0001},
1603#ifdef NCURSES_MOUSE_VERSION1
1604 {"enclose", (PyCFunction)PyCursesWindow_Enclose, METH_VARARGS0x0001},
1605#endif
1606 {"erase", (PyCFunction)PyCursesWindow_werase, METH_NOARGS0x0004},
1607 {"getbegyx", (PyCFunction)PyCursesWindow_getbegyx, METH_NOARGS0x0004},
1608 {"getbkgd", (PyCFunction)PyCursesWindow_GetBkgd, METH_NOARGS0x0004},
1609 {"getch", (PyCFunction)PyCursesWindow_GetCh, METH_VARARGS0x0001},
1610 {"getkey", (PyCFunction)PyCursesWindow_GetKey, METH_VARARGS0x0001},
1611 {"getmaxyx", (PyCFunction)PyCursesWindow_getmaxyx, METH_NOARGS0x0004},
1612 {"getparyx", (PyCFunction)PyCursesWindow_getparyx, METH_NOARGS0x0004},
1613 {"getstr", (PyCFunction)PyCursesWindow_GetStr, METH_VARARGS0x0001},
1614 {"getyx", (PyCFunction)PyCursesWindow_getyx, METH_NOARGS0x0004},
1615 {"hline", (PyCFunction)PyCursesWindow_Hline, METH_VARARGS0x0001},
1616 {"idcok", (PyCFunction)PyCursesWindow_idcok, METH_VARARGS0x0001},
1617 {"idlok", (PyCFunction)PyCursesWindow_idlok, METH_VARARGS0x0001},
1618 {"immedok", (PyCFunction)PyCursesWindow_immedok, METH_VARARGS0x0001},
1619 {"inch", (PyCFunction)PyCursesWindow_InCh, METH_VARARGS0x0001},
1620 {"insch", (PyCFunction)PyCursesWindow_InsCh, METH_VARARGS0x0001},
1621 {"insdelln", (PyCFunction)PyCursesWindow_winsdelln, METH_VARARGS0x0001},
1622 {"insertln", (PyCFunction)PyCursesWindow_winsertln, METH_NOARGS0x0004},
1623 {"insnstr", (PyCFunction)PyCursesWindow_InsNStr, METH_VARARGS0x0001},
1624 {"insstr", (PyCFunction)PyCursesWindow_InsStr, METH_VARARGS0x0001},
1625 {"instr", (PyCFunction)PyCursesWindow_InStr, METH_VARARGS0x0001},
1626 {"is_linetouched", (PyCFunction)PyCursesWindow_Is_LineTouched, METH_VARARGS0x0001},
1627 {"is_wintouched", (PyCFunction)PyCursesWindow_is_wintouched, METH_NOARGS0x0004},
1628 {"keypad", (PyCFunction)PyCursesWindow_keypad, METH_VARARGS0x0001},
1629 {"leaveok", (PyCFunction)PyCursesWindow_leaveok, METH_VARARGS0x0001},
1630 {"move", (PyCFunction)PyCursesWindow_wmove, METH_VARARGS0x0001},
1631 {"mvderwin", (PyCFunction)PyCursesWindow_mvderwin, METH_VARARGS0x0001},
1632 {"mvwin", (PyCFunction)PyCursesWindow_mvwin, METH_VARARGS0x0001},
1633 {"nodelay", (PyCFunction)PyCursesWindow_nodelay, METH_VARARGS0x0001},
1634 {"notimeout", (PyCFunction)PyCursesWindow_notimeout, METH_VARARGS0x0001},
1635 {"noutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS0x0001},
1636 /* Backward compatibility alias -- remove in Python 2.3 */
1637 {"nooutrefresh", (PyCFunction)PyCursesWindow_NoOutRefresh, METH_VARARGS0x0001},
1638 {"overlay", (PyCFunction)PyCursesWindow_Overlay, METH_VARARGS0x0001},
1639 {"overwrite", (PyCFunction)PyCursesWindow_Overwrite,
1640 METH_VARARGS0x0001},
1641 {"putwin", (PyCFunction)PyCursesWindow_PutWin, METH_O0x0008},
1642 {"redrawln", (PyCFunction)PyCursesWindow_RedrawLine, METH_VARARGS0x0001},
1643 {"redrawwin", (PyCFunction)PyCursesWindow_redrawwin, METH_NOARGS0x0004},
1644 {"refresh", (PyCFunction)PyCursesWindow_Refresh, METH_VARARGS0x0001},
1645#ifndef STRICT_SYSV_CURSES
1646 {"resize", (PyCFunction)PyCursesWindow_wresize, METH_VARARGS0x0001},
1647#endif
1648 {"scroll", (PyCFunction)PyCursesWindow_Scroll, METH_VARARGS0x0001},
1649 {"scrollok", (PyCFunction)PyCursesWindow_scrollok, METH_VARARGS0x0001},
1650 {"setscrreg", (PyCFunction)PyCursesWindow_SetScrollRegion, METH_VARARGS0x0001},
1651 {"standend", (PyCFunction)PyCursesWindow_wstandend, METH_NOARGS0x0004},
1652 {"standout", (PyCFunction)PyCursesWindow_wstandout, METH_NOARGS0x0004},
1653 {"subpad", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS0x0001},
1654 {"subwin", (PyCFunction)PyCursesWindow_SubWin, METH_VARARGS0x0001},
1655 {"syncdown", (PyCFunction)PyCursesWindow_wsyncdown, METH_NOARGS0x0004},
1656 {"syncok", (PyCFunction)PyCursesWindow_syncok, METH_VARARGS0x0001},
1657 {"syncup", (PyCFunction)PyCursesWindow_wsyncup, METH_NOARGS0x0004},
1658 {"timeout", (PyCFunction)PyCursesWindow_wtimeout, METH_VARARGS0x0001},
1659 {"touchline", (PyCFunction)PyCursesWindow_TouchLine, METH_VARARGS0x0001},
1660 {"touchwin", (PyCFunction)PyCursesWindow_touchwin, METH_NOARGS0x0004},
1661 {"untouchwin", (PyCFunction)PyCursesWindow_untouchwin, METH_NOARGS0x0004},
1662 {"vline", (PyCFunction)PyCursesWindow_Vline, METH_VARARGS0x0001},
1663 {NULL((void *)0), NULL((void *)0)} /* sentinel */
1664};
1665
1666/* -------------------------------------------------------*/
1667
1668PyTypeObject PyCursesWindow_Type = {
1669 PyVarObject_HEAD_INIT(NULL, 0){ { 0, 0, 1, ((void *)0) }, 0 },
1670 "_curses.curses window", /*tp_name*/
1671 sizeof(PyCursesWindowObject), /*tp_basicsize*/
1672 0, /*tp_itemsize*/
1673 /* methods */
1674 (destructor)PyCursesWindow_Dealloc, /*tp_dealloc*/
1675 0, /*tp_print*/
1676 (getattrfunc)0, /*tp_getattr*/
1677 (setattrfunc)0, /*tp_setattr*/
1678 0, /*tp_reserved*/
1679 0, /*tp_repr*/
1680 0, /*tp_as_number*/
1681 0, /*tp_as_sequence*/
1682 0, /*tp_as_mapping*/
1683 0, /*tp_hash*/
1684 0, /*tp_call*/
1685 0, /*tp_str*/
1686 0, /*tp_getattro*/
1687 0, /*tp_setattro*/
1688 0, /*tp_as_buffer*/
1689 Py_TPFLAGS_DEFAULT( 0 | (1L<<18) | 0), /*tp_flags*/
1690 0, /*tp_doc*/
1691 0, /*tp_traverse*/
1692 0, /*tp_clear*/
1693 0, /*tp_richcompare*/
1694 0, /*tp_weaklistoffset*/
1695 0, /*tp_iter*/
1696 0, /*tp_iternext*/
1697 PyCursesWindow_Methods, /*tp_methods*/
1698};
1699
1700/*********************************************************************
1701 Global Functions
1702**********************************************************************/
1703
1704NoArgNoReturnFunction(beep)static PyObject *PyCurses_beep (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(beep(), "beep"); }
1705NoArgNoReturnFunction(def_prog_mode)static PyObject *PyCurses_def_prog_mode (PyObject *self) { if
(initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(def_prog_mode(), "def_prog_mode"
); }
1706NoArgNoReturnFunction(def_shell_mode)static PyObject *PyCurses_def_shell_mode (PyObject *self) { if
(initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(def_shell_mode(), "def_shell_mode"
); }
1707NoArgNoReturnFunction(doupdate)static PyObject *PyCurses_doupdate (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(doupdate(), "doupdate"
); }
1708NoArgNoReturnFunction(endwin)static PyObject *PyCurses_endwin (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(endwin(), "endwin"); }
1709NoArgNoReturnFunction(flash)static PyObject *PyCurses_flash (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(flash(), "flash"); }
1710NoArgNoReturnFunction(nocbreak)static PyObject *PyCurses_nocbreak (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(nocbreak(), "nocbreak"
); }
1711NoArgNoReturnFunction(noecho)static PyObject *PyCurses_noecho (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(noecho(), "noecho"); }
1712NoArgNoReturnFunction(nonl)static PyObject *PyCurses_nonl (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(nonl(), "nonl"); }
1713NoArgNoReturnFunction(noraw)static PyObject *PyCurses_noraw (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(noraw(), "noraw"); }
1714NoArgNoReturnFunction(reset_prog_mode)static PyObject *PyCurses_reset_prog_mode (PyObject *self) { if
(initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(reset_prog_mode(), "reset_prog_mode"
); }
1715NoArgNoReturnFunction(reset_shell_mode)static PyObject *PyCurses_reset_shell_mode (PyObject *self) {
if (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(reset_shell_mode(), "reset_shell_mode"
); }
1716NoArgNoReturnFunction(resetty)static PyObject *PyCurses_resetty (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(resetty(), "resetty");
}
1717NoArgNoReturnFunction(savetty)static PyObject *PyCurses_savetty (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyCursesCheckERR(savetty(), "savetty");
}
1718
1719NoArgOrFlagNoReturnFunction(cbreak)static PyObject *PyCurses_cbreak (PyObject *self, PyObject *args
) { int flag = 0; if (initialised != 1) { PyErr_SetString(PyCursesError
, "must call initscr() first"); return 0; } switch(PyTuple_Size
(args)) { case 0: return PyCursesCheckERR(cbreak(), "cbreak")
; case 1: if (!_PyArg_ParseTuple_SizeT(args, "i;True(1) or False(0)"
, &flag)) return ((void *)0); if (flag) return PyCursesCheckERR
(cbreak(), "cbreak"); else return PyCursesCheckERR(nocbreak (
), "cbreak"); default: PyErr_SetString(PyExc_TypeError, "cbreak"
" requires 0 or 1 arguments"); return ((void *)0); } }
1720NoArgOrFlagNoReturnFunction(echo)static PyObject *PyCurses_echo (PyObject *self, PyObject *args
) { int flag = 0; if (initialised != 1) { PyErr_SetString(PyCursesError
, "must call initscr() first"); return 0; } switch(PyTuple_Size
(args)) { case 0: return PyCursesCheckERR(echo(), "echo"); case
1: if (!_PyArg_ParseTuple_SizeT(args, "i;True(1) or False(0)"
, &flag)) return ((void *)0); if (flag) return PyCursesCheckERR
(echo(), "echo"); else return PyCursesCheckERR(noecho (), "echo"
); default: PyErr_SetString(PyExc_TypeError, "echo" " requires 0 or 1 arguments"
); return ((void *)0); } }
1721NoArgOrFlagNoReturnFunction(nl)static PyObject *PyCurses_nl (PyObject *self, PyObject *args)
{ int flag = 0; if (initialised != 1) { PyErr_SetString(PyCursesError
, "must call initscr() first"); return 0; } switch(PyTuple_Size
(args)) { case 0: return PyCursesCheckERR(nl(), "nl"); case 1
: if (!_PyArg_ParseTuple_SizeT(args, "i;True(1) or False(0)",
&flag)) return ((void *)0); if (flag) return PyCursesCheckERR
(nl(), "nl"); else return PyCursesCheckERR(nonl (), "nl"); default
: PyErr_SetString(PyExc_TypeError, "nl" " requires 0 or 1 arguments"
); return ((void *)0); } }
1722NoArgOrFlagNoReturnFunction(raw)static PyObject *PyCurses_raw (PyObject *self, PyObject *args
) { int flag = 0; if (initialised != 1) { PyErr_SetString(PyCursesError
, "must call initscr() first"); return 0; } switch(PyTuple_Size
(args)) { case 0: return PyCursesCheckERR(raw(), "raw"); case
1: if (!_PyArg_ParseTuple_SizeT(args, "i;True(1) or False(0)"
, &flag)) return ((void *)0); if (flag) return PyCursesCheckERR
(raw(), "raw"); else return PyCursesCheckERR(noraw (), "raw")
; default: PyErr_SetString(PyExc_TypeError, "raw" " requires 0 or 1 arguments"
); return ((void *)0); } }
1723
1724NoArgReturnIntFunction(baudrate)static PyObject *PyCurses_baudrate (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyLong_FromLong((long) baudrate()); }
1725NoArgReturnIntFunction(termattrs)static PyObject *PyCurses_termattrs (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyLong_FromLong((long) termattrs()); }
1726
1727NoArgReturnStringFunction(termname)static PyObject *PyCurses_termname (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyBytes_FromString(termname()); }
1728NoArgReturnStringFunction(longname)static PyObject *PyCurses_longname (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } return PyBytes_FromString(longname()); }
1729
1730NoArgTrueFalseFunction(can_change_color)static PyObject *PyCurses_can_change_color (PyObject *self) {
if (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } if (can_change_color () == 0) { ( _Py_RefTotal
++ , ((PyObject*)(((PyObject *) &_Py_FalseStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_FalseStruct); } ( _Py_RefTotal
++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_TrueStruct); }
1731NoArgTrueFalseFunction(has_colors)static PyObject *PyCurses_has_colors (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } if (has_colors () == 0) { ( _Py_RefTotal++ , (
(PyObject*)(((PyObject *) &_Py_FalseStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_FalseStruct); } ( _Py_RefTotal
++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_TrueStruct); }
1732NoArgTrueFalseFunction(has_ic)static PyObject *PyCurses_has_ic (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } if (has_ic () == 0) { ( _Py_RefTotal++ , ((PyObject
*)(((PyObject *) &_Py_FalseStruct)))->ob_refcnt++); return
((PyObject *) &_Py_FalseStruct); } ( _Py_RefTotal++ , ((
PyObject*)(((PyObject *) &_Py_TrueStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_TrueStruct); }
1733NoArgTrueFalseFunction(has_il)static PyObject *PyCurses_has_il (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } if (has_il () == 0) { ( _Py_RefTotal++ , ((PyObject
*)(((PyObject *) &_Py_FalseStruct)))->ob_refcnt++); return
((PyObject *) &_Py_FalseStruct); } ( _Py_RefTotal++ , ((
PyObject*)(((PyObject *) &_Py_TrueStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_TrueStruct); }
1734NoArgTrueFalseFunction(isendwin)static PyObject *PyCurses_isendwin (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } if (isendwin () == 0) { ( _Py_RefTotal++ , ((PyObject
*)(((PyObject *) &_Py_FalseStruct)))->ob_refcnt++); return
((PyObject *) &_Py_FalseStruct); } ( _Py_RefTotal++ , ((
PyObject*)(((PyObject *) &_Py_TrueStruct)))->ob_refcnt
++); return ((PyObject *) &_Py_TrueStruct); }
1735NoArgNoReturnVoidFunction(flushinp)static PyObject *PyCurses_flushinp (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } flushinp(); ( _Py_RefTotal++ , ((PyObject*)((&
_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
1736NoArgNoReturnVoidFunction(noqiflush)static PyObject *PyCurses_noqiflush (PyObject *self) { if (initialised
!= 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; } noqiflush(); ( _Py_RefTotal++ , ((PyObject*)((
&_Py_NoneStruct)))->ob_refcnt++); return (&_Py_NoneStruct
); }
1737
1738static PyObject *
1739PyCurses_filter(PyObject *self)
1740{
1741 /* not checking for PyCursesInitialised here since filter() must
1742 be called before initscr() */
1743 filter();
1744 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
1745 return Py_None(&_Py_NoneStruct);
1746}
1747
1748static PyObject *
1749PyCurses_Color_Content(PyObject *self, PyObject *args)
1750{
1751 short color,r,g,b;
1752
1753 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1754 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
1755
1756 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "h:color_content", &color)) return NULL((void *)0);
1757
1758 if (color_content(color, &r, &g, &b) != ERR(-1))
1759 return Py_BuildValue_Py_BuildValue_SizeT("(iii)", r, g, b);
1760 else {
1761 PyErr_SetString(PyCursesError,
1762 "Argument 1 was out of range. Check value of COLORS.");
1763 return NULL((void *)0);
1764 }
1765}
1766
1767static PyObject *
1768PyCurses_color_pair(PyObject *self, PyObject *args)
1769{
1770 int n;
1771
1772 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1773 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
1774
1775 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i:color_pair", &n)) return NULL((void *)0);
1776 return PyLong_FromLong((long) (n << 8));
1777}
1778
1779static PyObject *
1780PyCurses_Curs_Set(PyObject *self, PyObject *args)
1781{
1782 int vis,erg;
1783
1784 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1785
1786 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i:curs_set", &vis)) return NULL((void *)0);
1787
1788 erg = curs_set(vis);
1789 if (erg == ERR(-1)) return PyCursesCheckERR(erg, "curs_set");
1790
1791 return PyLong_FromLong((long) erg);
1792}
1793
1794static PyObject *
1795PyCurses_Delay_Output(PyObject *self, PyObject *args)
1796{
1797 int ms;
1798
1799 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1800
1801 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i:delay_output", &ms)) return NULL((void *)0);
1802
1803 return PyCursesCheckERR(delay_output(ms), "delay_output");
1804}
1805
1806static PyObject *
1807PyCurses_EraseChar(PyObject *self)
1808{
1809 char ch;
1810
1811 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1812
1813 ch = erasechar();
1814
1815 return PyBytes_FromStringAndSize(&ch, 1);
1816}
1817
1818static PyObject *
1819PyCurses_getsyx(PyObject *self)
1820{
1821 int x = 0;
1822 int y = 0;
1823
1824 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1825
1826 getsyx(y, x)do { if (newscr) { if (((newscr)->_leaveok)) (y) = (x) = -
1; else ((y) = ((newscr) ? (newscr)->_cury : (-1)), (x) = (
(newscr) ? (newscr)->_curx : (-1))); } } while(0)
;
1827
1828 return Py_BuildValue_Py_BuildValue_SizeT("(ii)", y, x);
1829}
1830
1831#ifdef NCURSES_MOUSE_VERSION1
1832static PyObject *
1833PyCurses_GetMouse(PyObject *self)
1834{
1835 int rtn;
1836 MEVENT event;
1837
1838 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1839
1840 rtn = getmouse( &event );
1841 if (rtn == ERR(-1)) {
1842 PyErr_SetString(PyCursesError, "getmouse() returned ERR");
1843 return NULL((void *)0);
1844 }
1845 return Py_BuildValue_Py_BuildValue_SizeT("(hiiil)",
1846 (short)event.id,
1847 event.x, event.y, event.z,
1848 (long) event.bstate);
1849}
1850
1851static PyObject *
1852PyCurses_UngetMouse(PyObject *self, PyObject *args)
1853{
1854 MEVENT event;
1855
1856 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1857 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "hiiil",
1858 &event.id,
1859 &event.x, &event.y, &event.z,
1860 (int *) &event.bstate))
1861 return NULL((void *)0);
1862
1863 return PyCursesCheckERR(ungetmouse(&event), "ungetmouse");
1864}
1865#endif
1866
1867static PyObject *
1868PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
1869{
1870 char fn[100];
1871 int fd;
1872 FILE *fp;
1873 PyObject *data;
1874 size_t datalen;
1875 WINDOW *win;
1876
1877 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1878
1879 strcpy(fn, "/tmp/py.curses.getwin.XXXXXX")((__builtin_object_size (fn, 0) != (size_t) -1) ? __builtin___strcpy_chk
(fn, "/tmp/py.curses.getwin.XXXXXX", __builtin_object_size (
fn, 2 > 1)) : __inline_strcpy_chk (fn, "/tmp/py.curses.getwin.XXXXXX"
))
;
1880 fd = mkstemp(fn);
1881 if (fd < 0)
1882 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1883 fp = fdopen(fd, "wb+");
1884 if (fp == NULL((void *)0)) {
1885 close(fd);
1886 remove(fn);
1887 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1888 }
1889 data = PyObject_CallMethod_PyObject_CallMethod_SizeT(stream, "read", "");
1890 if (data == NULL((void *)0)) {
1891 fclose(fp);
1892 remove(fn);
1893 return NULL((void *)0);
1894 }
1895 if (!PyBytes_Check(data)((((((PyObject*)(data))->ob_type))->tp_flags & ((1L
<<27))) != 0)
) {
1896 PyErr_Format(PyExc_TypeError,
1897 "f.read() returned %.100s instead of bytes",
1898 data->ob_type->tp_name);
1899 Py_DECREF(data)do { if (_Py_RefTotal-- , --((PyObject*)(data))->ob_refcnt
!= 0) { if (((PyObject*)data)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 1899
, (PyObject *)(data)); } else _Py_Dealloc((PyObject *)(data))
; } while (0)
;
1900 fclose(fp);
1901 remove(fn);
1902 return NULL((void *)0);
1903 }
1904 datalen = PyBytes_GET_SIZE(data)((__builtin_expect(!(((((((PyObject*)(data))->ob_type))->
tp_flags & ((1L<<27))) != 0)), 0) ? __assert_rtn(__func__
, "/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c",
1904, "PyBytes_Check(data)") : (void)0),(((PyVarObject*)(data
))->ob_size))
;
1905 if (fwrite(PyBytes_AS_STRING(data)((__builtin_expect(!(((((((PyObject*)(data))->ob_type))->
tp_flags & ((1L<<27))) != 0)), 0) ? __assert_rtn(__func__
, "/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c",
1905, "PyBytes_Check(data)") : (void)0), (((PyBytesObject *)
(data))->ob_sval))
, 1, datalen, fp) != datalen) {
1906 Py_DECREF(data)do { if (_Py_RefTotal-- , --((PyObject*)(data))->ob_refcnt
!= 0) { if (((PyObject*)data)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 1906
, (PyObject *)(data)); } else _Py_Dealloc((PyObject *)(data))
; } while (0)
;
1907 fclose(fp);
1908 remove(fn);
1909 return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
1910 }
1911 Py_DECREF(data)do { if (_Py_RefTotal-- , --((PyObject*)(data))->ob_refcnt
!= 0) { if (((PyObject*)data)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 1911
, (PyObject *)(data)); } else _Py_Dealloc((PyObject *)(data))
; } while (0)
;
1912 fseek(fp, 0, 0);
1913 win = getwin(fp);
1914 fclose(fp);
1915 remove(fn);
1916 if (win == NULL((void *)0)) {
1917 PyErr_SetString(PyCursesError, catchall_NULL);
1918 return NULL((void *)0);
1919 }
1920 return PyCursesWindow_New(win);
1921}
1922
1923static PyObject *
1924PyCurses_HalfDelay(PyObject *self, PyObject *args)
1925{
1926 unsigned char tenths;
1927
1928 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1929
1930 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "b:halfdelay", &tenths)) return NULL((void *)0);
1931
1932 return PyCursesCheckERR(halfdelay(tenths), "halfdelay");
1933}
1934
1935#ifndef STRICT_SYSV_CURSES
1936/* No has_key! */
1937static PyObject * PyCurses_has_key(PyObject *self, PyObject *args)
1938{
1939 int ch;
1940
1941 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1942
1943 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i",&ch)) return NULL((void *)0);
1944
1945 if (has_key(ch) == FALSE0) {
1946 Py_INCREF(Py_False)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_FalseStruct
)))->ob_refcnt++)
;
1947 return Py_False((PyObject *) &_Py_FalseStruct);
1948 }
1949 Py_INCREF(Py_True)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct
)))->ob_refcnt++)
;
1950 return Py_True((PyObject *) &_Py_TrueStruct);
1951}
1952#endif /* STRICT_SYSV_CURSES */
1953
1954static PyObject *
1955PyCurses_Init_Color(PyObject *self, PyObject *args)
1956{
1957 short color, r, g, b;
1958
1959 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1960 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
1961
1962 switch(PyTuple_Size(args)) {
1963 case 4:
1964 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "hhhh;color,r,g,b", &color, &r, &g, &b)) return NULL((void *)0);
1965 break;
1966 default:
1967 PyErr_SetString(PyExc_TypeError, "init_color requires 4 arguments");
1968 return NULL((void *)0);
1969 }
1970
1971 return PyCursesCheckERR(init_color(color, r, g, b), "init_color");
1972}
1973
1974static PyObject *
1975PyCurses_Init_Pair(PyObject *self, PyObject *args)
1976{
1977 short pair, f, b;
1978
1979 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
1980 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
1981
1982 if (PyTuple_Size(args) != 3) {
1983 PyErr_SetString(PyExc_TypeError, "init_pair requires 3 arguments");
1984 return NULL((void *)0);
1985 }
1986
1987 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "hhh;pair, f, b", &pair, &f, &b)) return NULL((void *)0);
1988
1989 return PyCursesCheckERR(init_pair(pair, f, b), "init_pair");
1990}
1991
1992static PyObject *ModDict;
1993
1994static PyObject *
1995PyCurses_InitScr(PyObject *self)
1996{
1997 WINDOW *win;
1998
1999 if (initialised == TRUE1) {
2000 wrefresh(stdscr);
2001 return (PyObject *)PyCursesWindow_New(stdscr);
2002 }
2003
2004 win = initscr();
2005
2006 if (win == NULL((void *)0)) {
2007 PyErr_SetString(PyCursesError, catchall_NULL);
2008 return NULL((void *)0);
2009 }
2010
2011 initialised = initialised_setupterm = TRUE1;
2012
2013/* This was moved from initcurses() because it core dumped on SGI,
2014 where they're not defined until you've called initscr() */
2015#define SetDictInt(string,ch)do { PyObject *o = PyLong_FromLong((long) (ch)); if (o &&
PyDict_SetItemString(ModDict, string, o) == 0) { do { if (_Py_RefTotal
-- , --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*
)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2015, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
\
2016 do { \
2017 PyObject *o = PyLong_FromLong((long) (ch)); \
2018 if (o && PyDict_SetItemString(ModDict, string, o) == 0) { \
2019 Py_DECREF(o)do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt !=
0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2019
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0)
; \
2020 } \
2021 } while (0)
2022
2023 /* Here are some graphic symbols you can use */
2024 SetDictInt("ACS_ULCORNER", (ACS_ULCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('l')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_ULCORNER", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2024, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2025 SetDictInt("ACS_LLCORNER", (ACS_LLCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('m')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_LLCORNER", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2025, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2026 SetDictInt("ACS_URCORNER", (ACS_URCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('k')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_URCORNER", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2026, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2027 SetDictInt("ACS_LRCORNER", (ACS_LRCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('j')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_LRCORNER", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2027, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2028 SetDictInt("ACS_LTEE", (ACS_LTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('t')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_LTEE", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2028, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2029 SetDictInt("ACS_RTEE", (ACS_RTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('u')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_RTEE", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2029, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2030 SetDictInt("ACS_BTEE", (ACS_BTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('v')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BTEE", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2030, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2031 SetDictInt("ACS_TTEE", (ACS_TTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('w')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_TTEE", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2031, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2032 SetDictInt("ACS_HLINE", (ACS_HLINE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('q')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_HLINE", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2032, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2033 SetDictInt("ACS_VLINE", (ACS_VLINE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('x')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_VLINE", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2033, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2034 SetDictInt("ACS_PLUS", (ACS_PLUS))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('n')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_PLUS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2034, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2035#if !defined(__hpux) || defined(HAVE_NCURSES_H1)
2036 /* On HP/UX 11, these are of type cchar_t, which is not an
2037 integral type. If this is a problem on more platforms, a
2038 configure test should be added to determine whether ACS_S1
2039 is of integral type. */
2040 SetDictInt("ACS_S1", (ACS_S1))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('o')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_S1", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2040, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2041 SetDictInt("ACS_S9", (ACS_S9))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('s')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_S9", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2041, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2042 SetDictInt("ACS_DIAMOND", (ACS_DIAMOND))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('`')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_DIAMOND", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2042, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2043 SetDictInt("ACS_CKBOARD", (ACS_CKBOARD))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('a')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_CKBOARD", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2043, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2044 SetDictInt("ACS_DEGREE", (ACS_DEGREE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('f')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_DEGREE", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2044, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2045 SetDictInt("ACS_PLMINUS", (ACS_PLMINUS))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('g')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_PLMINUS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2045, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2046 SetDictInt("ACS_BULLET", (ACS_BULLET))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('~')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BULLET", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2046, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2047 SetDictInt("ACS_LARROW", (ACS_LARROW))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)(',')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_LARROW", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2047, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2048 SetDictInt("ACS_RARROW", (ACS_RARROW))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('+')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_RARROW", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2048, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2049 SetDictInt("ACS_DARROW", (ACS_DARROW))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('.')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_DARROW", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2049, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2050 SetDictInt("ACS_UARROW", (ACS_UARROW))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('-')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_UARROW", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2050, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2051 SetDictInt("ACS_BOARD", (ACS_BOARD))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('h')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BOARD", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2051, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2052 SetDictInt("ACS_LANTERN", (ACS_LANTERN))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('i')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_LANTERN", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2052, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2053 SetDictInt("ACS_BLOCK", (ACS_BLOCK))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('0')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BLOCK", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2053, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2054#endif
2055 SetDictInt("ACS_BSSB", (ACS_ULCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('l')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BSSB", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2055, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2056 SetDictInt("ACS_SSBB", (ACS_LLCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('m')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_SSBB", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2056, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2057 SetDictInt("ACS_BBSS", (ACS_URCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('k')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BBSS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2057, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2058 SetDictInt("ACS_SBBS", (ACS_LRCORNER))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('j')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_SBBS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2058, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2059 SetDictInt("ACS_SBSS", (ACS_RTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('u')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_SBSS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2059, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2060 SetDictInt("ACS_SSSB", (ACS_LTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('t')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_SSSB", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2060, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2061 SetDictInt("ACS_SSBS", (ACS_BTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('v')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_SSBS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2061, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2062 SetDictInt("ACS_BSSS", (ACS_TTEE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('w')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BSSS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2062, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2063 SetDictInt("ACS_BSBS", (ACS_HLINE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('q')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_BSBS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2063, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2064 SetDictInt("ACS_SBSB", (ACS_VLINE))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('x')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_SBSB", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2064, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2065 SetDictInt("ACS_SSSS", (ACS_PLUS))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('n')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_SSSS", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2065, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2066
2067 /* The following are never available with strict SYSV curses */
2068#ifdef ACS_S3(acs_map[(unsigned char)('p')])
2069 SetDictInt("ACS_S3", (ACS_S3))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('p')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_S3", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2069, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2070#endif
2071#ifdef ACS_S7(acs_map[(unsigned char)('r')])
2072 SetDictInt("ACS_S7", (ACS_S7))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('r')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_S7", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2072, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2073#endif
2074#ifdef ACS_LEQUAL(acs_map[(unsigned char)('y')])
2075 SetDictInt("ACS_LEQUAL", (ACS_LEQUAL))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('y')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_LEQUAL", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2075, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2076#endif
2077#ifdef ACS_GEQUAL(acs_map[(unsigned char)('z')])
2078 SetDictInt("ACS_GEQUAL", (ACS_GEQUAL))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('z')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_GEQUAL", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2078, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2079#endif
2080#ifdef ACS_PI(acs_map[(unsigned char)('{')])
2081 SetDictInt("ACS_PI", (ACS_PI))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('{')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_PI", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2081, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2082#endif
2083#ifdef ACS_NEQUAL(acs_map[(unsigned char)('|')])
2084 SetDictInt("ACS_NEQUAL", (ACS_NEQUAL))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('|')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_NEQUAL", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2084, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2085#endif
2086#ifdef ACS_STERLING(acs_map[(unsigned char)('}')])
2087 SetDictInt("ACS_STERLING", (ACS_STERLING))do { PyObject *o = PyLong_FromLong((long) (((acs_map[(unsigned
char)('}')])))); if (o && PyDict_SetItemString(ModDict
, "ACS_STERLING", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2087, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2088#endif
2089
2090 SetDictInt("LINES", LINES)do { PyObject *o = PyLong_FromLong((long) (LINES)); if (o &&
PyDict_SetItemString(ModDict, "LINES", o) == 0) { do { if (_Py_RefTotal
-- , --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*
)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2090, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2091 SetDictInt("COLS", COLS)do { PyObject *o = PyLong_FromLong((long) (COLS)); if (o &&
PyDict_SetItemString(ModDict, "COLS", o) == 0) { do { if (_Py_RefTotal
-- , --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*
)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2091, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2092
2093 return (PyObject *)PyCursesWindow_New(win);
2094}
2095
2096static PyObject *
2097PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds)
2098{
2099 int fd = -1;
2100 int err;
2101 char* termstr = NULL((void *)0);
2102
2103 static char *kwlist[] = {"term", "fd", NULL((void *)0)};
2104
2105 if (!PyArg_ParseTupleAndKeywords_PyArg_ParseTupleAndKeywords_SizeT(
2106 args, keywds, "|zi:setupterm", kwlist, &termstr, &fd)) {
2107 return NULL((void *)0);
2108 }
2109
2110 if (fd == -1) {
2111 PyObject* sys_stdout;
2112
2113 sys_stdout = PySys_GetObject("stdout");
2114
2115 if (sys_stdout == NULL((void *)0) || sys_stdout == Py_None(&_Py_NoneStruct)) {
2116 PyErr_SetString(
2117 PyCursesError,
2118 "lost sys.stdout");
2119 return NULL((void *)0);
2120 }
2121
2122 fd = PyObject_AsFileDescriptor(sys_stdout);
2123
2124 if (fd == -1) {
2125 return NULL((void *)0);
2126 }
2127 }
2128
2129 if (!initialised_setupterm && setupterm(termstr,fd,&err) == ERR(-1)) {
2130 char* s = "setupterm: unknown error";
2131
2132 if (err == 0) {
2133 s = "setupterm: could not find terminal";
2134 } else if (err == -1) {
2135 s = "setupterm: could not find terminfo database";
2136 }
2137
2138 PyErr_SetString(PyCursesError,s);
2139 return NULL((void *)0);
2140 }
2141
2142 initialised_setupterm = TRUE1;
2143
2144 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2145 return Py_None(&_Py_NoneStruct);
2146}
2147
2148static PyObject *
2149PyCurses_IntrFlush(PyObject *self, PyObject *args)
2150{
2151 int ch;
2152
2153 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2154
2155 switch(PyTuple_Size(args)) {
2156 case 1:
2157 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;True(1), False(0)",&ch)) return NULL((void *)0);
2158 break;
2159 default:
2160 PyErr_SetString(PyExc_TypeError, "intrflush requires 1 argument");
2161 return NULL((void *)0);
2162 }
2163
2164 return PyCursesCheckERR(intrflush(NULL((void *)0),ch), "intrflush");
2165}
2166
2167#ifdef HAVE_CURSES_IS_TERM_RESIZED1
2168static PyObject *
2169PyCurses_Is_Term_Resized(PyObject *self, PyObject *args)
2170{
2171 int lines;
2172 int columns;
2173 int result;
2174
2175 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2176
2177 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii:is_term_resized", &lines, &columns))
2178 return NULL((void *)0);
2179 result = is_term_resized(lines, columns);
2180 if (result == TRUE1) {
2181 Py_INCREF(Py_True)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_TrueStruct
)))->ob_refcnt++)
;
2182 return Py_True((PyObject *) &_Py_TrueStruct);
2183 } else {
2184 Py_INCREF(Py_False)( _Py_RefTotal++ , ((PyObject*)(((PyObject *) &_Py_FalseStruct
)))->ob_refcnt++)
;
2185 return Py_False((PyObject *) &_Py_FalseStruct);
2186 }
2187}
2188#endif /* HAVE_CURSES_IS_TERM_RESIZED */
2189
2190#if !defined(__NetBSD__)
2191static PyObject *
2192PyCurses_KeyName(PyObject *self, PyObject *args)
2193{
2194 const char *knp;
2195 int ch;
2196
2197 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2198
2199 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i",&ch)) return NULL((void *)0);
2200
2201 if (ch < 0) {
2202 PyErr_SetString(PyExc_ValueError, "invalid key number");
2203 return NULL((void *)0);
2204 }
2205 knp = keyname(ch);
2206
2207 return PyBytes_FromString((knp == NULL((void *)0)) ? "" : (char *)knp);
2208}
2209#endif
2210
2211static PyObject *
2212PyCurses_KillChar(PyObject *self)
2213{
2214 char ch;
2215
2216 ch = killchar();
2217
2218 return PyBytes_FromStringAndSize(&ch, 1);
2219}
2220
2221static PyObject *
2222PyCurses_Meta(PyObject *self, PyObject *args)
2223{
2224 int ch;
2225
2226 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2227
2228 switch(PyTuple_Size(args)) {
2229 case 1:
2230 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;True(1), False(0)",&ch)) return NULL((void *)0);
2231 break;
2232 default:
2233 PyErr_SetString(PyExc_TypeError, "meta requires 1 argument");
2234 return NULL((void *)0);
2235 }
2236
2237 return PyCursesCheckERR(meta(stdscr, ch), "meta");
2238}
2239
2240#ifdef NCURSES_MOUSE_VERSION1
2241static PyObject *
2242PyCurses_MouseInterval(PyObject *self, PyObject *args)
2243{
2244 int interval;
2245 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2246
2247 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;interval",&interval))
2248 return NULL((void *)0);
2249 return PyCursesCheckERR(mouseinterval(interval), "mouseinterval");
2250}
2251
2252static PyObject *
2253PyCurses_MouseMask(PyObject *self, PyObject *args)
2254{
2255 int newmask;
2256 mmask_t oldmask, availmask;
2257
2258 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2259 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;mousemask",&newmask))
2260 return NULL((void *)0);
2261 availmask = mousemask(newmask, &oldmask);
2262 return Py_BuildValue_Py_BuildValue_SizeT("(ll)", (long)availmask, (long)oldmask);
2263}
2264#endif
2265
2266static PyObject *
2267PyCurses_Napms(PyObject *self, PyObject *args)
2268{
2269 int ms;
2270
2271 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2272 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i;ms", &ms)) return NULL((void *)0);
2273
2274 return Py_BuildValue_Py_BuildValue_SizeT("i", napms(ms));
2275}
2276
2277
2278static PyObject *
2279PyCurses_NewPad(PyObject *self, PyObject *args)
2280{
2281 WINDOW *win;
2282 int nlines, ncols;
2283
2284 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2285
2286 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;nlines,ncols",&nlines,&ncols)) return NULL((void *)0);
2287
2288 win = newpad(nlines, ncols);
2289
2290 if (win == NULL((void *)0)) {
2291 PyErr_SetString(PyCursesError, catchall_NULL);
2292 return NULL((void *)0);
2293 }
2294
2295 return (PyObject *)PyCursesWindow_New(win);
2296}
2297
2298static PyObject *
2299PyCurses_NewWindow(PyObject *self, PyObject *args)
2300{
2301 WINDOW *win;
2302 int nlines, ncols, begin_y=0, begin_x=0;
2303
2304 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2305
2306 switch (PyTuple_Size(args)) {
2307 case 2:
2308 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii;nlines,ncols",&nlines,&ncols))
2309 return NULL((void *)0);
2310 break;
2311 case 4:
2312 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "iiii;nlines,ncols,begin_y,begin_x",
2313 &nlines,&ncols,&begin_y,&begin_x))
2314 return NULL((void *)0);
2315 break;
2316 default:
2317 PyErr_SetString(PyExc_TypeError, "newwin requires 2 or 4 arguments");
2318 return NULL((void *)0);
2319 }
2320
2321 win = newwin(nlines,ncols,begin_y,begin_x);
2322 if (win == NULL((void *)0)) {
2323 PyErr_SetString(PyCursesError, catchall_NULL);
2324 return NULL((void *)0);
2325 }
2326
2327 return (PyObject *)PyCursesWindow_New(win);
2328}
2329
2330static PyObject *
2331PyCurses_Pair_Content(PyObject *self, PyObject *args)
2332{
2333 short pair,f,b;
2334
2335 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2336 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
2337
2338 switch(PyTuple_Size(args)) {
2339 case 1:
2340 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "h;pair", &pair)) return NULL((void *)0);
2341 break;
2342 default:
2343 PyErr_SetString(PyExc_TypeError, "pair_content requires 1 argument");
2344 return NULL((void *)0);
2345 }
2346
2347 if (pair_content(pair, &f, &b)==ERR(-1)) {
2348 PyErr_SetString(PyCursesError,
2349 "Argument 1 was out of range. (1..COLOR_PAIRS-1)");
2350 return NULL((void *)0);
2351 }
2352
2353 return Py_BuildValue_Py_BuildValue_SizeT("(ii)", f, b);
2354}
2355
2356static PyObject *
2357PyCurses_pair_number(PyObject *self, PyObject *args)
2358{
2359 int n;
2360
2361 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2362 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
2363
2364 switch(PyTuple_Size(args)) {
2365 case 1:
2366 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i;pairvalue", &n)) return NULL((void *)0);
2367 break;
2368 default:
2369 PyErr_SetString(PyExc_TypeError,
2370 "pair_number requires 1 argument");
2371 return NULL((void *)0);
2372 }
2373
2374 return PyLong_FromLong((long) ((n & A_COLOR((((1U) << 8) - 1U) << ((0) + 8))) >> 8));
2375}
2376
2377static PyObject *
2378PyCurses_Putp(PyObject *self, PyObject *args)
2379{
2380 char *str;
2381
2382 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"s;str", &str)) return NULL((void *)0);
2383 return PyCursesCheckERR(putp(str), "putp");
2384}
2385
2386static PyObject *
2387PyCurses_QiFlush(PyObject *self, PyObject *args)
2388{
2389 int flag = 0;
2390
2391 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2392
2393 switch(PyTuple_Size(args)) {
2394 case 0:
2395 qiflush();
2396 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2397 return Py_None(&_Py_NoneStruct);
2398 case 1:
2399 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "i;True(1) or False(0)", &flag)) return NULL((void *)0);
2400 if (flag) qiflush();
2401 else noqiflush();
2402 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2403 return Py_None(&_Py_NoneStruct);
2404 default:
2405 PyErr_SetString(PyExc_TypeError, "qiflush requires 0 or 1 arguments");
2406 return NULL((void *)0);
2407 }
2408}
2409
2410/* Internal helper used for updating curses.LINES, curses.COLS, _curses.LINES
2411 * and _curses.COLS */
2412#if defined(HAVE_CURSES_RESIZETERM1) || defined(HAVE_CURSES_RESIZE_TERM1)
2413static int
2414update_lines_cols(void)
2415{
2416 PyObject *o;
2417 PyObject *m = PyImport_ImportModuleNoBlock("curses");
2418
2419 if (!m)
2420 return 0;
2421
2422 o = PyLong_FromLong(LINES);
2423 if (!o) {
2424 Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt !=
0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2424
, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while
(0)
;
2425 return 0;
2426 }
2427 if (PyObject_SetAttrString(m, "LINES", o)) {
2428 Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt !=
0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2428
, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while
(0)
;
2429 Py_DECREF(o)do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt !=
0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2429
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0)
;
2430 return 0;
2431 }
2432 if (PyDict_SetItemString(ModDict, "LINES", o)) {
2433 Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt !=
0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2433
, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while
(0)
;
2434 Py_DECREF(o)do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt !=
0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2434
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0)
;
2435 return 0;
2436 }
2437 Py_DECREF(o)do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt !=
0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2437
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0)
;
2438 o = PyLong_FromLong(COLS);
2439 if (!o) {
2440 Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt !=
0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2440
, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while
(0)
;
2441 return 0;
2442 }
2443 if (PyObject_SetAttrString(m, "COLS", o)) {
2444 Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt !=
0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2444
, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while
(0)
;
2445 Py_DECREF(o)do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt !=
0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2445
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0)
;
2446 return 0;
2447 }
2448 if (PyDict_SetItemString(ModDict, "COLS", o)) {
2449 Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt !=
0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2449
, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while
(0)
;
2450 Py_DECREF(o)do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt !=
0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2450
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0)
;
2451 return 0;
2452 }
2453 Py_DECREF(o)do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt !=
0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2453
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0)
;
2454 Py_DECREF(m)do { if (_Py_RefTotal-- , --((PyObject*)(m))->ob_refcnt !=
0) { if (((PyObject*)m)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2454
, (PyObject *)(m)); } else _Py_Dealloc((PyObject *)(m)); } while
(0)
;
2455 return 1;
2456}
2457#endif
2458
2459#ifdef HAVE_CURSES_RESIZETERM1
2460static PyObject *
2461PyCurses_ResizeTerm(PyObject *self, PyObject *args)
2462{
2463 int lines;
2464 int columns;
2465 PyObject *result;
2466
2467 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2468
2469 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii:resizeterm", &lines, &columns))
2470 return NULL((void *)0);
2471
2472 result = PyCursesCheckERR(resizeterm(lines, columns), "resizeterm");
2473 if (!result)
2474 return NULL((void *)0);
2475 if (!update_lines_cols())
2476 return NULL((void *)0);
2477 return result;
2478}
2479
2480#endif
2481
2482#ifdef HAVE_CURSES_RESIZE_TERM1
2483static PyObject *
2484PyCurses_Resize_Term(PyObject *self, PyObject *args)
2485{
2486 int lines;
2487 int columns;
2488
2489 PyObject *result;
2490
2491 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2492
2493 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"ii:resize_term", &lines, &columns))
2494 return NULL((void *)0);
2495
2496 result = PyCursesCheckERR(resize_term(lines, columns), "resize_term");
2497 if (!result)
2498 return NULL((void *)0);
2499 if (!update_lines_cols())
2500 return NULL((void *)0);
2501 return result;
2502}
2503#endif /* HAVE_CURSES_RESIZE_TERM */
2504
2505static PyObject *
2506PyCurses_setsyx(PyObject *self, PyObject *args)
2507{
2508 int y,x;
2509
2510 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2511
2512 if (PyTuple_Size(args)!=2) {
2513 PyErr_SetString(PyExc_TypeError, "setsyx requires 2 arguments");
2514 return NULL((void *)0);
2515 }
2516
2517 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "ii;y, x", &y, &x)) return NULL((void *)0);
2518
2519 setsyx(y,x)do { if (newscr) { if ((y) == -1 && (x) == -1) leaveok
(newscr, 1); else { leaveok(newscr, 0); wmove(newscr, (y), (x
)); } } } while(0)
;
2520
2521 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2522 return Py_None(&_Py_NoneStruct);
2523}
2524
2525static PyObject *
2526PyCurses_Start_Color(PyObject *self)
2527{
2528 int code;
2529 PyObject *c, *cp;
2530
2531 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2532
2533 code = start_color();
2534 if (code != ERR(-1)) {
2535 initialisedcolors = TRUE1;
2536 c = PyLong_FromLong((long) COLORS);
2537 PyDict_SetItemString(ModDict, "COLORS", c);
2538 Py_DECREF(c)do { if (_Py_RefTotal-- , --((PyObject*)(c))->ob_refcnt !=
0) { if (((PyObject*)c)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2538
, (PyObject *)(c)); } else _Py_Dealloc((PyObject *)(c)); } while
(0)
;
2539 cp = PyLong_FromLong((long) COLOR_PAIRS);
2540 PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp);
2541 Py_DECREF(cp)do { if (_Py_RefTotal-- , --((PyObject*)(cp))->ob_refcnt !=
0) { if (((PyObject*)cp)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2541
, (PyObject *)(cp)); } else _Py_Dealloc((PyObject *)(cp)); } while
(0)
;
2542 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2543 return Py_None(&_Py_NoneStruct);
2544 } else {
2545 PyErr_SetString(PyCursesError, "start_color() returned ERR");
2546 return NULL((void *)0);
2547 }
2548}
2549
2550static PyObject *
2551PyCurses_tigetflag(PyObject *self, PyObject *args)
2552{
2553 char *capname;
2554
2555 PyCursesSetupTermCalledif (initialised_setupterm != 1) { PyErr_SetString(PyCursesError
, "must call (at least) setupterm() first"); return 0; }
;
2556
2557 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s", &capname))
2558 return NULL((void *)0);
2559
2560 return PyLong_FromLong( (long) tigetflag( capname ) );
2561}
2562
2563static PyObject *
2564PyCurses_tigetnum(PyObject *self, PyObject *args)
2565{
2566 char *capname;
2567
2568 PyCursesSetupTermCalledif (initialised_setupterm != 1) { PyErr_SetString(PyCursesError
, "must call (at least) setupterm() first"); return 0; }
;
2569
2570 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s", &capname))
2571 return NULL((void *)0);
2572
2573 return PyLong_FromLong( (long) tigetnum( capname ) );
2574}
2575
2576static PyObject *
2577PyCurses_tigetstr(PyObject *self, PyObject *args)
2578{
2579 char *capname;
2580
2581 PyCursesSetupTermCalledif (initialised_setupterm != 1) { PyErr_SetString(PyCursesError
, "must call (at least) setupterm() first"); return 0; }
;
2582
2583 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s", &capname))
2584 return NULL((void *)0);
2585
2586 capname = tigetstr( capname );
2587 if (capname == 0 || capname == (char*) -1) {
2588 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2589 return Py_None(&_Py_NoneStruct);
2590 }
2591 return PyBytes_FromString( capname );
2592}
2593
2594static PyObject *
2595PyCurses_tparm(PyObject *self, PyObject *args)
2596{
2597 char* fmt;
2598 char* result = NULL((void *)0);
2599 int i1=0,i2=0,i3=0,i4=0,i5=0,i6=0,i7=0,i8=0,i9=0;
2600
2601 PyCursesSetupTermCalledif (initialised_setupterm != 1) { PyErr_SetString(PyCursesError
, "must call (at least) setupterm() first"); return 0; }
;
2602
2603 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args, "s|iiiiiiiii:tparm",
2604 &fmt, &i1, &i2, &i3, &i4,
2605 &i5, &i6, &i7, &i8, &i9)) {
2606 return NULL((void *)0);
2607 }
2608
2609 result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9);
2610 if (!result) {
2611 PyErr_SetString(PyCursesError, "tparm() returned NULL");
2612 return NULL((void *)0);
2613 }
2614
2615 return PyBytes_FromString(result);
2616}
2617
2618static PyObject *
2619PyCurses_TypeAhead(PyObject *self, PyObject *args)
2620{
2621 int fd;
2622
2623 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2624
2625 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;fd",&fd)) return NULL((void *)0);
2626
2627 return PyCursesCheckERR(typeahead( fd ), "typeahead");
2628}
2629
2630static PyObject *
2631PyCurses_UnCtrl(PyObject *self, PyObject *args)
2632{
2633 PyObject *temp;
2634 chtype ch;
2635
2636 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2637
2638 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"O;ch or int",&temp)) return NULL((void *)0);
2639
2640 if (!PyCurses_ConvertToChtype(temp, &ch)) {
2641 PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
2642 return NULL((void *)0);
2643 }
2644
2645 return PyBytes_FromString(unctrl(ch));
2646}
2647
2648static PyObject *
2649PyCurses_UngetCh(PyObject *self, PyObject *args)
2650{
2651 PyObject *temp;
2652 chtype ch;
2653
2654 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2655
2656 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"O;ch or int",&temp)) return NULL((void *)0);
2657
2658 if (!PyCurses_ConvertToChtype(temp, &ch)) {
2659 PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int");
2660 return NULL((void *)0);
2661 }
2662
2663 return PyCursesCheckERR(ungetch(ch), "ungetch");
2664}
2665
2666static PyObject *
2667PyCurses_Use_Env(PyObject *self, PyObject *args)
2668{
2669 int flag;
2670
2671 switch(PyTuple_Size(args)) {
2672 case 1:
2673 if (!PyArg_ParseTuple_PyArg_ParseTuple_SizeT(args,"i;True(1), False(0)",&flag))
2674 return NULL((void *)0);
2675 break;
2676 default:
2677 PyErr_SetString(PyExc_TypeError, "use_env requires 1 argument");
2678 return NULL((void *)0);
2679 }
2680 use_env(flag);
2681 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2682 return Py_None(&_Py_NoneStruct);
2683}
2684
2685#ifndef STRICT_SYSV_CURSES
2686static PyObject *
2687PyCurses_Use_Default_Colors(PyObject *self)
2688{
2689 int code;
2690
2691 PyCursesInitialisedif (initialised != 1) { PyErr_SetString(PyCursesError, "must call initscr() first"
); return 0; }
;
2692 PyCursesInitialisedColorif (initialisedcolors != 1) { PyErr_SetString(PyCursesError, "must call start_color() first"
); return 0; }
;
2693
2694 code = use_default_colors();
2695 if (code != ERR(-1)) {
2696 Py_INCREF(Py_None)( _Py_RefTotal++ , ((PyObject*)((&_Py_NoneStruct)))->ob_refcnt
++)
;
2697 return Py_None(&_Py_NoneStruct);
2698 } else {
2699 PyErr_SetString(PyCursesError, "use_default_colors() returned ERR");
2700 return NULL((void *)0);
2701 }
2702}
2703#endif /* STRICT_SYSV_CURSES */
2704
2705/* List of functions defined in the module */
2706
2707static PyMethodDef PyCurses_methods[] = {
2708 {"baudrate", (PyCFunction)PyCurses_baudrate, METH_NOARGS0x0004},
2709 {"beep", (PyCFunction)PyCurses_beep, METH_NOARGS0x0004},
2710 {"can_change_color", (PyCFunction)PyCurses_can_change_color, METH_NOARGS0x0004},
2711 {"cbreak", (PyCFunction)PyCurses_cbreak, METH_VARARGS0x0001},
2712 {"color_content", (PyCFunction)PyCurses_Color_Content, METH_VARARGS0x0001},
2713 {"color_pair", (PyCFunction)PyCurses_color_pair, METH_VARARGS0x0001},
2714 {"curs_set", (PyCFunction)PyCurses_Curs_Set, METH_VARARGS0x0001},
2715 {"def_prog_mode", (PyCFunction)PyCurses_def_prog_mode, METH_NOARGS0x0004},
2716 {"def_shell_mode", (PyCFunction)PyCurses_def_shell_mode, METH_NOARGS0x0004},
2717 {"delay_output", (PyCFunction)PyCurses_Delay_Output, METH_VARARGS0x0001},
2718 {"doupdate", (PyCFunction)PyCurses_doupdate, METH_NOARGS0x0004},
2719 {"echo", (PyCFunction)PyCurses_echo, METH_VARARGS0x0001},
2720 {"endwin", (PyCFunction)PyCurses_endwin, METH_NOARGS0x0004},
2721 {"erasechar", (PyCFunction)PyCurses_EraseChar, METH_NOARGS0x0004},
2722 {"filter", (PyCFunction)PyCurses_filter, METH_NOARGS0x0004},
2723 {"flash", (PyCFunction)PyCurses_flash, METH_NOARGS0x0004},
2724 {"flushinp", (PyCFunction)PyCurses_flushinp, METH_NOARGS0x0004},
2725#ifdef NCURSES_MOUSE_VERSION1
2726 {"getmouse", (PyCFunction)PyCurses_GetMouse, METH_NOARGS0x0004},
2727 {"ungetmouse", (PyCFunction)PyCurses_UngetMouse, METH_VARARGS0x0001},
2728#endif
2729 {"getsyx", (PyCFunction)PyCurses_getsyx, METH_NOARGS0x0004},
2730 {"getwin", (PyCFunction)PyCurses_GetWin, METH_O0x0008},
2731 {"has_colors", (PyCFunction)PyCurses_has_colors, METH_NOARGS0x0004},
2732 {"has_ic", (PyCFunction)PyCurses_has_ic, METH_NOARGS0x0004},
2733 {"has_il", (PyCFunction)PyCurses_has_il, METH_NOARGS0x0004},
2734#ifndef STRICT_SYSV_CURSES
2735 {"has_key", (PyCFunction)PyCurses_has_key, METH_VARARGS0x0001},
2736#endif
2737 {"halfdelay", (PyCFunction)PyCurses_HalfDelay, METH_VARARGS0x0001},
2738 {"init_color", (PyCFunction)PyCurses_Init_Color, METH_VARARGS0x0001},
2739 {"init_pair", (PyCFunction)PyCurses_Init_Pair, METH_VARARGS0x0001},
2740 {"initscr", (PyCFunction)PyCurses_InitScr, METH_NOARGS0x0004},
2741 {"intrflush", (PyCFunction)PyCurses_IntrFlush, METH_VARARGS0x0001},
2742 {"isendwin", (PyCFunction)PyCurses_isendwin, METH_NOARGS0x0004},
2743#ifdef HAVE_CURSES_IS_TERM_RESIZED1
2744 {"is_term_resized", (PyCFunction)PyCurses_Is_Term_Resized, METH_VARARGS0x0001},
2745#endif
2746#if !defined(__NetBSD__)
2747 {"keyname", (PyCFunction)PyCurses_KeyName, METH_VARARGS0x0001},
2748#endif
2749 {"killchar", (PyCFunction)PyCurses_KillChar, METH_NOARGS0x0004},
2750 {"longname", (PyCFunction)PyCurses_longname, METH_NOARGS0x0004},
2751 {"meta", (PyCFunction)PyCurses_Meta, METH_VARARGS0x0001},
2752#ifdef NCURSES_MOUSE_VERSION1
2753 {"mouseinterval", (PyCFunction)PyCurses_MouseInterval, METH_VARARGS0x0001},
2754 {"mousemask", (PyCFunction)PyCurses_MouseMask, METH_VARARGS0x0001},
2755#endif
2756 {"napms", (PyCFunction)PyCurses_Napms, METH_VARARGS0x0001},
2757 {"newpad", (PyCFunction)PyCurses_NewPad, METH_VARARGS0x0001},
2758 {"newwin", (PyCFunction)PyCurses_NewWindow, METH_VARARGS0x0001},
2759 {"nl", (PyCFunction)PyCurses_nl, METH_VARARGS0x0001},
2760 {"nocbreak", (PyCFunction)PyCurses_nocbreak, METH_NOARGS0x0004},
2761 {"noecho", (PyCFunction)PyCurses_noecho, METH_NOARGS0x0004},
2762 {"nonl", (PyCFunction)PyCurses_nonl, METH_NOARGS0x0004},
2763 {"noqiflush", (PyCFunction)PyCurses_noqiflush, METH_NOARGS0x0004},
2764 {"noraw", (PyCFunction)PyCurses_noraw, METH_NOARGS0x0004},
2765 {"pair_content", (PyCFunction)PyCurses_Pair_Content, METH_VARARGS0x0001},
2766 {"pair_number", (PyCFunction)PyCurses_pair_number, METH_VARARGS0x0001},
2767 {"putp", (PyCFunction)PyCurses_Putp, METH_VARARGS0x0001},
2768 {"qiflush", (PyCFunction)PyCurses_QiFlush, METH_VARARGS0x0001},
2769 {"raw", (PyCFunction)PyCurses_raw, METH_VARARGS0x0001},
2770 {"reset_prog_mode", (PyCFunction)PyCurses_reset_prog_mode, METH_NOARGS0x0004},
2771 {"reset_shell_mode", (PyCFunction)PyCurses_reset_shell_mode, METH_NOARGS0x0004},
2772 {"resetty", (PyCFunction)PyCurses_resetty, METH_NOARGS0x0004},
2773#ifdef HAVE_CURSES_RESIZETERM1
2774 {"resizeterm", (PyCFunction)PyCurses_ResizeTerm, METH_VARARGS0x0001},
2775#endif
2776#ifdef HAVE_CURSES_RESIZE_TERM1
2777 {"resize_term", (PyCFunction)PyCurses_Resize_Term, METH_VARARGS0x0001},
2778#endif
2779 {"savetty", (PyCFunction)PyCurses_savetty, METH_NOARGS0x0004},
2780 {"setsyx", (PyCFunction)PyCurses_setsyx, METH_VARARGS0x0001},
2781 {"setupterm", (PyCFunction)PyCurses_setupterm,
2782 METH_VARARGS0x0001|METH_KEYWORDS0x0002},
2783 {"start_color", (PyCFunction)PyCurses_Start_Color, METH_NOARGS0x0004},
2784 {"termattrs", (PyCFunction)PyCurses_termattrs, METH_NOARGS0x0004},
2785 {"termname", (PyCFunction)PyCurses_termname, METH_NOARGS0x0004},
2786 {"tigetflag", (PyCFunction)PyCurses_tigetflag, METH_VARARGS0x0001},
2787 {"tigetnum", (PyCFunction)PyCurses_tigetnum, METH_VARARGS0x0001},
2788 {"tigetstr", (PyCFunction)PyCurses_tigetstr, METH_VARARGS0x0001},
2789 {"tparm", (PyCFunction)PyCurses_tparm, METH_VARARGS0x0001},
2790 {"typeahead", (PyCFunction)PyCurses_TypeAhead, METH_VARARGS0x0001},
2791 {"unctrl", (PyCFunction)PyCurses_UnCtrl, METH_VARARGS0x0001},
2792 {"ungetch", (PyCFunction)PyCurses_UngetCh, METH_VARARGS0x0001},
2793 {"use_env", (PyCFunction)PyCurses_Use_Env, METH_VARARGS0x0001},
2794#ifndef STRICT_SYSV_CURSES
2795 {"use_default_colors", (PyCFunction)PyCurses_Use_Default_Colors, METH_NOARGS0x0004},
2796#endif
2797 {NULL((void *)0), NULL((void *)0)} /* sentinel */
2798};
2799
2800/* Initialization function for the module */
2801
2802
2803static struct PyModuleDef _cursesmodule = {
2804 PyModuleDef_HEAD_INIT{ { 0, 0, 1, ((void *)0) }, ((void *)0), 0, ((void *)0), },
2805 "_curses",
2806 NULL((void *)0),
2807 -1,
2808 PyCurses_methods,
2809 NULL((void *)0),
2810 NULL((void *)0),
2811 NULL((void *)0),
2812 NULL((void *)0)
2813};
2814
2815PyMODINIT_FUNCPyObject*
2816PyInit__curses(void)
2817{
2818 PyObject *m, *d, *v, *c_api_object;
2819 static void *PyCurses_API[PyCurses_API_pointers4];
2820
2821 /* Initialize object type */
2822 if (PyType_Ready(&PyCursesWindow_Type) < 0)
2823 return NULL((void *)0);
2824
2825 /* Initialize the C API pointer array */
2826 PyCurses_API[0] = (void *)&PyCursesWindow_Type;
2827 PyCurses_API[1] = (void *)func_PyCursesSetupTermCalled;
2828 PyCurses_API[2] = (void *)func_PyCursesInitialised;
2829 PyCurses_API[3] = (void *)func_PyCursesInitialisedColor;
2830
2831 /* Create the module and add the functions */
2832 m = PyModule_Create(&_cursesmodule)PyModule_Create2TraceRefs(&_cursesmodule, 1013);
2833 if (m == NULL((void *)0))
2834 return NULL((void *)0);
2835
2836 /* Add some symbolic constants to the module */
2837 d = PyModule_GetDict(m);
2838 if (d == NULL((void *)0))
2839 return NULL((void *)0);
2840 ModDict = d; /* For PyCurses_InitScr to use later */
2841
2842 /* Add a capsule for the C API */
2843 c_api_object = PyCapsule_New(PyCurses_API, PyCurses_CAPSULE_NAME"_curses._C_API", NULL((void *)0));
2844 PyDict_SetItemString(d, "_C_API", c_api_object);
2845 Py_DECREF(c_api_object)do { if (_Py_RefTotal-- , --((PyObject*)(c_api_object))->ob_refcnt
!= 0) { if (((PyObject*)c_api_object)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2845
, (PyObject *)(c_api_object)); } else _Py_Dealloc((PyObject *
)(c_api_object)); } while (0)
;
2846
2847 /* For exception curses.error */
2848 PyCursesError = PyErr_NewException("_curses.error", NULL((void *)0), NULL((void *)0));
2849 PyDict_SetItemString(d, "error", PyCursesError);
2850
2851 /* Make the version available */
2852 v = PyBytes_FromString(PyCursesVersion);
2853 PyDict_SetItemString(d, "version", v);
2854 PyDict_SetItemString(d, "__version__", v);
2855 Py_DECREF(v)do { if (_Py_RefTotal-- , --((PyObject*)(v))->ob_refcnt !=
0) { if (((PyObject*)v)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2855
, (PyObject *)(v)); } else _Py_Dealloc((PyObject *)(v)); } while
(0)
;
2856
2857 SetDictInt("ERR", ERR)do { PyObject *o = PyLong_FromLong((long) ((-1))); if (o &&
PyDict_SetItemString(ModDict, "ERR", o) == 0) { do { if (_Py_RefTotal
-- , --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*
)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2857, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2858 SetDictInt("OK", OK)do { PyObject *o = PyLong_FromLong((long) ((0))); if (o &&
PyDict_SetItemString(ModDict, "OK", o) == 0) { do { if (_Py_RefTotal
-- , --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*
)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2858, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2859
2860 /* Here are some attributes you can add to chars to print */
2861
2862 SetDictInt("A_ATTRIBUTES", A_ATTRIBUTES)do { PyObject *o = PyLong_FromLong((long) (((~(1U - 1U)) <<
((0) + 8)))); if (o && PyDict_SetItemString(ModDict,
"A_ATTRIBUTES", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2862, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2863 SetDictInt("A_NORMAL", A_NORMAL)do { PyObject *o = PyLong_FromLong((long) ((1U - 1U))); if (o
&& PyDict_SetItemString(ModDict, "A_NORMAL", o) == 0
) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt
!= 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2863
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2864 SetDictInt("A_STANDOUT", A_STANDOUT)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((8
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_STANDOUT"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2864
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2865 SetDictInt("A_UNDERLINE", A_UNDERLINE)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((9
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_UNDERLINE"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2865
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2866 SetDictInt("A_REVERSE", A_REVERSE)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((10
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_REVERSE"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2866
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2867 SetDictInt("A_BLINK", A_BLINK)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((11
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_BLINK"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2867
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2868 SetDictInt("A_DIM", A_DIM)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((12
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_DIM"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2868
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2869 SetDictInt("A_BOLD", A_BOLD)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((13
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_BOLD"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2869
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2870 SetDictInt("A_ALTCHARSET", A_ALTCHARSET)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((14
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_ALTCHARSET"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2870
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2871#if !defined(__NetBSD__)
2872 SetDictInt("A_INVIS", A_INVIS)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((15
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_INVIS"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2872
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2873#endif
2874 SetDictInt("A_PROTECT", A_PROTECT)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((16
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_PROTECT"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2874
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2875 SetDictInt("A_CHARTEXT", A_CHARTEXT)do { PyObject *o = PyLong_FromLong((long) ((((1U) << ((
0) + 8)) - 1U))); if (o && PyDict_SetItemString(ModDict
, "A_CHARTEXT", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2875, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2876 SetDictInt("A_COLOR", A_COLOR)do { PyObject *o = PyLong_FromLong((long) (((((1U) << 8
) - 1U) << ((0) + 8)))); if (o && PyDict_SetItemString
(ModDict, "A_COLOR", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2876, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2877
2878 /* The following are never available with strict SYSV curses */
2879#ifdef A_HORIZONTAL((1U) << ((17) + 8))
2880 SetDictInt("A_HORIZONTAL", A_HORIZONTAL)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((17
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_HORIZONTAL"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2880
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2881#endif
2882#ifdef A_LEFT((1U) << ((18) + 8))
2883 SetDictInt("A_LEFT", A_LEFT)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((18
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_LEFT"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2883
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2884#endif
2885#ifdef A_LOW((1U) << ((19) + 8))
2886 SetDictInt("A_LOW", A_LOW)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((19
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_LOW"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2886
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2887#endif
2888#ifdef A_RIGHT((1U) << ((20) + 8))
2889 SetDictInt("A_RIGHT", A_RIGHT)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((20
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_RIGHT"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2889
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2890#endif
2891#ifdef A_TOP((1U) << ((21) + 8))
2892 SetDictInt("A_TOP", A_TOP)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((21
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_TOP"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2892
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2893#endif
2894#ifdef A_VERTICAL((1U) << ((22) + 8))
2895 SetDictInt("A_VERTICAL", A_VERTICAL)do { PyObject *o = PyLong_FromLong((long) (((1U) << ((22
) + 8)))); if (o && PyDict_SetItemString(ModDict, "A_VERTICAL"
, o) == 0) { do { if (_Py_RefTotal-- , --((PyObject*)(o))->
ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2895
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2896#endif
2897
2898 SetDictInt("COLOR_BLACK", COLOR_BLACK)do { PyObject *o = PyLong_FromLong((long) (0)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_BLACK", o) == 0) { do {
if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) {
if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2898
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2899 SetDictInt("COLOR_RED", COLOR_RED)do { PyObject *o = PyLong_FromLong((long) (1)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_RED", o) == 0) { do { if
(_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) { if
(((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2899, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2900 SetDictInt("COLOR_GREEN", COLOR_GREEN)do { PyObject *o = PyLong_FromLong((long) (2)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_GREEN", o) == 0) { do {
if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) {
if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2900
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2901 SetDictInt("COLOR_YELLOW", COLOR_YELLOW)do { PyObject *o = PyLong_FromLong((long) (3)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_YELLOW", o) == 0) { do {
if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) {
if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2901
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2902 SetDictInt("COLOR_BLUE", COLOR_BLUE)do { PyObject *o = PyLong_FromLong((long) (4)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_BLUE", o) == 0) { do { if
(_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) { if
(((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2902, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2903 SetDictInt("COLOR_MAGENTA", COLOR_MAGENTA)do { PyObject *o = PyLong_FromLong((long) (5)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_MAGENTA", o) == 0) { do
{ if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0
) { if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2903
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2904 SetDictInt("COLOR_CYAN", COLOR_CYAN)do { PyObject *o = PyLong_FromLong((long) (6)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_CYAN", o) == 0) { do { if
(_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) { if
(((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2904, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2905 SetDictInt("COLOR_WHITE", COLOR_WHITE)do { PyObject *o = PyLong_FromLong((long) (7)); if (o &&
PyDict_SetItemString(ModDict, "COLOR_WHITE", o) == 0) { do {
if (_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) {
if (((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount
("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c", 2905
, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o)); } while
(0); } } while (0)
;
2906
2907#ifdef NCURSES_MOUSE_VERSION1
2908 /* Mouse-related constants */
2909 SetDictInt("BUTTON1_PRESSED", BUTTON1_PRESSED)do { PyObject *o = PyLong_FromLong((long) (((002L) << (
((1) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON1_PRESSED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2909, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2910 SetDictInt("BUTTON1_RELEASED", BUTTON1_RELEASED)do { PyObject *o = PyLong_FromLong((long) (((001L) << (
((1) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON1_RELEASED", o) == 0) { do { if (_Py_RefTotal-- , --
((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2910, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2911 SetDictInt("BUTTON1_CLICKED", BUTTON1_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((004L) << (
((1) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON1_CLICKED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2911, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2912 SetDictInt("BUTTON1_DOUBLE_CLICKED", BUTTON1_DOUBLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((010L) << (
((1) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON1_DOUBLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2912, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2913 SetDictInt("BUTTON1_TRIPLE_CLICKED", BUTTON1_TRIPLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((020L) << (
((1) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON1_TRIPLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2913, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2914
2915 SetDictInt("BUTTON2_PRESSED", BUTTON2_PRESSED)do { PyObject *o = PyLong_FromLong((long) (((002L) << (
((2) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON2_PRESSED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2915, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2916 SetDictInt("BUTTON2_RELEASED", BUTTON2_RELEASED)do { PyObject *o = PyLong_FromLong((long) (((001L) << (
((2) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON2_RELEASED", o) == 0) { do { if (_Py_RefTotal-- , --
((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2916, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2917 SetDictInt("BUTTON2_CLICKED", BUTTON2_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((004L) << (
((2) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON2_CLICKED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2917, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2918 SetDictInt("BUTTON2_DOUBLE_CLICKED", BUTTON2_DOUBLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((010L) << (
((2) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON2_DOUBLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2918, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2919 SetDictInt("BUTTON2_TRIPLE_CLICKED", BUTTON2_TRIPLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((020L) << (
((2) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON2_TRIPLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2919, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2920
2921 SetDictInt("BUTTON3_PRESSED", BUTTON3_PRESSED)do { PyObject *o = PyLong_FromLong((long) (((002L) << (
((3) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON3_PRESSED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2921, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2922 SetDictInt("BUTTON3_RELEASED", BUTTON3_RELEASED)do { PyObject *o = PyLong_FromLong((long) (((001L) << (
((3) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON3_RELEASED", o) == 0) { do { if (_Py_RefTotal-- , --
((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2922, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2923 SetDictInt("BUTTON3_CLICKED", BUTTON3_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((004L) << (
((3) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON3_CLICKED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2923, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2924 SetDictInt("BUTTON3_DOUBLE_CLICKED", BUTTON3_DOUBLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((010L) << (
((3) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON3_DOUBLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2924, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2925 SetDictInt("BUTTON3_TRIPLE_CLICKED", BUTTON3_TRIPLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((020L) << (
((3) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON3_TRIPLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2925, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2926
2927 SetDictInt("BUTTON4_PRESSED", BUTTON4_PRESSED)do { PyObject *o = PyLong_FromLong((long) (((002L) << (
((4) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON4_PRESSED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2927, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2928 SetDictInt("BUTTON4_RELEASED", BUTTON4_RELEASED)do { PyObject *o = PyLong_FromLong((long) (((001L) << (
((4) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON4_RELEASED", o) == 0) { do { if (_Py_RefTotal-- , --
((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2928, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2929 SetDictInt("BUTTON4_CLICKED", BUTTON4_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((004L) << (
((4) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON4_CLICKED", o) == 0) { do { if (_Py_RefTotal-- , --(
(PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->
ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2929, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2930 SetDictInt("BUTTON4_DOUBLE_CLICKED", BUTTON4_DOUBLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((010L) << (
((4) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON4_DOUBLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2930, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2931 SetDictInt("BUTTON4_TRIPLE_CLICKED", BUTTON4_TRIPLE_CLICKED)do { PyObject *o = PyLong_FromLong((long) (((020L) << (
((4) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON4_TRIPLE_CLICKED", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2931, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2932
2933 SetDictInt("BUTTON_SHIFT", BUTTON_SHIFT)do { PyObject *o = PyLong_FromLong((long) (((0002L) << (
((5) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON_SHIFT", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2933, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2934 SetDictInt("BUTTON_CTRL", BUTTON_CTRL)do { PyObject *o = PyLong_FromLong((long) (((0001L) << (
((5) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON_CTRL", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2934, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2935 SetDictInt("BUTTON_ALT", BUTTON_ALT)do { PyObject *o = PyLong_FromLong((long) (((0004L) << (
((5) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "BUTTON_ALT", o) == 0) { do { if (_Py_RefTotal-- , --((PyObject
*)(o))->ob_refcnt != 0) { if (((PyObject*)o)->ob_refcnt
< 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2935, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2936
2937 SetDictInt("ALL_MOUSE_EVENTS", ALL_MOUSE_EVENTS)do { PyObject *o = PyLong_FromLong((long) ((((0010L) <<
(((5) - 1) * 6)) - 1))); if (o && PyDict_SetItemString
(ModDict, "ALL_MOUSE_EVENTS", o) == 0) { do { if (_Py_RefTotal
-- , --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*
)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2937, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2938 SetDictInt("REPORT_MOUSE_POSITION", REPORT_MOUSE_POSITION)do { PyObject *o = PyLong_FromLong((long) (((0010L) << (
((5) - 1) * 6)))); if (o && PyDict_SetItemString(ModDict
, "REPORT_MOUSE_POSITION", o) == 0) { do { if (_Py_RefTotal--
, --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*)o
)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2938, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2939#endif
2940 /* Now set everything up for KEY_ variables */
2941 {
2942 int key;
2943 char *key_n;
2944 char *key_n2;
2945#if !defined(__NetBSD__)
2946 for (key=KEY_MIN0401;key < KEY_MAX0777; key++) {
2947 key_n = (char *)keyname(key);
2948 if (key_n == NULL((void *)0) || strcmp(key_n,"UNKNOWN KEY")==0)
2949 continue;
2950 if (strncmp(key_n,"KEY_F(",6)==0) {
2951 char *p1, *p2;
2952 key_n2 = malloc(strlen(key_n)+1);
2953 if (!key_n2) {
2954 PyErr_NoMemory();
2955 break;
2956 }
2957 p1 = key_n;
2958 p2 = key_n2;
2959 while (*p1) {
2960 if (*p1 != '(' && *p1 != ')') {
2961 *p2 = *p1;
2962 p2++;
2963 }
2964 p1++;
2965 }
2966 *p2 = (char)0;
2967 } else
2968 key_n2 = key_n;
2969 SetDictInt(key_n2,key)do { PyObject *o = PyLong_FromLong((long) (key)); if (o &&
PyDict_SetItemString(ModDict, key_n2, o) == 0) { do { if (_Py_RefTotal
-- , --((PyObject*)(o))->ob_refcnt != 0) { if (((PyObject*
)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2969, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2970 if (key_n2 != key_n)
2971 free(key_n2);
2972 }
2973#endif
2974 SetDictInt("KEY_MIN", KEY_MIN)do { PyObject *o = PyLong_FromLong((long) (0401)); if (o &&
PyDict_SetItemString(ModDict, "KEY_MIN", o) == 0) { do { if (
_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) { if (
((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2974, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2975 SetDictInt("KEY_MAX", KEY_MAX)do { PyObject *o = PyLong_FromLong((long) (0777)); if (o &&
PyDict_SetItemString(ModDict, "KEY_MAX", o) == 0) { do { if (
_Py_RefTotal-- , --((PyObject*)(o))->ob_refcnt != 0) { if (
((PyObject*)o)->ob_refcnt < 0) _Py_NegativeRefcount("/Users/brett/Dev/python/3.x/py3k/Modules/_cursesmodule.c"
, 2975, (PyObject *)(o)); } else _Py_Dealloc((PyObject *)(o))
; } while (0); } } while (0)
;
2976 }
2977 return m;
2978}