Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* TUI window generic functions. |
f33c6cbf | 2 | |
42a4f53d | 3 | Copyright (C) 1998-2019 Free Software Foundation, Inc. |
f33c6cbf | 4 | |
f377b406 | 5 | Contributed by Hewlett-Packard Company. |
c906108c | 6 | |
f377b406 SC |
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/>. */ |
f377b406 SC |
21 | |
22 | /* This module contains procedures for handling tui window functions | |
23 | like resize, scrolling, scrolling, changing focus, etc. | |
24 | ||
25 | Author: Susan B. Macchia */ | |
c906108c | 26 | |
c906108c SS |
27 | #include "defs.h" |
28 | #include "command.h" | |
29 | #include "symtab.h" | |
30 | #include "breakpoint.h" | |
31 | #include "frame.h" | |
41783295 | 32 | #include "cli/cli-cmds.h" |
3e752b04 | 33 | #include "top.h" |
52575520 | 34 | #include "source.h" |
c4ef48c6 | 35 | #include "event-loop.h" |
c906108c | 36 | |
d7b2e967 | 37 | #include "tui/tui.h" |
c4ef48c6 | 38 | #include "tui/tui-io.h" |
d7b2e967 AC |
39 | #include "tui/tui-data.h" |
40 | #include "tui/tui-wingeneral.h" | |
41 | #include "tui/tui-stack.h" | |
42 | #include "tui/tui-regs.h" | |
43 | #include "tui/tui-disasm.h" | |
44 | #include "tui/tui-source.h" | |
45 | #include "tui/tui-winsource.h" | |
46 | #include "tui/tui-windata.h" | |
2c0b251b | 47 | #include "tui/tui-win.h" |
c906108c | 48 | |
6a83354a | 49 | #include "gdb_curses.h" |
96ec9981 | 50 | #include <ctype.h> |
dbda9972 | 51 | #include "readline/readline.h" |
96ec9981 | 52 | |
9612b5ec UW |
53 | #include <signal.h> |
54 | ||
c906108c SS |
55 | /******************************* |
56 | ** Static Local Decls | |
57 | ********************************/ | |
08ef48c5 MS |
58 | static void make_invisible_and_set_new_height (struct tui_win_info *, |
59 | int); | |
60 | static enum tui_status tui_adjust_win_heights (struct tui_win_info *, | |
61 | int); | |
6ba8e26f | 62 | static int new_height_ok (struct tui_win_info *, int); |
0b39b52e TT |
63 | static void tui_set_tab_width_command (const char *, int); |
64 | static void tui_refresh_all_command (const char *, int); | |
1d12d88f | 65 | static void tui_all_windows_info (const char *, int); |
0b39b52e TT |
66 | static void tui_scroll_forward_command (const char *, int); |
67 | static void tui_scroll_backward_command (const char *, int); | |
68 | static void tui_scroll_left_command (const char *, int); | |
69 | static void tui_scroll_right_command (const char *, int); | |
70 | static void parse_scrolling_args (const char *, | |
08ef48c5 MS |
71 | struct tui_win_info **, |
72 | int *); | |
c906108c SS |
73 | |
74 | ||
75 | /*************************************** | |
76 | ** DEFINITIONS | |
77 | ***************************************/ | |
57dbb3af | 78 | #define WIN_HEIGHT_USAGE "Usage: winheight WINDOW-NAME [+ | -] NUM-LINES\n" |
bf212be1 | 79 | #define FOCUS_USAGE "Usage: focus [WINDOW-NAME | next | prev]\n" |
c906108c SS |
80 | |
81 | /*************************************** | |
82 | ** PUBLIC FUNCTIONS | |
83 | ***************************************/ | |
84 | ||
17aae570 SC |
85 | #ifndef ACS_LRCORNER |
86 | # define ACS_LRCORNER '+' | |
87 | #endif | |
88 | #ifndef ACS_LLCORNER | |
89 | # define ACS_LLCORNER '+' | |
90 | #endif | |
91 | #ifndef ACS_ULCORNER | |
92 | # define ACS_ULCORNER '+' | |
93 | #endif | |
94 | #ifndef ACS_URCORNER | |
95 | # define ACS_URCORNER '+' | |
96 | #endif | |
97 | #ifndef ACS_HLINE | |
98 | # define ACS_HLINE '-' | |
99 | #endif | |
100 | #ifndef ACS_VLINE | |
101 | # define ACS_VLINE '|' | |
102 | #endif | |
103 | ||
af101512 | 104 | /* Possible values for tui-border-kind variable. */ |
40478521 | 105 | static const char *const tui_border_kind_enums[] = { |
af101512 SC |
106 | "space", |
107 | "ascii", | |
108 | "acs", | |
109 | NULL | |
110 | }; | |
111 | ||
112 | /* Possible values for tui-border-mode and tui-active-border-mode. */ | |
40478521 | 113 | static const char *const tui_border_mode_enums[] = { |
af101512 SC |
114 | "normal", |
115 | "standout", | |
116 | "reverse", | |
117 | "half", | |
118 | "half-standout", | |
119 | "bold", | |
120 | "bold-standout", | |
121 | NULL | |
122 | }; | |
123 | ||
124 | struct tui_translate | |
125 | { | |
126 | const char *name; | |
127 | int value; | |
128 | }; | |
129 | ||
130 | /* Translation table for border-mode variables. | |
131 | The list of values must be terminated by a NULL. | |
132 | After the NULL value, an entry defines the default. */ | |
133 | struct tui_translate tui_border_mode_translate[] = { | |
134 | { "normal", A_NORMAL }, | |
135 | { "standout", A_STANDOUT }, | |
136 | { "reverse", A_REVERSE }, | |
137 | { "half", A_DIM }, | |
138 | { "half-standout", A_DIM | A_STANDOUT }, | |
139 | { "bold", A_BOLD }, | |
140 | { "bold-standout", A_BOLD | A_STANDOUT }, | |
141 | { 0, 0 }, | |
142 | { "normal", A_NORMAL } | |
143 | }; | |
144 | ||
145 | /* Translation tables for border-kind, one for each border | |
146 | character (see wborder, border curses operations). | |
147 | -1 is used to indicate the ACS because ACS characters | |
148 | are determined at run time by curses (depends on terminal). */ | |
149 | struct tui_translate tui_border_kind_translate_vline[] = { | |
150 | { "space", ' ' }, | |
151 | { "ascii", '|' }, | |
152 | { "acs", -1 }, | |
153 | { 0, 0 }, | |
154 | { "ascii", '|' } | |
155 | }; | |
156 | ||
157 | struct tui_translate tui_border_kind_translate_hline[] = { | |
158 | { "space", ' ' }, | |
159 | { "ascii", '-' }, | |
160 | { "acs", -1 }, | |
161 | { 0, 0 }, | |
162 | { "ascii", '-' } | |
163 | }; | |
164 | ||
165 | struct tui_translate tui_border_kind_translate_ulcorner[] = { | |
166 | { "space", ' ' }, | |
167 | { "ascii", '+' }, | |
168 | { "acs", -1 }, | |
169 | { 0, 0 }, | |
170 | { "ascii", '+' } | |
171 | }; | |
172 | ||
173 | struct tui_translate tui_border_kind_translate_urcorner[] = { | |
174 | { "space", ' ' }, | |
175 | { "ascii", '+' }, | |
176 | { "acs", -1 }, | |
177 | { 0, 0 }, | |
178 | { "ascii", '+' } | |
179 | }; | |
180 | ||
181 | struct tui_translate tui_border_kind_translate_llcorner[] = { | |
182 | { "space", ' ' }, | |
183 | { "ascii", '+' }, | |
184 | { "acs", -1 }, | |
185 | { 0, 0 }, | |
186 | { "ascii", '+' } | |
187 | }; | |
188 | ||
189 | struct tui_translate tui_border_kind_translate_lrcorner[] = { | |
190 | { "space", ' ' }, | |
191 | { "ascii", '+' }, | |
192 | { "acs", -1 }, | |
193 | { 0, 0 }, | |
194 | { "ascii", '+' } | |
195 | }; | |
196 | ||
197 | ||
198 | /* Tui configuration variables controlled with set/show command. */ | |
199 | const char *tui_active_border_mode = "bold-standout"; | |
920d2a44 | 200 | static void |
08ef48c5 MS |
201 | show_tui_active_border_mode (struct ui_file *file, |
202 | int from_tty, | |
203 | struct cmd_list_element *c, | |
204 | const char *value) | |
920d2a44 AC |
205 | { |
206 | fprintf_filtered (file, _("\ | |
207 | The attribute mode to use for the active TUI window border is \"%s\".\n"), | |
208 | value); | |
209 | } | |
210 | ||
af101512 | 211 | const char *tui_border_mode = "normal"; |
920d2a44 | 212 | static void |
08ef48c5 MS |
213 | show_tui_border_mode (struct ui_file *file, |
214 | int from_tty, | |
215 | struct cmd_list_element *c, | |
216 | const char *value) | |
920d2a44 AC |
217 | { |
218 | fprintf_filtered (file, _("\ | |
219 | The attribute mode to use for the TUI window borders is \"%s\".\n"), | |
220 | value); | |
221 | } | |
222 | ||
af101512 | 223 | const char *tui_border_kind = "acs"; |
920d2a44 | 224 | static void |
08ef48c5 MS |
225 | show_tui_border_kind (struct ui_file *file, |
226 | int from_tty, | |
227 | struct cmd_list_element *c, | |
228 | const char *value) | |
920d2a44 AC |
229 | { |
230 | fprintf_filtered (file, _("The kind of border for TUI windows is \"%s\".\n"), | |
231 | value); | |
232 | } | |
233 | ||
af101512 | 234 | |
1cc6d956 MS |
235 | /* Tui internal configuration variables. These variables are updated |
236 | by tui_update_variables to reflect the tui configuration | |
af101512 SC |
237 | variables. */ |
238 | chtype tui_border_vline; | |
239 | chtype tui_border_hline; | |
240 | chtype tui_border_ulcorner; | |
241 | chtype tui_border_urcorner; | |
242 | chtype tui_border_llcorner; | |
243 | chtype tui_border_lrcorner; | |
244 | ||
245 | int tui_border_attrs; | |
246 | int tui_active_border_attrs; | |
247 | ||
248 | /* Identify the item in the translation table. | |
249 | When the item is not recognized, use the default entry. */ | |
250 | static struct tui_translate * | |
251 | translate (const char *name, struct tui_translate *table) | |
252 | { | |
253 | while (table->name) | |
254 | { | |
255 | if (name && strcmp (table->name, name) == 0) | |
256 | return table; | |
257 | table++; | |
258 | } | |
259 | ||
260 | /* Not found, return default entry. */ | |
261 | table++; | |
262 | return table; | |
263 | } | |
264 | ||
265 | /* Update the tui internal configuration according to gdb settings. | |
266 | Returns 1 if the configuration has changed and the screen should | |
267 | be redrawn. */ | |
268 | int | |
d02c80cd | 269 | tui_update_variables (void) |
af101512 SC |
270 | { |
271 | int need_redraw = 0; | |
272 | struct tui_translate *entry; | |
273 | ||
274 | entry = translate (tui_border_mode, tui_border_mode_translate); | |
275 | if (tui_border_attrs != entry->value) | |
276 | { | |
277 | tui_border_attrs = entry->value; | |
278 | need_redraw = 1; | |
279 | } | |
280 | entry = translate (tui_active_border_mode, tui_border_mode_translate); | |
281 | if (tui_active_border_attrs != entry->value) | |
282 | { | |
283 | tui_active_border_attrs = entry->value; | |
284 | need_redraw = 1; | |
285 | } | |
286 | ||
287 | /* If one corner changes, all characters are changed. | |
288 | Only check the first one. The ACS characters are determined at | |
289 | run time by curses terminal management. */ | |
290 | entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner); | |
291 | if (tui_border_lrcorner != (chtype) entry->value) | |
292 | { | |
293 | tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value; | |
294 | need_redraw = 1; | |
295 | } | |
296 | entry = translate (tui_border_kind, tui_border_kind_translate_llcorner); | |
297 | tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value; | |
298 | ||
299 | entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner); | |
300 | tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value; | |
301 | ||
302 | entry = translate (tui_border_kind, tui_border_kind_translate_urcorner); | |
303 | tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value; | |
304 | ||
305 | entry = translate (tui_border_kind, tui_border_kind_translate_hline); | |
306 | tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value; | |
307 | ||
308 | entry = translate (tui_border_kind, tui_border_kind_translate_vline); | |
309 | tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value; | |
310 | ||
311 | return need_redraw; | |
312 | } | |
313 | ||
c9684879 | 314 | static void |
981a3fb3 | 315 | set_tui_cmd (const char *args, int from_tty) |
c9684879 SC |
316 | { |
317 | } | |
318 | ||
319 | static void | |
981a3fb3 | 320 | show_tui_cmd (const char *args, int from_tty) |
c9684879 SC |
321 | { |
322 | } | |
af101512 | 323 | |
10f59415 SC |
324 | static struct cmd_list_element *tuilist; |
325 | ||
326 | static void | |
981a3fb3 | 327 | tui_command (const char *args, int from_tty) |
10f59415 | 328 | { |
a3f17187 AC |
329 | printf_unfiltered (_("\"tui\" must be followed by the name of a " |
330 | "tui command.\n")); | |
635c7e8a | 331 | help_list (tuilist, "tui ", all_commands, gdb_stdout); |
10f59415 SC |
332 | } |
333 | ||
334 | struct cmd_list_element ** | |
da745b36 | 335 | tui_get_cmd_list (void) |
10f59415 SC |
336 | { |
337 | if (tuilist == 0) | |
338 | add_prefix_cmd ("tui", class_tui, tui_command, | |
1bedd215 | 339 | _("Text User Interface commands."), |
10f59415 SC |
340 | &tuilist, "tui ", 0, &cmdlist); |
341 | return &tuilist; | |
342 | } | |
343 | ||
6cdb25f4 EZ |
344 | /* The set_func hook of "set tui ..." commands that affect the window |
345 | borders on the TUI display. */ | |
346 | void | |
eb4c3f4a TT |
347 | tui_set_var_cmd (const char *null_args, |
348 | int from_tty, struct cmd_list_element *c) | |
6cdb25f4 EZ |
349 | { |
350 | if (tui_update_variables () && tui_active) | |
351 | tui_rehighlight_all (); | |
352 | } | |
353 | ||
97605e61 AB |
354 | /* Generic window name completion function. Complete window name pointed |
355 | to by TEXT and WORD. If INCLUDE_NEXT_PREV_P is true then the special | |
356 | window names 'next' and 'prev' will also be considered as possible | |
357 | completions of the window name. */ | |
2e52ae68 | 358 | |
eb3ff9a5 PA |
359 | static void |
360 | window_name_completer (completion_tracker &tracker, | |
361 | int include_next_prev_p, | |
97605e61 | 362 | const char *text, const char *word) |
2e52ae68 | 363 | { |
625ad440 | 364 | std::vector<const char *> completion_name_vec; |
2e52ae68 | 365 | |
1ce3e844 | 366 | for (tui_win_info *win_info : all_tui_windows ()) |
2e52ae68 PP |
367 | { |
368 | const char *completion_name = NULL; | |
369 | ||
370 | /* We can't focus on an invisible window. */ | |
1ce3e844 | 371 | if (!win_info->is_visible) |
2e52ae68 PP |
372 | continue; |
373 | ||
1ce3e844 | 374 | completion_name = win_info->name (); |
150375dc | 375 | gdb_assert (completion_name != NULL); |
625ad440 | 376 | completion_name_vec.push_back (completion_name); |
2e52ae68 PP |
377 | } |
378 | ||
379 | /* If no windows are considered visible then the TUI has not yet been | |
380 | initialized. But still "focus src" and "focus cmd" will work because | |
381 | invoking the focus command will entail initializing the TUI which sets the | |
382 | default layout to SRC_COMMAND. */ | |
625ad440 | 383 | if (completion_name_vec.empty ()) |
2e52ae68 | 384 | { |
625ad440 SM |
385 | completion_name_vec.push_back (SRC_NAME); |
386 | completion_name_vec.push_back (CMD_NAME); | |
2e52ae68 PP |
387 | } |
388 | ||
97605e61 AB |
389 | if (include_next_prev_p) |
390 | { | |
625ad440 SM |
391 | completion_name_vec.push_back ("next"); |
392 | completion_name_vec.push_back ("prev"); | |
97605e61 | 393 | } |
2e52ae68 | 394 | |
2e52ae68 | 395 | |
625ad440 SM |
396 | completion_name_vec.push_back (NULL); |
397 | complete_on_enum (tracker, completion_name_vec.data (), text, word); | |
2e52ae68 PP |
398 | } |
399 | ||
97605e61 AB |
400 | /* Complete possible window names to focus on. TEXT is the complete text |
401 | entered so far, WORD is the word currently being completed. */ | |
402 | ||
eb3ff9a5 | 403 | static void |
97605e61 | 404 | focus_completer (struct cmd_list_element *ignore, |
eb3ff9a5 PA |
405 | completion_tracker &tracker, |
406 | const char *text, const char *word) | |
97605e61 | 407 | { |
eb3ff9a5 | 408 | window_name_completer (tracker, 1, text, word); |
97605e61 AB |
409 | } |
410 | ||
411 | /* Complete possible window names for winheight command. TEXT is the | |
412 | complete text entered so far, WORD is the word currently being | |
413 | completed. */ | |
414 | ||
eb3ff9a5 | 415 | static void |
97605e61 | 416 | winheight_completer (struct cmd_list_element *ignore, |
eb3ff9a5 | 417 | completion_tracker &tracker, |
97605e61 AB |
418 | const char *text, const char *word) |
419 | { | |
420 | /* The first word is the window name. That we can complete. Subsequent | |
421 | words can't be completed. */ | |
422 | if (word != text) | |
eb3ff9a5 | 423 | return; |
97605e61 | 424 | |
eb3ff9a5 | 425 | window_name_completer (tracker, 0, text, word); |
97605e61 AB |
426 | } |
427 | ||
3e752b04 SC |
428 | /* Update gdb's knowledge of the terminal size. */ |
429 | void | |
d02c80cd | 430 | tui_update_gdb_sizes (void) |
3e752b04 | 431 | { |
d6e5e7f7 PP |
432 | int width, height; |
433 | ||
434 | if (tui_active) | |
435 | { | |
cb2ce893 TT |
436 | width = TUI_CMD_WIN->width; |
437 | height = TUI_CMD_WIN->height; | |
d6e5e7f7 PP |
438 | } |
439 | else | |
440 | { | |
441 | width = tui_term_width (); | |
442 | height = tui_term_height (); | |
443 | } | |
444 | ||
445 | set_screen_width_and_height (width, height); | |
3e752b04 SC |
446 | } |
447 | ||
c906108c | 448 | |
1cc6d956 | 449 | /* Set the logical focus to win_info. */ |
c906108c | 450 | void |
5b6fe301 | 451 | tui_set_win_focus_to (struct tui_win_info *win_info) |
c906108c | 452 | { |
6d012f14 | 453 | if (win_info != NULL) |
c906108c | 454 | { |
5b6fe301 | 455 | struct tui_win_info *win_with_focus = tui_win_with_focus (); |
c906108c | 456 | |
bbc228ee | 457 | tui_unhighlight_win (win_with_focus); |
6d012f14 | 458 | tui_set_win_with_focus (win_info); |
bbc228ee | 459 | tui_highlight_win (win_info); |
c906108c | 460 | } |
6ba8e26f | 461 | } |
c906108c SS |
462 | |
463 | ||
c906108c | 464 | void |
13446e05 | 465 | tui_win_info::forward_scroll (int num_to_scroll) |
c906108c | 466 | { |
13446e05 | 467 | if (num_to_scroll == 0) |
cb2ce893 | 468 | num_to_scroll = height - 3; |
c906108c | 469 | |
c3bd716f | 470 | do_scroll_vertical (num_to_scroll); |
a21fcd8f | 471 | } |
c906108c | 472 | |
c906108c | 473 | void |
13446e05 | 474 | tui_win_info::backward_scroll (int num_to_scroll) |
c906108c | 475 | { |
13446e05 | 476 | if (num_to_scroll == 0) |
cb2ce893 | 477 | num_to_scroll = height - 3; |
13446e05 | 478 | |
c3bd716f | 479 | do_scroll_vertical (-num_to_scroll); |
a21fcd8f | 480 | } |
c906108c SS |
481 | |
482 | ||
c906108c | 483 | void |
13446e05 | 484 | tui_win_info::left_scroll (int num_to_scroll) |
c906108c | 485 | { |
13446e05 TT |
486 | if (num_to_scroll == 0) |
487 | num_to_scroll = 1; | |
488 | ||
c3bd716f | 489 | do_scroll_horizontal (num_to_scroll); |
a21fcd8f | 490 | } |
c906108c SS |
491 | |
492 | ||
c906108c | 493 | void |
13446e05 | 494 | tui_win_info::right_scroll (int num_to_scroll) |
c906108c | 495 | { |
13446e05 TT |
496 | if (num_to_scroll == 0) |
497 | num_to_scroll = 1; | |
498 | ||
c3bd716f | 499 | do_scroll_horizontal (-num_to_scroll); |
e8b915dc | 500 | } |
c906108c SS |
501 | |
502 | ||
1825f487 TT |
503 | /* See tui-data.h. */ |
504 | ||
505 | void | |
506 | tui_source_window_base::refresh_all () | |
507 | { | |
508 | tui_show_source_content (this); | |
509 | tui_check_and_display_highlight_if_needed (this); | |
510 | tui_erase_exec_info_content (this); | |
511 | tui_update_exec_info (this); | |
512 | } | |
513 | ||
c906108c | 514 | void |
a21fcd8f | 515 | tui_refresh_all_win (void) |
c906108c | 516 | { |
3e266828 | 517 | clearok (curscr, TRUE); |
1ce3e844 TT |
518 | tui_refresh_all (); |
519 | for (tui_win_info *win_info : all_tui_windows ()) | |
c906108c | 520 | { |
1ce3e844 TT |
521 | if (win_info->is_visible) |
522 | win_info->refresh_all (); | |
c906108c | 523 | } |
47d3492a | 524 | tui_show_locator_content (); |
bc712bbf | 525 | } |
c906108c | 526 | |
6cdb25f4 EZ |
527 | void |
528 | tui_rehighlight_all (void) | |
529 | { | |
1ce3e844 TT |
530 | for (tui_win_info *win_info : all_tui_windows ()) |
531 | tui_check_and_display_highlight_if_needed (win_info); | |
6cdb25f4 | 532 | } |
c906108c | 533 | |
b021a221 | 534 | /* Resize all the windows based on the terminal size. This function |
ae2b5380 | 535 | gets called from within the readline SIGWINCH handler. */ |
c906108c | 536 | void |
6ba8e26f | 537 | tui_resize_all (void) |
c906108c | 538 | { |
6ba8e26f | 539 | int height_diff, width_diff; |
9255ee31 | 540 | int screenheight, screenwidth; |
c906108c | 541 | |
9255ee31 | 542 | rl_get_screen_size (&screenheight, &screenwidth); |
6ba8e26f AC |
543 | width_diff = screenwidth - tui_term_width (); |
544 | height_diff = screenheight - tui_term_height (); | |
545 | if (height_diff || width_diff) | |
c906108c | 546 | { |
6ba8e26f | 547 | enum tui_layout_type cur_layout = tui_current_layout (); |
5b6fe301 | 548 | struct tui_win_info *win_with_focus = tui_win_with_focus (); |
6ba8e26f AC |
549 | struct tui_win_info *first_win; |
550 | struct tui_win_info *second_win; | |
7908abbf | 551 | tui_source_window_base *src_win; |
3add462f | 552 | struct tui_locator_window *locator = tui_locator_win_info_ptr (); |
570dc176 | 553 | int win_type; |
6ba8e26f | 554 | int new_height, split_diff, cmd_split_diff, num_wins_displayed = 2; |
c906108c | 555 | |
10f59415 SC |
556 | #ifdef HAVE_RESIZE_TERM |
557 | resize_term (screenheight, screenwidth); | |
558 | #endif | |
1cc6d956 | 559 | /* Turn keypad off while we resize. */ |
6ba8e26f | 560 | if (win_with_focus != TUI_CMD_WIN) |
cb2ce893 | 561 | keypad (TUI_CMD_WIN->handle, FALSE); |
3e752b04 | 562 | tui_update_gdb_sizes (); |
dd1abb8c AC |
563 | tui_set_term_height_to (screenheight); |
564 | tui_set_term_width_to (screenwidth); | |
e5908723 MS |
565 | if (cur_layout == SRC_DISASSEM_COMMAND |
566 | || cur_layout == SRC_DATA_COMMAND | |
567 | || cur_layout == DISASSEM_DATA_COMMAND) | |
6ba8e26f AC |
568 | num_wins_displayed++; |
569 | split_diff = height_diff / num_wins_displayed; | |
570 | cmd_split_diff = split_diff; | |
571 | if (height_diff % num_wins_displayed) | |
c906108c | 572 | { |
6ba8e26f AC |
573 | if (height_diff < 0) |
574 | cmd_split_diff--; | |
c906108c | 575 | else |
c366c1f0 TT |
576 | cmd_split_diff++; |
577 | } | |
1cc6d956 | 578 | /* Now adjust each window. */ |
c366c1f0 TT |
579 | /* erase + clearok are used instead of a straightforward clear as |
580 | AIX 5.3 does not define clear. */ | |
581 | erase (); | |
582 | clearok (curscr, TRUE); | |
c906108c | 583 | refresh (); |
6ba8e26f | 584 | switch (cur_layout) |
c366c1f0 | 585 | { |
c906108c SS |
586 | case SRC_COMMAND: |
587 | case DISASSEM_COMMAND: | |
7908abbf TT |
588 | src_win = tui_source_windows ()[0]; |
589 | first_win = src_win; | |
cb2ce893 | 590 | first_win->width += width_diff; |
6ba8e26f | 591 | locator->width += width_diff; |
1cc6d956 | 592 | /* Check for invalid heights. */ |
6ba8e26f | 593 | if (height_diff == 0) |
cb2ce893 TT |
594 | new_height = first_win->height; |
595 | else if ((first_win->height + split_diff) >= | |
c906108c | 596 | (screenheight - MIN_CMD_WIN_HEIGHT - 1)) |
6ba8e26f | 597 | new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1; |
cb2ce893 | 598 | else if ((first_win->height + split_diff) <= 0) |
6ba8e26f | 599 | new_height = MIN_WIN_HEIGHT; |
c906108c | 600 | else |
cb2ce893 | 601 | new_height = first_win->height + split_diff; |
c906108c | 602 | |
0036e657 | 603 | locator->origin.y = new_height + 1; |
6ba8e26f | 604 | make_invisible_and_set_new_height (first_win, new_height); |
cb2ce893 TT |
605 | TUI_CMD_WIN->origin.y = locator->origin.y + 1; |
606 | TUI_CMD_WIN->width += width_diff; | |
607 | new_height = screenheight - TUI_CMD_WIN->origin.y; | |
6ba8e26f | 608 | make_invisible_and_set_new_height (TUI_CMD_WIN, new_height); |
5fcee43a TT |
609 | first_win->make_visible_with_new_height (); |
610 | TUI_CMD_WIN->make_visible_with_new_height (); | |
53e7cdba | 611 | if (src_win->content.empty ()) |
caf0bc4e | 612 | tui_erase_source_content (src_win); |
c906108c SS |
613 | break; |
614 | default: | |
6ba8e26f | 615 | if (cur_layout == SRC_DISASSEM_COMMAND) |
c906108c | 616 | { |
7908abbf TT |
617 | src_win = TUI_SRC_WIN; |
618 | first_win = src_win; | |
cb2ce893 | 619 | first_win->width += width_diff; |
6ba8e26f | 620 | second_win = TUI_DISASM_WIN; |
cb2ce893 | 621 | second_win->width += width_diff; |
c906108c SS |
622 | } |
623 | else | |
624 | { | |
6ba8e26f | 625 | first_win = TUI_DATA_WIN; |
cb2ce893 | 626 | first_win->width += width_diff; |
7908abbf TT |
627 | src_win = tui_source_windows ()[0]; |
628 | second_win = src_win; | |
cb2ce893 | 629 | second_win->width += width_diff; |
c906108c | 630 | } |
1cc6d956 MS |
631 | /* Change the first window's height/width. */ |
632 | /* Check for invalid heights. */ | |
6ba8e26f | 633 | if (height_diff == 0) |
cb2ce893 TT |
634 | new_height = first_win->height; |
635 | else if ((first_win->height + | |
636 | second_win->height + (split_diff * 2)) >= | |
c906108c | 637 | (screenheight - MIN_CMD_WIN_HEIGHT - 1)) |
6ba8e26f | 638 | new_height = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2; |
cb2ce893 | 639 | else if ((first_win->height + split_diff) <= 0) |
6ba8e26f | 640 | new_height = MIN_WIN_HEIGHT; |
c906108c | 641 | else |
cb2ce893 | 642 | new_height = first_win->height + split_diff; |
6ba8e26f | 643 | make_invisible_and_set_new_height (first_win, new_height); |
c906108c | 644 | |
6ba8e26f | 645 | locator->width += width_diff; |
c906108c | 646 | |
1cc6d956 MS |
647 | /* Change the second window's height/width. */ |
648 | /* Check for invalid heights. */ | |
6ba8e26f | 649 | if (height_diff == 0) |
cb2ce893 TT |
650 | new_height = second_win->height; |
651 | else if ((first_win->height + | |
652 | second_win->height + (split_diff * 2)) >= | |
c906108c SS |
653 | (screenheight - MIN_CMD_WIN_HEIGHT - 1)) |
654 | { | |
6ba8e26f AC |
655 | new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1; |
656 | if (new_height % 2) | |
657 | new_height = (new_height / 2) + 1; | |
c906108c | 658 | else |
6ba8e26f | 659 | new_height /= 2; |
c906108c | 660 | } |
cb2ce893 | 661 | else if ((second_win->height + split_diff) <= 0) |
6ba8e26f | 662 | new_height = MIN_WIN_HEIGHT; |
c906108c | 663 | else |
cb2ce893 TT |
664 | new_height = second_win->height + split_diff; |
665 | second_win->origin.y = first_win->height - 1; | |
6ba8e26f | 666 | make_invisible_and_set_new_height (second_win, new_height); |
c906108c | 667 | |
1cc6d956 | 668 | /* Change the command window's height/width. */ |
cb2ce893 | 669 | TUI_CMD_WIN->origin.y = locator->origin.y + 1; |
9a2b4c1b | 670 | make_invisible_and_set_new_height (TUI_CMD_WIN, |
cb2ce893 | 671 | TUI_CMD_WIN->height |
9a2b4c1b | 672 | + cmd_split_diff); |
5fcee43a TT |
673 | first_win->make_visible_with_new_height (); |
674 | second_win->make_visible_with_new_height (); | |
675 | TUI_CMD_WIN->make_visible_with_new_height (); | |
53e7cdba | 676 | if (src_win->content.empty ()) |
caf0bc4e | 677 | tui_erase_source_content (src_win); |
c906108c SS |
678 | break; |
679 | } | |
ef5eab5a MS |
680 | /* Now remove all invisible windows, and their content so that |
681 | they get created again when called for with the new size. */ | |
6ba8e26f | 682 | for (win_type = SRC_WIN; (win_type < MAX_MAJOR_WINDOWS); win_type++) |
c906108c | 683 | { |
e5908723 MS |
684 | if (win_type != CMD_WIN |
685 | && (tui_win_list[win_type] != NULL) | |
cb2ce893 | 686 | && !tui_win_list[win_type]->is_visible) |
c906108c | 687 | { |
e7e11af4 | 688 | delete tui_win_list[win_type]; |
e65b5245 | 689 | tui_win_list[win_type] = NULL; |
c906108c SS |
690 | } |
691 | } | |
1cc6d956 MS |
692 | /* Turn keypad back on, unless focus is in the command |
693 | window. */ | |
6ba8e26f | 694 | if (win_with_focus != TUI_CMD_WIN) |
cb2ce893 | 695 | keypad (TUI_CMD_WIN->handle, TRUE); |
c906108c | 696 | } |
6ba8e26f | 697 | } |
c906108c | 698 | |
2c0b251b | 699 | #ifdef SIGWINCH |
c4ef48c6 PP |
700 | /* Token for use by TUI's asynchronous SIGWINCH handler. */ |
701 | static struct async_signal_handler *tui_sigwinch_token; | |
702 | ||
703 | /* TUI's SIGWINCH signal handler. */ | |
2c0b251b | 704 | static void |
6ba8e26f | 705 | tui_sigwinch_handler (int signal) |
c906108c | 706 | { |
c4ef48c6 | 707 | mark_async_signal_handler (tui_sigwinch_token); |
dd1abb8c | 708 | tui_set_win_resized_to (TRUE); |
6ba8e26f | 709 | } |
c4ef48c6 PP |
710 | |
711 | /* Callback for asynchronously resizing TUI following a SIGWINCH signal. */ | |
712 | static void | |
713 | tui_async_resize_screen (gdb_client_data arg) | |
714 | { | |
a88d0bb3 PP |
715 | rl_resize_terminal (); |
716 | ||
c4ef48c6 | 717 | if (!tui_active) |
a88d0bb3 PP |
718 | { |
719 | int screen_height, screen_width; | |
c4ef48c6 | 720 | |
a88d0bb3 PP |
721 | rl_get_screen_size (&screen_height, &screen_width); |
722 | set_screen_width_and_height (screen_width, screen_height); | |
723 | ||
724 | /* win_resized is left set so that the next call to tui_enable() | |
725 | resizes the TUI windows. */ | |
726 | } | |
727 | else | |
728 | { | |
1e04046d | 729 | tui_set_win_resized_to (FALSE); |
a88d0bb3 PP |
730 | tui_resize_all (); |
731 | tui_refresh_all_win (); | |
732 | tui_update_gdb_sizes (); | |
a88d0bb3 PP |
733 | tui_redisplay_readline (); |
734 | } | |
c4ef48c6 | 735 | } |
2c0b251b | 736 | #endif |
c906108c | 737 | |
c4ef48c6 PP |
738 | /* Initialize TUI's SIGWINCH signal handler. Note that the handler is not |
739 | uninstalled when we exit TUI, so the handler should not assume that TUI is | |
740 | always active. */ | |
9612b5ec UW |
741 | void |
742 | tui_initialize_win (void) | |
743 | { | |
744 | #ifdef SIGWINCH | |
c4ef48c6 PP |
745 | tui_sigwinch_token |
746 | = create_async_signal_handler (tui_async_resize_screen, NULL); | |
747 | ||
748 | { | |
9612b5ec | 749 | #ifdef HAVE_SIGACTION |
c4ef48c6 | 750 | struct sigaction old_winch; |
1c5313c5 | 751 | |
c4ef48c6 PP |
752 | memset (&old_winch, 0, sizeof (old_winch)); |
753 | old_winch.sa_handler = &tui_sigwinch_handler; | |
a344fc09 | 754 | #ifdef SA_RESTART |
c4ef48c6 | 755 | old_winch.sa_flags = SA_RESTART; |
a344fc09 | 756 | #endif |
c4ef48c6 | 757 | sigaction (SIGWINCH, &old_winch, NULL); |
9612b5ec | 758 | #else |
c4ef48c6 | 759 | signal (SIGWINCH, &tui_sigwinch_handler); |
9612b5ec | 760 | #endif |
c4ef48c6 | 761 | } |
9612b5ec UW |
762 | #endif |
763 | } | |
c906108c SS |
764 | |
765 | ||
766 | /************************* | |
767 | ** STATIC LOCAL FUNCTIONS | |
768 | **************************/ | |
769 | ||
770 | ||
c906108c | 771 | static void |
0b39b52e | 772 | tui_scroll_forward_command (const char *arg, int from_tty) |
c906108c | 773 | { |
6ba8e26f | 774 | int num_to_scroll = 1; |
5b6fe301 | 775 | struct tui_win_info *win_to_scroll; |
c906108c | 776 | |
1854bb21 SC |
777 | /* Make sure the curses mode is enabled. */ |
778 | tui_enable (); | |
63a33118 | 779 | if (arg == NULL) |
cafb3438 | 780 | parse_scrolling_args (arg, &win_to_scroll, NULL); |
c906108c | 781 | else |
6ba8e26f | 782 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 783 | win_to_scroll->forward_scroll (num_to_scroll); |
e8b915dc | 784 | } |
c906108c SS |
785 | |
786 | ||
c906108c | 787 | static void |
0b39b52e | 788 | tui_scroll_backward_command (const char *arg, int from_tty) |
c906108c | 789 | { |
6ba8e26f | 790 | int num_to_scroll = 1; |
5b6fe301 | 791 | struct tui_win_info *win_to_scroll; |
c906108c | 792 | |
1854bb21 SC |
793 | /* Make sure the curses mode is enabled. */ |
794 | tui_enable (); | |
63a33118 | 795 | if (arg == NULL) |
cafb3438 | 796 | parse_scrolling_args (arg, &win_to_scroll, NULL); |
c906108c | 797 | else |
6ba8e26f | 798 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 799 | win_to_scroll->backward_scroll (num_to_scroll); |
e8b915dc | 800 | } |
c906108c SS |
801 | |
802 | ||
c906108c | 803 | static void |
0b39b52e | 804 | tui_scroll_left_command (const char *arg, int from_tty) |
c906108c | 805 | { |
6ba8e26f | 806 | int num_to_scroll; |
5b6fe301 | 807 | struct tui_win_info *win_to_scroll; |
c906108c | 808 | |
1854bb21 SC |
809 | /* Make sure the curses mode is enabled. */ |
810 | tui_enable (); | |
6ba8e26f | 811 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 812 | win_to_scroll->left_scroll (num_to_scroll); |
e8b915dc | 813 | } |
c906108c SS |
814 | |
815 | ||
c906108c | 816 | static void |
0b39b52e | 817 | tui_scroll_right_command (const char *arg, int from_tty) |
c906108c | 818 | { |
6ba8e26f | 819 | int num_to_scroll; |
5b6fe301 | 820 | struct tui_win_info *win_to_scroll; |
c906108c | 821 | |
1854bb21 SC |
822 | /* Make sure the curses mode is enabled. */ |
823 | tui_enable (); | |
6ba8e26f | 824 | parse_scrolling_args (arg, &win_to_scroll, &num_to_scroll); |
13446e05 | 825 | win_to_scroll->right_scroll (num_to_scroll); |
e8b915dc | 826 | } |
c906108c SS |
827 | |
828 | ||
6ba8e26f | 829 | /* Set focus to the window named by 'arg'. */ |
c906108c | 830 | static void |
01aeb396 | 831 | tui_set_focus_command (const char *arg, int from_tty) |
c906108c | 832 | { |
01aeb396 TT |
833 | tui_enable (); |
834 | ||
63a33118 | 835 | if (arg != NULL) |
c906108c | 836 | { |
63a33118 | 837 | char *buf_ptr = xstrdup (arg); |
c906108c | 838 | int i; |
e65b5245 | 839 | struct tui_win_info *win_info = NULL; |
c906108c | 840 | |
6ba8e26f | 841 | for (i = 0; (i < strlen (buf_ptr)); i++) |
6dce28e4 | 842 | buf_ptr[i] = tolower (arg[i]); |
c906108c | 843 | |
6dce28e4 | 844 | if (subset_compare (buf_ptr, "next")) |
6d012f14 | 845 | win_info = tui_next_win (tui_win_with_focus ()); |
6dce28e4 | 846 | else if (subset_compare (buf_ptr, "prev")) |
6d012f14 | 847 | win_info = tui_prev_win (tui_win_with_focus ()); |
c906108c | 848 | else |
6ba8e26f | 849 | win_info = tui_partial_win_by_name (buf_ptr); |
c906108c | 850 | |
cb2ce893 | 851 | if (win_info == NULL || !win_info->is_visible) |
8a3fe4f8 AC |
852 | warning (_("Invalid window specified. \n\ |
853 | The window name specified must be valid and visible.\n")); | |
c906108c SS |
854 | else |
855 | { | |
6d012f14 | 856 | tui_set_win_focus_to (win_info); |
cb2ce893 | 857 | keypad (TUI_CMD_WIN->handle, (win_info != TUI_CMD_WIN)); |
c906108c SS |
858 | } |
859 | ||
6ba8e26f | 860 | xfree (buf_ptr); |
a3f17187 | 861 | printf_filtered (_("Focus set to %s window.\n"), |
152f3f4b | 862 | tui_win_with_focus ()->name ()); |
c906108c SS |
863 | } |
864 | else | |
8a3fe4f8 | 865 | warning (_("Incorrect Number of Arguments.\n%s"), FOCUS_USAGE); |
6ba8e26f | 866 | } |
c906108c | 867 | |
c906108c | 868 | static void |
1d12d88f | 869 | tui_all_windows_info (const char *arg, int from_tty) |
c906108c | 870 | { |
5b6fe301 | 871 | struct tui_win_info *win_with_focus = tui_win_with_focus (); |
c906108c | 872 | |
1ce3e844 TT |
873 | for (tui_win_info *win_info : all_tui_windows ()) |
874 | if (win_info->is_visible) | |
c906108c | 875 | { |
1ce3e844 | 876 | if (win_with_focus == win_info) |
c906108c | 877 | printf_filtered (" %s\t(%d lines) <has focus>\n", |
1ce3e844 TT |
878 | win_info->name (), |
879 | win_info->height); | |
c906108c SS |
880 | else |
881 | printf_filtered (" %s\t(%d lines)\n", | |
1ce3e844 TT |
882 | win_info->name (), |
883 | win_info->height); | |
c906108c | 884 | } |
6ba8e26f | 885 | } |
c906108c SS |
886 | |
887 | ||
c906108c | 888 | static void |
0b39b52e | 889 | tui_refresh_all_command (const char *arg, int from_tty) |
c906108c | 890 | { |
1854bb21 SC |
891 | /* Make sure the curses mode is enabled. */ |
892 | tui_enable (); | |
893 | ||
a21fcd8f | 894 | tui_refresh_all_win (); |
c906108c SS |
895 | } |
896 | ||
7806cea7 TT |
897 | /* The tab width that should be used by the TUI. */ |
898 | ||
899 | unsigned int tui_tab_width = DEFAULT_TAB_LEN; | |
900 | ||
901 | /* The tab width as set by the user. */ | |
902 | ||
903 | static unsigned int internal_tab_width = DEFAULT_TAB_LEN; | |
904 | ||
d83f1fe6 | 905 | /* See tui-data.h. */ |
7806cea7 | 906 | |
d83f1fe6 TT |
907 | void |
908 | tui_source_window_base::update_tab_width () | |
7806cea7 TT |
909 | { |
910 | /* We don't really change the height of any windows, but | |
911 | calling these 2 functions causes a complete regeneration | |
912 | and redisplay of the window's contents, which will take | |
913 | the new tab width into account. */ | |
d83f1fe6 | 914 | make_invisible_and_set_new_height (this, height); |
5fcee43a | 915 | make_visible_with_new_height (); |
d83f1fe6 TT |
916 | } |
917 | ||
918 | /* After the tab width is set, call this to update the relevant | |
919 | windows. */ | |
920 | ||
921 | static void | |
922 | update_tab_width () | |
923 | { | |
1ce3e844 | 924 | for (tui_win_info *win_info : all_tui_windows ()) |
7806cea7 | 925 | { |
1ce3e844 TT |
926 | if (win_info->is_visible) |
927 | win_info->update_tab_width (); | |
7806cea7 TT |
928 | } |
929 | } | |
930 | ||
931 | /* Callback for "set tui tab-width". */ | |
932 | ||
933 | static void | |
934 | tui_set_tab_width (const char *ignore, | |
935 | int from_tty, struct cmd_list_element *c) | |
936 | { | |
937 | if (internal_tab_width == 0) | |
938 | { | |
939 | internal_tab_width = tui_tab_width; | |
940 | error (_("Tab width must not be 0")); | |
941 | } | |
942 | ||
943 | tui_tab_width = internal_tab_width; | |
944 | update_tab_width (); | |
945 | } | |
946 | ||
947 | /* Callback for "show tui tab-width". */ | |
948 | ||
949 | static void | |
950 | tui_show_tab_width (struct ui_file *file, int from_tty, | |
951 | struct cmd_list_element *c, const char *value) | |
952 | { | |
953 | fprintf_filtered (gdb_stdout, _("TUI tab width is %s spaces.\n"), value); | |
954 | ||
955 | } | |
c906108c | 956 | |
c54da50d | 957 | /* Set the tab width of the specified window. */ |
c906108c | 958 | static void |
0b39b52e | 959 | tui_set_tab_width_command (const char *arg, int from_tty) |
c906108c | 960 | { |
1854bb21 SC |
961 | /* Make sure the curses mode is enabled. */ |
962 | tui_enable (); | |
63a33118 | 963 | if (arg != NULL) |
c906108c SS |
964 | { |
965 | int ts; | |
966 | ||
967 | ts = atoi (arg); | |
7806cea7 TT |
968 | if (ts <= 0) |
969 | warning (_("Tab widths greater than 0 must be specified.")); | |
970 | else | |
cb86fcc1 | 971 | { |
7806cea7 TT |
972 | internal_tab_width = ts; |
973 | tui_tab_width = ts; | |
974 | ||
975 | update_tab_width (); | |
cb86fcc1 | 976 | } |
c906108c | 977 | } |
6ba8e26f | 978 | } |
c906108c SS |
979 | |
980 | ||
1cc6d956 | 981 | /* Set the height of the specified window. */ |
c906108c | 982 | static void |
4dde7b34 | 983 | tui_set_win_height_command (const char *arg, int from_tty) |
c906108c | 984 | { |
1854bb21 SC |
985 | /* Make sure the curses mode is enabled. */ |
986 | tui_enable (); | |
63a33118 | 987 | if (arg != NULL) |
c906108c | 988 | { |
f71c8822 TT |
989 | std::string copy = arg; |
990 | char *buf = ©[0]; | |
6ba8e26f | 991 | char *buf_ptr = buf; |
e65b5245 | 992 | char *wname = NULL; |
6ba8e26f | 993 | int new_height, i; |
5b6fe301 | 994 | struct tui_win_info *win_info; |
c906108c | 995 | |
6ba8e26f AC |
996 | wname = buf_ptr; |
997 | buf_ptr = strchr (buf_ptr, ' '); | |
63a33118 | 998 | if (buf_ptr != NULL) |
c906108c | 999 | { |
6ba8e26f | 1000 | *buf_ptr = (char) 0; |
c906108c | 1001 | |
ef5eab5a | 1002 | /* Validate the window name. */ |
c906108c | 1003 | for (i = 0; i < strlen (wname); i++) |
6dce28e4 | 1004 | wname[i] = tolower (wname[i]); |
6d012f14 | 1005 | win_info = tui_partial_win_by_name (wname); |
c906108c | 1006 | |
cb2ce893 | 1007 | if (win_info == NULL || !win_info->is_visible) |
8a3fe4f8 AC |
1008 | warning (_("Invalid window specified. \n\ |
1009 | The window name specified must be valid and visible.\n")); | |
c906108c SS |
1010 | else |
1011 | { | |
1cc6d956 | 1012 | /* Process the size. */ |
6ba8e26f | 1013 | while (*(++buf_ptr) == ' ') |
c906108c SS |
1014 | ; |
1015 | ||
6ba8e26f | 1016 | if (*buf_ptr != (char) 0) |
c906108c SS |
1017 | { |
1018 | int negate = FALSE; | |
6ba8e26f AC |
1019 | int fixed_size = TRUE; |
1020 | int input_no;; | |
c906108c | 1021 | |
6ba8e26f | 1022 | if (*buf_ptr == '+' || *buf_ptr == '-') |
c906108c | 1023 | { |
6ba8e26f | 1024 | if (*buf_ptr == '-') |
c906108c | 1025 | negate = TRUE; |
6ba8e26f AC |
1026 | fixed_size = FALSE; |
1027 | buf_ptr++; | |
c906108c | 1028 | } |
6ba8e26f AC |
1029 | input_no = atoi (buf_ptr); |
1030 | if (input_no > 0) | |
c906108c SS |
1031 | { |
1032 | if (negate) | |
6ba8e26f AC |
1033 | input_no *= (-1); |
1034 | if (fixed_size) | |
1035 | new_height = input_no; | |
c906108c | 1036 | else |
cb2ce893 | 1037 | new_height = win_info->height + input_no; |
ef5eab5a MS |
1038 | |
1039 | /* Now change the window's height, and adjust | |
1040 | all other windows around it. */ | |
6ba8e26f AC |
1041 | if (tui_adjust_win_heights (win_info, |
1042 | new_height) == TUI_FAILURE) | |
8a3fe4f8 | 1043 | warning (_("Invalid window height specified.\n%s"), |
c906108c SS |
1044 | WIN_HEIGHT_USAGE); |
1045 | else | |
3e752b04 | 1046 | tui_update_gdb_sizes (); |
c906108c SS |
1047 | } |
1048 | else | |
8a3fe4f8 | 1049 | warning (_("Invalid window height specified.\n%s"), |
c906108c SS |
1050 | WIN_HEIGHT_USAGE); |
1051 | } | |
1052 | } | |
1053 | } | |
1054 | else | |
1055 | printf_filtered (WIN_HEIGHT_USAGE); | |
c906108c SS |
1056 | } |
1057 | else | |
1058 | printf_filtered (WIN_HEIGHT_USAGE); | |
6ba8e26f | 1059 | } |
c906108c | 1060 | |
6ba8e26f | 1061 | /* Function to adjust all window heights around the primary. */ |
22940a24 | 1062 | static enum tui_status |
08ef48c5 MS |
1063 | tui_adjust_win_heights (struct tui_win_info *primary_win_info, |
1064 | int new_height) | |
c906108c | 1065 | { |
22940a24 | 1066 | enum tui_status status = TUI_FAILURE; |
c906108c | 1067 | |
6ba8e26f | 1068 | if (new_height_ok (primary_win_info, new_height)) |
c906108c SS |
1069 | { |
1070 | status = TUI_SUCCESS; | |
cb2ce893 | 1071 | if (new_height != primary_win_info->height) |
c906108c | 1072 | { |
bc712bbf | 1073 | int diff; |
5b6fe301 | 1074 | struct tui_win_info *win_info; |
3add462f | 1075 | struct tui_locator_window *locator = tui_locator_win_info_ptr (); |
6ba8e26f | 1076 | enum tui_layout_type cur_layout = tui_current_layout (); |
c906108c | 1077 | |
cb2ce893 | 1078 | diff = (new_height - primary_win_info->height) * (-1); |
e5908723 MS |
1079 | if (cur_layout == SRC_COMMAND |
1080 | || cur_layout == DISASSEM_COMMAND) | |
c906108c | 1081 | { |
5b6fe301 | 1082 | struct tui_win_info *src_win_info; |
c906108c | 1083 | |
6ba8e26f | 1084 | make_invisible_and_set_new_height (primary_win_info, new_height); |
cb2ce893 | 1085 | if (primary_win_info->type == CMD_WIN) |
c906108c | 1086 | { |
b4eb2452 | 1087 | win_info = tui_source_windows ()[0]; |
6ba8e26f | 1088 | src_win_info = win_info; |
c906108c SS |
1089 | } |
1090 | else | |
1091 | { | |
6d012f14 | 1092 | win_info = tui_win_list[CMD_WIN]; |
6ba8e26f | 1093 | src_win_info = primary_win_info; |
c906108c | 1094 | } |
6ba8e26f | 1095 | make_invisible_and_set_new_height (win_info, |
cb2ce893 TT |
1096 | win_info->height + diff); |
1097 | TUI_CMD_WIN->origin.y = locator->origin.y + 1; | |
5fcee43a TT |
1098 | win_info->make_visible_with_new_height (); |
1099 | primary_win_info->make_visible_with_new_height (); | |
7908abbf | 1100 | if ((src_win_info->type == SRC_WIN |
53e7cdba TT |
1101 | || src_win_info->type == DISASSEM_WIN)) |
1102 | { | |
1103 | tui_source_window_base *src_base | |
1104 | = (tui_source_window_base *) src_win_info; | |
1105 | if (src_base->content.empty ()) | |
caf0bc4e | 1106 | tui_erase_source_content (src_base); |
53e7cdba | 1107 | } |
c906108c SS |
1108 | } |
1109 | else | |
1110 | { | |
6ba8e26f | 1111 | struct tui_win_info *first_win; |
7908abbf TT |
1112 | struct tui_source_window_base *second_win; |
1113 | tui_source_window_base *src1; | |
c906108c | 1114 | |
6ba8e26f | 1115 | if (cur_layout == SRC_DISASSEM_COMMAND) |
c906108c | 1116 | { |
7908abbf TT |
1117 | src1 = TUI_SRC_WIN; |
1118 | first_win = src1; | |
6ba8e26f | 1119 | second_win = TUI_DISASM_WIN; |
c906108c SS |
1120 | } |
1121 | else | |
1122 | { | |
7908abbf | 1123 | src1 = nullptr; |
6ba8e26f | 1124 | first_win = TUI_DATA_WIN; |
b4eb2452 | 1125 | second_win = tui_source_windows ()[0]; |
c906108c | 1126 | } |
6ba8e26f | 1127 | if (primary_win_info == TUI_CMD_WIN) |
ef5eab5a MS |
1128 | { /* Split the change in height accross the 1st & 2nd |
1129 | windows, adjusting them as well. */ | |
1130 | /* Subtract the locator. */ | |
1131 | int first_split_diff = diff / 2; | |
6ba8e26f | 1132 | int second_split_diff = first_split_diff; |
c906108c SS |
1133 | |
1134 | if (diff % 2) | |
1135 | { | |
cb2ce893 TT |
1136 | if (first_win->height > |
1137 | second_win->height) | |
c906108c | 1138 | if (diff < 0) |
6ba8e26f | 1139 | first_split_diff--; |
c906108c | 1140 | else |
6ba8e26f | 1141 | first_split_diff++; |
c906108c SS |
1142 | else |
1143 | { | |
1144 | if (diff < 0) | |
6ba8e26f | 1145 | second_split_diff--; |
c906108c | 1146 | else |
6ba8e26f | 1147 | second_split_diff++; |
c906108c SS |
1148 | } |
1149 | } | |
1cc6d956 MS |
1150 | /* Make sure that the minimum hieghts are |
1151 | honored. */ | |
cb2ce893 | 1152 | while ((first_win->height + first_split_diff) < 3) |
c906108c | 1153 | { |
6ba8e26f AC |
1154 | first_split_diff++; |
1155 | second_split_diff--; | |
c906108c | 1156 | } |
cb2ce893 | 1157 | while ((second_win->height + second_split_diff) < 3) |
c906108c | 1158 | { |
6ba8e26f AC |
1159 | second_split_diff++; |
1160 | first_split_diff--; | |
c906108c | 1161 | } |
6ba8e26f AC |
1162 | make_invisible_and_set_new_height ( |
1163 | first_win, | |
cb2ce893 TT |
1164 | first_win->height + first_split_diff); |
1165 | second_win->origin.y = first_win->height - 1; | |
9a2b4c1b | 1166 | make_invisible_and_set_new_height (second_win, |
cb2ce893 | 1167 | second_win->height |
9a2b4c1b | 1168 | + second_split_diff); |
cb2ce893 | 1169 | TUI_CMD_WIN->origin.y = locator->origin.y + 1; |
6ba8e26f | 1170 | make_invisible_and_set_new_height (TUI_CMD_WIN, new_height); |
c906108c SS |
1171 | } |
1172 | else | |
1173 | { | |
cb2ce893 | 1174 | if ((TUI_CMD_WIN->height + diff) < 1) |
ef5eab5a MS |
1175 | { /* If there is no way to increase the command |
1176 | window take real estate from the 1st or 2nd | |
1177 | window. */ | |
cb2ce893 | 1178 | if ((TUI_CMD_WIN->height + diff) < 1) |
c906108c SS |
1179 | { |
1180 | int i; | |
1c5313c5 | 1181 | |
cb2ce893 | 1182 | for (i = TUI_CMD_WIN->height + diff; |
c906108c | 1183 | (i < 1); i++) |
6ba8e26f | 1184 | if (primary_win_info == first_win) |
cb2ce893 | 1185 | second_win->height--; |
c906108c | 1186 | else |
cb2ce893 | 1187 | first_win->height--; |
c906108c SS |
1188 | } |
1189 | } | |
6ba8e26f AC |
1190 | if (primary_win_info == first_win) |
1191 | make_invisible_and_set_new_height (first_win, new_height); | |
c906108c | 1192 | else |
6ba8e26f AC |
1193 | make_invisible_and_set_new_height ( |
1194 | first_win, | |
cb2ce893 TT |
1195 | first_win->height); |
1196 | second_win->origin.y = first_win->height - 1; | |
6ba8e26f AC |
1197 | if (primary_win_info == second_win) |
1198 | make_invisible_and_set_new_height (second_win, new_height); | |
c906108c | 1199 | else |
6ba8e26f | 1200 | make_invisible_and_set_new_height ( |
cb2ce893 TT |
1201 | second_win, second_win->height); |
1202 | TUI_CMD_WIN->origin.y = locator->origin.y + 1; | |
1203 | if ((TUI_CMD_WIN->height + diff) < 1) | |
6ba8e26f | 1204 | make_invisible_and_set_new_height (TUI_CMD_WIN, 1); |
c906108c | 1205 | else |
9a2b4c1b | 1206 | make_invisible_and_set_new_height (TUI_CMD_WIN, |
cb2ce893 | 1207 | TUI_CMD_WIN->height + diff); |
c906108c | 1208 | } |
5fcee43a TT |
1209 | TUI_CMD_WIN->make_visible_with_new_height (); |
1210 | second_win->make_visible_with_new_height (); | |
1211 | first_win->make_visible_with_new_height (); | |
53e7cdba | 1212 | if (src1 != nullptr && src1->content.empty ()) |
caf0bc4e | 1213 | tui_erase_source_content (src1); |
53e7cdba | 1214 | if (second_win->content.empty ()) |
caf0bc4e | 1215 | tui_erase_source_content (second_win); |
c906108c SS |
1216 | } |
1217 | } | |
1218 | } | |
1219 | ||
1220 | return status; | |
6ba8e26f | 1221 | } |
c906108c SS |
1222 | |
1223 | ||
3f02ce1e TT |
1224 | /* See tui-data.h. */ |
1225 | ||
1226 | void | |
1227 | tui_source_window_base::set_new_height (int height) | |
1228 | { | |
1229 | tui_make_invisible (execution_info); | |
1230 | execution_info->height = height; | |
cb2ce893 | 1231 | execution_info->origin.y = origin.y; |
3f02ce1e TT |
1232 | if (height > 1) |
1233 | execution_info->viewport_height = height - 1; | |
1234 | else | |
1235 | execution_info->viewport_height = height; | |
1236 | execution_info->viewport_height--; | |
1237 | ||
1238 | if (has_locator ()) | |
1239 | { | |
3add462f | 1240 | tui_locator_window *gen_win_info = tui_locator_win_info_ptr (); |
3f02ce1e | 1241 | tui_make_invisible (gen_win_info); |
cb2ce893 | 1242 | gen_win_info->origin.y = origin.y + height; |
3f02ce1e TT |
1243 | } |
1244 | } | |
1245 | ||
1246 | /* See tui-data.h. */ | |
1247 | ||
1248 | void | |
1249 | tui_data_window::set_new_height (int height) | |
1250 | { | |
1251 | /* Delete all data item windows. */ | |
21e1c91e | 1252 | for (auto &&win : regs_content) |
3f02ce1e | 1253 | { |
21e1c91e TT |
1254 | tui_delete_win (win->handle); |
1255 | win->handle = NULL; | |
3f02ce1e TT |
1256 | } |
1257 | } | |
1258 | ||
6658b1bf | 1259 | /* Function make the target window (and auxiliary windows associated |
1cc6d956 MS |
1260 | with the targer) invisible, and set the new height and |
1261 | location. */ | |
c906108c | 1262 | static void |
08ef48c5 MS |
1263 | make_invisible_and_set_new_height (struct tui_win_info *win_info, |
1264 | int height) | |
c906108c | 1265 | { |
cb2ce893 TT |
1266 | tui_make_invisible (win_info); |
1267 | win_info->height = height; | |
c906108c | 1268 | if (height > 1) |
cb2ce893 | 1269 | win_info->viewport_height = height - 1; |
c906108c | 1270 | else |
cb2ce893 | 1271 | win_info->viewport_height = height; |
6d012f14 | 1272 | if (win_info != TUI_CMD_WIN) |
cb2ce893 | 1273 | win_info->viewport_height--; |
c906108c | 1274 | |
6658b1bf | 1275 | /* Now deal with the auxiliary windows associated with win_info. */ |
3f02ce1e | 1276 | win_info->set_new_height (height); |
bc712bbf | 1277 | } |
c906108c SS |
1278 | |
1279 | ||
5fcee43a TT |
1280 | /* See tui-data.h. */ |
1281 | ||
1282 | void | |
1283 | tui_win_info::make_visible_with_new_height () | |
c906108c | 1284 | { |
5fcee43a TT |
1285 | make_visible (true); |
1286 | tui_check_and_display_highlight_if_needed (this); | |
1287 | do_make_visible_with_new_height (); | |
1288 | } | |
1289 | ||
1290 | /* See tui-data.h. */ | |
c906108c | 1291 | |
5fcee43a TT |
1292 | void |
1293 | tui_source_window_base::do_make_visible_with_new_height () | |
1294 | { | |
5fcee43a | 1295 | tui_make_visible (execution_info); |
53e7cdba | 1296 | if (!content.empty ()) |
c906108c | 1297 | { |
5fcee43a TT |
1298 | struct tui_line_or_address line_or_addr; |
1299 | struct symtab_and_line cursal | |
1300 | = get_current_source_symtab_and_line (); | |
1301 | ||
1302 | line_or_addr = start_line_or_addr; | |
5fcee43a TT |
1303 | tui_update_source_window (this, gdbarch, |
1304 | cursal.symtab, line_or_addr, TRUE); | |
1305 | } | |
1306 | else if (deprecated_safe_get_selected_frame () != NULL) | |
1307 | { | |
1308 | struct tui_line_or_address line; | |
1309 | struct symtab_and_line cursal | |
1310 | = get_current_source_symtab_and_line (); | |
1311 | struct frame_info *frame = deprecated_safe_get_selected_frame (); | |
1312 | struct gdbarch *gdbarch = get_frame_arch (frame); | |
1313 | ||
1314 | struct symtab *s = find_pc_line_symtab (get_frame_pc (frame)); | |
1315 | if (type == SRC_WIN) | |
c906108c | 1316 | { |
5fcee43a TT |
1317 | line.loa = LOA_LINE; |
1318 | line.u.line_no = cursal.line; | |
c906108c | 1319 | } |
5fcee43a | 1320 | else |
c906108c | 1321 | { |
5fcee43a TT |
1322 | line.loa = LOA_ADDRESS; |
1323 | find_line_pc (s, cursal.line, &line.u.addr); | |
c906108c | 1324 | } |
5fcee43a TT |
1325 | tui_update_source_window (this, gdbarch, s, line, TRUE); |
1326 | } | |
1327 | if (has_locator ()) | |
1328 | { | |
1329 | tui_make_visible (tui_locator_win_info_ptr ()); | |
1330 | tui_show_locator_content (); | |
c906108c | 1331 | } |
6ba8e26f | 1332 | } |
c906108c | 1333 | |
5fcee43a TT |
1334 | /* See tui-data.h. */ |
1335 | ||
1336 | void | |
1337 | tui_data_window::do_make_visible_with_new_height () | |
1338 | { | |
50daf268 | 1339 | display_all_data (); |
5fcee43a TT |
1340 | } |
1341 | ||
1342 | /* See tui-data.h. */ | |
1343 | ||
1344 | void | |
1345 | tui_cmd_window::do_make_visible_with_new_height () | |
1346 | { | |
1347 | #ifdef HAVE_WRESIZE | |
1348 | wresize (handle, height, width); | |
1349 | #endif | |
1350 | mvwin (handle, origin.y, origin.x); | |
1351 | wmove (handle, 0, 0); | |
1352 | } | |
c906108c | 1353 | |
8903bd8a TT |
1354 | /* See tui-data.h. */ |
1355 | ||
1356 | int | |
1357 | tui_win_info::max_height () const | |
1358 | { | |
1359 | return tui_term_height () - 2; | |
1360 | } | |
1361 | ||
1362 | /* See tui-data.h. */ | |
1363 | ||
1364 | int | |
1365 | tui_cmd_window::max_height () const | |
1366 | { | |
1367 | return tui_term_height () - 4; | |
1368 | } | |
1369 | ||
c906108c | 1370 | static int |
08ef48c5 MS |
1371 | new_height_ok (struct tui_win_info *primary_win_info, |
1372 | int new_height) | |
c906108c | 1373 | { |
6ba8e26f | 1374 | int ok = (new_height < tui_term_height ()); |
c906108c SS |
1375 | |
1376 | if (ok) | |
1377 | { | |
bc712bbf | 1378 | int diff; |
6d012f14 | 1379 | enum tui_layout_type cur_layout = tui_current_layout (); |
c906108c | 1380 | |
cb2ce893 | 1381 | diff = (new_height - primary_win_info->height) * (-1); |
6d012f14 | 1382 | if (cur_layout == SRC_COMMAND || cur_layout == DISASSEM_COMMAND) |
c906108c | 1383 | { |
8903bd8a TT |
1384 | ok = (new_height <= primary_win_info->max_height () |
1385 | && new_height >= MIN_CMD_WIN_HEIGHT); | |
c906108c | 1386 | if (ok) |
1cc6d956 | 1387 | { /* Check the total height. */ |
5b6fe301 | 1388 | struct tui_win_info *win_info; |
c906108c | 1389 | |
6ba8e26f | 1390 | if (primary_win_info == TUI_CMD_WIN) |
b4eb2452 | 1391 | win_info = tui_source_windows ()[0]; |
c906108c | 1392 | else |
6d012f14 | 1393 | win_info = TUI_CMD_WIN; |
6ba8e26f | 1394 | ok = ((new_height + |
cb2ce893 | 1395 | (win_info->height + diff)) <= tui_term_height ()); |
c906108c SS |
1396 | } |
1397 | } | |
1398 | else | |
1399 | { | |
6ba8e26f AC |
1400 | int cur_total_height, total_height, min_height = 0; |
1401 | struct tui_win_info *first_win; | |
1402 | struct tui_win_info *second_win; | |
c906108c | 1403 | |
6d012f14 | 1404 | if (cur_layout == SRC_DISASSEM_COMMAND) |
c906108c | 1405 | { |
6ba8e26f AC |
1406 | first_win = TUI_SRC_WIN; |
1407 | second_win = TUI_DISASM_WIN; | |
c906108c SS |
1408 | } |
1409 | else | |
1410 | { | |
6ba8e26f | 1411 | first_win = TUI_DATA_WIN; |
b4eb2452 | 1412 | second_win = tui_source_windows ()[0]; |
c906108c | 1413 | } |
ef5eab5a MS |
1414 | /* We could simply add all the heights to obtain the same |
1415 | result but below is more explicit since we subtract 1 for | |
1416 | the line that the first and second windows share, and add | |
1417 | one for the locator. */ | |
6ba8e26f | 1418 | total_height = cur_total_height = |
cb2ce893 TT |
1419 | (first_win->height + second_win->height - 1) |
1420 | + TUI_CMD_WIN->height + 1; /* Locator. */ | |
6ba8e26f | 1421 | if (primary_win_info == TUI_CMD_WIN) |
c906108c | 1422 | { |
1cc6d956 | 1423 | /* Locator included since first & second win share a line. */ |
cb2ce893 TT |
1424 | ok = ((first_win->height + |
1425 | second_win->height + diff) >= | |
e5908723 MS |
1426 | (MIN_WIN_HEIGHT * 2) |
1427 | && new_height >= MIN_CMD_WIN_HEIGHT); | |
c906108c SS |
1428 | if (ok) |
1429 | { | |
e5908723 | 1430 | total_height = new_height + |
cb2ce893 TT |
1431 | (first_win->height + |
1432 | second_win->height + diff); | |
6ba8e26f | 1433 | min_height = MIN_CMD_WIN_HEIGHT; |
c906108c SS |
1434 | } |
1435 | } | |
1436 | else | |
1437 | { | |
6ba8e26f | 1438 | min_height = MIN_WIN_HEIGHT; |
ef5eab5a MS |
1439 | |
1440 | /* First see if we can increase/decrease the command | |
1441 | window. And make sure that the command window is at | |
1442 | least 1 line. */ | |
cb2ce893 | 1443 | ok = ((TUI_CMD_WIN->height + diff) > 0); |
c906108c | 1444 | if (!ok) |
ef5eab5a MS |
1445 | { /* Looks like we have to increase/decrease one of |
1446 | the other windows. */ | |
6ba8e26f | 1447 | if (primary_win_info == first_win) |
cb2ce893 | 1448 | ok = (second_win->height + diff) >= min_height; |
c906108c | 1449 | else |
cb2ce893 | 1450 | ok = (first_win->height + diff) >= min_height; |
c906108c SS |
1451 | } |
1452 | if (ok) | |
1453 | { | |
6ba8e26f AC |
1454 | if (primary_win_info == first_win) |
1455 | total_height = new_height + | |
cb2ce893 TT |
1456 | second_win->height + |
1457 | TUI_CMD_WIN->height + diff; | |
c906108c | 1458 | else |
6ba8e26f | 1459 | total_height = new_height + |
cb2ce893 TT |
1460 | first_win->height + |
1461 | TUI_CMD_WIN->height + diff; | |
c906108c SS |
1462 | } |
1463 | } | |
ef5eab5a MS |
1464 | /* Now make sure that the proposed total height doesn't |
1465 | exceed the old total height. */ | |
c906108c | 1466 | if (ok) |
e5908723 MS |
1467 | ok = (new_height >= min_height |
1468 | && total_height <= cur_total_height); | |
c906108c SS |
1469 | } |
1470 | } | |
1471 | ||
1472 | return ok; | |
6ba8e26f | 1473 | } |
c906108c SS |
1474 | |
1475 | ||
c906108c | 1476 | static void |
0b39b52e | 1477 | parse_scrolling_args (const char *arg, |
08ef48c5 | 1478 | struct tui_win_info **win_to_scroll, |
6ba8e26f | 1479 | int *num_to_scroll) |
c906108c | 1480 | { |
6ba8e26f AC |
1481 | if (num_to_scroll) |
1482 | *num_to_scroll = 0; | |
1483 | *win_to_scroll = tui_win_with_focus (); | |
c906108c | 1484 | |
ef5eab5a MS |
1485 | /* First set up the default window to scroll, in case there is no |
1486 | window name arg. */ | |
63a33118 | 1487 | if (arg != NULL) |
c906108c | 1488 | { |
f71c8822 | 1489 | char *buf_ptr; |
c906108c | 1490 | |
1cc6d956 | 1491 | /* Process the number of lines to scroll. */ |
f71c8822 TT |
1492 | std::string copy = arg; |
1493 | buf_ptr = ©[0]; | |
6ba8e26f | 1494 | if (isdigit (*buf_ptr)) |
c906108c | 1495 | { |
6ba8e26f | 1496 | char *num_str; |
c906108c | 1497 | |
6ba8e26f AC |
1498 | num_str = buf_ptr; |
1499 | buf_ptr = strchr (buf_ptr, ' '); | |
63a33118 | 1500 | if (buf_ptr != NULL) |
c906108c | 1501 | { |
6ba8e26f AC |
1502 | *buf_ptr = (char) 0; |
1503 | if (num_to_scroll) | |
1504 | *num_to_scroll = atoi (num_str); | |
1505 | buf_ptr++; | |
c906108c | 1506 | } |
6ba8e26f AC |
1507 | else if (num_to_scroll) |
1508 | *num_to_scroll = atoi (num_str); | |
c906108c SS |
1509 | } |
1510 | ||
1cc6d956 | 1511 | /* Process the window name if one is specified. */ |
63a33118 | 1512 | if (buf_ptr != NULL) |
c906108c | 1513 | { |
a121b7c1 | 1514 | const char *wname; |
c906108c | 1515 | |
6ba8e26f AC |
1516 | if (*buf_ptr == ' ') |
1517 | while (*(++buf_ptr) == ' ') | |
c906108c SS |
1518 | ; |
1519 | ||
6ba8e26f | 1520 | if (*buf_ptr != (char) 0) |
c709a7c2 | 1521 | { |
c709a7c2 | 1522 | /* Validate the window name. */ |
a121b7c1 PA |
1523 | for (char *p = buf_ptr; *p != '\0'; p++) |
1524 | *p = tolower (*p); | |
1525 | ||
1526 | wname = buf_ptr; | |
c709a7c2 | 1527 | } |
a4b99e53 SC |
1528 | else |
1529 | wname = "?"; | |
1530 | ||
6ba8e26f | 1531 | *win_to_scroll = tui_partial_win_by_name (wname); |
c906108c | 1532 | |
cafb3438 | 1533 | if (*win_to_scroll == NULL |
cb2ce893 | 1534 | || !(*win_to_scroll)->is_visible) |
ec502284 | 1535 | error (_("Invalid window specified. \n\ |
8a3fe4f8 | 1536 | The window name specified must be valid and visible.\n")); |
6ba8e26f | 1537 | else if (*win_to_scroll == TUI_CMD_WIN) |
b4eb2452 | 1538 | *win_to_scroll = tui_source_windows ()[0]; |
c906108c | 1539 | } |
c906108c | 1540 | } |
6ba8e26f | 1541 | } |
7806cea7 TT |
1542 | |
1543 | /* Function to initialize gdb commands, for tui window | |
1544 | manipulation. */ | |
1545 | ||
1546 | void | |
1547 | _initialize_tui_win (void) | |
1548 | { | |
1549 | static struct cmd_list_element *tui_setlist; | |
1550 | static struct cmd_list_element *tui_showlist; | |
1551 | struct cmd_list_element *cmd; | |
1552 | ||
1553 | /* Define the classes of commands. | |
1554 | They will appear in the help list in the reverse of this order. */ | |
1555 | add_prefix_cmd ("tui", class_tui, set_tui_cmd, | |
1556 | _("TUI configuration variables"), | |
1557 | &tui_setlist, "set tui ", | |
1558 | 0 /* allow-unknown */, &setlist); | |
1559 | add_prefix_cmd ("tui", class_tui, show_tui_cmd, | |
1560 | _("TUI configuration variables"), | |
1561 | &tui_showlist, "show tui ", | |
1562 | 0 /* allow-unknown */, &showlist); | |
1563 | ||
1564 | add_com ("refresh", class_tui, tui_refresh_all_command, | |
89549d7f | 1565 | _("Refresh the terminal display.")); |
7806cea7 TT |
1566 | |
1567 | cmd = add_com ("tabset", class_tui, tui_set_tab_width_command, _("\ | |
1568 | Set the width (in characters) of tab stops.\n\ | |
89549d7f | 1569 | Usage: tabset N")); |
7806cea7 TT |
1570 | deprecate_cmd (cmd, "set tui tab-width"); |
1571 | ||
1572 | cmd = add_com ("winheight", class_tui, tui_set_win_height_command, _("\ | |
1573 | Set or modify the height of a specified window.\n" | |
1574 | WIN_HEIGHT_USAGE | |
1575 | "Window names are:\n\ | |
89549d7f TT |
1576 | src : the source window\n\ |
1577 | cmd : the command window\n\ | |
1578 | asm : the disassembly window\n\ | |
1579 | regs : the register display")); | |
7806cea7 TT |
1580 | add_com_alias ("wh", "winheight", class_tui, 0); |
1581 | set_cmd_completer (cmd, winheight_completer); | |
1582 | add_info ("win", tui_all_windows_info, | |
89549d7f | 1583 | _("List of all displayed windows.")); |
7806cea7 TT |
1584 | cmd = add_com ("focus", class_tui, tui_set_focus_command, _("\ |
1585 | Set focus to named window or next/prev window.\n" | |
1586 | FOCUS_USAGE | |
1587 | "Valid Window names are:\n\ | |
89549d7f TT |
1588 | src : the source window\n\ |
1589 | asm : the disassembly window\n\ | |
1590 | regs : the register display\n\ | |
1591 | cmd : the command window")); | |
7806cea7 TT |
1592 | add_com_alias ("fs", "focus", class_tui, 0); |
1593 | set_cmd_completer (cmd, focus_completer); | |
1594 | add_com ("+", class_tui, tui_scroll_forward_command, _("\ | |
1595 | Scroll window forward.\n\ | |
89549d7f | 1596 | Usage: + [WIN] [N]")); |
7806cea7 TT |
1597 | add_com ("-", class_tui, tui_scroll_backward_command, _("\ |
1598 | Scroll window backward.\n\ | |
89549d7f | 1599 | Usage: - [WIN] [N]")); |
7806cea7 TT |
1600 | add_com ("<", class_tui, tui_scroll_left_command, _("\ |
1601 | Scroll window text to the left.\n\ | |
89549d7f | 1602 | Usage: < [WIN] [N]")); |
7806cea7 TT |
1603 | add_com (">", class_tui, tui_scroll_right_command, _("\ |
1604 | Scroll window text to the right.\n\ | |
89549d7f | 1605 | Usage: > [WIN] [N]")); |
7806cea7 TT |
1606 | |
1607 | /* Define the tui control variables. */ | |
1608 | add_setshow_enum_cmd ("border-kind", no_class, tui_border_kind_enums, | |
1609 | &tui_border_kind, _("\ | |
1610 | Set the kind of border for TUI windows."), _("\ | |
1611 | Show the kind of border for TUI windows."), _("\ | |
1612 | This variable controls the border of TUI windows:\n\ | |
89549d7f TT |
1613 | space use a white space\n\ |
1614 | ascii use ascii characters + - | for the border\n\ | |
1615 | acs use the Alternate Character Set"), | |
7806cea7 TT |
1616 | tui_set_var_cmd, |
1617 | show_tui_border_kind, | |
1618 | &tui_setlist, &tui_showlist); | |
1619 | ||
1620 | add_setshow_enum_cmd ("border-mode", no_class, tui_border_mode_enums, | |
1621 | &tui_border_mode, _("\ | |
1622 | Set the attribute mode to use for the TUI window borders."), _("\ | |
1623 | Show the attribute mode to use for the TUI window borders."), _("\ | |
1624 | This variable controls the attributes to use for the window borders:\n\ | |
89549d7f TT |
1625 | normal normal display\n\ |
1626 | standout use highlight mode of terminal\n\ | |
1627 | reverse use reverse video mode\n\ | |
1628 | half use half bright\n\ | |
1629 | half-standout use half bright and standout mode\n\ | |
1630 | bold use extra bright or bold\n\ | |
1631 | bold-standout use extra bright or bold with standout mode"), | |
7806cea7 TT |
1632 | tui_set_var_cmd, |
1633 | show_tui_border_mode, | |
1634 | &tui_setlist, &tui_showlist); | |
1635 | ||
1636 | add_setshow_enum_cmd ("active-border-mode", no_class, tui_border_mode_enums, | |
1637 | &tui_active_border_mode, _("\ | |
1638 | Set the attribute mode to use for the active TUI window border."), _("\ | |
1639 | Show the attribute mode to use for the active TUI window border."), _("\ | |
1640 | This variable controls the attributes to use for the active window border:\n\ | |
89549d7f TT |
1641 | normal normal display\n\ |
1642 | standout use highlight mode of terminal\n\ | |
1643 | reverse use reverse video mode\n\ | |
1644 | half use half bright\n\ | |
1645 | half-standout use half bright and standout mode\n\ | |
1646 | bold use extra bright or bold\n\ | |
1647 | bold-standout use extra bright or bold with standout mode"), | |
7806cea7 TT |
1648 | tui_set_var_cmd, |
1649 | show_tui_active_border_mode, | |
1650 | &tui_setlist, &tui_showlist); | |
1651 | ||
1652 | add_setshow_zuinteger_cmd ("tab-width", no_class, | |
1653 | &internal_tab_width, _("\ | |
1654 | Set the tab width, in characters, for the TUI."), _("\ | |
1655 | Show the tab witdh, in characters, for the TUI"), _("\ | |
1656 | This variable controls how many spaces are used to display a tab character."), | |
1657 | tui_set_tab_width, tui_show_tab_width, | |
1658 | &tui_setlist, &tui_showlist); | |
1659 | } |