i386: Align branches within a fixed boundary
[deliverable/binutils-gdb.git] / gdb / tui / tui-data.c
CommitLineData
f377b406 1/* TUI data manipulation routines.
f33c6cbf 2
42a4f53d 3 Copyright (C) 1998-2019 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"
4e8f7a8b 29
7fa29be9 30struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
c906108c 31
6ba8e26f 32static int term_height, term_width;
e65b5245 33static struct tui_win_info *win_with_focus = NULL;
08ef48c5 34
9abd8a65 35static bool win_resized = false;
c906108c 36
1cc6d956 37/* Answer a whether the terminal window has been resized or not. */
9abd8a65
TT
38bool
39tui_win_resized ()
c906108c 40{
6ba8e26f 41 return win_resized;
dd1abb8c 42}
c906108c
SS
43
44
1cc6d956 45/* Set a whether the terminal window has been resized or not. */
c906108c 46void
9abd8a65 47tui_set_win_resized_to (bool resized)
c906108c 48{
6ba8e26f 49 win_resized = resized;
dd1abb8c 50}
c906108c
SS
51
52
1cc6d956 53/* Answer the window with the logical focus. */
2a8854a7 54struct tui_win_info *
dd1abb8c 55tui_win_with_focus (void)
c906108c 56{
6ba8e26f 57 return win_with_focus;
dd1abb8c 58}
c906108c
SS
59
60
1cc6d956 61/* Set the window that has the logical focus. */
c906108c 62void
5b6fe301 63tui_set_win_with_focus (struct tui_win_info *win_info)
c906108c 64{
6ba8e26f 65 win_with_focus = win_info;
dd1abb8c 66}
c906108c
SS
67
68
6ba8e26f 69/* Accessor for the term_height. */
c906108c 70int
dd1abb8c 71tui_term_height (void)
c906108c 72{
6ba8e26f 73 return term_height;
dd1abb8c 74}
c906108c
SS
75
76
1cc6d956 77/* Mutator for the term height. */
c906108c 78void
dd1abb8c 79tui_set_term_height_to (int h)
c906108c 80{
6ba8e26f 81 term_height = h;
dd1abb8c 82}
c906108c
SS
83
84
1cc6d956 85/* Accessor for the term_width. */
c906108c 86int
dd1abb8c 87tui_term_width (void)
c906108c 88{
6ba8e26f 89 return term_width;
dd1abb8c 90}
c906108c
SS
91
92
6ba8e26f 93/* Mutator for the term_width. */
c906108c 94void
dd1abb8c 95tui_set_term_width_to (int w)
c906108c 96{
6ba8e26f 97 term_width = w;
dd1abb8c 98}
c906108c
SS
99
100
dd1abb8c
AC
101/* Answer the next window in the list, cycling back to the top if
102 necessary. */
2a8854a7 103struct tui_win_info *
5b6fe301 104tui_next_win (struct tui_win_info *cur_win)
c906108c 105{
cb2ce893 106 int type = cur_win->type;
e65b5245 107 struct tui_win_info *next_win = NULL;
c906108c 108
cb2ce893 109 if (cur_win->type == CMD_WIN)
c906108c
SS
110 type = SRC_WIN;
111 else
cb2ce893
TT
112 type = cur_win->type + 1;
113 while (type != cur_win->type && (next_win == NULL))
c906108c 114 {
e5908723 115 if (tui_win_list[type]
2d83e710 116 && tui_win_list[type]->is_visible ())
6ba8e26f 117 next_win = tui_win_list[type];
c906108c
SS
118 else
119 {
120 if (type == CMD_WIN)
121 type = SRC_WIN;
122 else
123 type++;
124 }
125 }
126
6ba8e26f
AC
127 return next_win;
128}
c906108c
SS
129
130
dd1abb8c
AC
131/* Answer the prev window in the list, cycling back to the bottom if
132 necessary. */
2a8854a7 133struct tui_win_info *
5b6fe301 134tui_prev_win (struct tui_win_info *cur_win)
c906108c 135{
cb2ce893 136 int type = cur_win->type;
e65b5245 137 struct tui_win_info *prev = NULL;
c906108c 138
cb2ce893 139 if (cur_win->type == SRC_WIN)
c906108c
SS
140 type = CMD_WIN;
141 else
cb2ce893
TT
142 type = cur_win->type - 1;
143 while (type != cur_win->type && (prev == NULL))
c906108c 144 {
37715c4c 145 if (tui_win_list[type]
2d83e710 146 && tui_win_list[type]->is_visible ())
6d012f14 147 prev = tui_win_list[type];
c906108c
SS
148 else
149 {
150 if (type == SRC_WIN)
151 type = CMD_WIN;
152 else
153 type--;
154 }
155 }
156
157 return prev;
cb50eddd 158}
c906108c
SS
159
160
fede5273
TT
161/* See tui-data.h. */
162
163void
164tui_delete_invisible_windows ()
165{
166 for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
167 {
168 if (tui_win_list[win_type] != NULL
2d83e710 169 && !tui_win_list[win_type]->is_visible ())
fede5273
TT
170 {
171 /* This should always be made visible before a call to this
172 function. */
173 gdb_assert (win_type != CMD_WIN);
174
175 if (win_with_focus == tui_win_list[win_type])
176 win_with_focus = nullptr;
177
178 delete tui_win_list[win_type];
179 tui_win_list[win_type] = NULL;
180 }
181 }
182}
c906108c 183
33b906ab 184tui_win_info::tui_win_info (enum tui_win_type type)
cb2ce893 185 : tui_gen_win_info (type)
c906108c 186{
6ba8e26f 187}
c906108c 188
3df505f6
TT
189void
190tui_win_info::rerender ()
191{
192 check_and_display_highlight_if_needed ();
193}
This page took 2.077096 seconds and 4 git commands to generate.