]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/tui/tui-wingeneral.c
cad7b9a631c1262f037419df5aadc0f309b47a0f
[thirdparty/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
1 /* General window behavior.
2
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
4 Inc.
5
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. */
24
25 #include "defs.h"
26 #include "tui/tui.h"
27 #include "tui/tui-data.h"
28 #include "tui/tui-wingeneral.h"
29 #include "tui/tui-win.h"
30
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
39 /***********************
40 ** PUBLIC FUNCTIONS
41 ***********************/
42
43 /* Refresh the window. */
44 void
45 tui_refresh_win (TuiGenWinInfoPtr winInfo)
46 {
47 if (winInfo->type == DATA_WIN && winInfo->contentSize > 0)
48 {
49 int i;
50
51 for (i = 0; (i < winInfo->contentSize); i++)
52 {
53 TuiGenWinInfoPtr dataItemWinPtr;
54
55 dataItemWinPtr = &((TuiWinContent)
56 winInfo->content)[i]->whichElement.dataWindow;
57 if (m_genWinPtrNotNull (dataItemWinPtr) &&
58 dataItemWinPtr->handle != (WINDOW *) NULL)
59 wrefresh (dataItemWinPtr->handle);
60 }
61 }
62 else if (winInfo->type == CMD_WIN)
63 {
64 /* Do nothing */
65 }
66 else
67 {
68 if (winInfo->handle != (WINDOW *) NULL)
69 wrefresh (winInfo->handle);
70 }
71
72 return;
73 }
74
75
76 /* Function to delete the curses window, checking for NULL. */
77 void
78 tui_delete_win (WINDOW * window)
79 {
80 if (window != (WINDOW *) NULL)
81 delwin (window);
82
83 return;
84 }
85
86
87 /* Draw a border arround the window. */
88 void
89 boxWin (TuiGenWinInfoPtr winInfo, int highlightFlag)
90 {
91 if (winInfo && winInfo->handle)
92 {
93 WINDOW *win;
94 int attrs;
95
96 win = winInfo->handle;
97 if (highlightFlag == HILITE)
98 attrs = tui_active_border_attrs;
99 else
100 attrs = tui_border_attrs;
101
102 wattron (win, attrs);
103 wborder (win, tui_border_vline, tui_border_vline,
104 tui_border_hline, tui_border_hline,
105 tui_border_ulcorner, tui_border_urcorner,
106 tui_border_llcorner, tui_border_lrcorner);
107 if (winInfo->title)
108 mvwaddstr (win, 0, 3, winInfo->title);
109 wattroff (win, attrs);
110 }
111 }
112
113
114 void
115 tui_unhighlight_win (TuiWinInfoPtr winInfo)
116 {
117 if (m_winPtrNotNull (winInfo) && winInfo->generic.handle != (WINDOW *) NULL)
118 {
119 boxWin ((TuiGenWinInfoPtr) winInfo, NO_HILITE);
120 wrefresh (winInfo->generic.handle);
121 m_setWinHighlightOff (winInfo);
122 }
123 }
124
125
126 void
127 tui_highlight_win (TuiWinInfoPtr winInfo)
128 {
129 if (m_winPtrNotNull (winInfo) &&
130 winInfo->canHighlight && winInfo->generic.handle != (WINDOW *) NULL)
131 {
132 boxWin ((TuiGenWinInfoPtr) winInfo, HILITE);
133 wrefresh (winInfo->generic.handle);
134 m_setWinHighlightOn (winInfo);
135 }
136 }
137
138 void
139 tui_check_and_display_highlight_if_needed (TuiWinInfoPtr winInfo)
140 {
141 if (m_winPtrNotNull (winInfo) && winInfo->generic.type != CMD_WIN)
142 {
143 if (winInfo->isHighlighted)
144 tui_highlight_win (winInfo);
145 else
146 tui_unhighlight_win (winInfo);
147
148 }
149 return;
150 }
151
152
153 void
154 tui_make_window (TuiGenWinInfoPtr winInfo, int boxIt)
155 {
156 WINDOW *handle;
157
158 handle = newwin (winInfo->height,
159 winInfo->width,
160 winInfo->origin.y,
161 winInfo->origin.x);
162 winInfo->handle = handle;
163 if (handle != (WINDOW *) NULL)
164 {
165 if (boxIt == BOX_WINDOW)
166 boxWin (winInfo, NO_HILITE);
167 winInfo->isVisible = TRUE;
168 scrollok (handle, TRUE);
169 }
170 }
171
172
173 /* We can't really make windows visible, or invisible. So we have to
174 delete the entire window when making it visible, and create it
175 again when making it visible. */
176 static void
177 make_visible (struct tui_gen_win_info *win_info, int visible)
178 {
179 /* Don't tear down/recreate command window */
180 if (win_info->type == CMD_WIN)
181 return;
182
183 if (visible)
184 {
185 if (!win_info->isVisible)
186 {
187 tui_make_window (win_info,
188 (win_info->type != CMD_WIN
189 && !m_winIsAuxillary (win_info->type)));
190 win_info->isVisible = TRUE;
191 }
192 }
193 else if (!visible &&
194 win_info->isVisible && win_info->handle != (WINDOW *) NULL)
195 {
196 win_info->isVisible = FALSE;
197 tui_delete_win (win_info->handle);
198 win_info->handle = (WINDOW *) NULL;
199 }
200
201 return;
202 }
203
204 void
205 tui_make_visible (struct tui_gen_win_info *win_info)
206 {
207 make_visible (win_info, 1);
208 }
209
210 void
211 tui_make_invisible (struct tui_gen_win_info *win_info)
212 {
213 make_visible (win_info, 0);
214 }
215
216
217 /* Makes all windows invisible (except the command and locator windows). */
218 static void
219 make_all_visible (int visible)
220 {
221 int i;
222
223 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
224 {
225 if (m_winPtrNotNull (winList[i]) &&
226 ((winList[i])->generic.type) != CMD_WIN)
227 {
228 if (m_winIsSourceType ((winList[i])->generic.type))
229 make_visible ((winList[i])->detail.sourceInfo.executionInfo,
230 visible);
231 make_visible ((TuiGenWinInfoPtr) winList[i], visible);
232 }
233 }
234
235 return;
236 }
237
238 void
239 tui_make_all_visible (void)
240 {
241 make_all_visible (1);
242 }
243
244 void
245 tui_make_all_invisible (void)
246 {
247 make_all_visible (0);
248 }
249
250 /* Function to refresh all the windows currently displayed. */
251
252 void
253 tui_refresh_all (TuiWinInfoPtr * list)
254 {
255 TuiWinType type;
256 TuiGenWinInfoPtr locator = tui_locator_win_info_ptr ();
257
258 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
259 {
260 if (list[type] && list[type]->generic.isVisible)
261 {
262 if (type == SRC_WIN || type == DISASSEM_WIN)
263 {
264 touchwin (list[type]->detail.sourceInfo.executionInfo->handle);
265 tui_refresh_win (list[type]->detail.sourceInfo.executionInfo);
266 }
267 touchwin (list[type]->generic.handle);
268 tui_refresh_win (&list[type]->generic);
269 }
270 }
271 if (locator->isVisible)
272 {
273 touchwin (locator->handle);
274 tui_refresh_win (locator);
275 }
276
277 return;
278 } /* refreshAll */
279
280
281 /*********************************
282 ** Local Static Functions
283 *********************************/