1 /* TUI layout window management.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
6 Contributed by Hewlett-Packard Company.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
34 #include "tuiDataWin.h"
35 #include "tuiGeneralWin.h"
39 #include "tuiSourceWin.h"
40 #include "tuiDisassem.h"
50 /*******************************
52 ********************************/
53 static void showLayout (TuiLayoutType
);
54 static void _initGenWinInfo (TuiGenWinInfoPtr
, TuiWinType
, int, int, int, int);
55 static void _initAndMakeWin (Opaque
*, TuiWinType
, int, int, int, int, int);
56 static void _showSourceOrDisassemAndCommand (TuiLayoutType
);
57 static void _makeSourceOrDisassemWindow (TuiWinInfoPtr
*, TuiWinType
, int, int);
58 static void _makeCommandWindow (TuiWinInfoPtr
*, int, int);
59 static void _makeSourceWindow (TuiWinInfoPtr
*, int, int);
60 static void _makeDisassemWindow (TuiWinInfoPtr
*, int, int);
61 static void _makeDataWindow (TuiWinInfoPtr
*, int, int);
62 static void _showSourceCommand (void);
63 static void _showDisassemCommand (void);
64 static void _showSourceDisassemCommand (void);
65 static void _showData (TuiLayoutType
);
66 static TuiLayoutType
_nextLayout (void);
67 static TuiLayoutType
_prevLayout (void);
68 static void _tuiLayout_command (char *, int);
69 static void _tuiToggleLayout_command (char *, int);
70 static void _tuiToggleSplitLayout_command (char *, int);
71 static CORE_ADDR
_extractDisplayStartAddr (void);
72 static void _tuiHandleXDBLayout (TuiLayoutDefPtr
);
75 /***************************************
77 ***************************************/
79 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
81 /* 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 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
);
133 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
134 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
135 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
136 ** UNDEFINED_LAYOUT, then the data window is populated according
137 ** to regsDisplayType.
140 tuiSetLayout (TuiLayoutType layoutType
,
141 TuiRegisterDisplayType regsDisplayType
)
143 TuiStatus status
= TUI_SUCCESS
;
145 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
147 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
148 int regsPopulate
= FALSE
;
149 CORE_ADDR addr
= _extractDisplayStartAddr ();
150 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
151 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
154 if (layoutType
== UNDEFINED_LAYOUT
&&
155 regsDisplayType
!= TUI_UNDEFINED_REGS
)
157 if (curLayout
== SRC_DISASSEM_COMMAND
)
158 newLayout
= DISASSEM_DATA_COMMAND
;
159 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
160 newLayout
= SRC_DATA_COMMAND
;
161 else if (curLayout
== DISASSEM_COMMAND
||
162 curLayout
== DISASSEM_DATA_COMMAND
)
163 newLayout
= DISASSEM_DATA_COMMAND
;
166 newLayout
= layoutType
;
168 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
169 newLayout
== DISASSEM_DATA_COMMAND
||
170 regsDisplayType
!= TUI_UNDEFINED_REGS
);
171 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
173 if (newLayout
!= curLayout
)
175 showLayout (newLayout
);
177 ** Now determine where focus should be
179 if (winWithFocus
!= cmdWin
)
184 tuiSetWinFocusTo (srcWin
);
185 layoutDef
->displayMode
= SRC_WIN
;
186 layoutDef
->split
= FALSE
;
188 case DISASSEM_COMMAND
:
189 /* the previous layout was not showing
190 ** code. this can happen if there is no
192 ** 1. if the source file is in another dir OR
193 ** 2. if target was compiled without -g
194 ** We still want to show the assembly though!
196 addr
= tuiGetBeginAsmAddress ();
197 tuiSetWinFocusTo (disassemWin
);
198 layoutDef
->displayMode
= DISASSEM_WIN
;
199 layoutDef
->split
= FALSE
;
201 case SRC_DISASSEM_COMMAND
:
202 /* the previous layout was not showing
203 ** code. this can happen if there is no
205 ** 1. if the source file is in another dir OR
206 ** 2. if target was compiled without -g
207 ** We still want to show the assembly though!
209 addr
= tuiGetBeginAsmAddress ();
210 if (winWithFocus
== srcWin
)
211 tuiSetWinFocusTo (srcWin
);
213 tuiSetWinFocusTo (disassemWin
);
214 layoutDef
->split
= TRUE
;
216 case SRC_DATA_COMMAND
:
217 if (winWithFocus
!= dataWin
)
218 tuiSetWinFocusTo (srcWin
);
220 tuiSetWinFocusTo (dataWin
);
221 layoutDef
->displayMode
= SRC_WIN
;
222 layoutDef
->split
= FALSE
;
224 case DISASSEM_DATA_COMMAND
:
225 /* the previous layout was not showing
226 ** code. this can happen if there is no
228 ** 1. if the source file is in another dir OR
229 ** 2. if target was compiled without -g
230 ** We still want to show the assembly though!
232 addr
= tuiGetBeginAsmAddress ();
233 if (winWithFocus
!= dataWin
)
234 tuiSetWinFocusTo (disassemWin
);
236 tuiSetWinFocusTo (dataWin
);
237 layoutDef
->displayMode
= DISASSEM_WIN
;
238 layoutDef
->split
= FALSE
;
244 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
245 tuiSetWinFocusTo (newWinWithFocus
);
247 ** Now update the window content
250 (newLayout
== SRC_DATA_COMMAND
||
251 newLayout
== DISASSEM_DATA_COMMAND
))
252 tuiDisplayAllData ();
254 tuiUpdateSourceWindowsWithAddr (addr
);
258 layoutDef
->regsDisplayType
=
259 (regsDisplayType
== TUI_UNDEFINED_REGS
?
260 TUI_GENERAL_REGS
: regsDisplayType
);
261 tuiShowRegisters (layoutDef
->regsDisplayType
);
266 status
= TUI_FAILURE
;
272 ** tuiAddWinToLayout().
273 ** Add the specified window to the layout in a logical way.
274 ** This means setting up the most logical layout given the
275 ** window to be added.
278 tuiAddWinToLayout (TuiWinType type
)
280 TuiLayoutType curLayout
= currentLayout ();
285 if (curLayout
!= SRC_COMMAND
&&
286 curLayout
!= SRC_DISASSEM_COMMAND
&&
287 curLayout
!= SRC_DATA_COMMAND
)
289 clearSourceWindowsDetail ();
290 if (curLayout
== DISASSEM_DATA_COMMAND
)
291 showLayout (SRC_DATA_COMMAND
);
293 showLayout (SRC_COMMAND
);
297 if (curLayout
!= DISASSEM_COMMAND
&&
298 curLayout
!= SRC_DISASSEM_COMMAND
&&
299 curLayout
!= DISASSEM_DATA_COMMAND
)
301 clearSourceWindowsDetail ();
302 if (curLayout
== SRC_DATA_COMMAND
)
303 showLayout (DISASSEM_DATA_COMMAND
);
305 showLayout (DISASSEM_COMMAND
);
309 if (curLayout
!= SRC_DATA_COMMAND
&&
310 curLayout
!= DISASSEM_DATA_COMMAND
)
312 if (curLayout
== DISASSEM_COMMAND
)
313 showLayout (DISASSEM_DATA_COMMAND
);
315 showLayout (SRC_DATA_COMMAND
);
323 } /* tuiAddWinToLayout */
327 ** tuiDefaultWinHeight().
328 ** Answer the height of a window. If it hasn't been created yet,
329 ** answer what the height of a window would be based upon its
330 ** type and the layout.
333 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
337 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
338 h
= winList
[type
]->generic
.height
;
344 case DISASSEM_COMMAND
:
345 if (m_winPtrIsNull (cmdWin
))
346 h
= termHeight () / 2;
348 h
= termHeight () - cmdWin
->generic
.height
;
350 case SRC_DISASSEM_COMMAND
:
351 case SRC_DATA_COMMAND
:
352 case DISASSEM_DATA_COMMAND
:
353 if (m_winPtrIsNull (cmdWin
))
354 h
= termHeight () / 3;
356 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
365 } /* tuiDefaultWinHeight */
369 ** tuiDefaultWinViewportHeight().
370 ** Answer the height of a window. If it hasn't been created yet,
371 ** answer what the height of a window would be based upon its
372 ** type and the layout.
375 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
379 h
= tuiDefaultWinHeight (type
, layout
);
381 if (winList
[type
] == cmdWin
)
387 } /* tuiDefaultWinViewportHeight */
391 ** _initialize_tuiLayout().
392 ** Function to initialize gdb commands, for tui window layout
396 _initialize_tuiLayout (void)
398 add_com ("layout", class_tui
, _tuiLayout_command
,
399 "Change the layout of windows.\n\
400 Usage: layout prev | next | <layout_name> \n\
402 src : Displays source and command windows.\n\
403 asm : Displays disassembly and command windows.\n\
404 split : Displays source, disassembly and command windows.\n\
405 regs : Displays register window. If existing layout\n\
406 is source/command or assembly/command, the \n\
407 register window is displayed. If the\n\
408 source/assembly/command (split) is displayed, \n\
409 the register window is displayed with \n\
410 the window that has current logical focus.\n");
413 add_com ("td", class_tui
, _tuiToggleLayout_command
,
414 "Toggle between Source/Command and Disassembly/Command layouts.\n");
415 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
416 "Toggle between Source/Command or Disassembly/Command and \n\
417 Source/Disassembly/Command layouts.\n");
422 /*************************
423 ** STATIC LOCAL FUNCTIONS
424 **************************/
429 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
430 ** $REGS, $GREGS, $FREGS, $SREGS.
433 tui_set_layout (const char *layoutName
)
435 TuiStatus status
= TUI_SUCCESS
;
437 if (layoutName
!= (char *) NULL
)
440 register char *bufPtr
;
441 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
442 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
443 TuiLayoutType curLayout
= currentLayout ();
445 bufPtr
= (char *) xstrdup (layoutName
);
446 for (i
= 0; (i
< strlen (layoutName
)); i
++)
447 bufPtr
[i
] = toupper (bufPtr
[i
]);
449 /* First check for ambiguous input */
450 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
452 warning ("Ambiguous command input.\n");
453 status
= TUI_FAILURE
;
457 if (subset_compare (bufPtr
, "SRC"))
458 newLayout
= SRC_COMMAND
;
459 else if (subset_compare (bufPtr
, "ASM"))
460 newLayout
= DISASSEM_COMMAND
;
461 else if (subset_compare (bufPtr
, "SPLIT"))
462 newLayout
= SRC_DISASSEM_COMMAND
;
463 else if (subset_compare (bufPtr
, "REGS") ||
464 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
465 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
466 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
467 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
469 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
470 newLayout
= SRC_DATA_COMMAND
;
472 newLayout
= DISASSEM_DATA_COMMAND
;
474 /* could ifdef out the following code. when compile with -z, there are null
475 pointer references that cause a core dump if 'layout regs' is the first
476 layout command issued by the user. HP has asked us to hook up this code
479 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
481 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
483 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
485 dpyType
= TUI_SFLOAT_REGS
;
488 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
490 else if (subset_compare (bufPtr
,
491 TUI_GENERAL_SPECIAL_REGS_NAME
))
492 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
493 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
494 dpyType
= TUI_GENERAL_REGS
;
495 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
496 dpyType
= TUI_SPECIAL_REGS
;
499 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
502 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
504 dpyType
= TUI_GENERAL_REGS
;
507 /* end of potential ifdef
510 /* if ifdefed out code above, then assume that the user wishes to display the
511 general purpose registers
514 /* dpyType = TUI_GENERAL_REGS;
517 else if (subset_compare (bufPtr
, "NEXT"))
518 newLayout
= _nextLayout ();
519 else if (subset_compare (bufPtr
, "PREV"))
520 newLayout
= _prevLayout ();
522 status
= TUI_FAILURE
;
525 tuiSetLayout (newLayout
, dpyType
);
529 status
= TUI_FAILURE
;
536 _extractDisplayStartAddr (void)
538 TuiLayoutType curLayout
= currentLayout ();
541 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
546 case SRC_DATA_COMMAND
:
547 find_line_pc (cursal
.symtab
,
548 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
552 case DISASSEM_COMMAND
:
553 case SRC_DISASSEM_COMMAND
:
554 case DISASSEM_DATA_COMMAND
:
555 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
563 } /* _extractDisplayStartAddr */
567 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
569 if (layoutDef
->split
)
571 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
572 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
576 if (layoutDef
->displayMode
== SRC_WIN
)
577 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
579 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
584 } /* _tuiHandleXDBLayout */
588 _tuiToggleLayout_command (char *arg
, int fromTTY
)
590 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
592 /* Make sure the curses mode is enabled. */
594 if (layoutDef
->displayMode
== SRC_WIN
)
595 layoutDef
->displayMode
= DISASSEM_WIN
;
597 layoutDef
->displayMode
= SRC_WIN
;
599 if (!layoutDef
->split
)
600 _tuiHandleXDBLayout (layoutDef
);
606 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
608 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
610 /* Make sure the curses mode is enabled. */
612 layoutDef
->split
= (!layoutDef
->split
);
613 _tuiHandleXDBLayout (layoutDef
);
619 _tuiLayout_command (char *arg
, int fromTTY
)
621 /* Make sure the curses mode is enabled. */
624 /* Switch to the selected layout. */
625 if (tui_set_layout (arg
) != TUI_SUCCESS
)
626 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
632 ** Answer the previous layout to cycle to.
637 TuiLayoutType newLayout
;
639 newLayout
= currentLayout ();
640 if (newLayout
== UNDEFINED_LAYOUT
)
641 newLayout
= SRC_COMMAND
;
645 if (newLayout
== UNDEFINED_LAYOUT
)
646 newLayout
= SRC_COMMAND
;
655 ** Answer the next layout to cycle to.
660 TuiLayoutType newLayout
;
662 newLayout
= currentLayout ();
663 if (newLayout
== SRC_COMMAND
)
664 newLayout
= DISASSEM_DATA_COMMAND
;
668 if (newLayout
== UNDEFINED_LAYOUT
)
669 newLayout
= DISASSEM_DATA_COMMAND
;
678 ** _makeCommandWindow().
681 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
683 _initAndMakeWin ((Opaque
*) winInfoPtr
,
691 (*winInfoPtr
)->canHighlight
= FALSE
;
694 } /* _makeCommandWindow */
698 ** _makeSourceWindow().
701 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
703 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
706 } /* _makeSourceWindow */
710 ** _makeDisassemWindow().
713 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
715 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
718 } /* _makeDisassemWindow */
722 ** _makeDataWindow().
725 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
727 _initAndMakeWin ((Opaque
*) winInfoPtr
,
736 } /* _makeDataWindow */
741 ** _showSourceCommand().
742 ** Show the Source/Command layout
745 _showSourceCommand (void)
747 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
750 } /* _showSourceCommand */
754 ** _showDisassemCommand().
755 ** Show the Dissassem/Command layout
758 _showDisassemCommand (void)
760 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
763 } /* _showDisassemCommand */
767 ** _showSourceDisassemCommand().
768 ** Show the Source/Disassem/Command layout
771 _showSourceDisassemCommand (void)
773 if (currentLayout () != SRC_DISASSEM_COMMAND
)
775 int cmdHeight
, srcHeight
, asmHeight
;
777 if (m_winPtrNotNull (cmdWin
))
778 cmdHeight
= cmdWin
->generic
.height
;
780 cmdHeight
= termHeight () / 3;
782 srcHeight
= (termHeight () - cmdHeight
) / 2;
783 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
785 if (m_winPtrIsNull (srcWin
))
786 _makeSourceWindow (&srcWin
, srcHeight
, 0);
789 _initGenWinInfo (&srcWin
->generic
,
790 srcWin
->generic
.type
,
792 srcWin
->generic
.width
,
793 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
795 srcWin
->canHighlight
= TRUE
;
796 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
802 m_beVisible (srcWin
);
803 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
804 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
806 if (m_winPtrNotNull (srcWin
))
808 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
810 tuiShowSourceContent (srcWin
);
811 if (m_winPtrIsNull (disassemWin
))
813 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
814 _initAndMakeWin ((Opaque
*) & locator
,
819 (srcHeight
+ asmHeight
) - 1,
824 _initGenWinInfo (locator
,
829 (srcHeight
+ asmHeight
) - 1);
830 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
832 &disassemWin
->generic
,
833 disassemWin
->generic
.type
,
835 disassemWin
->generic
.width
,
836 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
838 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
844 disassemWin
->canHighlight
= TRUE
;
845 m_beVisible (disassemWin
);
846 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
848 if (m_winPtrNotNull (disassemWin
))
850 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
851 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
852 m_beVisible (locator
);
853 tuiShowLocatorContent ();
854 tuiShowSourceContent (disassemWin
);
856 if (m_winPtrIsNull (cmdWin
))
857 _makeCommandWindow (&cmdWin
,
859 termHeight () - cmdHeight
);
862 _initGenWinInfo (&cmdWin
->generic
,
863 cmdWin
->generic
.type
,
864 cmdWin
->generic
.height
,
865 cmdWin
->generic
.width
,
867 cmdWin
->generic
.origin
.y
);
868 cmdWin
->canHighlight
= FALSE
;
869 m_beVisible (cmdWin
);
871 if (m_winPtrNotNull (cmdWin
))
872 tuiRefreshWin (&cmdWin
->generic
);
875 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
879 } /* _showSourceDisassemCommand */
884 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
887 _showData (TuiLayoutType newLayout
)
889 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
890 int srcHeight
, dataHeight
;
892 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
895 dataHeight
= totalHeight
/ 2;
896 srcHeight
= totalHeight
- dataHeight
;
898 m_beInvisible (locator
);
899 _makeDataWindow (&dataWin
, dataHeight
, 0);
900 dataWin
->canHighlight
= TRUE
;
901 if (newLayout
== SRC_DATA_COMMAND
)
904 winType
= DISASSEM_WIN
;
905 if (m_winPtrIsNull (winList
[winType
]))
907 if (winType
== SRC_WIN
)
908 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
910 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
911 _initAndMakeWin ((Opaque
*) & locator
,
921 _initGenWinInfo (&winList
[winType
]->generic
,
922 winList
[winType
]->generic
.type
,
924 winList
[winType
]->generic
.width
,
925 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
927 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
933 m_beVisible (winList
[winType
]);
934 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
935 _initGenWinInfo (locator
,
942 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
943 m_beVisible (locator
);
944 tuiShowLocatorContent ();
945 addToSourceWindows (winList
[winType
]);
946 setCurrentLayoutTo (newLayout
);
952 ** _initGenWinInfo().
955 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
956 int height
, int width
, int originX
, int originY
)
960 winInfo
->type
= type
;
961 winInfo
->width
= width
;
965 winInfo
->viewportHeight
= h
- 1;
966 if (winInfo
->type
!= CMD_WIN
)
967 winInfo
->viewportHeight
--;
970 winInfo
->viewportHeight
= 1;
971 winInfo
->origin
.x
= originX
;
972 winInfo
->origin
.y
= originY
;
975 } /* _initGenWinInfo */
978 ** _initAndMakeWin().
981 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
982 int height
, int width
, int originX
, int originY
, int boxIt
)
984 Opaque opaqueWinInfo
= *winInfoPtr
;
985 TuiGenWinInfoPtr generic
;
987 if (opaqueWinInfo
== (Opaque
) NULL
)
989 if (m_winIsAuxillary (winType
))
990 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
992 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
994 if (m_winIsAuxillary (winType
))
995 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
997 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
999 if (opaqueWinInfo
!= (Opaque
) NULL
)
1001 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1002 if (!m_winIsAuxillary (winType
))
1004 if (generic
->type
== CMD_WIN
)
1005 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1007 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1009 makeWindow (generic
, boxIt
);
1011 *winInfoPtr
= opaqueWinInfo
;
1016 ** _makeSourceOrDisassemWindow().
1019 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1020 int height
, int originY
)
1022 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1025 ** Create the exeuction info window.
1027 if (type
== SRC_WIN
)
1028 executionInfo
= sourceExecInfoWinPtr ();
1030 executionInfo
= disassemExecInfoWinPtr ();
1031 _initAndMakeWin ((Opaque
*) & executionInfo
,
1039 ** Now create the source window.
1041 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1044 termWidth () - executionInfo
->width
,
1045 executionInfo
->width
,
1049 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1052 } /* _makeSourceOrDisassemWindow */
1056 ** _showSourceOrDisassemAndCommand().
1057 ** Show the Source/Command or the Disassem layout
1060 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1062 if (currentLayout () != layoutType
)
1064 TuiWinInfoPtr
*winInfoPtr
;
1065 int srcHeight
, cmdHeight
;
1066 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1068 if (m_winPtrNotNull (cmdWin
))
1069 cmdHeight
= cmdWin
->generic
.height
;
1071 cmdHeight
= termHeight () / 3;
1072 srcHeight
= termHeight () - cmdHeight
;
1075 if (layoutType
== SRC_COMMAND
)
1076 winInfoPtr
= &srcWin
;
1078 winInfoPtr
= &disassemWin
;
1080 if (m_winPtrIsNull (*winInfoPtr
))
1082 if (layoutType
== SRC_COMMAND
)
1083 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1085 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1086 _initAndMakeWin ((Opaque
*) & locator
,
1096 _initGenWinInfo (locator
,
1102 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1104 &(*winInfoPtr
)->generic
,
1105 (*winInfoPtr
)->generic
.type
,
1107 (*winInfoPtr
)->generic
.width
,
1108 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1110 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1116 (*winInfoPtr
)->canHighlight
= TRUE
;
1117 m_beVisible (*winInfoPtr
);
1118 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1120 if (m_winPtrNotNull (*winInfoPtr
))
1122 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1123 m_beVisible (locator
);
1124 tuiShowLocatorContent ();
1125 tuiShowSourceContent (*winInfoPtr
);
1127 if (m_winPtrIsNull (cmdWin
))
1129 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1130 tuiRefreshWin (&cmdWin
->generic
);
1134 _initGenWinInfo (&cmdWin
->generic
,
1135 cmdWin
->generic
.type
,
1136 cmdWin
->generic
.height
,
1137 cmdWin
->generic
.width
,
1138 cmdWin
->generic
.origin
.x
,
1139 cmdWin
->generic
.origin
.y
);
1140 cmdWin
->canHighlight
= FALSE
;
1141 m_beVisible (cmdWin
);
1144 setCurrentLayoutTo (layoutType
);
1148 } /* _showSourceOrDisassemAndCommand */