Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,26 @@ Terminfo database

:func:`setupterm` (or :func:`initscr`) must be called first.

.. function:: tgetent(term)
.. function:: tgetflag(id)
.. function:: tgetnum(id)
.. function:: tgetstr(id)
.. function:: tgoto(capability, col, row)

Access the terminal's legacy termcap entries. Call :func:`setupterm` first.
``tgetent`` returns ``0`` or ``1``; the other lookup functions return their
termcap value, or ``None`` when no value is available. *capability* must be
a bytes object returned by :func:`tgetstr`.

.. function:: mcprint(string, count)

Send *count* copies of *string* to the terminal printer.

.. function:: vidattr(attrs)
.. function:: vidputs(attrs)

Set the terminal video attributes represented by *attrs*.


Utilities
~~~~~~~~~
Expand Down
29 changes: 29 additions & 0 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,35 @@ def test_misc_module_funcs(self):

curses.newpad(50, 50)

@requires_curses_func('mcprint')
def test_mcprint(self):
try:
result = curses.mcprint('x', 1)
except curses.error:
pass
else:
self.assertIsNone(result)

@requires_curses_func('tgetent')
def test_termcap_functions(self):
self.assertIn(curses.tgetent(os.environ.get('TERM', 'unknown')), (0, 1))
self.assertIsInstance(curses.tgetflag('am'), int)
self.assertIsInstance(curses.tgetnum('co'), int)
value = curses.tgetstr('cl')
if value is None:
self.assertIsNone(value)
else:
self.assertIsInstance(value, bytes)
self.assertIsInstance(curses.tgoto(value, 0, 0), bytes)

@requires_curses_func('vidattr')
def test_video_attributes(self):
for function in curses.vidattr, curses.vidputs:
try:
self.assertIsNone(function(curses.A_NORMAL))
except curses.error:
pass

def test_env_queries(self):
self.assertIsInstance(curses.termname(), bytes)
self.assertIsInstance(curses.longname(), bytes)
Expand Down
Loading
Loading