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