Debian Codegraph @

Modules/clinic/_cursesmodule.c.h

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