*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
CommitLineData
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***********************/
ec7d9e56
AC
42
43/* Refresh the window. */
c906108c 44void
6d012f14 45tui_refresh_win (struct tui_gen_win_info * win_info)
c906108c 46{
6d012f14 47 if (win_info->type == DATA_WIN && win_info->content_size > 0)
c906108c
SS
48 {
49 int i;
50
6d012f14 51 for (i = 0; (i < win_info->content_size); i++)
c906108c 52 {
2a8854a7 53 struct tui_gen_win_info * dataItemWinPtr;
c906108c 54
2a8854a7 55 dataItemWinPtr = &((tui_win_content)
6d012f14
AC
56 win_info->content)[i]->which_element.data_window;
57 if (dataItemWinPtr != NULL
58 && dataItemWinPtr->handle != (WINDOW *) NULL)
c906108c
SS
59 wrefresh (dataItemWinPtr->handle);
60 }
61 }
6d012f14 62 else if (win_info->type == CMD_WIN)
c906108c
SS
63 {
64 /* Do nothing */
65 }
66 else
67 {
6d012f14
AC
68 if (win_info->handle != (WINDOW *) NULL)
69 wrefresh (win_info->handle);
c906108c
SS
70 }
71
72 return;
ec7d9e56 73}
c906108c
SS
74
75
ec7d9e56 76/* Function to delete the curses window, checking for NULL. */
c906108c 77void
ec7d9e56 78tui_delete_win (WINDOW * window)
c906108c
SS
79{
80 if (window != (WINDOW *) NULL)
81 delwin (window);
82
83 return;
ec7d9e56 84}
c906108c
SS
85
86
af101512 87/* Draw a border arround the window. */
c906108c 88void
6d012f14 89boxWin (struct tui_gen_win_info * win_info, int highlightFlag)
c906108c 90{
6d012f14 91 if (win_info && win_info->handle)
c906108c 92 {
af101512
SC
93 WINDOW *win;
94 int attrs;
95
6d012f14 96 win = win_info->handle;
c906108c 97 if (highlightFlag == HILITE)
af101512 98 attrs = tui_active_border_attrs;
c906108c 99 else
af101512
SC
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);
6d012f14
AC
107 if (win_info->title)
108 mvwaddstr (win, 0, 3, win_info->title);
af101512 109 wattroff (win, attrs);
c906108c 110 }
af101512 111}
c906108c
SS
112
113
c906108c 114void
6d012f14 115tui_unhighlight_win (struct tui_win_info * win_info)
c906108c 116{
6d012f14 117 if (win_info != NULL && win_info->generic.handle != (WINDOW *) NULL)
c906108c 118 {
6d012f14
AC
119 boxWin ((struct tui_gen_win_info *) win_info, NO_HILITE);
120 wrefresh (win_info->generic.handle);
121 tui_set_win_highlight (win_info, 0);
c906108c 122 }
ec7d9e56 123}
c906108c
SS
124
125
c906108c 126void
6d012f14 127tui_highlight_win (struct tui_win_info * win_info)
c906108c 128{
6d012f14
AC
129 if (win_info != NULL
130 && win_info->can_highlight
131 && win_info->generic.handle != (WINDOW *) NULL)
c906108c 132 {
6d012f14
AC
133 boxWin ((struct tui_gen_win_info *) win_info, HILITE);
134 wrefresh (win_info->generic.handle);
135 tui_set_win_highlight (win_info, 1);
c906108c 136 }
ec7d9e56 137}
c906108c 138
c906108c 139void
6d012f14 140tui_check_and_display_highlight_if_needed (struct tui_win_info * win_info)
c906108c 141{
6d012f14 142 if (win_info != NULL && win_info->generic.type != CMD_WIN)
c906108c 143 {
6d012f14
AC
144 if (win_info->is_highlighted)
145 tui_highlight_win (win_info);
c906108c 146 else
6d012f14 147 tui_unhighlight_win (win_info);
c906108c
SS
148
149 }
150 return;
ec7d9e56 151}
c906108c
SS
152
153
c906108c 154void
6d012f14 155tui_make_window (struct tui_gen_win_info * win_info, int boxIt)
c906108c
SS
156{
157 WINDOW *handle;
158
6d012f14
AC
159 handle = newwin (win_info->height,
160 win_info->width,
161 win_info->origin.y,
162 win_info->origin.x);
163 win_info->handle = handle;
c906108c
SS
164 if (handle != (WINDOW *) NULL)
165 {
166 if (boxIt == BOX_WINDOW)
6d012f14
AC
167 boxWin (win_info, NO_HILITE);
168 win_info->is_visible = TRUE;
c906108c 169 scrollok (handle, TRUE);
c906108c 170 }
bc712bbf 171}
c906108c
SS
172
173
ec7d9e56
AC
174/* We can't really make windows visible, or invisible. So we have to
175 delete the entire window when making it visible, and create it
176 again when making it visible. */
177static void
178make_visible (struct tui_gen_win_info *win_info, int visible)
c906108c
SS
179{
180 /* Don't tear down/recreate command window */
ec7d9e56 181 if (win_info->type == CMD_WIN)
c906108c
SS
182 return;
183
184 if (visible)
185 {
6d012f14 186 if (!win_info->is_visible)
c906108c 187 {
ec7d9e56
AC
188 tui_make_window (win_info,
189 (win_info->type != CMD_WIN
6d012f14
AC
190 && !tui_win_is_auxillary (win_info->type)));
191 win_info->is_visible = TRUE;
c906108c 192 }
c906108c
SS
193 }
194 else if (!visible &&
6d012f14 195 win_info->is_visible && win_info->handle != (WINDOW *) NULL)
c906108c 196 {
6d012f14 197 win_info->is_visible = FALSE;
ec7d9e56
AC
198 tui_delete_win (win_info->handle);
199 win_info->handle = (WINDOW *) NULL;
c906108c
SS
200 }
201
202 return;
ec7d9e56 203}
c906108c 204
ec7d9e56
AC
205void
206tui_make_visible (struct tui_gen_win_info *win_info)
207{
208 make_visible (win_info, 1);
209}
c906108c 210
c906108c 211void
ec7d9e56
AC
212tui_make_invisible (struct tui_gen_win_info *win_info)
213{
214 make_visible (win_info, 0);
215}
216
217
218/* Makes all windows invisible (except the command and locator windows). */
219static void
220make_all_visible (int visible)
c906108c
SS
221{
222 int i;
223
224 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
225 {
6d012f14
AC
226 if (tui_win_list[i] != NULL
227 && ((tui_win_list[i])->generic.type) != CMD_WIN)
c906108c 228 {
6d012f14
AC
229 if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
230 make_visible ((tui_win_list[i])->detail.source_info.execution_info,
ec7d9e56 231 visible);
6d012f14 232 make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible);
c906108c
SS
233 }
234 }
235
236 return;
ec7d9e56
AC
237}
238
239void
240tui_make_all_visible (void)
241{
242 make_all_visible (1);
243}
244
245void
246tui_make_all_invisible (void)
247{
248 make_all_visible (0);
249}
250
251/* Function to refresh all the windows currently displayed. */
c906108c 252
c906108c 253void
2a8854a7 254tui_refresh_all (struct tui_win_info * * list)
c906108c 255{
22940a24 256 enum tui_win_type type;
2a8854a7 257 struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
c906108c
SS
258
259 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
260 {
6d012f14 261 if (list[type] && list[type]->generic.is_visible)
c906108c
SS
262 {
263 if (type == SRC_WIN || type == DISASSEM_WIN)
264 {
6d012f14
AC
265 touchwin (list[type]->detail.source_info.execution_info->handle);
266 tui_refresh_win (list[type]->detail.source_info.execution_info);
c906108c
SS
267 }
268 touchwin (list[type]->generic.handle);
ec7d9e56 269 tui_refresh_win (&list[type]->generic);
c906108c
SS
270 }
271 }
6d012f14 272 if (locator->is_visible)
c906108c
SS
273 {
274 touchwin (locator->handle);
ec7d9e56 275 tui_refresh_win (locator);
c906108c
SS
276 }
277
278 return;
279} /* refreshAll */
280
281
282/*********************************
283** Local Static Functions
284*********************************/
This page took 0.573777 seconds and 4 git commands to generate.