Remove m_has_locator
[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
c906108c
SS
30/****************************
31** GLOBAL DECLARATIONS
32****************************/
7fa29be9 33struct tui_win_info *tui_win_list[MAX_MAJOR_WINDOWS];
c906108c 34
c906108c
SS
35/***************************
36** Private data
37****************************/
6ba8e26f 38static int term_height, term_width;
e65b5245 39static struct tui_win_info *win_with_focus = NULL;
08ef48c5 40
6ba8e26f 41static int win_resized = FALSE;
c906108c
SS
42
43
c906108c
SS
44/*********************************
45** PUBLIC FUNCTIONS
46**********************************/
47
6d012f14 48int
6658b1bf 49tui_win_is_auxiliary (enum tui_win_type win_type)
6d012f14
AC
50{
51 return (win_type > MAX_MAJOR_WINDOWS);
52}
53
c906108c
SS
54/******************************************
55** ACCESSORS & MUTATORS FOR PRIVATE DATA
56******************************************/
57
1cc6d956 58/* Answer a whether the terminal window has been resized or not. */
c906108c 59int
dd1abb8c 60tui_win_resized (void)
c906108c 61{
6ba8e26f 62 return win_resized;
dd1abb8c 63}
c906108c
SS
64
65
1cc6d956 66/* Set a whether the terminal window has been resized or not. */
c906108c 67void
dd1abb8c 68tui_set_win_resized_to (int resized)
c906108c 69{
6ba8e26f 70 win_resized = resized;
dd1abb8c 71}
c906108c
SS
72
73
1cc6d956 74/* Answer the window with the logical focus. */
2a8854a7 75struct tui_win_info *
dd1abb8c 76tui_win_with_focus (void)
c906108c 77{
6ba8e26f 78 return win_with_focus;
dd1abb8c 79}
c906108c
SS
80
81
1cc6d956 82/* Set the window that has the logical focus. */
c906108c 83void
5b6fe301 84tui_set_win_with_focus (struct tui_win_info *win_info)
c906108c 85{
6ba8e26f 86 win_with_focus = win_info;
dd1abb8c 87}
c906108c
SS
88
89
ae2b5380 90/* Clear the pertinent detail in the source windows. */
c906108c 91void
b4eb2452 92tui_clear_source_windows_detail ()
c906108c 93{
ad54d15b 94 for (tui_source_window_base *win : tui_source_windows ())
7778b912 95 win->clear_detail ();
dd1abb8c 96}
c906108c
SS
97
98
6ba8e26f 99/* Accessor for the term_height. */
c906108c 100int
dd1abb8c 101tui_term_height (void)
c906108c 102{
6ba8e26f 103 return term_height;
dd1abb8c 104}
c906108c
SS
105
106
1cc6d956 107/* Mutator for the term height. */
c906108c 108void
dd1abb8c 109tui_set_term_height_to (int h)
c906108c 110{
6ba8e26f 111 term_height = h;
dd1abb8c 112}
c906108c
SS
113
114
1cc6d956 115/* Accessor for the term_width. */
c906108c 116int
dd1abb8c 117tui_term_width (void)
c906108c 118{
6ba8e26f 119 return term_width;
dd1abb8c 120}
c906108c
SS
121
122
6ba8e26f 123/* Mutator for the term_width. */
c906108c 124void
dd1abb8c 125tui_set_term_width_to (int w)
c906108c 126{
6ba8e26f 127 term_width = w;
dd1abb8c 128}
c906108c
SS
129
130
c906108c
SS
131/*****************************
132** OTHER PUBLIC FUNCTIONS
133*****************************/
134
135
dd1abb8c
AC
136/* Answer the next window in the list, cycling back to the top if
137 necessary. */
2a8854a7 138struct tui_win_info *
5b6fe301 139tui_next_win (struct tui_win_info *cur_win)
c906108c 140{
cb2ce893 141 int type = cur_win->type;
e65b5245 142 struct tui_win_info *next_win = NULL;
c906108c 143
cb2ce893 144 if (cur_win->type == CMD_WIN)
c906108c
SS
145 type = SRC_WIN;
146 else
cb2ce893
TT
147 type = cur_win->type + 1;
148 while (type != cur_win->type && (next_win == NULL))
c906108c 149 {
e5908723 150 if (tui_win_list[type]
cb2ce893 151 && tui_win_list[type]->is_visible)
6ba8e26f 152 next_win = tui_win_list[type];
c906108c
SS
153 else
154 {
155 if (type == CMD_WIN)
156 type = SRC_WIN;
157 else
158 type++;
159 }
160 }
161
6ba8e26f
AC
162 return next_win;
163}
c906108c
SS
164
165
dd1abb8c
AC
166/* Answer the prev window in the list, cycling back to the bottom if
167 necessary. */
2a8854a7 168struct tui_win_info *
5b6fe301 169tui_prev_win (struct tui_win_info *cur_win)
c906108c 170{
cb2ce893 171 int type = cur_win->type;
e65b5245 172 struct tui_win_info *prev = NULL;
c906108c 173
cb2ce893 174 if (cur_win->type == SRC_WIN)
c906108c
SS
175 type = CMD_WIN;
176 else
cb2ce893
TT
177 type = cur_win->type - 1;
178 while (type != cur_win->type && (prev == NULL))
c906108c 179 {
37715c4c 180 if (tui_win_list[type]
cb2ce893 181 && tui_win_list[type]->is_visible)
6d012f14 182 prev = tui_win_list[type];
c906108c
SS
183 else
184 {
185 if (type == SRC_WIN)
186 type = CMD_WIN;
187 else
188 type--;
189 }
190 }
191
192 return prev;
cb50eddd 193}
c906108c
SS
194
195
1cc6d956 196/* Answer the window represented by name. */
2a8854a7 197struct tui_win_info *
a121b7c1 198tui_partial_win_by_name (const char *name)
c906108c 199{
63a33118 200 if (name != NULL)
c906108c 201 {
1ce3e844 202 for (tui_win_info *item : all_tui_windows ())
c906108c 203 {
1ce3e844
TT
204 const char *cur_name = item->name ();
205
206 if (strlen (name) <= strlen (cur_name)
207 && startswith (cur_name, name))
208 return item;
c906108c
SS
209 }
210 }
211
1ce3e844 212 return NULL;
6ba8e26f 213}
c906108c 214
fede5273
TT
215/* See tui-data.h. */
216
217void
218tui_delete_invisible_windows ()
219{
220 for (int win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++)
221 {
222 if (tui_win_list[win_type] != NULL
223 && !tui_win_list[win_type]->is_visible)
224 {
225 /* This should always be made visible before a call to this
226 function. */
227 gdb_assert (win_type != CMD_WIN);
228
229 if (win_with_focus == tui_win_list[win_type])
230 win_with_focus = nullptr;
231
232 delete tui_win_list[win_type];
233 tui_win_list[win_type] = NULL;
234 }
235 }
236}
c906108c 237
33b906ab 238tui_win_info::tui_win_info (enum tui_win_type type)
cb2ce893 239 : tui_gen_win_info (type)
c906108c 240{
6ba8e26f 241}
c906108c 242
f936bca2 243tui_gen_win_info::~tui_gen_win_info ()
c906108c 244{
c2fc64f5 245 tui_delete_win (handle);
f936bca2
TT
246 xfree (title);
247}
3df505f6
TT
248
249void
250tui_win_info::rerender ()
251{
252 check_and_display_highlight_if_needed ();
253}
This page took 2.479208 seconds and 4 git commands to generate.