Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_STRVAR(curses_window_addch__doc__, |
| 6 | "addch([y, x,] ch, [attr])\n" |
| 7 | "Paint character ch at (y, x) with attributes attr.\n" |
| 8 | "\n" |
| 9 | " y\n" |
| 10 | " Y-coordinate.\n" |
| 11 | " x\n" |
| 12 | " X-coordinate.\n" |
| 13 | " ch\n" |
| 14 | " Character to add.\n" |
| 15 | " attr\n" |
| 16 | " Attributes for the character.\n" |
| 17 | "\n" |
| 18 | "Paint character ch at (y, x) with attributes attr,\n" |
| 19 | "overwriting any character previously painted at that location.\n" |
| 20 | "By default, the character position and attributes are the\n" |
| 21 | "current settings for the window object."); |
| 22 | |
| 23 | #define CURSES_WINDOW_ADDCH_METHODDEF \ |
| 24 | {"addch", (PyCFunction)curses_window_addch, METH_VARARGS, curses_window_addch__doc__}, |
| 25 | |
| 26 | static PyObject * |
Larry Hastings | 89964c4 | 2015-04-14 18:07:59 -0400 | [diff] [blame] | 27 | curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1, int y, |
| 28 | int x, PyObject *ch, int group_right_1, long attr); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 29 | |
| 30 | static PyObject * |
| 31 | curses_window_addch(PyCursesWindowObject *self, PyObject *args) |
| 32 | { |
| 33 | PyObject *return_value = NULL; |
| 34 | int group_left_1 = 0; |
| 35 | int y = 0; |
| 36 | int x = 0; |
| 37 | PyObject *ch; |
| 38 | int group_right_1 = 0; |
| 39 | long attr = 0; |
| 40 | |
| 41 | switch (PyTuple_GET_SIZE(args)) { |
| 42 | case 1: |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 43 | if (!PyArg_ParseTuple(args, "O:addch", &ch)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 44 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 45 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 46 | break; |
| 47 | case 2: |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 48 | if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 49 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 50 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 51 | group_right_1 = 1; |
| 52 | break; |
| 53 | case 3: |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 54 | if (!PyArg_ParseTuple(args, "iiO:addch", &y, &x, &ch)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 55 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 56 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 57 | group_left_1 = 1; |
| 58 | break; |
| 59 | case 4: |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 60 | if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 61 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 62 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 63 | group_right_1 = 1; |
| 64 | group_left_1 = 1; |
| 65 | break; |
| 66 | default: |
| 67 | PyErr_SetString(PyExc_TypeError, "curses.window.addch requires 1 to 4 arguments"); |
| 68 | goto exit; |
| 69 | } |
| 70 | return_value = curses_window_addch_impl(self, group_left_1, y, x, ch, group_right_1, attr); |
| 71 | |
| 72 | exit: |
| 73 | return return_value; |
| 74 | } |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 75 | /*[clinic end generated code: output=13ffc5f8d79cbfbf input=a9049054013a1b77]*/ |