Mercurial > cpython-lru_cache-weakref
annotate Modules/_curses_panel.c @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | fd25030223b0 |
| children | aff0bdab358e |
| rev | line source |
|---|---|
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
1 /* |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
2 * Interface to the ncurses panel library |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
3 * |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
4 * Original version by Thomas Gellekum |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
5 */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
6 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
7 /* Release Number */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
8 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
9 static char *PyCursesVersion = "2.1"; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
10 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
11 /* Includes */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
12 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
13 #include "Python.h" |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
14 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
15 #include "py_curses.h" |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
16 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
17 #include <panel.h> |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
18 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
19 static PyObject *PyCursesError; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
20 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
21 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
22 /* Utility Functions */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
23 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
24 /* |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
25 * Check the return code from a curses function and return None |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
26 * or raise an exception as appropriate. |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
27 */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
28 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
29 static PyObject * |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
30 PyCursesCheckERR(int code, char *fname) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
31 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
32 if (code != ERR) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
33 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
34 return Py_None; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
35 } else { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
36 if (fname == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
37 PyErr_SetString(PyCursesError, catchall_ERR); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
38 } else { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
39 PyErr_Format(PyCursesError, "%s() returned ERR", fname); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
40 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
41 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
42 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
43 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
44 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
45 /***************************************************************************** |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
46 The Panel Object |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
47 ******************************************************************************/ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
48 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
49 /* Definition of the panel object and panel type */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
50 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
51 typedef struct { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
52 PyObject_HEAD |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
53 PANEL *pan; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
54 PyCursesWindowObject *wo; /* for reference counts */ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
55 } PyCursesPanelObject; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
56 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
57 PyTypeObject PyCursesPanel_Type; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
58 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
59 #define PyCursesPanel_Check(v) (Py_TYPE(v) == &PyCursesPanel_Type) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
60 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
61 /* Some helper functions. The problem is that there's always a window |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
62 associated with a panel. To ensure that Python's GC doesn't pull |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
63 this window from under our feet we need to keep track of references |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
64 to the corresponding window object within Python. We can't use |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
65 dupwin(oldwin) to keep a copy of the curses WINDOW because the |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
66 contents of oldwin is copied only once; code like |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
67 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
68 win = newwin(...) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
69 pan = win.panel() |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
70 win.addstr(some_string) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
71 pan.window().addstr(other_string) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
72 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
73 will fail. */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
74 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
75 /* We keep a linked list of PyCursesPanelObjects, lop. A list should |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
76 suffice, I don't expect more than a handful or at most a few |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
77 dozens of panel objects within a typical program. */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
78 typedef struct _list_of_panels { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
79 PyCursesPanelObject *po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
80 struct _list_of_panels *next; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
81 } list_of_panels; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
82 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
83 /* list anchor */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
84 static list_of_panels *lop; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
85 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
86 /* Insert a new panel object into lop */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
87 static int |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
88 insert_lop(PyCursesPanelObject *po) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
89 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
90 list_of_panels *new; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
91 |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
92 if ((new = (list_of_panels *)malloc(sizeof(list_of_panels))) == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
93 PyErr_NoMemory(); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
94 return -1; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
95 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
96 new->po = po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
97 new->next = lop; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
98 lop = new; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
99 return 0; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
100 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
101 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
102 /* Remove the panel object from lop */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
103 static void |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
104 remove_lop(PyCursesPanelObject *po) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
105 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
106 list_of_panels *temp, *n; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
107 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
108 temp = lop; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
109 if (temp->po == po) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
110 lop = temp->next; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
111 free(temp); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
112 return; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
113 } |
|
36868
e62767e64de8
Coverity-found bug: don't use temp->next *before* checking it for NULL. Also
Thomas Wouters <thomas@python.org>
parents:
36324
diff
changeset
|
114 while (temp->next == NULL || temp->next->po != po) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
115 if (temp->next == NULL) { |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
116 PyErr_SetString(PyExc_RuntimeError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
117 "remove_lop: can't find Panel Object"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
118 return; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
119 } |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
120 temp = temp->next; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
121 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
122 n = temp->next->next; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
123 free(temp->next); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
124 temp->next = n; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
125 return; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
126 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
127 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
128 /* Return the panel object that corresponds to pan */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
129 static PyCursesPanelObject * |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
130 find_po(PANEL *pan) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
131 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
132 list_of_panels *temp; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
133 for (temp = lop; temp->po->pan != pan; temp = temp->next) |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
134 if (temp->next == NULL) return NULL; /* not found!? */ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
135 return temp->po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
136 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
137 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
138 /* Function Prototype Macros - They are ugly but very, very useful. ;-) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
139 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
140 X - function name |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
141 TYPE - parameter Type |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
142 ERGSTR - format string for construction of the return value |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
143 PARSESTR - format string for argument parsing */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
144 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
145 #define Panel_NoArgNoReturnFunction(X) \ |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
146 static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
147 { return PyCursesCheckERR(X(self->pan), # X); } |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
148 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
149 #define Panel_NoArgTrueFalseFunction(X) \ |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
150 static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
151 { \ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
152 if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
153 else { Py_INCREF(Py_True); return Py_True; } } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
154 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
155 #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ |
|
15653
82bec388c636
Shortened / wrapped some long lines.
Fred Drake <fdrake@acm.org>
parents:
15651
diff
changeset
|
156 static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
157 { \ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
158 TYPE arg1, arg2; \ |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
159 if (!PyArg_ParseTuple(args, PARSESTR, &arg1, &arg2)) return NULL; \ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
160 return PyCursesCheckERR(X(self->pan, arg1, arg2), # X); } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
161 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
162 /* ------------- PANEL routines --------------- */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
163 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
164 Panel_NoArgNoReturnFunction(bottom_panel) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
165 Panel_NoArgNoReturnFunction(hide_panel) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
166 Panel_NoArgNoReturnFunction(show_panel) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
167 Panel_NoArgNoReturnFunction(top_panel) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
168 Panel_NoArgTrueFalseFunction(panel_hidden) |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
169 Panel_TwoArgNoReturnFunction(move_panel, int, "ii;y,x") |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
170 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
171 /* Allocation and deallocation of Panel Objects */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
172 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
173 static PyObject * |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
174 PyCursesPanel_New(PANEL *pan, PyCursesWindowObject *wo) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
175 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
176 PyCursesPanelObject *po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
177 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
178 po = PyObject_NEW(PyCursesPanelObject, &PyCursesPanel_Type); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
179 if (po == NULL) return NULL; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
180 po->pan = pan; |
|
59312
8678534242a0
Issue #3299: fix curses.panel.new_panel() error handler, replace PyObject_DEL()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
47527
diff
changeset
|
181 if (insert_lop(po) < 0) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
182 po->wo = NULL; |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
183 Py_DECREF(po); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
184 return NULL; |
|
59312
8678534242a0
Issue #3299: fix curses.panel.new_panel() error handler, replace PyObject_DEL()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
47527
diff
changeset
|
185 } |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
186 po->wo = wo; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
187 Py_INCREF(wo); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
188 return (PyObject *)po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
189 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
190 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
191 static void |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
192 PyCursesPanel_Dealloc(PyCursesPanelObject *po) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
193 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
194 (void)del_panel(po->pan); |
|
59312
8678534242a0
Issue #3299: fix curses.panel.new_panel() error handler, replace PyObject_DEL()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
47527
diff
changeset
|
195 if (po->wo != NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
196 Py_DECREF(po->wo); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
197 remove_lop(po); |
|
59312
8678534242a0
Issue #3299: fix curses.panel.new_panel() error handler, replace PyObject_DEL()
Victor Stinner <victor.stinner@haypocalc.com>
parents:
47527
diff
changeset
|
198 } |
| 21846 | 199 PyObject_DEL(po); |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
200 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
201 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
202 /* panel_above(NULL) returns the bottom panel in the stack. To get |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
203 this behaviour we use curses.panel.bottom_panel(). */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
204 static PyObject * |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
205 PyCursesPanel_above(PyCursesPanelObject *self) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
206 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
207 PANEL *pan; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
208 PyCursesPanelObject *po; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
209 |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
210 pan = panel_above(self->pan); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
211 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
212 if (pan == NULL) { /* valid output, it means the calling panel |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
213 is on top of the stack */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
214 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
215 return Py_None; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
216 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
217 po = find_po(pan); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
218 if (po == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
219 PyErr_SetString(PyExc_RuntimeError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
220 "panel_above: can't find Panel Object"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
221 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
222 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
223 Py_INCREF(po); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
224 return (PyObject *)po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
225 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
226 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
227 /* panel_below(NULL) returns the top panel in the stack. To get |
|
16034
19eee2db2b16
Minor patch from Thomas Gellekum:
Andrew M. Kuchling <amk@amk.ca>
parents:
15653
diff
changeset
|
228 this behaviour we use curses.panel.top_panel(). */ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
229 static PyObject * |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
230 PyCursesPanel_below(PyCursesPanelObject *self) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
231 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
232 PANEL *pan; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
233 PyCursesPanelObject *po; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
234 |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
235 pan = panel_below(self->pan); |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
236 |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
237 if (pan == NULL) { /* valid output, it means the calling panel |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
238 is on the bottom of the stack */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
239 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
240 return Py_None; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
241 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
242 po = find_po(pan); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
243 if (po == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
244 PyErr_SetString(PyExc_RuntimeError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
245 "panel_below: can't find Panel Object"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
246 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
247 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
248 Py_INCREF(po); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
249 return (PyObject *)po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
250 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
251 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
252 static PyObject * |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
253 PyCursesPanel_window(PyCursesPanelObject *self) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
254 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
255 Py_INCREF(self->wo); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
256 return (PyObject *)self->wo; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
257 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
258 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
259 static PyObject * |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
260 PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
261 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
262 PyCursesPanelObject *po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
263 PyCursesWindowObject *temp; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
264 int rtn; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
265 |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
266 if (PyTuple_Size(args) != 1) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
267 PyErr_SetString(PyExc_TypeError, "replace requires one argument"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
268 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
269 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
270 if (!PyArg_ParseTuple(args, "O!;window object", |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
271 &PyCursesWindow_Type, &temp)) |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
272 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
273 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
274 po = find_po(self->pan); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
275 if (po == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
276 PyErr_SetString(PyExc_RuntimeError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
277 "replace_panel: can't find Panel Object"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
278 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
279 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
280 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
281 rtn = replace_panel(self->pan, temp->win); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
282 if (rtn == ERR) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
283 PyErr_SetString(PyCursesError, "replace_panel() returned ERR"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
284 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
285 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
286 Py_DECREF(po->wo); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
287 po->wo = temp; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
288 Py_INCREF(po->wo); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
289 Py_INCREF(Py_None); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
290 return Py_None; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
291 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
292 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
293 static PyObject * |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
294 PyCursesPanel_set_panel_userptr(PyCursesPanelObject *self, PyObject *obj) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
295 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
296 Py_INCREF(obj); |
|
20411
4dab61f48458
Cast argument to set_panel_userptr to void*. Fixes bug #417240.
Martin v. Löwis <martin@v.loewis.de>
parents:
16306
diff
changeset
|
297 return PyCursesCheckERR(set_panel_userptr(self->pan, (void*)obj), |
|
15653
82bec388c636
Shortened / wrapped some long lines.
Fred Drake <fdrake@acm.org>
parents:
15651
diff
changeset
|
298 "set_panel_userptr"); |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
299 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
300 |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
301 static PyObject * |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
302 PyCursesPanel_userptr(PyCursesPanelObject *self) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
303 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
304 PyObject *obj; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
305 PyCursesInitialised; |
|
15653
82bec388c636
Shortened / wrapped some long lines.
Fred Drake <fdrake@acm.org>
parents:
15651
diff
changeset
|
306 obj = (PyObject *) panel_userptr(self->pan); |
|
36251
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
24471
diff
changeset
|
307 if (obj == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
308 PyErr_SetString(PyCursesError, "no userptr set"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
309 return NULL; |
|
36251
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
24471
diff
changeset
|
310 } |
|
8df194294c90
Bug #1400115, Fix segfault when calling curses.panel.userptr()
Neal Norwitz <nnorwitz@gmail.com>
parents:
24471
diff
changeset
|
311 |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
312 Py_INCREF(obj); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
313 return obj; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
314 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
315 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
316 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
317 /* Module interface */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
318 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
319 static PyMethodDef PyCursesPanel_Methods[] = { |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
320 {"above", (PyCFunction)PyCursesPanel_above, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
321 {"below", (PyCFunction)PyCursesPanel_below, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
322 {"bottom", (PyCFunction)PyCursesPanel_bottom_panel, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
323 {"hidden", (PyCFunction)PyCursesPanel_panel_hidden, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
324 {"hide", (PyCFunction)PyCursesPanel_hide_panel, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
325 {"move", (PyCFunction)PyCursesPanel_move_panel, METH_VARARGS}, |
| 22707 | 326 {"replace", (PyCFunction)PyCursesPanel_replace_panel, METH_VARARGS}, |
|
21756
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
327 {"set_userptr", (PyCFunction)PyCursesPanel_set_panel_userptr, METH_O}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
328 {"show", (PyCFunction)PyCursesPanel_show_panel, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
329 {"top", (PyCFunction)PyCursesPanel_top_panel, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
330 {"userptr", (PyCFunction)PyCursesPanel_userptr, METH_NOARGS}, |
|
d60350d71b60
Patch #477752: Drop old-style getargs from curses.
Martin v. Löwis <martin@v.loewis.de>
parents:
21313
diff
changeset
|
331 {"window", (PyCFunction)PyCursesPanel_window, METH_NOARGS}, |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
332 {NULL, NULL} /* sentinel */ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
333 }; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
334 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
335 static PyObject * |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
336 PyCursesPanel_GetAttr(PyCursesPanelObject *self, char *name) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
337 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
338 return Py_FindMethod(PyCursesPanel_Methods, (PyObject *)self, name); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
339 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
340 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
341 /* -------------------------------------------------------*/ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
342 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
343 PyTypeObject PyCursesPanel_Type = { |
|
42334
e70cdce0e8b2
Merged revisions 56467-56482 via svnmerge from
Martin v. Löwis <martin@v.loewis.de>
parents:
36868
diff
changeset
|
344 PyVarObject_HEAD_INIT(NULL, 0) |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
345 "_curses_panel.curses panel", /*tp_name*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
346 sizeof(PyCursesPanelObject), /*tp_basicsize*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
347 0, /*tp_itemsize*/ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
348 /* methods */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
349 (destructor)PyCursesPanel_Dealloc, /*tp_dealloc*/ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
350 0, /*tp_print*/ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
351 (getattrfunc)PyCursesPanel_GetAttr, /*tp_getattr*/ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
352 (setattrfunc)0, /*tp_setattr*/ |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
353 0, /*tp_compare*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
354 0, /*tp_repr*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
355 0, /*tp_as_number*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
356 0, /*tp_as_sequence*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
357 0, /*tp_as_mapping*/ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
358 0, /*tp_hash*/ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
359 }; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
360 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
361 /* Wrapper for panel_above(NULL). This function returns the bottom |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
362 panel of the stack, so it's renamed to bottom_panel(). |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
363 panel.above() *requires* a panel object in the first place which |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
364 may be undesirable. */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
365 static PyObject * |
|
22561
043ad7adc896
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21846
diff
changeset
|
366 PyCurses_bottom_panel(PyObject *self) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
367 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
368 PANEL *pan; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
369 PyCursesPanelObject *po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
370 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
371 PyCursesInitialised; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
372 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
373 pan = panel_above(NULL); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
374 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
375 if (pan == NULL) { /* valid output, it means |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
376 there's no panel at all */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
377 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
378 return Py_None; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
379 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
380 po = find_po(pan); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
381 if (po == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
382 PyErr_SetString(PyExc_RuntimeError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
383 "panel_above: can't find Panel Object"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
384 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
385 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
386 Py_INCREF(po); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
387 return (PyObject *)po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
388 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
389 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
390 static PyObject * |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
391 PyCurses_new_panel(PyObject *self, PyObject *args) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
392 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
393 PyCursesWindowObject *win; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
394 PANEL *pan; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
395 |
|
15653
82bec388c636
Shortened / wrapped some long lines.
Fred Drake <fdrake@acm.org>
parents:
15651
diff
changeset
|
396 if (!PyArg_ParseTuple(args, "O!", &PyCursesWindow_Type, &win)) |
|
82bec388c636
Shortened / wrapped some long lines.
Fred Drake <fdrake@acm.org>
parents:
15651
diff
changeset
|
397 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
398 pan = new_panel(win->win); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
399 if (pan == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
400 PyErr_SetString(PyCursesError, catchall_NULL); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
401 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
402 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
403 return (PyObject *)PyCursesPanel_New(pan, win); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
404 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
405 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
406 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
407 /* Wrapper for panel_below(NULL). This function returns the top panel |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
408 of the stack, so it's renamed to top_panel(). panel.below() |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
409 *requires* a panel object in the first place which may be |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
410 undesirable. */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
411 static PyObject * |
|
22561
043ad7adc896
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21846
diff
changeset
|
412 PyCurses_top_panel(PyObject *self) |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
413 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
414 PANEL *pan; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
415 PyCursesPanelObject *po; |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
416 |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
417 PyCursesInitialised; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
418 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
419 pan = panel_below(NULL); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
420 |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
421 if (pan == NULL) { /* valid output, it means |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
422 there's no panel at all */ |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
423 Py_INCREF(Py_None); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
424 return Py_None; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
425 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
426 po = find_po(pan); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
427 if (po == NULL) { |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
428 PyErr_SetString(PyExc_RuntimeError, |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
429 "panel_below: can't find Panel Object"); |
|
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
430 return NULL; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
431 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
432 Py_INCREF(po); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
433 return (PyObject *)po; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
434 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
435 |
|
22561
043ad7adc896
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21846
diff
changeset
|
436 static PyObject *PyCurses_update_panels(PyObject *self) |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
437 { |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
438 PyCursesInitialised; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
439 update_panels(); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
440 Py_INCREF(Py_None); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
441 return Py_None; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
442 } |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
443 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
444 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
445 /* List of functions defined in the module */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
446 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
447 static PyMethodDef PyCurses_methods[] = { |
|
22561
043ad7adc896
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21846
diff
changeset
|
448 {"bottom_panel", (PyCFunction)PyCurses_bottom_panel, METH_NOARGS}, |
|
043ad7adc896
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21846
diff
changeset
|
449 {"new_panel", (PyCFunction)PyCurses_new_panel, METH_VARARGS}, |
|
043ad7adc896
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21846
diff
changeset
|
450 {"top_panel", (PyCFunction)PyCurses_top_panel, METH_NOARGS}, |
|
043ad7adc896
Remove many uses of PyArg_NoArgs macro, change METH_OLDARGS to METH_NOARGS.
Neal Norwitz <nnorwitz@gmail.com>
parents:
21846
diff
changeset
|
451 {"update_panels", (PyCFunction)PyCurses_update_panels, METH_NOARGS}, |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
452 {NULL, NULL} /* sentinel */ |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
453 }; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
454 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
455 /* Initialization function for the module */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
456 |
|
24471
f66b3a3509c7
Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
Mark Hammond <mhammond@skippinet.com.au>
parents:
22707
diff
changeset
|
457 PyMODINIT_FUNC |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
458 init_curses_panel(void) |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
459 { |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
460 PyObject *m, *d, *v; |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
461 |
|
16306
8e873fa5450e
init_curses_panel(): Be more consistent with indentation and blank lines.
Fred Drake <fdrake@acm.org>
parents:
16106
diff
changeset
|
462 /* Initialize object type */ |
|
44350
26384b8180c7
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Macros for b/w compatibility are available.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
463 Py_TYPE(&PyCursesPanel_Type) = &PyType_Type; |
|
16106
28c414dcb3e1
SF Patch #103185, by jlt63: Some more standard modules cleanup for Cygwin
Guido van Rossum <guido@python.org>
parents:
16034
diff
changeset
|
464 |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
465 import_curses(); |
|
16306
8e873fa5450e
init_curses_panel(): Be more consistent with indentation and blank lines.
Fred Drake <fdrake@acm.org>
parents:
16106
diff
changeset
|
466 |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
467 /* Create the module and add the functions */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
468 m = Py_InitModule("_curses_panel", PyCurses_methods); |
|
36324
1af7f719ed28
Check return result from Py_InitModule*(). This API can fail.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36251
diff
changeset
|
469 if (m == NULL) |
|
61463
fd25030223b0
Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents:
59312
diff
changeset
|
470 return; |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
471 d = PyModule_GetDict(m); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
472 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
473 /* For exception _curses_panel.error */ |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
474 PyCursesError = PyErr_NewException("_curses_panel.error", NULL, NULL); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
475 PyDict_SetItemString(d, "error", PyCursesError); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
476 |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
477 /* Make the version available */ |
|
47527
52294af4b663
This reverts r63675 based on the discussion in this thread:
Gregory P. Smith <greg@mad-scientist.com>
parents:
47294
diff
changeset
|
478 v = PyString_FromString(PyCursesVersion); |
|
15647
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
479 PyDict_SetItemString(d, "version", v); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
480 PyDict_SetItemString(d, "__version__", v); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
481 Py_DECREF(v); |
|
e9f4b76699aa
Patch #102813: add a wrapper for the panel library included with ncurses.
Andrew M. Kuchling <amk@amk.ca>
parents:
diff
changeset
|
482 } |
