2002-02-08 Daniel Jacobowitz <drow@mvista.com>
[deliverable/binutils-gdb.git] / gdb / tui / tuiWin.c
CommitLineData
f377b406
SC
1/* TUI window generic functions.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
c906108c 4
f377b406
SC
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
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
4e8f7a8b
DJ
27/* If we need <curses.h>, we must include it before we get "bfd.h". */
28#include "config.h"
29#ifdef HAVE_NCURSES_H
30#include <ncurses.h>
31#else
32#ifdef HAVE_CURSES_H
33#include <curses.h>
34#endif
35#endif
36
c906108c 37#include <string.h>
84b1e7c7 38#include <ctype.h>
c906108c
SS
39#include "defs.h"
40#include "command.h"
41#include "symtab.h"
42#include "breakpoint.h"
43#include "frame.h"
41783295 44#include "cli/cli-cmds.h"
c906108c
SS
45
46#include "tui.h"
47#include "tuiData.h"
48#include "tuiGeneralWin.h"
49#include "tuiStack.h"
84b1e7c7
SC
50#include "tuiRegs.h"
51#include "tuiDisassem.h"
52#include "tuiSource.h"
c906108c
SS
53#include "tuiSourceWin.h"
54#include "tuiDataWin.h"
55
56/*******************************
57** External Declarations
58********************************/
59extern void init_page_info ();
60
61/*******************************
62** Static Local Decls
63********************************/
a14ed312
KB
64static void _makeVisibleWithNewHeight (TuiWinInfoPtr);
65static void _makeInvisibleAndSetNewHeight (TuiWinInfoPtr, int);
66static TuiStatus _tuiAdjustWinHeights (TuiWinInfoPtr, int);
67static int _newHeightOk (TuiWinInfoPtr, int);
68static void _tuiSetTabWidth_command (char *, int);
69static void _tuiRefreshAll_command (char *, int);
70static void _tuiSetWinHeight_command (char *, int);
71static void _tuiXDBsetWinHeight_command (char *, int);
72static void _tuiAllWindowsInfo (char *, int);
73static void _tuiSetFocus_command (char *, int);
74static void _tuiScrollForward_command (char *, int);
75static void _tuiScrollBackward_command (char *, int);
76static void _tuiScrollLeft_command (char *, int);
77static void _tuiScrollRight_command (char *, int);
78static void _parseScrollingArgs (char *, TuiWinInfoPtr *, int *);
c906108c
SS
79
80
81/***************************************
82** DEFINITIONS
83***************************************/
84#define WIN_HEIGHT_USAGE "Usage: winheight <win_name> [+ | -] <#lines>\n"
85#define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n"
86#define FOCUS_USAGE "Usage: focus {<win> | next | prev}\n"
87
88/***************************************
89** PUBLIC FUNCTIONS
90***************************************/
91
af101512
SC
92/* Possible values for tui-border-kind variable. */
93static const char *tui_border_kind_enums[] = {
94 "space",
95 "ascii",
96 "acs",
97 NULL
98};
99
100/* Possible values for tui-border-mode and tui-active-border-mode. */
101static const char *tui_border_mode_enums[] = {
102 "normal",
103 "standout",
104 "reverse",
105 "half",
106 "half-standout",
107 "bold",
108 "bold-standout",
109 NULL
110};
111
112struct tui_translate
113{
114 const char *name;
115 int value;
116};
117
118/* Translation table for border-mode variables.
119 The list of values must be terminated by a NULL.
120 After the NULL value, an entry defines the default. */
121struct tui_translate tui_border_mode_translate[] = {
122 { "normal", A_NORMAL },
123 { "standout", A_STANDOUT },
124 { "reverse", A_REVERSE },
125 { "half", A_DIM },
126 { "half-standout", A_DIM | A_STANDOUT },
127 { "bold", A_BOLD },
128 { "bold-standout", A_BOLD | A_STANDOUT },
129 { 0, 0 },
130 { "normal", A_NORMAL }
131};
132
133/* Translation tables for border-kind, one for each border
134 character (see wborder, border curses operations).
135 -1 is used to indicate the ACS because ACS characters
136 are determined at run time by curses (depends on terminal). */
137struct tui_translate tui_border_kind_translate_vline[] = {
138 { "space", ' ' },
139 { "ascii", '|' },
140 { "acs", -1 },
141 { 0, 0 },
142 { "ascii", '|' }
143};
144
145struct tui_translate tui_border_kind_translate_hline[] = {
146 { "space", ' ' },
147 { "ascii", '-' },
148 { "acs", -1 },
149 { 0, 0 },
150 { "ascii", '-' }
151};
152
153struct tui_translate tui_border_kind_translate_ulcorner[] = {
154 { "space", ' ' },
155 { "ascii", '+' },
156 { "acs", -1 },
157 { 0, 0 },
158 { "ascii", '+' }
159};
160
161struct tui_translate tui_border_kind_translate_urcorner[] = {
162 { "space", ' ' },
163 { "ascii", '+' },
164 { "acs", -1 },
165 { 0, 0 },
166 { "ascii", '+' }
167};
168
169struct tui_translate tui_border_kind_translate_llcorner[] = {
170 { "space", ' ' },
171 { "ascii", '+' },
172 { "acs", -1 },
173 { 0, 0 },
174 { "ascii", '+' }
175};
176
177struct tui_translate tui_border_kind_translate_lrcorner[] = {
178 { "space", ' ' },
179 { "ascii", '+' },
180 { "acs", -1 },
181 { 0, 0 },
182 { "ascii", '+' }
183};
184
185
186/* Tui configuration variables controlled with set/show command. */
187const char *tui_active_border_mode = "bold-standout";
188const char *tui_border_mode = "normal";
189const char *tui_border_kind = "acs";
190
191/* Tui internal configuration variables. These variables are
192 updated by tui_update_variables to reflect the tui configuration
193 variables. */
194chtype tui_border_vline;
195chtype tui_border_hline;
196chtype tui_border_ulcorner;
197chtype tui_border_urcorner;
198chtype tui_border_llcorner;
199chtype tui_border_lrcorner;
200
201int tui_border_attrs;
202int tui_active_border_attrs;
203
204/* Identify the item in the translation table.
205 When the item is not recognized, use the default entry. */
206static struct tui_translate *
207translate (const char *name, struct tui_translate *table)
208{
209 while (table->name)
210 {
211 if (name && strcmp (table->name, name) == 0)
212 return table;
213 table++;
214 }
215
216 /* Not found, return default entry. */
217 table++;
218 return table;
219}
220
221/* Update the tui internal configuration according to gdb settings.
222 Returns 1 if the configuration has changed and the screen should
223 be redrawn. */
224int
225tui_update_variables ()
226{
227 int need_redraw = 0;
228 struct tui_translate *entry;
229
230 entry = translate (tui_border_mode, tui_border_mode_translate);
231 if (tui_border_attrs != entry->value)
232 {
233 tui_border_attrs = entry->value;
234 need_redraw = 1;
235 }
236 entry = translate (tui_active_border_mode, tui_border_mode_translate);
237 if (tui_active_border_attrs != entry->value)
238 {
239 tui_active_border_attrs = entry->value;
240 need_redraw = 1;
241 }
242
243 /* If one corner changes, all characters are changed.
244 Only check the first one. The ACS characters are determined at
245 run time by curses terminal management. */
246 entry = translate (tui_border_kind, tui_border_kind_translate_lrcorner);
247 if (tui_border_lrcorner != (chtype) entry->value)
248 {
249 tui_border_lrcorner = (entry->value < 0) ? ACS_LRCORNER : entry->value;
250 need_redraw = 1;
251 }
252 entry = translate (tui_border_kind, tui_border_kind_translate_llcorner);
253 tui_border_llcorner = (entry->value < 0) ? ACS_LLCORNER : entry->value;
254
255 entry = translate (tui_border_kind, tui_border_kind_translate_ulcorner);
256 tui_border_ulcorner = (entry->value < 0) ? ACS_ULCORNER : entry->value;
257
258 entry = translate (tui_border_kind, tui_border_kind_translate_urcorner);
259 tui_border_urcorner = (entry->value < 0) ? ACS_URCORNER : entry->value;
260
261 entry = translate (tui_border_kind, tui_border_kind_translate_hline);
262 tui_border_hline = (entry->value < 0) ? ACS_HLINE : entry->value;
263
264 entry = translate (tui_border_kind, tui_border_kind_translate_vline);
265 tui_border_vline = (entry->value < 0) ? ACS_VLINE : entry->value;
266
267 return need_redraw;
268}
269
c9684879
SC
270static void
271set_tui_cmd (char *args, int from_tty)
272{
273}
274
275static void
276show_tui_cmd (char *args, int from_tty)
277{
278}
af101512 279
c906108c 280/*
c5aa993b
JM
281 ** _initialize_tuiWin().
282 ** Function to initialize gdb commands, for tui window manipulation.
283 */
c906108c 284void
fba45db2 285_initialize_tuiWin (void)
c906108c 286{
af101512 287 struct cmd_list_element *c;
c9684879
SC
288 static struct cmd_list_element *tui_setlist;
289 static struct cmd_list_element *tui_showlist;
af101512 290
41783295
SC
291 /* Define the classes of commands.
292 They will appear in the help list in the reverse of this order. */
e00d1dc8 293 add_cmd ("tui", class_tui, NULL,
41783295
SC
294 "Text User Interface commands.",
295 &cmdlist);
296
c9684879
SC
297 add_prefix_cmd ("tui", class_tui, set_tui_cmd,
298 "TUI configuration variables",
299 &tui_setlist, "set tui ",
300 0/*allow-unknown*/, &setlist);
301 add_prefix_cmd ("tui", class_tui, show_tui_cmd,
302 "TUI configuration variables",
303 &tui_showlist, "show tui ",
304 0/*allow-unknown*/, &showlist);
305
41783295
SC
306 add_com ("refresh", class_tui, _tuiRefreshAll_command,
307 "Refresh the terminal display.\n");
308 if (xdb_commands)
309 add_com_alias ("U", "refresh", class_tui, 0);
310 add_com ("tabset", class_tui, _tuiSetTabWidth_command,
311 "Set the width (in characters) of tab stops.\n\
c906108c 312Usage: tabset <n>\n");
41783295
SC
313 add_com ("winheight", class_tui, _tuiSetWinHeight_command,
314 "Set the height of a specified window.\n\
c906108c
SS
315Usage: winheight <win_name> [+ | -] <#lines>\n\
316Window names are:\n\
317src : the source window\n\
318cmd : the command window\n\
319asm : the disassembly window\n\
320regs : the register display\n");
41783295
SC
321 add_com_alias ("wh", "winheight", class_tui, 0);
322 add_info ("win", _tuiAllWindowsInfo,
323 "List of all displayed windows.\n");
324 add_com ("focus", class_tui, _tuiSetFocus_command,
325 "Set focus to named window or next/prev window.\n\
c906108c
SS
326Usage: focus {<win> | next | prev}\n\
327Valid Window names are:\n\
328src : the source window\n\
329asm : the disassembly window\n\
330regs : the register display\n\
331cmd : the command window\n");
41783295
SC
332 add_com_alias ("fs", "focus", class_tui, 0);
333 add_com ("+", class_tui, _tuiScrollForward_command,
334 "Scroll window forward.\nUsage: + [win] [n]\n");
335 add_com ("-", class_tui, _tuiScrollBackward_command,
336 "Scroll window backward.\nUsage: - [win] [n]\n");
337 add_com ("<", class_tui, _tuiScrollLeft_command,
338 "Scroll window forward.\nUsage: < [win] [n]\n");
339 add_com (">", class_tui, _tuiScrollRight_command,
340 "Scroll window backward.\nUsage: > [win] [n]\n");
341 if (xdb_commands)
342 add_com ("w", class_xdb, _tuiXDBsetWinHeight_command,
343 "XDB compatibility command for setting the height of a command window.\n\
c906108c 344Usage: w <#lines>\n");
af101512
SC
345
346 /* Define the tui control variables. */
347 c = add_set_enum_cmd
c9684879 348 ("border-kind", no_class,
c6f60bcd 349 tui_border_kind_enums, &tui_border_kind,
af101512
SC
350 "Set the kind of border for TUI windows.\n"
351 "This variable controls the border of TUI windows:\n"
352 "space use a white space\n"
353 "ascii use ascii characters + - | for the border\n"
354 "acs use the Alternate Character Set\n",
c9684879
SC
355 &tui_setlist);
356 add_show_from_set (c, &tui_showlist);
af101512
SC
357
358 c = add_set_enum_cmd
c9684879 359 ("border-mode", no_class,
c6f60bcd 360 tui_border_mode_enums, &tui_border_mode,
af101512
SC
361 "Set the attribute mode to use for the TUI window borders.\n"
362 "This variable controls the attributes to use for the window borders:\n"
363 "normal normal display\n"
364 "standout use highlight mode of terminal\n"
365 "reverse use reverse video mode\n"
366 "half use half bright\n"
367 "half-standout use half bright and standout mode\n"
368 "bold use extra bright or bold\n"
369 "bold-standout use extra bright or bold with standout mode\n",
c9684879
SC
370 &tui_setlist);
371 add_show_from_set (c, &tui_showlist);
af101512
SC
372
373 c = add_set_enum_cmd
c9684879 374 ("active-border-mode", no_class,
c6f60bcd 375 tui_border_mode_enums, &tui_active_border_mode,
af101512
SC
376 "Set the attribute mode to use for the active TUI window border.\n"
377 "This variable controls the attributes to use for the active window border:\n"
378 "normal normal display\n"
379 "standout use highlight mode of terminal\n"
380 "reverse use reverse video mode\n"
381 "half use half bright\n"
382 "half-standout use half bright and standout mode\n"
383 "bold use extra bright or bold\n"
384 "bold-standout use extra bright or bold with standout mode\n",
c9684879
SC
385 &tui_setlist);
386 add_show_from_set (c, &tui_showlist);
41783295 387}
c906108c
SS
388
389
390/*
c5aa993b
JM
391 ** tuiClearWinFocusFrom
392 ** Clear the logical focus from winInfo
393 */
c906108c 394void
eca6576c 395tuiClearWinFocusFrom (TuiWinInfoPtr winInfo)
c906108c
SS
396{
397 if (m_winPtrNotNull (winInfo))
398 {
399 if (winInfo->generic.type != CMD_WIN)
400 unhighlightWin (winInfo);
401 tuiSetWinWithFocus ((TuiWinInfoPtr) NULL);
402 }
403
404 return;
405} /* tuiClearWinFocusFrom */
406
407
408/*
c5aa993b
JM
409 ** tuiClearWinFocus().
410 ** Clear the window that has focus.
411 */
c906108c 412void
c906108c 413tuiClearWinFocus (void)
c906108c
SS
414{
415 tuiClearWinFocusFrom (tuiWinWithFocus ());
416
417 return;
418} /* tuiClearWinFocus */
419
420
421/*
c5aa993b
JM
422 ** tuiSetWinFocusTo
423 ** Set the logical focus to winInfo
424 */
c906108c 425void
eca6576c 426tuiSetWinFocusTo (TuiWinInfoPtr winInfo)
c906108c
SS
427{
428 if (m_winPtrNotNull (winInfo))
429 {
430 TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
431
432 if (m_winPtrNotNull (winWithFocus) &&
433 winWithFocus->generic.type != CMD_WIN)
434 unhighlightWin (winWithFocus);
435 tuiSetWinWithFocus (winInfo);
436 if (winInfo->generic.type != CMD_WIN)
437 highlightWin (winInfo);
438 }
439
440 return;
441} /* tuiSetWinFocusTo */
442
443
c906108c 444/*
c5aa993b
JM
445 ** tuiScrollForward().
446 */
c906108c 447void
eca6576c 448tuiScrollForward (TuiWinInfoPtr winToScroll, int numToScroll)
c906108c
SS
449{
450 if (winToScroll != cmdWin)
451 {
452 int _numToScroll = numToScroll;
453
454 if (numToScroll == 0)
455 _numToScroll = winToScroll->generic.height - 3;
456 /*
c5aa993b
JM
457 ** If we are scrolling the source or disassembly window, do a
458 ** "psuedo" scroll since not all of the source is in memory,
459 ** only what is in the viewport. If winToScroll is the
460 ** command window do nothing since the term should handle it.
461 */
c906108c
SS
462 if (winToScroll == srcWin)
463 tuiVerticalSourceScroll (FORWARD_SCROLL, _numToScroll);
464 else if (winToScroll == disassemWin)
465 tuiVerticalDisassemScroll (FORWARD_SCROLL, _numToScroll);
466 else if (winToScroll == dataWin)
467 tuiVerticalDataScroll (FORWARD_SCROLL, _numToScroll);
468 }
469
470 return;
471} /* tuiScrollForward */
472
473
474/*
c5aa993b
JM
475 ** tuiScrollBackward().
476 */
c906108c 477void
eca6576c 478tuiScrollBackward (TuiWinInfoPtr winToScroll, int numToScroll)
c906108c
SS
479{
480 if (winToScroll != cmdWin)
481 {
482 int _numToScroll = numToScroll;
483
484 if (numToScroll == 0)
485 _numToScroll = winToScroll->generic.height - 3;
486 /*
c5aa993b
JM
487 ** If we are scrolling the source or disassembly window, do a
488 ** "psuedo" scroll since not all of the source is in memory,
489 ** only what is in the viewport. If winToScroll is the
490 ** command window do nothing since the term should handle it.
491 */
c906108c
SS
492 if (winToScroll == srcWin)
493 tuiVerticalSourceScroll (BACKWARD_SCROLL, _numToScroll);
494 else if (winToScroll == disassemWin)
495 tuiVerticalDisassemScroll (BACKWARD_SCROLL, _numToScroll);
496 else if (winToScroll == dataWin)
497 tuiVerticalDataScroll (BACKWARD_SCROLL, _numToScroll);
498 }
499 return;
500} /* tuiScrollBackward */
501
502
503/*
c5aa993b
JM
504 ** tuiScrollLeft().
505 */
c906108c 506void
eca6576c 507tuiScrollLeft (TuiWinInfoPtr winToScroll, int numToScroll)
c906108c
SS
508{
509 if (winToScroll != cmdWin)
510 {
511 int _numToScroll = numToScroll;
512
513 if (_numToScroll == 0)
514 _numToScroll = 1;
515 /*
c5aa993b
JM
516 ** If we are scrolling the source or disassembly window, do a
517 ** "psuedo" scroll since not all of the source is in memory,
518 ** only what is in the viewport. If winToScroll is the
519 ** command window do nothing since the term should handle it.
520 */
c906108c
SS
521 if (winToScroll == srcWin || winToScroll == disassemWin)
522 tuiHorizontalSourceScroll (winToScroll, LEFT_SCROLL, _numToScroll);
523 }
524 return;
525} /* tuiScrollLeft */
526
527
528/*
c5aa993b
JM
529 ** tuiScrollRight().
530 */
c906108c 531void
eca6576c 532tuiScrollRight (TuiWinInfoPtr winToScroll, int numToScroll)
c906108c
SS
533{
534 if (winToScroll != cmdWin)
535 {
536 int _numToScroll = numToScroll;
537
538 if (_numToScroll == 0)
539 _numToScroll = 1;
540 /*
c5aa993b
JM
541 ** If we are scrolling the source or disassembly window, do a
542 ** "psuedo" scroll since not all of the source is in memory,
543 ** only what is in the viewport. If winToScroll is the
544 ** command window do nothing since the term should handle it.
545 */
c906108c
SS
546 if (winToScroll == srcWin || winToScroll == disassemWin)
547 tuiHorizontalSourceScroll (winToScroll, RIGHT_SCROLL, _numToScroll);
548 }
549 return;
550} /* tuiScrollRight */
551
552
553/*
e8b915dc 554 ** tui_scroll().
c5aa993b
JM
555 ** Scroll a window. Arguments are passed through a va_list.
556 */
c906108c 557void
e8b915dc
SC
558tui_scroll (TuiScrollDirection direction,
559 TuiWinInfoPtr winToScroll,
560 int numToScroll)
c906108c 561{
c906108c
SS
562 switch (direction)
563 {
564 case FORWARD_SCROLL:
565 tuiScrollForward (winToScroll, numToScroll);
566 break;
567 case BACKWARD_SCROLL:
568 tuiScrollBackward (winToScroll, numToScroll);
569 break;
570 case LEFT_SCROLL:
571 tuiScrollLeft (winToScroll, numToScroll);
572 break;
573 case RIGHT_SCROLL:
574 tuiScrollRight (winToScroll, numToScroll);
575 break;
576 default:
577 break;
578 }
e8b915dc 579}
c906108c
SS
580
581
582/*
c5aa993b
JM
583 ** tuiRefreshAll().
584 */
c906108c 585void
c906108c 586tuiRefreshAll (void)
c906108c
SS
587{
588 TuiWinType type;
589
3e266828 590 clearok (curscr, TRUE);
c906108c
SS
591 refreshAll (winList);
592 for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++)
593 {
75fd9bc1 594 if (winList[type] && winList[type]->generic.isVisible)
c906108c
SS
595 {
596 switch (type)
597 {
598 case SRC_WIN:
599 case DISASSEM_WIN:
600 tuiClearWin (&winList[type]->generic);
601 if (winList[type]->detail.sourceInfo.hasLocator)
602 tuiClearLocatorDisplay ();
603 tuiShowSourceContent (winList[type]);
604 checkAndDisplayHighlightIfNeeded (winList[type]);
605 tuiEraseExecInfoContent (winList[type]);
606 tuiUpdateExecInfo (winList[type]);
607 break;
608 case DATA_WIN:
609 tuiRefreshDataWin ();
610 break;
611 default:
612 break;
613 }
614 }
615 }
616 tuiClearLocatorDisplay ();
617 tuiShowLocatorContent ();
618
619 return;
620} /* tuiRefreshAll */
621
622
623/*
c5aa993b
JM
624 ** tuiResizeAll().
625 ** Resize all the windows based on the the terminal size. This
626 ** function gets called from within the readline sinwinch handler.
627 */
c906108c 628void
c906108c 629tuiResizeAll (void)
c906108c
SS
630{
631 int heightDiff, widthDiff;
c5aa993b 632 extern int screenheight, screenwidth; /* in readline */
c906108c
SS
633
634 widthDiff = screenwidth - termWidth ();
635 heightDiff = screenheight - termHeight ();
636 if (heightDiff || widthDiff)
637 {
638 TuiLayoutType curLayout = currentLayout ();
639 TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
640 TuiWinInfoPtr firstWin, secondWin;
641 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
642 TuiWinType winType;
643 int i, newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2;
644
645 /* turn keypad off while we resize */
646 if (winWithFocus != cmdWin)
647 keypad (cmdWin->generic.handle, FALSE);
648 init_page_info ();
649 setTermHeightTo (screenheight);
650 setTermWidthTo (screenwidth);
651 if (curLayout == SRC_DISASSEM_COMMAND ||
652 curLayout == SRC_DATA_COMMAND || curLayout == DISASSEM_DATA_COMMAND)
653 numWinsDisplayed++;
654 splitDiff = heightDiff / numWinsDisplayed;
655 cmdSplitDiff = splitDiff;
656 if (heightDiff % numWinsDisplayed)
657 {
658 if (heightDiff < 0)
659 cmdSplitDiff--;
660 else
661 cmdSplitDiff++;
662 }
663 /* now adjust each window */
664 clear ();
665 refresh ();
666 switch (curLayout)
667 {
668 case SRC_COMMAND:
669 case DISASSEM_COMMAND:
670 firstWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
671 firstWin->generic.width += widthDiff;
672 locator->width += widthDiff;
673 /* check for invalid heights */
674 if (heightDiff == 0)
675 newHeight = firstWin->generic.height;
676 else if ((firstWin->generic.height + splitDiff) >=
677 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
678 newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1;
679 else if ((firstWin->generic.height + splitDiff) <= 0)
680 newHeight = MIN_WIN_HEIGHT;
681 else
682 newHeight = firstWin->generic.height + splitDiff;
683
684 _makeInvisibleAndSetNewHeight (firstWin, newHeight);
685 cmdWin->generic.origin.y = locator->origin.y + 1;
686 cmdWin->generic.width += widthDiff;
687 newHeight = screenheight - cmdWin->generic.origin.y;
688 _makeInvisibleAndSetNewHeight (cmdWin, newHeight);
689 _makeVisibleWithNewHeight (firstWin);
690 _makeVisibleWithNewHeight (cmdWin);
691 if (firstWin->generic.contentSize <= 0)
692 tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT);
693 break;
694 default:
695 if (curLayout == SRC_DISASSEM_COMMAND)
696 {
697 firstWin = srcWin;
698 firstWin->generic.width += widthDiff;
699 secondWin = disassemWin;
700 secondWin->generic.width += widthDiff;
701 }
702 else
703 {
704 firstWin = dataWin;
705 firstWin->generic.width += widthDiff;
706 secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
707 secondWin->generic.width += widthDiff;
708 }
709 /* Change the first window's height/width */
710 /* check for invalid heights */
711 if (heightDiff == 0)
712 newHeight = firstWin->generic.height;
713 else if ((firstWin->generic.height +
714 secondWin->generic.height + (splitDiff * 2)) >=
715 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
716 newHeight = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2;
717 else if ((firstWin->generic.height + splitDiff) <= 0)
718 newHeight = MIN_WIN_HEIGHT;
719 else
720 newHeight = firstWin->generic.height + splitDiff;
721 _makeInvisibleAndSetNewHeight (firstWin, newHeight);
722
723 if (firstWin == dataWin && widthDiff != 0)
724 firstWin->detail.dataDisplayInfo.regsColumnCount =
725 tuiCalculateRegsColumnCount (
726 firstWin->detail.dataDisplayInfo.regsDisplayType);
727 locator->width += widthDiff;
728
729 /* Change the second window's height/width */
730 /* check for invalid heights */
731 if (heightDiff == 0)
732 newHeight = secondWin->generic.height;
733 else if ((firstWin->generic.height +
734 secondWin->generic.height + (splitDiff * 2)) >=
735 (screenheight - MIN_CMD_WIN_HEIGHT - 1))
736 {
737 newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1;
738 if (newHeight % 2)
739 newHeight = (newHeight / 2) + 1;
740 else
741 newHeight /= 2;
742 }
743 else if ((secondWin->generic.height + splitDiff) <= 0)
744 newHeight = MIN_WIN_HEIGHT;
745 else
746 newHeight = secondWin->generic.height + splitDiff;
747 secondWin->generic.origin.y = firstWin->generic.height - 1;
748 _makeInvisibleAndSetNewHeight (secondWin, newHeight);
749
750 /* Change the command window's height/width */
751 cmdWin->generic.origin.y = locator->origin.y + 1;
752 _makeInvisibleAndSetNewHeight (
753 cmdWin, cmdWin->generic.height + cmdSplitDiff);
754 _makeVisibleWithNewHeight (firstWin);
755 _makeVisibleWithNewHeight (secondWin);
756 _makeVisibleWithNewHeight (cmdWin);
757 if (firstWin->generic.contentSize <= 0)
758 tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT);
759 if (secondWin->generic.contentSize <= 0)
760 tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT);
761 break;
762 }
763 /*
c5aa993b
JM
764 ** Now remove all invisible windows, and their content so that they get
765 ** created again when called for with the new size
766 */
c906108c
SS
767 for (winType = SRC_WIN; (winType < MAX_MAJOR_WINDOWS); winType++)
768 {
769 if (winType != CMD_WIN && m_winPtrNotNull (winList[winType]) &&
770 !winList[winType]->generic.isVisible)
771 {
772 freeWindow (winList[winType]);
773 winList[winType] = (TuiWinInfoPtr) NULL;
774 }
775 }
776 tuiSetWinResizedTo (TRUE);
777 /* turn keypad back on, unless focus is in the command window */
778 if (winWithFocus != cmdWin)
779 keypad (cmdWin->generic.handle, TRUE);
780 }
781 return;
782} /* tuiResizeAll */
783
784
785/*
c5aa993b
JM
786 ** tuiSigwinchHandler()
787 ** SIGWINCH signal handler for the tui. This signal handler is
788 ** always called, even when the readline package clears signals
789 ** because it is set as the old_sigwinch() (TUI only)
790 */
c906108c 791void
eca6576c 792tuiSigwinchHandler (int signal)
c906108c
SS
793{
794 /*
c5aa993b
JM
795 ** Say that a resize was done so that the readline can do it
796 ** later when appropriate.
797 */
c906108c
SS
798 tuiSetWinResizedTo (TRUE);
799
800 return;
801} /* tuiSigwinchHandler */
802
803
804
805/*************************
806** STATIC LOCAL FUNCTIONS
807**************************/
808
809
810/*
c5aa993b
JM
811 ** _tuiScrollForward_command().
812 */
c906108c 813static void
eca6576c 814_tuiScrollForward_command (char *arg, int fromTTY)
c906108c
SS
815{
816 int numToScroll = 1;
817 TuiWinInfoPtr winToScroll;
818
1854bb21
SC
819 /* Make sure the curses mode is enabled. */
820 tui_enable ();
c906108c
SS
821 if (arg == (char *) NULL)
822 _parseScrollingArgs (arg, &winToScroll, (int *) NULL);
823 else
824 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
e8b915dc
SC
825 tui_scroll (FORWARD_SCROLL, winToScroll, numToScroll);
826}
c906108c
SS
827
828
829/*
c5aa993b
JM
830 ** _tuiScrollBackward_command().
831 */
c906108c 832static void
eca6576c 833_tuiScrollBackward_command (char *arg, int fromTTY)
c906108c
SS
834{
835 int numToScroll = 1;
836 TuiWinInfoPtr winToScroll;
837
1854bb21
SC
838 /* Make sure the curses mode is enabled. */
839 tui_enable ();
c906108c
SS
840 if (arg == (char *) NULL)
841 _parseScrollingArgs (arg, &winToScroll, (int *) NULL);
842 else
843 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
e8b915dc
SC
844 tui_scroll (BACKWARD_SCROLL, winToScroll, numToScroll);
845}
c906108c
SS
846
847
848/*
c5aa993b
JM
849 ** _tuiScrollLeft_command().
850 */
c906108c 851static void
eca6576c 852_tuiScrollLeft_command (char *arg, int fromTTY)
c906108c
SS
853{
854 int numToScroll;
855 TuiWinInfoPtr winToScroll;
856
1854bb21
SC
857 /* Make sure the curses mode is enabled. */
858 tui_enable ();
c906108c 859 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
e8b915dc
SC
860 tui_scroll (LEFT_SCROLL, winToScroll, numToScroll);
861}
c906108c
SS
862
863
864/*
c5aa993b
JM
865 ** _tuiScrollRight_command().
866 */
c906108c 867static void
eca6576c 868_tuiScrollRight_command (char *arg, int fromTTY)
c906108c
SS
869{
870 int numToScroll;
871 TuiWinInfoPtr winToScroll;
872
1854bb21
SC
873 /* Make sure the curses mode is enabled. */
874 tui_enable ();
c906108c 875 _parseScrollingArgs (arg, &winToScroll, &numToScroll);
e8b915dc
SC
876 tui_scroll (RIGHT_SCROLL, winToScroll, numToScroll);
877}
c906108c
SS
878
879
880/*
c5aa993b
JM
881 ** _tuiSetFocus().
882 ** Set focus to the window named by 'arg'
883 */
c906108c 884static void
eca6576c 885_tuiSetFocus (char *arg, int fromTTY)
c906108c
SS
886{
887 if (arg != (char *) NULL)
888 {
1854bb21 889 char *bufPtr = (char *) xstrdup (arg);
c906108c
SS
890 int i;
891 TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL;
892
893 for (i = 0; (i < strlen (bufPtr)); i++)
894 bufPtr[i] = toupper (arg[i]);
895
0963fc96 896 if (subset_compare (bufPtr, "NEXT"))
c906108c 897 winInfo = tuiNextWin (tuiWinWithFocus ());
0963fc96 898 else if (subset_compare (bufPtr, "PREV"))
c906108c
SS
899 winInfo = tuiPrevWin (tuiWinWithFocus ());
900 else
901 winInfo = partialWinByName (bufPtr);
902
903 if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible)
904 warning ("Invalid window specified. \n\
905The window name specified must be valid and visible.\n");
906 else
907 {
908 tuiSetWinFocusTo (winInfo);
909 keypad (cmdWin->generic.handle, (winInfo != cmdWin));
910 }
911
75fd9bc1 912 if (dataWin && dataWin->generic.isVisible)
c906108c
SS
913 tuiRefreshDataWin ();
914 tuiFree (bufPtr);
915 printf_filtered ("Focus set to %s window.\n",
916 winName ((TuiGenWinInfoPtr) tuiWinWithFocus ()));
917 }
918 else
919 warning ("Incorrect Number of Arguments.\n%s", FOCUS_USAGE);
920
921 return;
922} /* _tuiSetFocus */
923
c906108c 924/*
c5aa993b
JM
925 ** _tuiSetFocus_command()
926 */
c906108c 927static void
eca6576c 928_tuiSetFocus_command (char *arg, int fromTTY)
c906108c 929{
1854bb21
SC
930 /* Make sure the curses mode is enabled. */
931 tui_enable ();
e8b915dc
SC
932 _tuiSetFocus (arg, fromTTY);
933}
c906108c
SS
934
935
936/*
c5aa993b
JM
937 ** _tuiAllWindowsInfo().
938 */
c906108c 939static void
eca6576c 940_tuiAllWindowsInfo (char *arg, int fromTTY)
c906108c
SS
941{
942 TuiWinType type;
943 TuiWinInfoPtr winWithFocus = tuiWinWithFocus ();
944
945 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
946 if (winList[type]->generic.isVisible)
947 {
948 if (winWithFocus == winList[type])
949 printf_filtered (" %s\t(%d lines) <has focus>\n",
950 winName (&winList[type]->generic),
951 winList[type]->generic.height);
952 else
953 printf_filtered (" %s\t(%d lines)\n",
954 winName (&winList[type]->generic),
955 winList[type]->generic.height);
956 }
957
958 return;
959} /* _tuiAllWindowsInfo */
960
961
962/*
c5aa993b
JM
963 ** _tuiRefreshAll_command().
964 */
c906108c 965static void
eca6576c 966_tuiRefreshAll_command (char *arg, int fromTTY)
c906108c 967{
1854bb21
SC
968 /* Make sure the curses mode is enabled. */
969 tui_enable ();
970
e8b915dc 971 tuiRefreshAll ();
c906108c
SS
972}
973
974
975/*
c5aa993b
JM
976 ** _tuiSetWinTabWidth_command().
977 ** Set the height of the specified window.
978 */
c906108c 979static void
eca6576c 980_tuiSetTabWidth_command (char *arg, int fromTTY)
c906108c 981{
1854bb21
SC
982 /* Make sure the curses mode is enabled. */
983 tui_enable ();
c906108c
SS
984 if (arg != (char *) NULL)
985 {
986 int ts;
987
988 ts = atoi (arg);
989 if (ts > 0)
990 tuiSetDefaultTabLen (ts);
991 else
992 warning ("Tab widths greater than 0 must be specified.\n");
993 }
994
995 return;
996} /* _tuiSetTabWidth_command */
997
998
999/*
c5aa993b
JM
1000 ** _tuiSetWinHeight().
1001 ** Set the height of the specified window.
1002 */
c906108c 1003static void
eca6576c 1004_tuiSetWinHeight (char *arg, int fromTTY)
c906108c 1005{
1854bb21
SC
1006 /* Make sure the curses mode is enabled. */
1007 tui_enable ();
c906108c
SS
1008 if (arg != (char *) NULL)
1009 {
1854bb21 1010 char *buf = xstrdup (arg);
c906108c
SS
1011 char *bufPtr = buf;
1012 char *wname = (char *) NULL;
1013 int newHeight, i;
1014 TuiWinInfoPtr winInfo;
1015
1016 wname = bufPtr;
1017 bufPtr = strchr (bufPtr, ' ');
1018 if (bufPtr != (char *) NULL)
1019 {
1020 *bufPtr = (char) 0;
1021
1022 /*
c5aa993b
JM
1023 ** Validate the window name
1024 */
c906108c
SS
1025 for (i = 0; i < strlen (wname); i++)
1026 wname[i] = toupper (wname[i]);
1027 winInfo = partialWinByName (wname);
1028
1029 if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible)
1030 warning ("Invalid window specified. \n\
1031The window name specified must be valid and visible.\n");
1032 else
1033 {
1034 /* Process the size */
1035 while (*(++bufPtr) == ' ')
1036 ;
1037
1038 if (*bufPtr != (char) 0)
1039 {
1040 int negate = FALSE;
1041 int fixedSize = TRUE;
1042 int inputNo;;
1043
1044 if (*bufPtr == '+' || *bufPtr == '-')
1045 {
1046 if (*bufPtr == '-')
1047 negate = TRUE;
1048 fixedSize = FALSE;
1049 bufPtr++;
1050 }
1051 inputNo = atoi (bufPtr);
1052 if (inputNo > 0)
1053 {
1054 if (negate)
1055 inputNo *= (-1);
1056 if (fixedSize)
1057 newHeight = inputNo;
1058 else
1059 newHeight = winInfo->generic.height + inputNo;
1060 /*
c5aa993b
JM
1061 ** Now change the window's height, and adjust all
1062 ** other windows around it
1063 */
c906108c
SS
1064 if (_tuiAdjustWinHeights (winInfo,
1065 newHeight) == TUI_FAILURE)
1066 warning ("Invalid window height specified.\n%s",
1067 WIN_HEIGHT_USAGE);
1068 else
1069 init_page_info ();
1070 }
1071 else
1072 warning ("Invalid window height specified.\n%s",
1073 WIN_HEIGHT_USAGE);
1074 }
1075 }
1076 }
1077 else
1078 printf_filtered (WIN_HEIGHT_USAGE);
1079
1080 if (buf != (char *) NULL)
1081 tuiFree (buf);
1082 }
1083 else
1084 printf_filtered (WIN_HEIGHT_USAGE);
1085
1086 return;
1087} /* _tuiSetWinHeight */
1088
c906108c 1089/*
c5aa993b
JM
1090 ** _tuiSetWinHeight_command().
1091 ** Set the height of the specified window, with va_list.
1092 */
c906108c 1093static void
eca6576c 1094_tuiSetWinHeight_command (char *arg, int fromTTY)
c906108c 1095{
1854bb21
SC
1096 /* Make sure the curses mode is enabled. */
1097 tui_enable ();
e8b915dc
SC
1098 _tuiSetWinHeight (arg, fromTTY);
1099}
c906108c
SS
1100
1101
1102/*
c5aa993b
JM
1103 ** _tuiXDBsetWinHeight().
1104 ** XDB Compatibility command for setting the window height. This will
1105 ** increase or decrease the command window by the specified amount.
1106 */
c906108c 1107static void
eca6576c 1108_tuiXDBsetWinHeight (char *arg, int fromTTY)
c906108c 1109{
1854bb21
SC
1110 /* Make sure the curses mode is enabled. */
1111 tui_enable ();
c906108c
SS
1112 if (arg != (char *) NULL)
1113 {
1114 int inputNo = atoi (arg);
1115
1116 if (inputNo > 0)
1117 { /* Add 1 for the locator */
1118 int newHeight = termHeight () - (inputNo + 1);
1119
1120 if (!_newHeightOk (winList[CMD_WIN], newHeight) ||
1121 _tuiAdjustWinHeights (winList[CMD_WIN],
1122 newHeight) == TUI_FAILURE)
1123 warning ("Invalid window height specified.\n%s",
1124 XDBWIN_HEIGHT_USAGE);
1125 }
1126 else
1127 warning ("Invalid window height specified.\n%s",
1128 XDBWIN_HEIGHT_USAGE);
1129 }
1130 else
1131 warning ("Invalid window height specified.\n%s", XDBWIN_HEIGHT_USAGE);
1132
1133 return;
1134} /* _tuiXDBsetWinHeight */
1135
c906108c 1136/*
c5aa993b
JM
1137 ** _tuiSetWinHeight_command().
1138 ** Set the height of the specified window, with va_list.
1139 */
c906108c 1140static void
eca6576c 1141_tuiXDBsetWinHeight_command (char *arg, int fromTTY)
c906108c 1142{
e8b915dc
SC
1143 _tuiXDBsetWinHeight (arg, fromTTY);
1144}
c906108c
SS
1145
1146
1147/*
c5aa993b
JM
1148 ** _tuiAdjustWinHeights().
1149 ** Function to adjust all window heights around the primary
1150 */
c906108c 1151static TuiStatus
eca6576c 1152_tuiAdjustWinHeights (TuiWinInfoPtr primaryWinInfo, int newHeight)
c906108c
SS
1153{
1154 TuiStatus status = TUI_FAILURE;
1155
1156 if (_newHeightOk (primaryWinInfo, newHeight))
1157 {
1158 status = TUI_SUCCESS;
1159 if (newHeight != primaryWinInfo->generic.height)
1160 {
1161 int i, diff;
1162 TuiWinInfoPtr winInfo;
1163 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
1164 TuiLayoutType curLayout = currentLayout ();
1165
1166 diff = (newHeight - primaryWinInfo->generic.height) * (-1);
1167 if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND)
1168 {
1169 TuiWinInfoPtr srcWinInfo;
1170
1171 _makeInvisibleAndSetNewHeight (primaryWinInfo, newHeight);
1172 if (primaryWinInfo->generic.type == CMD_WIN)
1173 {
1174 winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1175 srcWinInfo = winInfo;
1176 }
1177 else
1178 {
1179 winInfo = winList[CMD_WIN];
1180 srcWinInfo = primaryWinInfo;
1181 }
1182 _makeInvisibleAndSetNewHeight (winInfo,
1183 winInfo->generic.height + diff);
1184 cmdWin->generic.origin.y = locator->origin.y + 1;
1185 _makeVisibleWithNewHeight (winInfo);
1186 _makeVisibleWithNewHeight (primaryWinInfo);
1187 if (srcWinInfo->generic.contentSize <= 0)
1188 tuiEraseSourceContent (srcWinInfo, EMPTY_SOURCE_PROMPT);
1189 }
1190 else
1191 {
1192 TuiWinInfoPtr firstWin, secondWin;
1193
1194 if (curLayout == SRC_DISASSEM_COMMAND)
1195 {
1196 firstWin = srcWin;
1197 secondWin = disassemWin;
1198 }
1199 else
1200 {
1201 firstWin = dataWin;
1202 secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1203 }
1204 if (primaryWinInfo == cmdWin)
1205 { /*
c5aa993b
JM
1206 ** Split the change in height accross the 1st & 2nd windows
1207 ** adjusting them as well.
1208 */
c906108c
SS
1209 int firstSplitDiff = diff / 2; /* subtract the locator */
1210 int secondSplitDiff = firstSplitDiff;
1211
1212 if (diff % 2)
1213 {
1214 if (firstWin->generic.height >
1215 secondWin->generic.height)
1216 if (diff < 0)
1217 firstSplitDiff--;
1218 else
1219 firstSplitDiff++;
1220 else
1221 {
1222 if (diff < 0)
1223 secondSplitDiff--;
1224 else
1225 secondSplitDiff++;
1226 }
1227 }
1228 /* make sure that the minimum hieghts are honored */
1229 while ((firstWin->generic.height + firstSplitDiff) < 3)
1230 {
1231 firstSplitDiff++;
1232 secondSplitDiff--;
1233 }
1234 while ((secondWin->generic.height + secondSplitDiff) < 3)
1235 {
1236 secondSplitDiff++;
1237 firstSplitDiff--;
1238 }
1239 _makeInvisibleAndSetNewHeight (
1240 firstWin,
1241 firstWin->generic.height + firstSplitDiff);
1242 secondWin->generic.origin.y = firstWin->generic.height - 1;
1243 _makeInvisibleAndSetNewHeight (
1244 secondWin, secondWin->generic.height + secondSplitDiff);
1245 cmdWin->generic.origin.y = locator->origin.y + 1;
1246 _makeInvisibleAndSetNewHeight (cmdWin, newHeight);
1247 }
1248 else
1249 {
1250 if ((cmdWin->generic.height + diff) < 1)
1251 { /*
c5aa993b
JM
1252 ** If there is no way to increase the command window
1253 ** take real estate from the 1st or 2nd window.
1254 */
c906108c
SS
1255 if ((cmdWin->generic.height + diff) < 1)
1256 {
1257 int i;
1258 for (i = cmdWin->generic.height + diff;
1259 (i < 1); i++)
1260 if (primaryWinInfo == firstWin)
1261 secondWin->generic.height--;
1262 else
1263 firstWin->generic.height--;
1264 }
1265 }
1266 if (primaryWinInfo == firstWin)
1267 _makeInvisibleAndSetNewHeight (firstWin, newHeight);
1268 else
1269 _makeInvisibleAndSetNewHeight (
1270 firstWin,
1271 firstWin->generic.height);
1272 secondWin->generic.origin.y = firstWin->generic.height - 1;
1273 if (primaryWinInfo == secondWin)
1274 _makeInvisibleAndSetNewHeight (secondWin, newHeight);
1275 else
1276 _makeInvisibleAndSetNewHeight (
1277 secondWin, secondWin->generic.height);
1278 cmdWin->generic.origin.y = locator->origin.y + 1;
1279 if ((cmdWin->generic.height + diff) < 1)
1280 _makeInvisibleAndSetNewHeight (cmdWin, 1);
1281 else
1282 _makeInvisibleAndSetNewHeight (
1283 cmdWin, cmdWin->generic.height + diff);
1284 }
1285 _makeVisibleWithNewHeight (cmdWin);
1286 _makeVisibleWithNewHeight (secondWin);
1287 _makeVisibleWithNewHeight (firstWin);
1288 if (firstWin->generic.contentSize <= 0)
1289 tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT);
1290 if (secondWin->generic.contentSize <= 0)
1291 tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT);
1292 }
1293 }
1294 }
1295
1296 return status;
1297} /* _tuiAdjustWinHeights */
1298
1299
1300/*
c5aa993b
JM
1301 ** _makeInvisibleAndSetNewHeight().
1302 ** Function make the target window (and auxillary windows associated
1303 ** with the targer) invisible, and set the new height and location.
1304 */
c906108c 1305static void
eca6576c 1306_makeInvisibleAndSetNewHeight (TuiWinInfoPtr winInfo, int height)
c906108c
SS
1307{
1308 int i;
1309 struct symtab *s;
1310 TuiGenWinInfoPtr genWinInfo;
1311
1312
1313 m_beInvisible (&winInfo->generic);
1314 winInfo->generic.height = height;
1315 if (height > 1)
1316 winInfo->generic.viewportHeight = height - 1;
1317 else
1318 winInfo->generic.viewportHeight = height;
1319 if (winInfo != cmdWin)
1320 winInfo->generic.viewportHeight--;
1321
1322 /* Now deal with the auxillary windows associated with winInfo */
1323 switch (winInfo->generic.type)
1324 {
1325 case SRC_WIN:
1326 case DISASSEM_WIN:
1327 genWinInfo = winInfo->detail.sourceInfo.executionInfo;
1328 m_beInvisible (genWinInfo);
1329 genWinInfo->height = height;
1330 genWinInfo->origin.y = winInfo->generic.origin.y;
1331 if (height > 1)
1332 genWinInfo->viewportHeight = height - 1;
1333 else
1334 genWinInfo->viewportHeight = height;
1335 if (winInfo != cmdWin)
1336 genWinInfo->viewportHeight--;
1337
1338 if (m_hasLocator (winInfo))
1339 {
1340 genWinInfo = locatorWinInfoPtr ();
1341 m_beInvisible (genWinInfo);
1342 genWinInfo->origin.y = winInfo->generic.origin.y + height;
1343 }
1344 break;
1345 case DATA_WIN:
1346 /* delete all data item windows */
1347 for (i = 0; i < winInfo->generic.contentSize; i++)
1348 {
1349 genWinInfo = (TuiGenWinInfoPtr) & ((TuiWinElementPtr)
1350 winInfo->generic.content[i])->whichElement.dataWindow;
1351 tuiDelwin (genWinInfo->handle);
1352 genWinInfo->handle = (WINDOW *) NULL;
1353 }
1354 break;
1355 default:
1356 break;
1357 }
1358
1359 return;
1360} /* _makeInvisibleAndSetNewHeight */
1361
1362
1363/*
c5aa993b
JM
1364 ** _makeVisibleWithNewHeight().
1365 ** Function to make the windows with new heights visible.
1366 ** This means re-creating the windows' content since the window
1367 ** had to be destroyed to be made invisible.
1368 */
c906108c 1369static void
eca6576c 1370_makeVisibleWithNewHeight (TuiWinInfoPtr winInfo)
c906108c
SS
1371{
1372 int i;
1373 struct symtab *s;
1374
1375 m_beVisible (&winInfo->generic);
1376 checkAndDisplayHighlightIfNeeded (winInfo);
1377 switch (winInfo->generic.type)
1378 {
1379 case SRC_WIN:
1380 case DISASSEM_WIN:
1381 freeWinContent (winInfo->detail.sourceInfo.executionInfo);
1382 m_beVisible (winInfo->detail.sourceInfo.executionInfo);
1383 if (winInfo->generic.content != (OpaquePtr) NULL)
1384 {
1385 TuiLineOrAddress lineOrAddr;
1386
1387 if (winInfo->generic.type == SRC_WIN)
1388 lineOrAddr.lineNo =
1389 winInfo->detail.sourceInfo.startLineOrAddr.lineNo;
1390 else
1391 lineOrAddr.addr =
1392 winInfo->detail.sourceInfo.startLineOrAddr.addr;
1393 freeWinContent (&winInfo->generic);
1394 tuiUpdateSourceWindow (winInfo,
a4b99e53 1395 current_source_symtab, lineOrAddr, TRUE);
c906108c
SS
1396 }
1397 else if (selected_frame != (struct frame_info *) NULL)
1398 {
a4b99e53 1399 TuiLineOrAddress line;
c906108c
SS
1400 extern int current_source_line;
1401
1402 s = find_pc_symtab (selected_frame->pc);
1403 if (winInfo->generic.type == SRC_WIN)
a4b99e53 1404 line.lineNo = current_source_line;
c906108c 1405 else
84b1e7c7 1406 {
a4b99e53 1407 find_line_pc (s, current_source_line, &line.addr);
84b1e7c7 1408 }
c906108c
SS
1409 tuiUpdateSourceWindow (winInfo, s, line, TRUE);
1410 }
1411 if (m_hasLocator (winInfo))
1412 {
1413 m_beVisible (locatorWinInfoPtr ());
1414 tuiClearLocatorDisplay ();
1415 tuiShowLocatorContent ();
1416 }
1417 break;
1418 case DATA_WIN:
1419 tuiDisplayAllData ();
1420 break;
1421 case CMD_WIN:
1422 winInfo->detail.commandInfo.curLine = 0;
1423 winInfo->detail.commandInfo.curch = 0;
1424 wmove (winInfo->generic.handle,
1425 winInfo->detail.commandInfo.curLine,
1426 winInfo->detail.commandInfo.curch);
1427 break;
1428 default:
1429 break;
1430 }
1431
1432 return;
1433} /* _makeVisibleWithNewHeight */
1434
1435
1436static int
eca6576c 1437_newHeightOk (TuiWinInfoPtr primaryWinInfo, int newHeight)
c906108c
SS
1438{
1439 int ok = (newHeight < termHeight ());
1440
1441 if (ok)
1442 {
1443 int diff, curHeight;
1444 TuiLayoutType curLayout = currentLayout ();
1445
1446 diff = (newHeight - primaryWinInfo->generic.height) * (-1);
1447 if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND)
1448 {
1449 ok = ((primaryWinInfo->generic.type == CMD_WIN &&
1450 newHeight <= (termHeight () - 4) &&
1451 newHeight >= MIN_CMD_WIN_HEIGHT) ||
1452 (primaryWinInfo->generic.type != CMD_WIN &&
1453 newHeight <= (termHeight () - 2) &&
1454 newHeight >= MIN_WIN_HEIGHT));
1455 if (ok)
1456 { /* check the total height */
1457 TuiWinInfoPtr winInfo;
1458
1459 if (primaryWinInfo == cmdWin)
1460 winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1461 else
1462 winInfo = cmdWin;
1463 ok = ((newHeight +
1464 (winInfo->generic.height + diff)) <= termHeight ());
1465 }
1466 }
1467 else
1468 {
1469 int curTotalHeight, totalHeight, minHeight;
1470 TuiWinInfoPtr firstWin, secondWin;
1471
1472 if (curLayout == SRC_DISASSEM_COMMAND)
1473 {
1474 firstWin = srcWin;
1475 secondWin = disassemWin;
1476 }
1477 else
1478 {
1479 firstWin = dataWin;
1480 secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1481 }
1482 /*
c5aa993b
JM
1483 ** We could simply add all the heights to obtain the same result
1484 ** but below is more explicit since we subtract 1 for the
1485 ** line that the first and second windows share, and add one
1486 ** for the locator.
1487 */
c906108c
SS
1488 curTotalHeight =
1489 (firstWin->generic.height + secondWin->generic.height - 1)
c5aa993b 1490 + cmdWin->generic.height + 1 /*locator */ ;
c906108c
SS
1491 if (primaryWinInfo == cmdWin)
1492 {
1493 /* locator included since first & second win share a line */
1494 ok = ((firstWin->generic.height +
1495 secondWin->generic.height + diff) >=
1496 (MIN_WIN_HEIGHT * 2) &&
1497 newHeight >= MIN_CMD_WIN_HEIGHT);
1498 if (ok)
1499 {
1500 totalHeight = newHeight + (firstWin->generic.height +
1501 secondWin->generic.height + diff);
1502 minHeight = MIN_CMD_WIN_HEIGHT;
1503 }
1504 }
1505 else
1506 {
1507 minHeight = MIN_WIN_HEIGHT;
1508 /*
c5aa993b
JM
1509 ** First see if we can increase/decrease the command
1510 ** window. And make sure that the command window is
1511 ** at least 1 line
1512 */
c906108c
SS
1513 ok = ((cmdWin->generic.height + diff) > 0);
1514 if (!ok)
1515 { /*
c5aa993b
JM
1516 ** Looks like we have to increase/decrease one of
1517 ** the other windows
1518 */
c906108c
SS
1519 if (primaryWinInfo == firstWin)
1520 ok = (secondWin->generic.height + diff) >= minHeight;
1521 else
1522 ok = (firstWin->generic.height + diff) >= minHeight;
1523 }
1524 if (ok)
1525 {
1526 if (primaryWinInfo == firstWin)
1527 totalHeight = newHeight +
1528 secondWin->generic.height +
1529 cmdWin->generic.height + diff;
1530 else
1531 totalHeight = newHeight +
1532 firstWin->generic.height +
1533 cmdWin->generic.height + diff;
1534 }
1535 }
1536 /*
c5aa993b
JM
1537 ** Now make sure that the proposed total height doesn't exceed
1538 ** the old total height.
1539 */
c906108c
SS
1540 if (ok)
1541 ok = (newHeight >= minHeight && totalHeight <= curTotalHeight);
1542 }
1543 }
1544
1545 return ok;
1546} /* _newHeightOk */
1547
1548
1549/*
c5aa993b
JM
1550 ** _parseScrollingArgs().
1551 */
c906108c 1552static void
eca6576c 1553_parseScrollingArgs (char *arg, TuiWinInfoPtr * winToScroll, int *numToScroll)
c906108c
SS
1554{
1555 if (numToScroll)
1556 *numToScroll = 0;
1557 *winToScroll = tuiWinWithFocus ();
1558
1559 /*
c5aa993b
JM
1560 ** First set up the default window to scroll, in case there is no
1561 ** window name arg
1562 */
c906108c
SS
1563 if (arg != (char *) NULL)
1564 {
1565 char *buf, *bufPtr;
1566
1567 /* process the number of lines to scroll */
1854bb21 1568 buf = bufPtr = xstrdup (arg);
c906108c
SS
1569 if (isdigit (*bufPtr))
1570 {
1571 char *numStr;
1572
1573 numStr = bufPtr;
1574 bufPtr = strchr (bufPtr, ' ');
1575 if (bufPtr != (char *) NULL)
1576 {
1577 *bufPtr = (char) 0;
1578 if (numToScroll)
1579 *numToScroll = atoi (numStr);
1580 bufPtr++;
1581 }
1582 else if (numToScroll)
1583 *numToScroll = atoi (numStr);
1584 }
1585
1586 /* process the window name if one is specified */
1587 if (bufPtr != (char *) NULL)
1588 {
1589 char *wname;
1590 int i;
1591
1592 if (*bufPtr == ' ')
1593 while (*(++bufPtr) == ' ')
1594 ;
1595
1596 if (*bufPtr != (char) 0)
1597 wname = bufPtr;
a4b99e53
SC
1598 else
1599 wname = "?";
1600
c906108c
SS
1601 /* Validate the window name */
1602 for (i = 0; i < strlen (wname); i++)
1603 wname[i] = toupper (wname[i]);
1604 *winToScroll = partialWinByName (wname);
1605
1606 if (*winToScroll == (TuiWinInfoPtr) NULL ||
1607 !(*winToScroll)->generic.isVisible)
1608 warning ("Invalid window specified. \n\
1609The window name specified must be valid and visible.\n");
1610 else if (*winToScroll == cmdWin)
1611 *winToScroll = (TuiWinInfoPtr) (sourceWindows ())->list[0];
1612 }
1613 tuiFree (buf);
1614 }
1615
1616 return;
1617} /* _parseScrollingArgs */
This page took 0.248672 seconds and 4 git commands to generate.