appearance of the screen.
+.. function:: term_attrs()
+
+ Like :func:`termattrs`, but return the attributes as :ref:`WA_*
+ <curses-wa-constants>` values rather than ``A_*`` values.
+
+ .. versionadded:: next
+
+
.. function:: termname()
Return the value of the environment variable :envvar:`TERM`, as a bytes object,
:func:`~curses.scr_set`, which dump the whole screen to a file and restore it.
(Contributed by Serhiy Storchaka in :gh:`152260`.)
+* Add the :func:`curses.term_attrs` function, which returns the supported
+ video attributes as :ref:`WA_* <curses-wa-constants>` values, the
+ counterpart of :func:`curses.termattrs`.
+ (Contributed by Serhiy Storchaka in :gh:`152332`.)
+
* Add the :mod:`curses` key-management functions :func:`~curses.define_key`,
:func:`~curses.key_defined` and :func:`~curses.keyok`, available when built
against an ncurses with ``NCURSES_EXT_FUNCS``.
curses.newpad(50, 50)
def test_env_queries(self):
- # TODO: term_attrs()
self.assertIsInstance(curses.termname(), bytes)
self.assertIsInstance(curses.longname(), bytes)
self.assertIsInstance(curses.baudrate(), int)
self.assertIsInstance(curses.has_ic(), bool)
self.assertIsInstance(curses.has_il(), bool)
self.assertIsInstance(curses.termattrs(), int)
+ self.assertIsInstance(curses.term_attrs(), int)
c = curses.killchar()
self.assertIsInstance(c, bytes)
--- /dev/null
+Add the :func:`curses.term_attrs` function, the counterpart of
+:func:`curses.termattrs` for the ``WA_*`` attributes.
/*[clinic end generated code: output=b06f437fce1b6fc4 input=0559882a04f84d1d]*/
NoArgReturnIntFunctionBody(termattrs)
+/*[clinic input]
+_curses.term_attrs
+
+Return a logical OR of all video attributes supported by the terminal.
+
+The attributes are WA_* values, the extended-attribute counterparts of
+the A_* values returned by termattrs().
+[clinic start generated code]*/
+
+static PyObject *
+_curses_term_attrs_impl(PyObject *module)
+/*[clinic end generated code: output=c559daa1370948d6 input=963136fd17ab797a]*/
+{
+ PyCursesStatefulInitialised(module);
+
+ return PyLong_FromUnsignedLong(term_attrs());
+}
+
/*[clinic input]
@permit_long_summary
_curses.termname
_CURSES_SETUPTERM_METHODDEF
_CURSES_START_COLOR_METHODDEF
_CURSES_TERMATTRS_METHODDEF
+ _CURSES_TERM_ATTRS_METHODDEF
_CURSES_TERMNAME_METHODDEF
_CURSES_TIGETFLAG_METHODDEF
_CURSES_TIGETNUM_METHODDEF
return _curses_termattrs_impl(module);
}
+PyDoc_STRVAR(_curses_term_attrs__doc__,
+"term_attrs($module, /)\n"
+"--\n"
+"\n"
+"Return a logical OR of all video attributes supported by the terminal.\n"
+"\n"
+"The attributes are WA_* values, the extended-attribute counterparts of\n"
+"the A_* values returned by termattrs().");
+
+#define _CURSES_TERM_ATTRS_METHODDEF \
+ {"term_attrs", (PyCFunction)_curses_term_attrs, METH_NOARGS, _curses_term_attrs__doc__},
+
+static PyObject *
+_curses_term_attrs_impl(PyObject *module);
+
+static PyObject *
+_curses_term_attrs(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return _curses_term_attrs_impl(module);
+}
+
PyDoc_STRVAR(_curses_termname__doc__,
"termname($module, /)\n"
"--\n"
#ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=01cb1ecb396881c9 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=976a6629bfe58a3d input=a9049054013a1b77]*/