1 /* TUI layout window management.
2 Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
3 Contributed by Hewlett-Packard Company.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
30 #include "tuiDataWin.h"
31 #include "tuiGeneralWin.h"
35 #include "tuiSourceWin.h"
36 #include "tuiDisassem.h"
38 /*******************************
40 ********************************/
42 static void _initGenWinInfo (TuiGenWinInfoPtr
, TuiWinType
, int, int, int, int);
43 static void _initAndMakeWin (Opaque
*, TuiWinType
, int, int, int, int, int);
44 static void _showSourceOrDisassemAndCommand (TuiLayoutType
);
45 static void _makeSourceOrDisassemWindow (TuiWinInfoPtr
*, TuiWinType
, int, int);
46 static void _makeCommandWindow (TuiWinInfoPtr
*, int, int);
47 static void _makeSourceWindow (TuiWinInfoPtr
*, int, int);
48 static void _makeDisassemWindow (TuiWinInfoPtr
*, int, int);
49 static void _makeDataWindow (TuiWinInfoPtr
*, int, int);
50 static void _showSourceCommand (void);
51 static void _showDisassemCommand (void);
52 static void _showSourceDisassemCommand (void);
53 static void _showData (TuiLayoutType
);
54 static TuiLayoutType
_nextLayout (void);
55 static TuiLayoutType
_prevLayout (void);
56 static void _tuiLayout_command (char *, int);
57 static void _tuiToggleLayout_command (char *, int);
58 static void _tui_vToggleLayout_command (va_list);
59 static void _tuiToggleSplitLayout_command (char *, int);
60 static void _tui_vToggleSplitLayout_command (va_list);
61 static CORE_ADDR
_extractDisplayStartAddr (void);
62 static void _tuiHandleXDBLayout (TuiLayoutDefPtr
);
65 /***************************************
67 ***************************************/
69 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
71 /***************************************
73 ***************************************/
74 static TuiLayoutType lastLayout
= UNDEFINED_LAYOUT
;
76 /***************************************
78 ***************************************/
82 ** Show the screen layout defined
85 showLayout (TuiLayoutType layout
)
87 TuiLayoutType curLayout
= currentLayout ();
89 if (layout
!= curLayout
)
92 ** Since the new layout may cause changes in window size, we
93 ** should free the content and reallocate on next display of
96 tuiClearAllSourceWinsContent (NO_EMPTY_SOURCE_PROMPT
);
97 freeAllSourceWinsContent ();
98 clearSourceWindows ();
99 if (layout
== SRC_DATA_COMMAND
|| layout
== DISASSEM_DATA_COMMAND
)
102 refreshAll (winList
);
106 /* First make the current layout be invisible */
108 m_beInvisible (locatorWinInfoPtr ());
112 /* Now show the new layout */
114 _showSourceCommand ();
115 addToSourceWindows (srcWin
);
117 case DISASSEM_COMMAND
:
118 _showDisassemCommand ();
119 addToSourceWindows (disassemWin
);
121 case SRC_DISASSEM_COMMAND
:
122 _showSourceDisassemCommand ();
123 addToSourceWindows (srcWin
);
124 addToSourceWindows (disassemWin
);
138 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
139 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
140 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
141 ** UNDEFINED_LAYOUT, then the data window is populated according
142 ** to regsDisplayType.
145 tuiSetLayout (TuiLayoutType layoutType
,
146 TuiRegisterDisplayType regsDisplayType
)
148 TuiStatus status
= TUI_SUCCESS
;
150 if (layoutType
!= UNDEFINED_LAYOUT
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
152 TuiLayoutType curLayout
= currentLayout (), newLayout
= UNDEFINED_LAYOUT
;
153 int regsPopulate
= FALSE
;
154 CORE_ADDR addr
= _extractDisplayStartAddr ();
155 TuiWinInfoPtr newWinWithFocus
= (TuiWinInfoPtr
) NULL
, winWithFocus
= tuiWinWithFocus ();
156 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
159 if (layoutType
== UNDEFINED_LAYOUT
&&
160 regsDisplayType
!= TUI_UNDEFINED_REGS
)
162 if (curLayout
== SRC_DISASSEM_COMMAND
)
163 newLayout
= DISASSEM_DATA_COMMAND
;
164 else if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
165 newLayout
= SRC_DATA_COMMAND
;
166 else if (curLayout
== DISASSEM_COMMAND
||
167 curLayout
== DISASSEM_DATA_COMMAND
)
168 newLayout
= DISASSEM_DATA_COMMAND
;
171 newLayout
= layoutType
;
173 regsPopulate
= (newLayout
== SRC_DATA_COMMAND
||
174 newLayout
== DISASSEM_DATA_COMMAND
||
175 regsDisplayType
!= TUI_UNDEFINED_REGS
);
176 if (newLayout
!= curLayout
|| regsDisplayType
!= TUI_UNDEFINED_REGS
)
178 if (newLayout
!= curLayout
)
180 if (winWithFocus
!= cmdWin
)
182 showLayout (newLayout
);
184 ** Now determine where focus should be
186 if (winWithFocus
!= cmdWin
)
191 tuiSetWinFocusTo (srcWin
);
192 layoutDef
->displayMode
= SRC_WIN
;
193 layoutDef
->split
= FALSE
;
195 case DISASSEM_COMMAND
:
196 /* the previous layout was not showing
197 ** code. this can happen if there is no
199 ** 1. if the source file is in another dir OR
200 ** 2. if target was compiled without -g
201 ** We still want to show the assembly though!
203 addr
= tuiGetBeginAsmAddress ();
204 tuiSetWinFocusTo (disassemWin
);
205 layoutDef
->displayMode
= DISASSEM_WIN
;
206 layoutDef
->split
= FALSE
;
208 case SRC_DISASSEM_COMMAND
:
209 /* the previous layout was not showing
210 ** code. this can happen if there is no
212 ** 1. if the source file is in another dir OR
213 ** 2. if target was compiled without -g
214 ** We still want to show the assembly though!
216 addr
= tuiGetBeginAsmAddress ();
217 if (winWithFocus
== srcWin
)
218 tuiSetWinFocusTo (srcWin
);
220 tuiSetWinFocusTo (disassemWin
);
221 layoutDef
->split
= TRUE
;
223 case SRC_DATA_COMMAND
:
224 if (winWithFocus
!= dataWin
)
225 tuiSetWinFocusTo (srcWin
);
227 tuiSetWinFocusTo (dataWin
);
228 layoutDef
->displayMode
= SRC_WIN
;
229 layoutDef
->split
= FALSE
;
231 case DISASSEM_DATA_COMMAND
:
232 /* the previous layout was not showing
233 ** code. this can happen if there is no
235 ** 1. if the source file is in another dir OR
236 ** 2. if target was compiled without -g
237 ** We still want to show the assembly though!
239 addr
= tuiGetBeginAsmAddress ();
240 if (winWithFocus
!= dataWin
)
241 tuiSetWinFocusTo (disassemWin
);
243 tuiSetWinFocusTo (dataWin
);
244 layoutDef
->displayMode
= DISASSEM_WIN
;
245 layoutDef
->split
= FALSE
;
251 if (newWinWithFocus
!= (TuiWinInfoPtr
) NULL
)
252 tuiSetWinFocusTo (newWinWithFocus
);
254 ** Now update the window content
257 (newLayout
== SRC_DATA_COMMAND
||
258 newLayout
== DISASSEM_DATA_COMMAND
))
259 tuiDisplayAllData ();
261 tuiUpdateSourceWindowsWithAddr (addr
);
265 layoutDef
->regsDisplayType
=
266 (regsDisplayType
== TUI_UNDEFINED_REGS
?
267 TUI_GENERAL_REGS
: regsDisplayType
);
268 tuiShowRegisters (layoutDef
->regsDisplayType
);
273 status
= TUI_FAILURE
;
280 ** tui_vSetLayoutTo()
281 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
282 ** REGS, $REGS, $GREGS, $FREGS, $SREGS with arguments in a va_list
285 tui_vSetLayoutTo (va_list args
)
289 layoutName
= va_arg (args
, char *);
291 return (_tuiSetLayoutTo (layoutName
));
292 } /* tui_vSetLayoutTo */
296 ** tuiAddWinToLayout().
297 ** Add the specified window to the layout in a logical way.
298 ** This means setting up the most logical layout given the
299 ** window to be added.
302 tuiAddWinToLayout (TuiWinType type
)
304 TuiLayoutType curLayout
= currentLayout ();
309 if (curLayout
!= SRC_COMMAND
&&
310 curLayout
!= SRC_DISASSEM_COMMAND
&&
311 curLayout
!= SRC_DATA_COMMAND
)
313 clearSourceWindowsDetail ();
314 if (curLayout
== DISASSEM_DATA_COMMAND
)
315 showLayout (SRC_DATA_COMMAND
);
317 showLayout (SRC_COMMAND
);
321 if (curLayout
!= DISASSEM_COMMAND
&&
322 curLayout
!= SRC_DISASSEM_COMMAND
&&
323 curLayout
!= DISASSEM_DATA_COMMAND
)
325 clearSourceWindowsDetail ();
326 if (curLayout
== SRC_DATA_COMMAND
)
327 showLayout (DISASSEM_DATA_COMMAND
);
329 showLayout (DISASSEM_COMMAND
);
333 if (curLayout
!= SRC_DATA_COMMAND
&&
334 curLayout
!= DISASSEM_DATA_COMMAND
)
336 if (curLayout
== DISASSEM_COMMAND
)
337 showLayout (DISASSEM_DATA_COMMAND
);
339 showLayout (SRC_DATA_COMMAND
);
347 } /* tuiAddWinToLayout */
351 ** tui_vAddWinToLayout().
352 ** Add the specified window to the layout in a logical way,
353 ** with arguments in a va_list.
356 tui_vAddWinToLayout (va_list args
)
358 TuiWinType type
= va_arg (args
, TuiWinType
);
360 tuiAddWinToLayout (type
);
363 } /* tui_vAddWinToLayout */
367 ** tuiDefaultWinHeight().
368 ** Answer the height of a window. If it hasn't been created yet,
369 ** answer what the height of a window would be based upon its
370 ** type and the layout.
373 tuiDefaultWinHeight (TuiWinType type
, TuiLayoutType layout
)
377 if (winList
[type
] != (TuiWinInfoPtr
) NULL
)
378 h
= winList
[type
]->generic
.height
;
384 case DISASSEM_COMMAND
:
385 if (m_winPtrIsNull (cmdWin
))
386 h
= termHeight () / 2;
388 h
= termHeight () - cmdWin
->generic
.height
;
390 case SRC_DISASSEM_COMMAND
:
391 case SRC_DATA_COMMAND
:
392 case DISASSEM_DATA_COMMAND
:
393 if (m_winPtrIsNull (cmdWin
))
394 h
= termHeight () / 3;
396 h
= (termHeight () - cmdWin
->generic
.height
) / 2;
405 } /* tuiDefaultWinHeight */
409 ** tuiDefaultWinViewportHeight().
410 ** Answer the height of a window. If it hasn't been created yet,
411 ** answer what the height of a window would be based upon its
412 ** type and the layout.
415 tuiDefaultWinViewportHeight (TuiWinType type
, TuiLayoutType layout
)
419 h
= tuiDefaultWinHeight (type
, layout
);
421 if (winList
[type
] == cmdWin
)
427 } /* tuiDefaultWinViewportHeight */
431 ** _initialize_tuiLayout().
432 ** Function to initialize gdb commands, for tui window layout
436 _initialize_tuiLayout (void)
440 add_com ("layout", class_tui
, _tuiLayout_command
,
441 "Change the layout of windows.\n\
442 Usage: layout prev | next | <layout_name> \n\
444 src : Displays source and command windows.\n\
445 asm : Displays disassembly and command windows.\n\
446 split : Displays source, disassembly and command windows.\n\
447 regs : Displays register window. If existing layout\n\
448 is source/command or assembly/command, the \n\
449 register window is displayed. If the\n\
450 source/assembly/command (split) is displayed, \n\
451 the register window is displayed with \n\
452 the window that has current logical focus.\n");
455 add_com ("td", class_tui
, _tuiToggleLayout_command
,
456 "Toggle between Source/Command and Disassembly/Command layouts.\n");
457 add_com ("ts", class_tui
, _tuiToggleSplitLayout_command
,
458 "Toggle between Source/Command or Disassembly/Command and \n\
459 Source/Disassembly/Command layouts.\n");
464 } /* _intialize_tuiLayout */
467 /*************************
468 ** STATIC LOCAL FUNCTIONS
469 **************************/
474 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
475 ** $REGS, $GREGS, $FREGS, $SREGS.
478 tui_set_layout (const char *layoutName
)
480 TuiStatus status
= TUI_SUCCESS
;
482 if (layoutName
!= (char *) NULL
)
485 register char *bufPtr
;
486 TuiLayoutType newLayout
= UNDEFINED_LAYOUT
;
487 TuiRegisterDisplayType dpyType
= TUI_UNDEFINED_REGS
;
488 TuiLayoutType curLayout
= currentLayout ();
490 bufPtr
= (char *) tuiStrDup (layoutName
);
491 for (i
= 0; (i
< strlen (layoutName
)); i
++)
492 bufPtr
[i
] = toupper (bufPtr
[i
]);
494 /* First check for ambiguous input */
495 if (strlen (bufPtr
) <= 1 && (*bufPtr
== 'S' || *bufPtr
== '$'))
497 warning ("Ambiguous command input.\n");
498 status
= TUI_FAILURE
;
502 if (subset_compare (bufPtr
, "SRC"))
503 newLayout
= SRC_COMMAND
;
504 else if (subset_compare (bufPtr
, "ASM"))
505 newLayout
= DISASSEM_COMMAND
;
506 else if (subset_compare (bufPtr
, "SPLIT"))
507 newLayout
= SRC_DISASSEM_COMMAND
;
508 else if (subset_compare (bufPtr
, "REGS") ||
509 subset_compare (bufPtr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
510 subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
) ||
511 subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
) ||
512 subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
514 if (curLayout
== SRC_COMMAND
|| curLayout
== SRC_DATA_COMMAND
)
515 newLayout
= SRC_DATA_COMMAND
;
517 newLayout
= DISASSEM_DATA_COMMAND
;
519 /* could ifdef out the following code. when compile with -z, there are null
520 pointer references that cause a core dump if 'layout regs' is the first
521 layout command issued by the user. HP has asked us to hook up this code
524 if (subset_compare (bufPtr
, TUI_FLOAT_REGS_NAME
))
526 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
528 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
530 dpyType
= TUI_SFLOAT_REGS
;
533 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
535 else if (subset_compare (bufPtr
,
536 TUI_GENERAL_SPECIAL_REGS_NAME
))
537 dpyType
= TUI_GENERAL_AND_SPECIAL_REGS
;
538 else if (subset_compare (bufPtr
, TUI_GENERAL_REGS_NAME
))
539 dpyType
= TUI_GENERAL_REGS
;
540 else if (subset_compare (bufPtr
, TUI_SPECIAL_REGS_NAME
))
541 dpyType
= TUI_SPECIAL_REGS
;
544 if (dataWin
->detail
.dataDisplayInfo
.regsDisplayType
!=
547 dataWin
->detail
.dataDisplayInfo
.regsDisplayType
;
549 dpyType
= TUI_GENERAL_REGS
;
552 /* end of potential ifdef
555 /* if ifdefed out code above, then assume that the user wishes to display the
556 general purpose registers
559 /* dpyType = TUI_GENERAL_REGS;
562 else if (subset_compare (bufPtr
, "NEXT"))
563 newLayout
= _nextLayout ();
564 else if (subset_compare (bufPtr
, "PREV"))
565 newLayout
= _prevLayout ();
567 status
= TUI_FAILURE
;
570 tuiSetLayout (newLayout
, dpyType
);
574 status
= TUI_FAILURE
;
581 _extractDisplayStartAddr (void)
583 TuiLayoutType curLayout
= currentLayout ();
590 case SRC_DATA_COMMAND
:
591 find_line_pc (current_source_symtab
,
592 srcWin
->detail
.sourceInfo
.startLineOrAddr
.lineNo
,
596 case DISASSEM_COMMAND
:
597 case SRC_DISASSEM_COMMAND
:
598 case DISASSEM_DATA_COMMAND
:
599 addr
= disassemWin
->detail
.sourceInfo
.startLineOrAddr
.addr
;
607 } /* _extractDisplayStartAddr */
611 _tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef
)
613 if (layoutDef
->split
)
615 tuiSetLayout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
616 tuiSetWinFocusTo (winList
[layoutDef
->displayMode
]);
620 if (layoutDef
->displayMode
== SRC_WIN
)
621 tuiSetLayout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
623 tuiSetLayout (DISASSEM_DATA_COMMAND
, layoutDef
->regsDisplayType
);
628 } /* _tuiHandleXDBLayout */
632 _tuiToggleLayout_command (char *arg
, int fromTTY
)
634 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
636 if (layoutDef
->displayMode
== SRC_WIN
)
637 layoutDef
->displayMode
= DISASSEM_WIN
;
639 layoutDef
->displayMode
= SRC_WIN
;
641 if (!layoutDef
->split
)
642 _tuiHandleXDBLayout (layoutDef
);
648 _tuiToggleSplitLayout_command (char *arg
, int fromTTY
)
650 TuiLayoutDefPtr layoutDef
= tuiLayoutDef ();
652 layoutDef
->split
= (!layoutDef
->split
);
653 _tuiHandleXDBLayout (layoutDef
);
659 _tuiLayout_command (char *arg
, int fromTTY
)
661 if (tui_set_layout (arg
) != TUI_SUCCESS
)
662 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE
);
668 ** Answer the previous layout to cycle to.
673 TuiLayoutType newLayout
;
675 newLayout
= currentLayout ();
676 if (newLayout
== UNDEFINED_LAYOUT
)
677 newLayout
= SRC_COMMAND
;
681 if (newLayout
== UNDEFINED_LAYOUT
)
682 newLayout
= SRC_COMMAND
;
691 ** Answer the next layout to cycle to.
696 TuiLayoutType newLayout
;
698 newLayout
= currentLayout ();
699 if (newLayout
== SRC_COMMAND
)
700 newLayout
= DISASSEM_DATA_COMMAND
;
704 if (newLayout
== UNDEFINED_LAYOUT
)
705 newLayout
= DISASSEM_DATA_COMMAND
;
714 ** _makeCommandWindow().
717 _makeCommandWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
719 _initAndMakeWin ((Opaque
*) winInfoPtr
,
727 (*winInfoPtr
)->canHighlight
= FALSE
;
730 } /* _makeCommandWindow */
734 ** _makeSourceWindow().
737 _makeSourceWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
739 _makeSourceOrDisassemWindow (winInfoPtr
, SRC_WIN
, height
, originY
);
742 } /* _makeSourceWindow */
746 ** _makeDisassemWindow().
749 _makeDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
751 _makeSourceOrDisassemWindow (winInfoPtr
, DISASSEM_WIN
, height
, originY
);
754 } /* _makeDisassemWindow */
758 ** _makeDataWindow().
761 _makeDataWindow (TuiWinInfoPtr
* winInfoPtr
, int height
, int originY
)
763 _initAndMakeWin ((Opaque
*) winInfoPtr
,
772 } /* _makeDataWindow */
777 ** _showSourceCommand().
778 ** Show the Source/Command layout
781 _showSourceCommand (void)
783 _showSourceOrDisassemAndCommand (SRC_COMMAND
);
786 } /* _showSourceCommand */
790 ** _showDisassemCommand().
791 ** Show the Dissassem/Command layout
794 _showDisassemCommand (void)
796 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND
);
799 } /* _showDisassemCommand */
803 ** _showSourceDisassemCommand().
804 ** Show the Source/Disassem/Command layout
807 _showSourceDisassemCommand (void)
809 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
811 if (currentLayout () != SRC_DISASSEM_COMMAND
)
813 int cmdHeight
, srcHeight
, asmHeight
;
815 if (m_winPtrNotNull (cmdWin
))
816 cmdHeight
= cmdWin
->generic
.height
;
818 cmdHeight
= termHeight () / 3;
820 srcHeight
= (termHeight () - cmdHeight
) / 2;
821 asmHeight
= termHeight () - (srcHeight
+ cmdHeight
);
823 if (m_winPtrIsNull (srcWin
))
824 _makeSourceWindow (&srcWin
, srcHeight
, 0);
827 _initGenWinInfo (&srcWin
->generic
,
828 srcWin
->generic
.type
,
830 srcWin
->generic
.width
,
831 srcWin
->detail
.sourceInfo
.executionInfo
->width
,
833 srcWin
->canHighlight
= TRUE
;
834 _initGenWinInfo (srcWin
->detail
.sourceInfo
.executionInfo
,
840 m_beVisible (srcWin
);
841 m_beVisible (srcWin
->detail
.sourceInfo
.executionInfo
);
842 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;;
844 if (m_winPtrNotNull (srcWin
))
846 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
848 tuiShowSourceContent (srcWin
);
849 if (m_winPtrIsNull (disassemWin
))
851 _makeDisassemWindow (&disassemWin
, asmHeight
, srcHeight
- 1);
852 _initAndMakeWin ((Opaque
*) & locator
,
857 (srcHeight
+ asmHeight
) - 1,
862 _initGenWinInfo (locator
,
867 (srcHeight
+ asmHeight
) - 1);
868 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
870 &disassemWin
->generic
,
871 disassemWin
->generic
.type
,
873 disassemWin
->generic
.width
,
874 disassemWin
->detail
.sourceInfo
.executionInfo
->width
,
876 _initGenWinInfo (disassemWin
->detail
.sourceInfo
.executionInfo
,
882 disassemWin
->canHighlight
= TRUE
;
883 m_beVisible (disassemWin
);
884 m_beVisible (disassemWin
->detail
.sourceInfo
.executionInfo
);
886 if (m_winPtrNotNull (disassemWin
))
888 srcWin
->detail
.sourceInfo
.hasLocator
= FALSE
;
889 disassemWin
->detail
.sourceInfo
.hasLocator
= TRUE
;
890 m_beVisible (locator
);
891 tuiShowLocatorContent ();
892 tuiShowSourceContent (disassemWin
);
894 if (m_winPtrIsNull (cmdWin
))
895 _makeCommandWindow (&cmdWin
,
897 termHeight () - cmdHeight
);
900 _initGenWinInfo (&cmdWin
->generic
,
901 cmdWin
->generic
.type
,
902 cmdWin
->generic
.height
,
903 cmdWin
->generic
.width
,
905 cmdWin
->generic
.origin
.y
);
906 cmdWin
->canHighlight
= FALSE
;
907 m_beVisible (cmdWin
);
909 if (m_winPtrNotNull (cmdWin
))
910 tuiRefreshWin (&cmdWin
->generic
);
913 setCurrentLayoutTo (SRC_DISASSEM_COMMAND
);
917 } /* _showSourceDisassemCommand */
922 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
925 _showData (TuiLayoutType newLayout
)
927 int totalHeight
= (termHeight () - cmdWin
->generic
.height
);
928 int srcHeight
, dataHeight
;
930 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
933 dataHeight
= totalHeight
/ 2;
934 srcHeight
= totalHeight
- dataHeight
;
936 m_beInvisible (locator
);
937 _makeDataWindow (&dataWin
, dataHeight
, 0);
938 dataWin
->canHighlight
= TRUE
;
939 if (newLayout
== SRC_DATA_COMMAND
)
942 winType
= DISASSEM_WIN
;
943 if (m_winPtrIsNull (winList
[winType
]))
945 if (winType
== SRC_WIN
)
946 _makeSourceWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
948 _makeDisassemWindow (&winList
[winType
], srcHeight
, dataHeight
- 1);
949 _initAndMakeWin ((Opaque
*) & locator
,
959 _initGenWinInfo (&winList
[winType
]->generic
,
960 winList
[winType
]->generic
.type
,
962 winList
[winType
]->generic
.width
,
963 winList
[winType
]->detail
.sourceInfo
.executionInfo
->width
,
965 _initGenWinInfo (winList
[winType
]->detail
.sourceInfo
.executionInfo
,
971 m_beVisible (winList
[winType
]);
972 m_beVisible (winList
[winType
]->detail
.sourceInfo
.executionInfo
);
973 _initGenWinInfo (locator
,
980 winList
[winType
]->detail
.sourceInfo
.hasLocator
= TRUE
;
981 m_beVisible (locator
);
982 tuiShowLocatorContent ();
983 addToSourceWindows (winList
[winType
]);
984 setCurrentLayoutTo (newLayout
);
990 ** _initGenWinInfo().
993 _initGenWinInfo (TuiGenWinInfoPtr winInfo
, TuiWinType type
,
994 int height
, int width
, int originX
, int originY
)
998 winInfo
->type
= type
;
999 winInfo
->width
= width
;
1000 winInfo
->height
= h
;
1003 winInfo
->viewportHeight
= h
- 1;
1004 if (winInfo
->type
!= CMD_WIN
)
1005 winInfo
->viewportHeight
--;
1008 winInfo
->viewportHeight
= 1;
1009 winInfo
->origin
.x
= originX
;
1010 winInfo
->origin
.y
= originY
;
1013 } /* _initGenWinInfo */
1016 ** _initAndMakeWin().
1019 _initAndMakeWin (Opaque
* winInfoPtr
, TuiWinType winType
,
1020 int height
, int width
, int originX
, int originY
, int boxIt
)
1022 Opaque opaqueWinInfo
= *winInfoPtr
;
1023 TuiGenWinInfoPtr generic
;
1025 if (opaqueWinInfo
== (Opaque
) NULL
)
1027 if (m_winIsAuxillary (winType
))
1028 opaqueWinInfo
= (Opaque
) allocGenericWinInfo ();
1030 opaqueWinInfo
= (Opaque
) allocWinInfo (winType
);
1032 if (m_winIsAuxillary (winType
))
1033 generic
= (TuiGenWinInfoPtr
) opaqueWinInfo
;
1035 generic
= &((TuiWinInfoPtr
) opaqueWinInfo
)->generic
;
1037 if (opaqueWinInfo
!= (Opaque
) NULL
)
1039 _initGenWinInfo (generic
, winType
, height
, width
, originX
, originY
);
1040 if (!m_winIsAuxillary (winType
))
1042 if (generic
->type
== CMD_WIN
)
1043 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= FALSE
;
1045 ((TuiWinInfoPtr
) opaqueWinInfo
)->canHighlight
= TRUE
;
1047 makeWindow (generic
, boxIt
);
1048 if (winType
== LOCATOR_WIN
)
1049 tuiClearLocatorDisplay ();
1051 *winInfoPtr
= opaqueWinInfo
;
1054 } /* _initAndMakeWin */
1058 ** _makeSourceOrDisassemWindow().
1061 _makeSourceOrDisassemWindow (TuiWinInfoPtr
* winInfoPtr
, TuiWinType type
,
1062 int height
, int originY
)
1064 TuiGenWinInfoPtr executionInfo
= (TuiGenWinInfoPtr
) NULL
;
1067 ** Create the exeuction info window.
1069 if (type
== SRC_WIN
)
1070 executionInfo
= sourceExecInfoWinPtr ();
1072 executionInfo
= disassemExecInfoWinPtr ();
1073 _initAndMakeWin ((Opaque
*) & executionInfo
,
1081 ** Now create the source window.
1083 _initAndMakeWin ((Opaque
*) winInfoPtr
,
1086 termWidth () - executionInfo
->width
,
1087 executionInfo
->width
,
1091 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
= executionInfo
;
1094 } /* _makeSourceOrDisassemWindow */
1098 ** _showSourceOrDisassemAndCommand().
1099 ** Show the Source/Command or the Disassem layout
1102 _showSourceOrDisassemAndCommand (TuiLayoutType layoutType
)
1104 if (currentLayout () != layoutType
)
1106 TuiWinInfoPtr
*winInfoPtr
;
1108 int srcHeight
, cmdHeight
;
1109 TuiGenWinInfoPtr locator
= locatorWinInfoPtr ();
1111 if (m_winPtrNotNull (cmdWin
))
1112 cmdHeight
= cmdWin
->generic
.height
;
1114 cmdHeight
= termHeight () / 3;
1115 srcHeight
= termHeight () - cmdHeight
;
1118 if (layoutType
== SRC_COMMAND
)
1119 winInfoPtr
= &srcWin
;
1121 winInfoPtr
= &disassemWin
;
1123 if (m_winPtrIsNull (*winInfoPtr
))
1125 if (layoutType
== SRC_COMMAND
)
1126 _makeSourceWindow (winInfoPtr
, srcHeight
- 1, 0);
1128 _makeDisassemWindow (winInfoPtr
, srcHeight
- 1, 0);
1129 _initAndMakeWin ((Opaque
*) & locator
,
1139 _initGenWinInfo (locator
,
1145 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1147 &(*winInfoPtr
)->generic
,
1148 (*winInfoPtr
)->generic
.type
,
1150 (*winInfoPtr
)->generic
.width
,
1151 (*winInfoPtr
)->detail
.sourceInfo
.executionInfo
->width
,
1153 _initGenWinInfo ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
,
1159 (*winInfoPtr
)->canHighlight
= TRUE
;
1160 m_beVisible (*winInfoPtr
);
1161 m_beVisible ((*winInfoPtr
)->detail
.sourceInfo
.executionInfo
);
1163 if (m_winPtrNotNull (*winInfoPtr
))
1165 (*winInfoPtr
)->detail
.sourceInfo
.hasLocator
= TRUE
;
1166 m_beVisible (locator
);
1167 tuiShowLocatorContent ();
1168 tuiShowSourceContent (*winInfoPtr
);
1170 if (m_winPtrIsNull (cmdWin
))
1172 _makeCommandWindow (&cmdWin
, cmdHeight
, srcHeight
);
1173 tuiRefreshWin (&cmdWin
->generic
);
1177 _initGenWinInfo (&cmdWin
->generic
,
1178 cmdWin
->generic
.type
,
1179 cmdWin
->generic
.height
,
1180 cmdWin
->generic
.width
,
1181 cmdWin
->generic
.origin
.x
,
1182 cmdWin
->generic
.origin
.y
);
1183 cmdWin
->canHighlight
= FALSE
;
1184 m_beVisible (cmdWin
);
1187 setCurrentLayoutTo (layoutType
);
1191 } /* _showSourceOrDisassemAndCommand */