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