1 /* TUI layout window management.
3 Copyright 1998, 1999, 2000, 2001, 2002 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. */
25 /* FIXME: cagney/2002-02-28: The GDB coding standard indicates that
26 "defs.h" should be included first. Unfortunatly some systems
27 (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h>
28 and they clash with "bfd.h"'s definiton of true/false. The correct
29 fix is to remove true/false from "bfd.h", however, until that
30 happens, hack around it by including "config.h" and <curses.h>
50 #include "tuiDataWin.h"
51 #include "tuiGeneralWin.h"
55 #include "tuiSourceWin.h"
56 #include "tuiDisassem.h"
58 /*******************************
60 ********************************/
62 static void _initGenWinInfo (TuiGenWinInfoPtr
, TuiWinType
, int, int, int, int);
63 static void _initAndMakeWin (Opaque
*, TuiWinType
, int, int, int, int, int);
64 static void _showSourceOrDisassemAndCommand (TuiLayoutType
);
65 static void _makeSourceOrDisassemWindow (TuiWinInfoPtr
*, TuiWinType
, int, int);
66 static void _makeCommandWindow (TuiWinInfoPtr
*, int, int);
67 static void _makeSourceWindow (TuiWinInfoPtr
*, int, int);
68 static void _makeDisassemWindow (TuiWinInfoPtr
*, int, int);
69 static void _makeDataWindow (TuiWinInfoPtr
*, int, int);
70 static void _showSourceCommand (void);
71 static void _showDisassemCommand (void);
72 static void _showSourceDisassemCommand (void);
73 static void _showData (TuiLayoutType
);
74 static TuiLayoutType
_nextLayout (void);
75 static TuiLayoutType
_prevLayout (void);
76 static void _tuiLayout_command (char *, int);
77 static void _tuiToggleLayout_command (char *, int);
78 static void _tuiToggleSplitLayout_command (char *, int);
79 static CORE_ADDR
_extractDisplayStartAddr (void);
80 static void _tuiHandleXDBLayout (TuiLayoutDefPtr
);
83 /***************************************
85 ***************************************/
87 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
89 /***************************************
91 ***************************************/
92 static TuiLayoutType lastLayout
= UNDEFINED_LAYOUT
;
94 /***************************************
96 ***************************************/
100 ** Show the screen layout defined
103 showLayout (TuiLayoutType layout
)
105 TuiLayoutType curLayout
= currentLayout ();
107 if (layout
!= curLayout
)
110 ** Since the new layout may cause changes in window size, we
111 ** should free the content and reallocate on next display of
114 tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT
);
115 freeAllSourceWinsContent ();
116 clearSourceWindows ();
117 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
120 refreshAll (winList
);
124 /* First make the current layout be invisible */
126 m_beInvisible (locatorWinInfoPtr ());
130 /* Now show the new layout */
132 _showSourceCommand ();
133 addToSourceWindows (srcWin
);
135 case DISASSEM_COMMAND
:
136 _showDisassemCommand ();
137 addToSourceWindows (disassemWin
);
139 case SRC_DISASSEM_COMMAND
:
140 _showSourceDisassemCommand ();
141 addToSourceWindows (srcWin
);
142 addToSourceWindows (disassemWin
);
156 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
157 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
158 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
159 ** UNDEFINED_LAYOUT, then the data window is populated according
160 ** to regsDisplayType.
163 tuiSetLayout (TuiLayoutType layoutType
,
164 TuiRegisterDisplayType regsDisplayType
)
166 TuiStatus status
= TUI_SUCCESS
;
168 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
170 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
171 int regsPopulate
= FALSE
;
172 CORE_ADDR addr
= _extractDisplayStartAddr ();
173 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
174 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
177 if (layoutType
== UNDEFINED_LAYOUT
&&
178 regsDisplayType
!= TUI_UNDEFINED_REGS
)
180 if (curLayout
== SRC_DISASSEM_COMMAND
)
181 newLayout
= DISASSEM_DATA_COMMAND
;
182 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
183 newLayout
= SRC_DATA_COMMAND
;
184 else if (curLayout
== DISASSEM_COMMAND
||
185 curLayout
== DISASSEM_DATA_COMMAND
)
186 newLayout
= DISASSEM_DATA_COMMAND
;
189 newLayout
= layoutType
;
191 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
192 newLayout
== DISASSEM_DATA_COMMAND
||
193 regsDisplayType
!= TUI_UNDEFINED_REGS
);
194 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
196 if (newLayout
!= curLayout
)
198 if (winWithFocus
!= cmdWin
)
200 showLayout (newLayout
);
202 ** Now determine where focus should be
204 if (winWithFocus
!= cmdWin
)
209 tuiSetWinFocusTo (srcWin
);
210 layoutDef
->displayMode
= SRC_WIN
;
211 layoutDef
->split
= FALSE
;
213 case DISASSEM_COMMAND
:
214 /* the previous layout was not showing
215 ** code. this can happen if there is no
217 ** 1. if the source file is in another dir OR
218 ** 2. if target was compiled without -g
219 ** We still want to show the assembly though!
221 addr
= tuiGetBeginAsmAddress ();
222 tuiSetWinFocusTo (disassemWin
);
223 layoutDef
->displayMode
= DISASSEM_WIN
;
224 layoutDef
->split
= FALSE
;
226 case SRC_DISASSEM_COMMAND
:
227 /* the previous layout was not showing
228 ** code. this can happen if there is no
230 ** 1. if the source file is in another dir OR
231 ** 2. if target was compiled without -g
232 ** We still want to show the assembly though!
234 addr
= tuiGetBeginAsmAddress ();
235 if (winWithFocus
== srcWin
)
236 tuiSetWinFocusTo (srcWin
);
238 tuiSetWinFocusTo (disassemWin
);
239 layoutDef
->split
= TRUE
;
241 case SRC_DATA_COMMAND
:
242 if (winWithFocus
!= dataWin
)
243 tuiSetWinFocusTo (srcWin
);
245 tuiSetWinFocusTo (dataWin
);
246 layoutDef
->displayMode
= SRC_WIN
;
247 layoutDef
->split
= FALSE
;
249 case DISASSEM_DATA_COMMAND
:
250 /* the previous layout was not showing
251 ** code. this can happen if there is no
253 ** 1. if the source file is in another dir OR
254 ** 2. if target was compiled without -g
255 ** We still want to show the assembly though!
257 addr
= tuiGetBeginAsmAddress ();
258 if (winWithFocus
!= dataWin
)
259 tuiSetWinFocusTo (disassemWin
);
261 tuiSetWinFocusTo (dataWin
);
262 layoutDef
->displayMode
= DISASSEM_WIN
;
263 layoutDef
->split
= FALSE
;
269 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
270 tuiSetWinFocusTo (newWinWithFocus
);
272 ** Now update the window content
275 (newLayout
== SRC_DATA_COMMAND
||
276 newLayout
== DISASSEM_DATA_COMMAND
))
277 tuiDisplayAllData ();
279 tuiUpdateSourceWindowsWithAddr (addr
);
283 layoutDef
->regsDisplayType
=
284 (regsDisplayType
== TUI_UNDEFINED_REGS
?
285 TUI_GENERAL_REGS
: regsDisplayType
);
286 tuiShowRegisters (layoutDef
->regsDisplayType
);
291 status
= TUI_FAILURE
;
297 ** tuiAddWinToLayout().
298 ** Add the specified window to the layout in a logical way.
299 ** This means setting up the most logical layout given the
300 ** window to be added.
303 tuiAddWinToLayout (TuiWinType type
)
305 TuiLayoutType curLayout
= currentLayout ();
310 if (curLayout
!= SRC_COMMAND
&&
311 curLayout
!= SRC_DISASSEM_COMMAND
&&
312 curLayout
!= SRC_DATA_COMMAND
)
314 clearSourceWindowsDetail ();
315 if (curLayout
== DISASSEM_DATA_COMMAND
)
316 showLayout (SRC_DATA_COMMAND
);
318 showLayout (SRC_COMMAND
);
322 if (curLayout
!= DISASSEM_COMMAND
&&
323 curLayout
!= SRC_DISASSEM_COMMAND
&&
324 curLayout
!= DISASSEM_DATA_COMMAND
)
326 clearSourceWindowsDetail ();
327 if (curLayout
== SRC_DATA_COMMAND
)
328 showLayout (DISASSEM_DATA_COMMAND
);
330 showLayout (DISASSEM_COMMAND
);
334 if (curLayout
!= SRC_DATA_COMMAND
&&
335 curLayout
!= DISASSEM_DATA_COMMAND
)
337 if (curLayout
== DISASSEM_COMMAND
)
338 showLayout (DISASSEM_DATA_COMMAND
);
340 showLayout (SRC_DATA_COMMAND
);
348 } /* tuiAddWinToLayout */
352 ** tuiDefaultWinHeight().
353 ** Answer the height of a window. If it hasn't been created yet,
354 ** answer what the height of a window would be based upon its
355 ** type and the layout.
358 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
362 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
363 h
= winList
[type
]->generic
.height
;
369 case DISASSEM_COMMAND
:
370 if (m_winPtrIsNull (cmdWin
))
371 h
= termHeight () / 2;
373 h
= termHeight () - cmdWin
->generic
.height
;
375 case SRC_DISASSEM_COMMAND
:
376 case SRC_DATA_COMMAND
:
377 case DISASSEM_DATA_COMMAND
:
378 if (m_winPtrIsNull (cmdWin
))
379 h
= termHeight () / 3;
381 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
390 } /* tuiDefaultWinHeight */
394 ** tuiDefaultWinViewportHeight().
395 ** Answer the height of a window. If it hasn't been created yet,
396 ** answer what the height of a window would be based upon its
397 ** type and the layout.
400 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
404 h
= tuiDefaultWinHeight (type
, layout
);
406 if (winList
[type
] == cmdWin
)
412 } /* tuiDefaultWinViewportHeight */
416 ** _initialize_tuiLayout().
417 ** Function to initialize gdb commands, for tui window layout
421 _initialize_tuiLayout (void)
423 add_com ("layout", class_tui
, _tuiLayout_command
,
424 "Change the layout of windows.\n\
425 Usage: layout prev | next | <layout_name> \n\
427 src : Displays source and command windows.\n\
428 asm : Displays disassembly and command windows.\n\
429 split : Displays source, disassembly and command windows.\n\
430 regs : Displays register window. If existing layout\n\
431 is source/command or assembly/command, the \n\
432 register window is displayed. If the\n\
433 source/assembly/command (split) is displayed, \n\
434 the register window is displayed with \n\
435 the window that has current logical focus.\n");
438 add_com ("td", class_tui
, _tuiToggleLayout_command
,
439 "Toggle between Source/Command and Disassembly/Command layouts.\n");
440 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
441 "Toggle between Source/Command or Disassembly/Command and \n\
442 Source/Disassembly/Command layouts.\n");
447 /*************************
448 ** STATIC LOCAL FUNCTIONS
449 **************************/
454 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
455 ** $REGS, $GREGS, $FREGS, $SREGS.
458 tui_set_layout (const char *layoutName
)
460 TuiStatus status
= TUI_SUCCESS
;
462 if (layoutName
!= (char *) NULL
)
465 register char *bufPtr
;
466 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
467 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
468 TuiLayoutType curLayout
= currentLayout ();
470 bufPtr
= (char *) xstrdup (layoutName
);
471 for (i
= 0; (i
< strlen (layoutName
)); i
++)
472 bufPtr
[i
] = toupper (bufPtr
[i
]);
474 /* First check for ambiguous input */
475 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
477 warning ("Ambiguous command input.\n");
478 status
= TUI_FAILURE
;
482 if (subset_compare (bufPtr
, "SRC"))
483 newLayout
= SRC_COMMAND
;
484 else if (subset_compare (bufPtr
, "ASM"))
485 newLayout
= DISASSEM_COMMAND
;
486 else if (subset_compare (bufPtr
, "SPLIT"))
487 newLayout
= SRC_DISASSEM_COMMAND
;
488 else if (subset_compare (bufPtr
, "REGS") ||
489 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
490 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
491 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
492 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
494 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
495 newLayout
= SRC_DATA_COMMAND
;
497 newLayout
= DISASSEM_DATA_COMMAND
;
499 /* could ifdef out the following code. when compile with -z, there are null
500 pointer references that cause a core dump if 'layout regs' is the first
501 layout command issued by the user. HP has asked us to hook up this code
504 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
506 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
508 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
510 dpyType
= TUI_SFLOAT_REGS
;
513 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
515 else if (subset_compare (bufPtr
,
516 TUI_GENERAL_SPECIAL_REGS_NAME
))
517 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
518 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
519 dpyType
= TUI_GENERAL_REGS
;
520 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
521 dpyType
= TUI_SPECIAL_REGS
;
524 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
527 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
529 dpyType
= TUI_GENERAL_REGS
;
532 /* end of potential ifdef
535 /* if ifdefed out code above, then assume that the user wishes to display the
536 general purpose registers
539 /* dpyType = TUI_GENERAL_REGS;
542 else if (subset_compare (bufPtr
, "NEXT"))
543 newLayout
= _nextLayout ();
544 else if (subset_compare (bufPtr
, "PREV"))
545 newLayout
= _prevLayout ();
547 status
= TUI_FAILURE
;
550 tuiSetLayout (newLayout
, dpyType
);
554 status
= TUI_FAILURE
;
561 _extractDisplayStartAddr (void)
563 TuiLayoutType curLayout
= currentLayout ();
570 case SRC_DATA_COMMAND
:
571 find_line_pc (current_source_symtab
,
572 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
576 case DISASSEM_COMMAND
:
577 case SRC_DISASSEM_COMMAND
:
578 case DISASSEM_DATA_COMMAND
:
579 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
587 } /* _extractDisplayStartAddr */
591 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
593 if (layoutDef
->split
)
595 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
596 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
600 if (layoutDef
->displayMode
== SRC_WIN
)
601 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
603 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
608 } /* _tuiHandleXDBLayout */
612 _tuiToggleLayout_command (char *arg
, int fromTTY
)
614 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
616 /* Make sure the curses mode is enabled. */
618 if (layoutDef
->displayMode
== SRC_WIN
)
619 layoutDef
->displayMode
= DISASSEM_WIN
;
621 layoutDef
->displayMode
= SRC_WIN
;
623 if (!layoutDef
->split
)
624 _tuiHandleXDBLayout (layoutDef
);
630 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
632 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
634 /* Make sure the curses mode is enabled. */
636 layoutDef
->split
= (!layoutDef
->split
);
637 _tuiHandleXDBLayout (layoutDef
);
643 _tuiLayout_command (char *arg
, int fromTTY
)
645 /* Make sure the curses mode is enabled. */
648 /* Switch to the selected layout. */
649 if (tui_set_layout (arg
) != TUI_SUCCESS
)
650 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
656 ** Answer the previous layout to cycle to.
661 TuiLayoutType newLayout
;
663 newLayout
= currentLayout ();
664 if (newLayout
== UNDEFINED_LAYOUT
)
665 newLayout
= SRC_COMMAND
;
669 if (newLayout
== UNDEFINED_LAYOUT
)
670 newLayout
= SRC_COMMAND
;
679 ** Answer the next layout to cycle to.
684 TuiLayoutType newLayout
;
686 newLayout
= currentLayout ();
687 if (newLayout
== SRC_COMMAND
)
688 newLayout
= DISASSEM_DATA_COMMAND
;
692 if (newLayout
== UNDEFINED_LAYOUT
)
693 newLayout
= DISASSEM_DATA_COMMAND
;
702 ** _makeCommandWindow().
705 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
707 _initAndMakeWin ((Opaque
*) winInfoPtr
,
715 (*winInfoPtr
)->canHighlight
= FALSE
;
718 } /* _makeCommandWindow */
722 ** _makeSourceWindow().
725 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
727 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
730 } /* _makeSourceWindow */
734 ** _makeDisassemWindow().
737 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
739 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
742 } /* _makeDisassemWindow */
746 ** _makeDataWindow().
749 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
751 _initAndMakeWin ((Opaque
*) winInfoPtr
,
760 } /* _makeDataWindow */
765 ** _showSourceCommand().
766 ** Show the Source/Command layout
769 _showSourceCommand (void)
771 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
774 } /* _showSourceCommand */
778 ** _showDisassemCommand().
779 ** Show the Dissassem/Command layout
782 _showDisassemCommand (void)
784 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
787 } /* _showDisassemCommand */
791 ** _showSourceDisassemCommand().
792 ** Show the Source/Disassem/Command layout
795 _showSourceDisassemCommand (void)
797 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
799 if (currentLayout () != SRC_DISASSEM_COMMAND
)
801 int cmdHeight
, srcHeight
, asmHeight
;
803 if (m_winPtrNotNull (cmdWin
))
804 cmdHeight
= cmdWin
->generic
.height
;
806 cmdHeight
= termHeight () / 3;
808 srcHeight
= (termHeight () - cmdHeight
) / 2;
809 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
811 if (m_winPtrIsNull (srcWin
))
812 _makeSourceWindow (&srcWin
, srcHeight
, 0);
815 _initGenWinInfo (&srcWin
->generic
,
816 srcWin
->generic
.type
,
818 srcWin
->generic
.width
,
819 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
821 srcWin
->canHighlight
= TRUE
;
822 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
828 m_beVisible (srcWin
);
829 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
830 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
832 if (m_winPtrNotNull (srcWin
))
834 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
836 tuiShowSourceContent (srcWin
);
837 if (m_winPtrIsNull (disassemWin
))
839 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
840 _initAndMakeWin ((Opaque
*) & locator
,
845 (srcHeight
+ asmHeight
) - 1,
850 _initGenWinInfo (locator
,
855 (srcHeight
+ asmHeight
) - 1);
856 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
858 &disassemWin
->generic
,
859 disassemWin
->generic
.type
,
861 disassemWin
->generic
.width
,
862 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
864 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
870 disassemWin
->canHighlight
= TRUE
;
871 m_beVisible (disassemWin
);
872 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
874 if (m_winPtrNotNull (disassemWin
))
876 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
877 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
878 m_beVisible (locator
);
879 tuiShowLocatorContent ();
880 tuiShowSourceContent (disassemWin
);
882 if (m_winPtrIsNull (cmdWin
))
883 _makeCommandWindow (&cmdWin
,
885 termHeight () - cmdHeight
);
888 _initGenWinInfo (&cmdWin
->generic
,
889 cmdWin
->generic
.type
,
890 cmdWin
->generic
.height
,
891 cmdWin
->generic
.width
,
893 cmdWin
->generic
.origin
.y
);
894 cmdWin
->canHighlight
= FALSE
;
895 m_beVisible (cmdWin
);
897 if (m_winPtrNotNull (cmdWin
))
898 tuiRefreshWin (&cmdWin
->generic
);
901 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
905 } /* _showSourceDisassemCommand */
910 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
913 _showData (TuiLayoutType newLayout
)
915 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
916 int srcHeight
, dataHeight
;
918 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
921 dataHeight
= totalHeight
/ 2;
922 srcHeight
= totalHeight
- dataHeight
;
924 m_beInvisible (locator
);
925 _makeDataWindow (&dataWin
, dataHeight
, 0);
926 dataWin
->canHighlight
= TRUE
;
927 if (newLayout
== SRC_DATA_COMMAND
)
930 winType
= DISASSEM_WIN
;
931 if (m_winPtrIsNull (winList
[winType
]))
933 if (winType
== SRC_WIN
)
934 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
936 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
937 _initAndMakeWin ((Opaque
*) & locator
,
947 _initGenWinInfo (&winList
[winType
]->generic
,
948 winList
[winType
]->generic
.type
,
950 winList
[winType
]->generic
.width
,
951 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
953 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
959 m_beVisible (winList
[winType
]);
960 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
961 _initGenWinInfo (locator
,
968 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
969 m_beVisible (locator
);
970 tuiShowLocatorContent ();
971 addToSourceWindows (winList
[winType
]);
972 setCurrentLayoutTo (newLayout
);
978 ** _initGenWinInfo().
981 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
982 int height
, int width
, int originX
, int originY
)
986 winInfo
->type
= type
;
987 winInfo
->width
= width
;
991 winInfo
->viewportHeight
= h
- 1;
992 if (winInfo
->type
!= CMD_WIN
)
993 winInfo
->viewportHeight
--;
996 winInfo
->viewportHeight
= 1;
997 winInfo
->origin
.x
= originX
;
998 winInfo
->origin
.y
= originY
;
1001 } /* _initGenWinInfo */
1004 ** _initAndMakeWin().
1007 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
1008 int height
, int width
, int originX
, int originY
, int boxIt
)
1010 Opaque opaqueWinInfo
= *winInfoPtr
;
1011 TuiGenWinInfoPtr generic
;
1013 if (opaqueWinInfo
== (Opaque
) NULL
)
1015 if (m_winIsAuxillary (winType
))
1016 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
1018 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
1020 if (m_winIsAuxillary (winType
))
1021 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
1023 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
1025 if (opaqueWinInfo
!= (Opaque
) NULL
)
1027 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1028 if (!m_winIsAuxillary (winType
))
1030 if (generic
->type
== CMD_WIN
)
1031 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1033 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1035 makeWindow (generic
, boxIt
);
1036 if (winType
== LOCATOR_WIN
)
1037 tuiClearLocatorDisplay ();
1039 *winInfoPtr
= opaqueWinInfo
;
1042 } /* _initAndMakeWin */
1046 ** _makeSourceOrDisassemWindow().
1049 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1050 int height
, int originY
)
1052 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1055 ** Create the exeuction info window.
1057 if (type
== SRC_WIN
)
1058 executionInfo
= sourceExecInfoWinPtr ();
1060 executionInfo
= disassemExecInfoWinPtr ();
1061 _initAndMakeWin ((Opaque
*) & executionInfo
,
1069 ** Now create the source window.
1071 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1074 termWidth () - executionInfo
->width
,
1075 executionInfo
->width
,
1079 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1082 } /* _makeSourceOrDisassemWindow */
1086 ** _showSourceOrDisassemAndCommand().
1087 ** Show the Source/Command or the Disassem layout
1090 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1092 if (currentLayout () != layoutType
)
1094 TuiWinInfoPtr
*winInfoPtr
;
1096 int srcHeight
, cmdHeight
;
1097 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1099 if (m_winPtrNotNull (cmdWin
))
1100 cmdHeight
= cmdWin
->generic
.height
;
1102 cmdHeight
= termHeight () / 3;
1103 srcHeight
= termHeight () - cmdHeight
;
1106 if (layoutType
== SRC_COMMAND
)
1107 winInfoPtr
= &srcWin
;
1109 winInfoPtr
= &disassemWin
;
1111 if (m_winPtrIsNull (*winInfoPtr
))
1113 if (layoutType
== SRC_COMMAND
)
1114 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1116 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1117 _initAndMakeWin ((Opaque
*) & locator
,
1127 _initGenWinInfo (locator
,
1133 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1135 &(*winInfoPtr
)->generic
,
1136 (*winInfoPtr
)->generic
.type
,
1138 (*winInfoPtr
)->generic
.width
,
1139 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1141 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1147 (*winInfoPtr
)->canHighlight
= TRUE
;
1148 m_beVisible (*winInfoPtr
);
1149 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1151 if (m_winPtrNotNull (*winInfoPtr
))
1153 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1154 m_beVisible (locator
);
1155 tuiShowLocatorContent ();
1156 tuiShowSourceContent (*winInfoPtr
);
1158 if (m_winPtrIsNull (cmdWin
))
1160 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1161 tuiRefreshWin (&cmdWin
->generic
);
1165 _initGenWinInfo (&cmdWin
->generic
,
1166 cmdWin
->generic
.type
,
1167 cmdWin
->generic
.height
,
1168 cmdWin
->generic
.width
,
1169 cmdWin
->generic
.origin
.x
,
1170 cmdWin
->generic
.origin
.y
);
1171 cmdWin
->canHighlight
= FALSE
;
1172 m_beVisible (cmdWin
);
1175 setCurrentLayoutTo (layoutType
);
1179 } /* _showSourceOrDisassemAndCommand */