Make target_ops::has_execution take an 'inferior *' instead of a ptid_t
[deliverable/binutils-gdb.git] / gdb / tui / tui-data.c
1 /* TUI data manipulation routines.
2
3 Copyright (C) 1998-2020 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 /* Answer a whether the terminal window has been resized or not. */
38 bool
39 tui_win_resized ()
40 {
41 return win_resized;
42 }
43
44
45 /* Set a whether the terminal window has been resized or not. */
46 void
47 tui_set_win_resized_to (bool resized)
48 {
49 win_resized = resized;
50 }
51
52
53 /* Answer the window with the logical focus. */
54 struct tui_win_info *
55 tui_win_with_focus (void)
56 {
57 return win_with_focus;
58 }
59
60
61 /* Set the window that has the logical focus. */
62 void
63 tui_set_win_with_focus (struct tui_win_info *win_info)
64 {
65 win_with_focus = win_info;
66 }
67
68
69 /* Accessor for the term_height. */
70 int
71 tui_term_height (void)
72 {
73 return term_height;
74 }
75
76
77 /* Mutator for the term height. */
78 void
79 tui_set_term_height_to (int h)
80 {
81 term_height = h;
82 }
83
84
85 /* Accessor for the term_width. */
86 int
87 tui_term_width (void)
88 {
89 return term_width;
90 }
91
92
93 /* Mutator for the term_width. */
94 void
95 tui_set_term_width_to (int w)
96 {
97 term_width = w;
98 }
99
100
101 /* Answer the next window in the list, cycling back to the top if
102 necessary. */
103 struct tui_win_info *
104 tui_next_win (struct tui_win_info *cur_win)
105 {
106 int type = cur_win->type;
107 struct tui_win_info *next_win = NULL;
108
109 if (cur_win->type == CMD_WIN)
110 type = SRC_WIN;
111 else
112 type = cur_win->type + 1;
113 while (type != cur_win->type && (next_win == NULL))
114 {
115 if (tui_win_list[type]
116 && tui_win_list[type]->is_visible ())
117 next_win = tui_win_list[type];
118 else
119 {
120 if (type == CMD_WIN)
121 type = SRC_WIN;
122 else
123 type++;
124 }
125 }
126
127 return next_win;
128 }
129
130
131 /* Answer the prev window in the list, cycling back to the bottom if
132 necessary. */
133 struct tui_win_info *
134 tui_prev_win (struct tui_win_info *cur_win)
135 {
136 int type = cur_win->type;
137 struct tui_win_info *prev = NULL;
138
139 if (cur_win->type == SRC_WIN)
140 type = CMD_WIN;
141 else
142 type = cur_win->type - 1;
143 while (type != cur_win->type && (prev == NULL))
144 {
145 if (tui_win_list[type]
146 && tui_win_list[type]->is_visible ())
147 prev = tui_win_list[type];
148 else
149 {
150 if (type == SRC_WIN)
151 type = CMD_WIN;
152 else
153 type--;
154 }
155 }
156
157 return prev;
158 }
159
160
161 /* See tui-data.h. */
162
163 void
164 tui_delete_invisible_windows ()
165 {
166 for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
167 {
168 if (tui_win_list[win_type] != NULL
169 && !tui_win_list[win_type]->is_visible ())
170 {
171 /* This should always be made visible before a call to this
172 function. */
173 gdb_assert (win_type != CMD_WIN);
174
175 if (win_with_focus == tui_win_list[win_type])
176 win_with_focus = nullptr;
177
178 delete tui_win_list[win_type];
179 tui_win_list[win_type] = NULL;
180 }
181 }
182 }
183
184 tui_win_info::tui_win_info (enum tui_win_type type)
185 : tui_gen_win_info (type)
186 {
187 }
188
189 void
190 tui_win_info::rerender ()
191 {
192 check_and_display_highlight_if_needed ();
193 }
This page took 0.049019 seconds and 4 git commands to generate.