Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* TUI data manipulation routines. |
f33c6cbf | 2 | |
b811d2c2 | 3 | Copyright (C) 1998-2020 Free Software Foundation, Inc. |
f33c6cbf | 4 | |
f377b406 SC |
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 | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
f377b406 SC |
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 | |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 21 | |
96ec9981 DJ |
22 | #include "defs.h" |
23 | #include "symtab.h" | |
d7b2e967 AC |
24 | #include "tui/tui.h" |
25 | #include "tui/tui-data.h" | |
26 | #include "tui/tui-wingeneral.h" | |
5104fe36 | 27 | #include "tui/tui-winsource.h" |
6a83354a | 28 | #include "gdb_curses.h" |
eb9c8874 | 29 | #include <algorithm> |
4e8f7a8b | 30 | |
7fa29be9 | 31 | struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS]; |
c906108c | 32 | |
6ba8e26f | 33 | static int term_height, term_width; |
e65b5245 | 34 | static struct tui_win_info *win_with_focus = NULL; |
08ef48c5 | 35 | |
9abd8a65 | 36 | static bool win_resized = false; |
c906108c | 37 | |
1cc6d956 | 38 | /* Answer a whether the terminal window has been resized or not. */ |
9abd8a65 TT |
39 | bool |
40 | tui_win_resized () | |
c906108c | 41 | { |
6ba8e26f | 42 | return win_resized; |
dd1abb8c | 43 | } |
c906108c SS |
44 | |
45 | ||
1cc6d956 | 46 | /* Set a whether the terminal window has been resized or not. */ |
c906108c | 47 | void |
9abd8a65 | 48 | tui_set_win_resized_to (bool resized) |
c906108c | 49 | { |
6ba8e26f | 50 | win_resized = resized; |
dd1abb8c | 51 | } |
c906108c SS |
52 | |
53 | ||
1cc6d956 | 54 | /* Answer the window with the logical focus. */ |
2a8854a7 | 55 | struct tui_win_info * |
dd1abb8c | 56 | tui_win_with_focus (void) |
c906108c | 57 | { |
6ba8e26f | 58 | return win_with_focus; |
dd1abb8c | 59 | } |
c906108c SS |
60 | |
61 | ||
1cc6d956 | 62 | /* Set the window that has the logical focus. */ |
c906108c | 63 | void |
5b6fe301 | 64 | tui_set_win_with_focus (struct tui_win_info *win_info) |
c906108c | 65 | { |
6ba8e26f | 66 | win_with_focus = win_info; |
dd1abb8c | 67 | } |
c906108c SS |
68 | |
69 | ||
6ba8e26f | 70 | /* Accessor for the term_height. */ |
c906108c | 71 | int |
dd1abb8c | 72 | tui_term_height (void) |
c906108c | 73 | { |
6ba8e26f | 74 | return term_height; |
dd1abb8c | 75 | } |
c906108c SS |
76 | |
77 | ||
1cc6d956 | 78 | /* Mutator for the term height. */ |
c906108c | 79 | void |
dd1abb8c | 80 | tui_set_term_height_to (int h) |
c906108c | 81 | { |
6ba8e26f | 82 | term_height = h; |
dd1abb8c | 83 | } |
c906108c SS |
84 | |
85 | ||
1cc6d956 | 86 | /* Accessor for the term_width. */ |
c906108c | 87 | int |
dd1abb8c | 88 | tui_term_width (void) |
c906108c | 89 | { |
6ba8e26f | 90 | return term_width; |
dd1abb8c | 91 | } |
c906108c SS |
92 | |
93 | ||
6ba8e26f | 94 | /* Mutator for the term_width. */ |
c906108c | 95 | void |
dd1abb8c | 96 | tui_set_term_width_to (int w) |
c906108c | 97 | { |
6ba8e26f | 98 | term_width = w; |
dd1abb8c | 99 | } |
c906108c SS |
100 | |
101 | ||
dd1abb8c AC |
102 | /* Answer the next window in the list, cycling back to the top if |
103 | necessary. */ | |
2a8854a7 | 104 | struct tui_win_info * |
5b6fe301 | 105 | tui_next_win (struct tui_win_info *cur_win) |
c906108c | 106 | { |
eb9c8874 TT |
107 | auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); |
108 | gdb_assert (iter != tui_windows.end ()); | |
c906108c | 109 | |
eb9c8874 TT |
110 | ++iter; |
111 | if (iter == tui_windows.end ()) | |
112 | return tui_windows[0]; | |
113 | return *iter; | |
6ba8e26f | 114 | } |
c906108c SS |
115 | |
116 | ||
dd1abb8c AC |
117 | /* Answer the prev window in the list, cycling back to the bottom if |
118 | necessary. */ | |
2a8854a7 | 119 | struct tui_win_info * |
5b6fe301 | 120 | tui_prev_win (struct tui_win_info *cur_win) |
c906108c | 121 | { |
eb9c8874 TT |
122 | auto iter = std::find (tui_windows.begin (), tui_windows.end (), cur_win); |
123 | gdb_assert (iter != tui_windows.end ()); | |
c906108c | 124 | |
eb9c8874 TT |
125 | if (iter == tui_windows.begin ()) |
126 | return tui_windows.back (); | |
127 | --iter; | |
128 | return *iter; | |
cb50eddd | 129 | } |
c906108c SS |
130 | |
131 | ||
33b906ab | 132 | tui_win_info::tui_win_info (enum tui_win_type type) |
cb2ce893 | 133 | : tui_gen_win_info (type) |
c906108c | 134 | { |
6ba8e26f | 135 | } |
c906108c | 136 | |
3df505f6 TT |
137 | void |
138 | tui_win_info::rerender () | |
139 | { | |
140 | check_and_display_highlight_if_needed (); | |
141 | } |