1 /* TUI layout window management.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
5 This file is part of GDB.
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.
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.
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. */
30 #include "tuiDataWin.h"
31 #include "tuiGeneralWin.h"
35 #include "tuiSourceWin.h"
36 #include "tuiDisassem.h"
38 /*******************************
40 ********************************/
42 static void _initGenWinInfo (TuiGenWinInfoPtr
, TuiWinType
, int, int, int, int);
43 static void _initAndMakeWin (Opaque
*, TuiWinType
, int, int, int, int, int);
44 static void _showSourceOrDisassemAndCommand (TuiLayoutType
);
45 static void _makeSourceOrDisassemWindow (TuiWinInfoPtr
*, TuiWinType
, int, int);
46 static void _makeCommandWindow (TuiWinInfoPtr
*, int, int);
47 static void _makeSourceWindow (TuiWinInfoPtr
*, int, int);
48 static void _makeDisassemWindow (TuiWinInfoPtr
*, int, int);
49 static void _makeDataWindow (TuiWinInfoPtr
*, int, int);
50 static void _showSourceCommand (void);
51 static void _showDisassemCommand (void);
52 static void _showSourceDisassemCommand (void);
53 static void _showData (TuiLayoutType
);
54 static TuiLayoutType
_nextLayout (void);
55 static TuiLayoutType
_prevLayout (void);
56 static void _tuiLayout_command (char *, int);
57 static void _tuiToggleLayout_command (char *, int);
58 static void _tuiToggleSplitLayout_command (char *, int);
59 static CORE_ADDR
_extractDisplayStartAddr (void);
60 static void _tuiHandleXDBLayout (TuiLayoutDefPtr
);
63 /***************************************
65 ***************************************/
67 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
69 /***************************************
71 ***************************************/
72 static TuiLayoutType lastLayout
= UNDEFINED_LAYOUT
;
74 /***************************************
76 ***************************************/
80 ** Show the screen layout defined
83 showLayout (TuiLayoutType layout
)
85 TuiLayoutType curLayout
= currentLayout ();
87 if (layout
!= curLayout
)
90 ** Since the new layout may cause changes in window size, we
91 ** should free the content and reallocate on next display of
94 tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT
);
95 freeAllSourceWinsContent ();
96 clearSourceWindows ();
97 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
100 refreshAll (winList
);
104 /* First make the current layout be invisible */
106 m_beInvisible (locatorWinInfoPtr ());
110 /* Now show the new layout */
112 _showSourceCommand ();
113 addToSourceWindows (srcWin
);
115 case DISASSEM_COMMAND
:
116 _showDisassemCommand ();
117 addToSourceWindows (disassemWin
);
119 case SRC_DISASSEM_COMMAND
:
120 _showSourceDisassemCommand ();
121 addToSourceWindows (srcWin
);
122 addToSourceWindows (disassemWin
);
136 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
137 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
138 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
139 ** UNDEFINED_LAYOUT, then the data window is populated according
140 ** to regsDisplayType.
143 tuiSetLayout (TuiLayoutType layoutType
,
144 TuiRegisterDisplayType regsDisplayType
)
146 TuiStatus status
= TUI_SUCCESS
;
148 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
150 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
151 int regsPopulate
= FALSE
;
152 CORE_ADDR addr
= _extractDisplayStartAddr ();
153 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
154 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
157 if (layoutType
== UNDEFINED_LAYOUT
&&
158 regsDisplayType
!= TUI_UNDEFINED_REGS
)
160 if (curLayout
== SRC_DISASSEM_COMMAND
)
161 newLayout
= DISASSEM_DATA_COMMAND
;
162 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
163 newLayout
= SRC_DATA_COMMAND
;
164 else if (curLayout
== DISASSEM_COMMAND
||
165 curLayout
== DISASSEM_DATA_COMMAND
)
166 newLayout
= DISASSEM_DATA_COMMAND
;
169 newLayout
= layoutType
;
171 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
172 newLayout
== DISASSEM_DATA_COMMAND
||
173 regsDisplayType
!= TUI_UNDEFINED_REGS
);
174 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
176 if (newLayout
!= curLayout
)
178 if (winWithFocus
!= cmdWin
)
180 showLayout (newLayout
);
182 ** Now determine where focus should be
184 if (winWithFocus
!= cmdWin
)
189 tuiSetWinFocusTo (srcWin
);
190 layoutDef
->displayMode
= SRC_WIN
;
191 layoutDef
->split
= FALSE
;
193 case DISASSEM_COMMAND
:
194 /* the previous layout was not showing
195 ** code. this can happen if there is no
197 ** 1. if the source file is in another dir OR
198 ** 2. if target was compiled without -g
199 ** We still want to show the assembly though!
201 addr
= tuiGetBeginAsmAddress ();
202 tuiSetWinFocusTo (disassemWin
);
203 layoutDef
->displayMode
= DISASSEM_WIN
;
204 layoutDef
->split
= FALSE
;
206 case SRC_DISASSEM_COMMAND
:
207 /* the previous layout was not showing
208 ** code. this can happen if there is no
210 ** 1. if the source file is in another dir OR
211 ** 2. if target was compiled without -g
212 ** We still want to show the assembly though!
214 addr
= tuiGetBeginAsmAddress ();
215 if (winWithFocus
== srcWin
)
216 tuiSetWinFocusTo (srcWin
);
218 tuiSetWinFocusTo (disassemWin
);
219 layoutDef
->split
= TRUE
;
221 case SRC_DATA_COMMAND
:
222 if (winWithFocus
!= dataWin
)
223 tuiSetWinFocusTo (srcWin
);
225 tuiSetWinFocusTo (dataWin
);
226 layoutDef
->displayMode
= SRC_WIN
;
227 layoutDef
->split
= FALSE
;
229 case DISASSEM_DATA_COMMAND
:
230 /* the previous layout was not showing
231 ** code. this can happen if there is no
233 ** 1. if the source file is in another dir OR
234 ** 2. if target was compiled without -g
235 ** We still want to show the assembly though!
237 addr
= tuiGetBeginAsmAddress ();
238 if (winWithFocus
!= dataWin
)
239 tuiSetWinFocusTo (disassemWin
);
241 tuiSetWinFocusTo (dataWin
);
242 layoutDef
->displayMode
= DISASSEM_WIN
;
243 layoutDef
->split
= FALSE
;
249 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
250 tuiSetWinFocusTo (newWinWithFocus
);
252 ** Now update the window content
255 (newLayout
== SRC_DATA_COMMAND
||
256 newLayout
== DISASSEM_DATA_COMMAND
))
257 tuiDisplayAllData ();
259 tuiUpdateSourceWindowsWithAddr (addr
);
263 layoutDef
->regsDisplayType
=
264 (regsDisplayType
== TUI_UNDEFINED_REGS
?
265 TUI_GENERAL_REGS
: regsDisplayType
);
266 tuiShowRegisters (layoutDef
->regsDisplayType
);
271 status
= TUI_FAILURE
;
277 ** tuiAddWinToLayout().
278 ** Add the specified window to the layout in a logical way.
279 ** This means setting up the most logical layout given the
280 ** window to be added.
283 tuiAddWinToLayout (TuiWinType type
)
285 TuiLayoutType curLayout
= currentLayout ();
290 if (curLayout
!= SRC_COMMAND
&&
291 curLayout
!= SRC_DISASSEM_COMMAND
&&
292 curLayout
!= SRC_DATA_COMMAND
)
294 clearSourceWindowsDetail ();
295 if (curLayout
== DISASSEM_DATA_COMMAND
)
296 showLayout (SRC_DATA_COMMAND
);
298 showLayout (SRC_COMMAND
);
302 if (curLayout
!= DISASSEM_COMMAND
&&
303 curLayout
!= SRC_DISASSEM_COMMAND
&&
304 curLayout
!= DISASSEM_DATA_COMMAND
)
306 clearSourceWindowsDetail ();
307 if (curLayout
== SRC_DATA_COMMAND
)
308 showLayout (DISASSEM_DATA_COMMAND
);
310 showLayout (DISASSEM_COMMAND
);
314 if (curLayout
!= SRC_DATA_COMMAND
&&
315 curLayout
!= DISASSEM_DATA_COMMAND
)
317 if (curLayout
== DISASSEM_COMMAND
)
318 showLayout (DISASSEM_DATA_COMMAND
);
320 showLayout (SRC_DATA_COMMAND
);
328 } /* tuiAddWinToLayout */
332 ** tuiDefaultWinHeight().
333 ** Answer the height of a window. If it hasn't been created yet,
334 ** answer what the height of a window would be based upon its
335 ** type and the layout.
338 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
342 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
343 h
= winList
[type
]->generic
.height
;
349 case DISASSEM_COMMAND
:
350 if (m_winPtrIsNull (cmdWin
))
351 h
= termHeight () / 2;
353 h
= termHeight () - cmdWin
->generic
.height
;
355 case SRC_DISASSEM_COMMAND
:
356 case SRC_DATA_COMMAND
:
357 case DISASSEM_DATA_COMMAND
:
358 if (m_winPtrIsNull (cmdWin
))
359 h
= termHeight () / 3;
361 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
370 } /* tuiDefaultWinHeight */
374 ** tuiDefaultWinViewportHeight().
375 ** Answer the height of a window. If it hasn't been created yet,
376 ** answer what the height of a window would be based upon its
377 ** type and the layout.
380 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
384 h
= tuiDefaultWinHeight (type
, layout
);
386 if (winList
[type
] == cmdWin
)
392 } /* tuiDefaultWinViewportHeight */
396 ** _initialize_tuiLayout().
397 ** Function to initialize gdb commands, for tui window layout
401 _initialize_tuiLayout (void)
403 add_com ("layout", class_tui
, _tuiLayout_command
,
404 "Change the layout of windows.\n\
405 Usage: layout prev | next | <layout_name> \n\
407 src : Displays source and command windows.\n\
408 asm : Displays disassembly and command windows.\n\
409 split : Displays source, disassembly and command windows.\n\
410 regs : Displays register window. If existing layout\n\
411 is source/command or assembly/command, the \n\
412 register window is displayed. If the\n\
413 source/assembly/command (split) is displayed, \n\
414 the register window is displayed with \n\
415 the window that has current logical focus.\n");
418 add_com ("td", class_tui
, _tuiToggleLayout_command
,
419 "Toggle between Source/Command and Disassembly/Command layouts.\n");
420 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
421 "Toggle between Source/Command or Disassembly/Command and \n\
422 Source/Disassembly/Command layouts.\n");
427 /*************************
428 ** STATIC LOCAL FUNCTIONS
429 **************************/
434 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
435 ** $REGS, $GREGS, $FREGS, $SREGS.
438 tui_set_layout (const char *layoutName
)
440 TuiStatus status
= TUI_SUCCESS
;
442 if (layoutName
!= (char *) NULL
)
445 register char *bufPtr
;
446 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
447 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
448 TuiLayoutType curLayout
= currentLayout ();
450 bufPtr
= (char *) xstrdup (layoutName
);
451 for (i
= 0; (i
< strlen (layoutName
)); i
++)
452 bufPtr
[i
] = toupper (bufPtr
[i
]);
454 /* First check for ambiguous input */
455 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
457 warning ("Ambiguous command input.\n");
458 status
= TUI_FAILURE
;
462 if (subset_compare (bufPtr
, "SRC"))
463 newLayout
= SRC_COMMAND
;
464 else if (subset_compare (bufPtr
, "ASM"))
465 newLayout
= DISASSEM_COMMAND
;
466 else if (subset_compare (bufPtr
, "SPLIT"))
467 newLayout
= SRC_DISASSEM_COMMAND
;
468 else if (subset_compare (bufPtr
, "REGS") ||
469 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
470 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
471 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
472 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
474 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
475 newLayout
= SRC_DATA_COMMAND
;
477 newLayout
= DISASSEM_DATA_COMMAND
;
479 /* could ifdef out the following code. when compile with -z, there are null
480 pointer references that cause a core dump if 'layout regs' is the first
481 layout command issued by the user. HP has asked us to hook up this code
484 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
486 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
488 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
490 dpyType
= TUI_SFLOAT_REGS
;
493 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
495 else if (subset_compare (bufPtr
,
496 TUI_GENERAL_SPECIAL_REGS_NAME
))
497 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
498 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
499 dpyType
= TUI_GENERAL_REGS
;
500 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
501 dpyType
= TUI_SPECIAL_REGS
;
504 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
507 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
509 dpyType
= TUI_GENERAL_REGS
;
512 /* end of potential ifdef
515 /* if ifdefed out code above, then assume that the user wishes to display the
516 general purpose registers
519 /* dpyType = TUI_GENERAL_REGS;
522 else if (subset_compare (bufPtr
, "NEXT"))
523 newLayout
= _nextLayout ();
524 else if (subset_compare (bufPtr
, "PREV"))
525 newLayout
= _prevLayout ();
527 status
= TUI_FAILURE
;
530 tuiSetLayout (newLayout
, dpyType
);
534 status
= TUI_FAILURE
;
541 _extractDisplayStartAddr (void)
543 TuiLayoutType curLayout
= currentLayout ();
550 case SRC_DATA_COMMAND
:
551 find_line_pc (current_source_symtab
,
552 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
556 case DISASSEM_COMMAND
:
557 case SRC_DISASSEM_COMMAND
:
558 case DISASSEM_DATA_COMMAND
:
559 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
567 } /* _extractDisplayStartAddr */
571 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
573 if (layoutDef
->split
)
575 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
576 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
580 if (layoutDef
->displayMode
== SRC_WIN
)
581 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
583 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
588 } /* _tuiHandleXDBLayout */
592 _tuiToggleLayout_command (char *arg
, int fromTTY
)
594 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
596 /* Make sure the curses mode is enabled. */
598 if (layoutDef
->displayMode
== SRC_WIN
)
599 layoutDef
->displayMode
= DISASSEM_WIN
;
601 layoutDef
->displayMode
= SRC_WIN
;
603 if (!layoutDef
->split
)
604 _tuiHandleXDBLayout (layoutDef
);
610 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
612 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
614 /* Make sure the curses mode is enabled. */
616 layoutDef
->split
= (!layoutDef
->split
);
617 _tuiHandleXDBLayout (layoutDef
);
623 _tuiLayout_command (char *arg
, int fromTTY
)
625 /* Make sure the curses mode is enabled. */
628 /* Switch to the selected layout. */
629 if (tui_set_layout (arg
) != TUI_SUCCESS
)
630 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
636 ** Answer the previous layout to cycle to.
641 TuiLayoutType newLayout
;
643 newLayout
= currentLayout ();
644 if (newLayout
== UNDEFINED_LAYOUT
)
645 newLayout
= SRC_COMMAND
;
649 if (newLayout
== UNDEFINED_LAYOUT
)
650 newLayout
= SRC_COMMAND
;
659 ** Answer the next layout to cycle to.
664 TuiLayoutType newLayout
;
666 newLayout
= currentLayout ();
667 if (newLayout
== SRC_COMMAND
)
668 newLayout
= DISASSEM_DATA_COMMAND
;
672 if (newLayout
== UNDEFINED_LAYOUT
)
673 newLayout
= DISASSEM_DATA_COMMAND
;
682 ** _makeCommandWindow().
685 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
687 _initAndMakeWin ((Opaque
*) winInfoPtr
,
695 (*winInfoPtr
)->canHighlight
= FALSE
;
698 } /* _makeCommandWindow */
702 ** _makeSourceWindow().
705 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
707 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
710 } /* _makeSourceWindow */
714 ** _makeDisassemWindow().
717 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
719 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
722 } /* _makeDisassemWindow */
726 ** _makeDataWindow().
729 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
731 _initAndMakeWin ((Opaque
*) winInfoPtr
,
740 } /* _makeDataWindow */
745 ** _showSourceCommand().
746 ** Show the Source/Command layout
749 _showSourceCommand (void)
751 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
754 } /* _showSourceCommand */
758 ** _showDisassemCommand().
759 ** Show the Dissassem/Command layout
762 _showDisassemCommand (void)
764 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
767 } /* _showDisassemCommand */
771 ** _showSourceDisassemCommand().
772 ** Show the Source/Disassem/Command layout
775 _showSourceDisassemCommand (void)
777 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
779 if (currentLayout () != SRC_DISASSEM_COMMAND
)
781 int cmdHeight
, srcHeight
, asmHeight
;
783 if (m_winPtrNotNull (cmdWin
))
784 cmdHeight
= cmdWin
->generic
.height
;
786 cmdHeight
= termHeight () / 3;
788 srcHeight
= (termHeight () - cmdHeight
) / 2;
789 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
791 if (m_winPtrIsNull (srcWin
))
792 _makeSourceWindow (&srcWin
, srcHeight
, 0);
795 _initGenWinInfo (&srcWin
->generic
,
796 srcWin
->generic
.type
,
798 srcWin
->generic
.width
,
799 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
801 srcWin
->canHighlight
= TRUE
;
802 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
808 m_beVisible (srcWin
);
809 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
810 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
812 if (m_winPtrNotNull (srcWin
))
814 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
816 tuiShowSourceContent (srcWin
);
817 if (m_winPtrIsNull (disassemWin
))
819 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
820 _initAndMakeWin ((Opaque
*) & locator
,
825 (srcHeight
+ asmHeight
) - 1,
830 _initGenWinInfo (locator
,
835 (srcHeight
+ asmHeight
) - 1);
836 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
838 &disassemWin
->generic
,
839 disassemWin
->generic
.type
,
841 disassemWin
->generic
.width
,
842 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
844 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
850 disassemWin
->canHighlight
= TRUE
;
851 m_beVisible (disassemWin
);
852 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
854 if (m_winPtrNotNull (disassemWin
))
856 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
857 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
858 m_beVisible (locator
);
859 tuiShowLocatorContent ();
860 tuiShowSourceContent (disassemWin
);
862 if (m_winPtrIsNull (cmdWin
))
863 _makeCommandWindow (&cmdWin
,
865 termHeight () - cmdHeight
);
868 _initGenWinInfo (&cmdWin
->generic
,
869 cmdWin
->generic
.type
,
870 cmdWin
->generic
.height
,
871 cmdWin
->generic
.width
,
873 cmdWin
->generic
.origin
.y
);
874 cmdWin
->canHighlight
= FALSE
;
875 m_beVisible (cmdWin
);
877 if (m_winPtrNotNull (cmdWin
))
878 tuiRefreshWin (&cmdWin
->generic
);
881 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
885 } /* _showSourceDisassemCommand */
890 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
893 _showData (TuiLayoutType newLayout
)
895 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
896 int srcHeight
, dataHeight
;
898 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
901 dataHeight
= totalHeight
/ 2;
902 srcHeight
= totalHeight
- dataHeight
;
904 m_beInvisible (locator
);
905 _makeDataWindow (&dataWin
, dataHeight
, 0);
906 dataWin
->canHighlight
= TRUE
;
907 if (newLayout
== SRC_DATA_COMMAND
)
910 winType
= DISASSEM_WIN
;
911 if (m_winPtrIsNull (winList
[winType
]))
913 if (winType
== SRC_WIN
)
914 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
916 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
917 _initAndMakeWin ((Opaque
*) & locator
,
927 _initGenWinInfo (&winList
[winType
]->generic
,
928 winList
[winType
]->generic
.type
,
930 winList
[winType
]->generic
.width
,
931 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
933 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
939 m_beVisible (winList
[winType
]);
940 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
941 _initGenWinInfo (locator
,
948 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
949 m_beVisible (locator
);
950 tuiShowLocatorContent ();
951 addToSourceWindows (winList
[winType
]);
952 setCurrentLayoutTo (newLayout
);
958 ** _initGenWinInfo().
961 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
962 int height
, int width
, int originX
, int originY
)
966 winInfo
->type
= type
;
967 winInfo
->width
= width
;
971 winInfo
->viewportHeight
= h
- 1;
972 if (winInfo
->type
!= CMD_WIN
)
973 winInfo
->viewportHeight
--;
976 winInfo
->viewportHeight
= 1;
977 winInfo
->origin
.x
= originX
;
978 winInfo
->origin
.y
= originY
;
981 } /* _initGenWinInfo */
984 ** _initAndMakeWin().
987 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
988 int height
, int width
, int originX
, int originY
, int boxIt
)
990 Opaque opaqueWinInfo
= *winInfoPtr
;
991 TuiGenWinInfoPtr generic
;
993 if (opaqueWinInfo
== (Opaque
) NULL
)
995 if (m_winIsAuxillary (winType
))
996 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
998 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
1000 if (m_winIsAuxillary (winType
))
1001 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
1003 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
1005 if (opaqueWinInfo
!= (Opaque
) NULL
)
1007 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1008 if (!m_winIsAuxillary (winType
))
1010 if (generic
->type
== CMD_WIN
)
1011 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1013 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1015 makeWindow (generic
, boxIt
);
1016 if (winType
== LOCATOR_WIN
)
1017 tuiClearLocatorDisplay ();
1019 *winInfoPtr
= opaqueWinInfo
;
1022 } /* _initAndMakeWin */
1026 ** _makeSourceOrDisassemWindow().
1029 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1030 int height
, int originY
)
1032 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1035 ** Create the exeuction info window.
1037 if (type
== SRC_WIN
)
1038 executionInfo
= sourceExecInfoWinPtr ();
1040 executionInfo
= disassemExecInfoWinPtr ();
1041 _initAndMakeWin ((Opaque
*) & executionInfo
,
1049 ** Now create the source window.
1051 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1054 termWidth () - executionInfo
->width
,
1055 executionInfo
->width
,
1059 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1062 } /* _makeSourceOrDisassemWindow */
1066 ** _showSourceOrDisassemAndCommand().
1067 ** Show the Source/Command or the Disassem layout
1070 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1072 if (currentLayout () != layoutType
)
1074 TuiWinInfoPtr
*winInfoPtr
;
1076 int srcHeight
, cmdHeight
;
1077 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1079 if (m_winPtrNotNull (cmdWin
))
1080 cmdHeight
= cmdWin
->generic
.height
;
1082 cmdHeight
= termHeight () / 3;
1083 srcHeight
= termHeight () - cmdHeight
;
1086 if (layoutType
== SRC_COMMAND
)
1087 winInfoPtr
= &srcWin
;
1089 winInfoPtr
= &disassemWin
;
1091 if (m_winPtrIsNull (*winInfoPtr
))
1093 if (layoutType
== SRC_COMMAND
)
1094 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1096 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1097 _initAndMakeWin ((Opaque
*) & locator
,
1107 _initGenWinInfo (locator
,
1113 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1115 &(*winInfoPtr
)->generic
,
1116 (*winInfoPtr
)->generic
.type
,
1118 (*winInfoPtr
)->generic
.width
,
1119 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1121 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1127 (*winInfoPtr
)->canHighlight
= TRUE
;
1128 m_beVisible (*winInfoPtr
);
1129 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1131 if (m_winPtrNotNull (*winInfoPtr
))
1133 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1134 m_beVisible (locator
);
1135 tuiShowLocatorContent ();
1136 tuiShowSourceContent (*winInfoPtr
);
1138 if (m_winPtrIsNull (cmdWin
))
1140 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1141 tuiRefreshWin (&cmdWin
->generic
);
1145 _initGenWinInfo (&cmdWin
->generic
,
1146 cmdWin
->generic
.type
,
1147 cmdWin
->generic
.height
,
1148 cmdWin
->generic
.width
,
1149 cmdWin
->generic
.origin
.x
,
1150 cmdWin
->generic
.origin
.y
);
1151 cmdWin
->canHighlight
= FALSE
;
1152 m_beVisible (cmdWin
);
1155 setCurrentLayoutTo (layoutType
);
1159 } /* _showSourceOrDisassemAndCommand */