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. */
29 #include "tuiGeneralWin.h"
32 #include "tuiDisassem.h"
34 /*******************************
36 ********************************/
38 static void _initGenWinInfo (TuiGenWinInfoPtr
, TuiWinType
, int, int, int, int);
39 static void _initAndMakeWin (Opaque
*, TuiWinType
, int, int, int, int, int);
40 static void _showSourceOrDisassemAndCommand (TuiLayoutType
);
41 static void _makeSourceOrDisassemWindow (TuiWinInfoPtr
*, TuiWinType
, int, int);
42 static void _makeCommandWindow (TuiWinInfoPtr
*, int, int);
43 static void _makeSourceWindow (TuiWinInfoPtr
*, int, int);
44 static void _makeDisassemWindow (TuiWinInfoPtr
*, int, int);
45 static void _makeDataWindow (TuiWinInfoPtr
*, int, int);
46 static void _showSourceCommand (void);
47 static void _showDisassemCommand (void);
48 static void _showSourceDisassemCommand (void);
49 static void _showData (TuiLayoutType
);
50 static TuiLayoutType
_nextLayout (void);
51 static TuiLayoutType
_prevLayout (void);
52 static void _tuiLayout_command (char *, int);
53 static void _tuiToggleLayout_command (char *, int);
54 static void _tui_vToggleLayout_command (va_list);
55 static void _tuiToggleSplitLayout_command (char *, int);
56 static void _tui_vToggleSplitLayout_command (va_list);
57 static Opaque
_extractDisplayStartAddr (void);
58 static void _tuiHandleXDBLayout (TuiLayoutDefPtr
);
59 static TuiStatus
_tuiSetLayoutTo (char *);
62 /***************************************
64 ***************************************/
66 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
68 /***************************************
70 ***************************************/
71 static TuiLayoutType lastLayout
= UNDEFINED_LAYOUT
;
73 /***************************************
75 ***************************************/
79 ** Show the screen layout defined
82 showLayout (TuiLayoutType layout
)
84 TuiLayoutType curLayout
= currentLayout ();
86 if (layout
!= curLayout
)
89 ** Since the new layout may cause changes in window size, we
90 ** should free the content and reallocate on next display of
93 tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT
);
94 freeAllSourceWinsContent ();
95 clearSourceWindows ();
96 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
103 /* First make the current layout be invisible */
105 m_beInvisible (locatorWinInfoPtr ());
109 /* Now show the new layout */
111 _showSourceCommand ();
112 addToSourceWindows (srcWin
);
114 case DISASSEM_COMMAND
:
115 _showDisassemCommand ();
116 addToSourceWindows (disassemWin
);
118 case SRC_DISASSEM_COMMAND
:
119 _showSourceDisassemCommand ();
120 addToSourceWindows (srcWin
);
121 addToSourceWindows (disassemWin
);
135 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
136 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
137 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
138 ** UNDEFINED_LAYOUT, then the data window is populated according
139 ** to regsDisplayType.
142 tuiSetLayout (TuiLayoutType layoutType
,
143 TuiRegisterDisplayType regsDisplayType
)
145 TuiStatus status
= TUI_SUCCESS
;
147 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
149 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
150 int regsPopulate
= FALSE
;
151 Opaque addr
= _extractDisplayStartAddr ();
152 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
153 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
156 if (layoutType
== UNDEFINED_LAYOUT
&&
157 regsDisplayType
!= TUI_UNDEFINED_REGS
)
159 if (curLayout
== SRC_DISASSEM_COMMAND
)
160 newLayout
= DISASSEM_DATA_COMMAND
;
161 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
162 newLayout
= SRC_DATA_COMMAND
;
163 else if (curLayout
== DISASSEM_COMMAND
||
164 curLayout
== DISASSEM_DATA_COMMAND
)
165 newLayout
= DISASSEM_DATA_COMMAND
;
168 newLayout
= layoutType
;
170 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
171 newLayout
== DISASSEM_DATA_COMMAND
||
172 regsDisplayType
!= TUI_UNDEFINED_REGS
);
173 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
175 if (newLayout
!= curLayout
)
177 if (winWithFocus
!= cmdWin
)
179 showLayout (newLayout
);
181 ** Now determine where focus should be
183 if (winWithFocus
!= cmdWin
)
188 tuiSetWinFocusTo (srcWin
);
189 layoutDef
->displayMode
= SRC_WIN
;
190 layoutDef
->split
= FALSE
;
192 case DISASSEM_COMMAND
:
193 /* the previous layout was not showing
194 ** code. this can happen if there is no
196 ** 1. if the source file is in another dir OR
197 ** 2. if target was compiled without -g
198 ** We still want to show the assembly though!
200 addr
= vcatch_errors ((OpaqueFuncPtr
)
201 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
= vcatch_errors ((OpaqueFuncPtr
)
215 tuiGetBeginAsmAddress
);
216 if (winWithFocus
== srcWin
)
217 tuiSetWinFocusTo (srcWin
);
219 tuiSetWinFocusTo (disassemWin
);
220 layoutDef
->split
= TRUE
;
222 case SRC_DATA_COMMAND
:
223 if (winWithFocus
!= dataWin
)
224 tuiSetWinFocusTo (srcWin
);
226 tuiSetWinFocusTo (dataWin
);
227 layoutDef
->displayMode
= SRC_WIN
;
228 layoutDef
->split
= FALSE
;
230 case DISASSEM_DATA_COMMAND
:
231 /* the previous layout was not showing
232 ** code. this can happen if there is no
234 ** 1. if the source file is in another dir OR
235 ** 2. if target was compiled without -g
236 ** We still want to show the assembly though!
238 addr
= vcatch_errors ((OpaqueFuncPtr
)
239 tuiGetBeginAsmAddress
);
240 if (winWithFocus
!= dataWin
)
241 tuiSetWinFocusTo (disassemWin
);
243 tuiSetWinFocusTo (dataWin
);
244 layoutDef
->displayMode
= DISASSEM_WIN
;
245 layoutDef
->split
= FALSE
;
251 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
252 tuiSetWinFocusTo (newWinWithFocus
);
254 ** Now update the window content
257 (newLayout
== SRC_DATA_COMMAND
||
258 newLayout
== DISASSEM_DATA_COMMAND
))
259 tuiDisplayAllData ();
261 tuiUpdateSourceWindowsWithAddr (addr
);
265 layoutDef
->regsDisplayType
=
266 (regsDisplayType
== TUI_UNDEFINED_REGS
?
267 TUI_GENERAL_REGS
: regsDisplayType
);
268 tuiShowRegisters (layoutDef
->regsDisplayType
);
273 status
= TUI_FAILURE
;
280 ** tui_vSetLayoutTo()
281 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
282 ** REGS, $REGS, $GREGS, $FREGS, $SREGS with arguments in a va_list
285 tui_vSetLayoutTo (va_list args
)
289 layoutName
= va_arg (args
, char *);
291 return (_tuiSetLayoutTo (layoutName
));
292 } /* tui_vSetLayoutTo */
296 ** tuiAddWinToLayout().
297 ** Add the specified window to the layout in a logical way.
298 ** This means setting up the most logical layout given the
299 ** window to be added.
302 tuiAddWinToLayout (TuiWinType type
)
304 TuiLayoutType curLayout
= currentLayout ();
309 if (curLayout
!= SRC_COMMAND
&&
310 curLayout
!= SRC_DISASSEM_COMMAND
&&
311 curLayout
!= SRC_DATA_COMMAND
)
313 clearSourceWindowsDetail ();
314 if (curLayout
== DISASSEM_DATA_COMMAND
)
315 showLayout (SRC_DATA_COMMAND
);
317 showLayout (SRC_COMMAND
);
321 if (curLayout
!= DISASSEM_COMMAND
&&
322 curLayout
!= SRC_DISASSEM_COMMAND
&&
323 curLayout
!= DISASSEM_DATA_COMMAND
)
325 clearSourceWindowsDetail ();
326 if (curLayout
== SRC_DATA_COMMAND
)
327 showLayout (DISASSEM_DATA_COMMAND
);
329 showLayout (DISASSEM_COMMAND
);
333 if (curLayout
!= SRC_DATA_COMMAND
&&
334 curLayout
!= DISASSEM_DATA_COMMAND
)
336 if (curLayout
== DISASSEM_COMMAND
)
337 showLayout (DISASSEM_DATA_COMMAND
);
339 showLayout (SRC_DATA_COMMAND
);
347 } /* tuiAddWinToLayout */
351 ** tui_vAddWinToLayout().
352 ** Add the specified window to the layout in a logical way,
353 ** with arguments in a va_list.
356 tui_vAddWinToLayout (va_list args
)
358 TuiWinType type
= va_arg (args
, TuiWinType
);
360 tuiAddWinToLayout (type
);
363 } /* tui_vAddWinToLayout */
367 ** tuiDefaultWinHeight().
368 ** Answer the height of a window. If it hasn't been created yet,
369 ** answer what the height of a window would be based upon its
370 ** type and the layout.
373 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
377 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
378 h
= winList
[type
]->generic
.height
;
384 case DISASSEM_COMMAND
:
385 if (m_winPtrIsNull (cmdWin
))
386 h
= termHeight () / 2;
388 h
= termHeight () - cmdWin
->generic
.height
;
390 case SRC_DISASSEM_COMMAND
:
391 case SRC_DATA_COMMAND
:
392 case DISASSEM_DATA_COMMAND
:
393 if (m_winPtrIsNull (cmdWin
))
394 h
= termHeight () / 3;
396 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
405 } /* tuiDefaultWinHeight */
409 ** tuiDefaultWinViewportHeight().
410 ** Answer the height of a window. If it hasn't been created yet,
411 ** answer what the height of a window would be based upon its
412 ** type and the layout.
415 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
419 h
= tuiDefaultWinHeight (type
, layout
);
421 if (winList
[type
] == cmdWin
)
427 } /* tuiDefaultWinViewportHeight */
431 ** _initialize_tuiLayout().
432 ** Function to initialize gdb commands, for tui window layout
436 _initialize_tuiLayout (void)
440 add_com ("layout", class_tui
, _tuiLayout_command
,
441 "Change the layout of windows.\n\
442 Usage: layout prev | next | <layout_name> \n\
444 src : Displays source and command windows.\n\
445 asm : Displays disassembly and command windows.\n\
446 split : Displays source, disassembly and command windows.\n\
447 regs : Displays register window. If existing layout\n\
448 is source/command or assembly/command, the \n\
449 register window is displayed. If the\n\
450 source/assembly/command (split) is displayed, \n\
451 the register window is displayed with \n\
452 the window that has current logical focus.\n");
455 add_com ("td", class_tui
, _tuiToggleLayout_command
,
456 "Toggle between Source/Command and Disassembly/Command layouts.\n");
457 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
458 "Toggle between Source/Command or Disassembly/Command and \n\
459 Source/Disassembly/Command layouts.\n");
464 } /* _intialize_tuiLayout */
467 /*************************
468 ** STATIC LOCAL FUNCTIONS
469 **************************/
474 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
475 ** $REGS, $GREGS, $FREGS, $SREGS.
478 _tuiSetLayoutTo (char *layoutName
)
480 TuiStatus status
= TUI_SUCCESS
;
482 if (layoutName
!= (char *) NULL
)
485 register char *bufPtr
;
486 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
487 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
488 TuiLayoutType curLayout
= currentLayout ();
490 bufPtr
= (char *) tuiStrDup (layoutName
);
491 for (i
= 0; (i
< strlen (layoutName
)); i
++)
492 bufPtr
[i
] = toupper (bufPtr
[i
]);
494 /* First check for ambiguous input */
495 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
497 warning ("Ambiguous command input.\n");
498 status
= TUI_FAILURE
;
502 if (subsetCompare (bufPtr
, "SRC"))
503 newLayout
= SRC_COMMAND
;
504 else if (subsetCompare (bufPtr
, "ASM"))
505 newLayout
= DISASSEM_COMMAND
;
506 else if (subsetCompare (bufPtr
, "SPLIT"))
507 newLayout
= SRC_DISASSEM_COMMAND
;
508 else if (subsetCompare (bufPtr
, "REGS") ||
509 subsetCompare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
510 subsetCompare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
511 subsetCompare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
512 subsetCompare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
514 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
515 newLayout
= SRC_DATA_COMMAND
;
517 newLayout
= DISASSEM_DATA_COMMAND
;
519 /* could ifdef out the following code. when compile with -z, there are null
520 pointer references that cause a core dump if 'layout regs' is the first
521 layout command issued by the user. HP has asked us to hook up this code
524 if (subsetCompare (bufPtr
, TUI_FLOAT_REGS_NAME
))
526 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
528 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
530 dpyType
= TUI_SFLOAT_REGS
;
533 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
535 else if (subsetCompare (bufPtr
,
536 TUI_GENERAL_SPECIAL_REGS_NAME
))
537 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
538 else if (subsetCompare (bufPtr
, TUI_GENERAL_REGS_NAME
))
539 dpyType
= TUI_GENERAL_REGS
;
540 else if (subsetCompare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
541 dpyType
= TUI_SPECIAL_REGS
;
544 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
547 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
549 dpyType
= TUI_GENERAL_REGS
;
552 /* end of potential ifdef
555 /* if ifdefed out code above, then assume that the user wishes to display the
556 general purpose registers
559 /* dpyType = TUI_GENERAL_REGS;
562 else if (subsetCompare (bufPtr
, "NEXT"))
563 newLayout
= _nextLayout ();
564 else if (subsetCompare (bufPtr
, "PREV"))
565 newLayout
= _prevLayout ();
567 status
= TUI_FAILURE
;
570 tuiSetLayout (newLayout
, dpyType
);
574 status
= TUI_FAILURE
;
577 } /* _tuiSetLayoutTo */
581 _extractDisplayStartAddr (void)
583 TuiLayoutType curLayout
= currentLayout ();
589 case SRC_DATA_COMMAND
:
590 addr
= (Opaque
) find_line_pc (
591 current_source_symtab
,
592 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
);
594 case DISASSEM_COMMAND
:
595 case SRC_DISASSEM_COMMAND
:
596 case DISASSEM_DATA_COMMAND
:
597 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
600 addr
= (Opaque
) NULL
;
605 } /* _extractDisplayStartAddr */
609 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
611 if (layoutDef
->split
)
613 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
614 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
618 if (layoutDef
->displayMode
== SRC_WIN
)
619 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
621 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
626 } /* _tuiHandleXDBLayout */
630 _tuiToggleLayout_command (char *arg
, int fromTTY
)
632 tuiDo ((TuiOpaqueFuncPtr
) _tui_vToggleLayout_command
, arg
, fromTTY
);
636 _tui_vToggleLayout_command (va_list args
)
638 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
640 if (layoutDef
->displayMode
== SRC_WIN
)
641 layoutDef
->displayMode
= DISASSEM_WIN
;
643 layoutDef
->displayMode
= SRC_WIN
;
645 if (!layoutDef
->split
)
646 _tuiHandleXDBLayout (layoutDef
);
649 } /* _tuiToggleLayout_command */
653 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
655 tuiDo ((TuiOpaqueFuncPtr
) _tui_vToggleSplitLayout_command
, arg
, fromTTY
);
659 _tui_vToggleSplitLayout_command (va_list args
)
661 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
663 layoutDef
->split
= (!layoutDef
->split
);
664 _tuiHandleXDBLayout (layoutDef
);
667 } /* _tui_vToggleSplitLayout_command */
671 _tuiLayout_command (char *arg
, int fromTTY
)
673 if ((TuiStatus
) tuiDo (
674 (TuiOpaqueFuncPtr
) tui_vSetLayoutTo
, arg
) != TUI_SUCCESS
)
675 warning ("Invalid layout specified.\n%s" LAYOUT_USAGE
);
678 } /* _tuiLayout_command */
682 ** Answer the previous layout to cycle to.
687 TuiLayoutType newLayout
;
689 newLayout
= currentLayout ();
690 if (newLayout
== UNDEFINED_LAYOUT
)
691 newLayout
= SRC_COMMAND
;
695 if (newLayout
== UNDEFINED_LAYOUT
)
696 newLayout
= SRC_COMMAND
;
705 ** Answer the next layout to cycle to.
710 TuiLayoutType newLayout
;
712 newLayout
= currentLayout ();
713 if (newLayout
== SRC_COMMAND
)
714 newLayout
= DISASSEM_DATA_COMMAND
;
718 if (newLayout
== UNDEFINED_LAYOUT
)
719 newLayout
= DISASSEM_DATA_COMMAND
;
728 ** _makeCommandWindow().
731 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
733 _initAndMakeWin ((Opaque
*) winInfoPtr
,
741 (*winInfoPtr
)->canHighlight
= FALSE
;
744 } /* _makeCommandWindow */
748 ** _makeSourceWindow().
751 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
753 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
756 } /* _makeSourceWindow */
760 ** _makeDisassemWindow().
763 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
765 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
768 } /* _makeDisassemWindow */
772 ** _makeDataWindow().
775 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
777 _initAndMakeWin ((Opaque
*) winInfoPtr
,
786 } /* _makeDataWindow */
791 ** _showSourceCommand().
792 ** Show the Source/Command layout
795 _showSourceCommand (void)
797 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
800 } /* _showSourceCommand */
804 ** _showDisassemCommand().
805 ** Show the Dissassem/Command layout
808 _showDisassemCommand (void)
810 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
813 } /* _showDisassemCommand */
817 ** _showSourceDisassemCommand().
818 ** Show the Source/Disassem/Command layout
821 _showSourceDisassemCommand (void)
823 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
825 if (currentLayout () != SRC_DISASSEM_COMMAND
)
827 int cmdHeight
, srcHeight
, asmHeight
;
829 if (m_winPtrNotNull (cmdWin
))
830 cmdHeight
= cmdWin
->generic
.height
;
832 cmdHeight
= termHeight () / 3;
834 srcHeight
= (termHeight () - cmdHeight
) / 2;
835 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
837 if (m_winPtrIsNull (srcWin
))
838 _makeSourceWindow (&srcWin
, srcHeight
, 0);
841 _initGenWinInfo (&srcWin
->generic
,
842 srcWin
->generic
.type
,
844 srcWin
->generic
.width
,
845 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
847 srcWin
->canHighlight
= TRUE
;
848 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
854 m_beVisible (srcWin
);
855 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
856 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
858 if (m_winPtrNotNull (srcWin
))
860 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
862 tuiShowSourceContent (srcWin
);
863 if (m_winPtrIsNull (disassemWin
))
865 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
866 _initAndMakeWin ((Opaque
*) & locator
,
871 (srcHeight
+ asmHeight
) - 1,
876 _initGenWinInfo (locator
,
881 (srcHeight
+ asmHeight
) - 1);
882 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
884 &disassemWin
->generic
,
885 disassemWin
->generic
.type
,
887 disassemWin
->generic
.width
,
888 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
890 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
896 disassemWin
->canHighlight
= TRUE
;
897 m_beVisible (disassemWin
);
898 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
900 if (m_winPtrNotNull (disassemWin
))
902 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
903 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
904 m_beVisible (locator
);
905 tuiShowLocatorContent ();
906 tuiShowSourceContent (disassemWin
);
908 if (m_winPtrIsNull (cmdWin
))
909 _makeCommandWindow (&cmdWin
,
911 termHeight () - cmdHeight
);
914 _initGenWinInfo (&cmdWin
->generic
,
915 cmdWin
->generic
.type
,
916 cmdWin
->generic
.height
,
917 cmdWin
->generic
.width
,
919 cmdWin
->generic
.origin
.y
);
920 cmdWin
->canHighlight
= FALSE
;
921 m_beVisible (cmdWin
);
923 if (m_winPtrNotNull (cmdWin
))
924 tuiRefreshWin (&cmdWin
->generic
);
927 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
931 } /* _showSourceDisassemCommand */
936 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
939 _showData (TuiLayoutType newLayout
)
941 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
942 int srcHeight
, dataHeight
;
944 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
947 dataHeight
= totalHeight
/ 2;
948 srcHeight
= totalHeight
- dataHeight
;
950 m_beInvisible (locator
);
951 _makeDataWindow (&dataWin
, dataHeight
, 0);
952 dataWin
->canHighlight
= TRUE
;
953 if (newLayout
== SRC_DATA_COMMAND
)
956 winType
= DISASSEM_WIN
;
957 if (m_winPtrIsNull (winList
[winType
]))
959 if (winType
== SRC_WIN
)
960 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
962 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
963 _initAndMakeWin ((Opaque
*) & locator
,
973 _initGenWinInfo (&winList
[winType
]->generic
,
974 winList
[winType
]->generic
.type
,
976 winList
[winType
]->generic
.width
,
977 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
979 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
985 m_beVisible (winList
[winType
]);
986 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
987 _initGenWinInfo (locator
,
994 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
995 m_beVisible (locator
);
996 tuiShowLocatorContent ();
997 addToSourceWindows (winList
[winType
]);
998 setCurrentLayoutTo (newLayout
);
1004 ** _initGenWinInfo().
1007 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
1008 int height
, int width
, int originX
, int originY
)
1012 winInfo
->type
= type
;
1013 winInfo
->width
= width
;
1014 winInfo
->height
= h
;
1017 winInfo
->viewportHeight
= h
- 1;
1018 if (winInfo
->type
!= CMD_WIN
)
1019 winInfo
->viewportHeight
--;
1022 winInfo
->viewportHeight
= 1;
1023 winInfo
->origin
.x
= originX
;
1024 winInfo
->origin
.y
= originY
;
1027 } /* _initGenWinInfo */
1030 ** _initAndMakeWin().
1033 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
1034 int height
, int width
, int originX
, int originY
, int boxIt
)
1036 Opaque opaqueWinInfo
= *winInfoPtr
;
1037 TuiGenWinInfoPtr generic
;
1039 if (opaqueWinInfo
== (Opaque
) NULL
)
1041 if (m_winIsAuxillary (winType
))
1042 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
1044 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
1046 if (m_winIsAuxillary (winType
))
1047 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
1049 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
1051 if (opaqueWinInfo
!= (Opaque
) NULL
)
1053 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1054 if (!m_winIsAuxillary (winType
))
1056 if (generic
->type
== CMD_WIN
)
1057 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1059 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1061 makeWindow (generic
, boxIt
);
1062 if (winType
== LOCATOR_WIN
)
1063 tuiClearLocatorDisplay ();
1066 *winInfoPtr
= opaqueWinInfo
;
1069 } /* _initAndMakeWin */
1073 ** _makeSourceOrDisassemWindow().
1076 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1077 int height
, int originY
)
1079 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1082 ** Create the exeuction info window.
1084 if (type
== SRC_WIN
)
1085 executionInfo
= sourceExecInfoWinPtr ();
1087 executionInfo
= disassemExecInfoWinPtr ();
1088 _initAndMakeWin ((Opaque
*) & executionInfo
,
1096 ** Now create the source window.
1098 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1101 termWidth () - executionInfo
->width
,
1102 executionInfo
->width
,
1106 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1109 } /* _makeSourceOrDisassemWindow */
1113 ** _showSourceOrDisassemAndCommand().
1114 ** Show the Source/Command or the Disassem layout
1117 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1119 if (currentLayout () != layoutType
)
1121 TuiWinInfoPtr
*winInfoPtr
;
1123 int srcHeight
, cmdHeight
;
1124 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1126 if (m_winPtrNotNull (cmdWin
))
1127 cmdHeight
= cmdWin
->generic
.height
;
1129 cmdHeight
= termHeight () / 3;
1130 srcHeight
= termHeight () - cmdHeight
;
1133 if (layoutType
== SRC_COMMAND
)
1134 winInfoPtr
= &srcWin
;
1136 winInfoPtr
= &disassemWin
;
1138 if (m_winPtrIsNull (*winInfoPtr
))
1140 if (layoutType
== SRC_COMMAND
)
1141 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1143 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1144 _initAndMakeWin ((Opaque
*) & locator
,
1154 _initGenWinInfo (locator
,
1160 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1162 &(*winInfoPtr
)->generic
,
1163 (*winInfoPtr
)->generic
.type
,
1165 (*winInfoPtr
)->generic
.width
,
1166 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1168 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1174 (*winInfoPtr
)->canHighlight
= TRUE
;
1175 m_beVisible (*winInfoPtr
);
1176 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1178 if (m_winPtrNotNull (*winInfoPtr
))
1180 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1181 m_beVisible (locator
);
1182 tuiShowLocatorContent ();
1183 tuiShowSourceContent (*winInfoPtr
);
1185 if (m_winPtrIsNull (cmdWin
))
1187 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1188 tuiRefreshWin (&cmdWin
->generic
);
1192 _initGenWinInfo (&cmdWin
->generic
,
1193 cmdWin
->generic
.type
,
1194 cmdWin
->generic
.height
,
1195 cmdWin
->generic
.width
,
1196 cmdWin
->generic
.origin
.x
,
1197 cmdWin
->generic
.origin
.y
);
1198 cmdWin
->canHighlight
= FALSE
;
1199 m_beVisible (cmdWin
);
1202 setCurrentLayoutTo (layoutType
);
1206 } /* _showSourceOrDisassemAndCommand */