obj may also be a complexchar, whose cell is used directly; it carries its
own rendition, so supplying *attr* too (attr_given) is rejected. */
static int
-PyCurses_ConvertToCell(PyCursesWindowObject *win, PyObject *obj, long attr,
+PyCurses_ConvertToCell(PyCursesWindowObject *win, PyObject *obj, attr_t attr,
int attr_given, const char *funcname,
chtype *pch, cchar_t *pwc)
{
class attr_converter(CConverter):
type = 'attr_t'
converter = 'attr_converter'
+ c_ignored_default = '0'
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=6132d3d99d3ec25a]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=57b994c97cbd5e80]*/
#ifdef HAVE_NCURSESW
/* -------------------------------------------------------*/
Character to add.
[
- attr: long
+ attr: attr
Attributes for the character.
]
/
static PyObject *
_curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int group_right_1,
- long attr)
-/*[clinic end generated code: output=00f4c37af3378f45 input=ab196a1dac3d354c]*/
+ attr_t attr)
+/*[clinic end generated code: output=3306e15a7059998f input=0a09ecdd04aa0a2d]*/
{
int coordinates_group = group_left_1;
int rtn;
#endif
static int
-curses_wattrset(PyCursesWindowObject *self, long attr, const char *funcname)
+curses_wattrset(PyCursesWindowObject *self, attr_t attr, const char *funcname)
{
if (wattrset(self->win, attr) == ERR) {
curses_window_set_error(self, "wattrset", funcname);
String to add.
[
- attr: long
+ attr: attr
Attributes for characters.
]
/
static PyObject *
_curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int group_right_1,
- long attr)
-/*[clinic end generated code: output=65a928ea85ff3115 input=ff6cbb91448a22a3]*/
+ attr_t attr)
+/*[clinic end generated code: output=4942cdb202012076 input=0202b09895bcb472]*/
{
int rtn;
int strtype;
Maximal number of characters.
[
- attr: long
+ attr: attr
Attributes for characters.
]
/
static PyObject *
_curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int n,
- int group_right_1, long attr)
-/*[clinic end generated code: output=6d21cee2ce6876d9 input=72718415c2744a2a]*/
+ int group_right_1, attr_t attr)
+/*[clinic end generated code: output=356ce38504dabf1d input=147405505606cd08]*/
{
int rtn;
int strtype;
ch: object
Background character.
[
- attr: long
+ attr: attr
Background attributes.
]
/
static PyObject *
_curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch,
- int group_right_1, long attr)
-/*[clinic end generated code: output=73cb11ecca59612f input=a2129c1b709db432]*/
+ int group_right_1, attr_t attr)
+/*[clinic end generated code: output=4dc2599da3afa46a input=7aee8008ff8066a5]*/
{
chtype bkgd;
#ifdef HAVE_NCURSESW
/*[clinic input]
_curses.window.attroff
- attr: long
+ attr: attr
/
Remove attribute attr from the "background" set.
[clinic start generated code]*/
static PyObject *
-_curses_window_attroff_impl(PyCursesWindowObject *self, long attr)
-/*[clinic end generated code: output=8a2fcd4df682fc64 input=786beedf06a7befe]*/
+_curses_window_attroff_impl(PyCursesWindowObject *self, attr_t attr)
+/*[clinic end generated code: output=27c9e77df32fa5d3 input=a22d4035e962e9a7]*/
{
int rtn = wattroff(self->win, (attr_t)attr);
return curses_window_check_err(self, rtn, "wattroff", "attroff");
/*[clinic input]
_curses.window.attron
- attr: long
+ attr: attr
/
Add attribute attr to the "background" set.
[clinic start generated code]*/
static PyObject *
-_curses_window_attron_impl(PyCursesWindowObject *self, long attr)
-/*[clinic end generated code: output=7afea43b237fa870 input=b57f824e1bf58326]*/
+_curses_window_attron_impl(PyCursesWindowObject *self, attr_t attr)
+/*[clinic end generated code: output=150ff7c387068cc7 input=361b6389f4d08681]*/
{
int rtn = wattron(self->win, (attr_t)attr);
return curses_window_check_err(self, rtn, "wattron", "attron");
/*[clinic input]
_curses.window.attrset
- attr: long
+ attr: attr
/
Set the "background" set of attributes.
[clinic start generated code]*/
static PyObject *
-_curses_window_attrset_impl(PyCursesWindowObject *self, long attr)
-/*[clinic end generated code: output=84e379bff20c0433 input=42e400c0d0154ab5]*/
+_curses_window_attrset_impl(PyCursesWindowObject *self, attr_t attr)
+/*[clinic end generated code: output=1b57b2a512603eb0 input=af748b1c18e35c34]*/
{
int rtn = wattrset(self->win, (attr_t)attr);
return curses_window_check_err(self, rtn, "wattrset", "attrset");
ch: object
Background character.
[
- attr: long
+ attr: attr
Background attributes.
]
/
static PyObject *
_curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch,
- int group_right_1, long attr)
-/*[clinic end generated code: output=3c32f2de5685a482 input=1f0811b24af821ca]*/
+ int group_right_1, attr_t attr)
+/*[clinic end generated code: output=32f5117c9e45422a input=64cf7cd3562b379b]*/
{
chtype bkgd;
#ifdef HAVE_NCURSESW
Character to add.
[
- attr: long
+ attr: attr
Attributes for the character.
]
/
static PyObject *
_curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch,
- int group_right_1, long attr)
-/*[clinic end generated code: output=f42da9e200c935e5 input=26e16855ec1b0e78]*/
+ int group_right_1, attr_t attr)
+/*[clinic end generated code: output=ab03afa580aa6a2a input=cd74c42aadcc7e30]*/
{
chtype ch_;
#ifdef HAVE_NCURSESW
Line length.
[
- attr: long
+ attr: attr
Attributes for the characters.
]
/
static PyObject *
_curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int n,
- int group_right_1, long attr)
-/*[clinic end generated code: output=c00d489d61fc9eef input=924f8c28521bc2ec]*/
+ int group_right_1, attr_t attr)
+/*[clinic end generated code: output=2c7489b8bd10c446 input=5d9f72ccba73975c]*/
{
chtype ch_;
#ifdef HAVE_NCURSESW
Character to insert.
[
- attr: long
+ attr: attr
Attributes for the character.
]
/
static PyObject *
_curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int group_right_1,
- long attr)
-/*[clinic end generated code: output=ade8cfe3a3bf3e34 input=47d2989159ae6ca7]*/
+ attr_t attr)
+/*[clinic end generated code: output=9d2576c0d8d982c4 input=f76641d529dbd8af]*/
{
int rtn;
chtype ch_ = 0;
String to insert.
[
- attr: long
+ attr: attr
Attributes for characters.
]
/
static PyObject *
_curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int group_right_1,
- long attr)
-/*[clinic end generated code: output=c259a5265ad0b777 input=dbfbdd3892155ea6]*/
+ attr_t attr)
+/*[clinic end generated code: output=2c8ed843880619ab input=f4a9d26b270058c2]*/
{
int rtn;
int strtype;
Maximal number of characters.
[
- attr: long
+ attr: attr
Attributes for characters.
]
/
static PyObject *
_curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int n,
- int group_right_1, long attr)
-/*[clinic end generated code: output=971a32ea6328ec8b input=fd0a9b65b84b385f]*/
+ int group_right_1, attr_t attr)
+/*[clinic end generated code: output=4895829689f3bdd2 input=7412feb3910276bf]*/
{
int rtn;
int strtype;
Line length.
[
- attr: long
+ attr: attr
Attributes for the character.
]
/
static PyObject *
_curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int n,
- int group_right_1, long attr)
-/*[clinic end generated code: output=287ad1cc8982217f input=1d4aa27ff0309bbc]*/
+ int group_right_1, attr_t attr)
+/*[clinic end generated code: output=18efd3ea37bb04f6 input=e8678752623197a1]*/
{
chtype ch_;
#ifdef HAVE_NCURSESW
PyCursesStatefulInitialised(module);
PyCursesStatefulInitialisedColor(module);
- return PyLong_FromLong(COLOR_PAIR(pair_number));
+ /* COLOR_PAIR() packs the pair into a limited field; a pair too large to be
+ recovered by its inverse PAIR_NUMBER() would be masked to a different
+ one. Reject pairs that do not round-trip (this assumes only that the two
+ macros are inverses). color_set()/attr_set()/complexchar can still
+ display larger pairs. */
+ chtype attr = COLOR_PAIR(pair_number);
+ if (pair_number < 0 || PAIR_NUMBER(attr) != pair_number) {
+ PyErr_Format(PyExc_OverflowError,
+ "color pair %d does not fit in a chtype "
+ "(color_pair() can encode only pairs 0 to %d)",
+ pair_number, (int)PAIR_NUMBER(A_COLOR));
+ return NULL;
+ }
+ return PyLong_FromLong(attr);
}
/*[clinic input]
static PyObject *
_curses_window_addch_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int group_right_1,
- long attr);
+ attr_t attr);
static PyObject *
_curses_window_addch(PyObject *self, PyObject *args)
int x = 0;
PyObject *ch;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 1:
}
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:addch", &ch, &attr)) {
+ if (!PyArg_ParseTuple(args, "OO&:addch", &ch, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 4:
- if (!PyArg_ParseTuple(args, "iiOl:addch", &y, &x, &ch, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOO&:addch", &y, &x, &ch, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int group_right_1,
- long attr);
+ attr_t attr);
static PyObject *
_curses_window_addstr(PyObject *self, PyObject *args)
int x = 0;
PyObject *str;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 1:
}
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:addstr", &str, &attr)) {
+ if (!PyArg_ParseTuple(args, "OO&:addstr", &str, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 4:
- if (!PyArg_ParseTuple(args, "iiOl:addstr", &y, &x, &str, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOO&:addstr", &y, &x, &str, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_addnstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int n,
- int group_right_1, long attr);
+ int group_right_1, attr_t attr);
static PyObject *
_curses_window_addnstr(PyObject *self, PyObject *args)
PyObject *str;
int n;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 2:
}
break;
case 3:
- if (!PyArg_ParseTuple(args, "Oil:addnstr", &str, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "OiO&:addnstr", &str, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 5:
- if (!PyArg_ParseTuple(args, "iiOil:addnstr", &y, &x, &str, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOiO&:addnstr", &y, &x, &str, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_bkgd_impl(PyCursesWindowObject *self, PyObject *ch,
- int group_right_1, long attr);
+ int group_right_1, attr_t attr);
static PyObject *
_curses_window_bkgd(PyObject *self, PyObject *args)
PyObject *return_value = NULL;
PyObject *ch;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 1:
}
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:bkgd", &ch, &attr)) {
+ if (!PyArg_ParseTuple(args, "OO&:bkgd", &ch, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
{"attroff", (PyCFunction)_curses_window_attroff, METH_O, _curses_window_attroff__doc__},
static PyObject *
-_curses_window_attroff_impl(PyCursesWindowObject *self, long attr);
+_curses_window_attroff_impl(PyCursesWindowObject *self, attr_t attr);
static PyObject *
_curses_window_attroff(PyObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
- long attr;
+ attr_t attr;
- attr = PyLong_AsLong(arg);
- if (attr == -1 && PyErr_Occurred()) {
+ if (!attr_converter(arg, &attr)) {
goto exit;
}
return_value = _curses_window_attroff_impl((PyCursesWindowObject *)self, attr);
{"attron", (PyCFunction)_curses_window_attron, METH_O, _curses_window_attron__doc__},
static PyObject *
-_curses_window_attron_impl(PyCursesWindowObject *self, long attr);
+_curses_window_attron_impl(PyCursesWindowObject *self, attr_t attr);
static PyObject *
_curses_window_attron(PyObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
- long attr;
+ attr_t attr;
- attr = PyLong_AsLong(arg);
- if (attr == -1 && PyErr_Occurred()) {
+ if (!attr_converter(arg, &attr)) {
goto exit;
}
return_value = _curses_window_attron_impl((PyCursesWindowObject *)self, attr);
{"attrset", (PyCFunction)_curses_window_attrset, METH_O, _curses_window_attrset__doc__},
static PyObject *
-_curses_window_attrset_impl(PyCursesWindowObject *self, long attr);
+_curses_window_attrset_impl(PyCursesWindowObject *self, attr_t attr);
static PyObject *
_curses_window_attrset(PyObject *self, PyObject *arg)
{
PyObject *return_value = NULL;
- long attr;
+ attr_t attr;
- attr = PyLong_AsLong(arg);
- if (attr == -1 && PyErr_Occurred()) {
+ if (!attr_converter(arg, &attr)) {
goto exit;
}
return_value = _curses_window_attrset_impl((PyCursesWindowObject *)self, attr);
static PyObject *
_curses_window_bkgdset_impl(PyCursesWindowObject *self, PyObject *ch,
- int group_right_1, long attr);
+ int group_right_1, attr_t attr);
static PyObject *
_curses_window_bkgdset(PyObject *self, PyObject *args)
PyObject *return_value = NULL;
PyObject *ch;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 1:
}
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:bkgdset", &ch, &attr)) {
+ if (!PyArg_ParseTuple(args, "OO&:bkgdset", &ch, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_echochar_impl(PyCursesWindowObject *self, PyObject *ch,
- int group_right_1, long attr);
+ int group_right_1, attr_t attr);
static PyObject *
_curses_window_echochar(PyObject *self, PyObject *args)
PyObject *return_value = NULL;
PyObject *ch;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 1:
}
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:echochar", &ch, &attr)) {
+ if (!PyArg_ParseTuple(args, "OO&:echochar", &ch, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_hline_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int n,
- int group_right_1, long attr);
+ int group_right_1, attr_t attr);
static PyObject *
_curses_window_hline(PyObject *self, PyObject *args)
PyObject *ch;
int n;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 2:
}
break;
case 3:
- if (!PyArg_ParseTuple(args, "Oil:hline", &ch, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "OiO&:hline", &ch, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 5:
- if (!PyArg_ParseTuple(args, "iiOil:hline", &y, &x, &ch, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOiO&:hline", &y, &x, &ch, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_insch_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int group_right_1,
- long attr);
+ attr_t attr);
static PyObject *
_curses_window_insch(PyObject *self, PyObject *args)
int x = 0;
PyObject *ch;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 1:
}
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:insch", &ch, &attr)) {
+ if (!PyArg_ParseTuple(args, "OO&:insch", &ch, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 4:
- if (!PyArg_ParseTuple(args, "iiOl:insch", &y, &x, &ch, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOO&:insch", &y, &x, &ch, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_insstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int group_right_1,
- long attr);
+ attr_t attr);
static PyObject *
_curses_window_insstr(PyObject *self, PyObject *args)
int x = 0;
PyObject *str;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 1:
}
break;
case 2:
- if (!PyArg_ParseTuple(args, "Ol:insstr", &str, &attr)) {
+ if (!PyArg_ParseTuple(args, "OO&:insstr", &str, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 4:
- if (!PyArg_ParseTuple(args, "iiOl:insstr", &y, &x, &str, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOO&:insstr", &y, &x, &str, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_insnstr_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *str, int n,
- int group_right_1, long attr);
+ int group_right_1, attr_t attr);
static PyObject *
_curses_window_insnstr(PyObject *self, PyObject *args)
PyObject *str;
int n;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 2:
}
break;
case 3:
- if (!PyArg_ParseTuple(args, "Oil:insnstr", &str, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "OiO&:insnstr", &str, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 5:
- if (!PyArg_ParseTuple(args, "iiOil:insnstr", &y, &x, &str, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOiO&:insnstr", &y, &x, &str, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
static PyObject *
_curses_window_vline_impl(PyCursesWindowObject *self, int group_left_1,
int y, int x, PyObject *ch, int n,
- int group_right_1, long attr);
+ int group_right_1, attr_t attr);
static PyObject *
_curses_window_vline(PyObject *self, PyObject *args)
PyObject *ch;
int n;
int group_right_1 = 0;
- long attr = 0;
+ attr_t attr = 0;
switch (PyTuple_GET_SIZE(args)) {
case 2:
}
break;
case 3:
- if (!PyArg_ParseTuple(args, "Oil:vline", &ch, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "OiO&:vline", &ch, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
group_left_1 = 1;
break;
case 5:
- if (!PyArg_ParseTuple(args, "iiOil:vline", &y, &x, &ch, &n, &attr)) {
+ if (!PyArg_ParseTuple(args, "iiOiO&:vline", &y, &x, &ch, &n, attr_converter, &attr)) {
goto exit;
}
group_right_1 = 1;
#ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=db4cb7f72e1dc166 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=01cb1ecb396881c9 input=a9049054013a1b77]*/