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