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