1 /* TUI layout window management.
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
4 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>. */
31 #include "tui/tui-data.h"
32 #include "tui/tui-windata.h"
33 #include "tui/tui-wingeneral.h"
34 #include "tui/tui-stack.h"
35 #include "tui/tui-regs.h"
36 #include "tui/tui-win.h"
37 #include "tui/tui-winsource.h"
38 #include "tui/tui-disasm.h"
40 #include "gdb_string.h"
41 #include "gdb_curses.h"
43 /*******************************
45 ********************************/
46 static void show_layout (enum tui_layout_type
);
47 static void init_gen_win_info (struct tui_gen_win_info
*,
50 static void *init_and_make_win (void *, enum tui_win_type
,
51 int, int, int, int, int);
52 static void show_source_or_disasm_and_command (enum tui_layout_type
);
53 static void make_source_or_disasm_window (struct tui_win_info
**,
56 static void make_command_window (struct tui_win_info
**, int, int);
57 static void make_source_window (struct tui_win_info
**, int, int);
58 static void make_disasm_window (struct tui_win_info
**, int, int);
59 static void make_data_window (struct tui_win_info
**, int, int);
60 static void show_source_command (void);
61 static void show_disasm_command (void);
62 static void show_source_disasm_command (void);
63 static void show_data (enum tui_layout_type
);
64 static enum tui_layout_type
next_layout (void);
65 static enum tui_layout_type
prev_layout (void);
66 static void tui_layout_command (char *, int);
67 static void tui_toggle_layout_command (char *, int);
68 static void tui_toggle_split_layout_command (char *, int);
69 static CORE_ADDR
extract_display_start_addr (void);
70 static void tui_handle_xdb_layout (struct tui_layout_def
*);
73 /***************************************
75 ***************************************/
77 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
79 /* Show the screen layout defined. */
81 show_layout (enum tui_layout_type layout
)
83 enum tui_layout_type cur_layout
= tui_current_layout ();
85 if (layout
!= cur_layout
)
87 /* Since the new layout may cause changes in window size, we
88 should free the content and reallocate on next display of
90 tui_free_all_source_wins_content ();
91 tui_clear_source_windows ();
92 if (layout
== SRC_DATA_COMMAND
93 || layout
== DISASSEM_DATA_COMMAND
)
96 tui_refresh_all (tui_win_list
);
100 /* First make the current layout be invisible. */
101 tui_make_all_invisible ();
102 tui_make_invisible (tui_locator_win_info_ptr ());
106 /* Now show the new layout. */
108 show_source_command ();
109 tui_add_to_source_windows (TUI_SRC_WIN
);
111 case DISASSEM_COMMAND
:
112 show_disasm_command ();
113 tui_add_to_source_windows (TUI_DISASM_WIN
);
115 case SRC_DISASSEM_COMMAND
:
116 show_source_disasm_command ();
117 tui_add_to_source_windows (TUI_SRC_WIN
);
118 tui_add_to_source_windows (TUI_DISASM_WIN
);
128 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
129 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
130 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
131 UNDEFINED_LAYOUT, then the data window is populated according to
132 regs_display_type. */
134 tui_set_layout (enum tui_layout_type layout_type
,
135 enum tui_register_display_type regs_display_type
)
137 enum tui_status status
= TUI_SUCCESS
;
139 if (layout_type
!= UNDEFINED_LAYOUT
140 || regs_display_type
!= TUI_UNDEFINED_REGS
)
142 enum tui_layout_type cur_layout
= tui_current_layout (),
143 new_layout
= UNDEFINED_LAYOUT
;
144 int regs_populate
= FALSE
;
145 CORE_ADDR addr
= extract_display_start_addr ();
146 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
147 struct tui_layout_def
*layout_def
= tui_layout_def ();
150 if (layout_type
== UNDEFINED_LAYOUT
151 && regs_display_type
!= TUI_UNDEFINED_REGS
)
153 if (cur_layout
== SRC_DISASSEM_COMMAND
)
154 new_layout
= DISASSEM_DATA_COMMAND
;
155 else if (cur_layout
== SRC_COMMAND
156 || cur_layout
== SRC_DATA_COMMAND
)
157 new_layout
= SRC_DATA_COMMAND
;
158 else if (cur_layout
== DISASSEM_COMMAND
159 || cur_layout
== DISASSEM_DATA_COMMAND
)
160 new_layout
= DISASSEM_DATA_COMMAND
;
163 new_layout
= layout_type
;
165 regs_populate
= (new_layout
== SRC_DATA_COMMAND
166 || new_layout
== DISASSEM_DATA_COMMAND
167 || regs_display_type
!= TUI_UNDEFINED_REGS
);
168 if (new_layout
!= cur_layout
169 || regs_display_type
!= TUI_UNDEFINED_REGS
)
171 if (new_layout
!= cur_layout
)
173 show_layout (new_layout
);
175 /* Now determine where focus should be. */
176 if (win_with_focus
!= TUI_CMD_WIN
)
181 tui_set_win_focus_to (TUI_SRC_WIN
);
182 layout_def
->display_mode
= SRC_WIN
;
183 layout_def
->split
= FALSE
;
185 case DISASSEM_COMMAND
:
186 /* The previous layout was not showing code.
187 This can happen if there is no source
190 1. if the source file is in another dir OR
191 2. if target was compiled without -g
192 We still want to show the assembly though! */
194 addr
= tui_get_begin_asm_address ();
195 tui_set_win_focus_to (TUI_DISASM_WIN
);
196 layout_def
->display_mode
= DISASSEM_WIN
;
197 layout_def
->split
= FALSE
;
199 case SRC_DISASSEM_COMMAND
:
200 /* The previous layout was not showing code.
201 This can happen if there is no source
204 1. if the source file is in another dir OR
205 2. if target was compiled without -g
206 We still want to show the assembly though! */
208 addr
= tui_get_begin_asm_address ();
209 if (win_with_focus
== TUI_SRC_WIN
)
210 tui_set_win_focus_to (TUI_SRC_WIN
);
212 tui_set_win_focus_to (TUI_DISASM_WIN
);
213 layout_def
->split
= TRUE
;
215 case SRC_DATA_COMMAND
:
216 if (win_with_focus
!= TUI_DATA_WIN
)
217 tui_set_win_focus_to (TUI_SRC_WIN
);
219 tui_set_win_focus_to (TUI_DATA_WIN
);
220 layout_def
->display_mode
= SRC_WIN
;
221 layout_def
->split
= FALSE
;
223 case DISASSEM_DATA_COMMAND
:
224 /* The previous layout was not showing code.
225 This can happen if there is no source
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! */
232 addr
= tui_get_begin_asm_address ();
233 if (win_with_focus
!= TUI_DATA_WIN
)
234 tui_set_win_focus_to (TUI_DISASM_WIN
);
236 tui_set_win_focus_to (TUI_DATA_WIN
);
237 layout_def
->display_mode
= DISASSEM_WIN
;
238 layout_def
->split
= FALSE
;
245 * Now update the window content.
248 && (new_layout
== SRC_DATA_COMMAND
249 || new_layout
== DISASSEM_DATA_COMMAND
))
250 tui_display_all_data ();
252 tui_update_source_windows_with_addr (addr
);
256 tui_show_registers (TUI_DATA_WIN
->detail
.data_display_info
.current_group
);
261 status
= TUI_FAILURE
;
266 /* Add the specified window to the layout in a logical way. This
267 means setting up the most logical layout given the window to be
270 tui_add_win_to_layout (enum tui_win_type type
)
272 enum tui_layout_type cur_layout
= tui_current_layout ();
277 if (cur_layout
!= SRC_COMMAND
278 && cur_layout
!= SRC_DISASSEM_COMMAND
279 && cur_layout
!= SRC_DATA_COMMAND
)
281 tui_clear_source_windows_detail ();
282 if (cur_layout
== DISASSEM_DATA_COMMAND
)
283 show_layout (SRC_DATA_COMMAND
);
285 show_layout (SRC_COMMAND
);
289 if (cur_layout
!= DISASSEM_COMMAND
290 && cur_layout
!= SRC_DISASSEM_COMMAND
291 && cur_layout
!= DISASSEM_DATA_COMMAND
)
293 tui_clear_source_windows_detail ();
294 if (cur_layout
== SRC_DATA_COMMAND
)
295 show_layout (DISASSEM_DATA_COMMAND
);
297 show_layout (DISASSEM_COMMAND
);
301 if (cur_layout
!= SRC_DATA_COMMAND
302 && cur_layout
!= DISASSEM_DATA_COMMAND
)
304 if (cur_layout
== DISASSEM_COMMAND
)
305 show_layout (DISASSEM_DATA_COMMAND
);
307 show_layout (SRC_DATA_COMMAND
);
316 /* Answer the height of a window. If it hasn't been created yet,
317 answer what the height of a window would be based upon its type and
320 tui_default_win_height (enum tui_win_type type
,
321 enum tui_layout_type layout
)
325 if (tui_win_list
[type
] != (struct tui_win_info
*) NULL
)
326 h
= tui_win_list
[type
]->generic
.height
;
332 case DISASSEM_COMMAND
:
333 if (TUI_CMD_WIN
== NULL
)
334 h
= tui_term_height () / 2;
336 h
= tui_term_height () - TUI_CMD_WIN
->generic
.height
;
338 case SRC_DISASSEM_COMMAND
:
339 case SRC_DATA_COMMAND
:
340 case DISASSEM_DATA_COMMAND
:
341 if (TUI_CMD_WIN
== NULL
)
342 h
= tui_term_height () / 3;
344 h
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
) / 2;
356 /* Answer the height of a window. If it hasn't been created yet,
357 answer what the height of a window would be based upon its type and
360 tui_default_win_viewport_height (enum tui_win_type type
,
361 enum tui_layout_type layout
)
365 h
= tui_default_win_height (type
, layout
);
367 if (tui_win_list
[type
] == TUI_CMD_WIN
)
376 /* Function to initialize gdb commands, for tui window layout
379 _initialize_tui_layout (void)
381 add_com ("layout", class_tui
, tui_layout_command
, _("\
382 Change the layout of windows.\n\
383 Usage: layout prev | next | <layout_name> \n\
385 src : Displays source and command windows.\n\
386 asm : Displays disassembly and command windows.\n\
387 split : Displays source, disassembly and command windows.\n\
388 regs : Displays register window. If existing layout\n\
389 is source/command or assembly/command, the \n\
390 register window is displayed. If the\n\
391 source/assembly/command (split) is displayed, \n\
392 the register window is displayed with \n\
393 the window that has current logical focus.\n"));
396 add_com ("td", class_tui
, tui_toggle_layout_command
, _("\
397 Toggle between Source/Command and Disassembly/Command layouts.\n"));
398 add_com ("ts", class_tui
, tui_toggle_split_layout_command
, _("\
399 Toggle between Source/Command or Disassembly/Command and \n\
400 Source/Disassembly/Command layouts.\n"));
405 /*************************
406 ** STATIC LOCAL FUNCTIONS
407 **************************/
410 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
411 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
413 tui_set_layout_for_display_command (const char *layout_name
)
415 enum tui_status status
= TUI_SUCCESS
;
417 if (layout_name
!= (char *) NULL
)
421 enum tui_layout_type new_layout
= UNDEFINED_LAYOUT
;
422 enum tui_register_display_type dpy_type
= TUI_UNDEFINED_REGS
;
423 enum tui_layout_type cur_layout
= tui_current_layout ();
425 buf_ptr
= (char *) xstrdup (layout_name
);
426 for (i
= 0; (i
< strlen (layout_name
)); i
++)
427 buf_ptr
[i
] = toupper (buf_ptr
[i
]);
429 /* First check for ambiguous input. */
430 if (strlen (buf_ptr
) <= 1
431 && (*buf_ptr
== 'S' || *buf_ptr
== '$'))
433 warning (_("Ambiguous command input."));
434 status
= TUI_FAILURE
;
438 if (subset_compare (buf_ptr
, "SRC"))
439 new_layout
= SRC_COMMAND
;
440 else if (subset_compare (buf_ptr
, "ASM"))
441 new_layout
= DISASSEM_COMMAND
;
442 else if (subset_compare (buf_ptr
, "SPLIT"))
443 new_layout
= SRC_DISASSEM_COMMAND
;
444 else if (subset_compare (buf_ptr
, "REGS")
445 || subset_compare (buf_ptr
, TUI_GENERAL_SPECIAL_REGS_NAME
)
446 || subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
)
447 || subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
)
448 || subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
450 if (cur_layout
== SRC_COMMAND
451 || cur_layout
== SRC_DATA_COMMAND
)
452 new_layout
= SRC_DATA_COMMAND
;
454 new_layout
= DISASSEM_DATA_COMMAND
;
456 /* Could ifdef out the following code. when compile with
457 -z, there are null pointer references that cause a
458 core dump if 'layout regs' is the first layout
459 command issued by the user. HP has asked us to hook
460 up this code. - edie epstein */
461 if (subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
))
463 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!= TUI_SFLOAT_REGS
464 && TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!= TUI_DFLOAT_REGS
)
465 dpy_type
= TUI_SFLOAT_REGS
;
468 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
470 else if (subset_compare (buf_ptr
,
471 TUI_GENERAL_SPECIAL_REGS_NAME
))
472 dpy_type
= TUI_GENERAL_AND_SPECIAL_REGS
;
473 else if (subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
))
474 dpy_type
= TUI_GENERAL_REGS
;
475 else if (subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
476 dpy_type
= TUI_SPECIAL_REGS
;
477 else if (TUI_DATA_WIN
)
479 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!=
482 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
484 dpy_type
= TUI_GENERAL_REGS
;
487 /* End of potential ifdef.
490 /* If ifdefed out code above, then assume that the user
491 wishes to display the general purpose registers .
494 /* dpy_type = TUI_GENERAL_REGS; */
496 else if (subset_compare (buf_ptr
, "NEXT"))
497 new_layout
= next_layout ();
498 else if (subset_compare (buf_ptr
, "PREV"))
499 new_layout
= prev_layout ();
501 status
= TUI_FAILURE
;
503 tui_set_layout (new_layout
, dpy_type
);
508 status
= TUI_FAILURE
;
515 extract_display_start_addr (void)
517 enum tui_layout_type cur_layout
= tui_current_layout ();
520 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
525 case SRC_DATA_COMMAND
:
526 find_line_pc (cursal
.symtab
,
527 TUI_SRC_WIN
->detail
.source_info
.start_line_or_addr
.u
.line_no
,
531 case DISASSEM_COMMAND
:
532 case SRC_DISASSEM_COMMAND
:
533 case DISASSEM_DATA_COMMAND
:
534 addr
= TUI_DISASM_WIN
->detail
.source_info
.start_line_or_addr
.u
.addr
;
546 tui_handle_xdb_layout (struct tui_layout_def
*layout_def
)
548 if (layout_def
->split
)
550 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
551 tui_set_win_focus_to (tui_win_list
[layout_def
->display_mode
]);
555 if (layout_def
->display_mode
== SRC_WIN
)
556 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
558 tui_set_layout (DISASSEM_DATA_COMMAND
, layout_def
->regs_display_type
);
564 tui_toggle_layout_command (char *arg
, int from_tty
)
566 struct tui_layout_def
*layout_def
= tui_layout_def ();
568 /* Make sure the curses mode is enabled. */
570 if (layout_def
->display_mode
== SRC_WIN
)
571 layout_def
->display_mode
= DISASSEM_WIN
;
573 layout_def
->display_mode
= SRC_WIN
;
575 if (!layout_def
->split
)
576 tui_handle_xdb_layout (layout_def
);
581 tui_toggle_split_layout_command (char *arg
, int from_tty
)
583 struct tui_layout_def
*layout_def
= tui_layout_def ();
585 /* Make sure the curses mode is enabled. */
587 layout_def
->split
= (!layout_def
->split
);
588 tui_handle_xdb_layout (layout_def
);
593 tui_layout_command (char *arg
, int from_tty
)
595 /* Make sure the curses mode is enabled. */
598 /* Switch to the selected layout. */
599 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
600 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE
);
604 /* Answer the previous layout to cycle to. */
605 static enum tui_layout_type
608 enum tui_layout_type new_layout
;
610 new_layout
= tui_current_layout ();
611 if (new_layout
== UNDEFINED_LAYOUT
)
612 new_layout
= SRC_COMMAND
;
616 if (new_layout
== UNDEFINED_LAYOUT
)
617 new_layout
= SRC_COMMAND
;
624 /* Answer the next layout to cycle to. */
625 static enum tui_layout_type
628 enum tui_layout_type new_layout
;
630 new_layout
= tui_current_layout ();
631 if (new_layout
== SRC_COMMAND
)
632 new_layout
= DISASSEM_DATA_COMMAND
;
636 if (new_layout
== UNDEFINED_LAYOUT
)
637 new_layout
= DISASSEM_DATA_COMMAND
;
646 make_command_window (struct tui_win_info
**win_info_ptr
,
647 int height
, int origin_y
)
649 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
657 (*win_info_ptr
)->can_highlight
= FALSE
;
661 /* make_source_window().
664 make_source_window (struct tui_win_info
**win_info_ptr
,
665 int height
, int origin_y
)
667 make_source_or_disasm_window (win_info_ptr
, SRC_WIN
, height
, origin_y
);
670 } /* make_source_window */
673 /* make_disasm_window().
676 make_disasm_window (struct tui_win_info
**win_info_ptr
,
677 int height
, int origin_y
)
679 make_source_or_disasm_window (win_info_ptr
, DISASSEM_WIN
, height
, origin_y
);
682 } /* make_disasm_window */
686 make_data_window (struct tui_win_info
**win_info_ptr
,
687 int height
, int origin_y
)
689 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
700 /* Show the Source/Command layout. */
702 show_source_command (void)
704 show_source_or_disasm_and_command (SRC_COMMAND
);
708 /* Show the Dissassem/Command layout. */
710 show_disasm_command (void)
712 show_source_or_disasm_and_command (DISASSEM_COMMAND
);
716 /* Show the Source/Disassem/Command layout. */
718 show_source_disasm_command (void)
720 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
722 int cmd_height
, src_height
, asm_height
;
724 if (TUI_CMD_WIN
!= NULL
)
725 cmd_height
= TUI_CMD_WIN
->generic
.height
;
727 cmd_height
= tui_term_height () / 3;
729 src_height
= (tui_term_height () - cmd_height
) / 2;
730 asm_height
= tui_term_height () - (src_height
+ cmd_height
);
732 if (TUI_SRC_WIN
== NULL
)
733 make_source_window (&TUI_SRC_WIN
, src_height
, 0);
736 init_gen_win_info (&TUI_SRC_WIN
->generic
,
737 TUI_SRC_WIN
->generic
.type
,
739 TUI_SRC_WIN
->generic
.width
,
740 TUI_SRC_WIN
->detail
.source_info
.execution_info
->width
,
742 TUI_SRC_WIN
->can_highlight
= TRUE
;
743 init_gen_win_info (TUI_SRC_WIN
->detail
.source_info
.execution_info
,
749 tui_make_visible (&TUI_SRC_WIN
->generic
);
750 tui_make_visible (TUI_SRC_WIN
->detail
.source_info
.execution_info
);
751 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;;
753 if (TUI_SRC_WIN
!= NULL
)
755 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
757 tui_show_source_content (TUI_SRC_WIN
);
758 if (TUI_DISASM_WIN
== NULL
)
760 make_disasm_window (&TUI_DISASM_WIN
, asm_height
, src_height
- 1);
761 locator
= init_and_make_win (locator
,
766 (src_height
+ asm_height
) - 1,
771 init_gen_win_info (locator
,
776 (src_height
+ asm_height
) - 1);
777 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
778 init_gen_win_info (&TUI_DISASM_WIN
->generic
,
779 TUI_DISASM_WIN
->generic
.type
,
781 TUI_DISASM_WIN
->generic
.width
,
782 TUI_DISASM_WIN
->detail
.source_info
.execution_info
->width
,
784 init_gen_win_info (TUI_DISASM_WIN
->detail
.source_info
.execution_info
,
790 TUI_DISASM_WIN
->can_highlight
= TRUE
;
791 tui_make_visible (&TUI_DISASM_WIN
->generic
);
792 tui_make_visible (TUI_DISASM_WIN
->detail
.source_info
.execution_info
);
794 if (TUI_DISASM_WIN
!= NULL
)
796 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;
797 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
798 tui_make_visible (locator
);
799 tui_show_locator_content ();
800 tui_show_source_content (TUI_DISASM_WIN
);
802 if (TUI_CMD_WIN
== NULL
)
803 make_command_window (&TUI_CMD_WIN
,
805 tui_term_height () - cmd_height
);
808 init_gen_win_info (&TUI_CMD_WIN
->generic
,
809 TUI_CMD_WIN
->generic
.type
,
810 TUI_CMD_WIN
->generic
.height
,
811 TUI_CMD_WIN
->generic
.width
,
813 TUI_CMD_WIN
->generic
.origin
.y
);
814 TUI_CMD_WIN
->can_highlight
= FALSE
;
815 tui_make_visible (&TUI_CMD_WIN
->generic
);
817 if (TUI_CMD_WIN
!= NULL
)
818 tui_refresh_win (&TUI_CMD_WIN
->generic
);
821 tui_set_current_layout_to (SRC_DISASSEM_COMMAND
);
826 /* Show the Source/Data/Command or the Dissassembly/Data/Command
829 show_data (enum tui_layout_type new_layout
)
831 int total_height
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
);
832 int src_height
, data_height
;
833 enum tui_win_type win_type
;
834 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
837 data_height
= total_height
/ 2;
838 src_height
= total_height
- data_height
;
839 tui_make_all_invisible ();
840 tui_make_invisible (locator
);
841 make_data_window (&TUI_DATA_WIN
, data_height
, 0);
842 TUI_DATA_WIN
->can_highlight
= TRUE
;
843 if (new_layout
== SRC_DATA_COMMAND
)
846 win_type
= DISASSEM_WIN
;
847 if (tui_win_list
[win_type
] == NULL
)
849 if (win_type
== SRC_WIN
)
850 make_source_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
852 make_disasm_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
853 locator
= init_and_make_win (locator
,
863 init_gen_win_info (&tui_win_list
[win_type
]->generic
,
864 tui_win_list
[win_type
]->generic
.type
,
866 tui_win_list
[win_type
]->generic
.width
,
867 tui_win_list
[win_type
]->detail
.source_info
.execution_info
->width
,
869 init_gen_win_info (tui_win_list
[win_type
]->detail
.source_info
.execution_info
,
875 tui_make_visible (&tui_win_list
[win_type
]->generic
);
876 tui_make_visible (tui_win_list
[win_type
]->detail
.source_info
.execution_info
);
877 init_gen_win_info (locator
,
884 tui_win_list
[win_type
]->detail
.source_info
.has_locator
= TRUE
;
885 tui_make_visible (locator
);
886 tui_show_locator_content ();
887 tui_add_to_source_windows (tui_win_list
[win_type
]);
888 tui_set_current_layout_to (new_layout
);
891 /* init_gen_win_info().
894 init_gen_win_info (struct tui_gen_win_info
*win_info
,
895 enum tui_win_type type
,
896 int height
, int width
,
897 int origin_x
, int origin_y
)
901 win_info
->type
= type
;
902 win_info
->width
= width
;
903 win_info
->height
= h
;
906 win_info
->viewport_height
= h
- 1;
907 if (win_info
->type
!= CMD_WIN
)
908 win_info
->viewport_height
--;
911 win_info
->viewport_height
= 1;
912 win_info
->origin
.x
= origin_x
;
913 win_info
->origin
.y
= origin_y
;
916 } /* init_gen_win_info */
918 /* init_and_make_win().
921 init_and_make_win (void *opaque_win_info
,
922 enum tui_win_type win_type
,
923 int height
, int width
,
924 int origin_x
, int origin_y
,
927 struct tui_gen_win_info
*generic
;
929 if (opaque_win_info
== NULL
)
931 if (tui_win_is_auxillary (win_type
))
932 opaque_win_info
= (void *) tui_alloc_generic_win_info ();
934 opaque_win_info
= (void *) tui_alloc_win_info (win_type
);
936 if (tui_win_is_auxillary (win_type
))
937 generic
= (struct tui_gen_win_info
*) opaque_win_info
;
939 generic
= &((struct tui_win_info
*) opaque_win_info
)->generic
;
941 if (opaque_win_info
!= NULL
)
943 init_gen_win_info (generic
, win_type
, height
, width
, origin_x
, origin_y
);
944 if (!tui_win_is_auxillary (win_type
))
946 if (generic
->type
== CMD_WIN
)
947 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= FALSE
;
949 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= TRUE
;
951 tui_make_window (generic
, box_it
);
953 return opaque_win_info
;
958 make_source_or_disasm_window (struct tui_win_info
**win_info_ptr
,
959 enum tui_win_type type
,
960 int height
, int origin_y
)
962 struct tui_gen_win_info
*execution_info
= (struct tui_gen_win_info
*) NULL
;
964 /* Create the exeuction info window. */
966 execution_info
= tui_source_exec_info_win_ptr ();
968 execution_info
= tui_disassem_exec_info_win_ptr ();
969 execution_info
= init_and_make_win (execution_info
,
977 /* Now create the source window. */
978 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
981 tui_term_width () - execution_info
->width
,
982 execution_info
->width
,
986 (*win_info_ptr
)->detail
.source_info
.execution_info
= execution_info
;
990 /* Show the Source/Command or the Disassem layout. */
992 show_source_or_disasm_and_command (enum tui_layout_type layout_type
)
994 if (tui_current_layout () != layout_type
)
996 struct tui_win_info
**win_info_ptr
;
997 int src_height
, cmd_height
;
998 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
1000 if (TUI_CMD_WIN
!= NULL
)
1001 cmd_height
= TUI_CMD_WIN
->generic
.height
;
1003 cmd_height
= tui_term_height () / 3;
1004 src_height
= tui_term_height () - cmd_height
;
1006 if (layout_type
== SRC_COMMAND
)
1007 win_info_ptr
= &TUI_SRC_WIN
;
1009 win_info_ptr
= &TUI_DISASM_WIN
;
1011 if ((*win_info_ptr
) == NULL
)
1013 if (layout_type
== SRC_COMMAND
)
1014 make_source_window (win_info_ptr
, src_height
- 1, 0);
1016 make_disasm_window (win_info_ptr
, src_height
- 1, 0);
1017 locator
= init_and_make_win (locator
,
1027 init_gen_win_info (locator
,
1033 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1034 init_gen_win_info (&(*win_info_ptr
)->generic
,
1035 (*win_info_ptr
)->generic
.type
,
1037 (*win_info_ptr
)->generic
.width
,
1038 (*win_info_ptr
)->detail
.source_info
.execution_info
->width
,
1040 init_gen_win_info ((*win_info_ptr
)->detail
.source_info
.execution_info
,
1046 (*win_info_ptr
)->can_highlight
= TRUE
;
1047 tui_make_visible (&(*win_info_ptr
)->generic
);
1048 tui_make_visible ((*win_info_ptr
)->detail
.source_info
.execution_info
);
1050 if ((*win_info_ptr
) != NULL
)
1052 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1053 tui_make_visible (locator
);
1054 tui_show_locator_content ();
1055 tui_show_source_content (*win_info_ptr
);
1057 if (TUI_CMD_WIN
== NULL
)
1059 make_command_window (&TUI_CMD_WIN
, cmd_height
, src_height
);
1060 tui_refresh_win (&TUI_CMD_WIN
->generic
);
1064 init_gen_win_info (&TUI_CMD_WIN
->generic
,
1065 TUI_CMD_WIN
->generic
.type
,
1066 TUI_CMD_WIN
->generic
.height
,
1067 TUI_CMD_WIN
->generic
.width
,
1068 TUI_CMD_WIN
->generic
.origin
.x
,
1069 TUI_CMD_WIN
->generic
.origin
.y
);
1070 TUI_CMD_WIN
->can_highlight
= FALSE
;
1071 tui_make_visible (&TUI_CMD_WIN
->generic
);
1074 tui_set_current_layout_to (layout_type
);