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
Improved modules
================
+curses
+------
+
+* Add :func:`curses.nofilter`, which undoes the effect of :func:`curses.filter`.
+ (Contributed by Serhiy Storchaka in :gh:`151744`.)
+
gzip
----
@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):
--- /dev/null
+Add :func:`curses.nofilter`, which undoes the effect of :func:`curses.filter`.
}
#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
_CURSES_ENDWIN_METHODDEF
_CURSES_ERASECHAR_METHODDEF
_CURSES_FILTER_METHODDEF
+ _CURSES_NOFILTER_METHODDEF
_CURSES_FLASH_METHODDEF
_CURSES_FLUSHINP_METHODDEF
_CURSES_GETMOUSE_METHODDEF
#endif /* defined(HAVE_CURSES_FILTER) */
+#if defined(HAVE_CURSES_NOFILTER)
+
+PyDoc_STRVAR(_curses_nofilter__doc__,
+"nofilter($module, /)\n"
+"--\n"
+"\n"
+"Undo the effect of a preceding filter() call.\n"
+"\n"
+"Must be called before initscr(). It restores the normal behaviour\n"
+"disabled by filter(), so that the next initscr() uses the full screen\n"
+"rather than a single line.");
+
+#define _CURSES_NOFILTER_METHODDEF \
+ {"nofilter", (PyCFunction)_curses_nofilter, METH_NOARGS, _curses_nofilter__doc__},
+
+static PyObject *
+_curses_nofilter_impl(PyObject *module);
+
+static PyObject *
+_curses_nofilter(PyObject *module, PyObject *Py_UNUSED(ignored))
+{
+ return _curses_nofilter_impl(module);
+}
+
+#endif /* defined(HAVE_CURSES_NOFILTER) */
+
PyDoc_STRVAR(_curses_baudrate__doc__,
"baudrate($module, /)\n"
"--\n"
#define _CURSES_FILTER_METHODDEF
#endif /* !defined(_CURSES_FILTER_METHODDEF) */
+#ifndef _CURSES_NOFILTER_METHODDEF
+ #define _CURSES_NOFILTER_METHODDEF
+#endif /* !defined(_CURSES_NOFILTER_METHODDEF) */
+
#ifndef _CURSES_GETSYX_METHODDEF
#define _CURSES_GETSYX_METHODDEF
#endif /* !defined(_CURSES_GETSYX_METHODDEF) */
#ifndef _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#define _CURSES_ASSUME_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_ASSUME_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=11ab7c93cbc13e75 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=7494804bf2c4d1f5 input=a9049054013a1b77]*/
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function nofilter" >&5
+printf %s "checking for curses function nofilter... " >&6; }
+if test ${ac_cv_lib_curses_nofilter+y}
+then :
+ printf %s "(cached) " >&6
+else case e in #(
+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#define NCURSES_OPAQUE 0
+#if defined(HAVE_NCURSESW_NCURSES_H)
+# include <ncursesw/ncurses.h>
+#elif defined(HAVE_NCURSESW_CURSES_H)
+# include <ncursesw/curses.h>
+#elif defined(HAVE_NCURSES_NCURSES_H)
+# include <ncurses/ncurses.h>
+#elif defined(HAVE_NCURSES_CURSES_H)
+# include <ncurses/curses.h>
+#elif defined(HAVE_NCURSES_H)
+# include <ncurses.h>
+#elif defined(HAVE_CURSES_H)
+# include <curses.h>
+#endif
+
+int
+main (void)
+{
+
+ #ifndef nofilter
+ void *x=nofilter
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+ ac_cv_lib_curses_nofilter=yes
+else case e in #(
+ e) ac_cv_lib_curses_nofilter=no ;;
+esac
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+ ;;
+esac
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_curses_nofilter" >&5
+printf "%s\n" "$ac_cv_lib_curses_nofilter" >&6; }
+ if test "x$ac_cv_lib_curses_nofilter" = xyes
+then :
+
+printf "%s\n" "#define HAVE_CURSES_NOFILTER 1" >>confdefs.h
+
+fi
+
+
+
+
+
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for curses function has_key" >&5
printf %s "checking for curses function has_key... " >&6; }
if test ${ac_cv_lib_curses_has_key+y}
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])
/* 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