Skip to content
Merged
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
11 changes: 11 additions & 0 deletions Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ The module :mod:`!curses` defines the following functions:
character-at-a-time line editing without touching the rest of the screen.


.. function:: nofilter()

Undo the effect of a previous :func:`.filter` call.
Like :func:`.filter`, it must be called before :func:`initscr` so that the
next initialization uses the full screen again.

Availability: if the underlying curses library provides ``nofilter()``.

.. versionadded:: next


.. function:: flash()

Flash the screen. That is, change it to reverse-video and then change it back
Expand Down
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.16.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ New modules
Improved modules
================

curses
------

* Add :func:`curses.nofilter`, which undoes the effect of :func:`curses.filter`.
(Contributed by Serhiy Storchaka in :gh:`151744`.)

gzip
----

Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ def setUp(self):
@requires_curses_func('filter')
def test_filter(self):
# TODO: Should be called before initscr() or newterm() are called.
# TODO: nofilter()
curses.filter()
if hasattr(curses, 'nofilter'):
curses.nofilter()

@requires_curses_func('use_env')
def test_use_env(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add :func:`curses.nofilter`, which undoes the effect of :func:`curses.filter`.
23 changes: 23 additions & 0 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3220,6 +3220,28 @@ _curses_filter_impl(PyObject *module)
}
#endif

#ifdef HAVE_CURSES_NOFILTER
/*[clinic input]
_curses.nofilter
Undo the effect of a preceding filter() call.
Must be called before initscr(). It restores the normal behaviour
disabled by filter(), so that the next initscr() uses the full screen
rather than a single line.
[clinic start generated code]*/

static PyObject *
_curses_nofilter_impl(PyObject *module)
/*[clinic end generated code: output=d95ca4d48a6bdbdf input=58aea83b1a5c969f]*/
{
/* not checking for PyCursesInitialised here since nofilter() must
be called before initscr() */
nofilter();
Py_RETURN_NONE;
}
#endif

/*[clinic input]
_curses.baudrate
Expand Down Expand Up @@ -5321,6 +5343,7 @@ static PyMethodDef cursesmodule_methods[] = {
_CURSES_ENDWIN_METHODDEF
_CURSES_ERASECHAR_METHODDEF
_CURSES_FILTER_METHODDEF
_CURSES_NOFILTER_METHODDEF
_CURSES_FLASH_METHODDEF
_CURSES_FLUSHINP_METHODDEF
_CURSES_GETMOUSE_METHODDEF
Expand Down
32 changes: 31 additions & 1 deletion Modules/clinic/_cursesmodule.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7192,6 +7192,7 @@ PY_CHECK_CURSES_FUNC([immedok])
PY_CHECK_CURSES_FUNC([syncok])
PY_CHECK_CURSES_FUNC([wchgat])
PY_CHECK_CURSES_FUNC([filter])
PY_CHECK_CURSES_FUNC([nofilter])
PY_CHECK_CURSES_FUNC([has_key])
PY_CHECK_CURSES_FUNC([typeahead])
PY_CHECK_CURSES_FUNC([use_env])
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@
/* Define if you have the 'is_term_resized' function. */
#undef HAVE_CURSES_IS_TERM_RESIZED

/* Define if you have the 'nofilter' function. */
#undef HAVE_CURSES_NOFILTER

/* Define if you have the 'resizeterm' function. */
#undef HAVE_CURSES_RESIZETERM

Expand Down
Loading