Debian Codegraph @

Modules/clinic/_cursesmodule.c.h

raw
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4
5 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 # include "pycore_gc.h" // PyGC_Head
7 # include "pycore_runtime.h" // _Py_ID()
8 #endif
9 #include "pycore_modsupport.h" // _PyArg_CheckPositional()
10
11 PyDoc_STRVAR(_curses_window_addch__doc__,
12 "addch([y, x,] ch, [attr=_curses.A_NORMAL])\n"
13 "Paint the character.\n"
14 "\n"
15 " y\n"
16 " Y-coordinate.\n"
17 " x\n"
18 " X-coordinate.\n"
19 " ch\n"
20 " Character to add.\n"
21 " attr\n"
22 " Attributes for the character.\n"
23 "\n"
24 "Paint character ch at (y, x) with attributes attr,\n"
25 "overwriting any character previously painted at that location.\n"
26 "By default, the character position and attributes are the\n"
27 "current settings for the window object.");
28
29 #define _CURSES_WINDOW_ADDCH_METHODDEF \
30 {"addch", (PyCFunction)_curses_window_addch, METH_VARARGS, _curses_window_addch__doc__},
31
32 static PyObject *
33 _curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1,
34 int y, int x, PyObject *ch, int group_right_1,
35 long attr);
36
37 static PyObject *
38 _curses_window_addch(PyObject *self, PyObject *args)
39 {
40 PyObject *return_value = NULL;
41 int group_left_1 = 0;
42 int y = 0;
43 int x = 0;
44 PyObject *ch;
45 int group_right_1 = 0;
46 long attr = A_NORMAL;
47
48 switch (PyTuple_GET_SIZE(args)) {
49 case 1:
50 if (!PyArg_ParseTuple(args, "O:addch", &ch)) {
51 goto exit;
52 }
53 break;
54 case 2:
55 if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) {
56 goto exit;
57 }
58 group_right_1 = 1;
59 break;
60 case 3:
61 if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) {
62 goto exit;
63 }
64 group_left_1 = 1;
65 break;
66 case 4:
67 if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) {
68 goto exit;
69 }
70 group_right_1 = 1;
71 group_left_1 = 1;
72 break;
73 default:
74 PyErr_SetString(PyExc_TypeError, "_curses.window.addch requires 1 to 4 arguments");
75 goto exit;
76 }
77 return_value = _curses_window_addch_impl((PyCursesWindowObject *)self, group_left_1, y, x, ch, group_right_1, attr);
78
79 exit:
80 return return_value;
81 }
82
83 PyDoc_STRVAR(_curses_window_addstr__doc__,
84 "addstr([y, x,] str, [attr])\n"
85 "Paint the string.\n"
86 "\n"
87 " y\n"
88 " Y-coordinate.\n"
89 " x\n"
90 " X-coordinate.\n"
91 " str\n"
92 " String to add.\n"
93 " attr\n"
94 " Attributes for characters.\n"
95 "\n"
96 "Paint the string str at (y, x) with attributes attr,\n"
97 "overwriting anything previously on the display.\n"
98 "By default, the character position and attributes are the\n"
99 "current settings for the window object.");
100
101 #define _CURSES_WINDOW_ADDSTR_METHODDEF \
102 {"addstr", (PyCFunction)_curses_window_addstr, METH_VARARGS, _curses_window_addstr__doc__},
103
104 static PyObject *
105 _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
106 int y, int x, PyObject *str, int group_right_1,
107 long attr);
108
109 static PyObject *
110 _curses_window_addstr(PyObject *self, PyObject *args)
111 {
112 PyObject *return_value = NULL;
113 int group_left_1 = 0;
114 int y = 0;
115 int x = 0;
116 PyObject *str;
117 int group_right_1 = 0;
118 long attr = 0;
119
120 switch (PyTuple_GET_SIZE(args)) {
121 case 1:
122 if (!PyArg_ParseTuple(args, "O:addstr", &str)) {
123 goto exit;
124 }
125 break;
126 case 2:
127 if (!PyArg_ParseTuple(args, "Ol:addstr", &str, &attr)) {
128 goto exit;
129 }
130 group_right_1 = 1;
131 break;
132 case 3:
133 if (!PyArg_ParseTuple(args, "iiO:addstr", &y, &x, &str)) {
134 goto exit;
135 }
136 group_left_1 = 1;
137 break;
138 case 4:
139 if (!PyArg_ParseTuple(args, "iiOl:addstr", &y, &x, &str, &attr)) {
140 goto exit;
141 }
142 group_right_1 = 1;
143 group_left_1 = 1;
144 break;
145 default:
146 PyErr_SetString(PyExc_TypeError, "_curses.window.addstr requires 1 to 4 arguments");
147 goto exit;
148 }
149 return_value = _curses_window_addstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, str, group_right_1, attr);
150
151 exit:
152 return return_value;
153 }
154
155 PyDoc_STRVAR(_curses_window_addnstr__doc__,
156 "addnstr([y, x,] str, n, [attr])\n"
157 "Paint at most n characters of the string.\n"
158 "\n"
159 " y\n"
160 " Y-coordinate.\n"
161 " x\n"
162 " X-coordinate.\n"
163 " str\n"
164 " String to add.\n"
165 " n\n"
166 " Maximal number of characters.\n"
167 " attr\n"
168 " Attributes for characters.\n"
169 "\n"
170 "Paint at most n characters of the string str at (y, x) with\n"
171 "attributes attr, overwriting anything previously on the display.\n"
172 "By default, the character position and attributes are the\n"
173 "current settings for the window object.");
174
175 #define _CURSES_WINDOW_ADDNSTR_METHODDEF \
176 {"addnstr", (PyCFunction)_curses_window_addnstr, METH_VARARGS, _curses_window_addnstr__doc__},
177
178 static PyObject *
179 _curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
180 int y, int x, PyObject *str, int n,
181 int group_right_1, long attr);
182
183 static PyObject *
184 _curses_window_addnstr(PyObject *self, PyObject *args)
185 {
186 PyObject *return_value = NULL;
187 int group_left_1 = 0;
188 int y = 0;
189 int x = 0;
190 PyObject *str;
191 int n;
192 int group_right_1 = 0;
193 long attr = 0;
194
195 switch (PyTuple_GET_SIZE(args)) {
196 case 2:
197 if (!PyArg_ParseTuple(args, "Oi:addnstr", &str, &n)) {
198 goto exit;
199 }
200 break;
201 case 3:
202 if (!PyArg_ParseTuple(args, "Oil:addnstr", &str, &n, &attr)) {
203 goto exit;
204 }
205 group_right_1 = 1;
206 break;
207 case 4:
208 if (!PyArg_ParseTuple(args, "iiOi:addnstr", &y, &x, &str, &n)) {
209 goto exit;
210 }
211 group_left_1 = 1;
212 break;
213 case 5:
214 if (!PyArg_ParseTuple(args, "iiOil:addnstr", &y, &x, &str, &n, &attr)) {
215 goto exit;
216 }
217 group_right_1 = 1;
218 group_left_1 = 1;
219 break;
220 default:
221 PyErr_SetString(PyExc_TypeError, "_curses.window.addnstr requires 2 to 5 arguments");
222 goto exit;
223 }
224 return_value = _curses_window_addnstr_impl((PyCursesWindowObject *)self, group_left_1, y, x, str, n, group_right_1, attr);
225
226 exit:
227 return return_value;
228 }
229
230 PyDoc_STRVAR(_curses_window_bkgd__doc__,
231 "bkgd($self, ch, attr=_curses.A_NORMAL, /)\n"
232 "--\n"
233 "\n"
234 "Set the background property of the window.\n"
235 "\n"
236 " ch\n"
237 " Background character.\n"
238 " attr\n"
239 " Background attributes.");
240
241 #define _CURSES_WINDOW_BKGD_METHODDEF \
242 {"bkgd", _PyCFunction_CAST(_curses_window_bkgd), METH_FASTCALL, _curses_window_bkgd__doc__},
243
244 static PyObject *
245 _curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch, long attr);
246
247 static PyObject *
248 _curses_window_bkgd(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
249 {
250 PyObject *return_value = NULL;
251 PyObject *ch;
252 long attr = A_NORMAL;
253
254 if (!_PyArg_CheckPositional("bkgd", nargs, 1, 2)) {
255 goto exit;
256 }
257 ch = args[0];
258 if (nargs < 2) {
259 goto skip_optional;
260 }
261 attr = PyLong_AsLong(args[1]);
262 if (attr == -1 && PyErr_Occurred()) {
263 goto exit;
264 }
265 skip_optional:
266 return_value = _curses_window_bkgd_impl((PyCursesWindowObject *)self, ch, attr);
267
268 exit:
269 return return_value;
270 }
271
272 PyDoc_STRVAR(_curses_window_attroff__doc__,
273 "attroff($self, attr, /)\n"
274 "--\n"
275 "\n"
276 "Remove attribute attr from the \"background\" set.");
277
278 #define _CURSES_WINDOW_ATTROFF_METHODDEF \
279 {"attroff", (PyCFunction)_curses_window_attroff, METH_O, _curses_window_attroff__doc__},
280
281 static PyObject *
282 _curses_window_attroff_impl(PyCursesWindowObject *self, long attr);
283
284 static PyObject *
285 _curses_window_attroff(PyObject *self, PyObject *arg)
286 {
287 PyObject *return_value = NULL;
288 long attr;
289
290 attr = PyLong_AsLong(arg);
291 if (attr == -1 && PyErr_Occurred()) {
292 goto exit;
293 }
294 return_value = _curses_window_attroff_impl((PyCursesWindowObject *)self, attr);
295
296 exit:
297 return return_value;
298 }
299
300 PyDoc_STRVAR(_curses_window_attron__doc__,
301 "attron($self, attr, /)\n"
302 "--\n"
303 "\n"
304 "Add attribute attr to the \"background\" set.");
305
306 #define _CURSES_WINDOW_ATTRON_METHODDEF \
307 {"attron", (PyCFunction)_curses_window_attron, METH_O, _curses_window_attron__doc__},
308
309 static PyObject *
310 _curses_window_attron_impl(PyCursesWindowObject *self, long attr);
311
312 static PyObject *
313 _curses_window_attron(PyObject *self, PyObject *arg)
314 {
315 PyObject *return_value = NULL;
316 long attr;
317
318 attr = PyLong_AsLong(arg);
319 if (attr == -1 && PyErr_Occurred()) {
320 goto exit;
321 }
322 return_value = _curses_window_attron_impl((PyCursesWindowObject *)self, attr);
323
324 exit:
325 return return_value;
326 }
327
328 PyDoc_STRVAR(_curses_window_attrset__doc__,
329 "attrset($self, attr, /)\n"
330 "--\n"
331 "\n"
332 "Set the \"background\" set of attributes.");
333
334 #define _CURSES_WINDOW_ATTRSET_METHODDEF \
335 {"attrset", (PyCFunction)_curses_window_attrset, METH_O, _curses_window_attrset__doc__},
336
337 static PyObject *
338 _curses_window_attrset_impl(PyCursesWindowObject *self, long attr);
339
340 static PyObject *
341 _curses_window_attrset(PyObject *self, PyObject *arg)
342 {
343 PyObject *return_value = NULL;
344 long attr;
345
346 attr = PyLong_AsLong(arg);
347 if (attr == -1 && PyErr_Occurred()) {
348 goto exit;
349 }
350 return_value = _curses_window_attrset_impl((PyCursesWindowObject *)self, attr);
351
352 exit:
353 return return_value;
354 }
355
356 PyDoc_STRVAR(_curses_window_bkgdset__doc__,
357 "bkgdset($self, ch, attr=_curses.A_NORMAL, /)\n"
358 "--\n"
359 "\n"
360 "Set the window\'s background.\n"
361 "\n"
362 " ch\n"
363 " Background character.\n"
364 " attr\n"
365 " Background attributes.");
366
367 #define _CURSES_WINDOW_BKGDSET_METHODDEF \
368 {"bkgdset", _PyCFunction_CAST(_curses_window_bkgdset), METH_FASTCALL, _curses_window_bkgdset__doc__},
369
370 static PyObject *
371 _curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch,
372 long attr);
373
374 static PyObject *
375 _curses_window_bkgdset(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
376 {
377 PyObject *return_value = NULL;
378 PyObject *ch;
379 long attr = A_NORMAL;
380
381 if (!_PyArg_CheckPositional("bkgdset", nargs, 1, 2)) {
382 goto exit;
383 }
384 ch = args[0];
385 if (nargs < 2) {
386 goto skip_optional;
387 }
388 attr = PyLong_AsLong(args[1]);
389 if (attr == -1 && PyErr_Occurred()) {
390 goto exit;
391 }
392 skip_optional:
393 return_value = _curses_window_bkgdset_impl((PyCursesWindowObject *)self, ch, attr);
394
395 exit:
396 return return_value;
397 }
398
399 PyDoc_STRVAR(_curses_window_border__doc__,
400 "border($self, ls=_curses.ACS_VLINE, rs=_curses.ACS_VLINE,\n"
401 " ts=_curses.ACS_HLINE, bs=_curses.ACS_HLINE,\n"
402 " tl=_curses.ACS_ULCORNER, tr=_curses.ACS_URCORNER,\n"
403 " bl=_curses.ACS_LLCORNER, br=_curses.ACS_LRCORNER, /)\n"
404 "--\n"
405 "\n"
406 "Draw a border around the edges of the window.\n"
407 "\n"
408 " ls\n"
409 " Left side.\n"
410 " rs\n"
411 " Right side.\n"
412 " ts\n"
413 " Top side.\n"
414 " bs\n"
415 " Bottom side.\n"
416 " tl\n"
417 " Upper-left corner.\n"
418 " tr\n"
419 " Upper-right corner.\n"
420 " bl\n"
421 " Bottom-left corner.\n"
422 " br\n"
423 " Bottom-right corner.\n"
424 "\n"
425 "Each parameter specifies the character to use for a specific part of 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(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
441 {
442 PyObject *return_value = NULL;
443 PyObject *ls = NULL;
444 PyObject *rs = NULL;
445 PyObject *ts = NULL;
446 PyObject *bs = NULL;
447 PyObject *tl = NULL;
448 PyObject *tr = NULL;
449 PyObject *bl = NULL;
450 PyObject *br = NULL;
451
452 if (!_PyArg_CheckPositional("border", nargs, 0, 8)) {
453 goto exit;
454 }
455 if (nargs < 1) {
456 goto skip_optional;
457 }
458 ls = args[0];
459 if (nargs < 2) {
460 goto skip_optional;
461 }
462 rs = args[1];
463 if (nargs < 3) {
464 goto skip_optional;
465 }
466 ts = args[2];
467 if (nargs < 4) {
468 goto skip_optional;
469 }
470 bs = args[3];
471 if (nargs < 5) {
472 goto skip_optional;
473 }
474 tl = args[4];
475 if (nargs < 6) {
476 goto skip_optional;
477 }
478 tr = args[5];
479 if (nargs < 7) {
480 goto skip_optional;
481 }
482 bl = args[6];
483 if (nargs < 8) {
484 goto skip_optional;
485 }
486 br = args[7];
487 skip_optional:
488 return_value = _curses_window_border_impl((PyCursesWindowObject *)self, ls, rs, ts, bs, tl, tr, bl, br);
489
490 exit:
491 return return_value;
492 }
493
494 PyDoc_STRVAR(_curses_window_box__doc__,
495 "box([verch=0, horch=0])\n"
496 "Draw a border around the edges of the window.\n"
497 "\n"
498 " verch\n"
499 " Left and right side.\n"
500 " horch\n"
501 " Top and bottom side.\n"
502 "\n"
503 "Similar to border(), but both ls and rs are verch and both ts and bs 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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *self, PyObject *Py_UNUSED(ignored))
741 {
742 PyObject *return_value = NULL;
743 long _return_value;
744
745 _return_value = _curses_window_getbkgd_impl((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *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((PyCursesWindowObject *)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(PyObject *self, PyObject *Py_UNUSED(ignored))
1344 {
1345 return _curses_window_noutrefresh_impl((PyCursesWindowObject *)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(PyObject *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", clinic_state()->window_type, &destwin)) {
1388 goto exit;
1389 }
1390 break;
1391 case 7:
1392 if (!PyArg_ParseTuple(args, "O!iiiiii:overlay", clinic_state()->window_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((PyCursesWindowObject *)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(PyObject *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", clinic_state()->window_type, &destwin)) {
1447 goto exit;
1448 }
1449 break;
1450 case 7:
1451 if (!PyArg_ParseTuple(args, "O!iiiiii:overwrite", clinic_state()->window_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((PyCursesWindowObject *)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 static PyObject *
1478 _curses_window_putwin_impl(PyCursesWindowObject *self, PyObject *file);
1479
1480 static PyObject *
1481 _curses_window_putwin(PyObject *self, PyObject *file)
1482 {
1483 PyObject *return_value = NULL;
1484
1485 return_value = _curses_window_putwin_impl((PyCursesWindowObject *)self, file);
1486
1487 return return_value;
1488 }
1489
1490 PyDoc_STRVAR(_curses_window_redrawln__doc__,
1491 "redrawln($self, beg, num, /)\n"
1492 "--\n"
1493 "\n"
1494 "Mark the specified lines corrupted.\n"
1495 "\n"
1496 " beg\n"
1497 " Starting line number.\n"
1498 " num\n"
1499 " The number of lines.\n"
1500 "\n"
1501 "They should be completely redrawn on the next refresh() call.");
1502
1503 #define _CURSES_WINDOW_REDRAWLN_METHODDEF \
1504 {"redrawln", _PyCFunction_CAST(_curses_window_redrawln), METH_FASTCALL, _curses_window_redrawln__doc__},
1505
1506 static PyObject *
1507 _curses_window_redrawln_impl(PyCursesWindowObject *self, int beg, int num);
1508
1509 static PyObject *
1510 _curses_window_redrawln(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
1511 {
1512 PyObject *return_value = NULL;
1513 int beg;
1514 int num;
1515
1516 if (!_PyArg_CheckPositional("redrawln", nargs, 2, 2)) {
1517 goto exit;
1518 }
1519 beg = PyLong_AsInt(args[0]);
1520 if (beg == -1 && PyErr_Occurred()) {
1521 goto exit;
1522 }
1523 num = PyLong_AsInt(args[1]);
1524 if (num == -1 && PyErr_Occurred()) {
1525 goto exit;
1526 }
1527 return_value = _curses_window_redrawln_impl((PyCursesWindowObject *)self, beg, num);
1528
1529 exit:
1530 return return_value;
1531 }
1532
1533 PyDoc_STRVAR(_curses_window_refresh__doc__,
1534 "refresh([pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol])\n"
1535 "Update the display immediately.\n"
1536 "\n"
1537 "Synchronize actual screen with previous drawing/deleting methods.\n"
1538 "The 6 optional arguments can only be specified when the window is a pad\n"
1539 "created with newpad(). The additional parameters are needed to indicate\n"
1540 "what part of the pad and screen are involved. pminrow and pmincol specify\n"
1541 "the upper left-hand corner of the rectangle to be displayed in the pad.\n"
1542 "sminrow, smincol, smaxrow, and smaxcol specify the edges of the rectangle to\n"
1543 "be displayed on the screen. The lower right-hand corner of the rectangle to\n"
1544 "be displayed in the pad is calculated from the screen coordinates, since the\n"
1545 "rectangles must be the same size. Both rectangles must be entirely contained\n"
1546 "within their respective structures. Negative values of pminrow, pmincol,\n"
1547 "sminrow, or smincol are treated as if they were zero.");
1548
1549 #define _CURSES_WINDOW_REFRESH_METHODDEF \
1550 {"refresh", (PyCFunction)_curses_window_refresh, METH_VARARGS, _curses_window_refresh__doc__},
1551
1552 static PyObject *
1553 _curses_window_refresh_impl(PyCursesWindowObject *self, int group_right_1,
1554 int pminrow, int pmincol, int sminrow,
1555 int smincol, int smaxrow, int smaxcol);
1556
1557 static PyObject *
1558 _curses_window_refresh(PyObject *self, PyObject *args)
1559 {
1560 PyObject *return_value = NULL;
1561 int group_right_1 = 0;
1562 int pminrow = 0;
1563 int pmincol = 0;
1564 int sminrow = 0;
1565 int smincol = 0;
1566 int smaxrow = 0;
1567 int smaxcol = 0;
1568
1569 switch (PyTuple_GET_SIZE(args)) {
1570 case 0:
1571 break;
1572 case 6:
1573 if (!PyArg_ParseTuple(args, "iiiiii:refresh", &pminrow, &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol)) {
1574 goto exit;
1575 }
1576 group_right_1 = 1;
1577 break;
1578 default:
1579 PyErr_SetString(PyExc_TypeError, "_curses.window.refresh requires 0 to 6 arguments");
1580 goto exit;
1581 }
1582 return_value = _curses_window_refresh_impl((PyCursesWindowObject *)self, group_right_1, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol);
1583
1584 exit:
1585 return return_value;
1586 }
1587
1588 PyDoc_STRVAR(_curses_window_setscrreg__doc__,
1589 "setscrreg($self, top, bottom, /)\n"
1590 "--\n"
1591 "\n"
1592 "Define a software scrolling region.\n"
1593 "\n"
1594 " top\n"
1595 " First line number.\n"
1596 " bottom\n"
1597 " Last line number.\n"
1598 "\n"
1599 "All scrolling actions will take place in this region.");
1600
1601 #define _CURSES_WINDOW_SETSCRREG_METHODDEF \
1602 {"setscrreg", _PyCFunction_CAST(_curses_window_setscrreg), METH_FASTCALL, _curses_window_setscrreg__doc__},
1603
1604 static PyObject *
1605 _curses_window_setscrreg_impl(PyCursesWindowObject *self, int top,
1606 int bottom);
1607
1608 static PyObject *
1609 _curses_window_setscrreg(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
1610 {
1611 PyObject *return_value = NULL;
1612 int top;
1613 int bottom;
1614
1615 if (!_PyArg_CheckPositional("setscrreg", nargs, 2, 2)) {
1616 goto exit;
1617 }
1618 top = PyLong_AsInt(args[0]);
1619 if (top == -1 && PyErr_Occurred()) {
1620 goto exit;
1621 }
1622 bottom = PyLong_AsInt(args[1]);
1623 if (bottom == -1 && PyErr_Occurred()) {
1624 goto exit;
1625 }
1626 return_value = _curses_window_setscrreg_impl((PyCursesWindowObject *)self, top, bottom);
1627
1628 exit:
1629 return return_value;
1630 }
1631
1632 PyDoc_STRVAR(_curses_window_subwin__doc__,
1633 "subwin([nlines=0, ncols=0,] begin_y, begin_x)\n"
1634 "Create a sub-window (screen-relative coordinates).\n"
1635 "\n"
1636 " nlines\n"
1637 " Height.\n"
1638 " ncols\n"
1639 " Width.\n"
1640 " begin_y\n"
1641 " Top side y-coordinate.\n"
1642 " begin_x\n"
1643 " Left side x-coordinate.\n"
1644 "\n"
1645 "By default, the sub-window will extend from the specified position to the\n"
1646 "lower right corner of the window.");
1647
1648 #define _CURSES_WINDOW_SUBWIN_METHODDEF \
1649 {"subwin", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__},
1650
1651 static PyObject *
1652 _curses_window_subwin_impl(PyCursesWindowObject *self, int group_left_1,
1653 int nlines, int ncols, int begin_y, int begin_x);
1654
1655 static PyObject *
1656 _curses_window_subwin(PyObject *self, PyObject *args)
1657 {
1658 PyObject *return_value = NULL;
1659 int group_left_1 = 0;
1660 int nlines = 0;
1661 int ncols = 0;
1662 int begin_y;
1663 int begin_x;
1664
1665 switch (PyTuple_GET_SIZE(args)) {
1666 case 2:
1667 if (!PyArg_ParseTuple(args, "ii:subwin", &begin_y, &begin_x)) {
1668 goto exit;
1669 }
1670 break;
1671 case 4:
1672 if (!PyArg_ParseTuple(args, "iiii:subwin", &nlines, &ncols, &begin_y, &begin_x)) {
1673 goto exit;
1674 }
1675 group_left_1 = 1;
1676 break;
1677 default:
1678 PyErr_SetString(PyExc_TypeError, "_curses.window.subwin requires 2 to 4 arguments");
1679 goto exit;
1680 }
1681 return_value = _curses_window_subwin_impl((PyCursesWindowObject *)self, group_left_1, nlines, ncols, begin_y, begin_x);
1682
1683 exit:
1684 return return_value;
1685 }
1686
1687 PyDoc_STRVAR(_curses_window_scroll__doc__,
1688 "scroll([lines=1])\n"
1689 "Scroll the screen or scrolling region.\n"
1690 "\n"
1691 " lines\n"
1692 " Number of lines to scroll.\n"
1693 "\n"
1694 "Scroll upward if the argument is positive and downward if it is negative.");
1695
1696 #define _CURSES_WINDOW_SCROLL_METHODDEF \
1697 {"scroll", (PyCFunction)_curses_window_scroll, METH_VARARGS, _curses_window_scroll__doc__},
1698
1699 static PyObject *
1700 _curses_window_scroll_impl(PyCursesWindowObject *self, int group_right_1,
1701 int lines);
1702
1703 static PyObject *
1704 _curses_window_scroll(PyObject *self, PyObject *args)
1705 {
1706 PyObject *return_value = NULL;
1707 int group_right_1 = 0;
1708 int lines = 1;
1709
1710 switch (PyTuple_GET_SIZE(args)) {
1711 case 0:
1712 break;
1713 case 1:
1714 if (!PyArg_ParseTuple(args, "i:scroll", &lines)) {
1715 goto exit;
1716 }
1717 group_right_1 = 1;
1718 break;
1719 default:
1720 PyErr_SetString(PyExc_TypeError, "_curses.window.scroll requires 0 to 1 arguments");
1721 goto exit;
1722 }
1723 return_value = _curses_window_scroll_impl((PyCursesWindowObject *)self, group_right_1, lines);
1724
1725 exit:
1726 return return_value;
1727 }
1728
1729 PyDoc_STRVAR(_curses_window_touchline__doc__,
1730 "touchline(start, count, [changed=True])\n"
1731 "Pretend count lines have been changed, starting with line start.\n"
1732 "\n"
1733 "If changed is supplied, it specifies whether the affected lines are marked\n"
1734 "as having been changed (changed=True) or unchanged (changed=False).");
1735
1736 #define _CURSES_WINDOW_TOUCHLINE_METHODDEF \
1737 {"touchline", (PyCFunction)_curses_window_touchline, METH_VARARGS, _curses_window_touchline__doc__},
1738
1739 static PyObject *
1740 _curses_window_touchline_impl(PyCursesWindowObject *self, int start,
1741 int count, int group_right_1, int changed);
1742
1743 static PyObject *
1744 _curses_window_touchline(PyObject *self, PyObject *args)
1745 {
1746 PyObject *return_value = NULL;
1747 int start;
1748 int count;
1749 int group_right_1 = 0;
1750 int changed = 1;
1751
1752 switch (PyTuple_GET_SIZE(args)) {
1753 case 2:
1754 if (!PyArg_ParseTuple(args, "ii:touchline", &start, &count)) {
1755 goto exit;
1756 }
1757 break;
1758 case 3:
1759 if (!PyArg_ParseTuple(args, "iip:touchline", &start, &count, &changed)) {
1760 goto exit;
1761 }
1762 group_right_1 = 1;
1763 break;
1764 default:
1765 PyErr_SetString(PyExc_TypeError, "_curses.window.touchline requires 2 to 3 arguments");
1766 goto exit;
1767 }
1768 return_value = _curses_window_touchline_impl((PyCursesWindowObject *)self, start, count, group_right_1, changed);
1769
1770 exit:
1771 return return_value;
1772 }
1773
1774 PyDoc_STRVAR(_curses_window_vline__doc__,
1775 "vline([y, x,] ch, n, [attr=_curses.A_NORMAL])\n"
1776 "Display a vertical line.\n"
1777 "\n"
1778 " y\n"
1779 " Starting Y-coordinate.\n"
1780 " x\n"
1781 " Starting X-coordinate.\n"
1782 " ch\n"
1783 " Character to draw.\n"
1784 " n\n"
1785 " Line length.\n"
1786 " attr\n"
1787 " Attributes for the character.");
1788
1789 #define _CURSES_WINDOW_VLINE_METHODDEF \
1790 {"vline", (PyCFunction)_curses_window_vline, METH_VARARGS, _curses_window_vline__doc__},
1791
1792 static PyObject *
1793 _curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1,
1794 int y, int x, PyObject *ch, int n,
1795 int group_right_1, long attr);
1796
1797 static PyObject *
1798 _curses_window_vline(PyObject *self, PyObject *args)
1799 {
1800 PyObject *return_value = NULL;
1801 int group_left_1 = 0;
1802 int y = 0;
1803 int x = 0;
1804 PyObject *ch;
1805 int n;
1806 int group_right_1 = 0;
1807 long attr = A_NORMAL;
1808
1809 switch (PyTuple_GET_SIZE(args)) {
1810 case 2:
1811 if (!PyArg_ParseTuple(args, "Oi:vline", &ch, &n)) {
1812 goto exit;
1813 }
1814 break;
1815 case 3:
1816 if (!PyArg_ParseTuple(args, "Oil:vline", &ch, &n, &attr)) {
1817 goto exit;
1818 }
1819 group_right_1 = 1;
1820 break;
1821 case 4:
1822 if (!PyArg_ParseTuple(args, "iiOi:vline", &y, &x, &ch, &n)) {
1823 goto exit;
1824 }
1825 group_left_1 = 1;
1826 break;
1827 case 5:
1828 if (!PyArg_ParseTuple(args, "iiOil:vline", &y, &x, &ch, &n, &attr)) {
1829 goto exit;
1830 }
1831 group_right_1 = 1;
1832 group_left_1 = 1;
1833 break;
1834 default:
1835 PyErr_SetString(PyExc_TypeError, "_curses.window.vline requires 2 to 5 arguments");
1836 goto exit;
1837 }
1838 return_value = _curses_window_vline_impl((PyCursesWindowObject *)self, group_left_1, y, x, ch, n, group_right_1, attr);
1839
1840 exit:
1841 return return_value;
1842 }
1843
1844 #if defined(HAVE_CURSES_FILTER)
1845
1846 PyDoc_STRVAR(_curses_filter__doc__,
1847 "filter($module, /)\n"
1848 "--\n"
1849 "\n");
1850
1851 #define _CURSES_FILTER_METHODDEF \
1852 {"filter", (PyCFunction)_curses_filter, METH_NOARGS, _curses_filter__doc__},
1853
1854 static PyObject *
1855 _curses_filter_impl(PyObject *module);
1856
1857 static PyObject *
1858 _curses_filter(PyObject *module, PyObject *Py_UNUSED(ignored))
1859 {
1860 return _curses_filter_impl(module);
1861 }
1862
1863 #endif /* defined(HAVE_CURSES_FILTER) */
1864
1865 PyDoc_STRVAR(_curses_baudrate__doc__,
1866 "baudrate($module, /)\n"
1867 "--\n"
1868 "\n"
1869 "Return the output speed of the terminal in bits per second.");
1870
1871 #define _CURSES_BAUDRATE_METHODDEF \
1872 {"baudrate", (PyCFunction)_curses_baudrate, METH_NOARGS, _curses_baudrate__doc__},
1873
1874 static PyObject *
1875 _curses_baudrate_impl(PyObject *module);
1876
1877 static PyObject *
1878 _curses_baudrate(PyObject *module, PyObject *Py_UNUSED(ignored))
1879 {
1880 return _curses_baudrate_impl(module);
1881 }
1882
1883 PyDoc_STRVAR(_curses_beep__doc__,
1884 "beep($module, /)\n"
1885 "--\n"
1886 "\n"
1887 "Emit a short attention sound.");
1888
1889 #define _CURSES_BEEP_METHODDEF \
1890 {"beep", (PyCFunction)_curses_beep, METH_NOARGS, _curses_beep__doc__},
1891
1892 static PyObject *
1893 _curses_beep_impl(PyObject *module);
1894
1895 static PyObject *
1896 _curses_beep(PyObject *module, PyObject *Py_UNUSED(ignored))
1897 {
1898 return _curses_beep_impl(module);
1899 }
1900
1901 PyDoc_STRVAR(_curses_can_change_color__doc__,
1902 "can_change_color($module, /)\n"
1903 "--\n"
1904 "\n"
1905 "Return True if the programmer can change the colors displayed by the terminal.");
1906
1907 #define _CURSES_CAN_CHANGE_COLOR_METHODDEF \
1908 {"can_change_color", (PyCFunction)_curses_can_change_color, METH_NOARGS, _curses_can_change_color__doc__},
1909
1910 static PyObject *
1911 _curses_can_change_color_impl(PyObject *module);
1912
1913 static PyObject *
1914 _curses_can_change_color(PyObject *module, PyObject *Py_UNUSED(ignored))
1915 {
1916 return _curses_can_change_color_impl(module);
1917 }
1918
1919 PyDoc_STRVAR(_curses_cbreak__doc__,
1920 "cbreak($module, flag=True, /)\n"
1921 "--\n"
1922 "\n"
1923 "Enter cbreak mode.\n"
1924 "\n"
1925 " flag\n"
1926 " If false, the effect is the same as calling nocbreak().\n"
1927 "\n"
1928 "In cbreak mode (sometimes called \"rare\" mode) normal tty line buffering is\n"
1929 "turned off and characters are available to be read one by one. However,\n"
1930 "unlike raw mode, special characters (interrupt, quit, suspend, and flow\n"
1931 "control) retain their effects on the tty driver and calling program.\n"
1932 "Calling first raw() then cbreak() leaves the terminal in cbreak mode.");
1933
1934 #define _CURSES_CBREAK_METHODDEF \
1935 {"cbreak", _PyCFunction_CAST(_curses_cbreak), METH_FASTCALL, _curses_cbreak__doc__},
1936
1937 static PyObject *
1938 _curses_cbreak_impl(PyObject *module, int flag);
1939
1940 static PyObject *
1941 _curses_cbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
1942 {
1943 PyObject *return_value = NULL;
1944 int flag = 1;
1945
1946 if (!_PyArg_CheckPositional("cbreak", nargs, 0, 1)) {
1947 goto exit;
1948 }
1949 if (nargs < 1) {
1950 goto skip_optional;
1951 }
1952 flag = PyObject_IsTrue(args[0]);
1953 if (flag < 0) {
1954 goto exit;
1955 }
1956 skip_optional:
1957 return_value = _curses_cbreak_impl(module, flag);
1958
1959 exit:
1960 return return_value;
1961 }
1962
1963 PyDoc_STRVAR(_curses_color_content__doc__,
1964 "color_content($module, color_number, /)\n"
1965 "--\n"
1966 "\n"
1967 "Return the red, green, and blue (RGB) components of the specified color.\n"
1968 "\n"
1969 " color_number\n"
1970 " The number of the color (0 - (COLORS-1)).\n"
1971 "\n"
1972 "A 3-tuple is returned, containing the R, G, B values for the given color,\n"
1973 "which will be between 0 (no component) and 1000 (maximum amount of component).");
1974
1975 #define _CURSES_COLOR_CONTENT_METHODDEF \
1976 {"color_content", (PyCFunction)_curses_color_content, METH_O, _curses_color_content__doc__},
1977
1978 static PyObject *
1979 _curses_color_content_impl(PyObject *module, int color_number);
1980
1981 static PyObject *
1982 _curses_color_content(PyObject *module, PyObject *arg)
1983 {
1984 PyObject *return_value = NULL;
1985 int color_number;
1986
1987 if (!color_converter(arg, &color_number)) {
1988 goto exit;
1989 }
1990 return_value = _curses_color_content_impl(module, color_number);
1991
1992 exit:
1993 return return_value;
1994 }
1995
1996 PyDoc_STRVAR(_curses_color_pair__doc__,
1997 "color_pair($module, pair_number, /)\n"
1998 "--\n"
1999 "\n"
2000 "Return the attribute value for displaying text in the specified color.\n"
2001 "\n"
2002 " pair_number\n"
2003 " The number of the color pair.\n"
2004 "\n"
2005 "This attribute value can be combined with A_STANDOUT, A_REVERSE, and the\n"
2006 "other A_* attributes. pair_number() is the counterpart to this function.");
2007
2008 #define _CURSES_COLOR_PAIR_METHODDEF \
2009 {"color_pair", (PyCFunction)_curses_color_pair, METH_O, _curses_color_pair__doc__},
2010
2011 static PyObject *
2012 _curses_color_pair_impl(PyObject *module, int pair_number);
2013
2014 static PyObject *
2015 _curses_color_pair(PyObject *module, PyObject *arg)
2016 {
2017 PyObject *return_value = NULL;
2018 int pair_number;
2019
2020 pair_number = PyLong_AsInt(arg);
2021 if (pair_number == -1 && PyErr_Occurred()) {
2022 goto exit;
2023 }
2024 return_value = _curses_color_pair_impl(module, pair_number);
2025
2026 exit:
2027 return return_value;
2028 }
2029
2030 PyDoc_STRVAR(_curses_curs_set__doc__,
2031 "curs_set($module, visibility, /)\n"
2032 "--\n"
2033 "\n"
2034 "Set the cursor state.\n"
2035 "\n"
2036 " visibility\n"
2037 " 0 for invisible, 1 for normal visible, or 2 for very visible.\n"
2038 "\n"
2039 "If the terminal supports the visibility requested, the previous cursor\n"
2040 "state is returned; otherwise, an exception is raised. On many terminals,\n"
2041 "the \"visible\" mode is an underline cursor and the \"very visible\" mode is\n"
2042 "a block cursor.");
2043
2044 #define _CURSES_CURS_SET_METHODDEF \
2045 {"curs_set", (PyCFunction)_curses_curs_set, METH_O, _curses_curs_set__doc__},
2046
2047 static PyObject *
2048 _curses_curs_set_impl(PyObject *module, int visibility);
2049
2050 static PyObject *
2051 _curses_curs_set(PyObject *module, PyObject *arg)
2052 {
2053 PyObject *return_value = NULL;
2054 int visibility;
2055
2056 visibility = PyLong_AsInt(arg);
2057 if (visibility == -1 && PyErr_Occurred()) {
2058 goto exit;
2059 }
2060 return_value = _curses_curs_set_impl(module, visibility);
2061
2062 exit:
2063 return return_value;
2064 }
2065
2066 PyDoc_STRVAR(_curses_def_prog_mode__doc__,
2067 "def_prog_mode($module, /)\n"
2068 "--\n"
2069 "\n"
2070 "Save the current terminal mode as the \"program\" mode.\n"
2071 "\n"
2072 "The \"program\" mode is the mode when the running program is using curses.\n"
2073 "\n"
2074 "Subsequent calls to reset_prog_mode() will restore this mode.");
2075
2076 #define _CURSES_DEF_PROG_MODE_METHODDEF \
2077 {"def_prog_mode", (PyCFunction)_curses_def_prog_mode, METH_NOARGS, _curses_def_prog_mode__doc__},
2078
2079 static PyObject *
2080 _curses_def_prog_mode_impl(PyObject *module);
2081
2082 static PyObject *
2083 _curses_def_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
2084 {
2085 return _curses_def_prog_mode_impl(module);
2086 }
2087
2088 PyDoc_STRVAR(_curses_def_shell_mode__doc__,
2089 "def_shell_mode($module, /)\n"
2090 "--\n"
2091 "\n"
2092 "Save the current terminal mode as the \"shell\" mode.\n"
2093 "\n"
2094 "The \"shell\" mode is the mode when the running program is not using curses.\n"
2095 "\n"
2096 "Subsequent calls to reset_shell_mode() will restore this mode.");
2097
2098 #define _CURSES_DEF_SHELL_MODE_METHODDEF \
2099 {"def_shell_mode", (PyCFunction)_curses_def_shell_mode, METH_NOARGS, _curses_def_shell_mode__doc__},
2100
2101 static PyObject *
2102 _curses_def_shell_mode_impl(PyObject *module);
2103
2104 static PyObject *
2105 _curses_def_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
2106 {
2107 return _curses_def_shell_mode_impl(module);
2108 }
2109
2110 PyDoc_STRVAR(_curses_delay_output__doc__,
2111 "delay_output($module, ms, /)\n"
2112 "--\n"
2113 "\n"
2114 "Insert a pause in output.\n"
2115 "\n"
2116 " ms\n"
2117 " Duration in milliseconds.");
2118
2119 #define _CURSES_DELAY_OUTPUT_METHODDEF \
2120 {"delay_output", (PyCFunction)_curses_delay_output, METH_O, _curses_delay_output__doc__},
2121
2122 static PyObject *
2123 _curses_delay_output_impl(PyObject *module, int ms);
2124
2125 static PyObject *
2126 _curses_delay_output(PyObject *module, PyObject *arg)
2127 {
2128 PyObject *return_value = NULL;
2129 int ms;
2130
2131 ms = PyLong_AsInt(arg);
2132 if (ms == -1 && PyErr_Occurred()) {
2133 goto exit;
2134 }
2135 return_value = _curses_delay_output_impl(module, ms);
2136
2137 exit:
2138 return return_value;
2139 }
2140
2141 PyDoc_STRVAR(_curses_doupdate__doc__,
2142 "doupdate($module, /)\n"
2143 "--\n"
2144 "\n"
2145 "Update the physical screen to match the virtual screen.");
2146
2147 #define _CURSES_DOUPDATE_METHODDEF \
2148 {"doupdate", (PyCFunction)_curses_doupdate, METH_NOARGS, _curses_doupdate__doc__},
2149
2150 static PyObject *
2151 _curses_doupdate_impl(PyObject *module);
2152
2153 static PyObject *
2154 _curses_doupdate(PyObject *module, PyObject *Py_UNUSED(ignored))
2155 {
2156 return _curses_doupdate_impl(module);
2157 }
2158
2159 PyDoc_STRVAR(_curses_echo__doc__,
2160 "echo($module, flag=True, /)\n"
2161 "--\n"
2162 "\n"
2163 "Enter echo mode.\n"
2164 "\n"
2165 " flag\n"
2166 " If false, the effect is the same as calling noecho().\n"
2167 "\n"
2168 "In echo mode, each character input is echoed to the screen as it is entered.");
2169
2170 #define _CURSES_ECHO_METHODDEF \
2171 {"echo", _PyCFunction_CAST(_curses_echo), METH_FASTCALL, _curses_echo__doc__},
2172
2173 static PyObject *
2174 _curses_echo_impl(PyObject *module, int flag);
2175
2176 static PyObject *
2177 _curses_echo(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2178 {
2179 PyObject *return_value = NULL;
2180 int flag = 1;
2181
2182 if (!_PyArg_CheckPositional("echo", nargs, 0, 1)) {
2183 goto exit;
2184 }
2185 if (nargs < 1) {
2186 goto skip_optional;
2187 }
2188 flag = PyObject_IsTrue(args[0]);
2189 if (flag < 0) {
2190 goto exit;
2191 }
2192 skip_optional:
2193 return_value = _curses_echo_impl(module, flag);
2194
2195 exit:
2196 return return_value;
2197 }
2198
2199 PyDoc_STRVAR(_curses_endwin__doc__,
2200 "endwin($module, /)\n"
2201 "--\n"
2202 "\n"
2203 "De-initialize the library, and return terminal to normal status.");
2204
2205 #define _CURSES_ENDWIN_METHODDEF \
2206 {"endwin", (PyCFunction)_curses_endwin, METH_NOARGS, _curses_endwin__doc__},
2207
2208 static PyObject *
2209 _curses_endwin_impl(PyObject *module);
2210
2211 static PyObject *
2212 _curses_endwin(PyObject *module, PyObject *Py_UNUSED(ignored))
2213 {
2214 return _curses_endwin_impl(module);
2215 }
2216
2217 PyDoc_STRVAR(_curses_erasechar__doc__,
2218 "erasechar($module, /)\n"
2219 "--\n"
2220 "\n"
2221 "Return the user\'s current erase character.");
2222
2223 #define _CURSES_ERASECHAR_METHODDEF \
2224 {"erasechar", (PyCFunction)_curses_erasechar, METH_NOARGS, _curses_erasechar__doc__},
2225
2226 static PyObject *
2227 _curses_erasechar_impl(PyObject *module);
2228
2229 static PyObject *
2230 _curses_erasechar(PyObject *module, PyObject *Py_UNUSED(ignored))
2231 {
2232 return _curses_erasechar_impl(module);
2233 }
2234
2235 PyDoc_STRVAR(_curses_flash__doc__,
2236 "flash($module, /)\n"
2237 "--\n"
2238 "\n"
2239 "Flash the screen.\n"
2240 "\n"
2241 "That is, change it to reverse-video and then change it back in a short interval.");
2242
2243 #define _CURSES_FLASH_METHODDEF \
2244 {"flash", (PyCFunction)_curses_flash, METH_NOARGS, _curses_flash__doc__},
2245
2246 static PyObject *
2247 _curses_flash_impl(PyObject *module);
2248
2249 static PyObject *
2250 _curses_flash(PyObject *module, PyObject *Py_UNUSED(ignored))
2251 {
2252 return _curses_flash_impl(module);
2253 }
2254
2255 PyDoc_STRVAR(_curses_flushinp__doc__,
2256 "flushinp($module, /)\n"
2257 "--\n"
2258 "\n"
2259 "Flush all input buffers.\n"
2260 "\n"
2261 "This throws away any typeahead that has been typed by the user and has not\n"
2262 "yet been processed by the program.");
2263
2264 #define _CURSES_FLUSHINP_METHODDEF \
2265 {"flushinp", (PyCFunction)_curses_flushinp, METH_NOARGS, _curses_flushinp__doc__},
2266
2267 static PyObject *
2268 _curses_flushinp_impl(PyObject *module);
2269
2270 static PyObject *
2271 _curses_flushinp(PyObject *module, PyObject *Py_UNUSED(ignored))
2272 {
2273 return _curses_flushinp_impl(module);
2274 }
2275
2276 #if defined(getsyx)
2277
2278 PyDoc_STRVAR(_curses_getsyx__doc__,
2279 "getsyx($module, /)\n"
2280 "--\n"
2281 "\n"
2282 "Return the current coordinates of the virtual screen cursor.\n"
2283 "\n"
2284 "Return a (y, x) tuple. If leaveok is currently true, return (-1, -1).");
2285
2286 #define _CURSES_GETSYX_METHODDEF \
2287 {"getsyx", (PyCFunction)_curses_getsyx, METH_NOARGS, _curses_getsyx__doc__},
2288
2289 static PyObject *
2290 _curses_getsyx_impl(PyObject *module);
2291
2292 static PyObject *
2293 _curses_getsyx(PyObject *module, PyObject *Py_UNUSED(ignored))
2294 {
2295 return _curses_getsyx_impl(module);
2296 }
2297
2298 #endif /* defined(getsyx) */
2299
2300 #if defined(NCURSES_MOUSE_VERSION)
2301
2302 PyDoc_STRVAR(_curses_getmouse__doc__,
2303 "getmouse($module, /)\n"
2304 "--\n"
2305 "\n"
2306 "Retrieve the queued mouse event.\n"
2307 "\n"
2308 "After getch() returns KEY_MOUSE to signal a mouse event, this function\n"
2309 "returns a 5-tuple (id, x, y, z, bstate).");
2310
2311 #define _CURSES_GETMOUSE_METHODDEF \
2312 {"getmouse", (PyCFunction)_curses_getmouse, METH_NOARGS, _curses_getmouse__doc__},
2313
2314 static PyObject *
2315 _curses_getmouse_impl(PyObject *module);
2316
2317 static PyObject *
2318 _curses_getmouse(PyObject *module, PyObject *Py_UNUSED(ignored))
2319 {
2320 return _curses_getmouse_impl(module);
2321 }
2322
2323 #endif /* defined(NCURSES_MOUSE_VERSION) */
2324
2325 #if defined(NCURSES_MOUSE_VERSION)
2326
2327 PyDoc_STRVAR(_curses_ungetmouse__doc__,
2328 "ungetmouse($module, id, x, y, z, bstate, /)\n"
2329 "--\n"
2330 "\n"
2331 "Push a KEY_MOUSE event onto the input queue.\n"
2332 "\n"
2333 "The following getmouse() will return the given state data.");
2334
2335 #define _CURSES_UNGETMOUSE_METHODDEF \
2336 {"ungetmouse", _PyCFunction_CAST(_curses_ungetmouse), METH_FASTCALL, _curses_ungetmouse__doc__},
2337
2338 static PyObject *
2339 _curses_ungetmouse_impl(PyObject *module, short id, int x, int y, int z,
2340 unsigned long bstate);
2341
2342 static PyObject *
2343 _curses_ungetmouse(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2344 {
2345 PyObject *return_value = NULL;
2346 short id;
2347 int x;
2348 int y;
2349 int z;
2350 unsigned long bstate;
2351
2352 if (!_PyArg_CheckPositional("ungetmouse", nargs, 5, 5)) {
2353 goto exit;
2354 }
2355 {
2356 long ival = PyLong_AsLong(args[0]);
2357 if (ival == -1 && PyErr_Occurred()) {
2358 goto exit;
2359 }
2360 else if (ival < SHRT_MIN) {
2361 PyErr_SetString(PyExc_OverflowError,
2362 "signed short integer is less than minimum");
2363 goto exit;
2364 }
2365 else if (ival > SHRT_MAX) {
2366 PyErr_SetString(PyExc_OverflowError,
2367 "signed short integer is greater than maximum");
2368 goto exit;
2369 }
2370 else {
2371 id = (short) ival;
2372 }
2373 }
2374 x = PyLong_AsInt(args[1]);
2375 if (x == -1 && PyErr_Occurred()) {
2376 goto exit;
2377 }
2378 y = PyLong_AsInt(args[2]);
2379 if (y == -1 && PyErr_Occurred()) {
2380 goto exit;
2381 }
2382 z = PyLong_AsInt(args[3]);
2383 if (z == -1 && PyErr_Occurred()) {
2384 goto exit;
2385 }
2386 if (!PyIndex_Check(args[4])) {
2387 _PyArg_BadArgument("ungetmouse", "argument 5", "int", args[4]);
2388 goto exit;
2389 }
2390 bstate = PyLong_AsUnsignedLongMask(args[4]);
2391 return_value = _curses_ungetmouse_impl(module, id, x, y, z, bstate);
2392
2393 exit:
2394 return return_value;
2395 }
2396
2397 #endif /* defined(NCURSES_MOUSE_VERSION) */
2398
2399 PyDoc_STRVAR(_curses_getwin__doc__,
2400 "getwin($module, file, /)\n"
2401 "--\n"
2402 "\n"
2403 "Read window related data stored in the file by an earlier putwin() call.\n"
2404 "\n"
2405 "The routine then creates and initializes a new window using that data,\n"
2406 "returning the new window object.");
2407
2408 #define _CURSES_GETWIN_METHODDEF \
2409 {"getwin", (PyCFunction)_curses_getwin, METH_O, _curses_getwin__doc__},
2410
2411 PyDoc_STRVAR(_curses_halfdelay__doc__,
2412 "halfdelay($module, tenths, /)\n"
2413 "--\n"
2414 "\n"
2415 "Enter half-delay mode.\n"
2416 "\n"
2417 " tenths\n"
2418 " Maximal blocking delay in tenths of seconds (1 - 255).\n"
2419 "\n"
2420 "Use nocbreak() to leave half-delay mode.");
2421
2422 #define _CURSES_HALFDELAY_METHODDEF \
2423 {"halfdelay", (PyCFunction)_curses_halfdelay, METH_O, _curses_halfdelay__doc__},
2424
2425 static PyObject *
2426 _curses_halfdelay_impl(PyObject *module, unsigned char tenths);
2427
2428 static PyObject *
2429 _curses_halfdelay(PyObject *module, PyObject *arg)
2430 {
2431 PyObject *return_value = NULL;
2432 unsigned char tenths;
2433
2434 {
2435 long ival = PyLong_AsLong(arg);
2436 if (ival == -1 && PyErr_Occurred()) {
2437 goto exit;
2438 }
2439 else if (ival < 0) {
2440 PyErr_SetString(PyExc_OverflowError,
2441 "unsigned byte integer is less than minimum");
2442 goto exit;
2443 }
2444 else if (ival > UCHAR_MAX) {
2445 PyErr_SetString(PyExc_OverflowError,
2446 "unsigned byte integer is greater than maximum");
2447 goto exit;
2448 }
2449 else {
2450 tenths = (unsigned char) ival;
2451 }
2452 }
2453 return_value = _curses_halfdelay_impl(module, tenths);
2454
2455 exit:
2456 return return_value;
2457 }
2458
2459 PyDoc_STRVAR(_curses_has_colors__doc__,
2460 "has_colors($module, /)\n"
2461 "--\n"
2462 "\n"
2463 "Return True if the terminal can display colors; otherwise, return False.");
2464
2465 #define _CURSES_HAS_COLORS_METHODDEF \
2466 {"has_colors", (PyCFunction)_curses_has_colors, METH_NOARGS, _curses_has_colors__doc__},
2467
2468 static PyObject *
2469 _curses_has_colors_impl(PyObject *module);
2470
2471 static PyObject *
2472 _curses_has_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
2473 {
2474 return _curses_has_colors_impl(module);
2475 }
2476
2477 PyDoc_STRVAR(_curses_has_ic__doc__,
2478 "has_ic($module, /)\n"
2479 "--\n"
2480 "\n"
2481 "Return True if the terminal has insert- and delete-character capabilities.");
2482
2483 #define _CURSES_HAS_IC_METHODDEF \
2484 {"has_ic", (PyCFunction)_curses_has_ic, METH_NOARGS, _curses_has_ic__doc__},
2485
2486 static PyObject *
2487 _curses_has_ic_impl(PyObject *module);
2488
2489 static PyObject *
2490 _curses_has_ic(PyObject *module, PyObject *Py_UNUSED(ignored))
2491 {
2492 return _curses_has_ic_impl(module);
2493 }
2494
2495 PyDoc_STRVAR(_curses_has_il__doc__,
2496 "has_il($module, /)\n"
2497 "--\n"
2498 "\n"
2499 "Return True if the terminal has insert- and delete-line capabilities.");
2500
2501 #define _CURSES_HAS_IL_METHODDEF \
2502 {"has_il", (PyCFunction)_curses_has_il, METH_NOARGS, _curses_has_il__doc__},
2503
2504 static PyObject *
2505 _curses_has_il_impl(PyObject *module);
2506
2507 static PyObject *
2508 _curses_has_il(PyObject *module, PyObject *Py_UNUSED(ignored))
2509 {
2510 return _curses_has_il_impl(module);
2511 }
2512
2513 #if defined(HAVE_CURSES_HAS_KEY)
2514
2515 PyDoc_STRVAR(_curses_has_key__doc__,
2516 "has_key($module, key, /)\n"
2517 "--\n"
2518 "\n"
2519 "Return True if the current terminal type recognizes a key with that value.\n"
2520 "\n"
2521 " key\n"
2522 " Key number.");
2523
2524 #define _CURSES_HAS_KEY_METHODDEF \
2525 {"has_key", (PyCFunction)_curses_has_key, METH_O, _curses_has_key__doc__},
2526
2527 static PyObject *
2528 _curses_has_key_impl(PyObject *module, int key);
2529
2530 static PyObject *
2531 _curses_has_key(PyObject *module, PyObject *arg)
2532 {
2533 PyObject *return_value = NULL;
2534 int key;
2535
2536 key = PyLong_AsInt(arg);
2537 if (key == -1 && PyErr_Occurred()) {
2538 goto exit;
2539 }
2540 return_value = _curses_has_key_impl(module, key);
2541
2542 exit:
2543 return return_value;
2544 }
2545
2546 #endif /* defined(HAVE_CURSES_HAS_KEY) */
2547
2548 PyDoc_STRVAR(_curses_init_color__doc__,
2549 "init_color($module, color_number, r, g, b, /)\n"
2550 "--\n"
2551 "\n"
2552 "Change the definition of a color.\n"
2553 "\n"
2554 " color_number\n"
2555 " The number of the color to be changed (0 - (COLORS-1)).\n"
2556 " r\n"
2557 " Red component (0 - 1000).\n"
2558 " g\n"
2559 " Green component (0 - 1000).\n"
2560 " b\n"
2561 " Blue component (0 - 1000).\n"
2562 "\n"
2563 "When init_color() is used, all occurrences of that color on the screen\n"
2564 "immediately change to the new definition. This function is a no-op on\n"
2565 "most terminals; it is active only if can_change_color() returns true.");
2566
2567 #define _CURSES_INIT_COLOR_METHODDEF \
2568 {"init_color", _PyCFunction_CAST(_curses_init_color), METH_FASTCALL, _curses_init_color__doc__},
2569
2570 static PyObject *
2571 _curses_init_color_impl(PyObject *module, int color_number, short r, short g,
2572 short b);
2573
2574 static PyObject *
2575 _curses_init_color(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2576 {
2577 PyObject *return_value = NULL;
2578 int color_number;
2579 short r;
2580 short g;
2581 short b;
2582
2583 if (!_PyArg_CheckPositional("init_color", nargs, 4, 4)) {
2584 goto exit;
2585 }
2586 if (!color_converter(args[0], &color_number)) {
2587 goto exit;
2588 }
2589 if (!component_converter(args[1], &r)) {
2590 goto exit;
2591 }
2592 if (!component_converter(args[2], &g)) {
2593 goto exit;
2594 }
2595 if (!component_converter(args[3], &b)) {
2596 goto exit;
2597 }
2598 return_value = _curses_init_color_impl(module, color_number, r, g, b);
2599
2600 exit:
2601 return return_value;
2602 }
2603
2604 PyDoc_STRVAR(_curses_init_pair__doc__,
2605 "init_pair($module, pair_number, fg, bg, /)\n"
2606 "--\n"
2607 "\n"
2608 "Change the definition of a color-pair.\n"
2609 "\n"
2610 " pair_number\n"
2611 " The number of the color-pair to be changed (1 - (COLOR_PAIRS-1)).\n"
2612 " fg\n"
2613 " Foreground color number (-1 - (COLORS-1)).\n"
2614 " bg\n"
2615 " Background color number (-1 - (COLORS-1)).\n"
2616 "\n"
2617 "If the color-pair was previously initialized, the screen is refreshed and\n"
2618 "all occurrences of that color-pair are changed to the new definition.");
2619
2620 #define _CURSES_INIT_PAIR_METHODDEF \
2621 {"init_pair", _PyCFunction_CAST(_curses_init_pair), METH_FASTCALL, _curses_init_pair__doc__},
2622
2623 static PyObject *
2624 _curses_init_pair_impl(PyObject *module, int pair_number, int fg, int bg);
2625
2626 static PyObject *
2627 _curses_init_pair(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2628 {
2629 PyObject *return_value = NULL;
2630 int pair_number;
2631 int fg;
2632 int bg;
2633
2634 if (!_PyArg_CheckPositional("init_pair", nargs, 3, 3)) {
2635 goto exit;
2636 }
2637 if (!pair_converter(args[0], &pair_number)) {
2638 goto exit;
2639 }
2640 if (!color_allow_default_converter(args[1], &fg)) {
2641 goto exit;
2642 }
2643 if (!color_allow_default_converter(args[2], &bg)) {
2644 goto exit;
2645 }
2646 return_value = _curses_init_pair_impl(module, pair_number, fg, bg);
2647
2648 exit:
2649 return return_value;
2650 }
2651
2652 PyDoc_STRVAR(_curses_initscr__doc__,
2653 "initscr($module, /)\n"
2654 "--\n"
2655 "\n"
2656 "Initialize the library.\n"
2657 "\n"
2658 "Return a WindowObject which represents the whole screen.");
2659
2660 #define _CURSES_INITSCR_METHODDEF \
2661 {"initscr", (PyCFunction)_curses_initscr, METH_NOARGS, _curses_initscr__doc__},
2662
2663 static PyObject *
2664 _curses_initscr_impl(PyObject *module);
2665
2666 static PyObject *
2667 _curses_initscr(PyObject *module, PyObject *Py_UNUSED(ignored))
2668 {
2669 return _curses_initscr_impl(module);
2670 }
2671
2672 PyDoc_STRVAR(_curses_setupterm__doc__,
2673 "setupterm($module, /, term=None, fd=-1)\n"
2674 "--\n"
2675 "\n"
2676 "Initialize the terminal.\n"
2677 "\n"
2678 " term\n"
2679 " Terminal name.\n"
2680 " If omitted, the value of the TERM environment variable will be used.\n"
2681 " fd\n"
2682 " File descriptor to which any initialization sequences will be sent.\n"
2683 " If not supplied, the file descriptor for sys.stdout will be used.");
2684
2685 #define _CURSES_SETUPTERM_METHODDEF \
2686 {"setupterm", _PyCFunction_CAST(_curses_setupterm), METH_FASTCALL|METH_KEYWORDS, _curses_setupterm__doc__},
2687
2688 static PyObject *
2689 _curses_setupterm_impl(PyObject *module, const char *term, int fd);
2690
2691 static PyObject *
2692 _curses_setupterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
2693 {
2694 PyObject *return_value = NULL;
2695 #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
2696
2697 #define NUM_KEYWORDS 2
2698 static struct {
2699 PyGC_Head _this_is_not_used;
2700 PyObject_VAR_HEAD
2701 Py_hash_t ob_hash;
2702 PyObject *ob_item[NUM_KEYWORDS];
2703 } _kwtuple = {
2704 .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
2705 .ob_hash = -1,
2706 .ob_item = { &_Py_ID(term), &_Py_ID(fd), },
2707 };
2708 #undef NUM_KEYWORDS
2709 #define KWTUPLE (&_kwtuple.ob_base.ob_base)
2710
2711 #else // !Py_BUILD_CORE
2712 # define KWTUPLE NULL
2713 #endif // !Py_BUILD_CORE
2714
2715 static const char * const _keywords[] = {"term", "fd", NULL};
2716 static _PyArg_Parser _parser = {
2717 .keywords = _keywords,
2718 .fname = "setupterm",
2719 .kwtuple = KWTUPLE,
2720 };
2721 #undef KWTUPLE
2722 PyObject *argsbuf[2];
2723 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
2724 const char *term = NULL;
2725 int fd = -1;
2726
2727 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
2728 /*minpos*/ 0, /*maxpos*/ 2, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
2729 if (!args) {
2730 goto exit;
2731 }
2732 if (!noptargs) {
2733 goto skip_optional_pos;
2734 }
2735 if (args[0]) {
2736 if (args[0] == Py_None) {
2737 term = NULL;
2738 }
2739 else if (PyUnicode_Check(args[0])) {
2740 Py_ssize_t term_length;
2741 term = PyUnicode_AsUTF8AndSize(args[0], &term_length);
2742 if (term == NULL) {
2743 goto exit;
2744 }
2745 if (strlen(term) != (size_t)term_length) {
2746 PyErr_SetString(PyExc_ValueError, "embedded null character");
2747 goto exit;
2748 }
2749 }
2750 else {
2751 _PyArg_BadArgument("setupterm", "argument 'term'", "str or None", args[0]);
2752 goto exit;
2753 }
2754 if (!--noptargs) {
2755 goto skip_optional_pos;
2756 }
2757 }
2758 fd = PyLong_AsInt(args[1]);
2759 if (fd == -1 && PyErr_Occurred()) {
2760 goto exit;
2761 }
2762 skip_optional_pos:
2763 return_value = _curses_setupterm_impl(module, term, fd);
2764
2765 exit:
2766 return return_value;
2767 }
2768
2769 #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2770
2771 PyDoc_STRVAR(_curses_get_escdelay__doc__,
2772 "get_escdelay($module, /)\n"
2773 "--\n"
2774 "\n"
2775 "Gets the curses ESCDELAY setting.\n"
2776 "\n"
2777 "Gets the number of milliseconds to wait after reading an escape character,\n"
2778 "to distinguish between an individual escape character entered on the\n"
2779 "keyboard from escape sequences sent by cursor and function keys.");
2780
2781 #define _CURSES_GET_ESCDELAY_METHODDEF \
2782 {"get_escdelay", (PyCFunction)_curses_get_escdelay, METH_NOARGS, _curses_get_escdelay__doc__},
2783
2784 static PyObject *
2785 _curses_get_escdelay_impl(PyObject *module);
2786
2787 static PyObject *
2788 _curses_get_escdelay(PyObject *module, PyObject *Py_UNUSED(ignored))
2789 {
2790 return _curses_get_escdelay_impl(module);
2791 }
2792
2793 #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2794
2795 #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2796
2797 PyDoc_STRVAR(_curses_set_escdelay__doc__,
2798 "set_escdelay($module, ms, /)\n"
2799 "--\n"
2800 "\n"
2801 "Sets the curses ESCDELAY setting.\n"
2802 "\n"
2803 " ms\n"
2804 " length of the delay in milliseconds.\n"
2805 "\n"
2806 "Sets the number of milliseconds to wait after reading an escape character,\n"
2807 "to distinguish between an individual escape character entered on the\n"
2808 "keyboard from escape sequences sent by cursor and function keys.");
2809
2810 #define _CURSES_SET_ESCDELAY_METHODDEF \
2811 {"set_escdelay", (PyCFunction)_curses_set_escdelay, METH_O, _curses_set_escdelay__doc__},
2812
2813 static PyObject *
2814 _curses_set_escdelay_impl(PyObject *module, int ms);
2815
2816 static PyObject *
2817 _curses_set_escdelay(PyObject *module, PyObject *arg)
2818 {
2819 PyObject *return_value = NULL;
2820 int ms;
2821
2822 ms = PyLong_AsInt(arg);
2823 if (ms == -1 && PyErr_Occurred()) {
2824 goto exit;
2825 }
2826 return_value = _curses_set_escdelay_impl(module, ms);
2827
2828 exit:
2829 return return_value;
2830 }
2831
2832 #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2833
2834 #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2835
2836 PyDoc_STRVAR(_curses_get_tabsize__doc__,
2837 "get_tabsize($module, /)\n"
2838 "--\n"
2839 "\n"
2840 "Gets the curses TABSIZE setting.\n"
2841 "\n"
2842 "Gets the number of columns used by the curses library when converting a tab\n"
2843 "character to spaces as it adds the tab to a window.");
2844
2845 #define _CURSES_GET_TABSIZE_METHODDEF \
2846 {"get_tabsize", (PyCFunction)_curses_get_tabsize, METH_NOARGS, _curses_get_tabsize__doc__},
2847
2848 static PyObject *
2849 _curses_get_tabsize_impl(PyObject *module);
2850
2851 static PyObject *
2852 _curses_get_tabsize(PyObject *module, PyObject *Py_UNUSED(ignored))
2853 {
2854 return _curses_get_tabsize_impl(module);
2855 }
2856
2857 #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2858
2859 #if (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102)
2860
2861 PyDoc_STRVAR(_curses_set_tabsize__doc__,
2862 "set_tabsize($module, size, /)\n"
2863 "--\n"
2864 "\n"
2865 "Sets the curses TABSIZE setting.\n"
2866 "\n"
2867 " size\n"
2868 " rendered cell width of a tab character.\n"
2869 "\n"
2870 "Sets the number of columns used by the curses library when converting a tab\n"
2871 "character to spaces as it adds the tab to a window.");
2872
2873 #define _CURSES_SET_TABSIZE_METHODDEF \
2874 {"set_tabsize", (PyCFunction)_curses_set_tabsize, METH_O, _curses_set_tabsize__doc__},
2875
2876 static PyObject *
2877 _curses_set_tabsize_impl(PyObject *module, int size);
2878
2879 static PyObject *
2880 _curses_set_tabsize(PyObject *module, PyObject *arg)
2881 {
2882 PyObject *return_value = NULL;
2883 int size;
2884
2885 size = PyLong_AsInt(arg);
2886 if (size == -1 && PyErr_Occurred()) {
2887 goto exit;
2888 }
2889 return_value = _curses_set_tabsize_impl(module, size);
2890
2891 exit:
2892 return return_value;
2893 }
2894
2895 #endif /* (defined(NCURSES_EXT_FUNCS) && NCURSES_EXT_FUNCS >= 20081102) */
2896
2897 PyDoc_STRVAR(_curses_intrflush__doc__,
2898 "intrflush($module, flag, /)\n"
2899 "--\n"
2900 "\n");
2901
2902 #define _CURSES_INTRFLUSH_METHODDEF \
2903 {"intrflush", (PyCFunction)_curses_intrflush, METH_O, _curses_intrflush__doc__},
2904
2905 static PyObject *
2906 _curses_intrflush_impl(PyObject *module, int flag);
2907
2908 static PyObject *
2909 _curses_intrflush(PyObject *module, PyObject *arg)
2910 {
2911 PyObject *return_value = NULL;
2912 int flag;
2913
2914 flag = PyObject_IsTrue(arg);
2915 if (flag < 0) {
2916 goto exit;
2917 }
2918 return_value = _curses_intrflush_impl(module, flag);
2919
2920 exit:
2921 return return_value;
2922 }
2923
2924 PyDoc_STRVAR(_curses_isendwin__doc__,
2925 "isendwin($module, /)\n"
2926 "--\n"
2927 "\n"
2928 "Return True if endwin() has been called.");
2929
2930 #define _CURSES_ISENDWIN_METHODDEF \
2931 {"isendwin", (PyCFunction)_curses_isendwin, METH_NOARGS, _curses_isendwin__doc__},
2932
2933 static PyObject *
2934 _curses_isendwin_impl(PyObject *module);
2935
2936 static PyObject *
2937 _curses_isendwin(PyObject *module, PyObject *Py_UNUSED(ignored))
2938 {
2939 return _curses_isendwin_impl(module);
2940 }
2941
2942 #if defined(HAVE_CURSES_IS_TERM_RESIZED)
2943
2944 PyDoc_STRVAR(_curses_is_term_resized__doc__,
2945 "is_term_resized($module, nlines, ncols, /)\n"
2946 "--\n"
2947 "\n"
2948 "Return True if resize_term() would modify the window structure, False otherwise.\n"
2949 "\n"
2950 " nlines\n"
2951 " Height.\n"
2952 " ncols\n"
2953 " Width.");
2954
2955 #define _CURSES_IS_TERM_RESIZED_METHODDEF \
2956 {"is_term_resized", _PyCFunction_CAST(_curses_is_term_resized), METH_FASTCALL, _curses_is_term_resized__doc__},
2957
2958 static PyObject *
2959 _curses_is_term_resized_impl(PyObject *module, int nlines, int ncols);
2960
2961 static PyObject *
2962 _curses_is_term_resized(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
2963 {
2964 PyObject *return_value = NULL;
2965 int nlines;
2966 int ncols;
2967
2968 if (!_PyArg_CheckPositional("is_term_resized", nargs, 2, 2)) {
2969 goto exit;
2970 }
2971 nlines = PyLong_AsInt(args[0]);
2972 if (nlines == -1 && PyErr_Occurred()) {
2973 goto exit;
2974 }
2975 ncols = PyLong_AsInt(args[1]);
2976 if (ncols == -1 && PyErr_Occurred()) {
2977 goto exit;
2978 }
2979 return_value = _curses_is_term_resized_impl(module, nlines, ncols);
2980
2981 exit:
2982 return return_value;
2983 }
2984
2985 #endif /* defined(HAVE_CURSES_IS_TERM_RESIZED) */
2986
2987 PyDoc_STRVAR(_curses_keyname__doc__,
2988 "keyname($module, key, /)\n"
2989 "--\n"
2990 "\n"
2991 "Return the name of specified key.\n"
2992 "\n"
2993 " key\n"
2994 " Key number.");
2995
2996 #define _CURSES_KEYNAME_METHODDEF \
2997 {"keyname", (PyCFunction)_curses_keyname, METH_O, _curses_keyname__doc__},
2998
2999 static PyObject *
3000 _curses_keyname_impl(PyObject *module, int key);
3001
3002 static PyObject *
3003 _curses_keyname(PyObject *module, PyObject *arg)
3004 {
3005 PyObject *return_value = NULL;
3006 int key;
3007
3008 key = PyLong_AsInt(arg);
3009 if (key == -1 && PyErr_Occurred()) {
3010 goto exit;
3011 }
3012 return_value = _curses_keyname_impl(module, key);
3013
3014 exit:
3015 return return_value;
3016 }
3017
3018 PyDoc_STRVAR(_curses_killchar__doc__,
3019 "killchar($module, /)\n"
3020 "--\n"
3021 "\n"
3022 "Return the user\'s current line kill character.");
3023
3024 #define _CURSES_KILLCHAR_METHODDEF \
3025 {"killchar", (PyCFunction)_curses_killchar, METH_NOARGS, _curses_killchar__doc__},
3026
3027 static PyObject *
3028 _curses_killchar_impl(PyObject *module);
3029
3030 static PyObject *
3031 _curses_killchar(PyObject *module, PyObject *Py_UNUSED(ignored))
3032 {
3033 return _curses_killchar_impl(module);
3034 }
3035
3036 PyDoc_STRVAR(_curses_longname__doc__,
3037 "longname($module, /)\n"
3038 "--\n"
3039 "\n"
3040 "Return the terminfo long name field describing the current terminal.\n"
3041 "\n"
3042 "The maximum length of a verbose description is 128 characters. It is defined\n"
3043 "only after the call to initscr().");
3044
3045 #define _CURSES_LONGNAME_METHODDEF \
3046 {"longname", (PyCFunction)_curses_longname, METH_NOARGS, _curses_longname__doc__},
3047
3048 static PyObject *
3049 _curses_longname_impl(PyObject *module);
3050
3051 static PyObject *
3052 _curses_longname(PyObject *module, PyObject *Py_UNUSED(ignored))
3053 {
3054 return _curses_longname_impl(module);
3055 }
3056
3057 PyDoc_STRVAR(_curses_meta__doc__,
3058 "meta($module, yes, /)\n"
3059 "--\n"
3060 "\n"
3061 "Enable/disable meta keys.\n"
3062 "\n"
3063 "If yes is True, allow 8-bit characters to be input. If yes is False,\n"
3064 "allow only 7-bit characters.");
3065
3066 #define _CURSES_META_METHODDEF \
3067 {"meta", (PyCFunction)_curses_meta, METH_O, _curses_meta__doc__},
3068
3069 static PyObject *
3070 _curses_meta_impl(PyObject *module, int yes);
3071
3072 static PyObject *
3073 _curses_meta(PyObject *module, PyObject *arg)
3074 {
3075 PyObject *return_value = NULL;
3076 int yes;
3077
3078 yes = PyObject_IsTrue(arg);
3079 if (yes < 0) {
3080 goto exit;
3081 }
3082 return_value = _curses_meta_impl(module, yes);
3083
3084 exit:
3085 return return_value;
3086 }
3087
3088 #if defined(NCURSES_MOUSE_VERSION)
3089
3090 PyDoc_STRVAR(_curses_mouseinterval__doc__,
3091 "mouseinterval($module, interval, /)\n"
3092 "--\n"
3093 "\n"
3094 "Set and retrieve the maximum time between press and release in a click.\n"
3095 "\n"
3096 " interval\n"
3097 " Time in milliseconds.\n"
3098 "\n"
3099 "Set the maximum time that can elapse between press and release events in\n"
3100 "order for them to be recognized as a click, and return the previous interval\n"
3101 "value.");
3102
3103 #define _CURSES_MOUSEINTERVAL_METHODDEF \
3104 {"mouseinterval", (PyCFunction)_curses_mouseinterval, METH_O, _curses_mouseinterval__doc__},
3105
3106 static PyObject *
3107 _curses_mouseinterval_impl(PyObject *module, int interval);
3108
3109 static PyObject *
3110 _curses_mouseinterval(PyObject *module, PyObject *arg)
3111 {
3112 PyObject *return_value = NULL;
3113 int interval;
3114
3115 interval = PyLong_AsInt(arg);
3116 if (interval == -1 && PyErr_Occurred()) {
3117 goto exit;
3118 }
3119 return_value = _curses_mouseinterval_impl(module, interval);
3120
3121 exit:
3122 return return_value;
3123 }
3124
3125 #endif /* defined(NCURSES_MOUSE_VERSION) */
3126
3127 #if defined(NCURSES_MOUSE_VERSION)
3128
3129 PyDoc_STRVAR(_curses_mousemask__doc__,
3130 "mousemask($module, newmask, /)\n"
3131 "--\n"
3132 "\n"
3133 "Set the mouse events to be reported, and return a tuple (availmask, oldmask).\n"
3134 "\n"
3135 "Return a tuple (availmask, oldmask). availmask indicates which of the\n"
3136 "specified mouse events can be reported; on complete failure it returns 0.\n"
3137 "oldmask is the previous value of the given window\'s mouse event mask.\n"
3138 "If this function is never called, no mouse events are ever reported.");
3139
3140 #define _CURSES_MOUSEMASK_METHODDEF \
3141 {"mousemask", (PyCFunction)_curses_mousemask, METH_O, _curses_mousemask__doc__},
3142
3143 static PyObject *
3144 _curses_mousemask_impl(PyObject *module, unsigned long newmask);
3145
3146 static PyObject *
3147 _curses_mousemask(PyObject *module, PyObject *arg)
3148 {
3149 PyObject *return_value = NULL;
3150 unsigned long newmask;
3151
3152 if (!PyIndex_Check(arg)) {
3153 _PyArg_BadArgument("mousemask", "argument", "int", arg);
3154 goto exit;
3155 }
3156 newmask = PyLong_AsUnsignedLongMask(arg);
3157 return_value = _curses_mousemask_impl(module, newmask);
3158
3159 exit:
3160 return return_value;
3161 }
3162
3163 #endif /* defined(NCURSES_MOUSE_VERSION) */
3164
3165 PyDoc_STRVAR(_curses_napms__doc__,
3166 "napms($module, ms, /)\n"
3167 "--\n"
3168 "\n"
3169 "Sleep for specified time.\n"
3170 "\n"
3171 " ms\n"
3172 " Duration in milliseconds.");
3173
3174 #define _CURSES_NAPMS_METHODDEF \
3175 {"napms", (PyCFunction)_curses_napms, METH_O, _curses_napms__doc__},
3176
3177 static int
3178 _curses_napms_impl(PyObject *module, int ms);
3179
3180 static PyObject *
3181 _curses_napms(PyObject *module, PyObject *arg)
3182 {
3183 PyObject *return_value = NULL;
3184 int ms;
3185 int _return_value;
3186
3187 ms = PyLong_AsInt(arg);
3188 if (ms == -1 && PyErr_Occurred()) {
3189 goto exit;
3190 }
3191 _return_value = _curses_napms_impl(module, ms);
3192 if ((_return_value == -1) && PyErr_Occurred()) {
3193 goto exit;
3194 }
3195 return_value = PyLong_FromLong((long)_return_value);
3196
3197 exit:
3198 return return_value;
3199 }
3200
3201 PyDoc_STRVAR(_curses_newpad__doc__,
3202 "newpad($module, nlines, ncols, /)\n"
3203 "--\n"
3204 "\n"
3205 "Create and return a pointer to a new pad data structure.\n"
3206 "\n"
3207 " nlines\n"
3208 " Height.\n"
3209 " ncols\n"
3210 " Width.");
3211
3212 #define _CURSES_NEWPAD_METHODDEF \
3213 {"newpad", _PyCFunction_CAST(_curses_newpad), METH_FASTCALL, _curses_newpad__doc__},
3214
3215 static PyObject *
3216 _curses_newpad_impl(PyObject *module, int nlines, int ncols);
3217
3218 static PyObject *
3219 _curses_newpad(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3220 {
3221 PyObject *return_value = NULL;
3222 int nlines;
3223 int ncols;
3224
3225 if (!_PyArg_CheckPositional("newpad", nargs, 2, 2)) {
3226 goto exit;
3227 }
3228 nlines = PyLong_AsInt(args[0]);
3229 if (nlines == -1 && PyErr_Occurred()) {
3230 goto exit;
3231 }
3232 ncols = PyLong_AsInt(args[1]);
3233 if (ncols == -1 && PyErr_Occurred()) {
3234 goto exit;
3235 }
3236 return_value = _curses_newpad_impl(module, nlines, ncols);
3237
3238 exit:
3239 return return_value;
3240 }
3241
3242 PyDoc_STRVAR(_curses_newwin__doc__,
3243 "newwin(nlines, ncols, [begin_y=0, begin_x=0])\n"
3244 "Return a new window.\n"
3245 "\n"
3246 " nlines\n"
3247 " Height.\n"
3248 " ncols\n"
3249 " Width.\n"
3250 " begin_y\n"
3251 " Top side y-coordinate.\n"
3252 " begin_x\n"
3253 " Left side x-coordinate.\n"
3254 "\n"
3255 "By default, the window will extend from the specified position to the lower\n"
3256 "right corner of the screen.");
3257
3258 #define _CURSES_NEWWIN_METHODDEF \
3259 {"newwin", (PyCFunction)_curses_newwin, METH_VARARGS, _curses_newwin__doc__},
3260
3261 static PyObject *
3262 _curses_newwin_impl(PyObject *module, int nlines, int ncols,
3263 int group_right_1, int begin_y, int begin_x);
3264
3265 static PyObject *
3266 _curses_newwin(PyObject *module, PyObject *args)
3267 {
3268 PyObject *return_value = NULL;
3269 int nlines;
3270 int ncols;
3271 int group_right_1 = 0;
3272 int begin_y = 0;
3273 int begin_x = 0;
3274
3275 switch (PyTuple_GET_SIZE(args)) {
3276 case 2:
3277 if (!PyArg_ParseTuple(args, "ii:newwin", &nlines, &ncols)) {
3278 goto exit;
3279 }
3280 break;
3281 case 4:
3282 if (!PyArg_ParseTuple(args, "iiii:newwin", &nlines, &ncols, &begin_y, &begin_x)) {
3283 goto exit;
3284 }
3285 group_right_1 = 1;
3286 break;
3287 default:
3288 PyErr_SetString(PyExc_TypeError, "_curses.newwin requires 2 to 4 arguments");
3289 goto exit;
3290 }
3291 return_value = _curses_newwin_impl(module, nlines, ncols, group_right_1, begin_y, begin_x);
3292
3293 exit:
3294 return return_value;
3295 }
3296
3297 PyDoc_STRVAR(_curses_nl__doc__,
3298 "nl($module, flag=True, /)\n"
3299 "--\n"
3300 "\n"
3301 "Enter newline mode.\n"
3302 "\n"
3303 " flag\n"
3304 " If false, the effect is the same as calling nonl().\n"
3305 "\n"
3306 "This mode translates the return key into newline on input, and translates\n"
3307 "newline into return and line-feed on output. Newline mode is initially on.");
3308
3309 #define _CURSES_NL_METHODDEF \
3310 {"nl", _PyCFunction_CAST(_curses_nl), METH_FASTCALL, _curses_nl__doc__},
3311
3312 static PyObject *
3313 _curses_nl_impl(PyObject *module, int flag);
3314
3315 static PyObject *
3316 _curses_nl(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3317 {
3318 PyObject *return_value = NULL;
3319 int flag = 1;
3320
3321 if (!_PyArg_CheckPositional("nl", nargs, 0, 1)) {
3322 goto exit;
3323 }
3324 if (nargs < 1) {
3325 goto skip_optional;
3326 }
3327 flag = PyObject_IsTrue(args[0]);
3328 if (flag < 0) {
3329 goto exit;
3330 }
3331 skip_optional:
3332 return_value = _curses_nl_impl(module, flag);
3333
3334 exit:
3335 return return_value;
3336 }
3337
3338 PyDoc_STRVAR(_curses_nocbreak__doc__,
3339 "nocbreak($module, /)\n"
3340 "--\n"
3341 "\n"
3342 "Leave cbreak mode.\n"
3343 "\n"
3344 "Return to normal \"cooked\" mode with line buffering.");
3345
3346 #define _CURSES_NOCBREAK_METHODDEF \
3347 {"nocbreak", (PyCFunction)_curses_nocbreak, METH_NOARGS, _curses_nocbreak__doc__},
3348
3349 static PyObject *
3350 _curses_nocbreak_impl(PyObject *module);
3351
3352 static PyObject *
3353 _curses_nocbreak(PyObject *module, PyObject *Py_UNUSED(ignored))
3354 {
3355 return _curses_nocbreak_impl(module);
3356 }
3357
3358 PyDoc_STRVAR(_curses_noecho__doc__,
3359 "noecho($module, /)\n"
3360 "--\n"
3361 "\n"
3362 "Leave echo mode.\n"
3363 "\n"
3364 "Echoing of input characters is turned off.");
3365
3366 #define _CURSES_NOECHO_METHODDEF \
3367 {"noecho", (PyCFunction)_curses_noecho, METH_NOARGS, _curses_noecho__doc__},
3368
3369 static PyObject *
3370 _curses_noecho_impl(PyObject *module);
3371
3372 static PyObject *
3373 _curses_noecho(PyObject *module, PyObject *Py_UNUSED(ignored))
3374 {
3375 return _curses_noecho_impl(module);
3376 }
3377
3378 PyDoc_STRVAR(_curses_nonl__doc__,
3379 "nonl($module, /)\n"
3380 "--\n"
3381 "\n"
3382 "Leave newline mode.\n"
3383 "\n"
3384 "Disable translation of return into newline on input, and disable low-level\n"
3385 "translation of newline into newline/return on output.");
3386
3387 #define _CURSES_NONL_METHODDEF \
3388 {"nonl", (PyCFunction)_curses_nonl, METH_NOARGS, _curses_nonl__doc__},
3389
3390 static PyObject *
3391 _curses_nonl_impl(PyObject *module);
3392
3393 static PyObject *
3394 _curses_nonl(PyObject *module, PyObject *Py_UNUSED(ignored))
3395 {
3396 return _curses_nonl_impl(module);
3397 }
3398
3399 PyDoc_STRVAR(_curses_noqiflush__doc__,
3400 "noqiflush($module, /)\n"
3401 "--\n"
3402 "\n"
3403 "Disable queue flushing.\n"
3404 "\n"
3405 "When queue flushing is disabled, normal flush of input and output queues\n"
3406 "associated with the INTR, QUIT and SUSP characters will not be done.");
3407
3408 #define _CURSES_NOQIFLUSH_METHODDEF \
3409 {"noqiflush", (PyCFunction)_curses_noqiflush, METH_NOARGS, _curses_noqiflush__doc__},
3410
3411 static PyObject *
3412 _curses_noqiflush_impl(PyObject *module);
3413
3414 static PyObject *
3415 _curses_noqiflush(PyObject *module, PyObject *Py_UNUSED(ignored))
3416 {
3417 return _curses_noqiflush_impl(module);
3418 }
3419
3420 PyDoc_STRVAR(_curses_noraw__doc__,
3421 "noraw($module, /)\n"
3422 "--\n"
3423 "\n"
3424 "Leave raw mode.\n"
3425 "\n"
3426 "Return to normal \"cooked\" mode with line buffering.");
3427
3428 #define _CURSES_NORAW_METHODDEF \
3429 {"noraw", (PyCFunction)_curses_noraw, METH_NOARGS, _curses_noraw__doc__},
3430
3431 static PyObject *
3432 _curses_noraw_impl(PyObject *module);
3433
3434 static PyObject *
3435 _curses_noraw(PyObject *module, PyObject *Py_UNUSED(ignored))
3436 {
3437 return _curses_noraw_impl(module);
3438 }
3439
3440 PyDoc_STRVAR(_curses_pair_content__doc__,
3441 "pair_content($module, pair_number, /)\n"
3442 "--\n"
3443 "\n"
3444 "Return a tuple (fg, bg) containing the colors for the requested color pair.\n"
3445 "\n"
3446 " pair_number\n"
3447 " The number of the color pair (0 - (COLOR_PAIRS-1)).");
3448
3449 #define _CURSES_PAIR_CONTENT_METHODDEF \
3450 {"pair_content", (PyCFunction)_curses_pair_content, METH_O, _curses_pair_content__doc__},
3451
3452 static PyObject *
3453 _curses_pair_content_impl(PyObject *module, int pair_number);
3454
3455 static PyObject *
3456 _curses_pair_content(PyObject *module, PyObject *arg)
3457 {
3458 PyObject *return_value = NULL;
3459 int pair_number;
3460
3461 if (!pair_converter(arg, &pair_number)) {
3462 goto exit;
3463 }
3464 return_value = _curses_pair_content_impl(module, pair_number);
3465
3466 exit:
3467 return return_value;
3468 }
3469
3470 PyDoc_STRVAR(_curses_pair_number__doc__,
3471 "pair_number($module, attr, /)\n"
3472 "--\n"
3473 "\n"
3474 "Return the number of the color-pair set by the specified attribute value.\n"
3475 "\n"
3476 "color_pair() is the counterpart to this function.");
3477
3478 #define _CURSES_PAIR_NUMBER_METHODDEF \
3479 {"pair_number", (PyCFunction)_curses_pair_number, METH_O, _curses_pair_number__doc__},
3480
3481 static PyObject *
3482 _curses_pair_number_impl(PyObject *module, int attr);
3483
3484 static PyObject *
3485 _curses_pair_number(PyObject *module, PyObject *arg)
3486 {
3487 PyObject *return_value = NULL;
3488 int attr;
3489
3490 attr = PyLong_AsInt(arg);
3491 if (attr == -1 && PyErr_Occurred()) {
3492 goto exit;
3493 }
3494 return_value = _curses_pair_number_impl(module, attr);
3495
3496 exit:
3497 return return_value;
3498 }
3499
3500 PyDoc_STRVAR(_curses_putp__doc__,
3501 "putp($module, string, /)\n"
3502 "--\n"
3503 "\n"
3504 "Emit the value of a specified terminfo capability for the current terminal.\n"
3505 "\n"
3506 "Note that the output of putp() always goes to standard output.");
3507
3508 #define _CURSES_PUTP_METHODDEF \
3509 {"putp", (PyCFunction)_curses_putp, METH_O, _curses_putp__doc__},
3510
3511 static PyObject *
3512 _curses_putp_impl(PyObject *module, const char *string);
3513
3514 static PyObject *
3515 _curses_putp(PyObject *module, PyObject *arg)
3516 {
3517 PyObject *return_value = NULL;
3518 const char *string;
3519
3520 if (!PyArg_Parse(arg, "y:putp", &string)) {
3521 goto exit;
3522 }
3523 return_value = _curses_putp_impl(module, string);
3524
3525 exit:
3526 return return_value;
3527 }
3528
3529 PyDoc_STRVAR(_curses_qiflush__doc__,
3530 "qiflush($module, flag=True, /)\n"
3531 "--\n"
3532 "\n"
3533 "Enable queue flushing.\n"
3534 "\n"
3535 " flag\n"
3536 " If false, the effect is the same as calling noqiflush().\n"
3537 "\n"
3538 "If queue flushing is enabled, all output in the display driver queue\n"
3539 "will be flushed when the INTR, QUIT and SUSP characters are read.");
3540
3541 #define _CURSES_QIFLUSH_METHODDEF \
3542 {"qiflush", _PyCFunction_CAST(_curses_qiflush), METH_FASTCALL, _curses_qiflush__doc__},
3543
3544 static PyObject *
3545 _curses_qiflush_impl(PyObject *module, int flag);
3546
3547 static PyObject *
3548 _curses_qiflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3549 {
3550 PyObject *return_value = NULL;
3551 int flag = 1;
3552
3553 if (!_PyArg_CheckPositional("qiflush", nargs, 0, 1)) {
3554 goto exit;
3555 }
3556 if (nargs < 1) {
3557 goto skip_optional;
3558 }
3559 flag = PyObject_IsTrue(args[0]);
3560 if (flag < 0) {
3561 goto exit;
3562 }
3563 skip_optional:
3564 return_value = _curses_qiflush_impl(module, flag);
3565
3566 exit:
3567 return return_value;
3568 }
3569
3570 #if (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM))
3571
3572 PyDoc_STRVAR(_curses_update_lines_cols__doc__,
3573 "update_lines_cols($module, /)\n"
3574 "--\n"
3575 "\n");
3576
3577 #define _CURSES_UPDATE_LINES_COLS_METHODDEF \
3578 {"update_lines_cols", (PyCFunction)_curses_update_lines_cols, METH_NOARGS, _curses_update_lines_cols__doc__},
3579
3580 static PyObject *
3581 _curses_update_lines_cols_impl(PyObject *module);
3582
3583 static PyObject *
3584 _curses_update_lines_cols(PyObject *module, PyObject *Py_UNUSED(ignored))
3585 {
3586 return _curses_update_lines_cols_impl(module);
3587 }
3588
3589 #endif /* (defined(HAVE_CURSES_RESIZETERM) || defined(HAVE_CURSES_RESIZE_TERM)) */
3590
3591 PyDoc_STRVAR(_curses_raw__doc__,
3592 "raw($module, flag=True, /)\n"
3593 "--\n"
3594 "\n"
3595 "Enter raw mode.\n"
3596 "\n"
3597 " flag\n"
3598 " If false, the effect is the same as calling noraw().\n"
3599 "\n"
3600 "In raw mode, normal line buffering and processing of interrupt, quit,\n"
3601 "suspend, and flow control keys are turned off; characters are presented to\n"
3602 "curses input functions one by one.");
3603
3604 #define _CURSES_RAW_METHODDEF \
3605 {"raw", _PyCFunction_CAST(_curses_raw), METH_FASTCALL, _curses_raw__doc__},
3606
3607 static PyObject *
3608 _curses_raw_impl(PyObject *module, int flag);
3609
3610 static PyObject *
3611 _curses_raw(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3612 {
3613 PyObject *return_value = NULL;
3614 int flag = 1;
3615
3616 if (!_PyArg_CheckPositional("raw", nargs, 0, 1)) {
3617 goto exit;
3618 }
3619 if (nargs < 1) {
3620 goto skip_optional;
3621 }
3622 flag = PyObject_IsTrue(args[0]);
3623 if (flag < 0) {
3624 goto exit;
3625 }
3626 skip_optional:
3627 return_value = _curses_raw_impl(module, flag);
3628
3629 exit:
3630 return return_value;
3631 }
3632
3633 PyDoc_STRVAR(_curses_reset_prog_mode__doc__,
3634 "reset_prog_mode($module, /)\n"
3635 "--\n"
3636 "\n"
3637 "Restore the terminal to \"program\" mode, as previously saved by def_prog_mode().");
3638
3639 #define _CURSES_RESET_PROG_MODE_METHODDEF \
3640 {"reset_prog_mode", (PyCFunction)_curses_reset_prog_mode, METH_NOARGS, _curses_reset_prog_mode__doc__},
3641
3642 static PyObject *
3643 _curses_reset_prog_mode_impl(PyObject *module);
3644
3645 static PyObject *
3646 _curses_reset_prog_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
3647 {
3648 return _curses_reset_prog_mode_impl(module);
3649 }
3650
3651 PyDoc_STRVAR(_curses_reset_shell_mode__doc__,
3652 "reset_shell_mode($module, /)\n"
3653 "--\n"
3654 "\n"
3655 "Restore the terminal to \"shell\" mode, as previously saved by def_shell_mode().");
3656
3657 #define _CURSES_RESET_SHELL_MODE_METHODDEF \
3658 {"reset_shell_mode", (PyCFunction)_curses_reset_shell_mode, METH_NOARGS, _curses_reset_shell_mode__doc__},
3659
3660 static PyObject *
3661 _curses_reset_shell_mode_impl(PyObject *module);
3662
3663 static PyObject *
3664 _curses_reset_shell_mode(PyObject *module, PyObject *Py_UNUSED(ignored))
3665 {
3666 return _curses_reset_shell_mode_impl(module);
3667 }
3668
3669 PyDoc_STRVAR(_curses_resetty__doc__,
3670 "resetty($module, /)\n"
3671 "--\n"
3672 "\n"
3673 "Restore terminal mode.");
3674
3675 #define _CURSES_RESETTY_METHODDEF \
3676 {"resetty", (PyCFunction)_curses_resetty, METH_NOARGS, _curses_resetty__doc__},
3677
3678 static PyObject *
3679 _curses_resetty_impl(PyObject *module);
3680
3681 static PyObject *
3682 _curses_resetty(PyObject *module, PyObject *Py_UNUSED(ignored))
3683 {
3684 return _curses_resetty_impl(module);
3685 }
3686
3687 #if defined(HAVE_CURSES_RESIZETERM)
3688
3689 PyDoc_STRVAR(_curses_resizeterm__doc__,
3690 "resizeterm($module, nlines, ncols, /)\n"
3691 "--\n"
3692 "\n"
3693 "Resize the standard and current windows to the specified dimensions.\n"
3694 "\n"
3695 " nlines\n"
3696 " Height.\n"
3697 " ncols\n"
3698 " Width.\n"
3699 "\n"
3700 "Adjusts other bookkeeping data used by the curses library that record the\n"
3701 "window dimensions (in particular the SIGWINCH handler).");
3702
3703 #define _CURSES_RESIZETERM_METHODDEF \
3704 {"resizeterm", _PyCFunction_CAST(_curses_resizeterm), METH_FASTCALL, _curses_resizeterm__doc__},
3705
3706 static PyObject *
3707 _curses_resizeterm_impl(PyObject *module, short nlines, short ncols);
3708
3709 static PyObject *
3710 _curses_resizeterm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3711 {
3712 PyObject *return_value = NULL;
3713 short nlines;
3714 short ncols;
3715
3716 if (!_PyArg_CheckPositional("resizeterm", nargs, 2, 2)) {
3717 goto exit;
3718 }
3719 {
3720 long ival = PyLong_AsLong(args[0]);
3721 if (ival == -1 && PyErr_Occurred()) {
3722 goto exit;
3723 }
3724 else if (ival < SHRT_MIN) {
3725 PyErr_SetString(PyExc_OverflowError,
3726 "signed short integer is less than minimum");
3727 goto exit;
3728 }
3729 else if (ival > SHRT_MAX) {
3730 PyErr_SetString(PyExc_OverflowError,
3731 "signed short integer is greater than maximum");
3732 goto exit;
3733 }
3734 else {
3735 nlines = (short) ival;
3736 }
3737 }
3738 {
3739 long ival = PyLong_AsLong(args[1]);
3740 if (ival == -1 && PyErr_Occurred()) {
3741 goto exit;
3742 }
3743 else if (ival < SHRT_MIN) {
3744 PyErr_SetString(PyExc_OverflowError,
3745 "signed short integer is less than minimum");
3746 goto exit;
3747 }
3748 else if (ival > SHRT_MAX) {
3749 PyErr_SetString(PyExc_OverflowError,
3750 "signed short integer is greater than maximum");
3751 goto exit;
3752 }
3753 else {
3754 ncols = (short) ival;
3755 }
3756 }
3757 return_value = _curses_resizeterm_impl(module, nlines, ncols);
3758
3759 exit:
3760 return return_value;
3761 }
3762
3763 #endif /* defined(HAVE_CURSES_RESIZETERM) */
3764
3765 #if defined(HAVE_CURSES_RESIZE_TERM)
3766
3767 PyDoc_STRVAR(_curses_resize_term__doc__,
3768 "resize_term($module, nlines, ncols, /)\n"
3769 "--\n"
3770 "\n"
3771 "Backend function used by resizeterm(), performing most of the work.\n"
3772 "\n"
3773 " nlines\n"
3774 " Height.\n"
3775 " ncols\n"
3776 " Width.\n"
3777 "\n"
3778 "When resizing the windows, resize_term() blank-fills the areas that are\n"
3779 "extended. The calling application should fill in these areas with appropriate\n"
3780 "data. The resize_term() function attempts to resize all windows. However,\n"
3781 "due to the calling convention of pads, it is not possible to resize these\n"
3782 "without additional interaction with the application.");
3783
3784 #define _CURSES_RESIZE_TERM_METHODDEF \
3785 {"resize_term", _PyCFunction_CAST(_curses_resize_term), METH_FASTCALL, _curses_resize_term__doc__},
3786
3787 static PyObject *
3788 _curses_resize_term_impl(PyObject *module, short nlines, short ncols);
3789
3790 static PyObject *
3791 _curses_resize_term(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3792 {
3793 PyObject *return_value = NULL;
3794 short nlines;
3795 short ncols;
3796
3797 if (!_PyArg_CheckPositional("resize_term", nargs, 2, 2)) {
3798 goto exit;
3799 }
3800 {
3801 long ival = PyLong_AsLong(args[0]);
3802 if (ival == -1 && PyErr_Occurred()) {
3803 goto exit;
3804 }
3805 else if (ival < SHRT_MIN) {
3806 PyErr_SetString(PyExc_OverflowError,
3807 "signed short integer is less than minimum");
3808 goto exit;
3809 }
3810 else if (ival > SHRT_MAX) {
3811 PyErr_SetString(PyExc_OverflowError,
3812 "signed short integer is greater than maximum");
3813 goto exit;
3814 }
3815 else {
3816 nlines = (short) ival;
3817 }
3818 }
3819 {
3820 long ival = PyLong_AsLong(args[1]);
3821 if (ival == -1 && PyErr_Occurred()) {
3822 goto exit;
3823 }
3824 else if (ival < SHRT_MIN) {
3825 PyErr_SetString(PyExc_OverflowError,
3826 "signed short integer is less than minimum");
3827 goto exit;
3828 }
3829 else if (ival > SHRT_MAX) {
3830 PyErr_SetString(PyExc_OverflowError,
3831 "signed short integer is greater than maximum");
3832 goto exit;
3833 }
3834 else {
3835 ncols = (short) ival;
3836 }
3837 }
3838 return_value = _curses_resize_term_impl(module, nlines, ncols);
3839
3840 exit:
3841 return return_value;
3842 }
3843
3844 #endif /* defined(HAVE_CURSES_RESIZE_TERM) */
3845
3846 PyDoc_STRVAR(_curses_savetty__doc__,
3847 "savetty($module, /)\n"
3848 "--\n"
3849 "\n"
3850 "Save terminal mode.");
3851
3852 #define _CURSES_SAVETTY_METHODDEF \
3853 {"savetty", (PyCFunction)_curses_savetty, METH_NOARGS, _curses_savetty__doc__},
3854
3855 static PyObject *
3856 _curses_savetty_impl(PyObject *module);
3857
3858 static PyObject *
3859 _curses_savetty(PyObject *module, PyObject *Py_UNUSED(ignored))
3860 {
3861 return _curses_savetty_impl(module);
3862 }
3863
3864 #if defined(getsyx)
3865
3866 PyDoc_STRVAR(_curses_setsyx__doc__,
3867 "setsyx($module, y, x, /)\n"
3868 "--\n"
3869 "\n"
3870 "Set the virtual screen cursor.\n"
3871 "\n"
3872 " y\n"
3873 " Y-coordinate.\n"
3874 " x\n"
3875 " X-coordinate.\n"
3876 "\n"
3877 "If y and x are both -1, then leaveok is set.");
3878
3879 #define _CURSES_SETSYX_METHODDEF \
3880 {"setsyx", _PyCFunction_CAST(_curses_setsyx), METH_FASTCALL, _curses_setsyx__doc__},
3881
3882 static PyObject *
3883 _curses_setsyx_impl(PyObject *module, int y, int x);
3884
3885 static PyObject *
3886 _curses_setsyx(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
3887 {
3888 PyObject *return_value = NULL;
3889 int y;
3890 int x;
3891
3892 if (!_PyArg_CheckPositional("setsyx", nargs, 2, 2)) {
3893 goto exit;
3894 }
3895 y = PyLong_AsInt(args[0]);
3896 if (y == -1 && PyErr_Occurred()) {
3897 goto exit;
3898 }
3899 x = PyLong_AsInt(args[1]);
3900 if (x == -1 && PyErr_Occurred()) {
3901 goto exit;
3902 }
3903 return_value = _curses_setsyx_impl(module, y, x);
3904
3905 exit:
3906 return return_value;
3907 }
3908
3909 #endif /* defined(getsyx) */
3910
3911 PyDoc_STRVAR(_curses_start_color__doc__,
3912 "start_color($module, /)\n"
3913 "--\n"
3914 "\n"
3915 "Initializes eight basic colors and global variables COLORS and COLOR_PAIRS.\n"
3916 "\n"
3917 "Must be called if the programmer wants to use colors, and before any other\n"
3918 "color manipulation routine is called. It is good practice to call this\n"
3919 "routine right after initscr().\n"
3920 "\n"
3921 "It also restores the colors on the terminal to the values they had when the\n"
3922 "terminal was just turned on.");
3923
3924 #define _CURSES_START_COLOR_METHODDEF \
3925 {"start_color", (PyCFunction)_curses_start_color, METH_NOARGS, _curses_start_color__doc__},
3926
3927 static PyObject *
3928 _curses_start_color_impl(PyObject *module);
3929
3930 static PyObject *
3931 _curses_start_color(PyObject *module, PyObject *Py_UNUSED(ignored))
3932 {
3933 return _curses_start_color_impl(module);
3934 }
3935
3936 PyDoc_STRVAR(_curses_termattrs__doc__,
3937 "termattrs($module, /)\n"
3938 "--\n"
3939 "\n"
3940 "Return a logical OR of all video attributes supported by the terminal.");
3941
3942 #define _CURSES_TERMATTRS_METHODDEF \
3943 {"termattrs", (PyCFunction)_curses_termattrs, METH_NOARGS, _curses_termattrs__doc__},
3944
3945 static PyObject *
3946 _curses_termattrs_impl(PyObject *module);
3947
3948 static PyObject *
3949 _curses_termattrs(PyObject *module, PyObject *Py_UNUSED(ignored))
3950 {
3951 return _curses_termattrs_impl(module);
3952 }
3953
3954 PyDoc_STRVAR(_curses_termname__doc__,
3955 "termname($module, /)\n"
3956 "--\n"
3957 "\n"
3958 "Return the value of the environment variable TERM, truncated to 14 characters.");
3959
3960 #define _CURSES_TERMNAME_METHODDEF \
3961 {"termname", (PyCFunction)_curses_termname, METH_NOARGS, _curses_termname__doc__},
3962
3963 static PyObject *
3964 _curses_termname_impl(PyObject *module);
3965
3966 static PyObject *
3967 _curses_termname(PyObject *module, PyObject *Py_UNUSED(ignored))
3968 {
3969 return _curses_termname_impl(module);
3970 }
3971
3972 PyDoc_STRVAR(_curses_tigetflag__doc__,
3973 "tigetflag($module, capname, /)\n"
3974 "--\n"
3975 "\n"
3976 "Return the value of the Boolean capability.\n"
3977 "\n"
3978 " capname\n"
3979 " The terminfo capability name.\n"
3980 "\n"
3981 "The value -1 is returned if capname is not a Boolean capability, or 0 if\n"
3982 "it is canceled or absent from the terminal description.");
3983
3984 #define _CURSES_TIGETFLAG_METHODDEF \
3985 {"tigetflag", (PyCFunction)_curses_tigetflag, METH_O, _curses_tigetflag__doc__},
3986
3987 static PyObject *
3988 _curses_tigetflag_impl(PyObject *module, const char *capname);
3989
3990 static PyObject *
3991 _curses_tigetflag(PyObject *module, PyObject *arg)
3992 {
3993 PyObject *return_value = NULL;
3994 const char *capname;
3995
3996 if (!PyUnicode_Check(arg)) {
3997 _PyArg_BadArgument("tigetflag", "argument", "str", arg);
3998 goto exit;
3999 }
4000 Py_ssize_t capname_length;
4001 capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
4002 if (capname == NULL) {
4003 goto exit;
4004 }
4005 if (strlen(capname) != (size_t)capname_length) {
4006 PyErr_SetString(PyExc_ValueError, "embedded null character");
4007 goto exit;
4008 }
4009 return_value = _curses_tigetflag_impl(module, capname);
4010
4011 exit:
4012 return return_value;
4013 }
4014
4015 PyDoc_STRVAR(_curses_tigetnum__doc__,
4016 "tigetnum($module, capname, /)\n"
4017 "--\n"
4018 "\n"
4019 "Return the value of the numeric capability.\n"
4020 "\n"
4021 " capname\n"
4022 " The terminfo capability name.\n"
4023 "\n"
4024 "The value -2 is returned if capname is not a numeric capability, or -1 if\n"
4025 "it is canceled or absent from the terminal description.");
4026
4027 #define _CURSES_TIGETNUM_METHODDEF \
4028 {"tigetnum", (PyCFunction)_curses_tigetnum, METH_O, _curses_tigetnum__doc__},
4029
4030 static PyObject *
4031 _curses_tigetnum_impl(PyObject *module, const char *capname);
4032
4033 static PyObject *
4034 _curses_tigetnum(PyObject *module, PyObject *arg)
4035 {
4036 PyObject *return_value = NULL;
4037 const char *capname;
4038
4039 if (!PyUnicode_Check(arg)) {
4040 _PyArg_BadArgument("tigetnum", "argument", "str", arg);
4041 goto exit;
4042 }
4043 Py_ssize_t capname_length;
4044 capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
4045 if (capname == NULL) {
4046 goto exit;
4047 }
4048 if (strlen(capname) != (size_t)capname_length) {
4049 PyErr_SetString(PyExc_ValueError, "embedded null character");
4050 goto exit;
4051 }
4052 return_value = _curses_tigetnum_impl(module, capname);
4053
4054 exit:
4055 return return_value;
4056 }
4057
4058 PyDoc_STRVAR(_curses_tigetstr__doc__,
4059 "tigetstr($module, capname, /)\n"
4060 "--\n"
4061 "\n"
4062 "Return the value of the string capability.\n"
4063 "\n"
4064 " capname\n"
4065 " The terminfo capability name.\n"
4066 "\n"
4067 "None is returned if capname is not a string capability, or is canceled or\n"
4068 "absent from the terminal description.");
4069
4070 #define _CURSES_TIGETSTR_METHODDEF \
4071 {"tigetstr", (PyCFunction)_curses_tigetstr, METH_O, _curses_tigetstr__doc__},
4072
4073 static PyObject *
4074 _curses_tigetstr_impl(PyObject *module, const char *capname);
4075
4076 static PyObject *
4077 _curses_tigetstr(PyObject *module, PyObject *arg)
4078 {
4079 PyObject *return_value = NULL;
4080 const char *capname;
4081
4082 if (!PyUnicode_Check(arg)) {
4083 _PyArg_BadArgument("tigetstr", "argument", "str", arg);
4084 goto exit;
4085 }
4086 Py_ssize_t capname_length;
4087 capname = PyUnicode_AsUTF8AndSize(arg, &capname_length);
4088 if (capname == NULL) {
4089 goto exit;
4090 }
4091 if (strlen(capname) != (size_t)capname_length) {
4092 PyErr_SetString(PyExc_ValueError, "embedded null character");
4093 goto exit;
4094 }
4095 return_value = _curses_tigetstr_impl(module, capname);
4096
4097 exit:
4098 return return_value;
4099 }
4100
4101 PyDoc_STRVAR(_curses_tparm__doc__,
4102 "tparm($module, str, i1=0, i2=0, i3=0, i4=0, i5=0, i6=0, i7=0, i8=0,\n"
4103 " i9=0, /)\n"
4104 "--\n"
4105 "\n"
4106 "Instantiate the specified byte string with the supplied parameters.\n"
4107 "\n"
4108 " str\n"
4109 " Parameterized byte string obtained from the terminfo database.");
4110
4111 #define _CURSES_TPARM_METHODDEF \
4112 {"tparm", _PyCFunction_CAST(_curses_tparm), METH_FASTCALL, _curses_tparm__doc__},
4113
4114 static PyObject *
4115 _curses_tparm_impl(PyObject *module, const char *str, int i1, int i2, int i3,
4116 int i4, int i5, int i6, int i7, int i8, int i9);
4117
4118 static PyObject *
4119 _curses_tparm(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
4120 {
4121 PyObject *return_value = NULL;
4122 const char *str;
4123 int i1 = 0;
4124 int i2 = 0;
4125 int i3 = 0;
4126 int i4 = 0;
4127 int i5 = 0;
4128 int i6 = 0;
4129 int i7 = 0;
4130 int i8 = 0;
4131 int i9 = 0;
4132
4133 if (!_PyArg_ParseStack(args, nargs, "y|iiiiiiiii:tparm",
4134 &str, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9)) {
4135 goto exit;
4136 }
4137 return_value = _curses_tparm_impl(module, str, i1, i2, i3, i4, i5, i6, i7, i8, i9);
4138
4139 exit:
4140 return return_value;
4141 }
4142
4143 #if defined(HAVE_CURSES_TYPEAHEAD)
4144
4145 PyDoc_STRVAR(_curses_typeahead__doc__,
4146 "typeahead($module, fd, /)\n"
4147 "--\n"
4148 "\n"
4149 "Specify that the file descriptor fd be used for typeahead checking.\n"
4150 "\n"
4151 " fd\n"
4152 " File descriptor.\n"
4153 "\n"
4154 "If fd is -1, then no typeahead checking is done.");
4155
4156 #define _CURSES_TYPEAHEAD_METHODDEF \
4157 {"typeahead", (PyCFunction)_curses_typeahead, METH_O, _curses_typeahead__doc__},
4158
4159 static PyObject *
4160 _curses_typeahead_impl(PyObject *module, int fd);
4161
4162 static PyObject *
4163 _curses_typeahead(PyObject *module, PyObject *arg)
4164 {
4165 PyObject *return_value = NULL;
4166 int fd;
4167
4168 fd = PyLong_AsInt(arg);
4169 if (fd == -1 && PyErr_Occurred()) {
4170 goto exit;
4171 }
4172 return_value = _curses_typeahead_impl(module, fd);
4173
4174 exit:
4175 return return_value;
4176 }
4177
4178 #endif /* defined(HAVE_CURSES_TYPEAHEAD) */
4179
4180 PyDoc_STRVAR(_curses_unctrl__doc__,
4181 "unctrl($module, ch, /)\n"
4182 "--\n"
4183 "\n"
4184 "Return a string which is a printable representation of the character ch.\n"
4185 "\n"
4186 "Control characters are displayed as a caret followed by the character,\n"
4187 "for example as ^C. Printing characters are left as they are.");
4188
4189 #define _CURSES_UNCTRL_METHODDEF \
4190 {"unctrl", (PyCFunction)_curses_unctrl, METH_O, _curses_unctrl__doc__},
4191
4192 PyDoc_STRVAR(_curses_ungetch__doc__,
4193 "ungetch($module, ch, /)\n"
4194 "--\n"
4195 "\n"
4196 "Push ch so the next getch() will return it.");
4197
4198 #define _CURSES_UNGETCH_METHODDEF \
4199 {"ungetch", (PyCFunction)_curses_ungetch, METH_O, _curses_ungetch__doc__},
4200
4201 #if defined(HAVE_NCURSESW)
4202
4203 PyDoc_STRVAR(_curses_unget_wch__doc__,
4204 "unget_wch($module, ch, /)\n"
4205 "--\n"
4206 "\n"
4207 "Push ch so the next get_wch() will return it.");
4208
4209 #define _CURSES_UNGET_WCH_METHODDEF \
4210 {"unget_wch", (PyCFunction)_curses_unget_wch, METH_O, _curses_unget_wch__doc__},
4211
4212 #endif /* defined(HAVE_NCURSESW) */
4213
4214 #if defined(HAVE_CURSES_USE_ENV)
4215
4216 PyDoc_STRVAR(_curses_use_env__doc__,
4217 "use_env($module, flag, /)\n"
4218 "--\n"
4219 "\n"
4220 "Use environment variables LINES and COLUMNS.\n"
4221 "\n"
4222 "If used, this function should be called before initscr() or newterm() are\n"
4223 "called.\n"
4224 "\n"
4225 "When flag is False, the values of lines and columns specified in the terminfo\n"
4226 "database will be used, even if environment variables LINES and COLUMNS (used\n"
4227 "by default) are set, or if curses is running in a window (in which case\n"
4228 "default behavior would be to use the window size if LINES and COLUMNS are\n"
4229 "not set).");
4230
4231 #define _CURSES_USE_ENV_METHODDEF \
4232 {"use_env", (PyCFunction)_curses_use_env, METH_O, _curses_use_env__doc__},
4233
4234 static PyObject *
4235 _curses_use_env_impl(PyObject *module, int flag);
4236
4237 static PyObject *
4238 _curses_use_env(PyObject *module, PyObject *arg)
4239 {
4240 PyObject *return_value = NULL;
4241 int flag;
4242
4243 flag = PyObject_IsTrue(arg);
4244 if (flag < 0) {
4245 goto exit;
4246 }
4247 return_value = _curses_use_env_impl(module, flag);
4248
4249 exit:
4250 return return_value;
4251 }
4252
4253 #endif /* defined(HAVE_CURSES_USE_ENV) */
4254
4255 #if !defined(STRICT_SYSV_CURSES)
4256
4257 PyDoc_STRVAR(_curses_use_default_colors__doc__,
4258 "use_default_colors($module, /)\n"
4259 "--\n"
4260 "\n"
4261 "Equivalent to assume_default_colors(-1, -1).");
4262
4263 #define _CURSES_USE_DEFAULT_COLORS_METHODDEF \
4264 {"use_default_colors", (PyCFunction)_curses_use_default_colors, METH_NOARGS, _curses_use_default_colors__doc__},
4265
4266 static PyObject *
4267 _curses_use_default_colors_impl(PyObject *module);
4268
4269 static PyObject *
4270 _curses_use_default_colors(PyObject *module, PyObject *Py_UNUSED(ignored))
4271 {
4272 return _curses_use_default_colors_impl(module);
4273 }
4274
4275 #endif /* !defined(STRICT_SYSV_CURSES) */
4276
4277 #if !defined(STRICT_SYSV_CURSES)
4278
4279 PyDoc_STRVAR(_curses_assume_default_colors__doc__,
4280 "assume_default_colors($module, fg, bg, /)\n"
4281 "--\n"
4282 "\n"
4283 "Allow use of default values for colors on terminals supporting this feature.\n"
4284 "\n"
4285 "Assign terminal default foreground/background colors to color number -1.\n"
4286 "Change the definition of the color-pair 0 to (fg, bg).\n"
4287 "\n"
4288 "Use this to support transparency in your application.");
4289
4290 #define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF \
4291 {"assume_default_colors", _PyCFunction_CAST(_curses_assume_default_colors), METH_FASTCALL, _curses_assume_default_colors__doc__},
4292
4293 static PyObject *
4294 _curses_assume_default_colors_impl(PyObject *module, int fg, int bg);
4295
4296 static PyObject *
4297 _curses_assume_default_colors(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
4298 {
4299 PyObject *return_value = NULL;
4300 int fg;
4301 int bg;
4302
4303 if (!_PyArg_CheckPositional("assume_default_colors", nargs, 2, 2)) {
4304 goto exit;
4305 }
4306 fg = PyLong_AsInt(args[0]);
4307 if (fg == -1 && PyErr_Occurred()) {
4308 goto exit;
4309 }
4310 bg = PyLong_AsInt(args[1]);
4311 if (bg == -1 && PyErr_Occurred()) {
4312 goto exit;
4313 }
4314 return_value = _curses_assume_default_colors_impl(module, fg, bg);
4315
4316 exit:
4317 return return_value;
4318 }
4319
4320 #endif /* !defined(STRICT_SYSV_CURSES) */
4321
4322 PyDoc_STRVAR(_curses_has_extended_color_support__doc__,
4323 "has_extended_color_support($module, /)\n"
4324 "--\n"
4325 "\n"
4326 "Return True if the module supports extended colors; otherwise, return False.\n"
4327 "\n"
4328 "Extended color support allows more than 256 color-pairs for terminals\n"
4329 "that support more than 16 colors (e.g. xterm-256color).");
4330
4331 #define _CURSES_HAS_EXTENDED_COLOR_SUPPORT_METHODDEF \
4332 {"has_extended_color_support", (PyCFunction)_curses_has_extended_color_support, METH_NOARGS, _curses_has_extended_color_support__doc__},
4333
4334 static PyObject *
4335 _curses_has_extended_color_support_impl(PyObject *module);
4336
4337 static PyObject *
4338 _curses_has_extended_color_support(PyObject *module, PyObject *Py_UNUSED(ignored))
4339 {
4340 return _curses_has_extended_color_support_impl(module);
4341 }
4342
4343 #ifndef _CURSES_WINDOW_ENCLOSE_METHODDEF
4344 #define _CURSES_WINDOW_ENCLOSE_METHODDEF
4345 #endif /* !defined(_CURSES_WINDOW_ENCLOSE_METHODDEF) */
4346
4347 #ifndef _CURSES_WINDOW_GET_WCH_METHODDEF
4348 #define _CURSES_WINDOW_GET_WCH_METHODDEF
4349 #endif /* !defined(_CURSES_WINDOW_GET_WCH_METHODDEF) */
4350
4351 #ifndef _CURSES_WINDOW_NOUTREFRESH_METHODDEF
4352 #define _CURSES_WINDOW_NOUTREFRESH_METHODDEF
4353 #endif /* !defined(_CURSES_WINDOW_NOUTREFRESH_METHODDEF) */
4354
4355 #ifndef _CURSES_FILTER_METHODDEF
4356 #define _CURSES_FILTER_METHODDEF
4357 #endif /* !defined(_CURSES_FILTER_METHODDEF) */
4358
4359 #ifndef _CURSES_GETSYX_METHODDEF
4360 #define _CURSES_GETSYX_METHODDEF
4361 #endif /* !defined(_CURSES_GETSYX_METHODDEF) */
4362
4363 #ifndef _CURSES_GETMOUSE_METHODDEF
4364 #define _CURSES_GETMOUSE_METHODDEF
4365 #endif /* !defined(_CURSES_GETMOUSE_METHODDEF) */
4366
4367 #ifndef _CURSES_UNGETMOUSE_METHODDEF
4368 #define _CURSES_UNGETMOUSE_METHODDEF
4369 #endif /* !defined(_CURSES_UNGETMOUSE_METHODDEF) */
4370
4371 #ifndef _CURSES_HAS_KEY_METHODDEF
4372 #define _CURSES_HAS_KEY_METHODDEF
4373 #endif /* !defined(_CURSES_HAS_KEY_METHODDEF) */
4374
4375 #ifndef _CURSES_GET_ESCDELAY_METHODDEF
4376 #define _CURSES_GET_ESCDELAY_METHODDEF
4377 #endif /* !defined(_CURSES_GET_ESCDELAY_METHODDEF) */
4378
4379 #ifndef _CURSES_SET_ESCDELAY_METHODDEF
4380 #define _CURSES_SET_ESCDELAY_METHODDEF
4381 #endif /* !defined(_CURSES_SET_ESCDELAY_METHODDEF) */
4382
4383 #ifndef _CURSES_GET_TABSIZE_METHODDEF
4384 #define _CURSES_GET_TABSIZE_METHODDEF
4385 #endif /* !defined(_CURSES_GET_TABSIZE_METHODDEF) */
4386
4387 #ifndef _CURSES_SET_TABSIZE_METHODDEF
4388 #define _CURSES_SET_TABSIZE_METHODDEF
4389 #endif /* !defined(_CURSES_SET_TABSIZE_METHODDEF) */
4390
4391 #ifndef _CURSES_IS_TERM_RESIZED_METHODDEF
4392 #define _CURSES_IS_TERM_RESIZED_METHODDEF
4393 #endif /* !defined(_CURSES_IS_TERM_RESIZED_METHODDEF) */
4394
4395 #ifndef _CURSES_MOUSEINTERVAL_METHODDEF
4396 #define _CURSES_MOUSEINTERVAL_METHODDEF
4397 #endif /* !defined(_CURSES_MOUSEINTERVAL_METHODDEF) */
4398
4399 #ifndef _CURSES_MOUSEMASK_METHODDEF
4400 #define _CURSES_MOUSEMASK_METHODDEF
4401 #endif /* !defined(_CURSES_MOUSEMASK_METHODDEF) */
4402
4403 #ifndef _CURSES_UPDATE_LINES_COLS_METHODDEF
4404 #define _CURSES_UPDATE_LINES_COLS_METHODDEF
4405 #endif /* !defined(_CURSES_UPDATE_LINES_COLS_METHODDEF) */
4406
4407 #ifndef _CURSES_RESIZETERM_METHODDEF
4408 #define _CURSES_RESIZETERM_METHODDEF
4409 #endif /* !defined(_CURSES_RESIZETERM_METHODDEF) */
4410
4411 #ifndef _CURSES_RESIZE_TERM_METHODDEF
4412 #define _CURSES_RESIZE_TERM_METHODDEF
4413 #endif /* !defined(_CURSES_RESIZE_TERM_METHODDEF) */
4414
4415 #ifndef _CURSES_SETSYX_METHODDEF
4416 #define _CURSES_SETSYX_METHODDEF
4417 #endif /* !defined(_CURSES_SETSYX_METHODDEF) */
4418
4419 #ifndef _CURSES_TYPEAHEAD_METHODDEF
4420 #define _CURSES_TYPEAHEAD_METHODDEF
4421 #endif /* !defined(_CURSES_TYPEAHEAD_METHODDEF) */
4422
4423 #ifndef _CURSES_UNGET_WCH_METHODDEF
4424 #define _CURSES_UNGET_WCH_METHODDEF
4425 #endif /* !defined(_CURSES_UNGET_WCH_METHODDEF) */
4426
4427 #ifndef _CURSES_USE_ENV_METHODDEF
4428 #define _CURSES_USE_ENV_METHODDEF
4429 #endif /* !defined(_CURSES_USE_ENV_METHODDEF) */
4430
4431 #ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
4432 #define _CURSES_USE_DEFAULT_COLORS_METHODDEF
4433 #endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
4434
4435 #ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
4436 #define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
4437 #endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */
4438 /*[clinic end generated code: output=78252f8805206d95 input=a9049054013a1b77]*/