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