determining what subset of the screen windows enclose the location of a mouse
event.
+ .. versionchanged:: 3.10
+ Previously it returned ``1`` or ``0`` instead of ``True`` or ``False``.
+
.. attribute:: window.encoding
@requires_curses_window_meth('enclose')
def test_enclose(self):
win = curses.newwin(5, 15, 2, 5)
- # TODO: Return bool instead of 1/0
- self.assertTrue(win.enclose(2, 5))
- self.assertFalse(win.enclose(1, 5))
- self.assertFalse(win.enclose(2, 4))
- self.assertTrue(win.enclose(6, 19))
- self.assertFalse(win.enclose(7, 19))
- self.assertFalse(win.enclose(6, 20))
+ self.assertIs(win.enclose(2, 5), True)
+ self.assertIs(win.enclose(1, 5), False)
+ self.assertIs(win.enclose(2, 4), False)
+ self.assertIs(win.enclose(6, 19), True)
+ self.assertIs(win.enclose(7, 19), False)
+ self.assertIs(win.enclose(6, 20), False)
def test_putwin(self):
win = curses.newwin(5, 12, 1, 2)
--- /dev/null
+:func:`curses.window.enclose` returns now ``True`` or ``False`` (as was
+documented) instead of ``1`` or ``0``.
#ifdef NCURSES_MOUSE_VERSION
/*[clinic input]
-_curses.window.enclose -> long
+_curses.window.enclose
y: int
Y-coordinate.
Return True if the screen-relative coordinates are enclosed by the window.
[clinic start generated code]*/
-static long
+static PyObject *
_curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x)
-/*[clinic end generated code: output=5251c961cbe3df63 input=dfe1d9d4d05d8642]*/
+/*[clinic end generated code: output=8679beef50502648 input=4fd3355d723f7bc9]*/
{
- return wenclose(self->win, y, x);
+ return PyBool_FromLong(wenclose(self->win, y, x));
}
#endif
#define _CURSES_WINDOW_ENCLOSE_METHODDEF \
{"enclose", (PyCFunction)(void(*)(void))_curses_window_enclose, METH_FASTCALL, _curses_window_enclose__doc__},
-static long
+static PyObject *
_curses_window_enclose_impl(PyCursesWindowObject *self, int y, int x);
static PyObject *
PyObject *return_value = NULL;
int y;
int x;
- long _return_value;
if (!_PyArg_CheckPositional("enclose", nargs, 2, 2)) {
goto exit;
if (x == -1 && PyErr_Occurred()) {
goto exit;
}
- _return_value = _curses_window_enclose_impl(self, y, x);
- if ((_return_value == -1) && PyErr_Occurred()) {
- goto exit;
- }
- return_value = PyLong_FromLong(_return_value);
+ return_value = _curses_window_enclose_impl(self, y, x);
exit:
return return_value;
#ifndef _CURSES_USE_DEFAULT_COLORS_METHODDEF
#define _CURSES_USE_DEFAULT_COLORS_METHODDEF
#endif /* !defined(_CURSES_USE_DEFAULT_COLORS_METHODDEF) */
-/*[clinic end generated code: output=ae6559aa61200289 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=9efc9943a3ac3741 input=a9049054013a1b77]*/