bpo-25720: Fix the method for checking pad state of curses WINDOW (GH… · python/cpython@6ba0b58
@@ -663,6 +663,12 @@ int py_mvwdelch(WINDOW *w, int y, int x)
663663}
664664#endif
665665666+#if defined(HAVE_CURSES_IS_PAD)
667+#define py_is_pad(win) is_pad(win)
668+#elif defined(WINDOW_HAS_FLAGS)
669+#define py_is_pad(win) ((win) ? ((win)->_flags & _ISPAD) != 0 : FALSE)
670+#endif
671+666672/* chgat, added by Fabian Kreutz <fabian.kreutz at gmx.net> */
667673668674static PyObject *
@@ -804,10 +810,11 @@ PyCursesWindow_EchoChar(PyCursesWindowObject *self, PyObject *args)
804810return NULL;
805811 }
806812807-#ifdef WINDOW_HAS_FLAGS
808-if (self->win->_flags & _ISPAD)
813+#ifdef py_is_pad
814+if (py_is_pad(self->win)) {
809815return PyCursesCheckERR(pechochar(self->win, ch | attr),
810816"echochar");
817+ }
811818else
812819#endif
813820return PyCursesCheckERR(wechochar(self->win, ch | attr),
@@ -1243,10 +1250,10 @@ PyCursesWindow_NoOutRefresh(PyCursesWindowObject *self, PyObject *args)
12431250int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
12441251int rtn;
124512521246-#ifndef WINDOW_HAS_FLAGS
1253+#ifndef py_is_pad
12471254if (0)
12481255#else
1249-if (self->win->_flags & _ISPAD)
1256+if (py_is_pad(self->win))
12501257#endif
12511258 {
12521259switch(PyTuple_Size(args)) {
@@ -1386,10 +1393,10 @@ PyCursesWindow_Refresh(PyCursesWindowObject *self, PyObject *args)
13861393int pminrow,pmincol,sminrow,smincol,smaxrow,smaxcol;
13871394int rtn;
138813951389-#ifndef WINDOW_HAS_FLAGS
1396+#ifndef py_is_pad
13901397if (0)
13911398#else
1392-if (self->win->_flags & _ISPAD)
1399+if (py_is_pad(self->win))
13931400#endif
13941401 {
13951402switch(PyTuple_Size(args)) {
@@ -1455,9 +1462,10 @@ PyCursesWindow_SubWin(PyCursesWindowObject *self, PyObject *args)
14551462 }
1456146314571464/* printf("Subwin: %i %i %i %i \n", nlines, ncols, begin_y, begin_x); */
1458-#ifdef WINDOW_HAS_FLAGS
1459-if (self->win->_flags & _ISPAD)
1465+#ifdef py_is_pad
1466+if (py_is_pad(self->win)) {
14601467win = subpad(self->win, nlines, ncols, begin_y, begin_x);
1468+ }
14611469else
14621470#endif
14631471win = subwin(self->win, nlines, ncols, begin_y, begin_x);