1 /* TUI data manipulation routines.
3 Copyright (C) 1998-2021 Free Software Foundation, Inc.
5 Contributed by Hewlett-Packard Company.
7 This file is part of GDB.
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.
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.
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/>. */
25 #include "tui/tui-data.h"
26 #include "tui/tui-win.h"
27 #include "tui/tui-wingeneral.h"
28 #include "tui/tui-winsource.h"
29 #include "gdb_curses.h"
32 struct tui_win_info
*tui_win_list
[MAX_MAJOR_WINDOWS
];
34 static int term_height
, term_width
;
35 static struct tui_win_info
*win_with_focus
= NULL
;
37 static bool win_resized
= false;
39 /* Answer a whether the terminal window has been resized or not. */
47 /* Set a whether the terminal window has been resized or not. */
49 tui_set_win_resized_to (bool resized
)
51 win_resized
= resized
;
55 /* Answer the window with the logical focus. */
57 tui_win_with_focus (void)
59 return win_with_focus
;
63 /* Set the logical focus to win_info. */
65 tui_set_win_focus_to (struct tui_win_info
*win_info
)
69 tui_unhighlight_win (win_with_focus
);
70 win_with_focus
= win_info
;
71 tui_highlight_win (win_info
);
76 /* Accessor for the term_height. */
78 tui_term_height (void)
84 /* Mutator for the term height. */
86 tui_set_term_height_to (int h
)
92 /* Accessor for the term_width. */
100 /* Mutator for the term_width. */
102 tui_set_term_width_to (int w
)
108 /* Answer the next window in the list, cycling back to the top if
110 struct tui_win_info
*
111 tui_next_win (struct tui_win_info
*cur_win
)
113 auto iter
= std::find (tui_windows
.begin (), tui_windows
.end (), cur_win
);
114 gdb_assert (iter
!= tui_windows
.end ());
116 gdb_assert (cur_win
->can_focus ());
117 /* This won't loop forever since we can't have just an un-focusable
122 if (iter
== tui_windows
.end ())
123 iter
= tui_windows
.begin ();
124 if ((*iter
)->can_focus ())
132 /* Answer the prev window in the list, cycling back to the bottom if
134 struct tui_win_info
*
135 tui_prev_win (struct tui_win_info
*cur_win
)
137 auto iter
= std::find (tui_windows
.rbegin (), tui_windows
.rend (), cur_win
);
138 gdb_assert (iter
!= tui_windows
.rend ());
140 gdb_assert (cur_win
->can_focus ());
141 /* This won't loop forever since we can't have just an un-focusable
146 if (iter
== tui_windows
.rend ())
147 iter
= tui_windows
.rbegin ();
148 if ((*iter
)->can_focus ())
157 tui_win_info::rerender ()
159 check_and_display_highlight_if_needed ();