Remove separator comments from TUI
[deliverable/binutils-gdb.git] / gdb / tui / tui-data.c
1 /* TUI data manipulation routines.
2
3 Copyright (C) 1998-2019 Free Software Foundation, Inc.
4
5 Contributed by Hewlett-Packard Company.
6
7 This file is part of GDB.
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #include "defs.h"
23 #include "symtab.h"
24 #include "tui/tui.h"
25 #include "tui/tui-data.h"
26 #include "tui/tui-wingeneral.h"
27 #include "tui/tui-winsource.h"
28 #include "gdb_curses.h"
29
30 struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
31
32 static int term_height, term_width;
33 static struct tui_win_info *win_with_focus = NULL;
34
35 static bool win_resized = false;
36
37 int
38 tui_win_is_auxiliary (enum tui_win_type win_type)
39 {
40 return (win_type > MAX_MAJOR_WINDOWS);
41 }
42
43 /* Answer a whether the terminal window has been resized or not. */
44 bool
45 tui_win_resized ()
46 {
47 return win_resized;
48 }
49
50
51 /* Set a whether the terminal window has been resized or not. */
52 void
53 tui_set_win_resized_to (bool resized)
54 {
55 win_resized = resized;
56 }
57
58
59 /* Answer the window with the logical focus. */
60 struct tui_win_info *
61 tui_win_with_focus (void)
62 {
63 return win_with_focus;
64 }
65
66
67 /* Set the window that has the logical focus. */
68 void
69 tui_set_win_with_focus (struct tui_win_info *win_info)
70 {
71 win_with_focus = win_info;
72 }
73
74
75 /* Accessor for the term_height. */
76 int
77 tui_term_height (void)
78 {
79 return term_height;
80 }
81
82
83 /* Mutator for the term height. */
84 void
85 tui_set_term_height_to (int h)
86 {
87 term_height = h;
88 }
89
90
91 /* Accessor for the term_width. */
92 int
93 tui_term_width (void)
94 {
95 return term_width;
96 }
97
98
99 /* Mutator for the term_width. */
100 void
101 tui_set_term_width_to (int w)
102 {
103 term_width = w;
104 }
105
106
107 /* Answer the next window in the list, cycling back to the top if
108 necessary. */
109 struct tui_win_info *
110 tui_next_win (struct tui_win_info *cur_win)
111 {
112 int type = cur_win->type;
113 struct tui_win_info *next_win = NULL;
114
115 if (cur_win->type == CMD_WIN)
116 type = SRC_WIN;
117 else
118 type = cur_win->type + 1;
119 while (type != cur_win->type && (next_win == NULL))
120 {
121 if (tui_win_list[type]
122 && tui_win_list[type]->is_visible ())
123 next_win = tui_win_list[type];
124 else
125 {
126 if (type == CMD_WIN)
127 type = SRC_WIN;
128 else
129 type++;
130 }
131 }
132
133 return next_win;
134 }
135
136
137 /* Answer the prev window in the list, cycling back to the bottom if
138 necessary. */
139 struct tui_win_info *
140 tui_prev_win (struct tui_win_info *cur_win)
141 {
142 int type = cur_win->type;
143 struct tui_win_info *prev = NULL;
144
145 if (cur_win->type == SRC_WIN)
146 type = CMD_WIN;
147 else
148 type = cur_win->type - 1;
149 while (type != cur_win->type && (prev == NULL))
150 {
151 if (tui_win_list[type]
152 && tui_win_list[type]->is_visible ())
153 prev = tui_win_list[type];
154 else
155 {
156 if (type == SRC_WIN)
157 type = CMD_WIN;
158 else
159 type--;
160 }
161 }
162
163 return prev;
164 }
165
166
167 /* Answer the window represented by name. */
168 struct tui_win_info *
169 tui_partial_win_by_name (const char *name)
170 {
171 if (name != NULL)
172 {
173 for (tui_win_info *item : all_tui_windows ())
174 {
175 const char *cur_name = item->name ();
176
177 if (strlen (name) <= strlen (cur_name)
178 && startswith (cur_name, name))
179 return item;
180 }
181 }
182
183 return NULL;
184 }
185
186 /* See tui-data.h. */
187
188 void
189 tui_delete_invisible_windows ()
190 {
191 for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
192 {
193 if (tui_win_list[win_type] != NULL
194 && !tui_win_list[win_type]->is_visible ())
195 {
196 /* This should always be made visible before a call to this
197 function. */
198 gdb_assert (win_type != CMD_WIN);
199
200 if (win_with_focus == tui_win_list[win_type])
201 win_with_focus = nullptr;
202
203 delete tui_win_list[win_type];
204 tui_win_list[win_type] = NULL;
205 }
206 }
207 }
208
209 tui_win_info::tui_win_info (enum tui_win_type type)
210 : tui_gen_win_info (type)
211 {
212 }
213
214 tui_gen_win_info::~tui_gen_win_info ()
215 {
216 tui_delete_win (handle);
217 }
218
219 void
220 tui_win_info::rerender ()
221 {
222 check_and_display_highlight_if_needed ();
223 }
This page took 0.034827 seconds and 5 git commands to generate.