* ia64-tdep.c (ia64_push_dummy_call): Define as combination of
[deliverable/binutils-gdb.git] / gdb / tui / tuiLayout.c
CommitLineData
f377b406 1/* TUI layout window management.
f33c6cbf 2
96ec9981 3 Copyright 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation,
f33c6cbf
AC
4 Inc.
5
f377b406 6 Contributed by Hewlett-Packard Company.
c906108c 7
f377b406
SC
8 This file is part of GDB.
9
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.
14
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.
19
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. */
c906108c
SS
24
25#include "defs.h"
26#include "command.h"
27#include "symtab.h"
28#include "frame.h"
52575520 29#include "source.h"
84b1e7c7 30#include <ctype.h>
c906108c
SS
31
32#include "tui.h"
33#include "tuiData.h"
84b1e7c7 34#include "tuiDataWin.h"
c906108c
SS
35#include "tuiGeneralWin.h"
36#include "tuiStack.h"
37#include "tuiRegs.h"
84b1e7c7
SC
38#include "tuiWin.h"
39#include "tuiSourceWin.h"
c906108c
SS
40#include "tuiDisassem.h"
41
96ec9981
DJ
42#ifdef HAVE_NCURSES_H
43#include <ncurses.h>
44#else
45#ifdef HAVE_CURSES_H
46#include <curses.h>
47#endif
48#endif
49
c906108c
SS
50/*******************************
51** Static Local Decls
52********************************/
c7037be1 53static void showLayout (TuiLayoutType);
f6dd1e70
KB
54static void _initGenWinInfo (TuiGenWinInfoPtr, TuiWinType, int, int, int, int);
55static void _initAndMakeWin (Opaque *, TuiWinType, int, int, int, int, int);
56static void _showSourceOrDisassemAndCommand (TuiLayoutType);
57static void _makeSourceOrDisassemWindow (TuiWinInfoPtr *, TuiWinType, int, int);
a14ed312
KB
58static void _makeCommandWindow (TuiWinInfoPtr *, int, int);
59static void _makeSourceWindow (TuiWinInfoPtr *, int, int);
f6dd1e70 60static void _makeDisassemWindow (TuiWinInfoPtr *, int, int);
a14ed312
KB
61static void _makeDataWindow (TuiWinInfoPtr *, int, int);
62static void _showSourceCommand (void);
63static void _showDisassemCommand (void);
64static void _showSourceDisassemCommand (void);
65static void _showData (TuiLayoutType);
66static TuiLayoutType _nextLayout (void);
67static TuiLayoutType _prevLayout (void);
68static void _tuiLayout_command (char *, int);
69static void _tuiToggleLayout_command (char *, int);
a14ed312 70static void _tuiToggleSplitLayout_command (char *, int);
c774cec6 71static CORE_ADDR _extractDisplayStartAddr (void);
a14ed312 72static void _tuiHandleXDBLayout (TuiLayoutDefPtr);
c906108c
SS
73
74
75/***************************************
76** DEFINITIONS
77***************************************/
78
79#define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
80
c7037be1
SC
81/* Show the screen layout defined. */
82static void
eca6576c 83showLayout (TuiLayoutType layout)
c906108c
SS
84{
85 TuiLayoutType curLayout = currentLayout ();
86
87 if (layout != curLayout)
88 {
89 /*
c5aa993b
JM
90 ** Since the new layout may cause changes in window size, we
91 ** should free the content and reallocate on next display of
92 ** source/asm
93 */
c906108c
SS
94 freeAllSourceWinsContent ();
95 clearSourceWindows ();
96 if (layout == SRC_DATA_COMMAND || layout == DISASSEM_DATA_COMMAND)
97 {
98 _showData (layout);
99 refreshAll (winList);
100 }
101 else
102 {
103 /* First make the current layout be invisible */
104 m_allBeInvisible ();
105 m_beInvisible (locatorWinInfoPtr ());
106
107 switch (layout)
108 {
109 /* Now show the new layout */
110 case SRC_COMMAND:
111 _showSourceCommand ();
112 addToSourceWindows (srcWin);
113 break;
114 case DISASSEM_COMMAND:
115 _showDisassemCommand ();
116 addToSourceWindows (disassemWin);
117 break;
118 case SRC_DISASSEM_COMMAND:
119 _showSourceDisassemCommand ();
120 addToSourceWindows (srcWin);
121 addToSourceWindows (disassemWin);
122 break;
123 default:
124 break;
125 }
126 }
127 }
bc712bbf 128}
c906108c
SS
129
130
131/*
c5aa993b
JM
132 ** tuiSetLayout()
133 ** Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
134 ** SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
135 ** If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
136 ** UNDEFINED_LAYOUT, then the data window is populated according
137 ** to regsDisplayType.
138 */
c906108c 139TuiStatus
eca6576c
SC
140tuiSetLayout (TuiLayoutType layoutType,
141 TuiRegisterDisplayType regsDisplayType)
c906108c
SS
142{
143 TuiStatus status = TUI_SUCCESS;
144
145 if (layoutType != UNDEFINED_LAYOUT || regsDisplayType != TUI_UNDEFINED_REGS)
146 {
147 TuiLayoutType curLayout = currentLayout (), newLayout = UNDEFINED_LAYOUT;
148 int regsPopulate = FALSE;
c774cec6 149 CORE_ADDR addr = _extractDisplayStartAddr ();
c906108c
SS
150 TuiWinInfoPtr newWinWithFocus = (TuiWinInfoPtr) NULL, winWithFocus = tuiWinWithFocus ();
151 TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
152
153
154 if (layoutType == UNDEFINED_LAYOUT &&
155 regsDisplayType != TUI_UNDEFINED_REGS)
156 {
157 if (curLayout == SRC_DISASSEM_COMMAND)
158 newLayout = DISASSEM_DATA_COMMAND;
159 else if (curLayout == SRC_COMMAND || curLayout == SRC_DATA_COMMAND)
160 newLayout = SRC_DATA_COMMAND;
161 else if (curLayout == DISASSEM_COMMAND ||
162 curLayout == DISASSEM_DATA_COMMAND)
163 newLayout = DISASSEM_DATA_COMMAND;
164 }
165 else
166 newLayout = layoutType;
167
168 regsPopulate = (newLayout == SRC_DATA_COMMAND ||
169 newLayout == DISASSEM_DATA_COMMAND ||
170 regsDisplayType != TUI_UNDEFINED_REGS);
171 if (newLayout != curLayout || regsDisplayType != TUI_UNDEFINED_REGS)
172 {
173 if (newLayout != curLayout)
174 {
c906108c
SS
175 showLayout (newLayout);
176 /*
c5aa993b
JM
177 ** Now determine where focus should be
178 */
c906108c
SS
179 if (winWithFocus != cmdWin)
180 {
181 switch (newLayout)
182 {
183 case SRC_COMMAND:
184 tuiSetWinFocusTo (srcWin);
185 layoutDef->displayMode = SRC_WIN;
186 layoutDef->split = FALSE;
187 break;
188 case DISASSEM_COMMAND:
189 /* the previous layout was not showing
c5aa993b
JM
190 ** code. this can happen if there is no
191 ** source available:
192 ** 1. if the source file is in another dir OR
193 ** 2. if target was compiled without -g
194 ** We still want to show the assembly though!
195 */
e8b915dc 196 addr = tuiGetBeginAsmAddress ();
c906108c
SS
197 tuiSetWinFocusTo (disassemWin);
198 layoutDef->displayMode = DISASSEM_WIN;
199 layoutDef->split = FALSE;
200 break;
201 case SRC_DISASSEM_COMMAND:
202 /* the previous layout was not showing
c5aa993b
JM
203 ** code. this can happen if there is no
204 ** source available:
205 ** 1. if the source file is in another dir OR
206 ** 2. if target was compiled without -g
207 ** We still want to show the assembly though!
208 */
e8b915dc 209 addr = tuiGetBeginAsmAddress ();
c906108c
SS
210 if (winWithFocus == srcWin)
211 tuiSetWinFocusTo (srcWin);
212 else
213 tuiSetWinFocusTo (disassemWin);
214 layoutDef->split = TRUE;
215 break;
216 case SRC_DATA_COMMAND:
217 if (winWithFocus != dataWin)
218 tuiSetWinFocusTo (srcWin);
219 else
220 tuiSetWinFocusTo (dataWin);
221 layoutDef->displayMode = SRC_WIN;
222 layoutDef->split = FALSE;
223 break;
224 case DISASSEM_DATA_COMMAND:
225 /* the previous layout was not showing
c5aa993b
JM
226 ** code. this can happen if there is no
227 ** source available:
228 ** 1. if the source file is in another dir OR
229 ** 2. if target was compiled without -g
230 ** We still want to show the assembly though!
231 */
e8b915dc 232 addr = tuiGetBeginAsmAddress ();
c906108c
SS
233 if (winWithFocus != dataWin)
234 tuiSetWinFocusTo (disassemWin);
235 else
236 tuiSetWinFocusTo (dataWin);
237 layoutDef->displayMode = DISASSEM_WIN;
238 layoutDef->split = FALSE;
239 break;
240 default:
241 break;
242 }
243 }
244 if (newWinWithFocus != (TuiWinInfoPtr) NULL)
245 tuiSetWinFocusTo (newWinWithFocus);
246 /*
c5aa993b
JM
247 ** Now update the window content
248 */
c906108c
SS
249 if (!regsPopulate &&
250 (newLayout == SRC_DATA_COMMAND ||
251 newLayout == DISASSEM_DATA_COMMAND))
252 tuiDisplayAllData ();
253
254 tuiUpdateSourceWindowsWithAddr (addr);
255 }
256 if (regsPopulate)
257 {
258 layoutDef->regsDisplayType =
259 (regsDisplayType == TUI_UNDEFINED_REGS ?
260 TUI_GENERAL_REGS : regsDisplayType);
261 tuiShowRegisters (layoutDef->regsDisplayType);
262 }
263 }
264 }
265 else
266 status = TUI_FAILURE;
267
268 return status;
bc712bbf 269}
c906108c 270
c906108c 271/*
c5aa993b
JM
272 ** tuiAddWinToLayout().
273 ** Add the specified window to the layout in a logical way.
274 ** This means setting up the most logical layout given the
275 ** window to be added.
276 */
c906108c 277void
eca6576c 278tuiAddWinToLayout (TuiWinType type)
c906108c
SS
279{
280 TuiLayoutType curLayout = currentLayout ();
281
282 switch (type)
283 {
284 case SRC_WIN:
285 if (curLayout != SRC_COMMAND &&
286 curLayout != SRC_DISASSEM_COMMAND &&
287 curLayout != SRC_DATA_COMMAND)
288 {
289 clearSourceWindowsDetail ();
290 if (curLayout == DISASSEM_DATA_COMMAND)
291 showLayout (SRC_DATA_COMMAND);
292 else
293 showLayout (SRC_COMMAND);
294 }
295 break;
296 case DISASSEM_WIN:
297 if (curLayout != DISASSEM_COMMAND &&
298 curLayout != SRC_DISASSEM_COMMAND &&
299 curLayout != DISASSEM_DATA_COMMAND)
300 {
301 clearSourceWindowsDetail ();
302 if (curLayout == SRC_DATA_COMMAND)
303 showLayout (DISASSEM_DATA_COMMAND);
304 else
305 showLayout (DISASSEM_COMMAND);
306 }
307 break;
308 case DATA_WIN:
309 if (curLayout != SRC_DATA_COMMAND &&
310 curLayout != DISASSEM_DATA_COMMAND)
311 {
312 if (curLayout == DISASSEM_COMMAND)
313 showLayout (DISASSEM_DATA_COMMAND);
314 else
315 showLayout (SRC_DATA_COMMAND);
316 }
317 break;
318 default:
319 break;
320 }
321
322 return;
323} /* tuiAddWinToLayout */
324
325
c906108c 326/*
c5aa993b
JM
327 ** tuiDefaultWinHeight().
328 ** Answer the height of a window. If it hasn't been created yet,
329 ** answer what the height of a window would be based upon its
330 ** type and the layout.
331 */
c906108c 332int
eca6576c 333tuiDefaultWinHeight (TuiWinType type, TuiLayoutType layout)
c906108c
SS
334{
335 int h;
336
337 if (winList[type] != (TuiWinInfoPtr) NULL)
338 h = winList[type]->generic.height;
339 else
340 {
341 switch (layout)
342 {
343 case SRC_COMMAND:
344 case DISASSEM_COMMAND:
345 if (m_winPtrIsNull (cmdWin))
346 h = termHeight () / 2;
347 else
348 h = termHeight () - cmdWin->generic.height;
349 break;
350 case SRC_DISASSEM_COMMAND:
351 case SRC_DATA_COMMAND:
352 case DISASSEM_DATA_COMMAND:
353 if (m_winPtrIsNull (cmdWin))
354 h = termHeight () / 3;
355 else
356 h = (termHeight () - cmdWin->generic.height) / 2;
357 break;
358 default:
359 h = 0;
360 break;
361 }
362 }
363
364 return h;
365} /* tuiDefaultWinHeight */
366
367
368/*
c5aa993b
JM
369 ** tuiDefaultWinViewportHeight().
370 ** Answer the height of a window. If it hasn't been created yet,
371 ** answer what the height of a window would be based upon its
372 ** type and the layout.
373 */
c906108c 374int
eca6576c 375tuiDefaultWinViewportHeight (TuiWinType type, TuiLayoutType layout)
c906108c
SS
376{
377 int h;
378
379 h = tuiDefaultWinHeight (type, layout);
380
381 if (winList[type] == cmdWin)
382 h -= 1;
383 else
384 h -= 2;
385
386 return h;
387} /* tuiDefaultWinViewportHeight */
388
389
390/*
c5aa993b
JM
391 ** _initialize_tuiLayout().
392 ** Function to initialize gdb commands, for tui window layout
393 ** manipulation.
394 */
c906108c 395void
fba45db2 396_initialize_tuiLayout (void)
c906108c 397{
41783295
SC
398 add_com ("layout", class_tui, _tuiLayout_command,
399 "Change the layout of windows.\n\
c906108c
SS
400Usage: layout prev | next | <layout_name> \n\
401Layout names are:\n\
402 src : Displays source and command windows.\n\
403 asm : Displays disassembly and command windows.\n\
404 split : Displays source, disassembly and command windows.\n\
405 regs : Displays register window. If existing layout\n\
406 is source/command or assembly/command, the \n\
407 register window is displayed. If the\n\
408 source/assembly/command (split) is displayed, \n\
409 the register window is displayed with \n\
410 the window that has current logical focus.\n");
41783295
SC
411 if (xdb_commands)
412 {
413 add_com ("td", class_tui, _tuiToggleLayout_command,
414 "Toggle between Source/Command and Disassembly/Command layouts.\n");
415 add_com ("ts", class_tui, _tuiToggleSplitLayout_command,
416 "Toggle between Source/Command or Disassembly/Command and \n\
c906108c 417Source/Disassembly/Command layouts.\n");
c906108c 418 }
41783295 419}
c906108c
SS
420
421
422/*************************
423** STATIC LOCAL FUNCTIONS
424**************************/
425
426
427/*
c5aa993b
JM
428 ** _tuiSetLayoutTo()
429 ** Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA, REGS,
430 ** $REGS, $GREGS, $FREGS, $SREGS.
431 */
e8b915dc
SC
432TuiStatus
433tui_set_layout (const char *layoutName)
c906108c
SS
434{
435 TuiStatus status = TUI_SUCCESS;
436
437 if (layoutName != (char *) NULL)
438 {
439 register int i;
440 register char *bufPtr;
441 TuiLayoutType newLayout = UNDEFINED_LAYOUT;
442 TuiRegisterDisplayType dpyType = TUI_UNDEFINED_REGS;
443 TuiLayoutType curLayout = currentLayout ();
444
19eb139b 445 bufPtr = (char *) xstrdup (layoutName);
c906108c
SS
446 for (i = 0; (i < strlen (layoutName)); i++)
447 bufPtr[i] = toupper (bufPtr[i]);
448
449 /* First check for ambiguous input */
450 if (strlen (bufPtr) <= 1 && (*bufPtr == 'S' || *bufPtr == '$'))
451 {
452 warning ("Ambiguous command input.\n");
453 status = TUI_FAILURE;
454 }
455 else
456 {
0963fc96 457 if (subset_compare (bufPtr, "SRC"))
c906108c 458 newLayout = SRC_COMMAND;
0963fc96 459 else if (subset_compare (bufPtr, "ASM"))
c906108c 460 newLayout = DISASSEM_COMMAND;
0963fc96 461 else if (subset_compare (bufPtr, "SPLIT"))
c906108c 462 newLayout = SRC_DISASSEM_COMMAND;
0963fc96
SC
463 else if (subset_compare (bufPtr, "REGS") ||
464 subset_compare (bufPtr, TUI_GENERAL_SPECIAL_REGS_NAME) ||
465 subset_compare (bufPtr, TUI_GENERAL_REGS_NAME) ||
466 subset_compare (bufPtr, TUI_FLOAT_REGS_NAME) ||
467 subset_compare (bufPtr, TUI_SPECIAL_REGS_NAME))
c906108c
SS
468 {
469 if (curLayout == SRC_COMMAND || curLayout == SRC_DATA_COMMAND)
470 newLayout = SRC_DATA_COMMAND;
471 else
472 newLayout = DISASSEM_DATA_COMMAND;
473
474/* could ifdef out the following code. when compile with -z, there are null
475 pointer references that cause a core dump if 'layout regs' is the first
476 layout command issued by the user. HP has asked us to hook up this code
477 - edie epstein
478 */
0963fc96 479 if (subset_compare (bufPtr, TUI_FLOAT_REGS_NAME))
c906108c
SS
480 {
481 if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
482 TUI_SFLOAT_REGS &&
483 dataWin->detail.dataDisplayInfo.regsDisplayType !=
484 TUI_DFLOAT_REGS)
485 dpyType = TUI_SFLOAT_REGS;
486 else
487 dpyType =
488 dataWin->detail.dataDisplayInfo.regsDisplayType;
489 }
0963fc96 490 else if (subset_compare (bufPtr,
c906108c
SS
491 TUI_GENERAL_SPECIAL_REGS_NAME))
492 dpyType = TUI_GENERAL_AND_SPECIAL_REGS;
0963fc96 493 else if (subset_compare (bufPtr, TUI_GENERAL_REGS_NAME))
c906108c 494 dpyType = TUI_GENERAL_REGS;
0963fc96 495 else if (subset_compare (bufPtr, TUI_SPECIAL_REGS_NAME))
c906108c 496 dpyType = TUI_SPECIAL_REGS;
84b1e7c7 497 else if (dataWin)
c906108c
SS
498 {
499 if (dataWin->detail.dataDisplayInfo.regsDisplayType !=
500 TUI_UNDEFINED_REGS)
501 dpyType =
502 dataWin->detail.dataDisplayInfo.regsDisplayType;
503 else
504 dpyType = TUI_GENERAL_REGS;
505 }
506
507/* end of potential ifdef
508 */
509
510/* if ifdefed out code above, then assume that the user wishes to display the
511 general purpose registers
512 */
513
514/* dpyType = TUI_GENERAL_REGS;
515 */
516 }
0963fc96 517 else if (subset_compare (bufPtr, "NEXT"))
c906108c 518 newLayout = _nextLayout ();
0963fc96 519 else if (subset_compare (bufPtr, "PREV"))
c906108c
SS
520 newLayout = _prevLayout ();
521 else
522 status = TUI_FAILURE;
b8c9b27d 523 xfree (bufPtr);
c906108c
SS
524
525 tuiSetLayout (newLayout, dpyType);
526 }
527 }
528 else
529 status = TUI_FAILURE;
530
531 return status;
e8b915dc 532}
c906108c
SS
533
534
c774cec6 535static CORE_ADDR
c906108c 536_extractDisplayStartAddr (void)
c906108c
SS
537{
538 TuiLayoutType curLayout = currentLayout ();
c774cec6 539 CORE_ADDR addr;
84b1e7c7 540 CORE_ADDR pc;
52575520 541 struct symtab_and_line cursal = get_current_source_symtab_and_line ();
c906108c
SS
542
543 switch (curLayout)
544 {
545 case SRC_COMMAND:
546 case SRC_DATA_COMMAND:
52575520 547 find_line_pc (cursal.symtab,
84b1e7c7
SC
548 srcWin->detail.sourceInfo.startLineOrAddr.lineNo,
549 &pc);
c774cec6 550 addr = pc;
c906108c
SS
551 break;
552 case DISASSEM_COMMAND:
553 case SRC_DISASSEM_COMMAND:
554 case DISASSEM_DATA_COMMAND:
555 addr = disassemWin->detail.sourceInfo.startLineOrAddr.addr;
556 break;
557 default:
c774cec6 558 addr = 0;
c906108c
SS
559 break;
560 }
561
562 return addr;
563} /* _extractDisplayStartAddr */
564
565
566static void
eca6576c 567_tuiHandleXDBLayout (TuiLayoutDefPtr layoutDef)
c906108c
SS
568{
569 if (layoutDef->split)
570 {
571 tuiSetLayout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
572 tuiSetWinFocusTo (winList[layoutDef->displayMode]);
573 }
574 else
575 {
576 if (layoutDef->displayMode == SRC_WIN)
577 tuiSetLayout (SRC_COMMAND, TUI_UNDEFINED_REGS);
578 else
579 tuiSetLayout (DISASSEM_DATA_COMMAND, layoutDef->regsDisplayType);
580 }
581
582
583 return;
584} /* _tuiHandleXDBLayout */
585
586
587static void
eca6576c 588_tuiToggleLayout_command (char *arg, int fromTTY)
c906108c
SS
589{
590 TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
591
19eb139b
SC
592 /* Make sure the curses mode is enabled. */
593 tui_enable ();
c906108c
SS
594 if (layoutDef->displayMode == SRC_WIN)
595 layoutDef->displayMode = DISASSEM_WIN;
596 else
597 layoutDef->displayMode = SRC_WIN;
598
599 if (!layoutDef->split)
600 _tuiHandleXDBLayout (layoutDef);
601
e8b915dc 602}
c906108c
SS
603
604
605static void
eca6576c 606_tuiToggleSplitLayout_command (char *arg, int fromTTY)
c906108c
SS
607{
608 TuiLayoutDefPtr layoutDef = tuiLayoutDef ();
609
19eb139b
SC
610 /* Make sure the curses mode is enabled. */
611 tui_enable ();
c906108c
SS
612 layoutDef->split = (!layoutDef->split);
613 _tuiHandleXDBLayout (layoutDef);
614
e8b915dc 615}
c906108c
SS
616
617
618static void
eca6576c 619_tuiLayout_command (char *arg, int fromTTY)
c906108c 620{
19eb139b
SC
621 /* Make sure the curses mode is enabled. */
622 tui_enable ();
623
624 /* Switch to the selected layout. */
e8b915dc 625 if (tui_set_layout (arg) != TUI_SUCCESS)
84b1e7c7 626 warning ("Invalid layout specified.\n%s", LAYOUT_USAGE);
c906108c 627
e8b915dc 628}
c906108c
SS
629
630/*
c5aa993b
JM
631 ** _nextLayout().
632 ** Answer the previous layout to cycle to.
633 */
c906108c 634static TuiLayoutType
c906108c 635_nextLayout (void)
c906108c
SS
636{
637 TuiLayoutType newLayout;
638
639 newLayout = currentLayout ();
640 if (newLayout == UNDEFINED_LAYOUT)
641 newLayout = SRC_COMMAND;
642 else
643 {
644 newLayout++;
645 if (newLayout == UNDEFINED_LAYOUT)
646 newLayout = SRC_COMMAND;
647 }
648
649 return newLayout;
650} /* _nextLayout */
651
652
653/*
c5aa993b
JM
654 ** _prevLayout().
655 ** Answer the next layout to cycle to.
656 */
c906108c 657static TuiLayoutType
c906108c 658_prevLayout (void)
c906108c
SS
659{
660 TuiLayoutType newLayout;
661
662 newLayout = currentLayout ();
663 if (newLayout == SRC_COMMAND)
664 newLayout = DISASSEM_DATA_COMMAND;
665 else
666 {
667 newLayout--;
668 if (newLayout == UNDEFINED_LAYOUT)
669 newLayout = DISASSEM_DATA_COMMAND;
670 }
671
672 return newLayout;
673} /* _prevLayout */
674
675
676
677/*
c5aa993b
JM
678 ** _makeCommandWindow().
679 */
c906108c 680static void
eca6576c 681_makeCommandWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
c906108c
SS
682{
683 _initAndMakeWin ((Opaque *) winInfoPtr,
684 CMD_WIN,
685 height,
686 termWidth (),
687 0,
688 originY,
689 DONT_BOX_WINDOW);
690
691 (*winInfoPtr)->canHighlight = FALSE;
692
693 return;
694} /* _makeCommandWindow */
695
696
697/*
c5aa993b
JM
698 ** _makeSourceWindow().
699 */
c906108c 700static void
eca6576c 701_makeSourceWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
c906108c
SS
702{
703 _makeSourceOrDisassemWindow (winInfoPtr, SRC_WIN, height, originY);
704
705 return;
706} /* _makeSourceWindow */
707
708
709/*
c5aa993b
JM
710 ** _makeDisassemWindow().
711 */
c906108c 712static void
eca6576c 713_makeDisassemWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
c906108c
SS
714{
715 _makeSourceOrDisassemWindow (winInfoPtr, DISASSEM_WIN, height, originY);
716
717 return;
718} /* _makeDisassemWindow */
719
720
721/*
c5aa993b
JM
722 ** _makeDataWindow().
723 */
c906108c 724static void
eca6576c 725_makeDataWindow (TuiWinInfoPtr * winInfoPtr, int height, int originY)
c906108c
SS
726{
727 _initAndMakeWin ((Opaque *) winInfoPtr,
728 DATA_WIN,
729 height,
730 termWidth (),
731 0,
732 originY,
733 BOX_WINDOW);
734
735 return;
736} /* _makeDataWindow */
737
738
739
740/*
c5aa993b
JM
741 ** _showSourceCommand().
742 ** Show the Source/Command layout
743 */
c906108c 744static void
c906108c 745_showSourceCommand (void)
c906108c
SS
746{
747 _showSourceOrDisassemAndCommand (SRC_COMMAND);
748
749 return;
750} /* _showSourceCommand */
751
752
753/*
c5aa993b
JM
754 ** _showDisassemCommand().
755 ** Show the Dissassem/Command layout
756 */
c906108c 757static void
c906108c 758_showDisassemCommand (void)
c906108c
SS
759{
760 _showSourceOrDisassemAndCommand (DISASSEM_COMMAND);
761
762 return;
763} /* _showDisassemCommand */
764
765
766/*
c5aa993b
JM
767 ** _showSourceDisassemCommand().
768 ** Show the Source/Disassem/Command layout
769 */
c906108c 770static void
c906108c 771_showSourceDisassemCommand (void)
c906108c 772{
c906108c
SS
773 if (currentLayout () != SRC_DISASSEM_COMMAND)
774 {
775 int cmdHeight, srcHeight, asmHeight;
776
777 if (m_winPtrNotNull (cmdWin))
778 cmdHeight = cmdWin->generic.height;
779 else
780 cmdHeight = termHeight () / 3;
781
782 srcHeight = (termHeight () - cmdHeight) / 2;
783 asmHeight = termHeight () - (srcHeight + cmdHeight);
784
785 if (m_winPtrIsNull (srcWin))
786 _makeSourceWindow (&srcWin, srcHeight, 0);
787 else
788 {
789 _initGenWinInfo (&srcWin->generic,
790 srcWin->generic.type,
791 srcHeight,
792 srcWin->generic.width,
793 srcWin->detail.sourceInfo.executionInfo->width,
794 0);
795 srcWin->canHighlight = TRUE;
796 _initGenWinInfo (srcWin->detail.sourceInfo.executionInfo,
797 EXEC_INFO_WIN,
798 srcHeight,
799 3,
800 0,
801 0);
802 m_beVisible (srcWin);
803 m_beVisible (srcWin->detail.sourceInfo.executionInfo);
804 srcWin->detail.sourceInfo.hasLocator = FALSE;;
805 }
806 if (m_winPtrNotNull (srcWin))
807 {
808 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
809
810 tuiShowSourceContent (srcWin);
811 if (m_winPtrIsNull (disassemWin))
812 {
813 _makeDisassemWindow (&disassemWin, asmHeight, srcHeight - 1);
814 _initAndMakeWin ((Opaque *) & locator,
815 LOCATOR_WIN,
816 2 /* 1 */ ,
817 termWidth (),
818 0,
819 (srcHeight + asmHeight) - 1,
820 DONT_BOX_WINDOW);
821 }
822 else
823 {
824 _initGenWinInfo (locator,
825 LOCATOR_WIN,
826 2 /* 1 */ ,
827 termWidth (),
828 0,
829 (srcHeight + asmHeight) - 1);
830 disassemWin->detail.sourceInfo.hasLocator = TRUE;
831 _initGenWinInfo (
832 &disassemWin->generic,
833 disassemWin->generic.type,
834 asmHeight,
835 disassemWin->generic.width,
836 disassemWin->detail.sourceInfo.executionInfo->width,
837 srcHeight - 1);
838 _initGenWinInfo (disassemWin->detail.sourceInfo.executionInfo,
839 EXEC_INFO_WIN,
840 asmHeight,
841 3,
842 0,
843 srcHeight - 1);
844 disassemWin->canHighlight = TRUE;
845 m_beVisible (disassemWin);
846 m_beVisible (disassemWin->detail.sourceInfo.executionInfo);
847 }
848 if (m_winPtrNotNull (disassemWin))
849 {
850 srcWin->detail.sourceInfo.hasLocator = FALSE;
851 disassemWin->detail.sourceInfo.hasLocator = TRUE;
852 m_beVisible (locator);
853 tuiShowLocatorContent ();
854 tuiShowSourceContent (disassemWin);
855
856 if (m_winPtrIsNull (cmdWin))
857 _makeCommandWindow (&cmdWin,
858 cmdHeight,
859 termHeight () - cmdHeight);
860 else
861 {
862 _initGenWinInfo (&cmdWin->generic,
863 cmdWin->generic.type,
864 cmdWin->generic.height,
865 cmdWin->generic.width,
866 0,
867 cmdWin->generic.origin.y);
868 cmdWin->canHighlight = FALSE;
869 m_beVisible (cmdWin);
870 }
871 if (m_winPtrNotNull (cmdWin))
872 tuiRefreshWin (&cmdWin->generic);
873 }
874 }
875 setCurrentLayoutTo (SRC_DISASSEM_COMMAND);
876 }
877
878 return;
879} /* _showSourceDisassemCommand */
880
881
882/*
c5aa993b
JM
883 ** _showData().
884 ** Show the Source/Data/Command or the Dissassembly/Data/Command layout
885 */
c906108c 886static void
eca6576c 887_showData (TuiLayoutType newLayout)
c906108c
SS
888{
889 int totalHeight = (termHeight () - cmdWin->generic.height);
890 int srcHeight, dataHeight;
891 TuiWinType winType;
892 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
893
894
895 dataHeight = totalHeight / 2;
896 srcHeight = totalHeight - dataHeight;
897 m_allBeInvisible ();
898 m_beInvisible (locator);
899 _makeDataWindow (&dataWin, dataHeight, 0);
900 dataWin->canHighlight = TRUE;
901 if (newLayout == SRC_DATA_COMMAND)
902 winType = SRC_WIN;
903 else
904 winType = DISASSEM_WIN;
905 if (m_winPtrIsNull (winList[winType]))
906 {
907 if (winType == SRC_WIN)
908 _makeSourceWindow (&winList[winType], srcHeight, dataHeight - 1);
909 else
910 _makeDisassemWindow (&winList[winType], srcHeight, dataHeight - 1);
911 _initAndMakeWin ((Opaque *) & locator,
912 LOCATOR_WIN,
913 2 /* 1 */ ,
914 termWidth (),
915 0,
916 totalHeight - 1,
917 DONT_BOX_WINDOW);
918 }
919 else
920 {
921 _initGenWinInfo (&winList[winType]->generic,
922 winList[winType]->generic.type,
923 srcHeight,
924 winList[winType]->generic.width,
925 winList[winType]->detail.sourceInfo.executionInfo->width,
926 dataHeight - 1);
927 _initGenWinInfo (winList[winType]->detail.sourceInfo.executionInfo,
928 EXEC_INFO_WIN,
929 srcHeight,
930 3,
931 0,
932 dataHeight - 1);
933 m_beVisible (winList[winType]);
934 m_beVisible (winList[winType]->detail.sourceInfo.executionInfo);
935 _initGenWinInfo (locator,
936 LOCATOR_WIN,
937 2 /* 1 */ ,
938 termWidth (),
939 0,
940 totalHeight - 1);
941 }
942 winList[winType]->detail.sourceInfo.hasLocator = TRUE;
943 m_beVisible (locator);
944 tuiShowLocatorContent ();
945 addToSourceWindows (winList[winType]);
946 setCurrentLayoutTo (newLayout);
947
948 return;
949} /* _showData */
950
951/*
c5aa993b
JM
952 ** _initGenWinInfo().
953 */
c906108c 954static void
eca6576c
SC
955_initGenWinInfo (TuiGenWinInfoPtr winInfo, TuiWinType type,
956 int height, int width, int originX, int originY)
c906108c
SS
957{
958 int h = height;
959
960 winInfo->type = type;
961 winInfo->width = width;
962 winInfo->height = h;
963 if (h > 1)
964 {
965 winInfo->viewportHeight = h - 1;
966 if (winInfo->type != CMD_WIN)
967 winInfo->viewportHeight--;
968 }
969 else
970 winInfo->viewportHeight = 1;
971 winInfo->origin.x = originX;
972 winInfo->origin.y = originY;
973
974 return;
975} /* _initGenWinInfo */
976
977/*
c5aa993b
JM
978 ** _initAndMakeWin().
979 */
c906108c 980static void
eca6576c
SC
981_initAndMakeWin (Opaque * winInfoPtr, TuiWinType winType,
982 int height, int width, int originX, int originY, int boxIt)
c906108c
SS
983{
984 Opaque opaqueWinInfo = *winInfoPtr;
985 TuiGenWinInfoPtr generic;
986
987 if (opaqueWinInfo == (Opaque) NULL)
988 {
989 if (m_winIsAuxillary (winType))
990 opaqueWinInfo = (Opaque) allocGenericWinInfo ();
991 else
992 opaqueWinInfo = (Opaque) allocWinInfo (winType);
993 }
994 if (m_winIsAuxillary (winType))
995 generic = (TuiGenWinInfoPtr) opaqueWinInfo;
996 else
997 generic = &((TuiWinInfoPtr) opaqueWinInfo)->generic;
998
999 if (opaqueWinInfo != (Opaque) NULL)
1000 {
1001 _initGenWinInfo (generic, winType, height, width, originX, originY);
1002 if (!m_winIsAuxillary (winType))
1003 {
1004 if (generic->type == CMD_WIN)
1005 ((TuiWinInfoPtr) opaqueWinInfo)->canHighlight = FALSE;
1006 else
1007 ((TuiWinInfoPtr) opaqueWinInfo)->canHighlight = TRUE;
1008 }
1009 makeWindow (generic, boxIt);
c906108c
SS
1010 }
1011 *winInfoPtr = opaqueWinInfo;
bc712bbf 1012}
c906108c
SS
1013
1014
1015/*
c5aa993b
JM
1016 ** _makeSourceOrDisassemWindow().
1017 */
c906108c 1018static void
eca6576c
SC
1019_makeSourceOrDisassemWindow (TuiWinInfoPtr * winInfoPtr, TuiWinType type,
1020 int height, int originY)
c906108c
SS
1021{
1022 TuiGenWinInfoPtr executionInfo = (TuiGenWinInfoPtr) NULL;
1023
1024 /*
c5aa993b
JM
1025 ** Create the exeuction info window.
1026 */
c906108c
SS
1027 if (type == SRC_WIN)
1028 executionInfo = sourceExecInfoWinPtr ();
1029 else
1030 executionInfo = disassemExecInfoWinPtr ();
1031 _initAndMakeWin ((Opaque *) & executionInfo,
1032 EXEC_INFO_WIN,
1033 height,
1034 3,
1035 0,
1036 originY,
1037 DONT_BOX_WINDOW);
1038 /*
c5aa993b
JM
1039 ** Now create the source window.
1040 */
c906108c
SS
1041 _initAndMakeWin ((Opaque *) winInfoPtr,
1042 type,
1043 height,
1044 termWidth () - executionInfo->width,
1045 executionInfo->width,
1046 originY,
1047 BOX_WINDOW);
1048
1049 (*winInfoPtr)->detail.sourceInfo.executionInfo = executionInfo;
1050
1051 return;
1052} /* _makeSourceOrDisassemWindow */
1053
1054
1055/*
c5aa993b
JM
1056 ** _showSourceOrDisassemAndCommand().
1057 ** Show the Source/Command or the Disassem layout
1058 */
c906108c 1059static void
eca6576c 1060_showSourceOrDisassemAndCommand (TuiLayoutType layoutType)
c906108c
SS
1061{
1062 if (currentLayout () != layoutType)
1063 {
1064 TuiWinInfoPtr *winInfoPtr;
c906108c
SS
1065 int srcHeight, cmdHeight;
1066 TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
1067
1068 if (m_winPtrNotNull (cmdWin))
1069 cmdHeight = cmdWin->generic.height;
1070 else
1071 cmdHeight = termHeight () / 3;
1072 srcHeight = termHeight () - cmdHeight;
1073
1074
1075 if (layoutType == SRC_COMMAND)
1076 winInfoPtr = &srcWin;
1077 else
1078 winInfoPtr = &disassemWin;
1079
1080 if (m_winPtrIsNull (*winInfoPtr))
1081 {
1082 if (layoutType == SRC_COMMAND)
1083 _makeSourceWindow (winInfoPtr, srcHeight - 1, 0);
1084 else
1085 _makeDisassemWindow (winInfoPtr, srcHeight - 1, 0);
1086 _initAndMakeWin ((Opaque *) & locator,
1087 LOCATOR_WIN,
1088 2 /* 1 */ ,
1089 termWidth (),
1090 0,
1091 srcHeight - 1,
1092 DONT_BOX_WINDOW);
1093 }
1094 else
1095 {
1096 _initGenWinInfo (locator,
1097 LOCATOR_WIN,
1098 2 /* 1 */ ,
1099 termWidth (),
1100 0,
1101 srcHeight - 1);
1102 (*winInfoPtr)->detail.sourceInfo.hasLocator = TRUE;
1103 _initGenWinInfo (
1104 &(*winInfoPtr)->generic,
1105 (*winInfoPtr)->generic.type,
1106 srcHeight - 1,
1107 (*winInfoPtr)->generic.width,
1108 (*winInfoPtr)->detail.sourceInfo.executionInfo->width,
1109 0);
1110 _initGenWinInfo ((*winInfoPtr)->detail.sourceInfo.executionInfo,
1111 EXEC_INFO_WIN,
1112 srcHeight - 1,
1113 3,
1114 0,
1115 0);
1116 (*winInfoPtr)->canHighlight = TRUE;
1117 m_beVisible (*winInfoPtr);
1118 m_beVisible ((*winInfoPtr)->detail.sourceInfo.executionInfo);
1119 }
1120 if (m_winPtrNotNull (*winInfoPtr))
1121 {
1122 (*winInfoPtr)->detail.sourceInfo.hasLocator = TRUE;
1123 m_beVisible (locator);
1124 tuiShowLocatorContent ();
1125 tuiShowSourceContent (*winInfoPtr);
1126
1127 if (m_winPtrIsNull (cmdWin))
1128 {
1129 _makeCommandWindow (&cmdWin, cmdHeight, srcHeight);
1130 tuiRefreshWin (&cmdWin->generic);
1131 }
1132 else
1133 {
1134 _initGenWinInfo (&cmdWin->generic,
1135 cmdWin->generic.type,
1136 cmdWin->generic.height,
1137 cmdWin->generic.width,
1138 cmdWin->generic.origin.x,
1139 cmdWin->generic.origin.y);
1140 cmdWin->canHighlight = FALSE;
1141 m_beVisible (cmdWin);
1142 }
1143 }
1144 setCurrentLayoutTo (layoutType);
1145 }
1146
1147 return;
1148} /* _showSourceOrDisassemAndCommand */
This page took 0.396536 seconds and 4 git commands to generate.