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