]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/tui/tui-wingeneral.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / tui / tui-wingeneral.c
CommitLineData
f377b406 1/* General window behavior.
f33c6cbf 2
6aba47ca
DJ
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2007
4 Free Software Foundation, Inc.
f33c6cbf 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
88d83552
EZ
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, 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
6a83354a 31#include "gdb_curses.h"
4e8f7a8b 32
c906108c
SS
33/***********************
34** PUBLIC FUNCTIONS
35***********************/
ec7d9e56
AC
36
37/* Refresh the window. */
c906108c 38void
6d012f14 39tui_refresh_win (struct tui_gen_win_info * win_info)
c906108c 40{
6d012f14 41 if (win_info->type == DATA_WIN && win_info->content_size > 0)
c906108c
SS
42 {
43 int i;
44
6d012f14 45 for (i = 0; (i < win_info->content_size); i++)
c906108c 46 {
6ba8e26f 47 struct tui_gen_win_info * data_item_win_ptr;
c906108c 48
6ba8e26f 49 data_item_win_ptr = &((tui_win_content)
6d012f14 50 win_info->content)[i]->which_element.data_window;
6ba8e26f
AC
51 if (data_item_win_ptr != NULL
52 && data_item_win_ptr->handle != (WINDOW *) NULL)
53 wrefresh (data_item_win_ptr->handle);
c906108c
SS
54 }
55 }
6d012f14 56 else if (win_info->type == CMD_WIN)
c906108c
SS
57 {
58 /* Do nothing */
59 }
60 else
61 {
6d012f14
AC
62 if (win_info->handle != (WINDOW *) NULL)
63 wrefresh (win_info->handle);
c906108c
SS
64 }
65
66 return;
ec7d9e56 67}
c906108c
SS
68
69
ec7d9e56 70/* Function to delete the curses window, checking for NULL. */
c906108c 71void
ec7d9e56 72tui_delete_win (WINDOW * window)
c906108c
SS
73{
74 if (window != (WINDOW *) NULL)
75 delwin (window);
76
77 return;
ec7d9e56 78}
c906108c
SS
79
80
af101512 81/* Draw a border arround the window. */
c906108c 82void
6ba8e26f 83box_win (struct tui_gen_win_info * win_info, int highlight_flag)
c906108c 84{
6d012f14 85 if (win_info && win_info->handle)
c906108c 86 {
af101512
SC
87 WINDOW *win;
88 int attrs;
89
6d012f14 90 win = win_info->handle;
6ba8e26f 91 if (highlight_flag == HILITE)
af101512 92 attrs = tui_active_border_attrs;
c906108c 93 else
af101512
SC
94 attrs = tui_border_attrs;
95
96 wattron (win, attrs);
8b9cf735 97#ifdef HAVE_WBORDER
af101512
SC
98 wborder (win, tui_border_vline, tui_border_vline,
99 tui_border_hline, tui_border_hline,
100 tui_border_ulcorner, tui_border_urcorner,
101 tui_border_llcorner, tui_border_lrcorner);
8b9cf735
MK
102#else
103 box (win, tui_border_vline, tui_border_hline);
104#endif
6d012f14
AC
105 if (win_info->title)
106 mvwaddstr (win, 0, 3, win_info->title);
af101512 107 wattroff (win, attrs);
c906108c 108 }
af101512 109}
c906108c
SS
110
111
c906108c 112void
6d012f14 113tui_unhighlight_win (struct tui_win_info * win_info)
c906108c 114{
6d012f14 115 if (win_info != NULL && win_info->generic.handle != (WINDOW *) NULL)
c906108c 116 {
6ba8e26f 117 box_win ((struct tui_gen_win_info *) win_info, NO_HILITE);
6d012f14
AC
118 wrefresh (win_info->generic.handle);
119 tui_set_win_highlight (win_info, 0);
c906108c 120 }
ec7d9e56 121}
c906108c
SS
122
123
c906108c 124void
6d012f14 125tui_highlight_win (struct tui_win_info * win_info)
c906108c 126{
6d012f14
AC
127 if (win_info != NULL
128 && win_info->can_highlight
129 && win_info->generic.handle != (WINDOW *) NULL)
c906108c 130 {
6ba8e26f 131 box_win ((struct tui_gen_win_info *) win_info, HILITE);
6d012f14
AC
132 wrefresh (win_info->generic.handle);
133 tui_set_win_highlight (win_info, 1);
c906108c 134 }
ec7d9e56 135}
c906108c 136
c906108c 137void
6d012f14 138tui_check_and_display_highlight_if_needed (struct tui_win_info * win_info)
c906108c 139{
6d012f14 140 if (win_info != NULL && win_info->generic.type != CMD_WIN)
c906108c 141 {
6d012f14
AC
142 if (win_info->is_highlighted)
143 tui_highlight_win (win_info);
c906108c 144 else
6d012f14 145 tui_unhighlight_win (win_info);
c906108c
SS
146
147 }
148 return;
ec7d9e56 149}
c906108c
SS
150
151
c906108c 152void
6ba8e26f 153tui_make_window (struct tui_gen_win_info * win_info, int box_it)
c906108c
SS
154{
155 WINDOW *handle;
156
6d012f14
AC
157 handle = newwin (win_info->height,
158 win_info->width,
159 win_info->origin.y,
160 win_info->origin.x);
161 win_info->handle = handle;
c906108c
SS
162 if (handle != (WINDOW *) NULL)
163 {
6ba8e26f
AC
164 if (box_it == BOX_WINDOW)
165 box_win (win_info, NO_HILITE);
6d012f14 166 win_info->is_visible = TRUE;
c906108c 167 scrollok (handle, TRUE);
c906108c 168 }
bc712bbf 169}
c906108c
SS
170
171
ec7d9e56
AC
172/* We can't really make windows visible, or invisible. So we have to
173 delete the entire window when making it visible, and create it
174 again when making it visible. */
175static void
176make_visible (struct tui_gen_win_info *win_info, int visible)
c906108c
SS
177{
178 /* Don't tear down/recreate command window */
ec7d9e56 179 if (win_info->type == CMD_WIN)
c906108c
SS
180 return;
181
182 if (visible)
183 {
6d012f14 184 if (!win_info->is_visible)
c906108c 185 {
ec7d9e56
AC
186 tui_make_window (win_info,
187 (win_info->type != CMD_WIN
6d012f14
AC
188 && !tui_win_is_auxillary (win_info->type)));
189 win_info->is_visible = TRUE;
c906108c 190 }
c906108c
SS
191 }
192 else if (!visible &&
6d012f14 193 win_info->is_visible && win_info->handle != (WINDOW *) NULL)
c906108c 194 {
6d012f14 195 win_info->is_visible = FALSE;
ec7d9e56
AC
196 tui_delete_win (win_info->handle);
197 win_info->handle = (WINDOW *) NULL;
c906108c
SS
198 }
199
200 return;
ec7d9e56 201}
c906108c 202
ec7d9e56
AC
203void
204tui_make_visible (struct tui_gen_win_info *win_info)
205{
206 make_visible (win_info, 1);
207}
c906108c 208
c906108c 209void
ec7d9e56
AC
210tui_make_invisible (struct tui_gen_win_info *win_info)
211{
212 make_visible (win_info, 0);
213}
214
215
216/* Makes all windows invisible (except the command and locator windows). */
217static void
218make_all_visible (int visible)
c906108c
SS
219{
220 int i;
221
222 for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
223 {
6d012f14
AC
224 if (tui_win_list[i] != NULL
225 && ((tui_win_list[i])->generic.type) != CMD_WIN)
c906108c 226 {
6d012f14
AC
227 if (tui_win_is_source_type ((tui_win_list[i])->generic.type))
228 make_visible ((tui_win_list[i])->detail.source_info.execution_info,
ec7d9e56 229 visible);
6d012f14 230 make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible);
c906108c
SS
231 }
232 }
233
234 return;
ec7d9e56
AC
235}
236
237void
238tui_make_all_visible (void)
239{
240 make_all_visible (1);
241}
242
243void
244tui_make_all_invisible (void)
245{
246 make_all_visible (0);
247}
248
249/* Function to refresh all the windows currently displayed. */
c906108c 250
c906108c 251void
2a8854a7 252tui_refresh_all (struct tui_win_info * * list)
c906108c 253{
22940a24 254 enum tui_win_type type;
2a8854a7 255 struct tui_gen_win_info * locator = tui_locator_win_info_ptr ();
c906108c
SS
256
257 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
258 {
6d012f14 259 if (list[type] && list[type]->generic.is_visible)
c906108c
SS
260 {
261 if (type == SRC_WIN || type == DISASSEM_WIN)
262 {
6d012f14
AC
263 touchwin (list[type]->detail.source_info.execution_info->handle);
264 tui_refresh_win (list[type]->detail.source_info.execution_info);
c906108c
SS
265 }
266 touchwin (list[type]->generic.handle);
ec7d9e56 267 tui_refresh_win (&list[type]->generic);
c906108c
SS
268 }
269 }
6d012f14 270 if (locator->is_visible)
c906108c
SS
271 {
272 touchwin (locator->handle);
ec7d9e56 273 tui_refresh_win (locator);
c906108c 274 }
6ba8e26f 275}
c906108c
SS
276
277
278/*********************************
279** Local Static Functions
280*********************************/