1 /* TUI layout window management.
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
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. */
33 #include "tui/tui-data.h"
34 #include "tui/tui-windata.h"
35 #include "tui/tui-wingeneral.h"
36 #include "tui/tui-stack.h"
37 #include "tui/tui-regs.h"
38 #include "tui/tui-win.h"
39 #include "tui/tui-winsource.h"
40 #include "tui/tui-disasm.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
);
131 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
132 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
133 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
134 UNDEFINED_LAYOUT, then the data window is populated according to
137 tui_set_layout (enum tui_layout_type layoutType
,
138 enum tui_register_display_type regsDisplayType
)
140 TuiStatus status
= TUI_SUCCESS
;
142 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
144 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
145 int regsPopulate
= FALSE
;
146 CORE_ADDR addr
= _extractDisplayStartAddr ();
147 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
148 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
151 if (layoutType
== UNDEFINED_LAYOUT
&&
152 regsDisplayType
!= TUI_UNDEFINED_REGS
)
154 if (curLayout
== SRC_DISASSEM_COMMAND
)
155 newLayout
= DISASSEM_DATA_COMMAND
;
156 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
157 newLayout
= SRC_DATA_COMMAND
;
158 else if (curLayout
== DISASSEM_COMMAND
||
159 curLayout
== DISASSEM_DATA_COMMAND
)
160 newLayout
= DISASSEM_DATA_COMMAND
;
163 newLayout
= layoutType
;
165 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
166 newLayout
== DISASSEM_DATA_COMMAND
||
167 regsDisplayType
!= TUI_UNDEFINED_REGS
);
168 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
170 if (newLayout
!= curLayout
)
172 showLayout (newLayout
);
174 ** Now determine where focus should be
176 if (winWithFocus
!= cmdWin
)
181 tuiSetWinFocusTo (srcWin
);
182 layoutDef
->displayMode
= SRC_WIN
;
183 layoutDef
->split
= FALSE
;
185 case DISASSEM_COMMAND
:
186 /* the previous layout was not showing
187 ** code. this can happen if there is no
189 ** 1. if the source file is in another dir OR
190 ** 2. if target was compiled without -g
191 ** We still want to show the assembly though!
193 addr
= tui_get_begin_asm_address ();
194 tuiSetWinFocusTo (disassemWin
);
195 layoutDef
->displayMode
= DISASSEM_WIN
;
196 layoutDef
->split
= FALSE
;
198 case SRC_DISASSEM_COMMAND
:
199 /* the previous layout was not showing
200 ** code. this can happen if there is no
202 ** 1. if the source file is in another dir OR
203 ** 2. if target was compiled without -g
204 ** We still want to show the assembly though!
206 addr
= tui_get_begin_asm_address ();
207 if (winWithFocus
== srcWin
)
208 tuiSetWinFocusTo (srcWin
);
210 tuiSetWinFocusTo (disassemWin
);
211 layoutDef
->split
= TRUE
;
213 case SRC_DATA_COMMAND
:
214 if (winWithFocus
!= dataWin
)
215 tuiSetWinFocusTo (srcWin
);
217 tuiSetWinFocusTo (dataWin
);
218 layoutDef
->displayMode
= SRC_WIN
;
219 layoutDef
->split
= FALSE
;
221 case DISASSEM_DATA_COMMAND
:
222 /* the previous layout was not showing
223 ** code. this can happen if there is no
225 ** 1. if the source file is in another dir OR
226 ** 2. if target was compiled without -g
227 ** We still want to show the assembly though!
229 addr
= tui_get_begin_asm_address ();
230 if (winWithFocus
!= dataWin
)
231 tuiSetWinFocusTo (disassemWin
);
233 tuiSetWinFocusTo (dataWin
);
234 layoutDef
->displayMode
= DISASSEM_WIN
;
235 layoutDef
->split
= FALSE
;
241 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
242 tuiSetWinFocusTo (newWinWithFocus
);
244 ** Now update the window content
247 (newLayout
== SRC_DATA_COMMAND
||
248 newLayout
== DISASSEM_DATA_COMMAND
))
249 tuiDisplayAllData ();
251 tuiUpdateSourceWindowsWithAddr (addr
);
255 layoutDef
->regsDisplayType
=
256 (regsDisplayType
== TUI_UNDEFINED_REGS
?
257 TUI_GENERAL_REGS
: regsDisplayType
);
258 tui_show_registers (layoutDef
->regsDisplayType
);
263 status
= TUI_FAILURE
;
268 /* Add the specified window to the layout in a logical way. This
269 means setting up the most logical layout given the window to be
272 tui_add_win_to_layout (enum tui_win_type type
)
274 TuiLayoutType curLayout
= currentLayout ();
279 if (curLayout
!= SRC_COMMAND
&&
280 curLayout
!= SRC_DISASSEM_COMMAND
&&
281 curLayout
!= SRC_DATA_COMMAND
)
283 clearSourceWindowsDetail ();
284 if (curLayout
== DISASSEM_DATA_COMMAND
)
285 showLayout (SRC_DATA_COMMAND
);
287 showLayout (SRC_COMMAND
);
291 if (curLayout
!= DISASSEM_COMMAND
&&
292 curLayout
!= SRC_DISASSEM_COMMAND
&&
293 curLayout
!= DISASSEM_DATA_COMMAND
)
295 clearSourceWindowsDetail ();
296 if (curLayout
== SRC_DATA_COMMAND
)
297 showLayout (DISASSEM_DATA_COMMAND
);
299 showLayout (DISASSEM_COMMAND
);
303 if (curLayout
!= SRC_DATA_COMMAND
&&
304 curLayout
!= DISASSEM_DATA_COMMAND
)
306 if (curLayout
== DISASSEM_COMMAND
)
307 showLayout (DISASSEM_DATA_COMMAND
);
309 showLayout (SRC_DATA_COMMAND
);
317 } /* tuiAddWinToLayout */
321 ** tuiDefaultWinHeight().
322 ** Answer the height of a window. If it hasn't been created yet,
323 ** answer what the height of a window would be based upon its
324 ** type and the layout.
327 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
331 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
332 h
= winList
[type
]->generic
.height
;
338 case DISASSEM_COMMAND
:
339 if (m_winPtrIsNull (cmdWin
))
340 h
= termHeight () / 2;
342 h
= termHeight () - cmdWin
->generic
.height
;
344 case SRC_DISASSEM_COMMAND
:
345 case SRC_DATA_COMMAND
:
346 case DISASSEM_DATA_COMMAND
:
347 if (m_winPtrIsNull (cmdWin
))
348 h
= termHeight () / 3;
350 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
359 } /* tuiDefaultWinHeight */
362 /* Answer the height of a window. If it hasn't been created yet,
363 answer what the height of a window would be based upon its type and
366 tui_default_win_viewport_height (enum tui_win_type type
,
367 enum tui_layout_type layout
)
371 h
= tuiDefaultWinHeight (type
, layout
);
373 if (winList
[type
] == cmdWin
)
379 } /* tuiDefaultWinViewportHeight */
383 ** _initialize_tuiLayout().
384 ** Function to initialize gdb commands, for tui window layout
388 _initialize_tuiLayout (void)
390 add_com ("layout", class_tui
, _tuiLayout_command
,
391 "Change the layout of windows.\n\
392 Usage: layout prev | next | <layout_name> \n\
394 src : Displays source and command windows.\n\
395 asm : Displays disassembly and command windows.\n\
396 split : Displays source, disassembly and command windows.\n\
397 regs : Displays register window. If existing layout\n\
398 is source/command or assembly/command, the \n\
399 register window is displayed. If the\n\
400 source/assembly/command (split) is displayed, \n\
401 the register window is displayed with \n\
402 the window that has current logical focus.\n");
405 add_com ("td", class_tui
, _tuiToggleLayout_command
,
406 "Toggle between Source/Command and Disassembly/Command layouts.\n");
407 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
408 "Toggle between Source/Command or Disassembly/Command and \n\
409 Source/Disassembly/Command layouts.\n");
414 /*************************
415 ** STATIC LOCAL FUNCTIONS
416 **************************/
421 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
422 ** $REGS, $GREGS, $FREGS, $SREGS.
425 tui_set_layout_for_display_command (const char *layoutName
)
427 TuiStatus status
= TUI_SUCCESS
;
429 if (layoutName
!= (char *) NULL
)
432 register char *bufPtr
;
433 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
434 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
435 TuiLayoutType curLayout
= currentLayout ();
437 bufPtr
= (char *) xstrdup (layoutName
);
438 for (i
= 0; (i
< strlen (layoutName
)); i
++)
439 bufPtr
[i
] = toupper (bufPtr
[i
]);
441 /* First check for ambiguous input */
442 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
444 warning ("Ambiguous command input.\n");
445 status
= TUI_FAILURE
;
449 if (subset_compare (bufPtr
, "SRC"))
450 newLayout
= SRC_COMMAND
;
451 else if (subset_compare (bufPtr
, "ASM"))
452 newLayout
= DISASSEM_COMMAND
;
453 else if (subset_compare (bufPtr
, "SPLIT"))
454 newLayout
= SRC_DISASSEM_COMMAND
;
455 else if (subset_compare (bufPtr
, "REGS") ||
456 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
457 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
458 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
459 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
461 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
462 newLayout
= SRC_DATA_COMMAND
;
464 newLayout
= DISASSEM_DATA_COMMAND
;
466 /* could ifdef out the following code. when compile with -z, there are null
467 pointer references that cause a core dump if 'layout regs' is the first
468 layout command issued by the user. HP has asked us to hook up this code
471 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
473 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
475 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
477 dpyType
= TUI_SFLOAT_REGS
;
480 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
482 else if (subset_compare (bufPtr
,
483 TUI_GENERAL_SPECIAL_REGS_NAME
))
484 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
485 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
486 dpyType
= TUI_GENERAL_REGS
;
487 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
488 dpyType
= TUI_SPECIAL_REGS
;
491 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
494 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
496 dpyType
= TUI_GENERAL_REGS
;
499 /* end of potential ifdef
502 /* if ifdefed out code above, then assume that the user wishes to display the
503 general purpose registers
506 /* dpyType = TUI_GENERAL_REGS;
509 else if (subset_compare (bufPtr
, "NEXT"))
510 newLayout
= _nextLayout ();
511 else if (subset_compare (bufPtr
, "PREV"))
512 newLayout
= _prevLayout ();
514 status
= TUI_FAILURE
;
517 tui_set_layout (newLayout
, dpyType
);
521 status
= TUI_FAILURE
;
528 _extractDisplayStartAddr (void)
530 TuiLayoutType curLayout
= currentLayout ();
533 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
538 case SRC_DATA_COMMAND
:
539 find_line_pc (cursal
.symtab
,
540 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
544 case DISASSEM_COMMAND
:
545 case SRC_DISASSEM_COMMAND
:
546 case DISASSEM_DATA_COMMAND
:
547 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
555 } /* _extractDisplayStartAddr */
559 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
561 if (layoutDef
->split
)
563 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
564 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
568 if (layoutDef
->displayMode
== SRC_WIN
)
569 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
571 tui_set_layout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
576 } /* _tuiHandleXDBLayout */
580 _tuiToggleLayout_command (char *arg
, int fromTTY
)
582 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
584 /* Make sure the curses mode is enabled. */
586 if (layoutDef
->displayMode
== SRC_WIN
)
587 layoutDef
->displayMode
= DISASSEM_WIN
;
589 layoutDef
->displayMode
= SRC_WIN
;
591 if (!layoutDef
->split
)
592 _tuiHandleXDBLayout (layoutDef
);
598 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
600 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
602 /* Make sure the curses mode is enabled. */
604 layoutDef
->split
= (!layoutDef
->split
);
605 _tuiHandleXDBLayout (layoutDef
);
611 _tuiLayout_command (char *arg
, int fromTTY
)
613 /* Make sure the curses mode is enabled. */
616 /* Switch to the selected layout. */
617 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
618 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
624 ** Answer the previous layout to cycle to.
629 TuiLayoutType newLayout
;
631 newLayout
= currentLayout ();
632 if (newLayout
== UNDEFINED_LAYOUT
)
633 newLayout
= SRC_COMMAND
;
637 if (newLayout
== UNDEFINED_LAYOUT
)
638 newLayout
= SRC_COMMAND
;
647 ** Answer the next layout to cycle to.
652 TuiLayoutType newLayout
;
654 newLayout
= currentLayout ();
655 if (newLayout
== SRC_COMMAND
)
656 newLayout
= DISASSEM_DATA_COMMAND
;
660 if (newLayout
== UNDEFINED_LAYOUT
)
661 newLayout
= DISASSEM_DATA_COMMAND
;
670 ** _makeCommandWindow().
673 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
675 _initAndMakeWin ((Opaque
*) winInfoPtr
,
683 (*winInfoPtr
)->canHighlight
= FALSE
;
686 } /* _makeCommandWindow */
690 ** _makeSourceWindow().
693 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
695 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
698 } /* _makeSourceWindow */
702 ** _makeDisassemWindow().
705 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
707 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
710 } /* _makeDisassemWindow */
714 ** _makeDataWindow().
717 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
719 _initAndMakeWin ((Opaque
*) winInfoPtr
,
728 } /* _makeDataWindow */
733 ** _showSourceCommand().
734 ** Show the Source/Command layout
737 _showSourceCommand (void)
739 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
742 } /* _showSourceCommand */
746 ** _showDisassemCommand().
747 ** Show the Dissassem/Command layout
750 _showDisassemCommand (void)
752 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
755 } /* _showDisassemCommand */
759 ** _showSourceDisassemCommand().
760 ** Show the Source/Disassem/Command layout
763 _showSourceDisassemCommand (void)
765 if (currentLayout () != SRC_DISASSEM_COMMAND
)
767 int cmdHeight
, srcHeight
, asmHeight
;
769 if (m_winPtrNotNull (cmdWin
))
770 cmdHeight
= cmdWin
->generic
.height
;
772 cmdHeight
= termHeight () / 3;
774 srcHeight
= (termHeight () - cmdHeight
) / 2;
775 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
777 if (m_winPtrIsNull (srcWin
))
778 _makeSourceWindow (&srcWin
, srcHeight
, 0);
781 _initGenWinInfo (&srcWin
->generic
,
782 srcWin
->generic
.type
,
784 srcWin
->generic
.width
,
785 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
787 srcWin
->canHighlight
= TRUE
;
788 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
794 m_beVisible (srcWin
);
795 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
796 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
798 if (m_winPtrNotNull (srcWin
))
800 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
802 tuiShowSourceContent (srcWin
);
803 if (m_winPtrIsNull (disassemWin
))
805 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
806 _initAndMakeWin ((Opaque
*) & locator
,
811 (srcHeight
+ asmHeight
) - 1,
816 _initGenWinInfo (locator
,
821 (srcHeight
+ asmHeight
) - 1);
822 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
824 &disassemWin
->generic
,
825 disassemWin
->generic
.type
,
827 disassemWin
->generic
.width
,
828 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
830 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
836 disassemWin
->canHighlight
= TRUE
;
837 m_beVisible (disassemWin
);
838 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
840 if (m_winPtrNotNull (disassemWin
))
842 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
843 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
844 m_beVisible (locator
);
845 tui_show_locator_content ();
846 tuiShowSourceContent (disassemWin
);
848 if (m_winPtrIsNull (cmdWin
))
849 _makeCommandWindow (&cmdWin
,
851 termHeight () - cmdHeight
);
854 _initGenWinInfo (&cmdWin
->generic
,
855 cmdWin
->generic
.type
,
856 cmdWin
->generic
.height
,
857 cmdWin
->generic
.width
,
859 cmdWin
->generic
.origin
.y
);
860 cmdWin
->canHighlight
= FALSE
;
861 m_beVisible (cmdWin
);
863 if (m_winPtrNotNull (cmdWin
))
864 tuiRefreshWin (&cmdWin
->generic
);
867 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
871 } /* _showSourceDisassemCommand */
876 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
879 _showData (TuiLayoutType newLayout
)
881 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
882 int srcHeight
, dataHeight
;
884 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
887 dataHeight
= totalHeight
/ 2;
888 srcHeight
= totalHeight
- dataHeight
;
890 m_beInvisible (locator
);
891 _makeDataWindow (&dataWin
, dataHeight
, 0);
892 dataWin
->canHighlight
= TRUE
;
893 if (newLayout
== SRC_DATA_COMMAND
)
896 winType
= DISASSEM_WIN
;
897 if (m_winPtrIsNull (winList
[winType
]))
899 if (winType
== SRC_WIN
)
900 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
902 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
903 _initAndMakeWin ((Opaque
*) & locator
,
913 _initGenWinInfo (&winList
[winType
]->generic
,
914 winList
[winType
]->generic
.type
,
916 winList
[winType
]->generic
.width
,
917 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
919 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
925 m_beVisible (winList
[winType
]);
926 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
927 _initGenWinInfo (locator
,
934 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
935 m_beVisible (locator
);
936 tui_show_locator_content ();
937 addToSourceWindows (winList
[winType
]);
938 setCurrentLayoutTo (newLayout
);
944 ** _initGenWinInfo().
947 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
948 int height
, int width
, int originX
, int originY
)
952 winInfo
->type
= type
;
953 winInfo
->width
= width
;
957 winInfo
->viewportHeight
= h
- 1;
958 if (winInfo
->type
!= CMD_WIN
)
959 winInfo
->viewportHeight
--;
962 winInfo
->viewportHeight
= 1;
963 winInfo
->origin
.x
= originX
;
964 winInfo
->origin
.y
= originY
;
967 } /* _initGenWinInfo */
970 ** _initAndMakeWin().
973 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
974 int height
, int width
, int originX
, int originY
, int boxIt
)
976 Opaque opaqueWinInfo
= *winInfoPtr
;
977 TuiGenWinInfoPtr generic
;
979 if (opaqueWinInfo
== (Opaque
) NULL
)
981 if (m_winIsAuxillary (winType
))
982 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
984 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
986 if (m_winIsAuxillary (winType
))
987 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
989 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
991 if (opaqueWinInfo
!= (Opaque
) NULL
)
993 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
994 if (!m_winIsAuxillary (winType
))
996 if (generic
->type
== CMD_WIN
)
997 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
999 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1001 makeWindow (generic
, boxIt
);
1003 *winInfoPtr
= opaqueWinInfo
;
1008 ** _makeSourceOrDisassemWindow().
1011 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1012 int height
, int originY
)
1014 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1017 ** Create the exeuction info window.
1019 if (type
== SRC_WIN
)
1020 executionInfo
= sourceExecInfoWinPtr ();
1022 executionInfo
= disassemExecInfoWinPtr ();
1023 _initAndMakeWin ((Opaque
*) & executionInfo
,
1031 ** Now create the source window.
1033 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1036 termWidth () - executionInfo
->width
,
1037 executionInfo
->width
,
1041 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1044 } /* _makeSourceOrDisassemWindow */
1048 ** _showSourceOrDisassemAndCommand().
1049 ** Show the Source/Command or the Disassem layout
1052 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1054 if (currentLayout () != layoutType
)
1056 TuiWinInfoPtr
*winInfoPtr
;
1057 int srcHeight
, cmdHeight
;
1058 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1060 if (m_winPtrNotNull (cmdWin
))
1061 cmdHeight
= cmdWin
->generic
.height
;
1063 cmdHeight
= termHeight () / 3;
1064 srcHeight
= termHeight () - cmdHeight
;
1067 if (layoutType
== SRC_COMMAND
)
1068 winInfoPtr
= &srcWin
;
1070 winInfoPtr
= &disassemWin
;
1072 if (m_winPtrIsNull (*winInfoPtr
))
1074 if (layoutType
== SRC_COMMAND
)
1075 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1077 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1078 _initAndMakeWin ((Opaque
*) & locator
,
1088 _initGenWinInfo (locator
,
1094 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1096 &(*winInfoPtr
)->generic
,
1097 (*winInfoPtr
)->generic
.type
,
1099 (*winInfoPtr
)->generic
.width
,
1100 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1102 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1108 (*winInfoPtr
)->canHighlight
= TRUE
;
1109 m_beVisible (*winInfoPtr
);
1110 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1112 if (m_winPtrNotNull (*winInfoPtr
))
1114 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1115 m_beVisible (locator
);
1116 tui_show_locator_content ();
1117 tuiShowSourceContent (*winInfoPtr
);
1119 if (m_winPtrIsNull (cmdWin
))
1121 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1122 tuiRefreshWin (&cmdWin
->generic
);
1126 _initGenWinInfo (&cmdWin
->generic
,
1127 cmdWin
->generic
.type
,
1128 cmdWin
->generic
.height
,
1129 cmdWin
->generic
.width
,
1130 cmdWin
->generic
.origin
.x
,
1131 cmdWin
->generic
.origin
.y
);
1132 cmdWin
->canHighlight
= FALSE
;
1133 m_beVisible (cmdWin
);
1136 setCurrentLayoutTo (layoutType
);
1140 } /* _showSourceOrDisassemAndCommand */