Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / tui / tui-data.c
CommitLineData
f377b406 1/* TUI data manipulation routines.
f33c6cbf 2
88b9d363 3 Copyright (C) 1998-2022 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 32struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
c906108c 33
6ba8e26f 34static int term_height, term_width;
e65b5245 35static struct tui_win_info *win_with_focus = NULL;
08ef48c5 36
9abd8a65 37static bool win_resized = false;
c906108c 38
1cc6d956 39/* Answer a whether the terminal window has been resized or not. */
9abd8a65
TT
40bool
41tui_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 48void
9abd8a65 49tui_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 56struct tui_win_info *
dd1abb8c 57tui_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 64void
935c78c0 65tui_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 77int
dd1abb8c 78tui_term_height (void)
c906108c 79{
6ba8e26f 80 return term_height;
dd1abb8c 81}
c906108c
SS
82
83
1cc6d956 84/* Mutator for the term height. */
c906108c 85void
dd1abb8c 86tui_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 93int
dd1abb8c 94tui_term_width (void)
c906108c 95{
6ba8e26f 96 return term_width;
dd1abb8c 97}
c906108c
SS
98
99
6ba8e26f 100/* Mutator for the term_width. */
c906108c 101void
dd1abb8c 102tui_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 110struct tui_win_info *
5b6fe301 111tui_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
b551a89f
TT
116 gdb_assert (cur_win->can_focus ());
117 /* This won't loop forever since we can't have just an un-focusable
118 window. */
119 while (true)
120 {
121 ++iter;
122 if (iter == tui_windows.end ())
123 iter = tui_windows.begin ();
124 if ((*iter)->can_focus ())
125 break;
126 }
127
eb9c8874 128 return *iter;
6ba8e26f 129}
c906108c
SS
130
131
dd1abb8c
AC
132/* Answer the prev window in the list, cycling back to the bottom if
133 necessary. */
2a8854a7 134struct tui_win_info *
5b6fe301 135tui_prev_win (struct tui_win_info *cur_win)
c906108c 136{
b551a89f
TT
137 auto iter = std::find (tui_windows.rbegin (), tui_windows.rend (), cur_win);
138 gdb_assert (iter != tui_windows.rend ());
139
140 gdb_assert (cur_win->can_focus ());
141 /* This won't loop forever since we can't have just an un-focusable
142 window. */
143 while (true)
144 {
145 ++iter;
146 if (iter == tui_windows.rend ())
147 iter = tui_windows.rbegin ();
148 if ((*iter)->can_focus ())
149 break;
150 }
c906108c 151
eb9c8874 152 return *iter;
cb50eddd 153}
c906108c
SS
154
155
3df505f6
TT
156void
157tui_win_info::rerender ()
158{
159 check_and_display_highlight_if_needed ();
160}
This page took 3.275288 seconds and 4 git commands to generate.