Handle ambiguity in tui_partial_win_by_name
[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 #include <algorithm>
30
31 struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
32
33 static int term_height, term_width;
34 static struct tui_win_info *win_with_focus = NULL;
35
36 static bool win_resized = false;
37
38 /* Answer a whether the terminal window has been resized or not. */
39 bool
40 tui_win_resized ()
41 {
42 return win_resized;
43 }
44
45
46 /* Set a whether the terminal window has been resized or not. */
47 void
48 tui_set_win_resized_to (bool resized)
49 {
50 win_resized = resized;
51 }
52
53
54 /* Answer the window with the logical focus. */
55 struct tui_win_info *
56 tui_win_with_focus (void)
57 {
58 return win_with_focus;
59 }
60
61
62 /* Set the window that has the logical focus. */
63 void
64 tui_set_win_with_focus (struct tui_win_info *win_info)
65 {
66 win_with_focus = win_info;
67 }
68
69
70 /* Accessor for the term_height. */
71 int
72 tui_term_height (void)
73 {
74 return term_height;
75 }
76
77
78 /* Mutator for the term height. */
79 void
80 tui_set_term_height_to (int h)
81 {
82 term_height = h;
83 }
84
85
86 /* Accessor for the term_width. */
87 int
88 tui_term_width (void)
89 {
90 return term_width;
91 }
92
93
94 /* Mutator for the term_width. */
95 void
96 tui_set_term_width_to (int w)
97 {
98 term_width = w;
99 }
100
101
102 /* Answer the next window in the list, cycling back to the top if
103 necessary. */
104 struct tui_win_info *
105 tui_next_win (struct tui_win_info *cur_win)
106 {
107 auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win);
108 gdb_assert (iter != tui_windows.end ());
109
110 ++iter;
111 if (iter == tui_windows.end ())
112 return tui_windows[0];
113 return *iter;
114 }
115
116
117 /* Answer the prev window in the list, cycling back to the bottom if
118 necessary. */
119 struct tui_win_info *
120 tui_prev_win (struct tui_win_info *cur_win)
121 {
122 auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win);
123 gdb_assert (iter != tui_windows.end ());
124
125 if (iter == tui_windows.begin ())
126 return tui_windows.back ();
127 --iter;
128 return *iter;
129 }
130
131
132 /* See tui-data.h. */
133
134 void
135 tui_delete_invisible_windows ()
136 {
137 for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
138 {
139 if (tui_win_list[win_type] != NULL
140 && !tui_win_list[win_type]->is_visible ())
141 {
142 /* This should always be made visible before a call to this
143 function. */
144 gdb_assert (win_type != CMD_WIN);
145
146 if (win_with_focus == tui_win_list[win_type])
147 win_with_focus = nullptr;
148
149 delete tui_win_list[win_type];
150 tui_win_list[win_type] = NULL;
151 }
152 }
153 }
154
155 tui_win_info::tui_win_info (enum tui_win_type type)
156 : tui_gen_win_info (type)
157 {
158 }
159
160 void
161 tui_win_info::rerender ()
162 {
163 check_and_display_highlight_if_needed ();
164 }
This page took 0.034537 seconds and 4 git commands to generate.