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 _tui_vToggleLayout_command (va_list);
59 static void _tuiToggleSplitLayout_command (char *, int);
60 static void _tui_vToggleSplitLayout_command (va_list);
61 static CORE_ADDR
_extractDisplayStartAddr (void);
62 static void _tuiHandleXDBLayout (TuiLayoutDefPtr
);
63 static TuiStatus
_tuiSetLayoutTo (char *);
66 /***************************************
68 ***************************************/
70 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
72 /***************************************
74 ***************************************/
75 static TuiLayoutType lastLayout
= UNDEFINED_LAYOUT
;
77 /***************************************
79 ***************************************/
83 ** Show the screen layout defined
86 showLayout (TuiLayoutType layout
)
88 TuiLayoutType curLayout
= currentLayout ();
90 if (layout
!= curLayout
)
93 ** Since the new layout may cause changes in window size, we
94 ** should free the content and reallocate on next display of
97 tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT
);
98 freeAllSourceWinsContent ();
99 clearSourceWindows ();
100 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
103 refreshAll (winList
);
107 /* First make the current layout be invisible */
109 m_beInvisible (locatorWinInfoPtr ());
113 /* Now show the new layout */
115 _showSourceCommand ();
116 addToSourceWindows (srcWin
);
118 case DISASSEM_COMMAND
:
119 _showDisassemCommand ();
120 addToSourceWindows (disassemWin
);
122 case SRC_DISASSEM_COMMAND
:
123 _showSourceDisassemCommand ();
124 addToSourceWindows (srcWin
);
125 addToSourceWindows (disassemWin
);
139 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
140 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
141 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
142 ** UNDEFINED_LAYOUT, then the data window is populated according
143 ** to regsDisplayType.
146 tuiSetLayout (TuiLayoutType layoutType
,
147 TuiRegisterDisplayType regsDisplayType
)
149 TuiStatus status
= TUI_SUCCESS
;
151 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
153 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
154 int regsPopulate
= FALSE
;
155 CORE_ADDR addr
= _extractDisplayStartAddr ();
156 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
157 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
160 if (layoutType
== UNDEFINED_LAYOUT
&&
161 regsDisplayType
!= TUI_UNDEFINED_REGS
)
163 if (curLayout
== SRC_DISASSEM_COMMAND
)
164 newLayout
= DISASSEM_DATA_COMMAND
;
165 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
166 newLayout
= SRC_DATA_COMMAND
;
167 else if (curLayout
== DISASSEM_COMMAND
||
168 curLayout
== DISASSEM_DATA_COMMAND
)
169 newLayout
= DISASSEM_DATA_COMMAND
;
172 newLayout
= layoutType
;
174 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
175 newLayout
== DISASSEM_DATA_COMMAND
||
176 regsDisplayType
!= TUI_UNDEFINED_REGS
);
177 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
179 if (newLayout
!= curLayout
)
181 if (winWithFocus
!= cmdWin
)
183 showLayout (newLayout
);
185 ** Now determine where focus should be
187 if (winWithFocus
!= cmdWin
)
192 tuiSetWinFocusTo (srcWin
);
193 layoutDef
->displayMode
= SRC_WIN
;
194 layoutDef
->split
= FALSE
;
196 case DISASSEM_COMMAND
:
197 /* the previous layout was not showing
198 ** code. this can happen if there is no
200 ** 1. if the source file is in another dir OR
201 ** 2. if target was compiled without -g
202 ** We still want to show the assembly though!
204 addr
= vcatch_errors ((OpaqueFuncPtr
)
205 tuiGetBeginAsmAddress
);
206 tuiSetWinFocusTo (disassemWin
);
207 layoutDef
->displayMode
= DISASSEM_WIN
;
208 layoutDef
->split
= FALSE
;
210 case SRC_DISASSEM_COMMAND
:
211 /* the previous layout was not showing
212 ** code. this can happen if there is no
214 ** 1. if the source file is in another dir OR
215 ** 2. if target was compiled without -g
216 ** We still want to show the assembly though!
218 addr
= vcatch_errors ((OpaqueFuncPtr
)
219 tuiGetBeginAsmAddress
);
220 if (winWithFocus
== srcWin
)
221 tuiSetWinFocusTo (srcWin
);
223 tuiSetWinFocusTo (disassemWin
);
224 layoutDef
->split
= TRUE
;
226 case SRC_DATA_COMMAND
:
227 if (winWithFocus
!= dataWin
)
228 tuiSetWinFocusTo (srcWin
);
230 tuiSetWinFocusTo (dataWin
);
231 layoutDef
->displayMode
= SRC_WIN
;
232 layoutDef
->split
= FALSE
;
234 case DISASSEM_DATA_COMMAND
:
235 /* the previous layout was not showing
236 ** code. this can happen if there is no
238 ** 1. if the source file is in another dir OR
239 ** 2. if target was compiled without -g
240 ** We still want to show the assembly though!
242 addr
= vcatch_errors ((OpaqueFuncPtr
)
243 tuiGetBeginAsmAddress
);
244 if (winWithFocus
!= dataWin
)
245 tuiSetWinFocusTo (disassemWin
);
247 tuiSetWinFocusTo (dataWin
);
248 layoutDef
->displayMode
= DISASSEM_WIN
;
249 layoutDef
->split
= FALSE
;
255 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
256 tuiSetWinFocusTo (newWinWithFocus
);
258 ** Now update the window content
261 (newLayout
== SRC_DATA_COMMAND
||
262 newLayout
== DISASSEM_DATA_COMMAND
))
263 tuiDisplayAllData ();
265 tuiUpdateSourceWindowsWithAddr (addr
);
269 layoutDef
->regsDisplayType
=
270 (regsDisplayType
== TUI_UNDEFINED_REGS
?
271 TUI_GENERAL_REGS
: regsDisplayType
);
272 tuiShowRegisters (layoutDef
->regsDisplayType
);
277 status
= TUI_FAILURE
;
284 ** tui_vSetLayoutTo()
285 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
286 ** REGS, $REGS, $GREGS, $FREGS, $SREGS with arguments in a va_list
289 tui_vSetLayoutTo (va_list args
)
293 layoutName
= va_arg (args
, char *);
295 return (_tuiSetLayoutTo (layoutName
));
296 } /* tui_vSetLayoutTo */
300 ** tuiAddWinToLayout().
301 ** Add the specified window to the layout in a logical way.
302 ** This means setting up the most logical layout given the
303 ** window to be added.
306 tuiAddWinToLayout (TuiWinType type
)
308 TuiLayoutType curLayout
= currentLayout ();
313 if (curLayout
!= SRC_COMMAND
&&
314 curLayout
!= SRC_DISASSEM_COMMAND
&&
315 curLayout
!= SRC_DATA_COMMAND
)
317 clearSourceWindowsDetail ();
318 if (curLayout
== DISASSEM_DATA_COMMAND
)
319 showLayout (SRC_DATA_COMMAND
);
321 showLayout (SRC_COMMAND
);
325 if (curLayout
!= DISASSEM_COMMAND
&&
326 curLayout
!= SRC_DISASSEM_COMMAND
&&
327 curLayout
!= DISASSEM_DATA_COMMAND
)
329 clearSourceWindowsDetail ();
330 if (curLayout
== SRC_DATA_COMMAND
)
331 showLayout (DISASSEM_DATA_COMMAND
);
333 showLayout (DISASSEM_COMMAND
);
337 if (curLayout
!= SRC_DATA_COMMAND
&&
338 curLayout
!= DISASSEM_DATA_COMMAND
)
340 if (curLayout
== DISASSEM_COMMAND
)
341 showLayout (DISASSEM_DATA_COMMAND
);
343 showLayout (SRC_DATA_COMMAND
);
351 } /* tuiAddWinToLayout */
355 ** tui_vAddWinToLayout().
356 ** Add the specified window to the layout in a logical way,
357 ** with arguments in a va_list.
360 tui_vAddWinToLayout (va_list args
)
362 TuiWinType type
= va_arg (args
, TuiWinType
);
364 tuiAddWinToLayout (type
);
367 } /* tui_vAddWinToLayout */
371 ** tuiDefaultWinHeight().
372 ** Answer the height of a window. If it hasn't been created yet,
373 ** answer what the height of a window would be based upon its
374 ** type and the layout.
377 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
381 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
382 h
= winList
[type
]->generic
.height
;
388 case DISASSEM_COMMAND
:
389 if (m_winPtrIsNull (cmdWin
))
390 h
= termHeight () / 2;
392 h
= termHeight () - cmdWin
->generic
.height
;
394 case SRC_DISASSEM_COMMAND
:
395 case SRC_DATA_COMMAND
:
396 case DISASSEM_DATA_COMMAND
:
397 if (m_winPtrIsNull (cmdWin
))
398 h
= termHeight () / 3;
400 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
409 } /* tuiDefaultWinHeight */
413 ** tuiDefaultWinViewportHeight().
414 ** Answer the height of a window. If it hasn't been created yet,
415 ** answer what the height of a window would be based upon its
416 ** type and the layout.
419 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
423 h
= tuiDefaultWinHeight (type
, layout
);
425 if (winList
[type
] == cmdWin
)
431 } /* tuiDefaultWinViewportHeight */
435 ** _initialize_tuiLayout().
436 ** Function to initialize gdb commands, for tui window layout
440 _initialize_tuiLayout (void)
444 add_com ("layout", class_tui
, _tuiLayout_command
,
445 "Change the layout of windows.\n\
446 Usage: layout prev | next | <layout_name> \n\
448 src : Displays source and command windows.\n\
449 asm : Displays disassembly and command windows.\n\
450 split : Displays source, disassembly and command windows.\n\
451 regs : Displays register window. If existing layout\n\
452 is source/command or assembly/command, the \n\
453 register window is displayed. If the\n\
454 source/assembly/command (split) is displayed, \n\
455 the register window is displayed with \n\
456 the window that has current logical focus.\n");
459 add_com ("td", class_tui
, _tuiToggleLayout_command
,
460 "Toggle between Source/Command and Disassembly/Command layouts.\n");
461 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
462 "Toggle between Source/Command or Disassembly/Command and \n\
463 Source/Disassembly/Command layouts.\n");
468 } /* _intialize_tuiLayout */
471 /*************************
472 ** STATIC LOCAL FUNCTIONS
473 **************************/
478 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
479 ** $REGS, $GREGS, $FREGS, $SREGS.
482 _tuiSetLayoutTo (char *layoutName
)
484 TuiStatus status
= TUI_SUCCESS
;
486 if (layoutName
!= (char *) NULL
)
489 register char *bufPtr
;
490 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
491 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
492 TuiLayoutType curLayout
= currentLayout ();
494 bufPtr
= (char *) tuiStrDup (layoutName
);
495 for (i
= 0; (i
< strlen (layoutName
)); i
++)
496 bufPtr
[i
] = toupper (bufPtr
[i
]);
498 /* First check for ambiguous input */
499 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
501 warning ("Ambiguous command input.\n");
502 status
= TUI_FAILURE
;
506 if (subset_compare (bufPtr
, "SRC"))
507 newLayout
= SRC_COMMAND
;
508 else if (subset_compare (bufPtr
, "ASM"))
509 newLayout
= DISASSEM_COMMAND
;
510 else if (subset_compare (bufPtr
, "SPLIT"))
511 newLayout
= SRC_DISASSEM_COMMAND
;
512 else if (subset_compare (bufPtr
, "REGS") ||
513 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
514 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
515 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
516 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
518 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
519 newLayout
= SRC_DATA_COMMAND
;
521 newLayout
= DISASSEM_DATA_COMMAND
;
523 /* could ifdef out the following code. when compile with -z, there are null
524 pointer references that cause a core dump if 'layout regs' is the first
525 layout command issued by the user. HP has asked us to hook up this code
528 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
530 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
532 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
534 dpyType
= TUI_SFLOAT_REGS
;
537 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
539 else if (subset_compare (bufPtr
,
540 TUI_GENERAL_SPECIAL_REGS_NAME
))
541 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
542 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
543 dpyType
= TUI_GENERAL_REGS
;
544 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
545 dpyType
= TUI_SPECIAL_REGS
;
548 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
551 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
553 dpyType
= TUI_GENERAL_REGS
;
556 /* end of potential ifdef
559 /* if ifdefed out code above, then assume that the user wishes to display the
560 general purpose registers
563 /* dpyType = TUI_GENERAL_REGS;
566 else if (subset_compare (bufPtr
, "NEXT"))
567 newLayout
= _nextLayout ();
568 else if (subset_compare (bufPtr
, "PREV"))
569 newLayout
= _prevLayout ();
571 status
= TUI_FAILURE
;
574 tuiSetLayout (newLayout
, dpyType
);
578 status
= TUI_FAILURE
;
581 } /* _tuiSetLayoutTo */
585 _extractDisplayStartAddr (void)
587 TuiLayoutType curLayout
= currentLayout ();
594 case SRC_DATA_COMMAND
:
595 find_line_pc (current_source_symtab
,
596 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
600 case DISASSEM_COMMAND
:
601 case SRC_DISASSEM_COMMAND
:
602 case DISASSEM_DATA_COMMAND
:
603 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
611 } /* _extractDisplayStartAddr */
615 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
617 if (layoutDef
->split
)
619 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
620 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
624 if (layoutDef
->displayMode
== SRC_WIN
)
625 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
627 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
632 } /* _tuiHandleXDBLayout */
636 _tuiToggleLayout_command (char *arg
, int fromTTY
)
638 tuiDo ((TuiOpaqueFuncPtr
) _tui_vToggleLayout_command
, arg
, fromTTY
);
642 _tui_vToggleLayout_command (va_list args
)
644 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
646 if (layoutDef
->displayMode
== SRC_WIN
)
647 layoutDef
->displayMode
= DISASSEM_WIN
;
649 layoutDef
->displayMode
= SRC_WIN
;
651 if (!layoutDef
->split
)
652 _tuiHandleXDBLayout (layoutDef
);
655 } /* _tuiToggleLayout_command */
659 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
661 tuiDo ((TuiOpaqueFuncPtr
) _tui_vToggleSplitLayout_command
, arg
, fromTTY
);
665 _tui_vToggleSplitLayout_command (va_list args
)
667 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
669 layoutDef
->split
= (!layoutDef
->split
);
670 _tuiHandleXDBLayout (layoutDef
);
673 } /* _tui_vToggleSplitLayout_command */
677 _tuiLayout_command (char *arg
, int fromTTY
)
679 if ((TuiStatus
) tuiDo (
680 (TuiOpaqueFuncPtr
) tui_vSetLayoutTo
, arg
) != TUI_SUCCESS
)
681 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
684 } /* _tuiLayout_command */
688 ** Answer the previous layout to cycle to.
693 TuiLayoutType newLayout
;
695 newLayout
= currentLayout ();
696 if (newLayout
== UNDEFINED_LAYOUT
)
697 newLayout
= SRC_COMMAND
;
701 if (newLayout
== UNDEFINED_LAYOUT
)
702 newLayout
= SRC_COMMAND
;
711 ** Answer the next layout to cycle to.
716 TuiLayoutType newLayout
;
718 newLayout
= currentLayout ();
719 if (newLayout
== SRC_COMMAND
)
720 newLayout
= DISASSEM_DATA_COMMAND
;
724 if (newLayout
== UNDEFINED_LAYOUT
)
725 newLayout
= DISASSEM_DATA_COMMAND
;
734 ** _makeCommandWindow().
737 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
739 _initAndMakeWin ((Opaque
*) winInfoPtr
,
747 (*winInfoPtr
)->canHighlight
= FALSE
;
750 } /* _makeCommandWindow */
754 ** _makeSourceWindow().
757 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
759 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
762 } /* _makeSourceWindow */
766 ** _makeDisassemWindow().
769 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
771 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
774 } /* _makeDisassemWindow */
778 ** _makeDataWindow().
781 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
783 _initAndMakeWin ((Opaque
*) winInfoPtr
,
792 } /* _makeDataWindow */
797 ** _showSourceCommand().
798 ** Show the Source/Command layout
801 _showSourceCommand (void)
803 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
806 } /* _showSourceCommand */
810 ** _showDisassemCommand().
811 ** Show the Dissassem/Command layout
814 _showDisassemCommand (void)
816 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
819 } /* _showDisassemCommand */
823 ** _showSourceDisassemCommand().
824 ** Show the Source/Disassem/Command layout
827 _showSourceDisassemCommand (void)
829 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
831 if (currentLayout () != SRC_DISASSEM_COMMAND
)
833 int cmdHeight
, srcHeight
, asmHeight
;
835 if (m_winPtrNotNull (cmdWin
))
836 cmdHeight
= cmdWin
->generic
.height
;
838 cmdHeight
= termHeight () / 3;
840 srcHeight
= (termHeight () - cmdHeight
) / 2;
841 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
843 if (m_winPtrIsNull (srcWin
))
844 _makeSourceWindow (&srcWin
, srcHeight
, 0);
847 _initGenWinInfo (&srcWin
->generic
,
848 srcWin
->generic
.type
,
850 srcWin
->generic
.width
,
851 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
853 srcWin
->canHighlight
= TRUE
;
854 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
860 m_beVisible (srcWin
);
861 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
862 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
864 if (m_winPtrNotNull (srcWin
))
866 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
868 tuiShowSourceContent (srcWin
);
869 if (m_winPtrIsNull (disassemWin
))
871 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
872 _initAndMakeWin ((Opaque
*) & locator
,
877 (srcHeight
+ asmHeight
) - 1,
882 _initGenWinInfo (locator
,
887 (srcHeight
+ asmHeight
) - 1);
888 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
890 &disassemWin
->generic
,
891 disassemWin
->generic
.type
,
893 disassemWin
->generic
.width
,
894 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
896 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
902 disassemWin
->canHighlight
= TRUE
;
903 m_beVisible (disassemWin
);
904 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
906 if (m_winPtrNotNull (disassemWin
))
908 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
909 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
910 m_beVisible (locator
);
911 tuiShowLocatorContent ();
912 tuiShowSourceContent (disassemWin
);
914 if (m_winPtrIsNull (cmdWin
))
915 _makeCommandWindow (&cmdWin
,
917 termHeight () - cmdHeight
);
920 _initGenWinInfo (&cmdWin
->generic
,
921 cmdWin
->generic
.type
,
922 cmdWin
->generic
.height
,
923 cmdWin
->generic
.width
,
925 cmdWin
->generic
.origin
.y
);
926 cmdWin
->canHighlight
= FALSE
;
927 m_beVisible (cmdWin
);
929 if (m_winPtrNotNull (cmdWin
))
930 tuiRefreshWin (&cmdWin
->generic
);
933 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
937 } /* _showSourceDisassemCommand */
942 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
945 _showData (TuiLayoutType newLayout
)
947 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
948 int srcHeight
, dataHeight
;
950 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
953 dataHeight
= totalHeight
/ 2;
954 srcHeight
= totalHeight
- dataHeight
;
956 m_beInvisible (locator
);
957 _makeDataWindow (&dataWin
, dataHeight
, 0);
958 dataWin
->canHighlight
= TRUE
;
959 if (newLayout
== SRC_DATA_COMMAND
)
962 winType
= DISASSEM_WIN
;
963 if (m_winPtrIsNull (winList
[winType
]))
965 if (winType
== SRC_WIN
)
966 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
968 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
969 _initAndMakeWin ((Opaque
*) & locator
,
979 _initGenWinInfo (&winList
[winType
]->generic
,
980 winList
[winType
]->generic
.type
,
982 winList
[winType
]->generic
.width
,
983 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
985 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
991 m_beVisible (winList
[winType
]);
992 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
993 _initGenWinInfo (locator
,
1000 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
1001 m_beVisible (locator
);
1002 tuiShowLocatorContent ();
1003 addToSourceWindows (winList
[winType
]);
1004 setCurrentLayoutTo (newLayout
);
1010 ** _initGenWinInfo().
1013 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
1014 int height
, int width
, int originX
, int originY
)
1018 winInfo
->type
= type
;
1019 winInfo
->width
= width
;
1020 winInfo
->height
= h
;
1023 winInfo
->viewportHeight
= h
- 1;
1024 if (winInfo
->type
!= CMD_WIN
)
1025 winInfo
->viewportHeight
--;
1028 winInfo
->viewportHeight
= 1;
1029 winInfo
->origin
.x
= originX
;
1030 winInfo
->origin
.y
= originY
;
1033 } /* _initGenWinInfo */
1036 ** _initAndMakeWin().
1039 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
1040 int height
, int width
, int originX
, int originY
, int boxIt
)
1042 Opaque opaqueWinInfo
= *winInfoPtr
;
1043 TuiGenWinInfoPtr generic
;
1045 if (opaqueWinInfo
== (Opaque
) NULL
)
1047 if (m_winIsAuxillary (winType
))
1048 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
1050 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
1052 if (m_winIsAuxillary (winType
))
1053 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
1055 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
1057 if (opaqueWinInfo
!= (Opaque
) NULL
)
1059 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1060 if (!m_winIsAuxillary (winType
))
1062 if (generic
->type
== CMD_WIN
)
1063 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1065 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1067 makeWindow (generic
, boxIt
);
1068 if (winType
== LOCATOR_WIN
)
1069 tuiClearLocatorDisplay ();
1071 *winInfoPtr
= opaqueWinInfo
;
1074 } /* _initAndMakeWin */
1078 ** _makeSourceOrDisassemWindow().
1081 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1082 int height
, int originY
)
1084 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1087 ** Create the exeuction info window.
1089 if (type
== SRC_WIN
)
1090 executionInfo
= sourceExecInfoWinPtr ();
1092 executionInfo
= disassemExecInfoWinPtr ();
1093 _initAndMakeWin ((Opaque
*) & executionInfo
,
1101 ** Now create the source window.
1103 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1106 termWidth () - executionInfo
->width
,
1107 executionInfo
->width
,
1111 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1114 } /* _makeSourceOrDisassemWindow */
1118 ** _showSourceOrDisassemAndCommand().
1119 ** Show the Source/Command or the Disassem layout
1122 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1124 if (currentLayout () != layoutType
)
1126 TuiWinInfoPtr
*winInfoPtr
;
1128 int srcHeight
, cmdHeight
;
1129 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1131 if (m_winPtrNotNull (cmdWin
))
1132 cmdHeight
= cmdWin
->generic
.height
;
1134 cmdHeight
= termHeight () / 3;
1135 srcHeight
= termHeight () - cmdHeight
;
1138 if (layoutType
== SRC_COMMAND
)
1139 winInfoPtr
= &srcWin
;
1141 winInfoPtr
= &disassemWin
;
1143 if (m_winPtrIsNull (*winInfoPtr
))
1145 if (layoutType
== SRC_COMMAND
)
1146 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1148 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1149 _initAndMakeWin ((Opaque
*) & locator
,
1159 _initGenWinInfo (locator
,
1165 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1167 &(*winInfoPtr
)->generic
,
1168 (*winInfoPtr
)->generic
.type
,
1170 (*winInfoPtr
)->generic
.width
,
1171 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1173 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1179 (*winInfoPtr
)->canHighlight
= TRUE
;
1180 m_beVisible (*winInfoPtr
);
1181 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1183 if (m_winPtrNotNull (*winInfoPtr
))
1185 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1186 m_beVisible (locator
);
1187 tuiShowLocatorContent ();
1188 tuiShowSourceContent (*winInfoPtr
);
1190 if (m_winPtrIsNull (cmdWin
))
1192 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1193 tuiRefreshWin (&cmdWin
->generic
);
1197 _initGenWinInfo (&cmdWin
->generic
,
1198 cmdWin
->generic
.type
,
1199 cmdWin
->generic
.height
,
1200 cmdWin
->generic
.width
,
1201 cmdWin
->generic
.origin
.x
,
1202 cmdWin
->generic
.origin
.y
);
1203 cmdWin
->canHighlight
= FALSE
;
1204 m_beVisible (cmdWin
);
1207 setCurrentLayoutTo (layoutType
);
1211 } /* _showSourceOrDisassemAndCommand */