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