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 ********************************/
61 static void showLayout (TuiLayoutType
);
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 /* Show the screen layout defined. */
91 showLayout (TuiLayoutType layout
)
93 TuiLayoutType curLayout
= currentLayout ();
95 if (layout
!= curLayout
)
98 ** Since the new layout may cause changes in window size, we
99 ** should free the content and reallocate on next display of
102 freeAllSourceWinsContent ();
103 clearSourceWindows ();
104 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
107 refreshAll (winList
);
111 /* First make the current layout be invisible */
113 m_beInvisible (locatorWinInfoPtr ());
117 /* Now show the new layout */
119 _showSourceCommand ();
120 addToSourceWindows (srcWin
);
122 case DISASSEM_COMMAND
:
123 _showDisassemCommand ();
124 addToSourceWindows (disassemWin
);
126 case SRC_DISASSEM_COMMAND
:
127 _showSourceDisassemCommand ();
128 addToSourceWindows (srcWin
);
129 addToSourceWindows (disassemWin
);
141 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
142 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
143 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
144 ** UNDEFINED_LAYOUT, then the data window is populated according
145 ** to regsDisplayType.
148 tuiSetLayout (TuiLayoutType layoutType
,
149 TuiRegisterDisplayType regsDisplayType
)
151 TuiStatus status
= TUI_SUCCESS
;
153 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
155 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
156 int regsPopulate
= FALSE
;
157 CORE_ADDR addr
= _extractDisplayStartAddr ();
158 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
159 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
162 if (layoutType
== UNDEFINED_LAYOUT
&&
163 regsDisplayType
!= TUI_UNDEFINED_REGS
)
165 if (curLayout
== SRC_DISASSEM_COMMAND
)
166 newLayout
= DISASSEM_DATA_COMMAND
;
167 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
168 newLayout
= SRC_DATA_COMMAND
;
169 else if (curLayout
== DISASSEM_COMMAND
||
170 curLayout
== DISASSEM_DATA_COMMAND
)
171 newLayout
= DISASSEM_DATA_COMMAND
;
174 newLayout
= layoutType
;
176 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
177 newLayout
== DISASSEM_DATA_COMMAND
||
178 regsDisplayType
!= TUI_UNDEFINED_REGS
);
179 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
181 if (newLayout
!= curLayout
)
183 showLayout (newLayout
);
185 ** Now determine where focus should be
187 if (winWithFocus
!= cmdWin
)
192 tuiSetWinFocusTo (srcWin
);
193 layoutDef
->displayMode
= SRC_WIN
;
194 layoutDef
->split
= FALSE
;
196 case DISASSEM_COMMAND
:
197 /* the previous layout was not showing
198 ** code. this can happen if there is no
200 ** 1. if the source file is in another dir OR
201 ** 2. if target was compiled without -g
202 ** We still want to show the assembly though!
204 addr
= tuiGetBeginAsmAddress ();
205 tuiSetWinFocusTo (disassemWin
);
206 layoutDef
->displayMode
= DISASSEM_WIN
;
207 layoutDef
->split
= FALSE
;
209 case SRC_DISASSEM_COMMAND
:
210 /* the previous layout was not showing
211 ** code. this can happen if there is no
213 ** 1. if the source file is in another dir OR
214 ** 2. if target was compiled without -g
215 ** We still want to show the assembly though!
217 addr
= tuiGetBeginAsmAddress ();
218 if (winWithFocus
== srcWin
)
219 tuiSetWinFocusTo (srcWin
);
221 tuiSetWinFocusTo (disassemWin
);
222 layoutDef
->split
= TRUE
;
224 case SRC_DATA_COMMAND
:
225 if (winWithFocus
!= dataWin
)
226 tuiSetWinFocusTo (srcWin
);
228 tuiSetWinFocusTo (dataWin
);
229 layoutDef
->displayMode
= SRC_WIN
;
230 layoutDef
->split
= FALSE
;
232 case DISASSEM_DATA_COMMAND
:
233 /* the previous layout was not showing
234 ** code. this can happen if there is no
236 ** 1. if the source file is in another dir OR
237 ** 2. if target was compiled without -g
238 ** We still want to show the assembly though!
240 addr
= tuiGetBeginAsmAddress ();
241 if (winWithFocus
!= dataWin
)
242 tuiSetWinFocusTo (disassemWin
);
244 tuiSetWinFocusTo (dataWin
);
245 layoutDef
->displayMode
= DISASSEM_WIN
;
246 layoutDef
->split
= FALSE
;
252 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
253 tuiSetWinFocusTo (newWinWithFocus
);
255 ** Now update the window content
258 (newLayout
== SRC_DATA_COMMAND
||
259 newLayout
== DISASSEM_DATA_COMMAND
))
260 tuiDisplayAllData ();
262 tuiUpdateSourceWindowsWithAddr (addr
);
266 layoutDef
->regsDisplayType
=
267 (regsDisplayType
== TUI_UNDEFINED_REGS
?
268 TUI_GENERAL_REGS
: regsDisplayType
);
269 tuiShowRegisters (layoutDef
->regsDisplayType
);
274 status
= TUI_FAILURE
;
280 ** tuiAddWinToLayout().
281 ** Add the specified window to the layout in a logical way.
282 ** This means setting up the most logical layout given the
283 ** window to be added.
286 tuiAddWinToLayout (TuiWinType type
)
288 TuiLayoutType curLayout
= currentLayout ();
293 if (curLayout
!= SRC_COMMAND
&&
294 curLayout
!= SRC_DISASSEM_COMMAND
&&
295 curLayout
!= SRC_DATA_COMMAND
)
297 clearSourceWindowsDetail ();
298 if (curLayout
== DISASSEM_DATA_COMMAND
)
299 showLayout (SRC_DATA_COMMAND
);
301 showLayout (SRC_COMMAND
);
305 if (curLayout
!= DISASSEM_COMMAND
&&
306 curLayout
!= SRC_DISASSEM_COMMAND
&&
307 curLayout
!= DISASSEM_DATA_COMMAND
)
309 clearSourceWindowsDetail ();
310 if (curLayout
== SRC_DATA_COMMAND
)
311 showLayout (DISASSEM_DATA_COMMAND
);
313 showLayout (DISASSEM_COMMAND
);
317 if (curLayout
!= SRC_DATA_COMMAND
&&
318 curLayout
!= DISASSEM_DATA_COMMAND
)
320 if (curLayout
== DISASSEM_COMMAND
)
321 showLayout (DISASSEM_DATA_COMMAND
);
323 showLayout (SRC_DATA_COMMAND
);
331 } /* tuiAddWinToLayout */
335 ** tuiDefaultWinHeight().
336 ** Answer the height of a window. If it hasn't been created yet,
337 ** answer what the height of a window would be based upon its
338 ** type and the layout.
341 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
345 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
346 h
= winList
[type
]->generic
.height
;
352 case DISASSEM_COMMAND
:
353 if (m_winPtrIsNull (cmdWin
))
354 h
= termHeight () / 2;
356 h
= termHeight () - cmdWin
->generic
.height
;
358 case SRC_DISASSEM_COMMAND
:
359 case SRC_DATA_COMMAND
:
360 case DISASSEM_DATA_COMMAND
:
361 if (m_winPtrIsNull (cmdWin
))
362 h
= termHeight () / 3;
364 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
373 } /* tuiDefaultWinHeight */
377 ** tuiDefaultWinViewportHeight().
378 ** Answer the height of a window. If it hasn't been created yet,
379 ** answer what the height of a window would be based upon its
380 ** type and the layout.
383 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
387 h
= tuiDefaultWinHeight (type
, layout
);
389 if (winList
[type
] == cmdWin
)
395 } /* tuiDefaultWinViewportHeight */
399 ** _initialize_tuiLayout().
400 ** Function to initialize gdb commands, for tui window layout
404 _initialize_tuiLayout (void)
406 add_com ("layout", class_tui
, _tuiLayout_command
,
407 "Change the layout of windows.\n\
408 Usage: layout prev | next | <layout_name> \n\
410 src : Displays source and command windows.\n\
411 asm : Displays disassembly and command windows.\n\
412 split : Displays source, disassembly and command windows.\n\
413 regs : Displays register window. If existing layout\n\
414 is source/command or assembly/command, the \n\
415 register window is displayed. If the\n\
416 source/assembly/command (split) is displayed, \n\
417 the register window is displayed with \n\
418 the window that has current logical focus.\n");
421 add_com ("td", class_tui
, _tuiToggleLayout_command
,
422 "Toggle between Source/Command and Disassembly/Command layouts.\n");
423 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
424 "Toggle between Source/Command or Disassembly/Command and \n\
425 Source/Disassembly/Command layouts.\n");
430 /*************************
431 ** STATIC LOCAL FUNCTIONS
432 **************************/
437 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
438 ** $REGS, $GREGS, $FREGS, $SREGS.
441 tui_set_layout (const char *layoutName
)
443 TuiStatus status
= TUI_SUCCESS
;
445 if (layoutName
!= (char *) NULL
)
448 register char *bufPtr
;
449 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
450 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
451 TuiLayoutType curLayout
= currentLayout ();
453 bufPtr
= (char *) xstrdup (layoutName
);
454 for (i
= 0; (i
< strlen (layoutName
)); i
++)
455 bufPtr
[i
] = toupper (bufPtr
[i
]);
457 /* First check for ambiguous input */
458 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
460 warning ("Ambiguous command input.\n");
461 status
= TUI_FAILURE
;
465 if (subset_compare (bufPtr
, "SRC"))
466 newLayout
= SRC_COMMAND
;
467 else if (subset_compare (bufPtr
, "ASM"))
468 newLayout
= DISASSEM_COMMAND
;
469 else if (subset_compare (bufPtr
, "SPLIT"))
470 newLayout
= SRC_DISASSEM_COMMAND
;
471 else if (subset_compare (bufPtr
, "REGS") ||
472 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
473 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
474 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
475 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
477 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
478 newLayout
= SRC_DATA_COMMAND
;
480 newLayout
= DISASSEM_DATA_COMMAND
;
482 /* could ifdef out the following code. when compile with -z, there are null
483 pointer references that cause a core dump if 'layout regs' is the first
484 layout command issued by the user. HP has asked us to hook up this code
487 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
489 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
491 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
493 dpyType
= TUI_SFLOAT_REGS
;
496 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
498 else if (subset_compare (bufPtr
,
499 TUI_GENERAL_SPECIAL_REGS_NAME
))
500 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
501 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
502 dpyType
= TUI_GENERAL_REGS
;
503 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
504 dpyType
= TUI_SPECIAL_REGS
;
507 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
510 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
512 dpyType
= TUI_GENERAL_REGS
;
515 /* end of potential ifdef
518 /* if ifdefed out code above, then assume that the user wishes to display the
519 general purpose registers
522 /* dpyType = TUI_GENERAL_REGS;
525 else if (subset_compare (bufPtr
, "NEXT"))
526 newLayout
= _nextLayout ();
527 else if (subset_compare (bufPtr
, "PREV"))
528 newLayout
= _prevLayout ();
530 status
= TUI_FAILURE
;
533 tuiSetLayout (newLayout
, dpyType
);
537 status
= TUI_FAILURE
;
544 _extractDisplayStartAddr (void)
546 TuiLayoutType curLayout
= currentLayout ();
553 case SRC_DATA_COMMAND
:
554 find_line_pc (current_source_symtab
,
555 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
559 case DISASSEM_COMMAND
:
560 case SRC_DISASSEM_COMMAND
:
561 case DISASSEM_DATA_COMMAND
:
562 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
570 } /* _extractDisplayStartAddr */
574 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
576 if (layoutDef
->split
)
578 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
579 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
583 if (layoutDef
->displayMode
== SRC_WIN
)
584 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
586 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
591 } /* _tuiHandleXDBLayout */
595 _tuiToggleLayout_command (char *arg
, int fromTTY
)
597 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
599 /* Make sure the curses mode is enabled. */
601 if (layoutDef
->displayMode
== SRC_WIN
)
602 layoutDef
->displayMode
= DISASSEM_WIN
;
604 layoutDef
->displayMode
= SRC_WIN
;
606 if (!layoutDef
->split
)
607 _tuiHandleXDBLayout (layoutDef
);
613 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
615 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
617 /* Make sure the curses mode is enabled. */
619 layoutDef
->split
= (!layoutDef
->split
);
620 _tuiHandleXDBLayout (layoutDef
);
626 _tuiLayout_command (char *arg
, int fromTTY
)
628 /* Make sure the curses mode is enabled. */
631 /* Switch to the selected layout. */
632 if (tui_set_layout (arg
) != TUI_SUCCESS
)
633 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
639 ** Answer the previous layout to cycle to.
644 TuiLayoutType newLayout
;
646 newLayout
= currentLayout ();
647 if (newLayout
== UNDEFINED_LAYOUT
)
648 newLayout
= SRC_COMMAND
;
652 if (newLayout
== UNDEFINED_LAYOUT
)
653 newLayout
= SRC_COMMAND
;
662 ** Answer the next layout to cycle to.
667 TuiLayoutType newLayout
;
669 newLayout
= currentLayout ();
670 if (newLayout
== SRC_COMMAND
)
671 newLayout
= DISASSEM_DATA_COMMAND
;
675 if (newLayout
== UNDEFINED_LAYOUT
)
676 newLayout
= DISASSEM_DATA_COMMAND
;
685 ** _makeCommandWindow().
688 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
690 _initAndMakeWin ((Opaque
*) winInfoPtr
,
698 (*winInfoPtr
)->canHighlight
= FALSE
;
701 } /* _makeCommandWindow */
705 ** _makeSourceWindow().
708 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
710 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
713 } /* _makeSourceWindow */
717 ** _makeDisassemWindow().
720 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
722 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
725 } /* _makeDisassemWindow */
729 ** _makeDataWindow().
732 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
734 _initAndMakeWin ((Opaque
*) winInfoPtr
,
743 } /* _makeDataWindow */
748 ** _showSourceCommand().
749 ** Show the Source/Command layout
752 _showSourceCommand (void)
754 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
757 } /* _showSourceCommand */
761 ** _showDisassemCommand().
762 ** Show the Dissassem/Command layout
765 _showDisassemCommand (void)
767 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
770 } /* _showDisassemCommand */
774 ** _showSourceDisassemCommand().
775 ** Show the Source/Disassem/Command layout
778 _showSourceDisassemCommand (void)
780 if (currentLayout () != SRC_DISASSEM_COMMAND
)
782 int cmdHeight
, srcHeight
, asmHeight
;
784 if (m_winPtrNotNull (cmdWin
))
785 cmdHeight
= cmdWin
->generic
.height
;
787 cmdHeight
= termHeight () / 3;
789 srcHeight
= (termHeight () - cmdHeight
) / 2;
790 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
792 if (m_winPtrIsNull (srcWin
))
793 _makeSourceWindow (&srcWin
, srcHeight
, 0);
796 _initGenWinInfo (&srcWin
->generic
,
797 srcWin
->generic
.type
,
799 srcWin
->generic
.width
,
800 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
802 srcWin
->canHighlight
= TRUE
;
803 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
809 m_beVisible (srcWin
);
810 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
811 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
813 if (m_winPtrNotNull (srcWin
))
815 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
817 tuiShowSourceContent (srcWin
);
818 if (m_winPtrIsNull (disassemWin
))
820 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
821 _initAndMakeWin ((Opaque
*) & locator
,
826 (srcHeight
+ asmHeight
) - 1,
831 _initGenWinInfo (locator
,
836 (srcHeight
+ asmHeight
) - 1);
837 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
839 &disassemWin
->generic
,
840 disassemWin
->generic
.type
,
842 disassemWin
->generic
.width
,
843 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
845 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
851 disassemWin
->canHighlight
= TRUE
;
852 m_beVisible (disassemWin
);
853 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
855 if (m_winPtrNotNull (disassemWin
))
857 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
858 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
859 m_beVisible (locator
);
860 tuiShowLocatorContent ();
861 tuiShowSourceContent (disassemWin
);
863 if (m_winPtrIsNull (cmdWin
))
864 _makeCommandWindow (&cmdWin
,
866 termHeight () - cmdHeight
);
869 _initGenWinInfo (&cmdWin
->generic
,
870 cmdWin
->generic
.type
,
871 cmdWin
->generic
.height
,
872 cmdWin
->generic
.width
,
874 cmdWin
->generic
.origin
.y
);
875 cmdWin
->canHighlight
= FALSE
;
876 m_beVisible (cmdWin
);
878 if (m_winPtrNotNull (cmdWin
))
879 tuiRefreshWin (&cmdWin
->generic
);
882 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
886 } /* _showSourceDisassemCommand */
891 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
894 _showData (TuiLayoutType newLayout
)
896 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
897 int srcHeight
, dataHeight
;
899 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
902 dataHeight
= totalHeight
/ 2;
903 srcHeight
= totalHeight
- dataHeight
;
905 m_beInvisible (locator
);
906 _makeDataWindow (&dataWin
, dataHeight
, 0);
907 dataWin
->canHighlight
= TRUE
;
908 if (newLayout
== SRC_DATA_COMMAND
)
911 winType
= DISASSEM_WIN
;
912 if (m_winPtrIsNull (winList
[winType
]))
914 if (winType
== SRC_WIN
)
915 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
917 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
918 _initAndMakeWin ((Opaque
*) & locator
,
928 _initGenWinInfo (&winList
[winType
]->generic
,
929 winList
[winType
]->generic
.type
,
931 winList
[winType
]->generic
.width
,
932 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
934 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
940 m_beVisible (winList
[winType
]);
941 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
942 _initGenWinInfo (locator
,
949 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
950 m_beVisible (locator
);
951 tuiShowLocatorContent ();
952 addToSourceWindows (winList
[winType
]);
953 setCurrentLayoutTo (newLayout
);
959 ** _initGenWinInfo().
962 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
963 int height
, int width
, int originX
, int originY
)
967 winInfo
->type
= type
;
968 winInfo
->width
= width
;
972 winInfo
->viewportHeight
= h
- 1;
973 if (winInfo
->type
!= CMD_WIN
)
974 winInfo
->viewportHeight
--;
977 winInfo
->viewportHeight
= 1;
978 winInfo
->origin
.x
= originX
;
979 winInfo
->origin
.y
= originY
;
982 } /* _initGenWinInfo */
985 ** _initAndMakeWin().
988 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
989 int height
, int width
, int originX
, int originY
, int boxIt
)
991 Opaque opaqueWinInfo
= *winInfoPtr
;
992 TuiGenWinInfoPtr generic
;
994 if (opaqueWinInfo
== (Opaque
) NULL
)
996 if (m_winIsAuxillary (winType
))
997 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
999 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
1001 if (m_winIsAuxillary (winType
))
1002 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
1004 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
1006 if (opaqueWinInfo
!= (Opaque
) NULL
)
1008 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1009 if (!m_winIsAuxillary (winType
))
1011 if (generic
->type
== CMD_WIN
)
1012 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1014 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1016 makeWindow (generic
, boxIt
);
1018 *winInfoPtr
= opaqueWinInfo
;
1023 ** _makeSourceOrDisassemWindow().
1026 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1027 int height
, int originY
)
1029 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1032 ** Create the exeuction info window.
1034 if (type
== SRC_WIN
)
1035 executionInfo
= sourceExecInfoWinPtr ();
1037 executionInfo
= disassemExecInfoWinPtr ();
1038 _initAndMakeWin ((Opaque
*) & executionInfo
,
1046 ** Now create the source window.
1048 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1051 termWidth () - executionInfo
->width
,
1052 executionInfo
->width
,
1056 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1059 } /* _makeSourceOrDisassemWindow */
1063 ** _showSourceOrDisassemAndCommand().
1064 ** Show the Source/Command or the Disassem layout
1067 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1069 if (currentLayout () != layoutType
)
1071 TuiWinInfoPtr
*winInfoPtr
;
1072 int srcHeight
, cmdHeight
;
1073 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1075 if (m_winPtrNotNull (cmdWin
))
1076 cmdHeight
= cmdWin
->generic
.height
;
1078 cmdHeight
= termHeight () / 3;
1079 srcHeight
= termHeight () - cmdHeight
;
1082 if (layoutType
== SRC_COMMAND
)
1083 winInfoPtr
= &srcWin
;
1085 winInfoPtr
= &disassemWin
;
1087 if (m_winPtrIsNull (*winInfoPtr
))
1089 if (layoutType
== SRC_COMMAND
)
1090 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1092 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1093 _initAndMakeWin ((Opaque
*) & locator
,
1103 _initGenWinInfo (locator
,
1109 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1111 &(*winInfoPtr
)->generic
,
1112 (*winInfoPtr
)->generic
.type
,
1114 (*winInfoPtr
)->generic
.width
,
1115 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1117 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1123 (*winInfoPtr
)->canHighlight
= TRUE
;
1124 m_beVisible (*winInfoPtr
);
1125 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1127 if (m_winPtrNotNull (*winInfoPtr
))
1129 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1130 m_beVisible (locator
);
1131 tuiShowLocatorContent ();
1132 tuiShowSourceContent (*winInfoPtr
);
1134 if (m_winPtrIsNull (cmdWin
))
1136 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1137 tuiRefreshWin (&cmdWin
->generic
);
1141 _initGenWinInfo (&cmdWin
->generic
,
1142 cmdWin
->generic
.type
,
1143 cmdWin
->generic
.height
,
1144 cmdWin
->generic
.width
,
1145 cmdWin
->generic
.origin
.x
,
1146 cmdWin
->generic
.origin
.y
);
1147 cmdWin
->canHighlight
= FALSE
;
1148 m_beVisible (cmdWin
);
1151 setCurrentLayoutTo (layoutType
);
1155 } /* _showSourceOrDisassemAndCommand */