| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  *   Interface to the ncurses panel library | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Original version by Thomas Gellekum | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Release Number */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-25 19:53:18 +02:00
										 |  |  | static const char PyCursesVersion[] = "2.1"; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Includes */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Python.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "py_curses.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <panel.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  |     PyObject *PyCursesError; | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  |     PyObject *PyCursesPanel_Type; | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  | } _curses_panelstate; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define _curses_panelstate(o) ((_curses_panelstate *)PyModule_GetState(o))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | _curses_panel_clear(PyObject *m) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Py_CLEAR(_curses_panelstate(m)->PyCursesError); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | _curses_panel_traverse(PyObject *m, visitproc visit, void *arg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Py_VISIT(_curses_panelstate(m)->PyCursesError); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | _curses_panel_free(void *m) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     _curses_panel_clear((PyObject *) m); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct PyModuleDef _curses_panelmodule; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  | #define _curses_panelstate_global \
 | 
					
						
							|  |  |  | ((_curses_panelstate *) PyModule_GetState(PyState_FindModule(&_curses_panelmodule))) | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Utility Functions */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |  * Check the return code from a curses function and return None | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |  * or raise an exception as appropriate. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2015-12-25 20:01:53 +02:00
										 |  |  | PyCursesCheckERR(int code, const char *fname) | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     if (code != ERR) { | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |         Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         if (fname == NULL) { | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |             PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR); | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |             PyErr_Format(_curses_panelstate_global->PyCursesError, "%s() returned ERR", fname); | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*****************************************************************************
 | 
					
						
							|  |  |  |  The Panel Object | 
					
						
							|  |  |  | ******************************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Definition of the panel object and panel type */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |     PyObject_HEAD | 
					
						
							|  |  |  |     PANEL *pan; | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     PyCursesWindowObject *wo;   /* for reference counts */ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | } PyCursesPanelObject; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  | #define PyCursesPanel_Check(v)  \
 | 
					
						
							|  |  |  |  (Py_TYPE(v) == _curses_panelstate_global->PyCursesPanel_Type) | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Some helper functions. The problem is that there's always a window
 | 
					
						
							|  |  |  |    associated with a panel. To ensure that Python's GC doesn't pull | 
					
						
							|  |  |  |    this window from under our feet we need to keep track of references | 
					
						
							|  |  |  |    to the corresponding window object within Python. We can't use | 
					
						
							|  |  |  |    dupwin(oldwin) to keep a copy of the curses WINDOW because the | 
					
						
							|  |  |  |    contents of oldwin is copied only once; code like | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    win = newwin(...) | 
					
						
							|  |  |  |    pan = win.panel() | 
					
						
							|  |  |  |    win.addstr(some_string) | 
					
						
							|  |  |  |    pan.window().addstr(other_string) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    will fail. */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* We keep a linked list of PyCursesPanelObjects, lop. A list should
 | 
					
						
							|  |  |  |    suffice, I don't expect more than a handful or at most a few | 
					
						
							|  |  |  |    dozens of panel objects within a typical program. */ | 
					
						
							|  |  |  | typedef struct _list_of_panels { | 
					
						
							|  |  |  |     PyCursesPanelObject *po; | 
					
						
							|  |  |  |     struct _list_of_panels *next; | 
					
						
							|  |  |  | } list_of_panels; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* list anchor */ | 
					
						
							|  |  |  | static list_of_panels *lop; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Insert a new panel object into lop */ | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | insert_lop(PyCursesPanelObject *po) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     list_of_panels *new; | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-07 16:21:41 +02:00
										 |  |  |     if ((new = (list_of_panels *)PyMem_Malloc(sizeof(list_of_panels))) == NULL) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyErr_NoMemory(); | 
					
						
							|  |  |  |         return -1; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     new->po = po; | 
					
						
							|  |  |  |     new->next = lop; | 
					
						
							|  |  |  |     lop = new; | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Remove the panel object from lop */ | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | remove_lop(PyCursesPanelObject *po) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     list_of_panels *temp, *n; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     temp = lop; | 
					
						
							|  |  |  |     if (temp->po == po) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         lop = temp->next; | 
					
						
							| 
									
										
										
										
											2013-07-07 16:21:41 +02:00
										 |  |  |         PyMem_Free(temp); | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         return; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2006-03-07 13:38:14 +00:00
										 |  |  |     while (temp->next == NULL || temp->next->po != po) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         if (temp->next == NULL) { | 
					
						
							|  |  |  |             PyErr_SetString(PyExc_RuntimeError, | 
					
						
							|  |  |  |                             "remove_lop: can't find Panel Object"); | 
					
						
							|  |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         temp = temp->next; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     n = temp->next->next; | 
					
						
							| 
									
										
										
										
											2013-07-07 16:21:41 +02:00
										 |  |  |     PyMem_Free(temp->next); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     temp->next = n; | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Return the panel object that corresponds to pan */ | 
					
						
							|  |  |  | static PyCursesPanelObject * | 
					
						
							|  |  |  | find_po(PANEL *pan) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     list_of_panels *temp; | 
					
						
							|  |  |  |     for (temp = lop; temp->po->pan != pan; temp = temp->next) | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         if (temp->next == NULL) return NULL;    /* not found!? */ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     return temp->po; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | module _curses_panel | 
					
						
							|  |  |  | class _curses_panel.panel "PyCursesPanelObject *" "&PyCursesPanel_Type" | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | /*[clinic end generated code: output=da39a3ee5e6b4b0d input=2f4ef263ca850a31]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "clinic/_curses_panel.c.h"
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ------------- PANEL routines --------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.bottom | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Push the panel to the bottom of the stack. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | _curses_panel_panel_bottom_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=7aa7d14d7e1d1ce6 input=b6c920c071b61e2e]*/ | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return PyCursesCheckERR(bottom_panel(self->pan), "bottom"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.hide | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Hide the panel. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | This does not delete the object, it just makes the window on screen invisible. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | _curses_panel_panel_hide_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=a7bbbd523e1eab49 input=f6ab884e99386118]*/ | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return PyCursesCheckERR(hide_panel(self->pan), "hide"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.show | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Display the panel (which might have been hidden). | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | _curses_panel_panel_show_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=6b4553ab45c97769 input=57b167bbefaa3755]*/ | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return PyCursesCheckERR(show_panel(self->pan), "show"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.top | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Push panel to the top of the stack. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | _curses_panel_panel_top_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=0f5f2f8cdd2d1777 input=be33975ec3ca0e9a]*/ | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return PyCursesCheckERR(top_panel(self->pan), "top"); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Allocation and deallocation of Panel Objects */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     PyCursesPanelObject *po; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  |     po = PyObject_NEW(PyCursesPanelObject, | 
					
						
							|  |  |  |                       (PyTypeObject *)(_curses_panelstate_global)->PyCursesPanel_Type); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     if (po == NULL) return NULL; | 
					
						
							|  |  |  |     po->pan = pan; | 
					
						
							|  |  |  |     if (insert_lop(po) < 0) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         po->wo = NULL; | 
					
						
							|  |  |  |         Py_DECREF(po); | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2010-03-03 21:56:53 +00:00
										 |  |  |     po->wo = wo; | 
					
						
							|  |  |  |     Py_INCREF(wo); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     return (PyObject *)po; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | PyCursesPanel_Dealloc(PyCursesPanelObject *po) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-03-27 07:52:18 -04:00
										 |  |  |     PyObject *tp, *obj; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     tp = (PyObject *) Py_TYPE(po); | 
					
						
							|  |  |  |     obj = (PyObject *) panel_userptr(po->pan); | 
					
						
							| 
									
										
										
										
											2016-05-09 00:11:59 +03:00
										 |  |  |     if (obj) { | 
					
						
							|  |  |  |         (void)set_panel_userptr(po->pan, NULL); | 
					
						
							|  |  |  |         Py_DECREF(obj); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     (void)del_panel(po->pan); | 
					
						
							| 
									
										
										
										
											2010-03-03 21:56:53 +00:00
										 |  |  |     if (po->wo != NULL) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         Py_DECREF(po->wo); | 
					
						
							|  |  |  |         remove_lop(po); | 
					
						
							| 
									
										
										
										
											2010-03-03 21:56:53 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2002-01-30 15:47:34 +00:00
										 |  |  |     PyObject_DEL(po); | 
					
						
							| 
									
										
										
										
											2019-03-27 07:52:18 -04:00
										 |  |  |     Py_DECREF(tp); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* panel_above(NULL) returns the bottom panel in the stack. To get
 | 
					
						
							|  |  |  |    this behaviour we use curses.panel.bottom_panel(). */ | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.above | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return the panel above the current panel. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_panel_above_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=70ac06d25fd3b4da input=c059994022976788]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PANEL *pan; | 
					
						
							|  |  |  |     PyCursesPanelObject *po; | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     pan = panel_above(self->pan); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     if (pan == NULL) {          /* valid output, it means the calling panel
 | 
					
						
							|  |  |  |                                    is on top of the stack */ | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |         Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     po = find_po(pan); | 
					
						
							|  |  |  |     if (po == NULL) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyErr_SetString(PyExc_RuntimeError, | 
					
						
							|  |  |  |                         "panel_above: can't find Panel Object"); | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     Py_INCREF(po); | 
					
						
							|  |  |  |     return (PyObject *)po; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* panel_below(NULL) returns the top panel in the stack. To get
 | 
					
						
							| 
									
										
										
										
											2001-01-19 15:35:26 +00:00
										 |  |  |    this behaviour we use curses.panel.top_panel(). */ | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.below | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return the panel below the current panel. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_panel_below_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=282861122e06e3de input=cc08f61936d297c6]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PANEL *pan; | 
					
						
							|  |  |  |     PyCursesPanelObject *po; | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     pan = panel_below(self->pan); | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (pan == NULL) {          /* valid output, it means the calling panel
 | 
					
						
							|  |  |  |                                    is on the bottom of the stack */ | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |         Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     po = find_po(pan); | 
					
						
							|  |  |  |     if (po == NULL) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyErr_SetString(PyExc_RuntimeError, | 
					
						
							|  |  |  |                         "panel_below: can't find Panel Object"); | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     Py_INCREF(po); | 
					
						
							|  |  |  |     return (PyObject *)po; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.hidden | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return True if the panel is hidden (not visible), False otherwise. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_panel_hidden_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=66eebd1ab4501a71 input=453d4b4fce25e21a]*/ | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (panel_hidden(self->pan)) | 
					
						
							|  |  |  |         Py_RETURN_TRUE; | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |         Py_RETURN_FALSE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.move | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     y: int | 
					
						
							|  |  |  |     x: int | 
					
						
							|  |  |  |     / | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Move the panel to the screen coordinates (y, x). | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | _curses_panel_panel_move_impl(PyCursesPanelObject *self, int y, int x) | 
					
						
							|  |  |  | /*[clinic end generated code: output=d867535a89777415 input=e0b36b78acc03fba]*/ | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return PyCursesCheckERR(move_panel(self->pan, y, x), "move_panel"); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.window | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return the window object associated with the panel. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | _curses_panel_panel_window_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=5f05940d4106b4cb input=6067353d2c307901]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     Py_INCREF(self->wo); | 
					
						
							|  |  |  |     return (PyObject *)self->wo; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.replace | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     win: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") | 
					
						
							|  |  |  |     / | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Change the window associated with the panel to the window win. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_panel_replace_impl(PyCursesPanelObject *self, | 
					
						
							|  |  |  |                                  PyCursesWindowObject *win) | 
					
						
							|  |  |  | /*[clinic end generated code: output=2253a95f7b287255 input=4b1c4283987d9dfa]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PyCursesPanelObject *po; | 
					
						
							|  |  |  |     int rtn; | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     po = find_po(self->pan); | 
					
						
							|  |  |  |     if (po == NULL) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyErr_SetString(PyExc_RuntimeError, | 
					
						
							|  |  |  |                         "replace_panel: can't find Panel Object"); | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  |     rtn = replace_panel(self->pan, win->win); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     if (rtn == ERR) { | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |         PyErr_SetString(_curses_panelstate_global->PyCursesError, "replace_panel() returned ERR"); | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  |     Py_INCREF(win); | 
					
						
							|  |  |  |     Py_SETREF(po->wo, win); | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |     Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.set_userptr | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     obj: object | 
					
						
							|  |  |  |     / | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-25 07:18:48 +08:00
										 |  |  | Set the panel's user pointer to obj. | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_panel_set_userptr(PyCursesPanelObject *self, PyObject *obj) | 
					
						
							| 
									
										
										
										
											2019-02-25 07:18:48 +08:00
										 |  |  | /*[clinic end generated code: output=6fb145b3af88cf4a input=d2c6a9dbefabbf39]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-06-15 14:04:04 -04:00
										 |  |  |     PyObject *oldobj; | 
					
						
							| 
									
										
										
										
											2013-06-22 14:50:56 -04:00
										 |  |  |     int rc; | 
					
						
							| 
									
										
										
										
											2013-06-15 14:04:04 -04:00
										 |  |  |     PyCursesInitialised; | 
					
						
							| 
									
										
										
										
											2013-06-22 14:50:56 -04:00
										 |  |  |     Py_INCREF(obj); | 
					
						
							| 
									
										
										
										
											2013-06-15 14:04:04 -04:00
										 |  |  |     oldobj = (PyObject *) panel_userptr(self->pan); | 
					
						
							| 
									
										
										
										
											2013-06-22 14:50:56 -04:00
										 |  |  |     rc = set_panel_userptr(self->pan, (void*)obj); | 
					
						
							|  |  |  |     if (rc == ERR) { | 
					
						
							|  |  |  |         /* In case of an ncurses error, decref the new object again */ | 
					
						
							|  |  |  |         Py_DECREF(obj); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-06-15 14:04:04 -04:00
										 |  |  |     Py_XDECREF(oldobj); | 
					
						
							| 
									
										
										
										
											2013-06-22 14:50:56 -04:00
										 |  |  |     return PyCursesCheckERR(rc, "set_panel_userptr"); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.panel.userptr | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return the user pointer for the panel. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-17 23:08:27 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_panel_userptr_impl(PyCursesPanelObject *self) | 
					
						
							|  |  |  | /*[clinic end generated code: output=e849c307b5dc9237 input=f78b7a47aef0fd50]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *obj; | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     PyCursesInitialised; | 
					
						
							| 
									
										
										
										
											2000-12-23 05:46:23 +00:00
										 |  |  |     obj = (PyObject *) panel_userptr(self->pan); | 
					
						
							| 
									
										
										
										
											2006-01-09 06:24:35 +00:00
										 |  |  |     if (obj == NULL) { | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |         PyErr_SetString(_curses_panelstate_global->PyCursesError, "no userptr set"); | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2006-01-09 06:24:35 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     Py_INCREF(obj); | 
					
						
							|  |  |  |     return obj; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Module interface */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef PyCursesPanel_Methods[] = { | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  |     _CURSES_PANEL_PANEL_ABOVE_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_BELOW_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_BOTTOM_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_HIDDEN_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_HIDE_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_MOVE_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_REPLACE_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_SET_USERPTR_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_SHOW_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_TOP_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_USERPTR_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_PANEL_WINDOW_METHODDEF | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     {NULL,              NULL}   /* sentinel */ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  | static PyType_Slot PyCursesPanel_Type_slots[] = { | 
					
						
							|  |  |  |     {Py_tp_dealloc, PyCursesPanel_Dealloc}, | 
					
						
							|  |  |  |     {Py_tp_methods, PyCursesPanel_Methods}, | 
					
						
							|  |  |  |     {0, 0}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyType_Spec PyCursesPanel_Type_spec = { | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  |     "_curses_panel.panel", | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  |     sizeof(PyCursesPanelObject), | 
					
						
							|  |  |  |     0, | 
					
						
							|  |  |  |     Py_TPFLAGS_DEFAULT, | 
					
						
							|  |  |  |     PyCursesPanel_Type_slots | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Wrapper for panel_above(NULL). This function returns the bottom
 | 
					
						
							|  |  |  |    panel of the stack, so it's renamed to bottom_panel(). | 
					
						
							|  |  |  |    panel.above() *requires* a panel object in the first place which | 
					
						
							|  |  |  |    may be undesirable. */ | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.bottom_panel | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return the bottom panel in the panel stack. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_bottom_panel_impl(PyObject *module) | 
					
						
							|  |  |  | /*[clinic end generated code: output=3aba9f985f4c2bd0 input=634c2a8078b3d7e4]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PANEL *pan; | 
					
						
							|  |  |  |     PyCursesPanelObject *po; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     PyCursesInitialised; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pan = panel_above(NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     if (pan == NULL) {          /* valid output, it means
 | 
					
						
							|  |  |  |                                    there's no panel at all */ | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |         Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     po = find_po(pan); | 
					
						
							|  |  |  |     if (po == NULL) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyErr_SetString(PyExc_RuntimeError, | 
					
						
							|  |  |  |                         "panel_above: can't find Panel Object"); | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     Py_INCREF(po); | 
					
						
							|  |  |  |     return (PyObject *)po; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.new_panel | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     win: object(type="PyCursesWindowObject *", subclass_of="&PyCursesWindow_Type") | 
					
						
							|  |  |  |     / | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return a panel object, associating it with the given window win. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_new_panel_impl(PyObject *module, PyCursesWindowObject *win) | 
					
						
							|  |  |  | /*[clinic end generated code: output=45e948e0176a9bd2 input=74d4754e0ebe4800]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  |     PANEL *pan = new_panel(win->win); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     if (pan == NULL) { | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |         PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_NULL); | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     return (PyObject *)PyCursesPanel_New(pan, win); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Wrapper for panel_below(NULL). This function returns the top panel
 | 
					
						
							|  |  |  |    of the stack, so it's renamed to top_panel(). panel.below() | 
					
						
							|  |  |  |    *requires* a panel object in the first place which may be | 
					
						
							|  |  |  |    undesirable. */ | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.top_panel | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return the top panel in the panel stack. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | _curses_panel_top_panel_impl(PyObject *module) | 
					
						
							|  |  |  | /*[clinic end generated code: output=86704988bea8508e input=e62d6278dba39e79]*/ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PANEL *pan; | 
					
						
							|  |  |  |     PyCursesPanelObject *po; | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     PyCursesInitialised; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     pan = panel_below(NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     if (pan == NULL) {          /* valid output, it means
 | 
					
						
							|  |  |  |                                    there's no panel at all */ | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |         Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     po = find_po(pan); | 
					
						
							|  |  |  |     if (po == NULL) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyErr_SetString(PyExc_RuntimeError, | 
					
						
							|  |  |  |                         "panel_below: can't find Panel Object"); | 
					
						
							|  |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     } | 
					
						
							|  |  |  |     Py_INCREF(po); | 
					
						
							|  |  |  |     return (PyObject *)po; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _curses_panel.update_panels | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Updates the virtual screen after changes in the panel stack. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-25 07:18:48 +08:00
										 |  |  | This does not call curses.doupdate(), so you'll have to do this yourself. | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | _curses_panel_update_panels_impl(PyObject *module) | 
					
						
							| 
									
										
										
										
											2019-02-25 07:18:48 +08:00
										 |  |  | /*[clinic end generated code: output=2f3b4c2e03d90ded input=5299624c9a708621]*/ | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     PyCursesInitialised; | 
					
						
							|  |  |  |     update_panels(); | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |     Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* List of functions defined in the module */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef PyCurses_methods[] = { | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  |     _CURSES_PANEL_BOTTOM_PANEL_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_NEW_PANEL_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_TOP_PANEL_METHODDEF | 
					
						
							|  |  |  |     _CURSES_PANEL_UPDATE_PANELS_METHODDEF | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     {NULL,              NULL}           /* sentinel */ | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Initialization function for the module */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static struct PyModuleDef _curses_panelmodule = { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyModuleDef_HEAD_INIT, | 
					
						
							|  |  |  |         "_curses_panel", | 
					
						
							|  |  |  |         NULL, | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |         sizeof(_curses_panelstate), | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyCurses_methods, | 
					
						
							|  |  |  |         NULL, | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |         _curses_panel_traverse, | 
					
						
							|  |  |  |         _curses_panel_clear, | 
					
						
							|  |  |  |         _curses_panel_free | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-08-02 02:27:13 +00:00
										 |  |  | PyMODINIT_FUNC | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  | PyInit__curses_panel(void) | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     PyObject *m, *d, *v; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Create the module and add the functions */ | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  |     m = PyModule_Create(&_curses_panelmodule); | 
					
						
							| 
									
										
										
										
											2006-01-19 06:09:39 +00:00
										 |  |  |     if (m == NULL) | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  |         goto fail; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     d = PyModule_GetDict(m); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  |     /* Initialize object type */ | 
					
						
							| 
									
										
										
										
											2016-05-08 20:46:22 +03:00
										 |  |  |     v = PyType_FromSpec(&PyCursesPanel_Type_spec); | 
					
						
							|  |  |  |     if (v == NULL) | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  |         goto fail; | 
					
						
							| 
									
										
										
										
											2016-05-08 20:46:22 +03:00
										 |  |  |     ((PyTypeObject *)v)->tp_new = NULL; | 
					
						
							|  |  |  |     _curses_panelstate(m)->PyCursesPanel_Type = v; | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     import_curses(); | 
					
						
							| 
									
										
										
										
											2013-07-18 02:31:21 +02:00
										 |  |  |     if (PyErr_Occurred()) | 
					
						
							|  |  |  |         goto fail; | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     /* For exception _curses_panel.error */ | 
					
						
							| 
									
										
										
										
											2012-06-14 16:00:24 +02:00
										 |  |  |     _curses_panelstate(m)->PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); | 
					
						
							|  |  |  |     PyDict_SetItemString(d, "error", _curses_panelstate(m)->PyCursesError); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* Make the version available */ | 
					
						
							| 
									
										
										
										
											2007-08-23 21:42:55 +00:00
										 |  |  |     v = PyUnicode_FromString(PyCursesVersion); | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  |     PyDict_SetItemString(d, "version", v); | 
					
						
							|  |  |  |     PyDict_SetItemString(d, "__version__", v); | 
					
						
							|  |  |  |     Py_DECREF(v); | 
					
						
							| 
									
										
										
										
											2018-05-10 11:27:23 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Py_INCREF(_curses_panelstate(m)->PyCursesPanel_Type); | 
					
						
							|  |  |  |     PyModule_AddObject(m, "panel", (PyObject *)_curses_panelstate(m)->PyCursesPanel_Type); | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  |     return m; | 
					
						
							| 
									
										
										
										
											2012-06-14 16:01:23 +02:00
										 |  |  |   fail: | 
					
						
							|  |  |  |     Py_XDECREF(m); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							| 
									
										
										
										
											2000-12-22 21:54:12 +00:00
										 |  |  | } |