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. */
22 /* If we need <curses.h>, we must include it before we get "bfd.h". */
40 #include "tuiDataWin.h"
41 #include "tuiGeneralWin.h"
45 #include "tuiSourceWin.h"
46 #include "tuiDisassem.h"
48 /*******************************
50 ********************************/
52 static void _initGenWinInfo (TuiGenWinInfoPtr
, TuiWinType
, int, int, int, int);
53 static void _initAndMakeWin (Opaque
*, TuiWinType
, int, int, int, int, int);
54 static void _showSourceOrDisassemAndCommand (TuiLayoutType
);
55 static void _makeSourceOrDisassemWindow (TuiWinInfoPtr
*, TuiWinType
, int, int);
56 static void _makeCommandWindow (TuiWinInfoPtr
*, int, int);
57 static void _makeSourceWindow (TuiWinInfoPtr
*, int, int);
58 static void _makeDisassemWindow (TuiWinInfoPtr
*, int, int);
59 static void _makeDataWindow (TuiWinInfoPtr
*, int, int);
60 static void _showSourceCommand (void);
61 static void _showDisassemCommand (void);
62 static void _showSourceDisassemCommand (void);
63 static void _showData (TuiLayoutType
);
64 static TuiLayoutType
_nextLayout (void);
65 static TuiLayoutType
_prevLayout (void);
66 static void _tuiLayout_command (char *, int);
67 static void _tuiToggleLayout_command (char *, int);
68 static void _tuiToggleSplitLayout_command (char *, int);
69 static CORE_ADDR
_extractDisplayStartAddr (void);
70 static void _tuiHandleXDBLayout (TuiLayoutDefPtr
);
73 /***************************************
75 ***************************************/
77 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
79 /***************************************
81 ***************************************/
82 static TuiLayoutType lastLayout
= UNDEFINED_LAYOUT
;
84 /***************************************
86 ***************************************/
90 ** Show the screen layout defined
93 showLayout (TuiLayoutType layout
)
95 TuiLayoutType curLayout
= currentLayout ();
97 if (layout
!= curLayout
)
100 ** Since the new layout may cause changes in window size, we
101 ** should free the content and reallocate on next display of
104 tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT
);
105 freeAllSourceWinsContent ();
106 clearSourceWindows ();
107 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
110 refreshAll (winList
);
114 /* First make the current layout be invisible */
116 m_beInvisible (locatorWinInfoPtr ());
120 /* Now show the new layout */
122 _showSourceCommand ();
123 addToSourceWindows (srcWin
);
125 case DISASSEM_COMMAND
:
126 _showDisassemCommand ();
127 addToSourceWindows (disassemWin
);
129 case SRC_DISASSEM_COMMAND
:
130 _showSourceDisassemCommand ();
131 addToSourceWindows (srcWin
);
132 addToSourceWindows (disassemWin
);
146 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
147 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
148 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
149 ** UNDEFINED_LAYOUT, then the data window is populated according
150 ** to regsDisplayType.
153 tuiSetLayout (TuiLayoutType layoutType
,
154 TuiRegisterDisplayType regsDisplayType
)
156 TuiStatus status
= TUI_SUCCESS
;
158 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
160 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
161 int regsPopulate
= FALSE
;
162 CORE_ADDR addr
= _extractDisplayStartAddr ();
163 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
164 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
167 if (layoutType
== UNDEFINED_LAYOUT
&&
168 regsDisplayType
!= TUI_UNDEFINED_REGS
)
170 if (curLayout
== SRC_DISASSEM_COMMAND
)
171 newLayout
= DISASSEM_DATA_COMMAND
;
172 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
173 newLayout
= SRC_DATA_COMMAND
;
174 else if (curLayout
== DISASSEM_COMMAND
||
175 curLayout
== DISASSEM_DATA_COMMAND
)
176 newLayout
= DISASSEM_DATA_COMMAND
;
179 newLayout
= layoutType
;
181 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
182 newLayout
== DISASSEM_DATA_COMMAND
||
183 regsDisplayType
!= TUI_UNDEFINED_REGS
);
184 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
186 if (newLayout
!= curLayout
)
188 if (winWithFocus
!= cmdWin
)
190 showLayout (newLayout
);
192 ** Now determine where focus should be
194 if (winWithFocus
!= cmdWin
)
199 tuiSetWinFocusTo (srcWin
);
200 layoutDef
->displayMode
= SRC_WIN
;
201 layoutDef
->split
= FALSE
;
203 case DISASSEM_COMMAND
:
204 /* the previous layout was not showing
205 ** code. this can happen if there is no
207 ** 1. if the source file is in another dir OR
208 ** 2. if target was compiled without -g
209 ** We still want to show the assembly though!
211 addr
= tuiGetBeginAsmAddress ();
212 tuiSetWinFocusTo (disassemWin
);
213 layoutDef
->displayMode
= DISASSEM_WIN
;
214 layoutDef
->split
= FALSE
;
216 case SRC_DISASSEM_COMMAND
:
217 /* the previous layout was not showing
218 ** code. this can happen if there is no
220 ** 1. if the source file is in another dir OR
221 ** 2. if target was compiled without -g
222 ** We still want to show the assembly though!
224 addr
= tuiGetBeginAsmAddress ();
225 if (winWithFocus
== srcWin
)
226 tuiSetWinFocusTo (srcWin
);
228 tuiSetWinFocusTo (disassemWin
);
229 layoutDef
->split
= TRUE
;
231 case SRC_DATA_COMMAND
:
232 if (winWithFocus
!= dataWin
)
233 tuiSetWinFocusTo (srcWin
);
235 tuiSetWinFocusTo (dataWin
);
236 layoutDef
->displayMode
= SRC_WIN
;
237 layoutDef
->split
= FALSE
;
239 case DISASSEM_DATA_COMMAND
:
240 /* the previous layout was not showing
241 ** code. this can happen if there is no
243 ** 1. if the source file is in another dir OR
244 ** 2. if target was compiled without -g
245 ** We still want to show the assembly though!
247 addr
= tuiGetBeginAsmAddress ();
248 if (winWithFocus
!= dataWin
)
249 tuiSetWinFocusTo (disassemWin
);
251 tuiSetWinFocusTo (dataWin
);
252 layoutDef
->displayMode
= DISASSEM_WIN
;
253 layoutDef
->split
= FALSE
;
259 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
260 tuiSetWinFocusTo (newWinWithFocus
);
262 ** Now update the window content
265 (newLayout
== SRC_DATA_COMMAND
||
266 newLayout
== DISASSEM_DATA_COMMAND
))
267 tuiDisplayAllData ();
269 tuiUpdateSourceWindowsWithAddr (addr
);
273 layoutDef
->regsDisplayType
=
274 (regsDisplayType
== TUI_UNDEFINED_REGS
?
275 TUI_GENERAL_REGS
: regsDisplayType
);
276 tuiShowRegisters (layoutDef
->regsDisplayType
);
281 status
= TUI_FAILURE
;
287 ** tuiAddWinToLayout().
288 ** Add the specified window to the layout in a logical way.
289 ** This means setting up the most logical layout given the
290 ** window to be added.
293 tuiAddWinToLayout (TuiWinType type
)
295 TuiLayoutType curLayout
= currentLayout ();
300 if (curLayout
!= SRC_COMMAND
&&
301 curLayout
!= SRC_DISASSEM_COMMAND
&&
302 curLayout
!= SRC_DATA_COMMAND
)
304 clearSourceWindowsDetail ();
305 if (curLayout
== DISASSEM_DATA_COMMAND
)
306 showLayout (SRC_DATA_COMMAND
);
308 showLayout (SRC_COMMAND
);
312 if (curLayout
!= DISASSEM_COMMAND
&&
313 curLayout
!= SRC_DISASSEM_COMMAND
&&
314 curLayout
!= DISASSEM_DATA_COMMAND
)
316 clearSourceWindowsDetail ();
317 if (curLayout
== SRC_DATA_COMMAND
)
318 showLayout (DISASSEM_DATA_COMMAND
);
320 showLayout (DISASSEM_COMMAND
);
324 if (curLayout
!= SRC_DATA_COMMAND
&&
325 curLayout
!= DISASSEM_DATA_COMMAND
)
327 if (curLayout
== DISASSEM_COMMAND
)
328 showLayout (DISASSEM_DATA_COMMAND
);
330 showLayout (SRC_DATA_COMMAND
);
338 } /* tuiAddWinToLayout */
342 ** tuiDefaultWinHeight().
343 ** Answer the height of a window. If it hasn't been created yet,
344 ** answer what the height of a window would be based upon its
345 ** type and the layout.
348 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
352 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
353 h
= winList
[type
]->generic
.height
;
359 case DISASSEM_COMMAND
:
360 if (m_winPtrIsNull (cmdWin
))
361 h
= termHeight () / 2;
363 h
= termHeight () - cmdWin
->generic
.height
;
365 case SRC_DISASSEM_COMMAND
:
366 case SRC_DATA_COMMAND
:
367 case DISASSEM_DATA_COMMAND
:
368 if (m_winPtrIsNull (cmdWin
))
369 h
= termHeight () / 3;
371 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
380 } /* tuiDefaultWinHeight */
384 ** tuiDefaultWinViewportHeight().
385 ** Answer the height of a window. If it hasn't been created yet,
386 ** answer what the height of a window would be based upon its
387 ** type and the layout.
390 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
394 h
= tuiDefaultWinHeight (type
, layout
);
396 if (winList
[type
] == cmdWin
)
402 } /* tuiDefaultWinViewportHeight */
406 ** _initialize_tuiLayout().
407 ** Function to initialize gdb commands, for tui window layout
411 _initialize_tuiLayout (void)
413 add_com ("layout", class_tui
, _tuiLayout_command
,
414 "Change the layout of windows.\n\
415 Usage: layout prev | next | <layout_name> \n\
417 src : Displays source and command windows.\n\
418 asm : Displays disassembly and command windows.\n\
419 split : Displays source, disassembly and command windows.\n\
420 regs : Displays register window. If existing layout\n\
421 is source/command or assembly/command, the \n\
422 register window is displayed. If the\n\
423 source/assembly/command (split) is displayed, \n\
424 the register window is displayed with \n\
425 the window that has current logical focus.\n");
428 add_com ("td", class_tui
, _tuiToggleLayout_command
,
429 "Toggle between Source/Command and Disassembly/Command layouts.\n");
430 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
431 "Toggle between Source/Command or Disassembly/Command and \n\
432 Source/Disassembly/Command layouts.\n");
437 /*************************
438 ** STATIC LOCAL FUNCTIONS
439 **************************/
444 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
445 ** $REGS, $GREGS, $FREGS, $SREGS.
448 tui_set_layout (const char *layoutName
)
450 TuiStatus status
= TUI_SUCCESS
;
452 if (layoutName
!= (char *) NULL
)
455 register char *bufPtr
;
456 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
457 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
458 TuiLayoutType curLayout
= currentLayout ();
460 bufPtr
= (char *) xstrdup (layoutName
);
461 for (i
= 0; (i
< strlen (layoutName
)); i
++)
462 bufPtr
[i
] = toupper (bufPtr
[i
]);
464 /* First check for ambiguous input */
465 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
467 warning ("Ambiguous command input.\n");
468 status
= TUI_FAILURE
;
472 if (subset_compare (bufPtr
, "SRC"))
473 newLayout
= SRC_COMMAND
;
474 else if (subset_compare (bufPtr
, "ASM"))
475 newLayout
= DISASSEM_COMMAND
;
476 else if (subset_compare (bufPtr
, "SPLIT"))
477 newLayout
= SRC_DISASSEM_COMMAND
;
478 else if (subset_compare (bufPtr
, "REGS") ||
479 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
480 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
481 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
482 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
484 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
485 newLayout
= SRC_DATA_COMMAND
;
487 newLayout
= DISASSEM_DATA_COMMAND
;
489 /* could ifdef out the following code. when compile with -z, there are null
490 pointer references that cause a core dump if 'layout regs' is the first
491 layout command issued by the user. HP has asked us to hook up this code
494 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
496 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
498 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
500 dpyType
= TUI_SFLOAT_REGS
;
503 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
505 else if (subset_compare (bufPtr
,
506 TUI_GENERAL_SPECIAL_REGS_NAME
))
507 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
508 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
509 dpyType
= TUI_GENERAL_REGS
;
510 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
511 dpyType
= TUI_SPECIAL_REGS
;
514 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
517 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
519 dpyType
= TUI_GENERAL_REGS
;
522 /* end of potential ifdef
525 /* if ifdefed out code above, then assume that the user wishes to display the
526 general purpose registers
529 /* dpyType = TUI_GENERAL_REGS;
532 else if (subset_compare (bufPtr
, "NEXT"))
533 newLayout
= _nextLayout ();
534 else if (subset_compare (bufPtr
, "PREV"))
535 newLayout
= _prevLayout ();
537 status
= TUI_FAILURE
;
540 tuiSetLayout (newLayout
, dpyType
);
544 status
= TUI_FAILURE
;
551 _extractDisplayStartAddr (void)
553 TuiLayoutType curLayout
= currentLayout ();
560 case SRC_DATA_COMMAND
:
561 find_line_pc (current_source_symtab
,
562 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
566 case DISASSEM_COMMAND
:
567 case SRC_DISASSEM_COMMAND
:
568 case DISASSEM_DATA_COMMAND
:
569 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
577 } /* _extractDisplayStartAddr */
581 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
583 if (layoutDef
->split
)
585 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
586 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
590 if (layoutDef
->displayMode
== SRC_WIN
)
591 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
593 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
598 } /* _tuiHandleXDBLayout */
602 _tuiToggleLayout_command (char *arg
, int fromTTY
)
604 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
606 /* Make sure the curses mode is enabled. */
608 if (layoutDef
->displayMode
== SRC_WIN
)
609 layoutDef
->displayMode
= DISASSEM_WIN
;
611 layoutDef
->displayMode
= SRC_WIN
;
613 if (!layoutDef
->split
)
614 _tuiHandleXDBLayout (layoutDef
);
620 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
622 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
624 /* Make sure the curses mode is enabled. */
626 layoutDef
->split
= (!layoutDef
->split
);
627 _tuiHandleXDBLayout (layoutDef
);
633 _tuiLayout_command (char *arg
, int fromTTY
)
635 /* Make sure the curses mode is enabled. */
638 /* Switch to the selected layout. */
639 if (tui_set_layout (arg
) != TUI_SUCCESS
)
640 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
646 ** Answer the previous layout to cycle to.
651 TuiLayoutType newLayout
;
653 newLayout
= currentLayout ();
654 if (newLayout
== UNDEFINED_LAYOUT
)
655 newLayout
= SRC_COMMAND
;
659 if (newLayout
== UNDEFINED_LAYOUT
)
660 newLayout
= SRC_COMMAND
;
669 ** Answer the next layout to cycle to.
674 TuiLayoutType newLayout
;
676 newLayout
= currentLayout ();
677 if (newLayout
== SRC_COMMAND
)
678 newLayout
= DISASSEM_DATA_COMMAND
;
682 if (newLayout
== UNDEFINED_LAYOUT
)
683 newLayout
= DISASSEM_DATA_COMMAND
;
692 ** _makeCommandWindow().
695 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
697 _initAndMakeWin ((Opaque
*) winInfoPtr
,
705 (*winInfoPtr
)->canHighlight
= FALSE
;
708 } /* _makeCommandWindow */
712 ** _makeSourceWindow().
715 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
717 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
720 } /* _makeSourceWindow */
724 ** _makeDisassemWindow().
727 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
729 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
732 } /* _makeDisassemWindow */
736 ** _makeDataWindow().
739 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
741 _initAndMakeWin ((Opaque
*) winInfoPtr
,
750 } /* _makeDataWindow */
755 ** _showSourceCommand().
756 ** Show the Source/Command layout
759 _showSourceCommand (void)
761 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
764 } /* _showSourceCommand */
768 ** _showDisassemCommand().
769 ** Show the Dissassem/Command layout
772 _showDisassemCommand (void)
774 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
777 } /* _showDisassemCommand */
781 ** _showSourceDisassemCommand().
782 ** Show the Source/Disassem/Command layout
785 _showSourceDisassemCommand (void)
787 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
789 if (currentLayout () != SRC_DISASSEM_COMMAND
)
791 int cmdHeight
, srcHeight
, asmHeight
;
793 if (m_winPtrNotNull (cmdWin
))
794 cmdHeight
= cmdWin
->generic
.height
;
796 cmdHeight
= termHeight () / 3;
798 srcHeight
= (termHeight () - cmdHeight
) / 2;
799 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
801 if (m_winPtrIsNull (srcWin
))
802 _makeSourceWindow (&srcWin
, srcHeight
, 0);
805 _initGenWinInfo (&srcWin
->generic
,
806 srcWin
->generic
.type
,
808 srcWin
->generic
.width
,
809 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
811 srcWin
->canHighlight
= TRUE
;
812 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
818 m_beVisible (srcWin
);
819 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
820 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
822 if (m_winPtrNotNull (srcWin
))
824 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
826 tuiShowSourceContent (srcWin
);
827 if (m_winPtrIsNull (disassemWin
))
829 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
830 _initAndMakeWin ((Opaque
*) & locator
,
835 (srcHeight
+ asmHeight
) - 1,
840 _initGenWinInfo (locator
,
845 (srcHeight
+ asmHeight
) - 1);
846 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
848 &disassemWin
->generic
,
849 disassemWin
->generic
.type
,
851 disassemWin
->generic
.width
,
852 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
854 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
860 disassemWin
->canHighlight
= TRUE
;
861 m_beVisible (disassemWin
);
862 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
864 if (m_winPtrNotNull (disassemWin
))
866 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
867 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
868 m_beVisible (locator
);
869 tuiShowLocatorContent ();
870 tuiShowSourceContent (disassemWin
);
872 if (m_winPtrIsNull (cmdWin
))
873 _makeCommandWindow (&cmdWin
,
875 termHeight () - cmdHeight
);
878 _initGenWinInfo (&cmdWin
->generic
,
879 cmdWin
->generic
.type
,
880 cmdWin
->generic
.height
,
881 cmdWin
->generic
.width
,
883 cmdWin
->generic
.origin
.y
);
884 cmdWin
->canHighlight
= FALSE
;
885 m_beVisible (cmdWin
);
887 if (m_winPtrNotNull (cmdWin
))
888 tuiRefreshWin (&cmdWin
->generic
);
891 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
895 } /* _showSourceDisassemCommand */
900 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
903 _showData (TuiLayoutType newLayout
)
905 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
906 int srcHeight
, dataHeight
;
908 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
911 dataHeight
= totalHeight
/ 2;
912 srcHeight
= totalHeight
- dataHeight
;
914 m_beInvisible (locator
);
915 _makeDataWindow (&dataWin
, dataHeight
, 0);
916 dataWin
->canHighlight
= TRUE
;
917 if (newLayout
== SRC_DATA_COMMAND
)
920 winType
= DISASSEM_WIN
;
921 if (m_winPtrIsNull (winList
[winType
]))
923 if (winType
== SRC_WIN
)
924 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
926 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
927 _initAndMakeWin ((Opaque
*) & locator
,
937 _initGenWinInfo (&winList
[winType
]->generic
,
938 winList
[winType
]->generic
.type
,
940 winList
[winType
]->generic
.width
,
941 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
943 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
949 m_beVisible (winList
[winType
]);
950 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
951 _initGenWinInfo (locator
,
958 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
959 m_beVisible (locator
);
960 tuiShowLocatorContent ();
961 addToSourceWindows (winList
[winType
]);
962 setCurrentLayoutTo (newLayout
);
968 ** _initGenWinInfo().
971 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
972 int height
, int width
, int originX
, int originY
)
976 winInfo
->type
= type
;
977 winInfo
->width
= width
;
981 winInfo
->viewportHeight
= h
- 1;
982 if (winInfo
->type
!= CMD_WIN
)
983 winInfo
->viewportHeight
--;
986 winInfo
->viewportHeight
= 1;
987 winInfo
->origin
.x
= originX
;
988 winInfo
->origin
.y
= originY
;
991 } /* _initGenWinInfo */
994 ** _initAndMakeWin().
997 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
998 int height
, int width
, int originX
, int originY
, int boxIt
)
1000 Opaque opaqueWinInfo
= *winInfoPtr
;
1001 TuiGenWinInfoPtr generic
;
1003 if (opaqueWinInfo
== (Opaque
) NULL
)
1005 if (m_winIsAuxillary (winType
))
1006 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
1008 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
1010 if (m_winIsAuxillary (winType
))
1011 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
1013 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
1015 if (opaqueWinInfo
!= (Opaque
) NULL
)
1017 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1018 if (!m_winIsAuxillary (winType
))
1020 if (generic
->type
== CMD_WIN
)
1021 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1023 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1025 makeWindow (generic
, boxIt
);
1026 if (winType
== LOCATOR_WIN
)
1027 tuiClearLocatorDisplay ();
1029 *winInfoPtr
= opaqueWinInfo
;
1032 } /* _initAndMakeWin */
1036 ** _makeSourceOrDisassemWindow().
1039 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1040 int height
, int originY
)
1042 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1045 ** Create the exeuction info window.
1047 if (type
== SRC_WIN
)
1048 executionInfo
= sourceExecInfoWinPtr ();
1050 executionInfo
= disassemExecInfoWinPtr ();
1051 _initAndMakeWin ((Opaque
*) & executionInfo
,
1059 ** Now create the source window.
1061 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1064 termWidth () - executionInfo
->width
,
1065 executionInfo
->width
,
1069 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1072 } /* _makeSourceOrDisassemWindow */
1076 ** _showSourceOrDisassemAndCommand().
1077 ** Show the Source/Command or the Disassem layout
1080 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1082 if (currentLayout () != layoutType
)
1084 TuiWinInfoPtr
*winInfoPtr
;
1086 int srcHeight
, cmdHeight
;
1087 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1089 if (m_winPtrNotNull (cmdWin
))
1090 cmdHeight
= cmdWin
->generic
.height
;
1092 cmdHeight
= termHeight () / 3;
1093 srcHeight
= termHeight () - cmdHeight
;
1096 if (layoutType
== SRC_COMMAND
)
1097 winInfoPtr
= &srcWin
;
1099 winInfoPtr
= &disassemWin
;
1101 if (m_winPtrIsNull (*winInfoPtr
))
1103 if (layoutType
== SRC_COMMAND
)
1104 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1106 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1107 _initAndMakeWin ((Opaque
*) & locator
,
1117 _initGenWinInfo (locator
,
1123 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1125 &(*winInfoPtr
)->generic
,
1126 (*winInfoPtr
)->generic
.type
,
1128 (*winInfoPtr
)->generic
.width
,
1129 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1131 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1137 (*winInfoPtr
)->canHighlight
= TRUE
;
1138 m_beVisible (*winInfoPtr
);
1139 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1141 if (m_winPtrNotNull (*winInfoPtr
))
1143 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1144 m_beVisible (locator
);
1145 tuiShowLocatorContent ();
1146 tuiShowSourceContent (*winInfoPtr
);
1148 if (m_winPtrIsNull (cmdWin
))
1150 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1151 tuiRefreshWin (&cmdWin
->generic
);
1155 _initGenWinInfo (&cmdWin
->generic
,
1156 cmdWin
->generic
.type
,
1157 cmdWin
->generic
.height
,
1158 cmdWin
->generic
.width
,
1159 cmdWin
->generic
.origin
.x
,
1160 cmdWin
->generic
.origin
.y
);
1161 cmdWin
->canHighlight
= FALSE
;
1162 m_beVisible (cmdWin
);
1165 setCurrentLayoutTo (layoutType
);
1169 } /* _showSourceOrDisassemAndCommand */