]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/tui/tuiLayout.c
import gdb-1999-07-07 post reformat
[thirdparty/binutils-gdb.git] / gdb / tui / tuiLayout.c
CommitLineData
c906108c
SS
1/*
2** tuiLayout.c
3** This module contains procedures for handling the layout of the windows.
4*/
5
6
7#include "defs.h"
8#include "command.h"
9#include "symtab.h"
10#include "frame.h"
11
12#include "tui.h"
13#include "tuiData.h"
14#include "tuiGeneralWin.h"
15#include "tuiStack.h"
16#include "tuiRegs.h"
17#include "tuiDisassem.h"
18
19/*******************************
20** Static Local Decls
21********************************/
22
23static void _initGenWinInfo PARAMS
24 ((TuiGenWinInfoPtr, TuiWinType, int, int, int, int));
25static void _initAndMakeWin PARAMS
26 ((Opaque *, TuiWinType, int, int, int, int, int));
27static void _showSourceOrDisassemAndCommand PARAMS
28 ((TuiLayoutType));
29static void _makeSourceOrDisassemWindow PARAMS
30 ((TuiWinInfoPtr *, TuiWinType, int, int));
31static void _makeCommandWindow PARAMS ((TuiWinInfoPtr *, int, int));
32static void _makeSourceWindow PARAMS ((TuiWinInfoPtr *, int, int));
33static void _makeDisassemWindow PARAMS
34 ((TuiWinInfoPtr *, int, int));
35static void _makeDataWindow PARAMS ((TuiWinInfoPtr *, int, int));
36static void _showSourceCommand PARAMS ((void));
37static void _showDisassemCommand PARAMS ((void));
38static void _showSourceDisassemCommand PARAMS ((void));
39static void _showData PARAMS ((TuiLayoutType));
40static TuiLayoutType _nextLayout PARAMS ((void));
41static TuiLayoutType _prevLayout PARAMS ((void));
42static void _tuiLayout_command PARAMS ((char *, int));
43static void _tuiToggleLayout_command PARAMS ((char *, int));
44static void _tui_vToggleLayout_command PARAMS ((va_list));
45static void _tuiToggleSplitLayout_command PARAMS ((char *, int));
46static void _tui_vToggleSplitLayout_command PARAMS ((va_list));
47static Opaque _extractDisplayStartAddr PARAMS ((void));
48static void _tuiHandleXDBLayout PARAMS ((TuiLayoutDefPtr));
49static TuiStatus _tuiSetLayoutTo PARAMS ((char *));
50
51
52/***************************************
53** DEFINITIONS
54***************************************/
55
56#define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
57
58/***************************************
59** Static Local Data
60***************************************/
61static TuiLayoutType lastLayout = UNDEFINED_LAYOUT;
62
63/***************************************
64** PUBLIC FUNCTIONS
65***************************************/
66
67/*
68** showLayout().
69** Show the screen layout defined
70*/
71void
72#ifdef __STDC__
73showLayout (
74 TuiLayoutType layout)
75#else
76showLayout (layout)
77 TuiLayoutType layout;
78#endif
79{
80 TuiLayoutType curLayout = currentLayout ();
81
82 if (layout != curLayout)
83 {
84 /*
85 ** Since the new layout may cause changes in window size, we
86 ** should free the content and reallocate on next display of
87 ** source/asm
88 */
89 tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT);
90 freeAllSourceWinsContent ();
91 clearSourceWindows ();
92 if (layout == SRC_DATA_COMMAND || layout == DISASSEM_DATA_COMMAND)
93 {
94 _showData (layout);
95 refreshAll (winList);
96 }
97 else
98 {
99 /* First make the current layout be invisible */
100 m_allBeInvisible ();
101 m_beInvisible (locatorWinInfoPtr ());
102
103 switch (layout)
104 {
105 /* Now show the new layout */
106 case SRC_COMMAND:
107 _showSourceCommand ();
108 addToSourceWindows (srcWin);
109 break;
110 case DISASSEM_COMMAND:
111 _showDisassemCommand ();
112 addToSourceWindows (disassemWin);
113 break;
114 case SRC_DISASSEM_COMMAND:
115 _showSourceDisassemCommand ();
116 addToSourceWindows (srcWin);
117 addToSourceWindows (disassemWin);
118 break;
119 default:
120 break;
121 }
122 }
123 }
124
125 return;
126} /* showLayout */
127
128
129/*
130** tuiSetLayout()
131** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
132** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
133** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
134** UNDEFINED_LAYOUT, then the data window is populated according
135** to regsDisplayType.
136*/
137TuiStatus
138#ifdef __STDC__
139tuiSetLayout (
140 TuiLayoutType layoutType,
141 TuiRegisterDisplayType regsDisplayType)
142#else
143tuiSetLayout (layoutType, regsDisplayType)
144 TuiLayoutType layoutType;
145 TuiRegisterDisplayType regsDisplayType;
146#endif
147{
148 TuiStatus status = TUI_SUCCESS;
149
150 if (layoutType != UNDEFINED_LAYOUT || regsDisplayType != TUI_UNDEFINED_REGS)
151 {
152 TuiLayoutType curLayout = currentLayout (), newLayout = UNDEFINED_LAYOUT;
153 int regsPopulate = FALSE;
154 Opaque addr = _extractDisplayStartAddr ();
155 TuiWinInfoPtr newWinWithFocus = (TuiWinInfoPtr) NULL, winWithFocus = tuiWinWithFocus ();
156 TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
157
158
159 if (layoutType == UNDEFINED_LAYOUT &&
160 regsDisplayType != TUI_UNDEFINED_REGS)
161 {
162 if (curLayout == SRC_DISASSEM_COMMAND)
163 newLayout = DISASSEM_DATA_COMMAND;
164 else if (curLayout == SRC_COMMAND || curLayout == SRC_DATA_COMMAND)
165 newLayout = SRC_DATA_COMMAND;
166 else if (curLayout == DISASSEM_COMMAND ||
167 curLayout == DISASSEM_DATA_COMMAND)
168 newLayout = DISASSEM_DATA_COMMAND;
169 }
170 else
171 newLayout = layoutType;
172
173 regsPopulate = (newLayout == SRC_DATA_COMMAND ||
174 newLayout == DISASSEM_DATA_COMMAND ||
175 regsDisplayType != TUI_UNDEFINED_REGS);
176 if (newLayout != curLayout || regsDisplayType != TUI_UNDEFINED_REGS)
177 {
178 if (newLayout != curLayout)
179 {
180 if (winWithFocus != cmdWin)
181 tuiClearWinFocus ();
182 showLayout (newLayout);
183 /*
184 ** Now determine where focus should be
185 */
186 if (winWithFocus != cmdWin)
187 {
188 switch (newLayout)
189 {
190 case SRC_COMMAND:
191 tuiSetWinFocusTo (srcWin);
192 layoutDef->displayMode = SRC_WIN;
193 layoutDef->split = FALSE;
194 break;
195 case DISASSEM_COMMAND:
196 /* the previous layout was not showing
197 ** code. this can happen if there is no
198 ** source available:
199 ** 1. if the source file is in another dir OR
200 ** 2. if target was compiled without -g
201 ** We still want to show the assembly though!
202 */
203 addr = vcatch_errors ((OpaqueFuncPtr)
204 tuiGetBeginAsmAddress);
205 tuiSetWinFocusTo (disassemWin);
206 layoutDef->displayMode = DISASSEM_WIN;
207 layoutDef->split = FALSE;
208 break;
209 case SRC_DISASSEM_COMMAND:
210 /* the previous layout was not showing
211 ** code. this can happen if there is no
212 ** source available:
213 ** 1. if the source file is in another dir OR
214 ** 2. if target was compiled without -g
215 ** We still want to show the assembly though!
216 */
217 addr = vcatch_errors ((OpaqueFuncPtr)
218 tuiGetBeginAsmAddress);
219 if (winWithFocus == srcWin)
220 tuiSetWinFocusTo (srcWin);
221 else
222 tuiSetWinFocusTo (disassemWin);
223 layoutDef->split = TRUE;
224 break;
225 case SRC_DATA_COMMAND:
226 if (winWithFocus != dataWin)
227 tuiSetWinFocusTo (srcWin);
228 else
229 tuiSetWinFocusTo (dataWin);
230 layoutDef->displayMode = SRC_WIN;
231 layoutDef->split = FALSE;
232 break;
233 case DISASSEM_DATA_COMMAND:
234 /* the previous layout was not showing
235 ** code. this can happen if there is no
236 ** source available:
237 ** 1. if the source file is in another dir OR
238 ** 2. if target was compiled without -g
239 ** We still want to show the assembly though!
240 */
241 addr = vcatch_errors ((OpaqueFuncPtr)
242 tuiGetBeginAsmAddress);
243 if (winWithFocus != dataWin)
244 tuiSetWinFocusTo (disassemWin);
245 else
246 tuiSetWinFocusTo (dataWin);
247 layoutDef->displayMode = DISASSEM_WIN;
248 layoutDef->split = FALSE;
249 break;
250 default:
251 break;
252 }
253 }
254 if (newWinWithFocus != (TuiWinInfoPtr) NULL)
255 tuiSetWinFocusTo (newWinWithFocus);
256 /*
257 ** Now update the window content
258 */
259 if (!regsPopulate &&
260 (newLayout == SRC_DATA_COMMAND ||
261 newLayout == DISASSEM_DATA_COMMAND))
262 tuiDisplayAllData ();
263
264 tuiUpdateSourceWindowsWithAddr (addr);
265 }
266 if (regsPopulate)
267 {
268 layoutDef->regsDisplayType =
269 (regsDisplayType == TUI_UNDEFINED_REGS ?
270 TUI_GENERAL_REGS : regsDisplayType);
271 tuiShowRegisters (layoutDef->regsDisplayType);
272 }
273 }
274 }
275 else
276 status = TUI_FAILURE;
277
278 return status;
279} /* tuiSetLayout */
280
281
282/*
283** tui_vSetLayoutTo()
284** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
285** REGS, $REGS, $GREGS, $FREGS, $SREGS with arguments in a va_list
286*/
287TuiStatus
288#ifdef __STDC__
289tui_vSetLayoutTo (
290 va_list args)
291#else
292tui_vSetLayoutTo (args)
293 va_list args;
294#endif
295{
296 char *layoutName;
297
298 layoutName = va_arg (args, char *);
299
300 return (_tuiSetLayoutTo (layoutName));
301} /* tui_vSetLayoutTo */
302
303
304/*
305** tuiAddWinToLayout().
306** Add the specified window to the layout in a logical way.
307** This means setting up the most logical layout given the
308** window to be added.
309*/
310void
311#ifdef __STDC__
312tuiAddWinToLayout (
313 TuiWinType type)
314#else
315tuiAddWinToLayout (type)
316 TuiWinType type;
317#endif
318{
319 TuiLayoutType curLayout = currentLayout ();
320
321 switch (type)
322 {
323 case SRC_WIN:
324 if (curLayout != SRC_COMMAND &&
325 curLayout != SRC_DISASSEM_COMMAND &&
326 curLayout != SRC_DATA_COMMAND)
327 {
328 clearSourceWindowsDetail ();
329 if (curLayout == DISASSEM_DATA_COMMAND)
330 showLayout (SRC_DATA_COMMAND);
331 else
332 showLayout (SRC_COMMAND);
333 }
334 break;
335 case DISASSEM_WIN:
336 if (curLayout != DISASSEM_COMMAND &&
337 curLayout != SRC_DISASSEM_COMMAND &&
338 curLayout != DISASSEM_DATA_COMMAND)
339 {
340 clearSourceWindowsDetail ();
341 if (curLayout == SRC_DATA_COMMAND)
342 showLayout (DISASSEM_DATA_COMMAND);
343 else
344 showLayout (DISASSEM_COMMAND);
345 }
346 break;
347 case DATA_WIN:
348 if (curLayout != SRC_DATA_COMMAND &&
349 curLayout != DISASSEM_DATA_COMMAND)
350 {
351 if (curLayout == DISASSEM_COMMAND)
352 showLayout (DISASSEM_DATA_COMMAND);
353 else
354 showLayout (SRC_DATA_COMMAND);
355 }
356 break;
357 default:
358 break;
359 }
360
361 return;
362} /* tuiAddWinToLayout */
363
364
365/*
366** tui_vAddWinToLayout().
367** Add the specified window to the layout in a logical way,
368** with arguments in a va_list.
369*/
370void
371#ifdef __STDC__
372tui_vAddWinToLayout (
373 va_list args)
374#else
375tui_vAddWinToLayout (args)
376 va_list args;
377#endif
378{
379 TuiWinType type = va_arg (args, TuiWinType);
380
381 tuiAddWinToLayout (type);
382
383 return;
384} /* tui_vAddWinToLayout */
385
386
387/*
388** tuiDefaultWinHeight().
389** Answer the height of a window. If it hasn't been created yet,
390** answer what the height of a window would be based upon its
391** type and the layout.
392*/
393int
394#ifdef __STDC__
395tuiDefaultWinHeight (
396 TuiWinType type,
397 TuiLayoutType layout)
398#else
399tuiDefaultWinHeight (type, layout)
400 TuiWinType type;
401 TuiLayoutType layout;
402#endif
403{
404 int h;
405
406 if (winList[type] != (TuiWinInfoPtr) NULL)
407 h = winList[type]->generic.height;
408 else
409 {
410 switch (layout)
411 {
412 case SRC_COMMAND:
413 case DISASSEM_COMMAND:
414 if (m_winPtrIsNull (cmdWin))
415 h = termHeight () / 2;
416 else
417 h = termHeight () - cmdWin->generic.height;
418 break;
419 case SRC_DISASSEM_COMMAND:
420 case SRC_DATA_COMMAND:
421 case DISASSEM_DATA_COMMAND:
422 if (m_winPtrIsNull (cmdWin))
423 h = termHeight () / 3;
424 else
425 h = (termHeight () - cmdWin->generic.height) / 2;
426 break;
427 default:
428 h = 0;
429 break;
430 }
431 }
432
433 return h;
434} /* tuiDefaultWinHeight */
435
436
437/*
438** tuiDefaultWinViewportHeight().
439** Answer the height of a window. If it hasn't been created yet,
440** answer what the height of a window would be based upon its
441** type and the layout.
442*/
443int
444#ifdef __STDC__
445tuiDefaultWinViewportHeight (
446 TuiWinType type,
447 TuiLayoutType layout)
448#else
449tuiDefaultWinViewportHeight (type, layout)
450 TuiWinType type;
451 TuiLayoutType layout;
452#endif
453{
454 int h;
455
456 h = tuiDefaultWinHeight (type, layout);
457
458 if (winList[type] == cmdWin)
459 h -= 1;
460 else
461 h -= 2;
462
463 return h;
464} /* tuiDefaultWinViewportHeight */
465
466
467/*
468** _initialize_tuiLayout().
469** Function to initialize gdb commands, for tui window layout
470** manipulation.
471*/
472void
473_initialize_tuiLayout ()
474{
475 if (tui_version)
476 {
477 add_com ("layout", class_tui, _tuiLayout_command,
478 "Change the layout of windows.\n\
479Usage: layout prev | next | <layout_name> \n\
480Layout names are:\n\
481 src : Displays source and command windows.\n\
482 asm : Displays disassembly and command windows.\n\
483 split : Displays source, disassembly and command windows.\n\
484 regs : Displays register window. If existing layout\n\
485 is source/command or assembly/command, the \n\
486 register window is displayed. If the\n\
487 source/assembly/command (split) is displayed, \n\
488 the register window is displayed with \n\
489 the window that has current logical focus.\n");
490 if (xdb_commands)
491 {
492 add_com ("td", class_tui, _tuiToggleLayout_command,
493 "Toggle between Source/Command and Disassembly/Command layouts.\n");
494 add_com ("ts", class_tui, _tuiToggleSplitLayout_command,
495 "Toggle between Source/Command or Disassembly/Command and \n\
496Source/Disassembly/Command layouts.\n");
497 }
498 }
499
500 return;
501} /* _intialize_tuiLayout */
502
503
504/*************************
505** STATIC LOCAL FUNCTIONS
506**************************/
507
508
509/*
510** _tuiSetLayoutTo()
511** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
512** $REGS, $GREGS, $FREGS, $SREGS.
513*/
514static TuiStatus
515#ifdef __STDC__
516_tuiSetLayoutTo (
517 char *layoutName)
518#else
519_tuiSetLayoutTo (layoutName)
520 char *layoutName;
521#endif
522{
523 TuiStatus status = TUI_SUCCESS;
524
525 if (layoutName != (char *) NULL)
526 {
527 register int i;
528 register char *bufPtr;
529 TuiLayoutType newLayout = UNDEFINED_LAYOUT;
530 TuiRegisterDisplayType dpyType = TUI_UNDEFINED_REGS;
531 TuiLayoutType curLayout = currentLayout ();
532
533 bufPtr = (char *) tuiStrDup (layoutName);
534 for (i = 0; (i < strlen (layoutName)); i++)
535 bufPtr[i] = toupper (bufPtr[i]);
536
537 /* First check for ambiguous input */
538 if (strlen (bufPtr) <= 1 && (*bufPtr == 'S' || *bufPtr == '$'))
539 {
540 warning ("Ambiguous command input.\n");
541 status = TUI_FAILURE;
542 }
543 else
544 {
545 if (subsetCompare (bufPtr, "SRC"))
546 newLayout = SRC_COMMAND;
547 else if (subsetCompare (bufPtr, "ASM"))
548 newLayout = DISASSEM_COMMAND;
549 else if (subsetCompare (bufPtr, "SPLIT"))
550 newLayout = SRC_DISASSEM_COMMAND;
551 else if (subsetCompare (bufPtr, "REGS") ||
552 subsetCompare (bufPtr, TUI_GENERAL_SPECIAL_REGS_NAME) ||
553 subsetCompare (bufPtr, TUI_GENERAL_REGS_NAME) ||
554 subsetCompare (bufPtr, TUI_FLOAT_REGS_NAME) ||
555 subsetCompare (bufPtr, TUI_SPECIAL_REGS_NAME))
556 {
557 if (curLayout == SRC_COMMAND || curLayout == SRC_DATA_COMMAND)
558 newLayout = SRC_DATA_COMMAND;
559 else
560 newLayout = DISASSEM_DATA_COMMAND;
561
562/* could ifdef out the following code. when compile with -z, there are null
563 pointer references that cause a core dump if 'layout regs' is the first
564 layout command issued by the user. HP has asked us to hook up this code
565 - edie epstein
566 */
567 if (subsetCompare (bufPtr, TUI_FLOAT_REGS_NAME))
568 {
569 if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
570 TUI_SFLOAT_REGS &&
571 dataWin->detail.dataDisplayInfo.regsDisplayType !=
572 TUI_DFLOAT_REGS)
573 dpyType = TUI_SFLOAT_REGS;
574 else
575 dpyType =
576 dataWin->detail.dataDisplayInfo.regsDisplayType;
577 }
578 else if (subsetCompare (bufPtr,
579 TUI_GENERAL_SPECIAL_REGS_NAME))
580 dpyType = TUI_GENERAL_AND_SPECIAL_REGS;
581 else if (subsetCompare (bufPtr, TUI_GENERAL_REGS_NAME))
582 dpyType = TUI_GENERAL_REGS;
583 else if (subsetCompare (bufPtr, TUI_SPECIAL_REGS_NAME))
584 dpyType = TUI_SPECIAL_REGS;
585 else
586 {
587 if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
588 TUI_UNDEFINED_REGS)
589 dpyType =
590 dataWin->detail.dataDisplayInfo.regsDisplayType;
591 else
592 dpyType = TUI_GENERAL_REGS;
593 }
594
595/* end of potential ifdef
596 */
597
598/* if ifdefed out code above, then assume that the user wishes to display the
599 general purpose registers
600 */
601
602/* dpyType = TUI_GENERAL_REGS;
603 */
604 }
605 else if (subsetCompare (bufPtr, "NEXT"))
606 newLayout = _nextLayout ();
607 else if (subsetCompare (bufPtr, "PREV"))
608 newLayout = _prevLayout ();
609 else
610 status = TUI_FAILURE;
611 free (bufPtr);
612
613 tuiSetLayout (newLayout, dpyType);
614 }
615 }
616 else
617 status = TUI_FAILURE;
618
619 return status;
620} /* _tuiSetLayoutTo */
621
622
623static Opaque
624#ifdef __STDC__
625_extractDisplayStartAddr (void)
626#else
627_extractDisplayStartAddr ()
628#endif
629{
630 TuiLayoutType curLayout = currentLayout ();
631 Opaque addr;
632
633 switch (curLayout)
634 {
635 case SRC_COMMAND:
636 case SRC_DATA_COMMAND:
637 addr = (Opaque) find_line_pc (
638 current_source_symtab,
639 srcWin->detail.sourceInfo.startLineOrAddr.lineNo);
640 break;
641 case DISASSEM_COMMAND:
642 case SRC_DISASSEM_COMMAND:
643 case DISASSEM_DATA_COMMAND:
644 addr = disassemWin->detail.sourceInfo.startLineOrAddr.addr;
645 break;
646 default:
647 addr = (Opaque) NULL;
648 break;
649 }
650
651 return addr;
652} /* _extractDisplayStartAddr */
653
654
655static void
656#ifdef __STDC__
657_tuiHandleXDBLayout (
658 TuiLayoutDefPtr layoutDef)
659#else
660_tuiHandleXDBLayout (layoutDef)
661 TuiLayoutDefPtr layoutDef;
662#endif
663{
664 if (layoutDef->split)
665 {
666 tuiSetLayout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
667 tuiSetWinFocusTo (winList[layoutDef->displayMode]);
668 }
669 else
670 {
671 if (layoutDef->displayMode == SRC_WIN)
672 tuiSetLayout (SRC_COMMAND, TUI_UNDEFINED_REGS);
673 else
674 tuiSetLayout (DISASSEM_DATA_COMMAND, layoutDef->regsDisplayType);
675 }
676
677
678 return;
679} /* _tuiHandleXDBLayout */
680
681
682static void
683#ifdef __STDC__
684_tuiToggleLayout_command (
685 char *arg,
686 int fromTTY)
687#else
688_tuiToggleLayout_command (arg, fromTTY)
689 char *arg;
690 int fromTTY;
691#endif
692{
693 tuiDo ((TuiOpaqueFuncPtr) _tui_vToggleLayout_command, arg, fromTTY);
694}
695
696static void
697#ifdef __STDC__
698_tui_vToggleLayout_command (
699 va_list args)
700#else
701_tui_vToggleLayout_command (args)
702 va_list args;
703#endif
704{
705 TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
706
707 if (layoutDef->displayMode == SRC_WIN)
708 layoutDef->displayMode = DISASSEM_WIN;
709 else
710 layoutDef->displayMode = SRC_WIN;
711
712 if (!layoutDef->split)
713 _tuiHandleXDBLayout (layoutDef);
714
715 return;
716} /* _tuiToggleLayout_command */
717
718
719static void
720#ifdef __STDC__
721_tuiToggleSplitLayout_command (
722 char *arg,
723 int fromTTY)
724#else
725_tuiToggleSplitLayout_command (arg, fromTTY)
726 char *arg;
727 int fromTTY;
728#endif
729{
730 tuiDo ((TuiOpaqueFuncPtr) _tui_vToggleSplitLayout_command, arg, fromTTY);
731}
732
733static void
734#ifdef __STDC__
735_tui_vToggleSplitLayout_command (
736 va_list args)
737#else
738_tui_vToggleSplitLayout_command (args)
739 va_list args;
740#endif
741{
742 TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
743
744 layoutDef->split = (!layoutDef->split);
745 _tuiHandleXDBLayout (layoutDef);
746
747 return;
748} /* _tui_vToggleSplitLayout_command */
749
750
751static void
752#ifdef __STDC__
753_tuiLayout_command (
754 char *arg,
755 int fromTTY)
756#else
757_tuiLayout_command (arg, fromTTY)
758 char *arg;
759 int fromTTY;
760#endif
761{
762 if ((TuiStatus) tuiDo (
763 (TuiOpaqueFuncPtr) tui_vSetLayoutTo, arg) != TUI_SUCCESS)
764 warning ("Invalid layout specified.\n%s" LAYOUT_USAGE);
765
766 return;
767} /* _tuiLayout_command */
768
769/*
770** _nextLayout().
771** Answer the previous layout to cycle to.
772*/
773static TuiLayoutType
774#ifdef __STDC__
775_nextLayout (void)
776#else
777_nextLayout ()
778#endif
779{
780 TuiLayoutType newLayout;
781
782 newLayout = currentLayout ();
783 if (newLayout == UNDEFINED_LAYOUT)
784 newLayout = SRC_COMMAND;
785 else
786 {
787 newLayout++;
788 if (newLayout == UNDEFINED_LAYOUT)
789 newLayout = SRC_COMMAND;
790 }
791
792 return newLayout;
793} /* _nextLayout */
794
795
796/*
797** _prevLayout().
798** Answer the next layout to cycle to.
799*/
800static TuiLayoutType
801#ifdef __STDC__
802_prevLayout (void)
803#else
804_prevLayout ()
805#endif
806{
807 TuiLayoutType newLayout;
808
809 newLayout = currentLayout ();
810 if (newLayout == SRC_COMMAND)
811 newLayout = DISASSEM_DATA_COMMAND;
812 else
813 {
814 newLayout--;
815 if (newLayout == UNDEFINED_LAYOUT)
816 newLayout = DISASSEM_DATA_COMMAND;
817 }
818
819 return newLayout;
820} /* _prevLayout */
821
822
823
824/*
825** _makeCommandWindow().
826*/
827static void
828#ifdef __STDC__
829_makeCommandWindow (
830 TuiWinInfoPtr * winInfoPtr,
831 int height,
832 int originY)
833#else
834_makeCommandWindow (winInfoPtr, height, originY)
835 TuiWinInfoPtr *winInfoPtr;
836 int height;
837 int originY;
838#endif
839{
840 _initAndMakeWin ((Opaque *) winInfoPtr,
841 CMD_WIN,
842 height,
843 termWidth (),
844 0,
845 originY,
846 DONT_BOX_WINDOW);
847
848 (*winInfoPtr)->canHighlight = FALSE;
849
850 return;
851} /* _makeCommandWindow */
852
853
854/*
855** _makeSourceWindow().
856*/
857static void
858#ifdef __STDC__
859_makeSourceWindow (
860 TuiWinInfoPtr * winInfoPtr,
861 int height,
862 int originY)
863#else
864_makeSourceWindow (winInfoPtr, height, originY)
865 TuiWinInfoPtr *winInfoPtr;
866 int height;
867 int originY;
868#endif
869{
870 _makeSourceOrDisassemWindow (winInfoPtr, SRC_WIN, height, originY);
871
872 return;
873} /* _makeSourceWindow */
874
875
876/*
877** _makeDisassemWindow().
878*/
879static void
880#ifdef __STDC__
881_makeDisassemWindow (
882 TuiWinInfoPtr * winInfoPtr,
883 int height,
884 int originY)
885#else
886_makeDisassemWindow (winInfoPtr, height, originY)
887 TuiWinInfoPtr *winInfoPtr;
888 int height;
889 int originY;
890#endif
891{
892 _makeSourceOrDisassemWindow (winInfoPtr, DISASSEM_WIN, height, originY);
893
894 return;
895} /* _makeDisassemWindow */
896
897
898/*
899** _makeDataWindow().
900*/
901static void
902#ifdef __STDC__
903_makeDataWindow (
904 TuiWinInfoPtr * winInfoPtr,
905 int height,
906 int originY)
907#else
908_makeDataWindow (winInfoPtr, height, originY)
909 TuiWinInfoPtr *winInfoPtr;
910 int height;
911 int originY;
912#endif
913{
914 _initAndMakeWin ((Opaque *) winInfoPtr,
915 DATA_WIN,
916 height,
917 termWidth (),
918 0,
919 originY,
920 BOX_WINDOW);
921
922 return;
923} /* _makeDataWindow */
924
925
926
927/*
928** _showSourceCommand().
929** Show the Source/Command layout
930*/
931static void
932#ifdef __STDC__
933_showSourceCommand (void)
934#else
935_showSourceCommand ()
936#endif
937{
938 _showSourceOrDisassemAndCommand (SRC_COMMAND);
939
940 return;
941} /* _showSourceCommand */
942
943
944/*
945** _showDisassemCommand().
946** Show the Dissassem/Command layout
947*/
948static void
949#ifdef __STDC__
950_showDisassemCommand (void)
951#else
952_showDisassemCommand ()
953#endif
954{
955 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND);
956
957 return;
958} /* _showDisassemCommand */
959
960
961/*
962** _showSourceDisassemCommand().
963** Show the Source/Disassem/Command layout
964*/
965static void
966#ifdef __STDC__
967_showSourceDisassemCommand (void)
968#else
969_showSourceDisassemCommand ()
970#endif
971{
972 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
973
974 if (currentLayout () != SRC_DISASSEM_COMMAND)
975 {
976 int cmdHeight, srcHeight, asmHeight;
977
978 if (m_winPtrNotNull (cmdWin))
979 cmdHeight = cmdWin->generic.height;
980 else
981 cmdHeight = termHeight () / 3;
982
983 srcHeight = (termHeight () - cmdHeight) / 2;
984 asmHeight = termHeight () - (srcHeight + cmdHeight);
985
986 if (m_winPtrIsNull (srcWin))
987 _makeSourceWindow (&srcWin, srcHeight, 0);
988 else
989 {
990 _initGenWinInfo (&srcWin->generic,
991 srcWin->generic.type,
992 srcHeight,
993 srcWin->generic.width,
994 srcWin->detail.sourceInfo.executionInfo->width,
995 0);
996 srcWin->canHighlight = TRUE;
997 _initGenWinInfo (srcWin->detail.sourceInfo.executionInfo,
998 EXEC_INFO_WIN,
999 srcHeight,
1000 3,
1001 0,
1002 0);
1003 m_beVisible (srcWin);
1004 m_beVisible (srcWin->detail.sourceInfo.executionInfo);
1005 srcWin->detail.sourceInfo.hasLocator = FALSE;;
1006 }
1007 if (m_winPtrNotNull (srcWin))
1008 {
1009 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
1010
1011 tuiShowSourceContent (srcWin);
1012 if (m_winPtrIsNull (disassemWin))
1013 {
1014 _makeDisassemWindow (&disassemWin, asmHeight, srcHeight - 1);
1015 _initAndMakeWin ((Opaque *) & locator,
1016 LOCATOR_WIN,
1017 2 /* 1 */ ,
1018 termWidth (),
1019 0,
1020 (srcHeight + asmHeight) - 1,
1021 DONT_BOX_WINDOW);
1022 }
1023 else
1024 {
1025 _initGenWinInfo (locator,
1026 LOCATOR_WIN,
1027 2 /* 1 */ ,
1028 termWidth (),
1029 0,
1030 (srcHeight + asmHeight) - 1);
1031 disassemWin->detail.sourceInfo.hasLocator = TRUE;
1032 _initGenWinInfo (
1033 &disassemWin->generic,
1034 disassemWin->generic.type,
1035 asmHeight,
1036 disassemWin->generic.width,
1037 disassemWin->detail.sourceInfo.executionInfo->width,
1038 srcHeight - 1);
1039 _initGenWinInfo (disassemWin->detail.sourceInfo.executionInfo,
1040 EXEC_INFO_WIN,
1041 asmHeight,
1042 3,
1043 0,
1044 srcHeight - 1);
1045 disassemWin->canHighlight = TRUE;
1046 m_beVisible (disassemWin);
1047 m_beVisible (disassemWin->detail.sourceInfo.executionInfo);
1048 }
1049 if (m_winPtrNotNull (disassemWin))
1050 {
1051 srcWin->detail.sourceInfo.hasLocator = FALSE;
1052 disassemWin->detail.sourceInfo.hasLocator = TRUE;
1053 m_beVisible (locator);
1054 tuiShowLocatorContent ();
1055 tuiShowSourceContent (disassemWin);
1056
1057 if (m_winPtrIsNull (cmdWin))
1058 _makeCommandWindow (&cmdWin,
1059 cmdHeight,
1060 termHeight () - cmdHeight);
1061 else
1062 {
1063 _initGenWinInfo (&cmdWin->generic,
1064 cmdWin->generic.type,
1065 cmdWin->generic.height,
1066 cmdWin->generic.width,
1067 0,
1068 cmdWin->generic.origin.y);
1069 cmdWin->canHighlight = FALSE;
1070 m_beVisible (cmdWin);
1071 }
1072 if (m_winPtrNotNull (cmdWin))
1073 tuiRefreshWin (&cmdWin->generic);
1074 }
1075 }
1076 setCurrentLayoutTo (SRC_DISASSEM_COMMAND);
1077 }
1078
1079 return;
1080} /* _showSourceDisassemCommand */
1081
1082
1083/*
1084** _showData().
1085** Show the Source/Data/Command or the Dissassembly/Data/Command layout
1086*/
1087static void
1088#ifdef __STDC__
1089_showData (
1090 TuiLayoutType newLayout)
1091#else
1092_showData (newLayout)
1093 TuiLayoutType newLayout;
1094#endif
1095{
1096 int totalHeight = (termHeight () - cmdWin->generic.height);
1097 int srcHeight, dataHeight;
1098 TuiWinType winType;
1099 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
1100
1101
1102 dataHeight = totalHeight / 2;
1103 srcHeight = totalHeight - dataHeight;
1104 m_allBeInvisible ();
1105 m_beInvisible (locator);
1106 _makeDataWindow (&dataWin, dataHeight, 0);
1107 dataWin->canHighlight = TRUE;
1108 if (newLayout == SRC_DATA_COMMAND)
1109 winType = SRC_WIN;
1110 else
1111 winType = DISASSEM_WIN;
1112 if (m_winPtrIsNull (winList[winType]))
1113 {
1114 if (winType == SRC_WIN)
1115 _makeSourceWindow (&winList[winType], srcHeight, dataHeight - 1);
1116 else
1117 _makeDisassemWindow (&winList[winType], srcHeight, dataHeight - 1);
1118 _initAndMakeWin ((Opaque *) & locator,
1119 LOCATOR_WIN,
1120 2 /* 1 */ ,
1121 termWidth (),
1122 0,
1123 totalHeight - 1,
1124 DONT_BOX_WINDOW);
1125 }
1126 else
1127 {
1128 _initGenWinInfo (&winList[winType]->generic,
1129 winList[winType]->generic.type,
1130 srcHeight,
1131 winList[winType]->generic.width,
1132 winList[winType]->detail.sourceInfo.executionInfo->width,
1133 dataHeight - 1);
1134 _initGenWinInfo (winList[winType]->detail.sourceInfo.executionInfo,
1135 EXEC_INFO_WIN,
1136 srcHeight,
1137 3,
1138 0,
1139 dataHeight - 1);
1140 m_beVisible (winList[winType]);
1141 m_beVisible (winList[winType]->detail.sourceInfo.executionInfo);
1142 _initGenWinInfo (locator,
1143 LOCATOR_WIN,
1144 2 /* 1 */ ,
1145 termWidth (),
1146 0,
1147 totalHeight - 1);
1148 }
1149 winList[winType]->detail.sourceInfo.hasLocator = TRUE;
1150 m_beVisible (locator);
1151 tuiShowLocatorContent ();
1152 addToSourceWindows (winList[winType]);
1153 setCurrentLayoutTo (newLayout);
1154
1155 return;
1156} /* _showData */
1157
1158/*
1159** _initGenWinInfo().
1160*/
1161static void
1162#ifdef __STDC__
1163_initGenWinInfo (
1164 TuiGenWinInfoPtr winInfo,
1165 TuiWinType type,
1166 int height,
1167 int width,
1168 int originX,
1169 int originY)
1170#else
1171_initGenWinInfo (winInfo, type, height, width, originX, originY)
1172 TuiGenWinInfoPtr winInfo;
1173 TuiWinType type;
1174 int height;
1175 int width;
1176 int originX;
1177 int originY;
1178#endif
1179{
1180 int h = height;
1181
1182 winInfo->type = type;
1183 winInfo->width = width;
1184 winInfo->height = h;
1185 if (h > 1)
1186 {
1187 winInfo->viewportHeight = h - 1;
1188 if (winInfo->type != CMD_WIN)
1189 winInfo->viewportHeight--;
1190 }
1191 else
1192 winInfo->viewportHeight = 1;
1193 winInfo->origin.x = originX;
1194 winInfo->origin.y = originY;
1195
1196 return;
1197} /* _initGenWinInfo */
1198
1199/*
1200** _initAndMakeWin().
1201*/
1202static void
1203#ifdef __STDC__
1204_initAndMakeWin (
1205 Opaque * winInfoPtr,
1206 TuiWinType winType,
1207 int height,
1208 int width,
1209 int originX,
1210 int originY,
1211 int boxIt)
1212#else
1213_initAndMakeWin (winInfoPtr, winType, height, width, originX, originY, boxIt)
1214 Opaque *winInfoPtr;
1215 TuiWinType winType;
1216 int height;
1217 int width;
1218 int originX;
1219 int originY;
1220 int boxIt;
1221#endif
1222{
1223 Opaque opaqueWinInfo = *winInfoPtr;
1224 TuiGenWinInfoPtr generic;
1225
1226 if (opaqueWinInfo == (Opaque) NULL)
1227 {
1228 if (m_winIsAuxillary (winType))
1229 opaqueWinInfo = (Opaque) allocGenericWinInfo ();
1230 else
1231 opaqueWinInfo = (Opaque) allocWinInfo (winType);
1232 }
1233 if (m_winIsAuxillary (winType))
1234 generic = (TuiGenWinInfoPtr) opaqueWinInfo;
1235 else
1236 generic = &((TuiWinInfoPtr) opaqueWinInfo)->generic;
1237
1238 if (opaqueWinInfo != (Opaque) NULL)
1239 {
1240 _initGenWinInfo (generic, winType, height, width, originX, originY);
1241 if (!m_winIsAuxillary (winType))
1242 {
1243 if (generic->type == CMD_WIN)
1244 ((TuiWinInfoPtr) opaqueWinInfo)->canHighlight = FALSE;
1245 else
1246 ((TuiWinInfoPtr) opaqueWinInfo)->canHighlight = TRUE;
1247 }
1248 makeWindow (generic, boxIt);
1249 if (winType == LOCATOR_WIN)
1250 tuiClearLocatorDisplay ();
1251 echo ();
1252 }
1253 *winInfoPtr = opaqueWinInfo;
1254
1255 return;
1256} /* _initAndMakeWin */
1257
1258
1259/*
1260** _makeSourceOrDisassemWindow().
1261*/
1262static void
1263#ifdef __STDC__
1264_makeSourceOrDisassemWindow (
1265 TuiWinInfoPtr * winInfoPtr,
1266 TuiWinType type,
1267 int height,
1268 int originY)
1269#else
1270_makeSourceOrDisassemWindow (winInfoPtr, type, height, originY)
1271 TuiWinInfoPtr *winInfoPtr;
1272 TuiWinType type;
1273 int height;
1274 int originY;
1275#endif
1276{
1277 TuiGenWinInfoPtr executionInfo = (TuiGenWinInfoPtr) NULL;
1278
1279 /*
1280 ** Create the exeuction info window.
1281 */
1282 if (type == SRC_WIN)
1283 executionInfo = sourceExecInfoWinPtr ();
1284 else
1285 executionInfo = disassemExecInfoWinPtr ();
1286 _initAndMakeWin ((Opaque *) & executionInfo,
1287 EXEC_INFO_WIN,
1288 height,
1289 3,
1290 0,
1291 originY,
1292 DONT_BOX_WINDOW);
1293 /*
1294 ** Now create the source window.
1295 */
1296 _initAndMakeWin ((Opaque *) winInfoPtr,
1297 type,
1298 height,
1299 termWidth () - executionInfo->width,
1300 executionInfo->width,
1301 originY,
1302 BOX_WINDOW);
1303
1304 (*winInfoPtr)->detail.sourceInfo.executionInfo = executionInfo;
1305
1306 return;
1307} /* _makeSourceOrDisassemWindow */
1308
1309
1310/*
1311** _showSourceOrDisassemAndCommand().
1312** Show the Source/Command or the Disassem layout
1313*/
1314static void
1315#ifdef __STDC__
1316_showSourceOrDisassemAndCommand (
1317 TuiLayoutType layoutType)
1318#else
1319_showSourceOrDisassemAndCommand (layoutType)
1320 TuiLayoutType layoutType;
1321#endif
1322{
1323 if (currentLayout () != layoutType)
1324 {
1325 TuiWinInfoPtr *winInfoPtr;
1326 int areaLeft;
1327 int srcHeight, cmdHeight;
1328 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
1329
1330 if (m_winPtrNotNull (cmdWin))
1331 cmdHeight = cmdWin->generic.height;
1332 else
1333 cmdHeight = termHeight () / 3;
1334 srcHeight = termHeight () - cmdHeight;
1335
1336
1337 if (layoutType == SRC_COMMAND)
1338 winInfoPtr = &srcWin;
1339 else
1340 winInfoPtr = &disassemWin;
1341
1342 if (m_winPtrIsNull (*winInfoPtr))
1343 {
1344 if (layoutType == SRC_COMMAND)
1345 _makeSourceWindow (winInfoPtr, srcHeight - 1, 0);
1346 else
1347 _makeDisassemWindow (winInfoPtr, srcHeight - 1, 0);
1348 _initAndMakeWin ((Opaque *) & locator,
1349 LOCATOR_WIN,
1350 2 /* 1 */ ,
1351 termWidth (),
1352 0,
1353 srcHeight - 1,
1354 DONT_BOX_WINDOW);
1355 }
1356 else
1357 {
1358 _initGenWinInfo (locator,
1359 LOCATOR_WIN,
1360 2 /* 1 */ ,
1361 termWidth (),
1362 0,
1363 srcHeight - 1);
1364 (*winInfoPtr)->detail.sourceInfo.hasLocator = TRUE;
1365 _initGenWinInfo (
1366 &(*winInfoPtr)->generic,
1367 (*winInfoPtr)->generic.type,
1368 srcHeight - 1,
1369 (*winInfoPtr)->generic.width,
1370 (*winInfoPtr)->detail.sourceInfo.executionInfo->width,
1371 0);
1372 _initGenWinInfo ((*winInfoPtr)->detail.sourceInfo.executionInfo,
1373 EXEC_INFO_WIN,
1374 srcHeight - 1,
1375 3,
1376 0,
1377 0);
1378 (*winInfoPtr)->canHighlight = TRUE;
1379 m_beVisible (*winInfoPtr);
1380 m_beVisible ((*winInfoPtr)->detail.sourceInfo.executionInfo);
1381 }
1382 if (m_winPtrNotNull (*winInfoPtr))
1383 {
1384 (*winInfoPtr)->detail.sourceInfo.hasLocator = TRUE;
1385 m_beVisible (locator);
1386 tuiShowLocatorContent ();
1387 tuiShowSourceContent (*winInfoPtr);
1388
1389 if (m_winPtrIsNull (cmdWin))
1390 {
1391 _makeCommandWindow (&cmdWin, cmdHeight, srcHeight);
1392 tuiRefreshWin (&cmdWin->generic);
1393 }
1394 else
1395 {
1396 _initGenWinInfo (&cmdWin->generic,
1397 cmdWin->generic.type,
1398 cmdWin->generic.height,
1399 cmdWin->generic.width,
1400 cmdWin->generic.origin.x,
1401 cmdWin->generic.origin.y);
1402 cmdWin->canHighlight = FALSE;
1403 m_beVisible (cmdWin);
1404 }
1405 }
1406 setCurrentLayoutTo (layoutType);
1407 }
1408
1409 return;
1410} /* _showSourceOrDisassemAndCommand */