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