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