Branch data Line data Source code
1 : : /*[clinic input]
2 : : preserve
3 : : [clinic start generated code]*/
4 : :
5 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 : : # include "pycore_gc.h" // PyGC_Head
7 : : # include "pycore_runtime.h" // _Py_ID()
8 : : #endif
9 : :
10 : :
11 : : PyDoc_STRVAR(_curses_window_addch__doc__,
12 : : "addch([y, x,] ch, [attr=_curses.A_NORMAL])\n"
13 : : "Paint the character.\n"
14 : : "\n"
15 : : " y\n"
16 : : " Y-coordinate.\n"
17 : : " x\n"
18 : : " X-coordinate.\n"
19 : : " ch\n"
20 : : " Character to add.\n"
21 : : " attr\n"
22 : : " Attributes for the character.\n"
23 : : "\n"
24 : : "Paint character ch at (y, x) with attributes attr,\n"
25 : : "overwriting any character previously painted at that location.\n"
26 : : "By default, the character position and attributes are the\n"
27 : : "current settings for the window object.");
28 : :
29 : : #define _CURSES_WINDOW_ADDCH_METHODDEF \
30 : : {"addch", (PyCFunction)_curses_window_addch, METH_VARARGS, _curses_window_addch__doc__},
31 : :
32 : : static PyObject *
33 : : _curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1,
34 : : int y, int x, PyObject *ch, int group_right_1,
35 : : long attr);
36 : :
37 : : static PyObject *
38 : 0 : _curses_window_addch(PyCursesWindowObject *self, PyObject *args)
39 : : {
40 : 0 : PyObject *return_value = NULL;
41 : 0 : int group_left_1 = 0;
42 : 0 : int y = 0;
43 : 0 : int x = 0;
44 : : PyObject *ch;
45 : 0 : int group_right_1 = 0;
46 : 0 : long attr = A_NORMAL;
47 : :
48 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
49 : 0 : case 1:
50 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O:addch", &ch)) {
51 : 0 : goto exit;
52 : : }
53 : 0 : break;
54 : 0 : case 2:
55 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) {
56 : 0 : goto exit;
57 : : }
58 : 0 : group_right_1 = 1;
59 : 0 : break;
60 : 0 : case 3:
61 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) {
62 : 0 : goto exit;
63 : : }
64 : 0 : group_left_1 = 1;
65 : 0 : break;
66 : 0 : case 4:
67 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) {
68 : 0 : goto exit;
69 : : }
70 : 0 : group_right_1 = 1;
71 : 0 : group_left_1 = 1;
72 : 0 : break;
73 : 0 : default:
74 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 1 to 4 arguments");
75 : 0 : goto exit;
76 : : }
77 : 0 : return_value = _curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr);
78 : :
79 : 0 : exit:
80 : 0 : return return_value;
81 : : }
82 : :
83 : : PyDoc_STRVAR(_curses_window_addstr__doc__,
84 : : "addstr([y, x,] str, [attr])\n"
85 : : "Paint the string.\n"
86 : : "\n"
87 : : " y\n"
88 : : " Y-coordinate.\n"
89 : : " x\n"
90 : : " X-coordinate.\n"
91 : : " str\n"
92 : : " String to add.\n"
93 : : " attr\n"
94 : : " Attributes for characters.\n"
95 : : "\n"
96 : : "Paint the string str at (y, x) with attributes attr,\n"
97 : : "overwriting anything previously on the display.\n"
98 : : "By default, the character position and attributes are the\n"
99 : : "current settings for the window object.");
100 : :
101 : : #define _CURSES_WINDOW_ADDSTR_METHODDEF \
102 : : {"addstr", (PyCFunction)_curses_window_addstr, METH_VARARGS, _curses_window_addstr__doc__},
103 : :
104 : : static PyObject *
105 : : _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
106 : : int y, int x, PyObject *str, int group_right_1,
107 : : long attr);
108 : :
109 : : static PyObject *
110 : 0 : _curses_window_addstr(PyCursesWindowObject *self, PyObject *args)
111 : : {
112 : 0 : PyObject *return_value = NULL;
113 : 0 : int group_left_1 = 0;
114 : 0 : int y = 0;
115 : 0 : int x = 0;
116 : : PyObject *str;
117 : 0 : int group_right_1 = 0;
118 : 0 : long attr = 0;
119 : :
120 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
121 : 0 : case 1:
122 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O:addstr", &str)) {
123 : 0 : goto exit;
124 : : }
125 : 0 : break;
126 : 0 : case 2:
127 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Ol:addstr", &str, &attr)) {
128 : 0 : goto exit;
129 : : }
130 : 0 : group_right_1 = 1;
131 : 0 : break;
132 : 0 : case 3:
133 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiO:addstr", &y, &x, &str)) {
134 : 0 : goto exit;
135 : : }
136 : 0 : group_left_1 = 1;
137 : 0 : break;
138 : 0 : case 4:
139 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOl:addstr", &y, &x, &str, &attr)) {
140 : 0 : goto exit;
141 : : }
142 : 0 : group_right_1 = 1;
143 : 0 : group_left_1 = 1;
144 : 0 : break;
145 : 0 : default:
146 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments");
147 : 0 : goto exit;
148 : : }
149 : 0 : return_value = _curses_window_addstr_impl(self, group_left_1, y, x, str, group_right_1, attr);
150 : :
151 : 0 : exit:
152 : 0 : return return_value;
153 : : }
154 : :
155 : : PyDoc_STRVAR(_curses_window_addnstr__doc__,
156 : : "addnstr([y, x,] str, n, [attr])\n"
157 : : "Paint at most n characters of the string.\n"
158 : : "\n"
159 : : " y\n"
160 : : " Y-coordinate.\n"
161 : : " x\n"
162 : : " X-coordinate.\n"
163 : : " str\n"
164 : : " String to add.\n"
165 : : " n\n"
166 : : " Maximal number of characters.\n"
167 : : " attr\n"
168 : : " Attributes for characters.\n"
169 : : "\n"
170 : : "Paint at most n characters of the string str at (y, x) with\n"
171 : : "attributes attr, overwriting anything previously on the display.\n"
172 : : "By default, the character position and attributes are the\n"
173 : : "current settings for the window object.");
174 : :
175 : : #define _CURSES_WINDOW_ADDNSTR_METHODDEF \
176 : : {"addnstr", (PyCFunction)_curses_window_addnstr, METH_VARARGS, _curses_window_addnstr__doc__},
177 : :
178 : : static PyObject *
179 : : _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
180 : : int y, int x, PyObject *str, int n,
181 : : int group_right_1, long attr);
182 : :
183 : : static PyObject *
184 : 0 : _curses_window_addnstr(PyCursesWindowObject *self, PyObject *args)
185 : : {
186 : 0 : PyObject *return_value = NULL;
187 : 0 : int group_left_1 = 0;
188 : 0 : int y = 0;
189 : 0 : int x = 0;
190 : : PyObject *str;
191 : : int n;
192 : 0 : int group_right_1 = 0;
193 : 0 : long attr = 0;
194 : :
195 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
196 : 0 : case 2:
197 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oi:addnstr", &str, &n)) {
198 : 0 : goto exit;
199 : : }
200 : 0 : break;
201 : 0 : case 3:
202 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oil:addnstr", &str, &n, &attr)) {
203 : 0 : goto exit;
204 : : }
205 : 0 : group_right_1 = 1;
206 : 0 : break;
207 : 0 : case 4:
208 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOi:addnstr", &y, &x, &str, &n)) {
209 : 0 : goto exit;
210 : : }
211 : 0 : group_left_1 = 1;
212 : 0 : break;
213 : 0 : case 5:
214 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOil:addnstr", &y, &x, &str, &n, &attr)) {
215 : 0 : goto exit;
216 : : }
217 : 0 : group_right_1 = 1;
218 : 0 : group_left_1 = 1;
219 : 0 : break;
220 : 0 : default:
221 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments");
222 : 0 : goto exit;
223 : : }
224 : 0 : return_value = _curses_window_addnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr);
225 : :
226 : 0 : exit:
227 : 0 : return return_value;
228 : : }
229 : :
230 : : PyDoc_STRVAR(_curses_window_bkgd__doc__,
231 : : "bkgd($self, ch, attr=_curses.A_NORMAL, /)\n"
232 : : "--\n"
233 : : "\n"
234 : : "Set the background property of the window.\n"
235 : : "\n"
236 : : " ch\n"
237 : : " Background character.\n"
238 : : " attr\n"
239 : : " Background attributes.");
240 : :
241 : : #define _CURSES_WINDOW_BKGD_METHODDEF \
242 : : {"bkgd", _PyCFunction_CAST(_curses_window_bkgd), METH_FASTCALL, _curses_window_bkgd__doc__},
243 : :
244 : : static PyObject *
245 : : _curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, long attr);
246 : :
247 : : static PyObject *
248 : 0 : _curses_window_bkgd(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs)
249 : : {
250 : 0 : PyObject *return_value = NULL;
251 : : PyObject *ch;
252 : 0 : long attr = A_NORMAL;
253 : :
254 [ # # # # : 0 : if (!_PyArg_CheckPositional("bkgd", nargs, 1, 2)) {
# # ]
255 : 0 : goto exit;
256 : : }
257 : 0 : ch = args[0];
258 [ # # ]: 0 : if (nargs < 2) {
259 : 0 : goto skip_optional;
260 : : }
261 : 0 : attr = PyLong_AsLong(args[1]);
262 [ # # # # ]: 0 : if (attr == -1 && PyErr_Occurred()) {
263 : 0 : goto exit;
264 : : }
265 : 0 : skip_optional:
266 : 0 : return_value = _curses_window_bkgd_impl(self, ch, attr);
267 : :
268 : 0 : exit:
269 : 0 : return return_value;
270 : : }
271 : :
272 : : PyDoc_STRVAR(_curses_window_attroff__doc__,
273 : : "attroff($self, attr, /)\n"
274 : : "--\n"
275 : : "\n"
276 : : "Remove attribute attr from the \"background\" set.");
277 : :
278 : : #define _CURSES_WINDOW_ATTROFF_METHODDEF \
279 : : {"attroff", (PyCFunction)_curses_window_attroff, METH_O, _curses_window_attroff__doc__},
280 : :
281 : : static PyObject *
282 : : _curses_window_attroff_impl(PyCursesWindowObject *self, long attr);
283 : :
284 : : static PyObject *
285 : 0 : _curses_window_attroff(PyCursesWindowObject *self, PyObject *arg)
286 : : {
287 : 0 : PyObject *return_value = NULL;
288 : : long attr;
289 : :
290 : 0 : attr = PyLong_AsLong(arg);
291 [ # # # # ]: 0 : if (attr == -1 && PyErr_Occurred()) {
292 : 0 : goto exit;
293 : : }
294 : 0 : return_value = _curses_window_attroff_impl(self, attr);
295 : :
296 : 0 : exit:
297 : 0 : return return_value;
298 : : }
299 : :
300 : : PyDoc_STRVAR(_curses_window_attron__doc__,
301 : : "attron($self, attr, /)\n"
302 : : "--\n"
303 : : "\n"
304 : : "Add attribute attr from the \"background\" set.");
305 : :
306 : : #define _CURSES_WINDOW_ATTRON_METHODDEF \
307 : : {"attron", (PyCFunction)_curses_window_attron, METH_O, _curses_window_attron__doc__},
308 : :
309 : : static PyObject *
310 : : _curses_window_attron_impl(PyCursesWindowObject *self, long attr);
311 : :
312 : : static PyObject *
313 : 0 : _curses_window_attron(PyCursesWindowObject *self, PyObject *arg)
314 : : {
315 : 0 : PyObject *return_value = NULL;
316 : : long attr;
317 : :
318 : 0 : attr = PyLong_AsLong(arg);
319 [ # # # # ]: 0 : if (attr == -1 && PyErr_Occurred()) {
320 : 0 : goto exit;
321 : : }
322 : 0 : return_value = _curses_window_attron_impl(self, attr);
323 : :
324 : 0 : exit:
325 : 0 : return return_value;
326 : : }
327 : :
328 : : PyDoc_STRVAR(_curses_window_attrset__doc__,
329 : : "attrset($self, attr, /)\n"
330 : : "--\n"
331 : : "\n"
332 : : "Set the \"background\" set of attributes.");
333 : :
334 : : #define _CURSES_WINDOW_ATTRSET_METHODDEF \
335 : : {"attrset", (PyCFunction)_curses_window_attrset, METH_O, _curses_window_attrset__doc__},
336 : :
337 : : static PyObject *
338 : : _curses_window_attrset_impl(PyCursesWindowObject *self, long attr);
339 : :
340 : : static PyObject *
341 : 0 : _curses_window_attrset(PyCursesWindowObject *self, PyObject *arg)
342 : : {
343 : 0 : PyObject *return_value = NULL;
344 : : long attr;
345 : :
346 : 0 : attr = PyLong_AsLong(arg);
347 [ # # # # ]: 0 : if (attr == -1 && PyErr_Occurred()) {
348 : 0 : goto exit;
349 : : }
350 : 0 : return_value = _curses_window_attrset_impl(self, attr);
351 : :
352 : 0 : exit:
353 : 0 : return return_value;
354 : : }
355 : :
356 : : PyDoc_STRVAR(_curses_window_bkgdset__doc__,
357 : : "bkgdset($self, ch, attr=_curses.A_NORMAL, /)\n"
358 : : "--\n"
359 : : "\n"
360 : : "Set the window\'s background.\n"
361 : : "\n"
362 : : " ch\n"
363 : : " Background character.\n"
364 : : " attr\n"
365 : : " Background attributes.");
366 : :
367 : : #define _CURSES_WINDOW_BKGDSET_METHODDEF \
368 : : {"bkgdset", _PyCFunction_CAST(_curses_window_bkgdset), METH_FASTCALL, _curses_window_bkgdset__doc__},
369 : :
370 : : static PyObject *
371 : : _curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch,
372 : : long attr);
373 : :
374 : : static PyObject *
375 : 0 : _curses_window_bkgdset(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs)
376 : : {
377 : 0 : PyObject *return_value = NULL;
378 : : PyObject *ch;
379 : 0 : long attr = A_NORMAL;
380 : :
381 [ # # # # : 0 : if (!_PyArg_CheckPositional("bkgdset", nargs, 1, 2)) {
# # ]
382 : 0 : goto exit;
383 : : }
384 : 0 : ch = args[0];
385 [ # # ]: 0 : if (nargs < 2) {
386 : 0 : goto skip_optional;
387 : : }
388 : 0 : attr = PyLong_AsLong(args[1]);
389 [ # # # # ]: 0 : if (attr == -1 && PyErr_Occurred()) {
390 : 0 : goto exit;
391 : : }
392 : 0 : skip_optional:
393 : 0 : return_value = _curses_window_bkgdset_impl(self, ch, attr);
394 : :
395 : 0 : exit:
396 : 0 : return return_value;
397 : : }
398 : :
399 : : PyDoc_STRVAR(_curses_window_border__doc__,
400 : : "border($self, ls=_curses.ACS_VLINE, rs=_curses.ACS_VLINE,\n"
401 : : " ts=_curses.ACS_HLINE, bs=_curses.ACS_HLINE,\n"
402 : : " tl=_curses.ACS_ULCORNER, tr=_curses.ACS_URCORNER,\n"
403 : : " bl=_curses.ACS_LLCORNER, br=_curses.ACS_LRCORNER, /)\n"
404 : : "--\n"
405 : : "\n"
406 : : "Draw a border around the edges of the window.\n"
407 : : "\n"
408 : : " ls\n"
409 : : " Left side.\n"
410 : : " rs\n"
411 : : " Right side.\n"
412 : : " ts\n"
413 : : " Top side.\n"
414 : : " bs\n"
415 : : " Bottom side.\n"
416 : : " tl\n"
417 : : " Upper-left corner.\n"
418 : : " tr\n"
419 : : " Upper-right corner.\n"
420 : : " bl\n"
421 : : " Bottom-left corner.\n"
422 : : " br\n"
423 : : " Bottom-right corner.\n"
424 : : "\n"
425 : : "Each parameter specifies the character to use for a specific part of the\n"
426 : : "border. The characters can be specified as integers or as one-character\n"
427 : : "strings. A 0 value for any parameter will cause the default character to be\n"
428 : : "used for that parameter.");
429 : :
430 : : #define _CURSES_WINDOW_BORDER_METHODDEF \
431 : : {"border", _PyCFunction_CAST(_curses_window_border), METH_FASTCALL, _curses_window_border__doc__},
432 : :
433 : : static PyObject *
434 : : _curses_window_border_impl(PyCursesWindowObject *self, PyObject *ls,
435 : : PyObject *rs, PyObject *ts, PyObject *bs,
436 : : PyObject *tl, PyObject *tr, PyObject *bl,
437 : : PyObject *br);
438 : :
439 : : static PyObject *
440 : 0 : _curses_window_border(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs)
441 : : {
442 : 0 : PyObject *return_value = NULL;
443 : 0 : PyObject *ls = NULL;
444 : 0 : PyObject *rs = NULL;
445 : 0 : PyObject *ts = NULL;
446 : 0 : PyObject *bs = NULL;
447 : 0 : PyObject *tl = NULL;
448 : 0 : PyObject *tr = NULL;
449 : 0 : PyObject *bl = NULL;
450 : 0 : PyObject *br = NULL;
451 : :
452 [ # # # # : 0 : if (!_PyArg_CheckPositional("border", nargs, 0, 8)) {
# # ]
453 : 0 : goto exit;
454 : : }
455 [ # # ]: 0 : if (nargs < 1) {
456 : 0 : goto skip_optional;
457 : : }
458 : 0 : ls = args[0];
459 [ # # ]: 0 : if (nargs < 2) {
460 : 0 : goto skip_optional;
461 : : }
462 : 0 : rs = args[1];
463 [ # # ]: 0 : if (nargs < 3) {
464 : 0 : goto skip_optional;
465 : : }
466 : 0 : ts = args[2];
467 [ # # ]: 0 : if (nargs < 4) {
468 : 0 : goto skip_optional;
469 : : }
470 : 0 : bs = args[3];
471 [ # # ]: 0 : if (nargs < 5) {
472 : 0 : goto skip_optional;
473 : : }
474 : 0 : tl = args[4];
475 [ # # ]: 0 : if (nargs < 6) {
476 : 0 : goto skip_optional;
477 : : }
478 : 0 : tr = args[5];
479 [ # # ]: 0 : if (nargs < 7) {
480 : 0 : goto skip_optional;
481 : : }
482 : 0 : bl = args[6];
483 [ # # ]: 0 : if (nargs < 8) {
484 : 0 : goto skip_optional;
485 : : }
486 : 0 : br = args[7];
487 : 0 : skip_optional:
488 : 0 : return_value = _curses_window_border_impl(self, ls, rs, ts, bs, tl, tr, bl, br);
489 : :
490 : 0 : exit:
491 : 0 : return return_value;
492 : : }
493 : :
494 : : PyDoc_STRVAR(_curses_window_box__doc__,
495 : : "box([verch=0, horch=0])\n"
496 : : "Draw a border around the edges of the window.\n"
497 : : "\n"
498 : : " verch\n"
499 : : " Left and right side.\n"
500 : : " horch\n"
501 : : " Top and bottom side.\n"
502 : : "\n"
503 : : "Similar to border(), but both ls and rs are verch and both ts and bs are\n"
504 : : "horch. The default corner characters are always used by this function.");
505 : :
506 : : #define _CURSES_WINDOW_BOX_METHODDEF \
507 : : {"box", (PyCFunction)_curses_window_box, METH_VARARGS, _curses_window_box__doc__},
508 : :
509 : : static PyObject *
510 : : _curses_window_box_impl(PyCursesWindowObject *self, int group_right_1,
511 : : PyObject *verch, PyObject *horch);
512 : :
513 : : static PyObject *
514 : 0 : _curses_window_box(PyCursesWindowObject *self, PyObject *args)
515 : : {
516 : 0 : PyObject *return_value = NULL;
517 : 0 : int group_right_1 = 0;
518 : 0 : PyObject *verch = _PyLong_GetZero();
519 : 0 : PyObject *horch = _PyLong_GetZero();
520 : :
521 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
522 : 0 : case 0:
523 : 0 : break;
524 : 0 : case 2:
525 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "OO:box", &verch, &horch)) {
526 : 0 : goto exit;
527 : : }
528 : 0 : group_right_1 = 1;
529 : 0 : break;
530 : 0 : default:
531 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.box requires 0 to 2 arguments");
532 : 0 : goto exit;
533 : : }
534 : 0 : return_value = _curses_window_box_impl(self, group_right_1, verch, horch);
535 : :
536 : 0 : exit:
537 : 0 : return return_value;
538 : : }
539 : :
540 : : PyDoc_STRVAR(_curses_window_delch__doc__,
541 : : "delch([y, x])\n"
542 : : "Delete any character at (y, x).\n"
543 : : "\n"
544 : : " y\n"
545 : : " Y-coordinate.\n"
546 : : " x\n"
547 : : " X-coordinate.");
548 : :
549 : : #define _CURSES_WINDOW_DELCH_METHODDEF \
550 : : {"delch", (PyCFunction)_curses_window_delch, METH_VARARGS, _curses_window_delch__doc__},
551 : :
552 : : static PyObject *
553 : : _curses_window_delch_impl(PyCursesWindowObject *self, int group_right_1,
554 : : int y, int x);
555 : :
556 : : static PyObject *
557 : 0 : _curses_window_delch(PyCursesWindowObject *self, PyObject *args)
558 : : {
559 : 0 : PyObject *return_value = NULL;
560 : 0 : int group_right_1 = 0;
561 : 0 : int y = 0;
562 : 0 : int x = 0;
563 : :
564 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
565 : 0 : case 0:
566 : 0 : break;
567 : 0 : case 2:
568 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:delch", &y, &x)) {
569 : 0 : goto exit;
570 : : }
571 : 0 : group_right_1 = 1;
572 : 0 : break;
573 : 0 : default:
574 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.delch requires 0 to 2 arguments");
575 : 0 : goto exit;
576 : : }
577 : 0 : return_value = _curses_window_delch_impl(self, group_right_1, y, x);
578 : :
579 : 0 : exit:
580 : 0 : return return_value;
581 : : }
582 : :
583 : : PyDoc_STRVAR(_curses_window_derwin__doc__,
584 : : "derwin([nlines=0, ncols=0,] begin_y, begin_x)\n"
585 : : "Create a sub-window (window-relative coordinates).\n"
586 : : "\n"
587 : : " nlines\n"
588 : : " Height.\n"
589 : : " ncols\n"
590 : : " Width.\n"
591 : : " begin_y\n"
592 : : " Top side y-coordinate.\n"
593 : : " begin_x\n"
594 : : " Left side x-coordinate.\n"
595 : : "\n"
596 : : "derwin() is the same as calling subwin(), except that begin_y and begin_x\n"
597 : : "are relative to the origin of the window, rather than relative to the entire\n"
598 : : "screen.");
599 : :
600 : : #define _CURSES_WINDOW_DERWIN_METHODDEF \
601 : : {"derwin", (PyCFunction)_curses_window_derwin, METH_VARARGS, _curses_window_derwin__doc__},
602 : :
603 : : static PyObject *
604 : : _curses_window_derwin_impl(PyCursesWindowObject *self, int group_left_1,
605 : : int nlines, int ncols, int begin_y, int begin_x);
606 : :
607 : : static PyObject *
608 : 0 : _curses_window_derwin(PyCursesWindowObject *self, PyObject *args)
609 : : {
610 : 0 : PyObject *return_value = NULL;
611 : 0 : int group_left_1 = 0;
612 : 0 : int nlines = 0;
613 : 0 : int ncols = 0;
614 : : int begin_y;
615 : : int begin_x;
616 : :
617 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
618 : 0 : case 2:
619 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:derwin", &begin_y, &begin_x)) {
620 : 0 : goto exit;
621 : : }
622 : 0 : break;
623 : 0 : case 4:
624 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiii:derwin", &nlines, &ncols, &begin_y, &begin_x)) {
625 : 0 : goto exit;
626 : : }
627 : 0 : group_left_1 = 1;
628 : 0 : break;
629 : 0 : default:
630 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.derwin requires 2 to 4 arguments");
631 : 0 : goto exit;
632 : : }
633 : 0 : return_value = _curses_window_derwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x);
634 : :
635 : 0 : exit:
636 : 0 : return return_value;
637 : : }
638 : :
639 : : PyDoc_STRVAR(_curses_window_echochar__doc__,
640 : : "echochar($self, ch, attr=_curses.A_NORMAL, /)\n"
641 : : "--\n"
642 : : "\n"
643 : : "Add character ch with attribute attr, and refresh.\n"
644 : : "\n"
645 : : " ch\n"
646 : : " Character to add.\n"
647 : : " attr\n"
648 : : " Attributes for the character.");
649 : :
650 : : #define _CURSES_WINDOW_ECHOCHAR_METHODDEF \
651 : : {"echochar", _PyCFunction_CAST(_curses_window_echochar), METH_FASTCALL, _curses_window_echochar__doc__},
652 : :
653 : : static PyObject *
654 : : _curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch,
655 : : long attr);
656 : :
657 : : static PyObject *
658 : 0 : _curses_window_echochar(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs)
659 : : {
660 : 0 : PyObject *return_value = NULL;
661 : : PyObject *ch;
662 : 0 : long attr = A_NORMAL;
663 : :
664 [ # # # # : 0 : if (!_PyArg_CheckPositional("echochar", nargs, 1, 2)) {
# # ]
665 : 0 : goto exit;
666 : : }
667 : 0 : ch = args[0];
668 [ # # ]: 0 : if (nargs < 2) {
669 : 0 : goto skip_optional;
670 : : }
671 : 0 : attr = PyLong_AsLong(args[1]);
672 [ # # # # ]: 0 : if (attr == -1 && PyErr_Occurred()) {
673 : 0 : goto exit;
674 : : }
675 : 0 : skip_optional:
676 : 0 : return_value = _curses_window_echochar_impl(self, ch, attr);
677 : :
678 : 0 : exit:
679 : 0 : return return_value;
680 : : }
681 : :
682 : : #if defined(NCURSES_MOUSE_VERSION)
683 : :
684 : : PyDoc_STRVAR(_curses_window_enclose__doc__,
685 : : "enclose($self, y, x, /)\n"
686 : : "--\n"
687 : : "\n"
688 : : "Return True if the screen-relative coordinates are enclosed by the window.\n"
689 : : "\n"
690 : : " y\n"
691 : : " Y-coordinate.\n"
692 : : " x\n"
693 : : " X-coordinate.");
694 : :
695 : : #define _CURSES_WINDOW_ENCLOSE_METHODDEF \
696 : : {"enclose", _PyCFunction_CAST(_curses_window_enclose), METH_FASTCALL, _curses_window_enclose__doc__},
697 : :
698 : : static PyObject *
699 : : _curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x);
700 : :
701 : : static PyObject *
702 : 0 : _curses_window_enclose(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs)
703 : : {
704 : 0 : PyObject *return_value = NULL;
705 : : int y;
706 : : int x;
707 : :
708 [ # # # # : 0 : if (!_PyArg_CheckPositional("enclose", nargs, 2, 2)) {
# # ]
709 : 0 : goto exit;
710 : : }
711 : 0 : y = _PyLong_AsInt(args[0]);
712 [ # # # # ]: 0 : if (y == -1 && PyErr_Occurred()) {
713 : 0 : goto exit;
714 : : }
715 : 0 : x = _PyLong_AsInt(args[1]);
716 [ # # # # ]: 0 : if (x == -1 && PyErr_Occurred()) {
717 : 0 : goto exit;
718 : : }
719 : 0 : return_value = _curses_window_enclose_impl(self, y, x);
720 : :
721 : 0 : exit:
722 : 0 : return return_value;
723 : : }
724 : :
725 : : #endif /* defined(NCURSES_MOUSE_VERSION) */
726 : :
727 : : PyDoc_STRVAR(_curses_window_getbkgd__doc__,
728 : : "getbkgd($self, /)\n"
729 : : "--\n"
730 : : "\n"
731 : : "Return the window\'s current background character/attribute pair.");
732 : :
733 : : #define _CURSES_WINDOW_GETBKGD_METHODDEF \
734 : : {"getbkgd", (PyCFunction)_curses_window_getbkgd, METH_NOARGS, _curses_window_getbkgd__doc__},
735 : :
736 : : static long
737 : : _curses_window_getbkgd_impl(PyCursesWindowObject *self);
738 : :
739 : : static PyObject *
740 : 0 : _curses_window_getbkgd(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored))
741 : : {
742 : 0 : PyObject *return_value = NULL;
743 : : long _return_value;
744 : :
745 : 0 : _return_value = _curses_window_getbkgd_impl(self);
746 [ # # # # ]: 0 : if ((_return_value == -1) && PyErr_Occurred()) {
747 : 0 : goto exit;
748 : : }
749 : 0 : return_value = PyLong_FromLong(_return_value);
750 : :
751 : 0 : exit:
752 : 0 : return return_value;
753 : : }
754 : :
755 : : PyDoc_STRVAR(_curses_window_getch__doc__,
756 : : "getch([y, x])\n"
757 : : "Get a character code from terminal keyboard.\n"
758 : : "\n"
759 : : " y\n"
760 : : " Y-coordinate.\n"
761 : : " x\n"
762 : : " X-coordinate.\n"
763 : : "\n"
764 : : "The integer returned does not have to be in ASCII range: function keys,\n"
765 : : "keypad keys and so on return numbers higher than 256. In no-delay mode, -1\n"
766 : : "is returned if there is no input, else getch() waits until a key is pressed.");
767 : :
768 : : #define _CURSES_WINDOW_GETCH_METHODDEF \
769 : : {"getch", (PyCFunction)_curses_window_getch, METH_VARARGS, _curses_window_getch__doc__},
770 : :
771 : : static int
772 : : _curses_window_getch_impl(PyCursesWindowObject *self, int group_right_1,
773 : : int y, int x);
774 : :
775 : : static PyObject *
776 : 0 : _curses_window_getch(PyCursesWindowObject *self, PyObject *args)
777 : : {
778 : 0 : PyObject *return_value = NULL;
779 : 0 : int group_right_1 = 0;
780 : 0 : int y = 0;
781 : 0 : int x = 0;
782 : : int _return_value;
783 : :
784 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
785 : 0 : case 0:
786 : 0 : break;
787 : 0 : case 2:
788 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:getch", &y, &x)) {
789 : 0 : goto exit;
790 : : }
791 : 0 : group_right_1 = 1;
792 : 0 : break;
793 : 0 : default:
794 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.getch requires 0 to 2 arguments");
795 : 0 : goto exit;
796 : : }
797 : 0 : _return_value = _curses_window_getch_impl(self, group_right_1, y, x);
798 [ # # # # ]: 0 : if ((_return_value == -1) && PyErr_Occurred()) {
799 : 0 : goto exit;
800 : : }
801 : 0 : return_value = PyLong_FromLong((long)_return_value);
802 : :
803 : 0 : exit:
804 : 0 : return return_value;
805 : : }
806 : :
807 : : PyDoc_STRVAR(_curses_window_getkey__doc__,
808 : : "getkey([y, x])\n"
809 : : "Get a character (string) from terminal keyboard.\n"
810 : : "\n"
811 : : " y\n"
812 : : " Y-coordinate.\n"
813 : : " x\n"
814 : : " X-coordinate.\n"
815 : : "\n"
816 : : "Returning a string instead of an integer, as getch() does. Function keys,\n"
817 : : "keypad keys and other special keys return a multibyte string containing the\n"
818 : : "key name. In no-delay mode, an exception is raised if there is no input.");
819 : :
820 : : #define _CURSES_WINDOW_GETKEY_METHODDEF \
821 : : {"getkey", (PyCFunction)_curses_window_getkey, METH_VARARGS, _curses_window_getkey__doc__},
822 : :
823 : : static PyObject *
824 : : _curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1,
825 : : int y, int x);
826 : :
827 : : static PyObject *
828 : 0 : _curses_window_getkey(PyCursesWindowObject *self, PyObject *args)
829 : : {
830 : 0 : PyObject *return_value = NULL;
831 : 0 : int group_right_1 = 0;
832 : 0 : int y = 0;
833 : 0 : int x = 0;
834 : :
835 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
836 : 0 : case 0:
837 : 0 : break;
838 : 0 : case 2:
839 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:getkey", &y, &x)) {
840 : 0 : goto exit;
841 : : }
842 : 0 : group_right_1 = 1;
843 : 0 : break;
844 : 0 : default:
845 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.getkey requires 0 to 2 arguments");
846 : 0 : goto exit;
847 : : }
848 : 0 : return_value = _curses_window_getkey_impl(self, group_right_1, y, x);
849 : :
850 : 0 : exit:
851 : 0 : return return_value;
852 : : }
853 : :
854 : : #if defined(HAVE_NCURSESW)
855 : :
856 : : PyDoc_STRVAR(_curses_window_get_wch__doc__,
857 : : "get_wch([y, x])\n"
858 : : "Get a wide character from terminal keyboard.\n"
859 : : "\n"
860 : : " y\n"
861 : : " Y-coordinate.\n"
862 : : " x\n"
863 : : " X-coordinate.\n"
864 : : "\n"
865 : : "Return a character for most keys, or an integer for function keys,\n"
866 : : "keypad keys, and other special keys.");
867 : :
868 : : #define _CURSES_WINDOW_GET_WCH_METHODDEF \
869 : : {"get_wch", (PyCFunction)_curses_window_get_wch, METH_VARARGS, _curses_window_get_wch__doc__},
870 : :
871 : : static PyObject *
872 : : _curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1,
873 : : int y, int x);
874 : :
875 : : static PyObject *
876 : 0 : _curses_window_get_wch(PyCursesWindowObject *self, PyObject *args)
877 : : {
878 : 0 : PyObject *return_value = NULL;
879 : 0 : int group_right_1 = 0;
880 : 0 : int y = 0;
881 : 0 : int x = 0;
882 : :
883 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
884 : 0 : case 0:
885 : 0 : break;
886 : 0 : case 2:
887 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:get_wch", &y, &x)) {
888 : 0 : goto exit;
889 : : }
890 : 0 : group_right_1 = 1;
891 : 0 : break;
892 : 0 : default:
893 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.get_wch requires 0 to 2 arguments");
894 : 0 : goto exit;
895 : : }
896 : 0 : return_value = _curses_window_get_wch_impl(self, group_right_1, y, x);
897 : :
898 : 0 : exit:
899 : 0 : return return_value;
900 : : }
901 : :
902 : : #endif /* defined(HAVE_NCURSESW) */
903 : :
904 : : PyDoc_STRVAR(_curses_window_hline__doc__,
905 : : "hline([y, x,] ch, n, [attr=_curses.A_NORMAL])\n"
906 : : "Display a horizontal line.\n"
907 : : "\n"
908 : : " y\n"
909 : : " Starting Y-coordinate.\n"
910 : : " x\n"
911 : : " Starting X-coordinate.\n"
912 : : " ch\n"
913 : : " Character to draw.\n"
914 : : " n\n"
915 : : " Line length.\n"
916 : : " attr\n"
917 : : " Attributes for the characters.");
918 : :
919 : : #define _CURSES_WINDOW_HLINE_METHODDEF \
920 : : {"hline", (PyCFunction)_curses_window_hline, METH_VARARGS, _curses_window_hline__doc__},
921 : :
922 : : static PyObject *
923 : : _curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1,
924 : : int y, int x, PyObject *ch, int n,
925 : : int group_right_1, long attr);
926 : :
927 : : static PyObject *
928 : 0 : _curses_window_hline(PyCursesWindowObject *self, PyObject *args)
929 : : {
930 : 0 : PyObject *return_value = NULL;
931 : 0 : int group_left_1 = 0;
932 : 0 : int y = 0;
933 : 0 : int x = 0;
934 : : PyObject *ch;
935 : : int n;
936 : 0 : int group_right_1 = 0;
937 : 0 : long attr = A_NORMAL;
938 : :
939 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
940 : 0 : case 2:
941 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oi:hline", &ch, &n)) {
942 : 0 : goto exit;
943 : : }
944 : 0 : break;
945 : 0 : case 3:
946 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oil:hline", &ch, &n, &attr)) {
947 : 0 : goto exit;
948 : : }
949 : 0 : group_right_1 = 1;
950 : 0 : break;
951 : 0 : case 4:
952 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOi:hline", &y, &x, &ch, &n)) {
953 : 0 : goto exit;
954 : : }
955 : 0 : group_left_1 = 1;
956 : 0 : break;
957 : 0 : case 5:
958 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOil:hline", &y, &x, &ch, &n, &attr)) {
959 : 0 : goto exit;
960 : : }
961 : 0 : group_right_1 = 1;
962 : 0 : group_left_1 = 1;
963 : 0 : break;
964 : 0 : default:
965 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.hline requires 2 to 5 arguments");
966 : 0 : goto exit;
967 : : }
968 : 0 : return_value = _curses_window_hline_impl(self, group_left_1, y, x, ch, n, group_right_1, attr);
969 : :
970 : 0 : exit:
971 : 0 : return return_value;
972 : : }
973 : :
974 : : PyDoc_STRVAR(_curses_window_insch__doc__,
975 : : "insch([y, x,] ch, [attr=_curses.A_NORMAL])\n"
976 : : "Insert a character before the current or specified position.\n"
977 : : "\n"
978 : : " y\n"
979 : : " Y-coordinate.\n"
980 : : " x\n"
981 : : " X-coordinate.\n"
982 : : " ch\n"
983 : : " Character to insert.\n"
984 : : " attr\n"
985 : : " Attributes for the character.\n"
986 : : "\n"
987 : : "All characters to the right of the cursor are shifted one position right, with\n"
988 : : "the rightmost characters on the line being lost.");
989 : :
990 : : #define _CURSES_WINDOW_INSCH_METHODDEF \
991 : : {"insch", (PyCFunction)_curses_window_insch, METH_VARARGS, _curses_window_insch__doc__},
992 : :
993 : : static PyObject *
994 : : _curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1,
995 : : int y, int x, PyObject *ch, int group_right_1,
996 : : long attr);
997 : :
998 : : static PyObject *
999 : 0 : _curses_window_insch(PyCursesWindowObject *self, PyObject *args)
1000 : : {
1001 : 0 : PyObject *return_value = NULL;
1002 : 0 : int group_left_1 = 0;
1003 : 0 : int y = 0;
1004 : 0 : int x = 0;
1005 : : PyObject *ch;
1006 : 0 : int group_right_1 = 0;
1007 : 0 : long attr = A_NORMAL;
1008 : :
1009 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
1010 : 0 : case 1:
1011 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O:insch", &ch)) {
1012 : 0 : goto exit;
1013 : : }
1014 : 0 : break;
1015 : 0 : case 2:
1016 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Ol:insch", &ch, &attr)) {
1017 : 0 : goto exit;
1018 : : }
1019 : 0 : group_right_1 = 1;
1020 : 0 : break;
1021 : 0 : case 3:
1022 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiO:insch", &y, &x, &ch)) {
1023 : 0 : goto exit;
1024 : : }
1025 : 0 : group_left_1 = 1;
1026 : 0 : break;
1027 : 0 : case 4:
1028 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOl:insch", &y, &x, &ch, &attr)) {
1029 : 0 : goto exit;
1030 : : }
1031 : 0 : group_right_1 = 1;
1032 : 0 : group_left_1 = 1;
1033 : 0 : break;
1034 : 0 : default:
1035 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.insch requires 1 to 4 arguments");
1036 : 0 : goto exit;
1037 : : }
1038 : 0 : return_value = _curses_window_insch_impl(self, group_left_1, y, x, ch, group_right_1, attr);
1039 : :
1040 : 0 : exit:
1041 : 0 : return return_value;
1042 : : }
1043 : :
1044 : : PyDoc_STRVAR(_curses_window_inch__doc__,
1045 : : "inch([y, x])\n"
1046 : : "Return the character at the given position in the window.\n"
1047 : : "\n"
1048 : : " y\n"
1049 : : " Y-coordinate.\n"
1050 : : " x\n"
1051 : : " X-coordinate.\n"
1052 : : "\n"
1053 : : "The bottom 8 bits are the character proper, and upper bits are the attributes.");
1054 : :
1055 : : #define _CURSES_WINDOW_INCH_METHODDEF \
1056 : : {"inch", (PyCFunction)_curses_window_inch, METH_VARARGS, _curses_window_inch__doc__},
1057 : :
1058 : : static unsigned long
1059 : : _curses_window_inch_impl(PyCursesWindowObject *self, int group_right_1,
1060 : : int y, int x);
1061 : :
1062 : : static PyObject *
1063 : 0 : _curses_window_inch(PyCursesWindowObject *self, PyObject *args)
1064 : : {
1065 : 0 : PyObject *return_value = NULL;
1066 : 0 : int group_right_1 = 0;
1067 : 0 : int y = 0;
1068 : 0 : int x = 0;
1069 : : unsigned long _return_value;
1070 : :
1071 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1072 : 0 : case 0:
1073 : 0 : break;
1074 : 0 : case 2:
1075 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:inch", &y, &x)) {
1076 : 0 : goto exit;
1077 : : }
1078 : 0 : group_right_1 = 1;
1079 : 0 : break;
1080 : 0 : default:
1081 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.inch requires 0 to 2 arguments");
1082 : 0 : goto exit;
1083 : : }
1084 : 0 : _return_value = _curses_window_inch_impl(self, group_right_1, y, x);
1085 [ # # # # ]: 0 : if ((_return_value == (unsigned long)-1) && PyErr_Occurred()) {
1086 : 0 : goto exit;
1087 : : }
1088 : 0 : return_value = PyLong_FromUnsignedLong(_return_value);
1089 : :
1090 : 0 : exit:
1091 : 0 : return return_value;
1092 : : }
1093 : :
1094 : : PyDoc_STRVAR(_curses_window_insstr__doc__,
1095 : : "insstr([y, x,] str, [attr])\n"
1096 : : "Insert the string before the current or specified position.\n"
1097 : : "\n"
1098 : : " y\n"
1099 : : " Y-coordinate.\n"
1100 : : " x\n"
1101 : : " X-coordinate.\n"
1102 : : " str\n"
1103 : : " String to insert.\n"
1104 : : " attr\n"
1105 : : " Attributes for characters.\n"
1106 : : "\n"
1107 : : "Insert a character string (as many characters as will fit on the line)\n"
1108 : : "before the character under the cursor. All characters to the right of\n"
1109 : : "the cursor are shifted right, with the rightmost characters on the line\n"
1110 : : "being lost. The cursor position does not change (after moving to y, x,\n"
1111 : : "if specified).");
1112 : :
1113 : : #define _CURSES_WINDOW_INSSTR_METHODDEF \
1114 : : {"insstr", (PyCFunction)_curses_window_insstr, METH_VARARGS, _curses_window_insstr__doc__},
1115 : :
1116 : : static PyObject *
1117 : : _curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1,
1118 : : int y, int x, PyObject *str, int group_right_1,
1119 : : long attr);
1120 : :
1121 : : static PyObject *
1122 : 0 : _curses_window_insstr(PyCursesWindowObject *self, PyObject *args)
1123 : : {
1124 : 0 : PyObject *return_value = NULL;
1125 : 0 : int group_left_1 = 0;
1126 : 0 : int y = 0;
1127 : 0 : int x = 0;
1128 : : PyObject *str;
1129 : 0 : int group_right_1 = 0;
1130 : 0 : long attr = 0;
1131 : :
1132 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
1133 : 0 : case 1:
1134 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O:insstr", &str)) {
1135 : 0 : goto exit;
1136 : : }
1137 : 0 : break;
1138 : 0 : case 2:
1139 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Ol:insstr", &str, &attr)) {
1140 : 0 : goto exit;
1141 : : }
1142 : 0 : group_right_1 = 1;
1143 : 0 : break;
1144 : 0 : case 3:
1145 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiO:insstr", &y, &x, &str)) {
1146 : 0 : goto exit;
1147 : : }
1148 : 0 : group_left_1 = 1;
1149 : 0 : break;
1150 : 0 : case 4:
1151 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOl:insstr", &y, &x, &str, &attr)) {
1152 : 0 : goto exit;
1153 : : }
1154 : 0 : group_right_1 = 1;
1155 : 0 : group_left_1 = 1;
1156 : 0 : break;
1157 : 0 : default:
1158 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.insstr requires 1 to 4 arguments");
1159 : 0 : goto exit;
1160 : : }
1161 : 0 : return_value = _curses_window_insstr_impl(self, group_left_1, y, x, str, group_right_1, attr);
1162 : :
1163 : 0 : exit:
1164 : 0 : return return_value;
1165 : : }
1166 : :
1167 : : PyDoc_STRVAR(_curses_window_insnstr__doc__,
1168 : : "insnstr([y, x,] str, n, [attr])\n"
1169 : : "Insert at most n characters of the string.\n"
1170 : : "\n"
1171 : : " y\n"
1172 : : " Y-coordinate.\n"
1173 : : " x\n"
1174 : : " X-coordinate.\n"
1175 : : " str\n"
1176 : : " String to insert.\n"
1177 : : " n\n"
1178 : : " Maximal number of characters.\n"
1179 : : " attr\n"
1180 : : " Attributes for characters.\n"
1181 : : "\n"
1182 : : "Insert a character string (as many characters as will fit on the line)\n"
1183 : : "before the character under the cursor, up to n characters. If n is zero\n"
1184 : : "or negative, the entire string is inserted. All characters to the right\n"
1185 : : "of the cursor are shifted right, with the rightmost characters on the line\n"
1186 : : "being lost. The cursor position does not change (after moving to y, x, if\n"
1187 : : "specified).");
1188 : :
1189 : : #define _CURSES_WINDOW_INSNSTR_METHODDEF \
1190 : : {"insnstr", (PyCFunction)_curses_window_insnstr, METH_VARARGS, _curses_window_insnstr__doc__},
1191 : :
1192 : : static PyObject *
1193 : : _curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1,
1194 : : int y, int x, PyObject *str, int n,
1195 : : int group_right_1, long attr);
1196 : :
1197 : : static PyObject *
1198 : 0 : _curses_window_insnstr(PyCursesWindowObject *self, PyObject *args)
1199 : : {
1200 : 0 : PyObject *return_value = NULL;
1201 : 0 : int group_left_1 = 0;
1202 : 0 : int y = 0;
1203 : 0 : int x = 0;
1204 : : PyObject *str;
1205 : : int n;
1206 : 0 : int group_right_1 = 0;
1207 : 0 : long attr = 0;
1208 : :
1209 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
1210 : 0 : case 2:
1211 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oi:insnstr", &str, &n)) {
1212 : 0 : goto exit;
1213 : : }
1214 : 0 : break;
1215 : 0 : case 3:
1216 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oil:insnstr", &str, &n, &attr)) {
1217 : 0 : goto exit;
1218 : : }
1219 : 0 : group_right_1 = 1;
1220 : 0 : break;
1221 : 0 : case 4:
1222 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOi:insnstr", &y, &x, &str, &n)) {
1223 : 0 : goto exit;
1224 : : }
1225 : 0 : group_left_1 = 1;
1226 : 0 : break;
1227 : 0 : case 5:
1228 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOil:insnstr", &y, &x, &str, &n, &attr)) {
1229 : 0 : goto exit;
1230 : : }
1231 : 0 : group_right_1 = 1;
1232 : 0 : group_left_1 = 1;
1233 : 0 : break;
1234 : 0 : default:
1235 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.insnstr requires 2 to 5 arguments");
1236 : 0 : goto exit;
1237 : : }
1238 : 0 : return_value = _curses_window_insnstr_impl(self, group_left_1, y, x, str, n, group_right_1, attr);
1239 : :
1240 : 0 : exit:
1241 : 0 : return return_value;
1242 : : }
1243 : :
1244 : : PyDoc_STRVAR(_curses_window_is_linetouched__doc__,
1245 : : "is_linetouched($self, line, /)\n"
1246 : : "--\n"
1247 : : "\n"
1248 : : "Return True if the specified line was modified, otherwise return False.\n"
1249 : : "\n"
1250 : : " line\n"
1251 : : " Line number.\n"
1252 : : "\n"
1253 : : "Raise a curses.error exception if line is not valid for the given window.");
1254 : :
1255 : : #define _CURSES_WINDOW_IS_LINETOUCHED_METHODDEF \
1256 : : {"is_linetouched", (PyCFunction)_curses_window_is_linetouched, METH_O, _curses_window_is_linetouched__doc__},
1257 : :
1258 : : static PyObject *
1259 : : _curses_window_is_linetouched_impl(PyCursesWindowObject *self, int line);
1260 : :
1261 : : static PyObject *
1262 : 0 : _curses_window_is_linetouched(PyCursesWindowObject *self, PyObject *arg)
1263 : : {
1264 : 0 : PyObject *return_value = NULL;
1265 : : int line;
1266 : :
1267 : 0 : line = _PyLong_AsInt(arg);
1268 [ # # # # ]: 0 : if (line == -1 && PyErr_Occurred()) {
1269 : 0 : goto exit;
1270 : : }
1271 : 0 : return_value = _curses_window_is_linetouched_impl(self, line);
1272 : :
1273 : 0 : exit:
1274 : 0 : return return_value;
1275 : : }
1276 : :
1277 : : #if defined(py_is_pad)
1278 : :
1279 : : PyDoc_STRVAR(_curses_window_noutrefresh__doc__,
1280 : : "noutrefresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n"
1281 : : "Mark for refresh but wait.\n"
1282 : : "\n"
1283 : : "This function updates the data structure representing the desired state of the\n"
1284 : : "window, but does not force an update of the physical screen. To accomplish\n"
1285 : : "that, call doupdate().");
1286 : :
1287 : : #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \
1288 : : {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_VARARGS, _curses_window_noutrefresh__doc__},
1289 : :
1290 : : static PyObject *
1291 : : _curses_window_noutrefresh_impl(PyCursesWindowObject *self,
1292 : : int group_right_1, int pminrow, int pmincol,
1293 : : int sminrow, int smincol, int smaxrow,
1294 : : int smaxcol);
1295 : :
1296 : : static PyObject *
1297 : 0 : _curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *args)
1298 : : {
1299 : 0 : PyObject *return_value = NULL;
1300 : 0 : int group_right_1 = 0;
1301 : 0 : int pminrow = 0;
1302 : 0 : int pmincol = 0;
1303 : 0 : int sminrow = 0;
1304 : 0 : int smincol = 0;
1305 : 0 : int smaxrow = 0;
1306 : 0 : int smaxcol = 0;
1307 : :
1308 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1309 : 0 : case 0:
1310 : 0 : break;
1311 : 0 : case 6:
1312 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiiiii:noutrefresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) {
1313 : 0 : goto exit;
1314 : : }
1315 : 0 : group_right_1 = 1;
1316 : 0 : break;
1317 : 0 : default:
1318 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.noutrefresh requires 0 to 6 arguments");
1319 : 0 : goto exit;
1320 : : }
1321 : 0 : return_value = _curses_window_noutrefresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol);
1322 : :
1323 : 0 : exit:
1324 : 0 : return return_value;
1325 : : }
1326 : :
1327 : : #endif /* defined(py_is_pad) */
1328 : :
1329 : : #if !defined(py_is_pad)
1330 : :
1331 : : PyDoc_STRVAR(_curses_window_noutrefresh__doc__,
1332 : : "noutrefresh($self, /)\n"
1333 : : "--\n"
1334 : : "\n"
1335 : : "Mark for refresh but wait.\n"
1336 : : "\n"
1337 : : "This function updates the data structure representing the desired state of the\n"
1338 : : "window, but does not force an update of the physical screen. To accomplish\n"
1339 : : "that, call doupdate().");
1340 : :
1341 : : #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF \
1342 : : {"noutrefresh", (PyCFunction)_curses_window_noutrefresh, METH_NOARGS, _curses_window_noutrefresh__doc__},
1343 : :
1344 : : static PyObject *
1345 : : _curses_window_noutrefresh_impl(PyCursesWindowObject *self);
1346 : :
1347 : : static PyObject *
1348 : : _curses_window_noutrefresh(PyCursesWindowObject *self, PyObject *Py_UNUSED(ignored))
1349 : : {
1350 : : return _curses_window_noutrefresh_impl(self);
1351 : : }
1352 : :
1353 : : #endif /* !defined(py_is_pad) */
1354 : :
1355 : : PyDoc_STRVAR(_curses_window_overlay__doc__,
1356 : : "overlay(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol])\n"
1357 : : "Overlay the window on top of destwin.\n"
1358 : : "\n"
1359 : : "The windows need not be the same size, only the overlapping region is copied.\n"
1360 : : "This copy is non-destructive, which means that the current background\n"
1361 : : "character does not overwrite the old contents of destwin.\n"
1362 : : "\n"
1363 : : "To get fine-grained control over the copied region, the second form of\n"
1364 : : "overlay() can be used. sminrow and smincol are the upper-left coordinates\n"
1365 : : "of the source window, and the other variables mark a rectangle in the\n"
1366 : : "destination window.");
1367 : :
1368 : : #define _CURSES_WINDOW_OVERLAY_METHODDEF \
1369 : : {"overlay", (PyCFunction)_curses_window_overlay, METH_VARARGS, _curses_window_overlay__doc__},
1370 : :
1371 : : static PyObject *
1372 : : _curses_window_overlay_impl(PyCursesWindowObject *self,
1373 : : PyCursesWindowObject *destwin, int group_right_1,
1374 : : int sminrow, int smincol, int dminrow,
1375 : : int dmincol, int dmaxrow, int dmaxcol);
1376 : :
1377 : : static PyObject *
1378 : 0 : _curses_window_overlay(PyCursesWindowObject *self, PyObject *args)
1379 : : {
1380 : 0 : PyObject *return_value = NULL;
1381 : : PyCursesWindowObject *destwin;
1382 : 0 : int group_right_1 = 0;
1383 : 0 : int sminrow = 0;
1384 : 0 : int smincol = 0;
1385 : 0 : int dminrow = 0;
1386 : 0 : int dmincol = 0;
1387 : 0 : int dmaxrow = 0;
1388 : 0 : int dmaxcol = 0;
1389 : :
1390 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1391 : 0 : case 1:
1392 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O!:overlay", &PyCursesWindow_Type, &destwin)) {
1393 : 0 : goto exit;
1394 : : }
1395 : 0 : break;
1396 : 0 : case 7:
1397 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O!iiiiii:overlay", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) {
1398 : 0 : goto exit;
1399 : : }
1400 : 0 : group_right_1 = 1;
1401 : 0 : break;
1402 : 0 : default:
1403 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.overlay requires 1 to 7 arguments");
1404 : 0 : goto exit;
1405 : : }
1406 : 0 : return_value = _curses_window_overlay_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol);
1407 : :
1408 : 0 : exit:
1409 : 0 : return return_value;
1410 : : }
1411 : :
1412 : : PyDoc_STRVAR(_curses_window_overwrite__doc__,
1413 : : "overwrite(destwin, [sminrow, smincol, dminrow, dmincol, dmaxrow,\n"
1414 : : " dmaxcol])\n"
1415 : : "Overwrite the window on top of destwin.\n"
1416 : : "\n"
1417 : : "The windows need not be the same size, in which case only the overlapping\n"
1418 : : "region is copied. This copy is destructive, which means that the current\n"
1419 : : "background character overwrites the old contents of destwin.\n"
1420 : : "\n"
1421 : : "To get fine-grained control over the copied region, the second form of\n"
1422 : : "overwrite() can be used. sminrow and smincol are the upper-left coordinates\n"
1423 : : "of the source window, the other variables mark a rectangle in the destination\n"
1424 : : "window.");
1425 : :
1426 : : #define _CURSES_WINDOW_OVERWRITE_METHODDEF \
1427 : : {"overwrite", (PyCFunction)_curses_window_overwrite, METH_VARARGS, _curses_window_overwrite__doc__},
1428 : :
1429 : : static PyObject *
1430 : : _curses_window_overwrite_impl(PyCursesWindowObject *self,
1431 : : PyCursesWindowObject *destwin,
1432 : : int group_right_1, int sminrow, int smincol,
1433 : : int dminrow, int dmincol, int dmaxrow,
1434 : : int dmaxcol);
1435 : :
1436 : : static PyObject *
1437 : 0 : _curses_window_overwrite(PyCursesWindowObject *self, PyObject *args)
1438 : : {
1439 : 0 : PyObject *return_value = NULL;
1440 : : PyCursesWindowObject *destwin;
1441 : 0 : int group_right_1 = 0;
1442 : 0 : int sminrow = 0;
1443 : 0 : int smincol = 0;
1444 : 0 : int dminrow = 0;
1445 : 0 : int dmincol = 0;
1446 : 0 : int dmaxrow = 0;
1447 : 0 : int dmaxcol = 0;
1448 : :
1449 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1450 : 0 : case 1:
1451 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O!:overwrite", &PyCursesWindow_Type, &destwin)) {
1452 : 0 : goto exit;
1453 : : }
1454 : 0 : break;
1455 : 0 : case 7:
1456 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "O!iiiiii:overwrite", &PyCursesWindow_Type, &destwin, &sminrow, &smincol, &dminrow, &dmincol, &dmaxrow, &dmaxcol)) {
1457 : 0 : goto exit;
1458 : : }
1459 : 0 : group_right_1 = 1;
1460 : 0 : break;
1461 : 0 : default:
1462 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.overwrite requires 1 to 7 arguments");
1463 : 0 : goto exit;
1464 : : }
1465 : 0 : return_value = _curses_window_overwrite_impl(self, destwin, group_right_1, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol);
1466 : :
1467 : 0 : exit:
1468 : 0 : return return_value;
1469 : : }
1470 : :
1471 : : PyDoc_STRVAR(_curses_window_putwin__doc__,
1472 : : "putwin($self, file, /)\n"
1473 : : "--\n"
1474 : : "\n"
1475 : : "Write all data associated with the window into the provided file object.\n"
1476 : : "\n"
1477 : : "This information can be later retrieved using the getwin() function.");
1478 : :
1479 : : #define _CURSES_WINDOW_PUTWIN_METHODDEF \
1480 : : {"putwin", (PyCFunction)_curses_window_putwin, METH_O, _curses_window_putwin__doc__},
1481 : :
1482 : : PyDoc_STRVAR(_curses_window_redrawln__doc__,
1483 : : "redrawln($self, beg, num, /)\n"
1484 : : "--\n"
1485 : : "\n"
1486 : : "Mark the specified lines corrupted.\n"
1487 : : "\n"
1488 : : " beg\n"
1489 : : " Starting line number.\n"
1490 : : " num\n"
1491 : : " The number of lines.\n"
1492 : : "\n"
1493 : : "They should be completely redrawn on the next refresh() call.");
1494 : :
1495 : : #define _CURSES_WINDOW_REDRAWLN_METHODDEF \
1496 : : {"redrawln", _PyCFunction_CAST(_curses_window_redrawln), METH_FASTCALL, _curses_window_redrawln__doc__},
1497 : :
1498 : : static PyObject *
1499 : : _curses_window_redrawln_impl(PyCursesWindowObject *self, int beg, int num);
1500 : :
1501 : : static PyObject *
1502 : 0 : _curses_window_redrawln(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs)
1503 : : {
1504 : 0 : PyObject *return_value = NULL;
1505 : : int beg;
1506 : : int num;
1507 : :
1508 [ # # # # : 0 : if (!_PyArg_CheckPositional("redrawln", nargs, 2, 2)) {
# # ]
1509 : 0 : goto exit;
1510 : : }
1511 : 0 : beg = _PyLong_AsInt(args[0]);
1512 [ # # # # ]: 0 : if (beg == -1 && PyErr_Occurred()) {
1513 : 0 : goto exit;
1514 : : }
1515 : 0 : num = _PyLong_AsInt(args[1]);
1516 [ # # # # ]: 0 : if (num == -1 && PyErr_Occurred()) {
1517 : 0 : goto exit;
1518 : : }
1519 : 0 : return_value = _curses_window_redrawln_impl(self, beg, num);
1520 : :
1521 : 0 : exit:
1522 : 0 : return return_value;
1523 : : }
1524 : :
1525 : : PyDoc_STRVAR(_curses_window_refresh__doc__,
1526 : : "refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n"
1527 : : "Update the display immediately.\n"
1528 : : "\n"
1529 : : "Synchronize actual screen with previous drawing/deleting methods.\n"
1530 : : "The 6 optional arguments can only be specified when the window is a pad\n"
1531 : : "created with newpad(). The additional parameters are needed to indicate\n"
1532 : : "what part of the pad and screen are involved. pminrow and pmincol specify\n"
1533 : : "the upper left-hand corner of the rectangle to be displayed in the pad.\n"
1534 : : "sminrow, smincol, smaxrow, and smaxcol specify the edges of the rectangle to\n"
1535 : : "be displayed on the screen. The lower right-hand corner of the rectangle to\n"
1536 : : "be displayed in the pad is calculated from the screen coordinates, since the\n"
1537 : : "rectangles must be the same size. Both rectangles must be entirely contained\n"
1538 : : "within their respective structures. Negative values of pminrow, pmincol,\n"
1539 : : "sminrow, or smincol are treated as if they were zero.");
1540 : :
1541 : : #define _CURSES_WINDOW_REFRESH_METHODDEF \
1542 : : {"refresh", (PyCFunction)_curses_window_refresh, METH_VARARGS, _curses_window_refresh__doc__},
1543 : :
1544 : : static PyObject *
1545 : : _curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1,
1546 : : int pminrow, int pmincol, int sminrow,
1547 : : int smincol, int smaxrow, int smaxcol);
1548 : :
1549 : : static PyObject *
1550 : 0 : _curses_window_refresh(PyCursesWindowObject *self, PyObject *args)
1551 : : {
1552 : 0 : PyObject *return_value = NULL;
1553 : 0 : int group_right_1 = 0;
1554 : 0 : int pminrow = 0;
1555 : 0 : int pmincol = 0;
1556 : 0 : int sminrow = 0;
1557 : 0 : int smincol = 0;
1558 : 0 : int smaxrow = 0;
1559 : 0 : int smaxcol = 0;
1560 : :
1561 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1562 : 0 : case 0:
1563 : 0 : break;
1564 : 0 : case 6:
1565 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiiiii:refresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) {
1566 : 0 : goto exit;
1567 : : }
1568 : 0 : group_right_1 = 1;
1569 : 0 : break;
1570 : 0 : default:
1571 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.refresh requires 0 to 6 arguments");
1572 : 0 : goto exit;
1573 : : }
1574 : 0 : return_value = _curses_window_refresh_impl(self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol);
1575 : :
1576 : 0 : exit:
1577 : 0 : return return_value;
1578 : : }
1579 : :
1580 : : PyDoc_STRVAR(_curses_window_setscrreg__doc__,
1581 : : "setscrreg($self, top, bottom, /)\n"
1582 : : "--\n"
1583 : : "\n"
1584 : : "Define a software scrolling region.\n"
1585 : : "\n"
1586 : : " top\n"
1587 : : " First line number.\n"
1588 : : " bottom\n"
1589 : : " Last line number.\n"
1590 : : "\n"
1591 : : "All scrolling actions will take place in this region.");
1592 : :
1593 : : #define _CURSES_WINDOW_SETSCRREG_METHODDEF \
1594 : : {"setscrreg", _PyCFunction_CAST(_curses_window_setscrreg), METH_FASTCALL, _curses_window_setscrreg__doc__},
1595 : :
1596 : : static PyObject *
1597 : : _curses_window_setscrreg_impl(PyCursesWindowObject *self, int top,
1598 : : int bottom);
1599 : :
1600 : : static PyObject *
1601 : 0 : _curses_window_setscrreg(PyCursesWindowObject *self, PyObject *const *args, Py_ssize_t nargs)
1602 : : {
1603 : 0 : PyObject *return_value = NULL;
1604 : : int top;
1605 : : int bottom;
1606 : :
1607 [ # # # # : 0 : if (!_PyArg_CheckPositional("setscrreg", nargs, 2, 2)) {
# # ]
1608 : 0 : goto exit;
1609 : : }
1610 : 0 : top = _PyLong_AsInt(args[0]);
1611 [ # # # # ]: 0 : if (top == -1 && PyErr_Occurred()) {
1612 : 0 : goto exit;
1613 : : }
1614 : 0 : bottom = _PyLong_AsInt(args[1]);
1615 [ # # # # ]: 0 : if (bottom == -1 && PyErr_Occurred()) {
1616 : 0 : goto exit;
1617 : : }
1618 : 0 : return_value = _curses_window_setscrreg_impl(self, top, bottom);
1619 : :
1620 : 0 : exit:
1621 : 0 : return return_value;
1622 : : }
1623 : :
1624 : : PyDoc_STRVAR(_curses_window_subwin__doc__,
1625 : : "subwin([nlines=0, ncols=0,] begin_y, begin_x)\n"
1626 : : "Create a sub-window (screen-relative coordinates).\n"
1627 : : "\n"
1628 : : " nlines\n"
1629 : : " Height.\n"
1630 : : " ncols\n"
1631 : : " Width.\n"
1632 : : " begin_y\n"
1633 : : " Top side y-coordinate.\n"
1634 : : " begin_x\n"
1635 : : " Left side x-coordinate.\n"
1636 : : "\n"
1637 : : "By default, the sub-window will extend from the specified position to the\n"
1638 : : "lower right corner of the window.");
1639 : :
1640 : : #define _CURSES_WINDOW_SUBWIN_METHODDEF \
1641 : : {"subwin", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__},
1642 : :
1643 : : static PyObject *
1644 : : _curses_window_subwin_impl(PyCursesWindowObject *self, int group_left_1,
1645 : : int nlines, int ncols, int begin_y, int begin_x);
1646 : :
1647 : : static PyObject *
1648 : 0 : _curses_window_subwin(PyCursesWindowObject *self, PyObject *args)
1649 : : {
1650 : 0 : PyObject *return_value = NULL;
1651 : 0 : int group_left_1 = 0;
1652 : 0 : int nlines = 0;
1653 : 0 : int ncols = 0;
1654 : : int begin_y;
1655 : : int begin_x;
1656 : :
1657 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1658 : 0 : case 2:
1659 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:subwin", &begin_y, &begin_x)) {
1660 : 0 : goto exit;
1661 : : }
1662 : 0 : break;
1663 : 0 : case 4:
1664 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiii:subwin", &nlines, &ncols, &begin_y, &begin_x)) {
1665 : 0 : goto exit;
1666 : : }
1667 : 0 : group_left_1 = 1;
1668 : 0 : break;
1669 : 0 : default:
1670 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.subwin requires 2 to 4 arguments");
1671 : 0 : goto exit;
1672 : : }
1673 : 0 : return_value = _curses_window_subwin_impl(self, group_left_1, nlines, ncols, begin_y, begin_x);
1674 : :
1675 : 0 : exit:
1676 : 0 : return return_value;
1677 : : }
1678 : :
1679 : : PyDoc_STRVAR(_curses_window_scroll__doc__,
1680 : : "scroll([lines=1])\n"
1681 : : "Scroll the screen or scrolling region.\n"
1682 : : "\n"
1683 : : " lines\n"
1684 : : " Number of lines to scroll.\n"
1685 : : "\n"
1686 : : "Scroll upward if the argument is positive and downward if it is negative.");
1687 : :
1688 : : #define _CURSES_WINDOW_SCROLL_METHODDEF \
1689 : : {"scroll", (PyCFunction)_curses_window_scroll, METH_VARARGS, _curses_window_scroll__doc__},
1690 : :
1691 : : static PyObject *
1692 : : _curses_window_scroll_impl(PyCursesWindowObject *self, int group_right_1,
1693 : : int lines);
1694 : :
1695 : : static PyObject *
1696 : 0 : _curses_window_scroll(PyCursesWindowObject *self, PyObject *args)
1697 : : {
1698 : 0 : PyObject *return_value = NULL;
1699 : 0 : int group_right_1 = 0;
1700 : 0 : int lines = 1;
1701 : :
1702 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1703 : 0 : case 0:
1704 : 0 : break;
1705 : 0 : case 1:
1706 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "i:scroll", &lines)) {
1707 : 0 : goto exit;
1708 : : }
1709 : 0 : group_right_1 = 1;
1710 : 0 : break;
1711 : 0 : default:
1712 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.scroll requires 0 to 1 arguments");
1713 : 0 : goto exit;
1714 : : }
1715 : 0 : return_value = _curses_window_scroll_impl(self, group_right_1, lines);
1716 : :
1717 : 0 : exit:
1718 : 0 : return return_value;
1719 : : }
1720 : :
1721 : : PyDoc_STRVAR(_curses_window_touchline__doc__,
1722 : : "touchline(start, count, [changed=True])\n"
1723 : : "Pretend count lines have been changed, starting with line start.\n"
1724 : : "\n"
1725 : : "If changed is supplied, it specifies whether the affected lines are marked\n"
1726 : : "as having been changed (changed=True) or unchanged (changed=False).");
1727 : :
1728 : : #define _CURSES_WINDOW_TOUCHLINE_METHODDEF \
1729 : : {"touchline", (PyCFunction)_curses_window_touchline, METH_VARARGS, _curses_window_touchline__doc__},
1730 : :
1731 : : static PyObject *
1732 : : _curses_window_touchline_impl(PyCursesWindowObject *self, int start,
1733 : : int count, int group_right_1, int changed);
1734 : :
1735 : : static PyObject *
1736 : 0 : _curses_window_touchline(PyCursesWindowObject *self, PyObject *args)
1737 : : {
1738 : 0 : PyObject *return_value = NULL;
1739 : : int start;
1740 : : int count;
1741 : 0 : int group_right_1 = 0;
1742 : 0 : int changed = 1;
1743 : :
1744 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
1745 : 0 : case 2:
1746 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:touchline", &start, &count)) {
1747 : 0 : goto exit;
1748 : : }
1749 : 0 : break;
1750 : 0 : case 3:
1751 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iip:touchline", &start, &count, &changed)) {
1752 : 0 : goto exit;
1753 : : }
1754 : 0 : group_right_1 = 1;
1755 : 0 : break;
1756 : 0 : default:
1757 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.touchline requires 2 to 3 arguments");
1758 : 0 : goto exit;
1759 : : }
1760 : 0 : return_value = _curses_window_touchline_impl(self, start, count, group_right_1, changed);
1761 : :
1762 : 0 : exit:
1763 : 0 : return return_value;
1764 : : }
1765 : :
1766 : : PyDoc_STRVAR(_curses_window_vline__doc__,
1767 : : "vline([y, x,] ch, n, [attr=_curses.A_NORMAL])\n"
1768 : : "Display a vertical line.\n"
1769 : : "\n"
1770 : : " y\n"
1771 : : " Starting Y-coordinate.\n"
1772 : : " x\n"
1773 : : " Starting X-coordinate.\n"
1774 : : " ch\n"
1775 : : " Character to draw.\n"
1776 : : " n\n"
1777 : : " Line length.\n"
1778 : : " attr\n"
1779 : : " Attributes for the character.");
1780 : :
1781 : : #define _CURSES_WINDOW_VLINE_METHODDEF \
1782 : : {"vline", (PyCFunction)_curses_window_vline, METH_VARARGS, _curses_window_vline__doc__},
1783 : :
1784 : : static PyObject *
1785 : : _curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1,
1786 : : int y, int x, PyObject *ch, int n,
1787 : : int group_right_1, long attr);
1788 : :
1789 : : static PyObject *
1790 : 0 : _curses_window_vline(PyCursesWindowObject *self, PyObject *args)
1791 : : {
1792 : 0 : PyObject *return_value = NULL;
1793 : 0 : int group_left_1 = 0;
1794 : 0 : int y = 0;
1795 : 0 : int x = 0;
1796 : : PyObject *ch;
1797 : : int n;
1798 : 0 : int group_right_1 = 0;
1799 : 0 : long attr = A_NORMAL;
1800 : :
1801 [ # # # # : 0 : switch (PyTuple_GET_SIZE(args)) {
# ]
1802 : 0 : case 2:
1803 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oi:vline", &ch, &n)) {
1804 : 0 : goto exit;
1805 : : }
1806 : 0 : break;
1807 : 0 : case 3:
1808 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "Oil:vline", &ch, &n, &attr)) {
1809 : 0 : goto exit;
1810 : : }
1811 : 0 : group_right_1 = 1;
1812 : 0 : break;
1813 : 0 : case 4:
1814 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOi:vline", &y, &x, &ch, &n)) {
1815 : 0 : goto exit;
1816 : : }
1817 : 0 : group_left_1 = 1;
1818 : 0 : break;
1819 : 0 : case 5:
1820 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiOil:vline", &y, &x, &ch, &n, &attr)) {
1821 : 0 : goto exit;
1822 : : }
1823 : 0 : group_right_1 = 1;
1824 : 0 : group_left_1 = 1;
1825 : 0 : break;
1826 : 0 : default:
1827 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 2 to 5 arguments");
1828 : 0 : goto exit;
1829 : : }
1830 : 0 : return_value = _curses_window_vline_impl(self, group_left_1, y, x, ch, n, group_right_1, attr);
1831 : :
1832 : 0 : exit:
1833 : 0 : return return_value;
1834 : : }
1835 : :
1836 : : #if defined(HAVE_CURSES_FILTER)
1837 : :
1838 : : PyDoc_STRVAR(_curses_filter__doc__,
1839 : : "filter($module, /)\n"
1840 : : "--\n"
1841 : : "\n");
1842 : :
1843 : : #define _CURSES_FILTER_METHODDEF \
1844 : : {"filter", (PyCFunction)_curses_filter, METH_NOARGS, _curses_filter__doc__},
1845 : :
1846 : : static PyObject *
1847 : : _curses_filter_impl(PyObject *module);
1848 : :
1849 : : static PyObject *
1850 : 0 : _curses_filter(PyObject *module, PyObject *Py_UNUSED(ignored))
1851 : : {
1852 : 0 : return _curses_filter_impl(module);
1853 : : }
1854 : :
1855 : : #endif /* defined(HAVE_CURSES_FILTER) */
1856 : :
1857 : : PyDoc_STRVAR(_curses_baudrate__doc__,
1858 : : "baudrate($module, /)\n"
1859 : : "--\n"
1860 : : "\n"
1861 : : "Return the output speed of the terminal in bits per second.");
1862 : :
1863 : : #define _CURSES_BAUDRATE_METHODDEF \
1864 : : {"baudrate", (PyCFunction)_curses_baudrate, METH_NOARGS, _curses_baudrate__doc__},
1865 : :
1866 : : static PyObject *
1867 : : _curses_baudrate_impl(PyObject *module);
1868 : :
1869 : : static PyObject *
1870 : 0 : _curses_baudrate(PyObject *module, PyObject *Py_UNUSED(ignored))
1871 : : {
1872 : 0 : return _curses_baudrate_impl(module);
1873 : : }
1874 : :
1875 : : PyDoc_STRVAR(_curses_beep__doc__,
1876 : : "beep($module, /)\n"
1877 : : "--\n"
1878 : : "\n"
1879 : : "Emit a short attention sound.");
1880 : :
1881 : : #define _CURSES_BEEP_METHODDEF \
1882 : : {"beep", (PyCFunction)_curses_beep, METH_NOARGS, _curses_beep__doc__},
1883 : :
1884 : : static PyObject *
1885 : : _curses_beep_impl(PyObject *module);
1886 : :
1887 : : static PyObject *
1888 : 0 : _curses_beep(PyObject *module, PyObject *Py_UNUSED(ignored))
1889 : : {
1890 : 0 : return _curses_beep_impl(module);
1891 : : }
1892 : :
1893 : : PyDoc_STRVAR(_curses_can_change_color__doc__,
1894 : : "can_change_color($module, /)\n"
1895 : : "--\n"
1896 : : "\n"
1897 : : "Return True if the programmer can change the colors displayed by the terminal.");
1898 : :
1899 : : #define _CURSES_CAN_CHANGE_COLOR_METHODDEF \
1900 : : {"can_change_color", (PyCFunction)_curses_can_change_color, METH_NOARGS, _curses_can_change_color__doc__},
1901 : :
1902 : : static PyObject *
1903 : : _curses_can_change_color_impl(PyObject *module);
1904 : :
1905 : : static PyObject *
1906 : 0 : _curses_can_change_color(PyObject *module, PyObject *Py_UNUSED(ignored))
1907 : : {
1908 : 0 : return _curses_can_change_color_impl(module);
1909 : : }
1910 : :
1911 : : PyDoc_STRVAR(_curses_cbreak__doc__,
1912 : : "cbreak($module, flag=True, /)\n"
1913 : : "--\n"
1914 : : "\n"
1915 : : "Enter cbreak mode.\n"
1916 : : "\n"
1917 : : " flag\n"
1918 : : " If false, the effect is the same as calling nocbreak().\n"
1919 : : "\n"
1920 : : "In cbreak mode (sometimes called \"rare\" mode) normal tty line buffering is\n"
1921 : : "turned off and characters are available to be read one by one. However,\n"
1922 : : "unlike raw mode, special characters (interrupt, quit, suspend, and flow\n"
1923 : : "control) retain their effects on the tty driver and calling program.\n"
1924 : : "Calling first raw() then cbreak() leaves the terminal in cbreak mode.");
1925 : :
1926 : : #define _CURSES_CBREAK_METHODDEF \
1927 : : {"cbreak", _PyCFunction_CAST(_curses_cbreak), METH_FASTCALL, _curses_cbreak__doc__},
1928 : :
1929 : : static PyObject *
1930 : : _curses_cbreak_impl(PyObject *module, int flag);
1931 : :
1932 : : static PyObject *
1933 : 0 : _curses_cbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1934 : : {
1935 : 0 : PyObject *return_value = NULL;
1936 : 0 : int flag = 1;
1937 : :
1938 [ # # # # : 0 : if (!_PyArg_CheckPositional("cbreak", nargs, 0, 1)) {
# # ]
1939 : 0 : goto exit;
1940 : : }
1941 [ # # ]: 0 : if (nargs < 1) {
1942 : 0 : goto skip_optional;
1943 : : }
1944 : 0 : flag = PyObject_IsTrue(args[0]);
1945 [ # # ]: 0 : if (flag < 0) {
1946 : 0 : goto exit;
1947 : : }
1948 : 0 : skip_optional:
1949 : 0 : return_value = _curses_cbreak_impl(module, flag);
1950 : :
1951 : 0 : exit:
1952 : 0 : return return_value;
1953 : : }
1954 : :
1955 : : PyDoc_STRVAR(_curses_color_content__doc__,
1956 : : "color_content($module, color_number, /)\n"
1957 : : "--\n"
1958 : : "\n"
1959 : : "Return the red, green, and blue (RGB) components of the specified color.\n"
1960 : : "\n"
1961 : : " color_number\n"
1962 : : " The number of the color (0 - (COLORS-1)).\n"
1963 : : "\n"
1964 : : "A 3-tuple is returned, containing the R, G, B values for the given color,\n"
1965 : : "which will be between 0 (no component) and 1000 (maximum amount of component).");
1966 : :
1967 : : #define _CURSES_COLOR_CONTENT_METHODDEF \
1968 : : {"color_content", (PyCFunction)_curses_color_content, METH_O, _curses_color_content__doc__},
1969 : :
1970 : : static PyObject *
1971 : : _curses_color_content_impl(PyObject *module, int color_number);
1972 : :
1973 : : static PyObject *
1974 : 0 : _curses_color_content(PyObject *module, PyObject *arg)
1975 : : {
1976 : 0 : PyObject *return_value = NULL;
1977 : : int color_number;
1978 : :
1979 [ # # ]: 0 : if (!color_converter(arg, &color_number)) {
1980 : 0 : goto exit;
1981 : : }
1982 : 0 : return_value = _curses_color_content_impl(module, color_number);
1983 : :
1984 : 0 : exit:
1985 : 0 : return return_value;
1986 : : }
1987 : :
1988 : : PyDoc_STRVAR(_curses_color_pair__doc__,
1989 : : "color_pair($module, pair_number, /)\n"
1990 : : "--\n"
1991 : : "\n"
1992 : : "Return the attribute value for displaying text in the specified color.\n"
1993 : : "\n"
1994 : : " pair_number\n"
1995 : : " The number of the color pair.\n"
1996 : : "\n"
1997 : : "This attribute value can be combined with A_STANDOUT, A_REVERSE, and the\n"
1998 : : "other A_* attributes. pair_number() is the counterpart to this function.");
1999 : :
2000 : : #define _CURSES_COLOR_PAIR_METHODDEF \
2001 : : {"color_pair", (PyCFunction)_curses_color_pair, METH_O, _curses_color_pair__doc__},
2002 : :
2003 : : static PyObject *
2004 : : _curses_color_pair_impl(PyObject *module, int pair_number);
2005 : :
2006 : : static PyObject *
2007 : 0 : _curses_color_pair(PyObject *module, PyObject *arg)
2008 : : {
2009 : 0 : PyObject *return_value = NULL;
2010 : : int pair_number;
2011 : :
2012 : 0 : pair_number = _PyLong_AsInt(arg);
2013 [ # # # # ]: 0 : if (pair_number == -1 && PyErr_Occurred()) {
2014 : 0 : goto exit;
2015 : : }
2016 : 0 : return_value = _curses_color_pair_impl(module, pair_number);
2017 : :
2018 : 0 : exit:
2019 : 0 : return return_value;
2020 : : }
2021 : :
2022 : : PyDoc_STRVAR(_curses_curs_set__doc__,
2023 : : "curs_set($module, visibility, /)\n"
2024 : : "--\n"
2025 : : "\n"
2026 : : "Set the cursor state.\n"
2027 : : "\n"
2028 : : " visibility\n"
2029 : : " 0 for invisible, 1 for normal visible, or 2 for very visible.\n"
2030 : : "\n"
2031 : : "If the terminal supports the visibility requested, the previous cursor\n"
2032 : : "state is returned; otherwise, an exception is raised. On many terminals,\n"
2033 : : "the \"visible\" mode is an underline cursor and the \"very visible\" mode is\n"
2034 : : "a block cursor.");
2035 : :
2036 : : #define _CURSES_CURS_SET_METHODDEF \
2037 : : {"curs_set", (PyCFunction)_curses_curs_set, METH_O, _curses_curs_set__doc__},
2038 : :
2039 : : static PyObject *
2040 : : _curses_curs_set_impl(PyObject *module, int visibility);
2041 : :
2042 : : static PyObject *
2043 : 0 : _curses_curs_set(PyObject *module, PyObject *arg)
2044 : : {
2045 : 0 : PyObject *return_value = NULL;
2046 : : int visibility;
2047 : :
2048 : 0 : visibility = _PyLong_AsInt(arg);
2049 [ # # # # ]: 0 : if (visibility == -1 && PyErr_Occurred()) {
2050 : 0 : goto exit;
2051 : : }
2052 : 0 : return_value = _curses_curs_set_impl(module, visibility);
2053 : :
2054 : 0 : exit:
2055 : 0 : return return_value;
2056 : : }
2057 : :
2058 : : PyDoc_STRVAR(_curses_def_prog_mode__doc__,
2059 : : "def_prog_mode($module, /)\n"
2060 : : "--\n"
2061 : : "\n"
2062 : : "Save the current terminal mode as the \"program\" mode.\n"
2063 : : "\n"
2064 : : "The \"program\" mode is the mode when the running program is using curses.\n"
2065 : : "\n"
2066 : : "Subsequent calls to reset_prog_mode() will restore this mode.");
2067 : :
2068 : : #define _CURSES_DEF_PROG_MODE_METHODDEF \
2069 : : {"def_prog_mode", (PyCFunction)_curses_def_prog_mode, METH_NOARGS, _curses_def_prog_mode__doc__},
2070 : :
2071 : : static PyObject *
2072 : : _curses_def_prog_mode_impl(PyObject *module);
2073 : :
2074 : : static PyObject *
2075 : 0 : _curses_def_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
2076 : : {
2077 : 0 : return _curses_def_prog_mode_impl(module);
2078 : : }
2079 : :
2080 : : PyDoc_STRVAR(_curses_def_shell_mode__doc__,
2081 : : "def_shell_mode($module, /)\n"
2082 : : "--\n"
2083 : : "\n"
2084 : : "Save the current terminal mode as the \"shell\" mode.\n"
2085 : : "\n"
2086 : : "The \"shell\" mode is the mode when the running program is not using curses.\n"
2087 : : "\n"
2088 : : "Subsequent calls to reset_shell_mode() will restore this mode.");
2089 : :
2090 : : #define _CURSES_DEF_SHELL_MODE_METHODDEF \
2091 : : {"def_shell_mode", (PyCFunction)_curses_def_shell_mode, METH_NOARGS, _curses_def_shell_mode__doc__},
2092 : :
2093 : : static PyObject *
2094 : : _curses_def_shell_mode_impl(PyObject *module);
2095 : :
2096 : : static PyObject *
2097 : 0 : _curses_def_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
2098 : : {
2099 : 0 : return _curses_def_shell_mode_impl(module);
2100 : : }
2101 : :
2102 : : PyDoc_STRVAR(_curses_delay_output__doc__,
2103 : : "delay_output($module, ms, /)\n"
2104 : : "--\n"
2105 : : "\n"
2106 : : "Insert a pause in output.\n"
2107 : : "\n"
2108 : : " ms\n"
2109 : : " Duration in milliseconds.");
2110 : :
2111 : : #define _CURSES_DELAY_OUTPUT_METHODDEF \
2112 : : {"delay_output", (PyCFunction)_curses_delay_output, METH_O, _curses_delay_output__doc__},
2113 : :
2114 : : static PyObject *
2115 : : _curses_delay_output_impl(PyObject *module, int ms);
2116 : :
2117 : : static PyObject *
2118 : 0 : _curses_delay_output(PyObject *module, PyObject *arg)
2119 : : {
2120 : 0 : PyObject *return_value = NULL;
2121 : : int ms;
2122 : :
2123 : 0 : ms = _PyLong_AsInt(arg);
2124 [ # # # # ]: 0 : if (ms == -1 && PyErr_Occurred()) {
2125 : 0 : goto exit;
2126 : : }
2127 : 0 : return_value = _curses_delay_output_impl(module, ms);
2128 : :
2129 : 0 : exit:
2130 : 0 : return return_value;
2131 : : }
2132 : :
2133 : : PyDoc_STRVAR(_curses_doupdate__doc__,
2134 : : "doupdate($module, /)\n"
2135 : : "--\n"
2136 : : "\n"
2137 : : "Update the physical screen to match the virtual screen.");
2138 : :
2139 : : #define _CURSES_DOUPDATE_METHODDEF \
2140 : : {"doupdate", (PyCFunction)_curses_doupdate, METH_NOARGS, _curses_doupdate__doc__},
2141 : :
2142 : : static PyObject *
2143 : : _curses_doupdate_impl(PyObject *module);
2144 : :
2145 : : static PyObject *
2146 : 0 : _curses_doupdate(PyObject *module, PyObject *Py_UNUSED(ignored))
2147 : : {
2148 : 0 : return _curses_doupdate_impl(module);
2149 : : }
2150 : :
2151 : : PyDoc_STRVAR(_curses_echo__doc__,
2152 : : "echo($module, flag=True, /)\n"
2153 : : "--\n"
2154 : : "\n"
2155 : : "Enter echo mode.\n"
2156 : : "\n"
2157 : : " flag\n"
2158 : : " If false, the effect is the same as calling noecho().\n"
2159 : : "\n"
2160 : : "In echo mode, each character input is echoed to the screen as it is entered.");
2161 : :
2162 : : #define _CURSES_ECHO_METHODDEF \
2163 : : {"echo", _PyCFunction_CAST(_curses_echo), METH_FASTCALL, _curses_echo__doc__},
2164 : :
2165 : : static PyObject *
2166 : : _curses_echo_impl(PyObject *module, int flag);
2167 : :
2168 : : static PyObject *
2169 : 0 : _curses_echo(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2170 : : {
2171 : 0 : PyObject *return_value = NULL;
2172 : 0 : int flag = 1;
2173 : :
2174 [ # # # # : 0 : if (!_PyArg_CheckPositional("echo", nargs, 0, 1)) {
# # ]
2175 : 0 : goto exit;
2176 : : }
2177 [ # # ]: 0 : if (nargs < 1) {
2178 : 0 : goto skip_optional;
2179 : : }
2180 : 0 : flag = PyObject_IsTrue(args[0]);
2181 [ # # ]: 0 : if (flag < 0) {
2182 : 0 : goto exit;
2183 : : }
2184 : 0 : skip_optional:
2185 : 0 : return_value = _curses_echo_impl(module, flag);
2186 : :
2187 : 0 : exit:
2188 : 0 : return return_value;
2189 : : }
2190 : :
2191 : : PyDoc_STRVAR(_curses_endwin__doc__,
2192 : : "endwin($module, /)\n"
2193 : : "--\n"
2194 : : "\n"
2195 : : "De-initialize the library, and return terminal to normal status.");
2196 : :
2197 : : #define _CURSES_ENDWIN_METHODDEF \
2198 : : {"endwin", (PyCFunction)_curses_endwin, METH_NOARGS, _curses_endwin__doc__},
2199 : :
2200 : : static PyObject *
2201 : : _curses_endwin_impl(PyObject *module);
2202 : :
2203 : : static PyObject *
2204 : 0 : _curses_endwin(PyObject *module, PyObject *Py_UNUSED(ignored))
2205 : : {
2206 : 0 : return _curses_endwin_impl(module);
2207 : : }
2208 : :
2209 : : PyDoc_STRVAR(_curses_erasechar__doc__,
2210 : : "erasechar($module, /)\n"
2211 : : "--\n"
2212 : : "\n"
2213 : : "Return the user\'s current erase character.");
2214 : :
2215 : : #define _CURSES_ERASECHAR_METHODDEF \
2216 : : {"erasechar", (PyCFunction)_curses_erasechar, METH_NOARGS, _curses_erasechar__doc__},
2217 : :
2218 : : static PyObject *
2219 : : _curses_erasechar_impl(PyObject *module);
2220 : :
2221 : : static PyObject *
2222 : 0 : _curses_erasechar(PyObject *module, PyObject *Py_UNUSED(ignored))
2223 : : {
2224 : 0 : return _curses_erasechar_impl(module);
2225 : : }
2226 : :
2227 : : PyDoc_STRVAR(_curses_flash__doc__,
2228 : : "flash($module, /)\n"
2229 : : "--\n"
2230 : : "\n"
2231 : : "Flash the screen.\n"
2232 : : "\n"
2233 : : "That is, change it to reverse-video and then change it back in a short interval.");
2234 : :
2235 : : #define _CURSES_FLASH_METHODDEF \
2236 : : {"flash", (PyCFunction)_curses_flash, METH_NOARGS, _curses_flash__doc__},
2237 : :
2238 : : static PyObject *
2239 : : _curses_flash_impl(PyObject *module);
2240 : :
2241 : : static PyObject *
2242 : 0 : _curses_flash(PyObject *module, PyObject *Py_UNUSED(ignored))
2243 : : {
2244 : 0 : return _curses_flash_impl(module);
2245 : : }
2246 : :
2247 : : PyDoc_STRVAR(_curses_flushinp__doc__,
2248 : : "flushinp($module, /)\n"
2249 : : "--\n"
2250 : : "\n"
2251 : : "Flush all input buffers.\n"
2252 : : "\n"
2253 : : "This throws away any typeahead that has been typed by the user and has not\n"
2254 : : "yet been processed by the program.");
2255 : :
2256 : : #define _CURSES_FLUSHINP_METHODDEF \
2257 : : {"flushinp", (PyCFunction)_curses_flushinp, METH_NOARGS, _curses_flushinp__doc__},
2258 : :
2259 : : static PyObject *
2260 : : _curses_flushinp_impl(PyObject *module);
2261 : :
2262 : : static PyObject *
2263 : 0 : _curses_flushinp(PyObject *module, PyObject *Py_UNUSED(ignored))
2264 : : {
2265 : 0 : return _curses_flushinp_impl(module);
2266 : : }
2267 : :
2268 : : #if defined(getsyx)
2269 : :
2270 : : PyDoc_STRVAR(_curses_getsyx__doc__,
2271 : : "getsyx($module, /)\n"
2272 : : "--\n"
2273 : : "\n"
2274 : : "Return the current coordinates of the virtual screen cursor.\n"
2275 : : "\n"
2276 : : "Return a (y, x) tuple. If leaveok is currently true, return (-1, -1).");
2277 : :
2278 : : #define _CURSES_GETSYX_METHODDEF \
2279 : : {"getsyx", (PyCFunction)_curses_getsyx, METH_NOARGS, _curses_getsyx__doc__},
2280 : :
2281 : : static PyObject *
2282 : : _curses_getsyx_impl(PyObject *module);
2283 : :
2284 : : static PyObject *
2285 : 0 : _curses_getsyx(PyObject *module, PyObject *Py_UNUSED(ignored))
2286 : : {
2287 : 0 : return _curses_getsyx_impl(module);
2288 : : }
2289 : :
2290 : : #endif /* defined(getsyx) */
2291 : :
2292 : : #if defined(NCURSES_MOUSE_VERSION)
2293 : :
2294 : : PyDoc_STRVAR(_curses_getmouse__doc__,
2295 : : "getmouse($module, /)\n"
2296 : : "--\n"
2297 : : "\n"
2298 : : "Retrieve the queued mouse event.\n"
2299 : : "\n"
2300 : : "After getch() returns KEY_MOUSE to signal a mouse event, this function\n"
2301 : : "returns a 5-tuple (id, x, y, z, bstate).");
2302 : :
2303 : : #define _CURSES_GETMOUSE_METHODDEF \
2304 : : {"getmouse", (PyCFunction)_curses_getmouse, METH_NOARGS, _curses_getmouse__doc__},
2305 : :
2306 : : static PyObject *
2307 : : _curses_getmouse_impl(PyObject *module);
2308 : :
2309 : : static PyObject *
2310 : 0 : _curses_getmouse(PyObject *module, PyObject *Py_UNUSED(ignored))
2311 : : {
2312 : 0 : return _curses_getmouse_impl(module);
2313 : : }
2314 : :
2315 : : #endif /* defined(NCURSES_MOUSE_VERSION) */
2316 : :
2317 : : #if defined(NCURSES_MOUSE_VERSION)
2318 : :
2319 : : PyDoc_STRVAR(_curses_ungetmouse__doc__,
2320 : : "ungetmouse($module, id, x, y, z, bstate, /)\n"
2321 : : "--\n"
2322 : : "\n"
2323 : : "Push a KEY_MOUSE event onto the input queue.\n"
2324 : : "\n"
2325 : : "The following getmouse() will return the given state data.");
2326 : :
2327 : : #define _CURSES_UNGETMOUSE_METHODDEF \
2328 : : {"ungetmouse", _PyCFunction_CAST(_curses_ungetmouse), METH_FASTCALL, _curses_ungetmouse__doc__},
2329 : :
2330 : : static PyObject *
2331 : : _curses_ungetmouse_impl(PyObject *module, short id, int x, int y, int z,
2332 : : unsigned long bstate);
2333 : :
2334 : : static PyObject *
2335 : 0 : _curses_ungetmouse(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2336 : : {
2337 : 0 : PyObject *return_value = NULL;
2338 : : short id;
2339 : : int x;
2340 : : int y;
2341 : : int z;
2342 : : unsigned long bstate;
2343 : :
2344 [ # # # # : 0 : if (!_PyArg_CheckPositional("ungetmouse", nargs, 5, 5)) {
# # ]
2345 : 0 : goto exit;
2346 : : }
2347 : : {
2348 : 0 : long ival = PyLong_AsLong(args[0]);
2349 [ # # # # ]: 0 : if (ival == -1 && PyErr_Occurred()) {
2350 : 0 : goto exit;
2351 : : }
2352 [ # # ]: 0 : else if (ival < SHRT_MIN) {
2353 : 0 : PyErr_SetString(PyExc_OverflowError,
2354 : : "signed short integer is less than minimum");
2355 : 0 : goto exit;
2356 : : }
2357 [ # # ]: 0 : else if (ival > SHRT_MAX) {
2358 : 0 : PyErr_SetString(PyExc_OverflowError,
2359 : : "signed short integer is greater than maximum");
2360 : 0 : goto exit;
2361 : : }
2362 : : else {
2363 : 0 : id = (short) ival;
2364 : : }
2365 : : }
2366 : 0 : x = _PyLong_AsInt(args[1]);
2367 [ # # # # ]: 0 : if (x == -1 && PyErr_Occurred()) {
2368 : 0 : goto exit;
2369 : : }
2370 : 0 : y = _PyLong_AsInt(args[2]);
2371 [ # # # # ]: 0 : if (y == -1 && PyErr_Occurred()) {
2372 : 0 : goto exit;
2373 : : }
2374 : 0 : z = _PyLong_AsInt(args[3]);
2375 [ # # # # ]: 0 : if (z == -1 && PyErr_Occurred()) {
2376 : 0 : goto exit;
2377 : : }
2378 [ # # ]: 0 : if (!PyLong_Check(args[4])) {
2379 : 0 : _PyArg_BadArgument("ungetmouse", "argument 5", "int", args[4]);
2380 : 0 : goto exit;
2381 : : }
2382 : 0 : bstate = PyLong_AsUnsignedLongMask(args[4]);
2383 : 0 : return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate);
2384 : :
2385 : 0 : exit:
2386 : 0 : return return_value;
2387 : : }
2388 : :
2389 : : #endif /* defined(NCURSES_MOUSE_VERSION) */
2390 : :
2391 : : PyDoc_STRVAR(_curses_getwin__doc__,
2392 : : "getwin($module, file, /)\n"
2393 : : "--\n"
2394 : : "\n"
2395 : : "Read window related data stored in the file by an earlier putwin() call.\n"
2396 : : "\n"
2397 : : "The routine then creates and initializes a new window using that data,\n"
2398 : : "returning the new window object.");
2399 : :
2400 : : #define _CURSES_GETWIN_METHODDEF \
2401 : : {"getwin", (PyCFunction)_curses_getwin, METH_O, _curses_getwin__doc__},
2402 : :
2403 : : PyDoc_STRVAR(_curses_halfdelay__doc__,
2404 : : "halfdelay($module, tenths, /)\n"
2405 : : "--\n"
2406 : : "\n"
2407 : : "Enter half-delay mode.\n"
2408 : : "\n"
2409 : : " tenths\n"
2410 : : " Maximal blocking delay in tenths of seconds (1 - 255).\n"
2411 : : "\n"
2412 : : "Use nocbreak() to leave half-delay mode.");
2413 : :
2414 : : #define _CURSES_HALFDELAY_METHODDEF \
2415 : : {"halfdelay", (PyCFunction)_curses_halfdelay, METH_O, _curses_halfdelay__doc__},
2416 : :
2417 : : static PyObject *
2418 : : _curses_halfdelay_impl(PyObject *module, unsigned char tenths);
2419 : :
2420 : : static PyObject *
2421 : 0 : _curses_halfdelay(PyObject *module, PyObject *arg)
2422 : : {
2423 : 0 : PyObject *return_value = NULL;
2424 : : unsigned char tenths;
2425 : :
2426 : : {
2427 : 0 : long ival = PyLong_AsLong(arg);
2428 [ # # # # ]: 0 : if (ival == -1 && PyErr_Occurred()) {
2429 : 0 : goto exit;
2430 : : }
2431 [ # # ]: 0 : else if (ival < 0) {
2432 : 0 : PyErr_SetString(PyExc_OverflowError,
2433 : : "unsigned byte integer is less than minimum");
2434 : 0 : goto exit;
2435 : : }
2436 [ # # ]: 0 : else if (ival > UCHAR_MAX) {
2437 : 0 : PyErr_SetString(PyExc_OverflowError,
2438 : : "unsigned byte integer is greater than maximum");
2439 : 0 : goto exit;
2440 : : }
2441 : : else {
2442 : 0 : tenths = (unsigned char) ival;
2443 : : }
2444 : : }
2445 : 0 : return_value = _curses_halfdelay_impl(module, tenths);
2446 : :
2447 : 0 : exit:
2448 : 0 : return return_value;
2449 : : }
2450 : :
2451 : : PyDoc_STRVAR(_curses_has_colors__doc__,
2452 : : "has_colors($module, /)\n"
2453 : : "--\n"
2454 : : "\n"
2455 : : "Return True if the terminal can display colors; otherwise, return False.");
2456 : :
2457 : : #define _CURSES_HAS_COLORS_METHODDEF \
2458 : : {"has_colors", (PyCFunction)_curses_has_colors, METH_NOARGS, _curses_has_colors__doc__},
2459 : :
2460 : : static PyObject *
2461 : : _curses_has_colors_impl(PyObject *module);
2462 : :
2463 : : static PyObject *
2464 : 0 : _curses_has_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
2465 : : {
2466 : 0 : return _curses_has_colors_impl(module);
2467 : : }
2468 : :
2469 : : PyDoc_STRVAR(_curses_has_ic__doc__,
2470 : : "has_ic($module, /)\n"
2471 : : "--\n"
2472 : : "\n"
2473 : : "Return True if the terminal has insert- and delete-character capabilities.");
2474 : :
2475 : : #define _CURSES_HAS_IC_METHODDEF \
2476 : : {"has_ic", (PyCFunction)_curses_has_ic, METH_NOARGS, _curses_has_ic__doc__},
2477 : :
2478 : : static PyObject *
2479 : : _curses_has_ic_impl(PyObject *module);
2480 : :
2481 : : static PyObject *
2482 : 0 : _curses_has_ic(PyObject *module, PyObject *Py_UNUSED(ignored))
2483 : : {
2484 : 0 : return _curses_has_ic_impl(module);
2485 : : }
2486 : :
2487 : : PyDoc_STRVAR(_curses_has_il__doc__,
2488 : : "has_il($module, /)\n"
2489 : : "--\n"
2490 : : "\n"
2491 : : "Return True if the terminal has insert- and delete-line capabilities.");
2492 : :
2493 : : #define _CURSES_HAS_IL_METHODDEF \
2494 : : {"has_il", (PyCFunction)_curses_has_il, METH_NOARGS, _curses_has_il__doc__},
2495 : :
2496 : : static PyObject *
2497 : : _curses_has_il_impl(PyObject *module);
2498 : :
2499 : : static PyObject *
2500 : 0 : _curses_has_il(PyObject *module, PyObject *Py_UNUSED(ignored))
2501 : : {
2502 : 0 : return _curses_has_il_impl(module);
2503 : : }
2504 : :
2505 : : #if defined(HAVE_CURSES_HAS_KEY)
2506 : :
2507 : : PyDoc_STRVAR(_curses_has_key__doc__,
2508 : : "has_key($module, key, /)\n"
2509 : : "--\n"
2510 : : "\n"
2511 : : "Return True if the current terminal type recognizes a key with that value.\n"
2512 : : "\n"
2513 : : " key\n"
2514 : : " Key number.");
2515 : :
2516 : : #define _CURSES_HAS_KEY_METHODDEF \
2517 : : {"has_key", (PyCFunction)_curses_has_key, METH_O, _curses_has_key__doc__},
2518 : :
2519 : : static PyObject *
2520 : : _curses_has_key_impl(PyObject *module, int key);
2521 : :
2522 : : static PyObject *
2523 : 0 : _curses_has_key(PyObject *module, PyObject *arg)
2524 : : {
2525 : 0 : PyObject *return_value = NULL;
2526 : : int key;
2527 : :
2528 : 0 : key = _PyLong_AsInt(arg);
2529 [ # # # # ]: 0 : if (key == -1 && PyErr_Occurred()) {
2530 : 0 : goto exit;
2531 : : }
2532 : 0 : return_value = _curses_has_key_impl(module, key);
2533 : :
2534 : 0 : exit:
2535 : 0 : return return_value;
2536 : : }
2537 : :
2538 : : #endif /* defined(HAVE_CURSES_HAS_KEY) */
2539 : :
2540 : : PyDoc_STRVAR(_curses_init_color__doc__,
2541 : : "init_color($module, color_number, r, g, b, /)\n"
2542 : : "--\n"
2543 : : "\n"
2544 : : "Change the definition of a color.\n"
2545 : : "\n"
2546 : : " color_number\n"
2547 : : " The number of the color to be changed (0 - (COLORS-1)).\n"
2548 : : " r\n"
2549 : : " Red component (0 - 1000).\n"
2550 : : " g\n"
2551 : : " Green component (0 - 1000).\n"
2552 : : " b\n"
2553 : : " Blue component (0 - 1000).\n"
2554 : : "\n"
2555 : : "When init_color() is used, all occurrences of that color on the screen\n"
2556 : : "immediately change to the new definition. This function is a no-op on\n"
2557 : : "most terminals; it is active only if can_change_color() returns true.");
2558 : :
2559 : : #define _CURSES_INIT_COLOR_METHODDEF \
2560 : : {"init_color", _PyCFunction_CAST(_curses_init_color), METH_FASTCALL, _curses_init_color__doc__},
2561 : :
2562 : : static PyObject *
2563 : : _curses_init_color_impl(PyObject *module, int color_number, short r, short g,
2564 : : short b);
2565 : :
2566 : : static PyObject *
2567 : 0 : _curses_init_color(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2568 : : {
2569 : 0 : PyObject *return_value = NULL;
2570 : : int color_number;
2571 : : short r;
2572 : : short g;
2573 : : short b;
2574 : :
2575 [ # # # # : 0 : if (!_PyArg_CheckPositional("init_color", nargs, 4, 4)) {
# # ]
2576 : 0 : goto exit;
2577 : : }
2578 [ # # ]: 0 : if (!color_converter(args[0], &color_number)) {
2579 : 0 : goto exit;
2580 : : }
2581 [ # # ]: 0 : if (!component_converter(args[1], &r)) {
2582 : 0 : goto exit;
2583 : : }
2584 [ # # ]: 0 : if (!component_converter(args[2], &g)) {
2585 : 0 : goto exit;
2586 : : }
2587 [ # # ]: 0 : if (!component_converter(args[3], &b)) {
2588 : 0 : goto exit;
2589 : : }
2590 : 0 : return_value = _curses_init_color_impl(module, color_number, r, g, b);
2591 : :
2592 : 0 : exit:
2593 : 0 : return return_value;
2594 : : }
2595 : :
2596 : : PyDoc_STRVAR(_curses_init_pair__doc__,
2597 : : "init_pair($module, pair_number, fg, bg, /)\n"
2598 : : "--\n"
2599 : : "\n"
2600 : : "Change the definition of a color-pair.\n"
2601 : : "\n"
2602 : : " pair_number\n"
2603 : : " The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)).\n"
2604 : : " fg\n"
2605 : : " Foreground color number (-1 - (COLORS-1)).\n"
2606 : : " bg\n"
2607 : : " Background color number (-1 - (COLORS-1)).\n"
2608 : : "\n"
2609 : : "If the color-pair was previously initialized, the screen is refreshed and\n"
2610 : : "all occurrences of that color-pair are changed to the new definition.");
2611 : :
2612 : : #define _CURSES_INIT_PAIR_METHODDEF \
2613 : : {"init_pair", _PyCFunction_CAST(_curses_init_pair), METH_FASTCALL, _curses_init_pair__doc__},
2614 : :
2615 : : static PyObject *
2616 : : _curses_init_pair_impl(PyObject *module, int pair_number, int fg, int bg);
2617 : :
2618 : : static PyObject *
2619 : 0 : _curses_init_pair(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2620 : : {
2621 : 0 : PyObject *return_value = NULL;
2622 : : int pair_number;
2623 : : int fg;
2624 : : int bg;
2625 : :
2626 [ # # # # : 0 : if (!_PyArg_CheckPositional("init_pair", nargs, 3, 3)) {
# # ]
2627 : 0 : goto exit;
2628 : : }
2629 [ # # ]: 0 : if (!pair_converter(args[0], &pair_number)) {
2630 : 0 : goto exit;
2631 : : }
2632 [ # # ]: 0 : if (!color_allow_default_converter(args[1], &fg)) {
2633 : 0 : goto exit;
2634 : : }
2635 [ # # ]: 0 : if (!color_allow_default_converter(args[2], &bg)) {
2636 : 0 : goto exit;
2637 : : }
2638 : 0 : return_value = _curses_init_pair_impl(module, pair_number, fg, bg);
2639 : :
2640 : 0 : exit:
2641 : 0 : return return_value;
2642 : : }
2643 : :
2644 : : PyDoc_STRVAR(_curses_initscr__doc__,
2645 : : "initscr($module, /)\n"
2646 : : "--\n"
2647 : : "\n"
2648 : : "Initialize the library.\n"
2649 : : "\n"
2650 : : "Return a WindowObject which represents the whole screen.");
2651 : :
2652 : : #define _CURSES_INITSCR_METHODDEF \
2653 : : {"initscr", (PyCFunction)_curses_initscr, METH_NOARGS, _curses_initscr__doc__},
2654 : :
2655 : : static PyObject *
2656 : : _curses_initscr_impl(PyObject *module);
2657 : :
2658 : : static PyObject *
2659 : 0 : _curses_initscr(PyObject *module, PyObject *Py_UNUSED(ignored))
2660 : : {
2661 : 0 : return _curses_initscr_impl(module);
2662 : : }
2663 : :
2664 : : PyDoc_STRVAR(_curses_setupterm__doc__,
2665 : : "setupterm($module, /, term=None, fd=-1)\n"
2666 : : "--\n"
2667 : : "\n"
2668 : : "Initialize the terminal.\n"
2669 : : "\n"
2670 : : " term\n"
2671 : : " Terminal name.\n"
2672 : : " If omitted, the value of the TERM environment variable will be used.\n"
2673 : : " fd\n"
2674 : : " File descriptor to which any initialization sequences will be sent.\n"
2675 : : " If not supplied, the file descriptor for sys.stdout will be used.");
2676 : :
2677 : : #define _CURSES_SETUPTERM_METHODDEF \
2678 : : {"setupterm", _PyCFunction_CAST(_curses_setupterm), METH_FASTCALL|METH_KEYWORDS, _curses_setupterm__doc__},
2679 : :
2680 : : static PyObject *
2681 : : _curses_setupterm_impl(PyObject *module, const char *term, int fd);
2682 : :
2683 : : static PyObject *
2684 : 0 : _curses_setupterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
2685 : : {
2686 : 0 : PyObject *return_value = NULL;
2687 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
2688 : :
2689 : : #define NUM_KEYWORDS 2
2690 : : static struct {
2691 : : PyGC_Head _this_is_not_used;
2692 : : PyObject_VAR_HEAD
2693 : : PyObject *ob_item[NUM_KEYWORDS];
2694 : : } _kwtuple = {
2695 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
2696 : : .ob_item = { &_Py_ID(term), &_Py_ID(fd), },
2697 : : };
2698 : : #undef NUM_KEYWORDS
2699 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
2700 : :
2701 : : #else // !Py_BUILD_CORE
2702 : : # define KWTUPLE NULL
2703 : : #endif // !Py_BUILD_CORE
2704 : :
2705 : : static const char * const _keywords[] = {"term", "fd", NULL};
2706 : : static _PyArg_Parser _parser = {
2707 : : .keywords = _keywords,
2708 : : .fname = "setupterm",
2709 : : .kwtuple = KWTUPLE,
2710 : : };
2711 : : #undef KWTUPLE
2712 : : PyObject *argsbuf[2];
2713 [ # # ]: 0 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
2714 : 0 : const char *term = NULL;
2715 : 0 : int fd = -1;
2716 : :
2717 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 2, 0, argsbuf);
# # # # ]
2718 [ # # ]: 0 : if (!args) {
2719 : 0 : goto exit;
2720 : : }
2721 [ # # ]: 0 : if (!noptargs) {
2722 : 0 : goto skip_optional_pos;
2723 : : }
2724 [ # # ]: 0 : if (args[0]) {
2725 [ # # ]: 0 : if (args[0] == Py_None) {
2726 : 0 : term = NULL;
2727 : : }
2728 [ # # ]: 0 : else if (PyUnicode_Check(args[0])) {
2729 : : Py_ssize_t term_length;
2730 : 0 : term = PyUnicode_AsUTF8AndSize(args[0], &term_length);
2731 [ # # ]: 0 : if (term == NULL) {
2732 : 0 : goto exit;
2733 : : }
2734 [ # # ]: 0 : if (strlen(term) != (size_t)term_length) {
2735 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character");
2736 : 0 : goto exit;
2737 : : }
2738 : : }
2739 : : else {
2740 : 0 : _PyArg_BadArgument("setupterm", "argument 'term'", "str or None", args[0]);
2741 : 0 : goto exit;
2742 : : }
2743 [ # # ]: 0 : if (!--noptargs) {
2744 : 0 : goto skip_optional_pos;
2745 : : }
2746 : : }
2747 : 0 : fd = _PyLong_AsInt(args[1]);
2748 [ # # # # ]: 0 : if (fd == -1 && PyErr_Occurred()) {
2749 : 0 : goto exit;
2750 : : }
2751 : 0 : skip_optional_pos:
2752 : 0 : return_value = _curses_setupterm_impl(module, term, fd);
2753 : :
2754 : 0 : exit:
2755 : 0 : return return_value;
2756 : : }
2757 : :
2758 : : #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2759 : :
2760 : : PyDoc_STRVAR(_curses_get_escdelay__doc__,
2761 : : "get_escdelay($module, /)\n"
2762 : : "--\n"
2763 : : "\n"
2764 : : "Gets the curses ESCDELAY setting.\n"
2765 : : "\n"
2766 : : "Gets the number of milliseconds to wait after reading an escape character,\n"
2767 : : "to distinguish between an individual escape character entered on the\n"
2768 : : "keyboard from escape sequences sent by cursor and function keys.");
2769 : :
2770 : : #define _CURSES_GET_ESCDELAY_METHODDEF \
2771 : : {"get_escdelay", (PyCFunction)_curses_get_escdelay, METH_NOARGS, _curses_get_escdelay__doc__},
2772 : :
2773 : : static PyObject *
2774 : : _curses_get_escdelay_impl(PyObject *module);
2775 : :
2776 : : static PyObject *
2777 : 0 : _curses_get_escdelay(PyObject *module, PyObject *Py_UNUSED(ignored))
2778 : : {
2779 : 0 : return _curses_get_escdelay_impl(module);
2780 : : }
2781 : :
2782 : : #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2783 : :
2784 : : #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2785 : :
2786 : : PyDoc_STRVAR(_curses_set_escdelay__doc__,
2787 : : "set_escdelay($module, ms, /)\n"
2788 : : "--\n"
2789 : : "\n"
2790 : : "Sets the curses ESCDELAY setting.\n"
2791 : : "\n"
2792 : : " ms\n"
2793 : : " length of the delay in milliseconds.\n"
2794 : : "\n"
2795 : : "Sets the number of milliseconds to wait after reading an escape character,\n"
2796 : : "to distinguish between an individual escape character entered on the\n"
2797 : : "keyboard from escape sequences sent by cursor and function keys.");
2798 : :
2799 : : #define _CURSES_SET_ESCDELAY_METHODDEF \
2800 : : {"set_escdelay", (PyCFunction)_curses_set_escdelay, METH_O, _curses_set_escdelay__doc__},
2801 : :
2802 : : static PyObject *
2803 : : _curses_set_escdelay_impl(PyObject *module, int ms);
2804 : :
2805 : : static PyObject *
2806 : 0 : _curses_set_escdelay(PyObject *module, PyObject *arg)
2807 : : {
2808 : 0 : PyObject *return_value = NULL;
2809 : : int ms;
2810 : :
2811 : 0 : ms = _PyLong_AsInt(arg);
2812 [ # # # # ]: 0 : if (ms == -1 && PyErr_Occurred()) {
2813 : 0 : goto exit;
2814 : : }
2815 : 0 : return_value = _curses_set_escdelay_impl(module, ms);
2816 : :
2817 : 0 : exit:
2818 : 0 : return return_value;
2819 : : }
2820 : :
2821 : : #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2822 : :
2823 : : #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2824 : :
2825 : : PyDoc_STRVAR(_curses_get_tabsize__doc__,
2826 : : "get_tabsize($module, /)\n"
2827 : : "--\n"
2828 : : "\n"
2829 : : "Gets the curses TABSIZE setting.\n"
2830 : : "\n"
2831 : : "Gets the number of columns used by the curses library when converting a tab\n"
2832 : : "character to spaces as it adds the tab to a window.");
2833 : :
2834 : : #define _CURSES_GET_TABSIZE_METHODDEF \
2835 : : {"get_tabsize", (PyCFunction)_curses_get_tabsize, METH_NOARGS, _curses_get_tabsize__doc__},
2836 : :
2837 : : static PyObject *
2838 : : _curses_get_tabsize_impl(PyObject *module);
2839 : :
2840 : : static PyObject *
2841 : 0 : _curses_get_tabsize(PyObject *module, PyObject *Py_UNUSED(ignored))
2842 : : {
2843 : 0 : return _curses_get_tabsize_impl(module);
2844 : : }
2845 : :
2846 : : #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2847 : :
2848 : : #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2849 : :
2850 : : PyDoc_STRVAR(_curses_set_tabsize__doc__,
2851 : : "set_tabsize($module, size, /)\n"
2852 : : "--\n"
2853 : : "\n"
2854 : : "Sets the curses TABSIZE setting.\n"
2855 : : "\n"
2856 : : " size\n"
2857 : : " rendered cell width of a tab character.\n"
2858 : : "\n"
2859 : : "Sets the number of columns used by the curses library when converting a tab\n"
2860 : : "character to spaces as it adds the tab to a window.");
2861 : :
2862 : : #define _CURSES_SET_TABSIZE_METHODDEF \
2863 : : {"set_tabsize", (PyCFunction)_curses_set_tabsize, METH_O, _curses_set_tabsize__doc__},
2864 : :
2865 : : static PyObject *
2866 : : _curses_set_tabsize_impl(PyObject *module, int size);
2867 : :
2868 : : static PyObject *
2869 : 0 : _curses_set_tabsize(PyObject *module, PyObject *arg)
2870 : : {
2871 : 0 : PyObject *return_value = NULL;
2872 : : int size;
2873 : :
2874 : 0 : size = _PyLong_AsInt(arg);
2875 [ # # # # ]: 0 : if (size == -1 && PyErr_Occurred()) {
2876 : 0 : goto exit;
2877 : : }
2878 : 0 : return_value = _curses_set_tabsize_impl(module, size);
2879 : :
2880 : 0 : exit:
2881 : 0 : return return_value;
2882 : : }
2883 : :
2884 : : #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2885 : :
2886 : : PyDoc_STRVAR(_curses_intrflush__doc__,
2887 : : "intrflush($module, flag, /)\n"
2888 : : "--\n"
2889 : : "\n");
2890 : :
2891 : : #define _CURSES_INTRFLUSH_METHODDEF \
2892 : : {"intrflush", (PyCFunction)_curses_intrflush, METH_O, _curses_intrflush__doc__},
2893 : :
2894 : : static PyObject *
2895 : : _curses_intrflush_impl(PyObject *module, int flag);
2896 : :
2897 : : static PyObject *
2898 : 0 : _curses_intrflush(PyObject *module, PyObject *arg)
2899 : : {
2900 : 0 : PyObject *return_value = NULL;
2901 : : int flag;
2902 : :
2903 : 0 : flag = PyObject_IsTrue(arg);
2904 [ # # ]: 0 : if (flag < 0) {
2905 : 0 : goto exit;
2906 : : }
2907 : 0 : return_value = _curses_intrflush_impl(module, flag);
2908 : :
2909 : 0 : exit:
2910 : 0 : return return_value;
2911 : : }
2912 : :
2913 : : PyDoc_STRVAR(_curses_isendwin__doc__,
2914 : : "isendwin($module, /)\n"
2915 : : "--\n"
2916 : : "\n"
2917 : : "Return True if endwin() has been called.");
2918 : :
2919 : : #define _CURSES_ISENDWIN_METHODDEF \
2920 : : {"isendwin", (PyCFunction)_curses_isendwin, METH_NOARGS, _curses_isendwin__doc__},
2921 : :
2922 : : static PyObject *
2923 : : _curses_isendwin_impl(PyObject *module);
2924 : :
2925 : : static PyObject *
2926 : 0 : _curses_isendwin(PyObject *module, PyObject *Py_UNUSED(ignored))
2927 : : {
2928 : 0 : return _curses_isendwin_impl(module);
2929 : : }
2930 : :
2931 : : #if defined(HAVE_CURSES_IS_TERM_RESIZED)
2932 : :
2933 : : PyDoc_STRVAR(_curses_is_term_resized__doc__,
2934 : : "is_term_resized($module, nlines, ncols, /)\n"
2935 : : "--\n"
2936 : : "\n"
2937 : : "Return True if resize_term() would modify the window structure, False otherwise.\n"
2938 : : "\n"
2939 : : " nlines\n"
2940 : : " Height.\n"
2941 : : " ncols\n"
2942 : : " Width.");
2943 : :
2944 : : #define _CURSES_IS_TERM_RESIZED_METHODDEF \
2945 : : {"is_term_resized", _PyCFunction_CAST(_curses_is_term_resized), METH_FASTCALL, _curses_is_term_resized__doc__},
2946 : :
2947 : : static PyObject *
2948 : : _curses_is_term_resized_impl(PyObject *module, int nlines, int ncols);
2949 : :
2950 : : static PyObject *
2951 : 0 : _curses_is_term_resized(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2952 : : {
2953 : 0 : PyObject *return_value = NULL;
2954 : : int nlines;
2955 : : int ncols;
2956 : :
2957 [ # # # # : 0 : if (!_PyArg_CheckPositional("is_term_resized", nargs, 2, 2)) {
# # ]
2958 : 0 : goto exit;
2959 : : }
2960 : 0 : nlines = _PyLong_AsInt(args[0]);
2961 [ # # # # ]: 0 : if (nlines == -1 && PyErr_Occurred()) {
2962 : 0 : goto exit;
2963 : : }
2964 : 0 : ncols = _PyLong_AsInt(args[1]);
2965 [ # # # # ]: 0 : if (ncols == -1 && PyErr_Occurred()) {
2966 : 0 : goto exit;
2967 : : }
2968 : 0 : return_value = _curses_is_term_resized_impl(module, nlines, ncols);
2969 : :
2970 : 0 : exit:
2971 : 0 : return return_value;
2972 : : }
2973 : :
2974 : : #endif /* defined(HAVE_CURSES_IS_TERM_RESIZED) */
2975 : :
2976 : : PyDoc_STRVAR(_curses_keyname__doc__,
2977 : : "keyname($module, key, /)\n"
2978 : : "--\n"
2979 : : "\n"
2980 : : "Return the name of specified key.\n"
2981 : : "\n"
2982 : : " key\n"
2983 : : " Key number.");
2984 : :
2985 : : #define _CURSES_KEYNAME_METHODDEF \
2986 : : {"keyname", (PyCFunction)_curses_keyname, METH_O, _curses_keyname__doc__},
2987 : :
2988 : : static PyObject *
2989 : : _curses_keyname_impl(PyObject *module, int key);
2990 : :
2991 : : static PyObject *
2992 : 0 : _curses_keyname(PyObject *module, PyObject *arg)
2993 : : {
2994 : 0 : PyObject *return_value = NULL;
2995 : : int key;
2996 : :
2997 : 0 : key = _PyLong_AsInt(arg);
2998 [ # # # # ]: 0 : if (key == -1 && PyErr_Occurred()) {
2999 : 0 : goto exit;
3000 : : }
3001 : 0 : return_value = _curses_keyname_impl(module, key);
3002 : :
3003 : 0 : exit:
3004 : 0 : return return_value;
3005 : : }
3006 : :
3007 : : PyDoc_STRVAR(_curses_killchar__doc__,
3008 : : "killchar($module, /)\n"
3009 : : "--\n"
3010 : : "\n"
3011 : : "Return the user\'s current line kill character.");
3012 : :
3013 : : #define _CURSES_KILLCHAR_METHODDEF \
3014 : : {"killchar", (PyCFunction)_curses_killchar, METH_NOARGS, _curses_killchar__doc__},
3015 : :
3016 : : static PyObject *
3017 : : _curses_killchar_impl(PyObject *module);
3018 : :
3019 : : static PyObject *
3020 : 0 : _curses_killchar(PyObject *module, PyObject *Py_UNUSED(ignored))
3021 : : {
3022 : 0 : return _curses_killchar_impl(module);
3023 : : }
3024 : :
3025 : : PyDoc_STRVAR(_curses_longname__doc__,
3026 : : "longname($module, /)\n"
3027 : : "--\n"
3028 : : "\n"
3029 : : "Return the terminfo long name field describing the current terminal.\n"
3030 : : "\n"
3031 : : "The maximum length of a verbose description is 128 characters. It is defined\n"
3032 : : "only after the call to initscr().");
3033 : :
3034 : : #define _CURSES_LONGNAME_METHODDEF \
3035 : : {"longname", (PyCFunction)_curses_longname, METH_NOARGS, _curses_longname__doc__},
3036 : :
3037 : : static PyObject *
3038 : : _curses_longname_impl(PyObject *module);
3039 : :
3040 : : static PyObject *
3041 : 0 : _curses_longname(PyObject *module, PyObject *Py_UNUSED(ignored))
3042 : : {
3043 : 0 : return _curses_longname_impl(module);
3044 : : }
3045 : :
3046 : : PyDoc_STRVAR(_curses_meta__doc__,
3047 : : "meta($module, yes, /)\n"
3048 : : "--\n"
3049 : : "\n"
3050 : : "Enable/disable meta keys.\n"
3051 : : "\n"
3052 : : "If yes is True, allow 8-bit characters to be input. If yes is False,\n"
3053 : : "allow only 7-bit characters.");
3054 : :
3055 : : #define _CURSES_META_METHODDEF \
3056 : : {"meta", (PyCFunction)_curses_meta, METH_O, _curses_meta__doc__},
3057 : :
3058 : : static PyObject *
3059 : : _curses_meta_impl(PyObject *module, int yes);
3060 : :
3061 : : static PyObject *
3062 : 0 : _curses_meta(PyObject *module, PyObject *arg)
3063 : : {
3064 : 0 : PyObject *return_value = NULL;
3065 : : int yes;
3066 : :
3067 : 0 : yes = PyObject_IsTrue(arg);
3068 [ # # ]: 0 : if (yes < 0) {
3069 : 0 : goto exit;
3070 : : }
3071 : 0 : return_value = _curses_meta_impl(module, yes);
3072 : :
3073 : 0 : exit:
3074 : 0 : return return_value;
3075 : : }
3076 : :
3077 : : #if defined(NCURSES_MOUSE_VERSION)
3078 : :
3079 : : PyDoc_STRVAR(_curses_mouseinterval__doc__,
3080 : : "mouseinterval($module, interval, /)\n"
3081 : : "--\n"
3082 : : "\n"
3083 : : "Set and retrieve the maximum time between press and release in a click.\n"
3084 : : "\n"
3085 : : " interval\n"
3086 : : " Time in milliseconds.\n"
3087 : : "\n"
3088 : : "Set the maximum time that can elapse between press and release events in\n"
3089 : : "order for them to be recognized as a click, and return the previous interval\n"
3090 : : "value.");
3091 : :
3092 : : #define _CURSES_MOUSEINTERVAL_METHODDEF \
3093 : : {"mouseinterval", (PyCFunction)_curses_mouseinterval, METH_O, _curses_mouseinterval__doc__},
3094 : :
3095 : : static PyObject *
3096 : : _curses_mouseinterval_impl(PyObject *module, int interval);
3097 : :
3098 : : static PyObject *
3099 : 0 : _curses_mouseinterval(PyObject *module, PyObject *arg)
3100 : : {
3101 : 0 : PyObject *return_value = NULL;
3102 : : int interval;
3103 : :
3104 : 0 : interval = _PyLong_AsInt(arg);
3105 [ # # # # ]: 0 : if (interval == -1 && PyErr_Occurred()) {
3106 : 0 : goto exit;
3107 : : }
3108 : 0 : return_value = _curses_mouseinterval_impl(module, interval);
3109 : :
3110 : 0 : exit:
3111 : 0 : return return_value;
3112 : : }
3113 : :
3114 : : #endif /* defined(NCURSES_MOUSE_VERSION) */
3115 : :
3116 : : #if defined(NCURSES_MOUSE_VERSION)
3117 : :
3118 : : PyDoc_STRVAR(_curses_mousemask__doc__,
3119 : : "mousemask($module, newmask, /)\n"
3120 : : "--\n"
3121 : : "\n"
3122 : : "Set the mouse events to be reported, and return a tuple (availmask, oldmask).\n"
3123 : : "\n"
3124 : : "Return a tuple (availmask, oldmask). availmask indicates which of the\n"
3125 : : "specified mouse events can be reported; on complete failure it returns 0.\n"
3126 : : "oldmask is the previous value of the given window\'s mouse event mask.\n"
3127 : : "If this function is never called, no mouse events are ever reported.");
3128 : :
3129 : : #define _CURSES_MOUSEMASK_METHODDEF \
3130 : : {"mousemask", (PyCFunction)_curses_mousemask, METH_O, _curses_mousemask__doc__},
3131 : :
3132 : : static PyObject *
3133 : : _curses_mousemask_impl(PyObject *module, unsigned long newmask);
3134 : :
3135 : : static PyObject *
3136 : 0 : _curses_mousemask(PyObject *module, PyObject *arg)
3137 : : {
3138 : 0 : PyObject *return_value = NULL;
3139 : : unsigned long newmask;
3140 : :
3141 [ # # ]: 0 : if (!PyLong_Check(arg)) {
3142 : 0 : _PyArg_BadArgument("mousemask", "argument", "int", arg);
3143 : 0 : goto exit;
3144 : : }
3145 : 0 : newmask = PyLong_AsUnsignedLongMask(arg);
3146 : 0 : return_value = _curses_mousemask_impl(module, newmask);
3147 : :
3148 : 0 : exit:
3149 : 0 : return return_value;
3150 : : }
3151 : :
3152 : : #endif /* defined(NCURSES_MOUSE_VERSION) */
3153 : :
3154 : : PyDoc_STRVAR(_curses_napms__doc__,
3155 : : "napms($module, ms, /)\n"
3156 : : "--\n"
3157 : : "\n"
3158 : : "Sleep for specified time.\n"
3159 : : "\n"
3160 : : " ms\n"
3161 : : " Duration in milliseconds.");
3162 : :
3163 : : #define _CURSES_NAPMS_METHODDEF \
3164 : : {"napms", (PyCFunction)_curses_napms, METH_O, _curses_napms__doc__},
3165 : :
3166 : : static PyObject *
3167 : : _curses_napms_impl(PyObject *module, int ms);
3168 : :
3169 : : static PyObject *
3170 : 0 : _curses_napms(PyObject *module, PyObject *arg)
3171 : : {
3172 : 0 : PyObject *return_value = NULL;
3173 : : int ms;
3174 : :
3175 : 0 : ms = _PyLong_AsInt(arg);
3176 [ # # # # ]: 0 : if (ms == -1 && PyErr_Occurred()) {
3177 : 0 : goto exit;
3178 : : }
3179 : 0 : return_value = _curses_napms_impl(module, ms);
3180 : :
3181 : 0 : exit:
3182 : 0 : return return_value;
3183 : : }
3184 : :
3185 : : PyDoc_STRVAR(_curses_newpad__doc__,
3186 : : "newpad($module, nlines, ncols, /)\n"
3187 : : "--\n"
3188 : : "\n"
3189 : : "Create and return a pointer to a new pad data structure.\n"
3190 : : "\n"
3191 : : " nlines\n"
3192 : : " Height.\n"
3193 : : " ncols\n"
3194 : : " Width.");
3195 : :
3196 : : #define _CURSES_NEWPAD_METHODDEF \
3197 : : {"newpad", _PyCFunction_CAST(_curses_newpad), METH_FASTCALL, _curses_newpad__doc__},
3198 : :
3199 : : static PyObject *
3200 : : _curses_newpad_impl(PyObject *module, int nlines, int ncols);
3201 : :
3202 : : static PyObject *
3203 : 0 : _curses_newpad(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3204 : : {
3205 : 0 : PyObject *return_value = NULL;
3206 : : int nlines;
3207 : : int ncols;
3208 : :
3209 [ # # # # : 0 : if (!_PyArg_CheckPositional("newpad", nargs, 2, 2)) {
# # ]
3210 : 0 : goto exit;
3211 : : }
3212 : 0 : nlines = _PyLong_AsInt(args[0]);
3213 [ # # # # ]: 0 : if (nlines == -1 && PyErr_Occurred()) {
3214 : 0 : goto exit;
3215 : : }
3216 : 0 : ncols = _PyLong_AsInt(args[1]);
3217 [ # # # # ]: 0 : if (ncols == -1 && PyErr_Occurred()) {
3218 : 0 : goto exit;
3219 : : }
3220 : 0 : return_value = _curses_newpad_impl(module, nlines, ncols);
3221 : :
3222 : 0 : exit:
3223 : 0 : return return_value;
3224 : : }
3225 : :
3226 : : PyDoc_STRVAR(_curses_newwin__doc__,
3227 : : "newwin(nlines, ncols, [begin_y=0, begin_x=0])\n"
3228 : : "Return a new window.\n"
3229 : : "\n"
3230 : : " nlines\n"
3231 : : " Height.\n"
3232 : : " ncols\n"
3233 : : " Width.\n"
3234 : : " begin_y\n"
3235 : : " Top side y-coordinate.\n"
3236 : : " begin_x\n"
3237 : : " Left side x-coordinate.\n"
3238 : : "\n"
3239 : : "By default, the window will extend from the specified position to the lower\n"
3240 : : "right corner of the screen.");
3241 : :
3242 : : #define _CURSES_NEWWIN_METHODDEF \
3243 : : {"newwin", (PyCFunction)_curses_newwin, METH_VARARGS, _curses_newwin__doc__},
3244 : :
3245 : : static PyObject *
3246 : : _curses_newwin_impl(PyObject *module, int nlines, int ncols,
3247 : : int group_right_1, int begin_y, int begin_x);
3248 : :
3249 : : static PyObject *
3250 : 0 : _curses_newwin(PyObject *module, PyObject *args)
3251 : : {
3252 : 0 : PyObject *return_value = NULL;
3253 : : int nlines;
3254 : : int ncols;
3255 : 0 : int group_right_1 = 0;
3256 : 0 : int begin_y = 0;
3257 : 0 : int begin_x = 0;
3258 : :
3259 [ # # # ]: 0 : switch (PyTuple_GET_SIZE(args)) {
3260 : 0 : case 2:
3261 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "ii:newwin", &nlines, &ncols)) {
3262 : 0 : goto exit;
3263 : : }
3264 : 0 : break;
3265 : 0 : case 4:
3266 [ # # ]: 0 : if (!PyArg_ParseTuple(args, "iiii:newwin", &nlines, &ncols, &begin_y, &begin_x)) {
3267 : 0 : goto exit;
3268 : : }
3269 : 0 : group_right_1 = 1;
3270 : 0 : break;
3271 : 0 : default:
3272 : 0 : PyErr_SetString(PyExc_TypeError, "_curses.newwin requires 2 to 4 arguments");
3273 : 0 : goto exit;
3274 : : }
3275 : 0 : return_value = _curses_newwin_impl(module, nlines, ncols, group_right_1, begin_y, begin_x);
3276 : :
3277 : 0 : exit:
3278 : 0 : return return_value;
3279 : : }
3280 : :
3281 : : PyDoc_STRVAR(_curses_nl__doc__,
3282 : : "nl($module, flag=True, /)\n"
3283 : : "--\n"
3284 : : "\n"
3285 : : "Enter newline mode.\n"
3286 : : "\n"
3287 : : " flag\n"
3288 : : " If false, the effect is the same as calling nonl().\n"
3289 : : "\n"
3290 : : "This mode translates the return key into newline on input, and translates\n"
3291 : : "newline into return and line-feed on output. Newline mode is initially on.");
3292 : :
3293 : : #define _CURSES_NL_METHODDEF \
3294 : : {"nl", _PyCFunction_CAST(_curses_nl), METH_FASTCALL, _curses_nl__doc__},
3295 : :
3296 : : static PyObject *
3297 : : _curses_nl_impl(PyObject *module, int flag);
3298 : :
3299 : : static PyObject *
3300 : 0 : _curses_nl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3301 : : {
3302 : 0 : PyObject *return_value = NULL;
3303 : 0 : int flag = 1;
3304 : :
3305 [ # # # # : 0 : if (!_PyArg_CheckPositional("nl", nargs, 0, 1)) {
# # ]
3306 : 0 : goto exit;
3307 : : }
3308 [ # # ]: 0 : if (nargs < 1) {
3309 : 0 : goto skip_optional;
3310 : : }
3311 : 0 : flag = PyObject_IsTrue(args[0]);
3312 [ # # ]: 0 : if (flag < 0) {
3313 : 0 : goto exit;
3314 : : }
3315 : 0 : skip_optional:
3316 : 0 : return_value = _curses_nl_impl(module, flag);
3317 : :
3318 : 0 : exit:
3319 : 0 : return return_value;
3320 : : }
3321 : :
3322 : : PyDoc_STRVAR(_curses_nocbreak__doc__,
3323 : : "nocbreak($module, /)\n"
3324 : : "--\n"
3325 : : "\n"
3326 : : "Leave cbreak mode.\n"
3327 : : "\n"
3328 : : "Return to normal \"cooked\" mode with line buffering.");
3329 : :
3330 : : #define _CURSES_NOCBREAK_METHODDEF \
3331 : : {"nocbreak", (PyCFunction)_curses_nocbreak, METH_NOARGS, _curses_nocbreak__doc__},
3332 : :
3333 : : static PyObject *
3334 : : _curses_nocbreak_impl(PyObject *module);
3335 : :
3336 : : static PyObject *
3337 : 0 : _curses_nocbreak(PyObject *module, PyObject *Py_UNUSED(ignored))
3338 : : {
3339 : 0 : return _curses_nocbreak_impl(module);
3340 : : }
3341 : :
3342 : : PyDoc_STRVAR(_curses_noecho__doc__,
3343 : : "noecho($module, /)\n"
3344 : : "--\n"
3345 : : "\n"
3346 : : "Leave echo mode.\n"
3347 : : "\n"
3348 : : "Echoing of input characters is turned off.");
3349 : :
3350 : : #define _CURSES_NOECHO_METHODDEF \
3351 : : {"noecho", (PyCFunction)_curses_noecho, METH_NOARGS, _curses_noecho__doc__},
3352 : :
3353 : : static PyObject *
3354 : : _curses_noecho_impl(PyObject *module);
3355 : :
3356 : : static PyObject *
3357 : 0 : _curses_noecho(PyObject *module, PyObject *Py_UNUSED(ignored))
3358 : : {
3359 : 0 : return _curses_noecho_impl(module);
3360 : : }
3361 : :
3362 : : PyDoc_STRVAR(_curses_nonl__doc__,
3363 : : "nonl($module, /)\n"
3364 : : "--\n"
3365 : : "\n"
3366 : : "Leave newline mode.\n"
3367 : : "\n"
3368 : : "Disable translation of return into newline on input, and disable low-level\n"
3369 : : "translation of newline into newline/return on output.");
3370 : :
3371 : : #define _CURSES_NONL_METHODDEF \
3372 : : {"nonl", (PyCFunction)_curses_nonl, METH_NOARGS, _curses_nonl__doc__},
3373 : :
3374 : : static PyObject *
3375 : : _curses_nonl_impl(PyObject *module);
3376 : :
3377 : : static PyObject *
3378 : 0 : _curses_nonl(PyObject *module, PyObject *Py_UNUSED(ignored))
3379 : : {
3380 : 0 : return _curses_nonl_impl(module);
3381 : : }
3382 : :
3383 : : PyDoc_STRVAR(_curses_noqiflush__doc__,
3384 : : "noqiflush($module, /)\n"
3385 : : "--\n"
3386 : : "\n"
3387 : : "Disable queue flushing.\n"
3388 : : "\n"
3389 : : "When queue flushing is disabled, normal flush of input and output queues\n"
3390 : : "associated with the INTR, QUIT and SUSP characters will not be done.");
3391 : :
3392 : : #define _CURSES_NOQIFLUSH_METHODDEF \
3393 : : {"noqiflush", (PyCFunction)_curses_noqiflush, METH_NOARGS, _curses_noqiflush__doc__},
3394 : :
3395 : : static PyObject *
3396 : : _curses_noqiflush_impl(PyObject *module);
3397 : :
3398 : : static PyObject *
3399 : 0 : _curses_noqiflush(PyObject *module, PyObject *Py_UNUSED(ignored))
3400 : : {
3401 : 0 : return _curses_noqiflush_impl(module);
3402 : : }
3403 : :
3404 : : PyDoc_STRVAR(_curses_noraw__doc__,
3405 : : "noraw($module, /)\n"
3406 : : "--\n"
3407 : : "\n"
3408 : : "Leave raw mode.\n"
3409 : : "\n"
3410 : : "Return to normal \"cooked\" mode with line buffering.");
3411 : :
3412 : : #define _CURSES_NORAW_METHODDEF \
3413 : : {"noraw", (PyCFunction)_curses_noraw, METH_NOARGS, _curses_noraw__doc__},
3414 : :
3415 : : static PyObject *
3416 : : _curses_noraw_impl(PyObject *module);
3417 : :
3418 : : static PyObject *
3419 : 0 : _curses_noraw(PyObject *module, PyObject *Py_UNUSED(ignored))
3420 : : {
3421 : 0 : return _curses_noraw_impl(module);
3422 : : }
3423 : :
3424 : : PyDoc_STRVAR(_curses_pair_content__doc__,
3425 : : "pair_content($module, pair_number, /)\n"
3426 : : "--\n"
3427 : : "\n"
3428 : : "Return a tuple (fg, bg) containing the colors for the requested color pair.\n"
3429 : : "\n"
3430 : : " pair_number\n"
3431 : : " The number of the color pair (0 - (COLOR_PAIRS-1)).");
3432 : :
3433 : : #define _CURSES_PAIR_CONTENT_METHODDEF \
3434 : : {"pair_content", (PyCFunction)_curses_pair_content, METH_O, _curses_pair_content__doc__},
3435 : :
3436 : : static PyObject *
3437 : : _curses_pair_content_impl(PyObject *module, int pair_number);
3438 : :
3439 : : static PyObject *
3440 : 0 : _curses_pair_content(PyObject *module, PyObject *arg)
3441 : : {
3442 : 0 : PyObject *return_value = NULL;
3443 : : int pair_number;
3444 : :
3445 [ # # ]: 0 : if (!pair_converter(arg, &pair_number)) {
3446 : 0 : goto exit;
3447 : : }
3448 : 0 : return_value = _curses_pair_content_impl(module, pair_number);
3449 : :
3450 : 0 : exit:
3451 : 0 : return return_value;
3452 : : }
3453 : :
3454 : : PyDoc_STRVAR(_curses_pair_number__doc__,
3455 : : "pair_number($module, attr, /)\n"
3456 : : "--\n"
3457 : : "\n"
3458 : : "Return the number of the color-pair set by the specified attribute value.\n"
3459 : : "\n"
3460 : : "color_pair() is the counterpart to this function.");
3461 : :
3462 : : #define _CURSES_PAIR_NUMBER_METHODDEF \
3463 : : {"pair_number", (PyCFunction)_curses_pair_number, METH_O, _curses_pair_number__doc__},
3464 : :
3465 : : static PyObject *
3466 : : _curses_pair_number_impl(PyObject *module, int attr);
3467 : :
3468 : : static PyObject *
3469 : 0 : _curses_pair_number(PyObject *module, PyObject *arg)
3470 : : {
3471 : 0 : PyObject *return_value = NULL;
3472 : : int attr;
3473 : :
3474 : 0 : attr = _PyLong_AsInt(arg);
3475 [ # # # # ]: 0 : if (attr == -1 && PyErr_Occurred()) {
3476 : 0 : goto exit;
3477 : : }
3478 : 0 : return_value = _curses_pair_number_impl(module, attr);
3479 : :
3480 : 0 : exit:
3481 : 0 : return return_value;
3482 : : }
3483 : :
3484 : : PyDoc_STRVAR(_curses_putp__doc__,
3485 : : "putp($module, string, /)\n"
3486 : : "--\n"
3487 : : "\n"
3488 : : "Emit the value of a specified terminfo capability for the current terminal.\n"
3489 : : "\n"
3490 : : "Note that the output of putp() always goes to standard output.");
3491 : :
3492 : : #define _CURSES_PUTP_METHODDEF \
3493 : : {"putp", (PyCFunction)_curses_putp, METH_O, _curses_putp__doc__},
3494 : :
3495 : : static PyObject *
3496 : : _curses_putp_impl(PyObject *module, const char *string);
3497 : :
3498 : : static PyObject *
3499 : 0 : _curses_putp(PyObject *module, PyObject *arg)
3500 : : {
3501 : 0 : PyObject *return_value = NULL;
3502 : : const char *string;
3503 : :
3504 [ # # ]: 0 : if (!PyArg_Parse(arg, "y:putp", &string)) {
3505 : 0 : goto exit;
3506 : : }
3507 : 0 : return_value = _curses_putp_impl(module, string);
3508 : :
3509 : 0 : exit:
3510 : 0 : return return_value;
3511 : : }
3512 : :
3513 : : PyDoc_STRVAR(_curses_qiflush__doc__,
3514 : : "qiflush($module, flag=True, /)\n"
3515 : : "--\n"
3516 : : "\n"
3517 : : "Enable queue flushing.\n"
3518 : : "\n"
3519 : : " flag\n"
3520 : : " If false, the effect is the same as calling noqiflush().\n"
3521 : : "\n"
3522 : : "If queue flushing is enabled, all output in the display driver queue\n"
3523 : : "will be flushed when the INTR, QUIT and SUSP characters are read.");
3524 : :
3525 : : #define _CURSES_QIFLUSH_METHODDEF \
3526 : : {"qiflush", _PyCFunction_CAST(_curses_qiflush), METH_FASTCALL, _curses_qiflush__doc__},
3527 : :
3528 : : static PyObject *
3529 : : _curses_qiflush_impl(PyObject *module, int flag);
3530 : :
3531 : : static PyObject *
3532 : 0 : _curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3533 : : {
3534 : 0 : PyObject *return_value = NULL;
3535 : 0 : int flag = 1;
3536 : :
3537 [ # # # # : 0 : if (!_PyArg_CheckPositional("qiflush", nargs, 0, 1)) {
# # ]
3538 : 0 : goto exit;
3539 : : }
3540 [ # # ]: 0 : if (nargs < 1) {
3541 : 0 : goto skip_optional;
3542 : : }
3543 : 0 : flag = PyObject_IsTrue(args[0]);
3544 [ # # ]: 0 : if (flag < 0) {
3545 : 0 : goto exit;
3546 : : }
3547 : 0 : skip_optional:
3548 : 0 : return_value = _curses_qiflush_impl(module, flag);
3549 : :
3550 : 0 : exit:
3551 : 0 : return return_value;
3552 : : }
3553 : :
3554 : : #if (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM))
3555 : :
3556 : : PyDoc_STRVAR(_curses_update_lines_cols__doc__,
3557 : : "update_lines_cols($module, /)\n"
3558 : : "--\n"
3559 : : "\n");
3560 : :
3561 : : #define _CURSES_UPDATE_LINES_COLS_METHODDEF \
3562 : : {"update_lines_cols", (PyCFunction)_curses_update_lines_cols, METH_NOARGS, _curses_update_lines_cols__doc__},
3563 : :
3564 : : static PyObject *
3565 : : _curses_update_lines_cols_impl(PyObject *module);
3566 : :
3567 : : static PyObject *
3568 : 0 : _curses_update_lines_cols(PyObject *module, PyObject *Py_UNUSED(ignored))
3569 : : {
3570 : 0 : return _curses_update_lines_cols_impl(module);
3571 : : }
3572 : :
3573 : : #endif /* (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) */
3574 : :
3575 : : PyDoc_STRVAR(_curses_raw__doc__,
3576 : : "raw($module, flag=True, /)\n"
3577 : : "--\n"
3578 : : "\n"
3579 : : "Enter raw mode.\n"
3580 : : "\n"
3581 : : " flag\n"
3582 : : " If false, the effect is the same as calling noraw().\n"
3583 : : "\n"
3584 : : "In raw mode, normal line buffering and processing of interrupt, quit,\n"
3585 : : "suspend, and flow control keys are turned off; characters are presented to\n"
3586 : : "curses input functions one by one.");
3587 : :
3588 : : #define _CURSES_RAW_METHODDEF \
3589 : : {"raw", _PyCFunction_CAST(_curses_raw), METH_FASTCALL, _curses_raw__doc__},
3590 : :
3591 : : static PyObject *
3592 : : _curses_raw_impl(PyObject *module, int flag);
3593 : :
3594 : : static PyObject *
3595 : 0 : _curses_raw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3596 : : {
3597 : 0 : PyObject *return_value = NULL;
3598 : 0 : int flag = 1;
3599 : :
3600 [ # # # # : 0 : if (!_PyArg_CheckPositional("raw", nargs, 0, 1)) {
# # ]
3601 : 0 : goto exit;
3602 : : }
3603 [ # # ]: 0 : if (nargs < 1) {
3604 : 0 : goto skip_optional;
3605 : : }
3606 : 0 : flag = PyObject_IsTrue(args[0]);
3607 [ # # ]: 0 : if (flag < 0) {
3608 : 0 : goto exit;
3609 : : }
3610 : 0 : skip_optional:
3611 : 0 : return_value = _curses_raw_impl(module, flag);
3612 : :
3613 : 0 : exit:
3614 : 0 : return return_value;
3615 : : }
3616 : :
3617 : : PyDoc_STRVAR(_curses_reset_prog_mode__doc__,
3618 : : "reset_prog_mode($module, /)\n"
3619 : : "--\n"
3620 : : "\n"
3621 : : "Restore the terminal to \"program\" mode, as previously saved by def_prog_mode().");
3622 : :
3623 : : #define _CURSES_RESET_PROG_MODE_METHODDEF \
3624 : : {"reset_prog_mode", (PyCFunction)_curses_reset_prog_mode, METH_NOARGS, _curses_reset_prog_mode__doc__},
3625 : :
3626 : : static PyObject *
3627 : : _curses_reset_prog_mode_impl(PyObject *module);
3628 : :
3629 : : static PyObject *
3630 : 0 : _curses_reset_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
3631 : : {
3632 : 0 : return _curses_reset_prog_mode_impl(module);
3633 : : }
3634 : :
3635 : : PyDoc_STRVAR(_curses_reset_shell_mode__doc__,
3636 : : "reset_shell_mode($module, /)\n"
3637 : : "--\n"
3638 : : "\n"
3639 : : "Restore the terminal to \"shell\" mode, as previously saved by def_shell_mode().");
3640 : :
3641 : : #define _CURSES_RESET_SHELL_MODE_METHODDEF \
3642 : : {"reset_shell_mode", (PyCFunction)_curses_reset_shell_mode, METH_NOARGS, _curses_reset_shell_mode__doc__},
3643 : :
3644 : : static PyObject *
3645 : : _curses_reset_shell_mode_impl(PyObject *module);
3646 : :
3647 : : static PyObject *
3648 : 0 : _curses_reset_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
3649 : : {
3650 : 0 : return _curses_reset_shell_mode_impl(module);
3651 : : }
3652 : :
3653 : : PyDoc_STRVAR(_curses_resetty__doc__,
3654 : : "resetty($module, /)\n"
3655 : : "--\n"
3656 : : "\n"
3657 : : "Restore terminal mode.");
3658 : :
3659 : : #define _CURSES_RESETTY_METHODDEF \
3660 : : {"resetty", (PyCFunction)_curses_resetty, METH_NOARGS, _curses_resetty__doc__},
3661 : :
3662 : : static PyObject *
3663 : : _curses_resetty_impl(PyObject *module);
3664 : :
3665 : : static PyObject *
3666 : 0 : _curses_resetty(PyObject *module, PyObject *Py_UNUSED(ignored))
3667 : : {
3668 : 0 : return _curses_resetty_impl(module);
3669 : : }
3670 : :
3671 : : #if defined(HAVE_CURSES_RESIZETERM)
3672 : :
3673 : : PyDoc_STRVAR(_curses_resizeterm__doc__,
3674 : : "resizeterm($module, nlines, ncols, /)\n"
3675 : : "--\n"
3676 : : "\n"
3677 : : "Resize the standard and current windows to the specified dimensions.\n"
3678 : : "\n"
3679 : : " nlines\n"
3680 : : " Height.\n"
3681 : : " ncols\n"
3682 : : " Width.\n"
3683 : : "\n"
3684 : : "Adjusts other bookkeeping data used by the curses library that record the\n"
3685 : : "window dimensions (in particular the SIGWINCH handler).");
3686 : :
3687 : : #define _CURSES_RESIZETERM_METHODDEF \
3688 : : {"resizeterm", _PyCFunction_CAST(_curses_resizeterm), METH_FASTCALL, _curses_resizeterm__doc__},
3689 : :
3690 : : static PyObject *
3691 : : _curses_resizeterm_impl(PyObject *module, int nlines, int ncols);
3692 : :
3693 : : static PyObject *
3694 : 0 : _curses_resizeterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3695 : : {
3696 : 0 : PyObject *return_value = NULL;
3697 : : int nlines;
3698 : : int ncols;
3699 : :
3700 [ # # # # : 0 : if (!_PyArg_CheckPositional("resizeterm", nargs, 2, 2)) {
# # ]
3701 : 0 : goto exit;
3702 : : }
3703 : 0 : nlines = _PyLong_AsInt(args[0]);
3704 [ # # # # ]: 0 : if (nlines == -1 && PyErr_Occurred()) {
3705 : 0 : goto exit;
3706 : : }
3707 : 0 : ncols = _PyLong_AsInt(args[1]);
3708 [ # # # # ]: 0 : if (ncols == -1 && PyErr_Occurred()) {
3709 : 0 : goto exit;
3710 : : }
3711 : 0 : return_value = _curses_resizeterm_impl(module, nlines, ncols);
3712 : :
3713 : 0 : exit:
3714 : 0 : return return_value;
3715 : : }
3716 : :
3717 : : #endif /* defined(HAVE_CURSES_RESIZETERM) */
3718 : :
3719 : : #if defined(HAVE_CURSES_RESIZE_TERM)
3720 : :
3721 : : PyDoc_STRVAR(_curses_resize_term__doc__,
3722 : : "resize_term($module, nlines, ncols, /)\n"
3723 : : "--\n"
3724 : : "\n"
3725 : : "Backend function used by resizeterm(), performing most of the work.\n"
3726 : : "\n"
3727 : : " nlines\n"
3728 : : " Height.\n"
3729 : : " ncols\n"
3730 : : " Width.\n"
3731 : : "\n"
3732 : : "When resizing the windows, resize_term() blank-fills the areas that are\n"
3733 : : "extended. The calling application should fill in these areas with appropriate\n"
3734 : : "data. The resize_term() function attempts to resize all windows. However,\n"
3735 : : "due to the calling convention of pads, it is not possible to resize these\n"
3736 : : "without additional interaction with the application.");
3737 : :
3738 : : #define _CURSES_RESIZE_TERM_METHODDEF \
3739 : : {"resize_term", _PyCFunction_CAST(_curses_resize_term), METH_FASTCALL, _curses_resize_term__doc__},
3740 : :
3741 : : static PyObject *
3742 : : _curses_resize_term_impl(PyObject *module, int nlines, int ncols);
3743 : :
3744 : : static PyObject *
3745 : 0 : _curses_resize_term(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3746 : : {
3747 : 0 : PyObject *return_value = NULL;
3748 : : int nlines;
3749 : : int ncols;
3750 : :
3751 [ # # # # : 0 : if (!_PyArg_CheckPositional("resize_term", nargs, 2, 2)) {
# # ]
3752 : 0 : goto exit;
3753 : : }
3754 : 0 : nlines = _PyLong_AsInt(args[0]);
3755 [ # # # # ]: 0 : if (nlines == -1 && PyErr_Occurred()) {
3756 : 0 : goto exit;
3757 : : }
3758 : 0 : ncols = _PyLong_AsInt(args[1]);
3759 [ # # # # ]: 0 : if (ncols == -1 && PyErr_Occurred()) {
3760 : 0 : goto exit;
3761 : : }
3762 : 0 : return_value = _curses_resize_term_impl(module, nlines, ncols);
3763 : :
3764 : 0 : exit:
3765 : 0 : return return_value;
3766 : : }
3767 : :
3768 : : #endif /* defined(HAVE_CURSES_RESIZE_TERM) */
3769 : :
3770 : : PyDoc_STRVAR(_curses_savetty__doc__,
3771 : : "savetty($module, /)\n"
3772 : : "--\n"
3773 : : "\n"
3774 : : "Save terminal mode.");
3775 : :
3776 : : #define _CURSES_SAVETTY_METHODDEF \
3777 : : {"savetty", (PyCFunction)_curses_savetty, METH_NOARGS, _curses_savetty__doc__},
3778 : :
3779 : : static PyObject *
3780 : : _curses_savetty_impl(PyObject *module);
3781 : :
3782 : : static PyObject *
3783 : 0 : _curses_savetty(PyObject *module, PyObject *Py_UNUSED(ignored))
3784 : : {
3785 : 0 : return _curses_savetty_impl(module);
3786 : : }
3787 : :
3788 : : #if defined(getsyx)
3789 : :
3790 : : PyDoc_STRVAR(_curses_setsyx__doc__,
3791 : : "setsyx($module, y, x, /)\n"
3792 : : "--\n"
3793 : : "\n"
3794 : : "Set the virtual screen cursor.\n"
3795 : : "\n"
3796 : : " y\n"
3797 : : " Y-coordinate.\n"
3798 : : " x\n"
3799 : : " X-coordinate.\n"
3800 : : "\n"
3801 : : "If y and x are both -1, then leaveok is set.");
3802 : :
3803 : : #define _CURSES_SETSYX_METHODDEF \
3804 : : {"setsyx", _PyCFunction_CAST(_curses_setsyx), METH_FASTCALL, _curses_setsyx__doc__},
3805 : :
3806 : : static PyObject *
3807 : : _curses_setsyx_impl(PyObject *module, int y, int x);
3808 : :
3809 : : static PyObject *
3810 : 0 : _curses_setsyx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3811 : : {
3812 : 0 : PyObject *return_value = NULL;
3813 : : int y;
3814 : : int x;
3815 : :
3816 [ # # # # : 0 : if (!_PyArg_CheckPositional("setsyx", nargs, 2, 2)) {
# # ]
3817 : 0 : goto exit;
3818 : : }
3819 : 0 : y = _PyLong_AsInt(args[0]);
3820 [ # # # # ]: 0 : if (y == -1 && PyErr_Occurred()) {
3821 : 0 : goto exit;
3822 : : }
3823 : 0 : x = _PyLong_AsInt(args[1]);
3824 [ # # # # ]: 0 : if (x == -1 && PyErr_Occurred()) {
3825 : 0 : goto exit;
3826 : : }
3827 : 0 : return_value = _curses_setsyx_impl(module, y, x);
3828 : :
3829 : 0 : exit:
3830 : 0 : return return_value;
3831 : : }
3832 : :
3833 : : #endif /* defined(getsyx) */
3834 : :
3835 : : PyDoc_STRVAR(_curses_start_color__doc__,
3836 : : "start_color($module, /)\n"
3837 : : "--\n"
3838 : : "\n"
3839 : : "Initializes eight basic colors and global variables COLORS and COLOR_PAIRS.\n"
3840 : : "\n"
3841 : : "Must be called if the programmer wants to use colors, and before any other\n"
3842 : : "color manipulation routine is called. It is good practice to call this\n"
3843 : : "routine right after initscr().\n"
3844 : : "\n"
3845 : : "It also restores the colors on the terminal to the values they had when the\n"
3846 : : "terminal was just turned on.");
3847 : :
3848 : : #define _CURSES_START_COLOR_METHODDEF \
3849 : : {"start_color", (PyCFunction)_curses_start_color, METH_NOARGS, _curses_start_color__doc__},
3850 : :
3851 : : static PyObject *
3852 : : _curses_start_color_impl(PyObject *module);
3853 : :
3854 : : static PyObject *
3855 : 0 : _curses_start_color(PyObject *module, PyObject *Py_UNUSED(ignored))
3856 : : {
3857 : 0 : return _curses_start_color_impl(module);
3858 : : }
3859 : :
3860 : : PyDoc_STRVAR(_curses_termattrs__doc__,
3861 : : "termattrs($module, /)\n"
3862 : : "--\n"
3863 : : "\n"
3864 : : "Return a logical OR of all video attributes supported by the terminal.");
3865 : :
3866 : : #define _CURSES_TERMATTRS_METHODDEF \
3867 : : {"termattrs", (PyCFunction)_curses_termattrs, METH_NOARGS, _curses_termattrs__doc__},
3868 : :
3869 : : static PyObject *
3870 : : _curses_termattrs_impl(PyObject *module);
3871 : :
3872 : : static PyObject *
3873 : 0 : _curses_termattrs(PyObject *module, PyObject *Py_UNUSED(ignored))
3874 : : {
3875 : 0 : return _curses_termattrs_impl(module);
3876 : : }
3877 : :
3878 : : PyDoc_STRVAR(_curses_termname__doc__,
3879 : : "termname($module, /)\n"
3880 : : "--\n"
3881 : : "\n"
3882 : : "Return the value of the environment variable TERM, truncated to 14 characters.");
3883 : :
3884 : : #define _CURSES_TERMNAME_METHODDEF \
3885 : : {"termname", (PyCFunction)_curses_termname, METH_NOARGS, _curses_termname__doc__},
3886 : :
3887 : : static PyObject *
3888 : : _curses_termname_impl(PyObject *module);
3889 : :
3890 : : static PyObject *
3891 : 0 : _curses_termname(PyObject *module, PyObject *Py_UNUSED(ignored))
3892 : : {
3893 : 0 : return _curses_termname_impl(module);
3894 : : }
3895 : :
3896 : : PyDoc_STRVAR(_curses_tigetflag__doc__,
3897 : : "tigetflag($module, capname, /)\n"
3898 : : "--\n"
3899 : : "\n"
3900 : : "Return the value of the Boolean capability.\n"
3901 : : "\n"
3902 : : " capname\n"
3903 : : " The terminfo capability name.\n"
3904 : : "\n"
3905 : : "The value -1 is returned if capname is not a Boolean capability, or 0 if\n"
3906 : : "it is canceled or absent from the terminal description.");
3907 : :
3908 : : #define _CURSES_TIGETFLAG_METHODDEF \
3909 : : {"tigetflag", (PyCFunction)_curses_tigetflag, METH_O, _curses_tigetflag__doc__},
3910 : :
3911 : : static PyObject *
3912 : : _curses_tigetflag_impl(PyObject *module, const char *capname);
3913 : :
3914 : : static PyObject *
3915 : 0 : _curses_tigetflag(PyObject *module, PyObject *arg)
3916 : : {
3917 : 0 : PyObject *return_value = NULL;
3918 : : const char *capname;
3919 : :
3920 [ # # ]: 0 : if (!PyUnicode_Check(arg)) {
3921 : 0 : _PyArg_BadArgument("tigetflag", "argument", "str", arg);
3922 : 0 : goto exit;
3923 : : }
3924 : : Py_ssize_t capname_length;
3925 : 0 : capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
3926 [ # # ]: 0 : if (capname == NULL) {
3927 : 0 : goto exit;
3928 : : }
3929 [ # # ]: 0 : if (strlen(capname) != (size_t)capname_length) {
3930 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character");
3931 : 0 : goto exit;
3932 : : }
3933 : 0 : return_value = _curses_tigetflag_impl(module, capname);
3934 : :
3935 : 0 : exit:
3936 : 0 : return return_value;
3937 : : }
3938 : :
3939 : : PyDoc_STRVAR(_curses_tigetnum__doc__,
3940 : : "tigetnum($module, capname, /)\n"
3941 : : "--\n"
3942 : : "\n"
3943 : : "Return the value of the numeric capability.\n"
3944 : : "\n"
3945 : : " capname\n"
3946 : : " The terminfo capability name.\n"
3947 : : "\n"
3948 : : "The value -2 is returned if capname is not a numeric capability, or -1 if\n"
3949 : : "it is canceled or absent from the terminal description.");
3950 : :
3951 : : #define _CURSES_TIGETNUM_METHODDEF \
3952 : : {"tigetnum", (PyCFunction)_curses_tigetnum, METH_O, _curses_tigetnum__doc__},
3953 : :
3954 : : static PyObject *
3955 : : _curses_tigetnum_impl(PyObject *module, const char *capname);
3956 : :
3957 : : static PyObject *
3958 : 0 : _curses_tigetnum(PyObject *module, PyObject *arg)
3959 : : {
3960 : 0 : PyObject *return_value = NULL;
3961 : : const char *capname;
3962 : :
3963 [ # # ]: 0 : if (!PyUnicode_Check(arg)) {
3964 : 0 : _PyArg_BadArgument("tigetnum", "argument", "str", arg);
3965 : 0 : goto exit;
3966 : : }
3967 : : Py_ssize_t capname_length;
3968 : 0 : capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
3969 [ # # ]: 0 : if (capname == NULL) {
3970 : 0 : goto exit;
3971 : : }
3972 [ # # ]: 0 : if (strlen(capname) != (size_t)capname_length) {
3973 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character");
3974 : 0 : goto exit;
3975 : : }
3976 : 0 : return_value = _curses_tigetnum_impl(module, capname);
3977 : :
3978 : 0 : exit:
3979 : 0 : return return_value;
3980 : : }
3981 : :
3982 : : PyDoc_STRVAR(_curses_tigetstr__doc__,
3983 : : "tigetstr($module, capname, /)\n"
3984 : : "--\n"
3985 : : "\n"
3986 : : "Return the value of the string capability.\n"
3987 : : "\n"
3988 : : " capname\n"
3989 : : " The terminfo capability name.\n"
3990 : : "\n"
3991 : : "None is returned if capname is not a string capability, or is canceled or\n"
3992 : : "absent from the terminal description.");
3993 : :
3994 : : #define _CURSES_TIGETSTR_METHODDEF \
3995 : : {"tigetstr", (PyCFunction)_curses_tigetstr, METH_O, _curses_tigetstr__doc__},
3996 : :
3997 : : static PyObject *
3998 : : _curses_tigetstr_impl(PyObject *module, const char *capname);
3999 : :
4000 : : static PyObject *
4001 : 0 : _curses_tigetstr(PyObject *module, PyObject *arg)
4002 : : {
4003 : 0 : PyObject *return_value = NULL;
4004 : : const char *capname;
4005 : :
4006 [ # # ]: 0 : if (!PyUnicode_Check(arg)) {
4007 : 0 : _PyArg_BadArgument("tigetstr", "argument", "str", arg);
4008 : 0 : goto exit;
4009 : : }
4010 : : Py_ssize_t capname_length;
4011 : 0 : capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
4012 [ # # ]: 0 : if (capname == NULL) {
4013 : 0 : goto exit;
4014 : : }
4015 [ # # ]: 0 : if (strlen(capname) != (size_t)capname_length) {
4016 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character");
4017 : 0 : goto exit;
4018 : : }
4019 : 0 : return_value = _curses_tigetstr_impl(module, capname);
4020 : :
4021 : 0 : exit:
4022 : 0 : return return_value;
4023 : : }
4024 : :
4025 : : PyDoc_STRVAR(_curses_tparm__doc__,
4026 : : "tparm($module, str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0,\n"
4027 : : " i9=0, /)\n"
4028 : : "--\n"
4029 : : "\n"
4030 : : "Instantiate the specified byte string with the supplied parameters.\n"
4031 : : "\n"
4032 : : " str\n"
4033 : : " Parameterized byte string obtained from the terminfo database.");
4034 : :
4035 : : #define _CURSES_TPARM_METHODDEF \
4036 : : {"tparm", _PyCFunction_CAST(_curses_tparm), METH_FASTCALL, _curses_tparm__doc__},
4037 : :
4038 : : static PyObject *
4039 : : _curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3,
4040 : : int i4, int i5, int i6, int i7, int i8, int i9);
4041 : :
4042 : : static PyObject *
4043 : 0 : _curses_tparm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
4044 : : {
4045 : 0 : PyObject *return_value = NULL;
4046 : : const char *str;
4047 : 0 : int i1 = 0;
4048 : 0 : int i2 = 0;
4049 : 0 : int i3 = 0;
4050 : 0 : int i4 = 0;
4051 : 0 : int i5 = 0;
4052 : 0 : int i6 = 0;
4053 : 0 : int i7 = 0;
4054 : 0 : int i8 = 0;
4055 : 0 : int i9 = 0;
4056 : :
4057 [ # # ]: 0 : if (!_PyArg_ParseStack(args, nargs, "y|iiiiiiiii:tparm",
4058 : : &str, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)) {
4059 : 0 : goto exit;
4060 : : }
4061 : 0 : return_value = _curses_tparm_impl(module, str, i1, i2, i3, i4, i5, i6, i7, i8, i9);
4062 : :
4063 : 0 : exit:
4064 : 0 : return return_value;
4065 : : }
4066 : :
4067 : : #if defined(HAVE_CURSES_TYPEAHEAD)
4068 : :
4069 : : PyDoc_STRVAR(_curses_typeahead__doc__,
4070 : : "typeahead($module, fd, /)\n"
4071 : : "--\n"
4072 : : "\n"
4073 : : "Specify that the file descriptor fd be used for typeahead checking.\n"
4074 : : "\n"
4075 : : " fd\n"
4076 : : " File descriptor.\n"
4077 : : "\n"
4078 : : "If fd is -1, then no typeahead checking is done.");
4079 : :
4080 : : #define _CURSES_TYPEAHEAD_METHODDEF \
4081 : : {"typeahead", (PyCFunction)_curses_typeahead, METH_O, _curses_typeahead__doc__},
4082 : :
4083 : : static PyObject *
4084 : : _curses_typeahead_impl(PyObject *module, int fd);
4085 : :
4086 : : static PyObject *
4087 : 0 : _curses_typeahead(PyObject *module, PyObject *arg)
4088 : : {
4089 : 0 : PyObject *return_value = NULL;
4090 : : int fd;
4091 : :
4092 : 0 : fd = _PyLong_AsInt(arg);
4093 [ # # # # ]: 0 : if (fd == -1 && PyErr_Occurred()) {
4094 : 0 : goto exit;
4095 : : }
4096 : 0 : return_value = _curses_typeahead_impl(module, fd);
4097 : :
4098 : 0 : exit:
4099 : 0 : return return_value;
4100 : : }
4101 : :
4102 : : #endif /* defined(HAVE_CURSES_TYPEAHEAD) */
4103 : :
4104 : : PyDoc_STRVAR(_curses_unctrl__doc__,
4105 : : "unctrl($module, ch, /)\n"
4106 : : "--\n"
4107 : : "\n"
4108 : : "Return a string which is a printable representation of the character ch.\n"
4109 : : "\n"
4110 : : "Control characters are displayed as a caret followed by the character,\n"
4111 : : "for example as ^C. Printing characters are left as they are.");
4112 : :
4113 : : #define _CURSES_UNCTRL_METHODDEF \
4114 : : {"unctrl", (PyCFunction)_curses_unctrl, METH_O, _curses_unctrl__doc__},
4115 : :
4116 : : PyDoc_STRVAR(_curses_ungetch__doc__,
4117 : : "ungetch($module, ch, /)\n"
4118 : : "--\n"
4119 : : "\n"
4120 : : "Push ch so the next getch() will return it.");
4121 : :
4122 : : #define _CURSES_UNGETCH_METHODDEF \
4123 : : {"ungetch", (PyCFunction)_curses_ungetch, METH_O, _curses_ungetch__doc__},
4124 : :
4125 : : #if defined(HAVE_NCURSESW)
4126 : :
4127 : : PyDoc_STRVAR(_curses_unget_wch__doc__,
4128 : : "unget_wch($module, ch, /)\n"
4129 : : "--\n"
4130 : : "\n"
4131 : : "Push ch so the next get_wch() will return it.");
4132 : :
4133 : : #define _CURSES_UNGET_WCH_METHODDEF \
4134 : : {"unget_wch", (PyCFunction)_curses_unget_wch, METH_O, _curses_unget_wch__doc__},
4135 : :
4136 : : #endif /* defined(HAVE_NCURSESW) */
4137 : :
4138 : : #if defined(HAVE_CURSES_USE_ENV)
4139 : :
4140 : : PyDoc_STRVAR(_curses_use_env__doc__,
4141 : : "use_env($module, flag, /)\n"
4142 : : "--\n"
4143 : : "\n"
4144 : : "Use environment variables LINES and COLUMNS.\n"
4145 : : "\n"
4146 : : "If used, this function should be called before initscr() or newterm() are\n"
4147 : : "called.\n"
4148 : : "\n"
4149 : : "When flag is False, the values of lines and columns specified in the terminfo\n"
4150 : : "database will be used, even if environment variables LINES and COLUMNS (used\n"
4151 : : "by default) are set, or if curses is running in a window (in which case\n"
4152 : : "default behavior would be to use the window size if LINES and COLUMNS are\n"
4153 : : "not set).");
4154 : :
4155 : : #define _CURSES_USE_ENV_METHODDEF \
4156 : : {"use_env", (PyCFunction)_curses_use_env, METH_O, _curses_use_env__doc__},
4157 : :
4158 : : static PyObject *
4159 : : _curses_use_env_impl(PyObject *module, int flag);
4160 : :
4161 : : static PyObject *
4162 : 0 : _curses_use_env(PyObject *module, PyObject *arg)
4163 : : {
4164 : 0 : PyObject *return_value = NULL;
4165 : : int flag;
4166 : :
4167 : 0 : flag = PyObject_IsTrue(arg);
4168 [ # # ]: 0 : if (flag < 0) {
4169 : 0 : goto exit;
4170 : : }
4171 : 0 : return_value = _curses_use_env_impl(module, flag);
4172 : :
4173 : 0 : exit:
4174 : 0 : return return_value;
4175 : : }
4176 : :
4177 : : #endif /* defined(HAVE_CURSES_USE_ENV) */
4178 : :
4179 : : #if !defined(STRICT_SYSV_CURSES)
4180 : :
4181 : : PyDoc_STRVAR(_curses_use_default_colors__doc__,
4182 : : "use_default_colors($module, /)\n"
4183 : : "--\n"
4184 : : "\n"
4185 : : "Allow use of default values for colors on terminals supporting this feature.\n"
4186 : : "\n"
4187 : : "Use this to support transparency in your application. The default color\n"
4188 : : "is assigned to the color number -1.");
4189 : :
4190 : : #define _CURSES_USE_DEFAULT_COLORS_METHODDEF \
4191 : : {"use_default_colors", (PyCFunction)_curses_use_default_colors, METH_NOARGS, _curses_use_default_colors__doc__},
4192 : :
4193 : : static PyObject *
4194 : : _curses_use_default_colors_impl(PyObject *module);
4195 : :
4196 : : static PyObject *
4197 : 0 : _curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
4198 : : {
4199 : 0 : return _curses_use_default_colors_impl(module);
4200 : : }
4201 : :
4202 : : #endif /* !defined(STRICT_SYSV_CURSES) */
4203 : :
4204 : : PyDoc_STRVAR(_curses_has_extended_color_support__doc__,
4205 : : "has_extended_color_support($module, /)\n"
4206 : : "--\n"
4207 : : "\n"
4208 : : "Return True if the module supports extended colors; otherwise, return False.\n"
4209 : : "\n"
4210 : : "Extended color support allows more than 256 color-pairs for terminals\n"
4211 : : "that support more than 16 colors (e.g. xterm-256color).");
4212 : :
4213 : : #define _CURSES_HAS_EXTENDED_COLOR_SUPPORT_METHODDEF \
4214 : : {"has_extended_color_support", (PyCFunction)_curses_has_extended_color_support, METH_NOARGS, _curses_has_extended_color_support__doc__},
4215 : :
4216 : : static PyObject *
4217 : : _curses_has_extended_color_support_impl(PyObject *module);
4218 : :
4219 : : static PyObject *
4220 : 0 : _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored))
4221 : : {
4222 : 0 : return _curses_has_extended_color_support_impl(module);
4223 : : }
4224 : :
4225 : : #ifndef _CURSES_WINDOW_ENCLOSE_METHODDEF
4226 : : #define _CURSES_WINDOW_ENCLOSE_METHODDEF
4227 : : #endif /* !defined(_CURSES_WINDOW_ENCLOSE_METHODDEF) */
4228 : :
4229 : : #ifndef _CURSES_WINDOW_GET_WCH_METHODDEF
4230 : : #define _CURSES_WINDOW_GET_WCH_METHODDEF
4231 : : #endif /* !defined(_CURSES_WINDOW_GET_WCH_METHODDEF) */
4232 : :
4233 : : #ifndef _CURSES_WINDOW_NOUTREFRESH_METHODDEF
4234 : : #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF
4235 : : #endif /* !defined(_CURSES_WINDOW_NOUTREFRESH_METHODDEF) */
4236 : :
4237 : : #ifndef _CURSES_FILTER_METHODDEF
4238 : : #define _CURSES_FILTER_METHODDEF
4239 : : #endif /* !defined(_CURSES_FILTER_METHODDEF) */
4240 : :
4241 : : #ifndef _CURSES_GETSYX_METHODDEF
4242 : : #define _CURSES_GETSYX_METHODDEF
4243 : : #endif /* !defined(_CURSES_GETSYX_METHODDEF) */
4244 : :
4245 : : #ifndef _CURSES_GETMOUSE_METHODDEF
4246 : : #define _CURSES_GETMOUSE_METHODDEF
4247 : : #endif /* !defined(_CURSES_GETMOUSE_METHODDEF) */
4248 : :
4249 : : #ifndef _CURSES_UNGETMOUSE_METHODDEF
4250 : : #define _CURSES_UNGETMOUSE_METHODDEF
4251 : : #endif /* !defined(_CURSES_UNGETMOUSE_METHODDEF) */
4252 : :
4253 : : #ifndef _CURSES_HAS_KEY_METHODDEF
4254 : : #define _CURSES_HAS_KEY_METHODDEF
4255 : : #endif /* !defined(_CURSES_HAS_KEY_METHODDEF) */
4256 : :
4257 : : #ifndef _CURSES_GET_ESCDELAY_METHODDEF
4258 : : #define _CURSES_GET_ESCDELAY_METHODDEF
4259 : : #endif /* !defined(_CURSES_GET_ESCDELAY_METHODDEF) */
4260 : :
4261 : : #ifndef _CURSES_SET_ESCDELAY_METHODDEF
4262 : : #define _CURSES_SET_ESCDELAY_METHODDEF
4263 : : #endif /* !defined(_CURSES_SET_ESCDELAY_METHODDEF) */
4264 : :
4265 : : #ifndef _CURSES_GET_TABSIZE_METHODDEF
4266 : : #define _CURSES_GET_TABSIZE_METHODDEF
4267 : : #endif /* !defined(_CURSES_GET_TABSIZE_METHODDEF) */
4268 : :
4269 : : #ifndef _CURSES_SET_TABSIZE_METHODDEF
4270 : : #define _CURSES_SET_TABSIZE_METHODDEF
4271 : : #endif /* !defined(_CURSES_SET_TABSIZE_METHODDEF) */
4272 : :
4273 : : #ifndef _CURSES_IS_TERM_RESIZED_METHODDEF
4274 : : #define _CURSES_IS_TERM_RESIZED_METHODDEF
4275 : : #endif /* !defined(_CURSES_IS_TERM_RESIZED_METHODDEF) */
4276 : :
4277 : : #ifndef _CURSES_MOUSEINTERVAL_METHODDEF
4278 : : #define _CURSES_MOUSEINTERVAL_METHODDEF
4279 : : #endif /* !defined(_CURSES_MOUSEINTERVAL_METHODDEF) */
4280 : :
4281 : : #ifndef _CURSES_MOUSEMASK_METHODDEF
4282 : : #define _CURSES_MOUSEMASK_METHODDEF
4283 : : #endif /* !defined(_CURSES_MOUSEMASK_METHODDEF) */
4284 : :
4285 : : #ifndef _CURSES_UPDATE_LINES_COLS_METHODDEF
4286 : : #define _CURSES_UPDATE_LINES_COLS_METHODDEF
4287 : : #endif /* !defined(_CURSES_UPDATE_LINES_COLS_METHODDEF) */
4288 : :
4289 : : #ifndef _CURSES_RESIZETERM_METHODDEF
4290 : : #define _CURSES_RESIZETERM_METHODDEF
4291 : : #endif /* !defined(_CURSES_RESIZETERM_METHODDEF) */
4292 : :
4293 : : #ifndef _CURSES_RESIZE_TERM_METHODDEF
4294 : : #define _CURSES_RESIZE_TERM_METHODDEF
4295 : : #endif /* !defined(_CURSES_RESIZE_TERM_METHODDEF) */
4296 : :
4297 : : #ifndef _CURSES_SETSYX_METHODDEF
4298 : : #define _CURSES_SETSYX_METHODDEF
4299 : : #endif /* !defined(_CURSES_SETSYX_METHODDEF) */
4300 : :
4301 : : #ifndef _CURSES_TYPEAHEAD_METHODDEF
4302 : : #define _CURSES_TYPEAHEAD_METHODDEF
4303 : : #endif /* !defined(_CURSES_TYPEAHEAD_METHODDEF) */
4304 : :
4305 : : #ifndef _CURSES_UNGET_WCH_METHODDEF
4306 : : #define _CURSES_UNGET_WCH_METHODDEF
4307 : : #endif /* !defined(_CURSES_UNGET_WCH_METHODDEF) */
4308 : :
4309 : : #ifndef _CURSES_USE_ENV_METHODDEF
4310 : : #define _CURSES_USE_ENV_METHODDEF
4311 : : #endif /* !defined(_CURSES_USE_ENV_METHODDEF) */
4312 : :
4313 : : #ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
4314 : : #define _CURSES_USE_DEFAULT_COLORS_METHODDEF
4315 : : #endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
4316 : : /*[clinic end generated code: output=27a2364193b503c1 input=a9049054013a1b77]*/
|