Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* General window behavior. |
f33c6cbf | 2 | |
96ec9981 | 3 | Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, |
f33c6cbf AC |
4 | Inc. |
5 | ||
f377b406 SC |
6 | Contributed by Hewlett-Packard Company. |
7 | ||
8 | This file is part of GDB. | |
9 | ||
10 | This program is free software; you can redistribute it and/or modify | |
11 | it under the terms of the GNU General Public License as published by | |
12 | the Free Software Foundation; either version 2 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | This program is distributed in the hope that it will be useful, | |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 | GNU General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU General Public License | |
21 | along with this program; if not, write to the Free Software | |
22 | Foundation, Inc., 59 Temple Place - Suite 330, | |
23 | Boston, MA 02111-1307, USA. */ | |
c906108c | 24 | |
96ec9981 | 25 | #include "defs.h" |
d7b2e967 AC |
26 | #include "tui/tui.h" |
27 | #include "tui/tui-data.h" | |
28 | #include "tui/tui-wingeneral.h" | |
29 | #include "tui/tui-win.h" | |
f33c6cbf | 30 | |
4e8f7a8b DJ |
31 | #ifdef HAVE_NCURSES_H |
32 | #include <ncurses.h> | |
33 | #else | |
34 | #ifdef HAVE_CURSES_H | |
35 | #include <curses.h> | |
36 | #endif | |
37 | #endif | |
38 | ||
c906108c SS |
39 | /*********************** |
40 | ** PUBLIC FUNCTIONS | |
41 | ***********************/ | |
42 | /* | |
c5aa993b JM |
43 | ** tuiRefreshWin() |
44 | ** Refresh the window | |
45 | */ | |
c906108c | 46 | void |
eca6576c | 47 | tuiRefreshWin (TuiGenWinInfoPtr winInfo) |
c906108c SS |
48 | { |
49 | if (winInfo->type == DATA_WIN && winInfo->contentSize > 0) | |
50 | { | |
51 | int i; | |
52 | ||
53 | for (i = 0; (i < winInfo->contentSize); i++) | |
54 | { | |
55 | TuiGenWinInfoPtr dataItemWinPtr; | |
56 | ||
57 | dataItemWinPtr = &((TuiWinContent) | |
58 | winInfo->content)[i]->whichElement.dataWindow; | |
59 | if (m_genWinPtrNotNull (dataItemWinPtr) && | |
60 | dataItemWinPtr->handle != (WINDOW *) NULL) | |
61 | wrefresh (dataItemWinPtr->handle); | |
62 | } | |
63 | } | |
64 | else if (winInfo->type == CMD_WIN) | |
65 | { | |
66 | /* Do nothing */ | |
67 | } | |
68 | else | |
69 | { | |
70 | if (winInfo->handle != (WINDOW *) NULL) | |
71 | wrefresh (winInfo->handle); | |
72 | } | |
73 | ||
74 | return; | |
75 | } /* tuiRefreshWin */ | |
76 | ||
77 | ||
78 | /* | |
c5aa993b JM |
79 | ** tuiDelwin() |
80 | ** Function to delete the curses window, checking for null | |
81 | */ | |
c906108c | 82 | void |
eca6576c | 83 | tuiDelwin (WINDOW * window) |
c906108c SS |
84 | { |
85 | if (window != (WINDOW *) NULL) | |
86 | delwin (window); | |
87 | ||
88 | return; | |
89 | } /* tuiDelwin */ | |
90 | ||
91 | ||
af101512 | 92 | /* Draw a border arround the window. */ |
c906108c | 93 | void |
eca6576c | 94 | boxWin (TuiGenWinInfoPtr winInfo, int highlightFlag) |
c906108c | 95 | { |
af101512 | 96 | if (winInfo && winInfo->handle) |
c906108c | 97 | { |
af101512 SC |
98 | WINDOW *win; |
99 | int attrs; | |
100 | ||
101 | win = winInfo->handle; | |
c906108c | 102 | if (highlightFlag == HILITE) |
af101512 | 103 | attrs = tui_active_border_attrs; |
c906108c | 104 | else |
af101512 SC |
105 | attrs = tui_border_attrs; |
106 | ||
107 | wattron (win, attrs); | |
108 | wborder (win, tui_border_vline, tui_border_vline, | |
109 | tui_border_hline, tui_border_hline, | |
110 | tui_border_ulcorner, tui_border_urcorner, | |
111 | tui_border_llcorner, tui_border_lrcorner); | |
bc6b7f04 SC |
112 | if (winInfo->title) |
113 | mvwaddstr (win, 0, 3, winInfo->title); | |
af101512 | 114 | wattroff (win, attrs); |
c906108c | 115 | } |
af101512 | 116 | } |
c906108c SS |
117 | |
118 | ||
119 | /* | |
c5aa993b JM |
120 | ** unhighlightWin(). |
121 | */ | |
c906108c | 122 | void |
eca6576c | 123 | unhighlightWin (TuiWinInfoPtr winInfo) |
c906108c SS |
124 | { |
125 | if (m_winPtrNotNull (winInfo) && winInfo->generic.handle != (WINDOW *) NULL) | |
126 | { | |
127 | boxWin ((TuiGenWinInfoPtr) winInfo, NO_HILITE); | |
128 | wrefresh (winInfo->generic.handle); | |
129 | m_setWinHighlightOff (winInfo); | |
130 | } | |
131 | } /* unhighlightWin */ | |
132 | ||
133 | ||
134 | /* | |
c5aa993b JM |
135 | ** highlightWin(). |
136 | */ | |
c906108c | 137 | void |
eca6576c | 138 | highlightWin (TuiWinInfoPtr winInfo) |
c906108c SS |
139 | { |
140 | if (m_winPtrNotNull (winInfo) && | |
141 | winInfo->canHighlight && winInfo->generic.handle != (WINDOW *) NULL) | |
142 | { | |
143 | boxWin ((TuiGenWinInfoPtr) winInfo, HILITE); | |
144 | wrefresh (winInfo->generic.handle); | |
145 | m_setWinHighlightOn (winInfo); | |
146 | } | |
147 | } /* highlightWin */ | |
148 | ||
149 | ||
150 | /* | |
c5aa993b JM |
151 | ** checkAndDisplayHighlightIfNecessay |
152 | */ | |
c906108c | 153 | void |
eca6576c | 154 | checkAndDisplayHighlightIfNeeded (TuiWinInfoPtr winInfo) |
c906108c SS |
155 | { |
156 | if (m_winPtrNotNull (winInfo) && winInfo->generic.type != CMD_WIN) | |
157 | { | |
158 | if (winInfo->isHighlighted) | |
159 | highlightWin (winInfo); | |
160 | else | |
161 | unhighlightWin (winInfo); | |
162 | ||
163 | } | |
164 | return; | |
165 | } /* checkAndDisplayHighlightIfNeeded */ | |
166 | ||
167 | ||
168 | /* | |
c5aa993b JM |
169 | ** makeWindow(). |
170 | */ | |
c906108c | 171 | void |
eca6576c | 172 | makeWindow (TuiGenWinInfoPtr winInfo, int boxIt) |
c906108c SS |
173 | { |
174 | WINDOW *handle; | |
175 | ||
176 | handle = newwin (winInfo->height, | |
177 | winInfo->width, | |
178 | winInfo->origin.y, | |
179 | winInfo->origin.x); | |
180 | winInfo->handle = handle; | |
181 | if (handle != (WINDOW *) NULL) | |
182 | { | |
183 | if (boxIt == BOX_WINDOW) | |
184 | boxWin (winInfo, NO_HILITE); | |
185 | winInfo->isVisible = TRUE; | |
186 | scrollok (handle, TRUE); | |
c906108c | 187 | } |
bc712bbf | 188 | } |
c906108c SS |
189 | |
190 | ||
191 | /* | |
c5aa993b JM |
192 | ** makeVisible(). |
193 | ** We can't really make windows visible, or invisible. So we | |
194 | ** have to delete the entire window when making it visible, | |
195 | ** and create it again when making it visible. | |
196 | */ | |
c906108c | 197 | void |
eca6576c | 198 | makeVisible (TuiGenWinInfoPtr winInfo, int visible) |
c906108c SS |
199 | { |
200 | /* Don't tear down/recreate command window */ | |
201 | if (winInfo->type == CMD_WIN) | |
202 | return; | |
203 | ||
204 | if (visible) | |
205 | { | |
206 | if (!winInfo->isVisible) | |
207 | { | |
208 | makeWindow ( | |
209 | winInfo, | |
210 | (winInfo->type != CMD_WIN && !m_winIsAuxillary (winInfo->type))); | |
211 | winInfo->isVisible = TRUE; | |
212 | } | |
c906108c SS |
213 | } |
214 | else if (!visible && | |
215 | winInfo->isVisible && winInfo->handle != (WINDOW *) NULL) | |
216 | { | |
217 | winInfo->isVisible = FALSE; | |
c906108c SS |
218 | tuiDelwin (winInfo->handle); |
219 | winInfo->handle = (WINDOW *) NULL; | |
220 | } | |
221 | ||
222 | return; | |
223 | } /* makeVisible */ | |
224 | ||
225 | ||
226 | /* | |
c5aa993b JM |
227 | ** makeAllVisible(). |
228 | ** Makes all windows invisible (except the command and locator windows) | |
229 | */ | |
c906108c | 230 | void |
eca6576c | 231 | makeAllVisible (int visible) |
c906108c SS |
232 | { |
233 | int i; | |
234 | ||
235 | for (i = 0; i < MAX_MAJOR_WINDOWS; i++) | |
236 | { | |
237 | if (m_winPtrNotNull (winList[i]) && | |
238 | ((winList[i])->generic.type) != CMD_WIN) | |
239 | { | |
240 | if (m_winIsSourceType ((winList[i])->generic.type)) | |
241 | makeVisible ((winList[i])->detail.sourceInfo.executionInfo, | |
242 | visible); | |
243 | makeVisible ((TuiGenWinInfoPtr) winList[i], visible); | |
244 | } | |
245 | } | |
246 | ||
247 | return; | |
248 | } /* makeAllVisible */ | |
249 | ||
c906108c | 250 | /* |
c5aa993b JM |
251 | ** refreshAll(). |
252 | ** Function to refresh all the windows currently displayed | |
253 | */ | |
c906108c | 254 | void |
eca6576c | 255 | refreshAll (TuiWinInfoPtr * list) |
c906108c SS |
256 | { |
257 | TuiWinType type; | |
258 | TuiGenWinInfoPtr locator = locatorWinInfoPtr (); | |
259 | ||
260 | for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) | |
261 | { | |
75fd9bc1 | 262 | if (list[type] && list[type]->generic.isVisible) |
c906108c SS |
263 | { |
264 | if (type == SRC_WIN || type == DISASSEM_WIN) | |
265 | { | |
266 | touchwin (list[type]->detail.sourceInfo.executionInfo->handle); | |
267 | tuiRefreshWin (list[type]->detail.sourceInfo.executionInfo); | |
268 | } | |
269 | touchwin (list[type]->generic.handle); | |
270 | tuiRefreshWin (&list[type]->generic); | |
271 | } | |
272 | } | |
273 | if (locator->isVisible) | |
274 | { | |
275 | touchwin (locator->handle); | |
276 | tuiRefreshWin (locator); | |
277 | } | |
278 | ||
279 | return; | |
280 | } /* refreshAll */ | |
281 | ||
282 | ||
283 | /********************************* | |
284 | ** Local Static Functions | |
285 | *********************************/ |