1 /* TUI data manipulation routines.
3 Copyright (C) 1998-2019 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-wingeneral.h"
27 #include "tui/tui-winsource.h"
28 #include "gdb_curses.h"
30 /****************************
31 ** GLOBAL DECLARATIONS
32 ****************************/
33 struct tui_win_info
*tui_win_list
[MAX_MAJOR_WINDOWS
];
35 /***************************
37 ****************************/
38 static int term_height
, term_width
;
39 static struct tui_win_info
*win_with_focus
= NULL
;
41 static int win_resized
= FALSE
;
44 /*********************************
46 **********************************/
49 tui_win_is_auxiliary (enum tui_win_type win_type
)
51 return (win_type
> MAX_MAJOR_WINDOWS
);
54 /******************************************
55 ** ACCESSORS & MUTATORS FOR PRIVATE DATA
56 ******************************************/
58 /* Answer a whether the terminal window has been resized or not. */
60 tui_win_resized (void)
66 /* Set a whether the terminal window has been resized or not. */
68 tui_set_win_resized_to (int resized
)
70 win_resized
= resized
;
74 /* Answer the window with the logical focus. */
76 tui_win_with_focus (void)
78 return win_with_focus
;
82 /* Set the window that has the logical focus. */
84 tui_set_win_with_focus (struct tui_win_info
*win_info
)
86 win_with_focus
= win_info
;
90 /* Clear the pertinent detail in the source windows. */
92 tui_clear_source_windows_detail ()
94 for (tui_source_window_base
*win
: tui_source_windows ())
99 /* Accessor for the term_height. */
101 tui_term_height (void)
107 /* Mutator for the term height. */
109 tui_set_term_height_to (int h
)
115 /* Accessor for the term_width. */
117 tui_term_width (void)
123 /* Mutator for the term_width. */
125 tui_set_term_width_to (int w
)
131 /*****************************
132 ** OTHER PUBLIC FUNCTIONS
133 *****************************/
136 /* Answer the next window in the list, cycling back to the top if
138 struct tui_win_info
*
139 tui_next_win (struct tui_win_info
*cur_win
)
141 int type
= cur_win
->type
;
142 struct tui_win_info
*next_win
= NULL
;
144 if (cur_win
->type
== CMD_WIN
)
147 type
= cur_win
->type
+ 1;
148 while (type
!= cur_win
->type
&& (next_win
== NULL
))
150 if (tui_win_list
[type
]
151 && tui_win_list
[type
]->is_visible ())
152 next_win
= tui_win_list
[type
];
166 /* Answer the prev window in the list, cycling back to the bottom if
168 struct tui_win_info
*
169 tui_prev_win (struct tui_win_info
*cur_win
)
171 int type
= cur_win
->type
;
172 struct tui_win_info
*prev
= NULL
;
174 if (cur_win
->type
== SRC_WIN
)
177 type
= cur_win
->type
- 1;
178 while (type
!= cur_win
->type
&& (prev
== NULL
))
180 if (tui_win_list
[type
]
181 && tui_win_list
[type
]->is_visible ())
182 prev
= tui_win_list
[type
];
196 /* Answer the window represented by name. */
197 struct tui_win_info
*
198 tui_partial_win_by_name (const char *name
)
202 for (tui_win_info
*item
: all_tui_windows ())
204 const char *cur_name
= item
->name ();
206 if (strlen (name
) <= strlen (cur_name
)
207 && startswith (cur_name
, name
))
215 /* See tui-data.h. */
218 tui_delete_invisible_windows ()
220 for (int win_type
= SRC_WIN
; (win_type
< MAX_MAJOR_WINDOWS
); win_type
++)
222 if (tui_win_list
[win_type
] != NULL
223 && !tui_win_list
[win_type
]->is_visible ())
225 /* This should always be made visible before a call to this
227 gdb_assert (win_type
!= CMD_WIN
);
229 if (win_with_focus
== tui_win_list
[win_type
])
230 win_with_focus
= nullptr;
232 delete tui_win_list
[win_type
];
233 tui_win_list
[win_type
] = NULL
;
238 tui_win_info::tui_win_info (enum tui_win_type type
)
239 : tui_gen_win_info (type
)
243 tui_gen_win_info::~tui_gen_win_info ()
245 tui_delete_win (handle
);
249 tui_win_info::rerender ()
251 check_and_display_highlight_if_needed ();
This page took 0.045337 seconds and 4 git commands to generate.