1 /* TUI layout window management.
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009,
4 2010, 2011 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/>. */
24 #include "arch-utils.h"
32 #include "tui/tui-data.h"
33 #include "tui/tui-windata.h"
34 #include "tui/tui-wingeneral.h"
35 #include "tui/tui-stack.h"
36 #include "tui/tui-regs.h"
37 #include "tui/tui-win.h"
38 #include "tui/tui-winsource.h"
39 #include "tui/tui-disasm.h"
40 #include "tui/tui-layout.h"
42 #include "gdb_string.h"
43 #include "gdb_curses.h"
45 /*******************************
47 ********************************/
48 static void show_layout (enum tui_layout_type
);
49 static void init_gen_win_info (struct tui_gen_win_info
*,
52 static void *init_and_make_win (void *, enum tui_win_type
,
53 int, int, int, int, int);
54 static void show_source_or_disasm_and_command (enum tui_layout_type
);
55 static void make_source_or_disasm_window (struct tui_win_info
**,
58 static void make_command_window (struct tui_win_info
**, int, int);
59 static void make_source_window (struct tui_win_info
**, int, int);
60 static void make_disasm_window (struct tui_win_info
**, int, int);
61 static void make_data_window (struct tui_win_info
**, int, int);
62 static void show_source_command (void);
63 static void show_disasm_command (void);
64 static void show_source_disasm_command (void);
65 static void show_data (enum tui_layout_type
);
66 static enum tui_layout_type
next_layout (void);
67 static enum tui_layout_type
prev_layout (void);
68 static void tui_layout_command (char *, int);
69 static void tui_toggle_layout_command (char *, int);
70 static void tui_toggle_split_layout_command (char *, int);
71 static void extract_display_start_addr (struct gdbarch
**, CORE_ADDR
*);
72 static void tui_handle_xdb_layout (struct tui_layout_def
*);
75 /***************************************
77 ***************************************/
79 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
81 /* Show the screen layout defined. */
83 show_layout (enum tui_layout_type layout
)
85 enum tui_layout_type cur_layout
= tui_current_layout ();
87 if (layout
!= cur_layout
)
89 /* Since the new layout may cause changes in window size, we
90 should free the content and reallocate on next display of
92 tui_free_all_source_wins_content ();
93 tui_clear_source_windows ();
94 if (layout
== SRC_DATA_COMMAND
95 || layout
== DISASSEM_DATA_COMMAND
)
98 tui_refresh_all (tui_win_list
);
102 /* First make the current layout be invisible. */
103 tui_make_all_invisible ();
104 tui_make_invisible (tui_locator_win_info_ptr ());
108 /* Now show the new layout. */
110 show_source_command ();
111 tui_add_to_source_windows (TUI_SRC_WIN
);
113 case DISASSEM_COMMAND
:
114 show_disasm_command ();
115 tui_add_to_source_windows (TUI_DISASM_WIN
);
117 case SRC_DISASSEM_COMMAND
:
118 show_source_disasm_command ();
119 tui_add_to_source_windows (TUI_SRC_WIN
);
120 tui_add_to_source_windows (TUI_DISASM_WIN
);
130 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
131 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
132 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
133 UNDEFINED_LAYOUT, then the data window is populated according to
134 regs_display_type. */
136 tui_set_layout (enum tui_layout_type layout_type
,
137 enum tui_register_display_type regs_display_type
)
139 enum tui_status status
= TUI_SUCCESS
;
141 if (layout_type
!= UNDEFINED_LAYOUT
142 || regs_display_type
!= TUI_UNDEFINED_REGS
)
144 enum tui_layout_type cur_layout
= tui_current_layout (),
145 new_layout
= UNDEFINED_LAYOUT
;
146 int regs_populate
= FALSE
;
147 struct gdbarch
*gdbarch
;
149 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
150 struct tui_layout_def
*layout_def
= tui_layout_def ();
152 extract_display_start_addr (&gdbarch
, &addr
);
154 if (layout_type
== UNDEFINED_LAYOUT
155 && regs_display_type
!= TUI_UNDEFINED_REGS
)
157 if (cur_layout
== SRC_DISASSEM_COMMAND
)
158 new_layout
= DISASSEM_DATA_COMMAND
;
159 else if (cur_layout
== SRC_COMMAND
160 || cur_layout
== SRC_DATA_COMMAND
)
161 new_layout
= SRC_DATA_COMMAND
;
162 else if (cur_layout
== DISASSEM_COMMAND
163 || cur_layout
== DISASSEM_DATA_COMMAND
)
164 new_layout
= DISASSEM_DATA_COMMAND
;
167 new_layout
= layout_type
;
169 regs_populate
= (new_layout
== SRC_DATA_COMMAND
170 || new_layout
== DISASSEM_DATA_COMMAND
171 || regs_display_type
!= TUI_UNDEFINED_REGS
);
172 if (new_layout
!= cur_layout
173 || regs_display_type
!= TUI_UNDEFINED_REGS
)
175 if (new_layout
!= cur_layout
)
177 show_layout (new_layout
);
179 /* Now determine where focus should be. */
180 if (win_with_focus
!= TUI_CMD_WIN
)
185 tui_set_win_focus_to (TUI_SRC_WIN
);
186 layout_def
->display_mode
= SRC_WIN
;
187 layout_def
->split
= FALSE
;
189 case DISASSEM_COMMAND
:
190 /* The previous layout was not showing code.
191 This can happen if there is no source
194 1. if the source file is in another dir OR
195 2. if target was compiled without -g
196 We still want to show the assembly though! */
198 tui_get_begin_asm_address (&gdbarch
, &addr
);
199 tui_set_win_focus_to (TUI_DISASM_WIN
);
200 layout_def
->display_mode
= DISASSEM_WIN
;
201 layout_def
->split
= FALSE
;
203 case SRC_DISASSEM_COMMAND
:
204 /* The previous layout was not showing code.
205 This can happen if there is no source
208 1. if the source file is in another dir OR
209 2. if target was compiled without -g
210 We still want to show the assembly though! */
212 tui_get_begin_asm_address (&gdbarch
, &addr
);
213 if (win_with_focus
== TUI_SRC_WIN
)
214 tui_set_win_focus_to (TUI_SRC_WIN
);
216 tui_set_win_focus_to (TUI_DISASM_WIN
);
217 layout_def
->split
= TRUE
;
219 case SRC_DATA_COMMAND
:
220 if (win_with_focus
!= TUI_DATA_WIN
)
221 tui_set_win_focus_to (TUI_SRC_WIN
);
223 tui_set_win_focus_to (TUI_DATA_WIN
);
224 layout_def
->display_mode
= SRC_WIN
;
225 layout_def
->split
= FALSE
;
227 case DISASSEM_DATA_COMMAND
:
228 /* The previous layout was not showing code.
229 This can happen if there is no source
232 1. if the source file is in another dir OR
233 2. if target was compiled without -g
234 We still want to show the assembly though! */
236 tui_get_begin_asm_address (&gdbarch
, &addr
);
237 if (win_with_focus
!= TUI_DATA_WIN
)
238 tui_set_win_focus_to (TUI_DISASM_WIN
);
240 tui_set_win_focus_to (TUI_DATA_WIN
);
241 layout_def
->display_mode
= DISASSEM_WIN
;
242 layout_def
->split
= FALSE
;
249 * Now update the window content.
252 && (new_layout
== SRC_DATA_COMMAND
253 || new_layout
== DISASSEM_DATA_COMMAND
))
254 tui_display_all_data ();
256 tui_update_source_windows_with_addr (gdbarch
, addr
);
260 tui_show_registers (TUI_DATA_WIN
->detail
.data_display_info
.current_group
);
265 status
= TUI_FAILURE
;
270 /* Add the specified window to the layout in a logical way. This
271 means setting up the most logical layout given the window to be
274 tui_add_win_to_layout (enum tui_win_type type
)
276 enum tui_layout_type cur_layout
= tui_current_layout ();
281 if (cur_layout
!= SRC_COMMAND
282 && cur_layout
!= SRC_DISASSEM_COMMAND
283 && cur_layout
!= SRC_DATA_COMMAND
)
285 tui_clear_source_windows_detail ();
286 if (cur_layout
== DISASSEM_DATA_COMMAND
)
287 show_layout (SRC_DATA_COMMAND
);
289 show_layout (SRC_COMMAND
);
293 if (cur_layout
!= DISASSEM_COMMAND
294 && cur_layout
!= SRC_DISASSEM_COMMAND
295 && cur_layout
!= DISASSEM_DATA_COMMAND
)
297 tui_clear_source_windows_detail ();
298 if (cur_layout
== SRC_DATA_COMMAND
)
299 show_layout (DISASSEM_DATA_COMMAND
);
301 show_layout (DISASSEM_COMMAND
);
305 if (cur_layout
!= SRC_DATA_COMMAND
306 && cur_layout
!= DISASSEM_DATA_COMMAND
)
308 if (cur_layout
== DISASSEM_COMMAND
)
309 show_layout (DISASSEM_DATA_COMMAND
);
311 show_layout (SRC_DATA_COMMAND
);
320 /* Answer the height of a window. If it hasn't been created yet,
321 answer what the height of a window would be based upon its type and
324 tui_default_win_height (enum tui_win_type type
,
325 enum tui_layout_type layout
)
329 if (tui_win_list
[type
] != (struct tui_win_info
*) NULL
)
330 h
= tui_win_list
[type
]->generic
.height
;
336 case DISASSEM_COMMAND
:
337 if (TUI_CMD_WIN
== NULL
)
338 h
= tui_term_height () / 2;
340 h
= tui_term_height () - TUI_CMD_WIN
->generic
.height
;
342 case SRC_DISASSEM_COMMAND
:
343 case SRC_DATA_COMMAND
:
344 case DISASSEM_DATA_COMMAND
:
345 if (TUI_CMD_WIN
== NULL
)
346 h
= tui_term_height () / 3;
348 h
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
) / 2;
360 /* Answer the height of a window. If it hasn't been created yet,
361 answer what the height of a window would be based upon its type and
364 tui_default_win_viewport_height (enum tui_win_type type
,
365 enum tui_layout_type layout
)
369 h
= tui_default_win_height (type
, layout
);
371 if (tui_win_list
[type
] == TUI_CMD_WIN
)
380 /* Function to initialize gdb commands, for tui window layout
383 /* Provide a prototype to silence -Wmissing-prototypes. */
384 extern initialize_file_ftype _initialize_tui_layout
;
387 _initialize_tui_layout (void)
389 add_com ("layout", class_tui
, tui_layout_command
, _("\
390 Change the layout of windows.\n\
391 Usage: layout prev | next | <layout_name> \n\
393 src : Displays source and command windows.\n\
394 asm : Displays disassembly and command windows.\n\
395 split : Displays source, disassembly and command windows.\n\
396 regs : Displays register window. If existing layout\n\
397 is source/command or assembly/command, the \n\
398 register window is displayed. If the\n\
399 source/assembly/command (split) is displayed, \n\
400 the register window is displayed with \n\
401 the window that has current logical focus.\n"));
404 add_com ("td", class_tui
, tui_toggle_layout_command
, _("\
405 Toggle between Source/Command and Disassembly/Command layouts.\n"));
406 add_com ("ts", class_tui
, tui_toggle_split_layout_command
, _("\
407 Toggle between Source/Command or Disassembly/Command and \n\
408 Source/Disassembly/Command layouts.\n"));
413 /*************************
414 ** STATIC LOCAL FUNCTIONS
415 **************************/
418 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
419 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
421 tui_set_layout_for_display_command (const char *layout_name
)
423 enum tui_status status
= TUI_SUCCESS
;
425 if (layout_name
!= (char *) NULL
)
429 enum tui_layout_type new_layout
= UNDEFINED_LAYOUT
;
430 enum tui_register_display_type dpy_type
= TUI_UNDEFINED_REGS
;
431 enum tui_layout_type cur_layout
= tui_current_layout ();
433 buf_ptr
= (char *) xstrdup (layout_name
);
434 for (i
= 0; (i
< strlen (layout_name
)); i
++)
435 buf_ptr
[i
] = toupper (buf_ptr
[i
]);
437 /* First check for ambiguous input. */
438 if (strlen (buf_ptr
) <= 1
439 && (*buf_ptr
== 'S' || *buf_ptr
== '$'))
441 warning (_("Ambiguous command input."));
442 status
= TUI_FAILURE
;
446 if (subset_compare (buf_ptr
, "SRC"))
447 new_layout
= SRC_COMMAND
;
448 else if (subset_compare (buf_ptr
, "ASM"))
449 new_layout
= DISASSEM_COMMAND
;
450 else if (subset_compare (buf_ptr
, "SPLIT"))
451 new_layout
= SRC_DISASSEM_COMMAND
;
452 else if (subset_compare (buf_ptr
, "REGS")
453 || subset_compare (buf_ptr
, TUI_GENERAL_SPECIAL_REGS_NAME
)
454 || subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
)
455 || subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
)
456 || subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
458 if (cur_layout
== SRC_COMMAND
459 || cur_layout
== SRC_DATA_COMMAND
)
460 new_layout
= SRC_DATA_COMMAND
;
462 new_layout
= DISASSEM_DATA_COMMAND
;
464 /* Could ifdef out the following code. when compile with
465 -z, there are null pointer references that cause a
466 core dump if 'layout regs' is the first layout
467 command issued by the user. HP has asked us to hook
468 up this code. - edie epstein */
469 if (subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
))
471 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!= TUI_SFLOAT_REGS
472 && TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!= TUI_DFLOAT_REGS
)
473 dpy_type
= TUI_SFLOAT_REGS
;
476 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
478 else if (subset_compare (buf_ptr
,
479 TUI_GENERAL_SPECIAL_REGS_NAME
))
480 dpy_type
= TUI_GENERAL_AND_SPECIAL_REGS
;
481 else if (subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
))
482 dpy_type
= TUI_GENERAL_REGS
;
483 else if (subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
484 dpy_type
= TUI_SPECIAL_REGS
;
485 else if (TUI_DATA_WIN
)
487 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!=
490 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
492 dpy_type
= TUI_GENERAL_REGS
;
495 /* End of potential ifdef.
498 /* If ifdefed out code above, then assume that the user
499 wishes to display the general purpose registers .
502 /* dpy_type = TUI_GENERAL_REGS; */
504 else if (subset_compare (buf_ptr
, "NEXT"))
505 new_layout
= next_layout ();
506 else if (subset_compare (buf_ptr
, "PREV"))
507 new_layout
= prev_layout ();
509 status
= TUI_FAILURE
;
511 tui_set_layout (new_layout
, dpy_type
);
516 status
= TUI_FAILURE
;
523 extract_display_start_addr (struct gdbarch
**gdbarch_p
, CORE_ADDR
*addr_p
)
525 enum tui_layout_type cur_layout
= tui_current_layout ();
526 struct gdbarch
*gdbarch
= get_current_arch ();
529 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
534 case SRC_DATA_COMMAND
:
535 gdbarch
= TUI_SRC_WIN
->detail
.source_info
.gdbarch
;
536 find_line_pc (cursal
.symtab
,
537 TUI_SRC_WIN
->detail
.source_info
.start_line_or_addr
.u
.line_no
,
541 case DISASSEM_COMMAND
:
542 case SRC_DISASSEM_COMMAND
:
543 case DISASSEM_DATA_COMMAND
:
544 gdbarch
= TUI_DISASM_WIN
->detail
.source_info
.gdbarch
;
545 addr
= TUI_DISASM_WIN
->detail
.source_info
.start_line_or_addr
.u
.addr
;
552 *gdbarch_p
= gdbarch
;
558 tui_handle_xdb_layout (struct tui_layout_def
*layout_def
)
560 if (layout_def
->split
)
562 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
563 tui_set_win_focus_to (tui_win_list
[layout_def
->display_mode
]);
567 if (layout_def
->display_mode
== SRC_WIN
)
568 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
570 tui_set_layout (DISASSEM_DATA_COMMAND
, layout_def
->regs_display_type
);
576 tui_toggle_layout_command (char *arg
, int from_tty
)
578 struct tui_layout_def
*layout_def
= tui_layout_def ();
580 /* Make sure the curses mode is enabled. */
582 if (layout_def
->display_mode
== SRC_WIN
)
583 layout_def
->display_mode
= DISASSEM_WIN
;
585 layout_def
->display_mode
= SRC_WIN
;
587 if (!layout_def
->split
)
588 tui_handle_xdb_layout (layout_def
);
593 tui_toggle_split_layout_command (char *arg
, int from_tty
)
595 struct tui_layout_def
*layout_def
= tui_layout_def ();
597 /* Make sure the curses mode is enabled. */
599 layout_def
->split
= (!layout_def
->split
);
600 tui_handle_xdb_layout (layout_def
);
605 tui_layout_command (char *arg
, int from_tty
)
607 /* Make sure the curses mode is enabled. */
610 /* Switch to the selected layout. */
611 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
612 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE
);
616 /* Answer the previous layout to cycle to. */
617 static enum tui_layout_type
620 enum tui_layout_type new_layout
;
622 new_layout
= tui_current_layout ();
623 if (new_layout
== UNDEFINED_LAYOUT
)
624 new_layout
= SRC_COMMAND
;
628 if (new_layout
== UNDEFINED_LAYOUT
)
629 new_layout
= SRC_COMMAND
;
636 /* Answer the next layout to cycle to. */
637 static enum tui_layout_type
640 enum tui_layout_type new_layout
;
642 new_layout
= tui_current_layout ();
643 if (new_layout
== SRC_COMMAND
)
644 new_layout
= DISASSEM_DATA_COMMAND
;
648 if (new_layout
== UNDEFINED_LAYOUT
)
649 new_layout
= DISASSEM_DATA_COMMAND
;
658 make_command_window (struct tui_win_info
**win_info_ptr
,
659 int height
, int origin_y
)
661 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
669 (*win_info_ptr
)->can_highlight
= FALSE
;
673 /* make_source_window().
676 make_source_window (struct tui_win_info
**win_info_ptr
,
677 int height
, int origin_y
)
679 make_source_or_disasm_window (win_info_ptr
, SRC_WIN
, height
, origin_y
);
682 } /* make_source_window */
685 /* make_disasm_window().
688 make_disasm_window (struct tui_win_info
**win_info_ptr
,
689 int height
, int origin_y
)
691 make_source_or_disasm_window (win_info_ptr
, DISASSEM_WIN
, height
, origin_y
);
694 } /* make_disasm_window */
698 make_data_window (struct tui_win_info
**win_info_ptr
,
699 int height
, int origin_y
)
701 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
712 /* Show the Source/Command layout. */
714 show_source_command (void)
716 show_source_or_disasm_and_command (SRC_COMMAND
);
720 /* Show the Dissassem/Command layout. */
722 show_disasm_command (void)
724 show_source_or_disasm_and_command (DISASSEM_COMMAND
);
728 /* Show the Source/Disassem/Command layout. */
730 show_source_disasm_command (void)
732 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
734 int cmd_height
, src_height
, asm_height
;
736 if (TUI_CMD_WIN
!= NULL
)
737 cmd_height
= TUI_CMD_WIN
->generic
.height
;
739 cmd_height
= tui_term_height () / 3;
741 src_height
= (tui_term_height () - cmd_height
) / 2;
742 asm_height
= tui_term_height () - (src_height
+ cmd_height
);
744 if (TUI_SRC_WIN
== NULL
)
745 make_source_window (&TUI_SRC_WIN
, src_height
, 0);
748 init_gen_win_info (&TUI_SRC_WIN
->generic
,
749 TUI_SRC_WIN
->generic
.type
,
751 TUI_SRC_WIN
->generic
.width
,
752 TUI_SRC_WIN
->detail
.source_info
.execution_info
->width
,
754 TUI_SRC_WIN
->can_highlight
= TRUE
;
755 init_gen_win_info (TUI_SRC_WIN
->detail
.source_info
.execution_info
,
761 tui_make_visible (&TUI_SRC_WIN
->generic
);
762 tui_make_visible (TUI_SRC_WIN
->detail
.source_info
.execution_info
);
763 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;;
765 if (TUI_SRC_WIN
!= NULL
)
767 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
769 tui_show_source_content (TUI_SRC_WIN
);
770 if (TUI_DISASM_WIN
== NULL
)
772 make_disasm_window (&TUI_DISASM_WIN
, asm_height
, src_height
- 1);
773 locator
= init_and_make_win (locator
,
778 (src_height
+ asm_height
) - 1,
783 init_gen_win_info (locator
,
788 (src_height
+ asm_height
) - 1);
789 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
790 init_gen_win_info (&TUI_DISASM_WIN
->generic
,
791 TUI_DISASM_WIN
->generic
.type
,
793 TUI_DISASM_WIN
->generic
.width
,
794 TUI_DISASM_WIN
->detail
.source_info
.execution_info
->width
,
796 init_gen_win_info (TUI_DISASM_WIN
->detail
.source_info
.execution_info
,
802 TUI_DISASM_WIN
->can_highlight
= TRUE
;
803 tui_make_visible (&TUI_DISASM_WIN
->generic
);
804 tui_make_visible (TUI_DISASM_WIN
->detail
.source_info
.execution_info
);
806 if (TUI_DISASM_WIN
!= NULL
)
808 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;
809 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
810 tui_make_visible (locator
);
811 tui_show_locator_content ();
812 tui_show_source_content (TUI_DISASM_WIN
);
814 if (TUI_CMD_WIN
== NULL
)
815 make_command_window (&TUI_CMD_WIN
,
817 tui_term_height () - cmd_height
);
820 init_gen_win_info (&TUI_CMD_WIN
->generic
,
821 TUI_CMD_WIN
->generic
.type
,
822 TUI_CMD_WIN
->generic
.height
,
823 TUI_CMD_WIN
->generic
.width
,
825 TUI_CMD_WIN
->generic
.origin
.y
);
826 TUI_CMD_WIN
->can_highlight
= FALSE
;
827 tui_make_visible (&TUI_CMD_WIN
->generic
);
829 if (TUI_CMD_WIN
!= NULL
)
830 tui_refresh_win (&TUI_CMD_WIN
->generic
);
833 tui_set_current_layout_to (SRC_DISASSEM_COMMAND
);
838 /* Show the Source/Data/Command or the Dissassembly/Data/Command
841 show_data (enum tui_layout_type new_layout
)
843 int total_height
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
);
844 int src_height
, data_height
;
845 enum tui_win_type win_type
;
846 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
849 data_height
= total_height
/ 2;
850 src_height
= total_height
- data_height
;
851 tui_make_all_invisible ();
852 tui_make_invisible (locator
);
853 make_data_window (&TUI_DATA_WIN
, data_height
, 0);
854 TUI_DATA_WIN
->can_highlight
= TRUE
;
855 if (new_layout
== SRC_DATA_COMMAND
)
858 win_type
= DISASSEM_WIN
;
859 if (tui_win_list
[win_type
] == NULL
)
861 if (win_type
== SRC_WIN
)
862 make_source_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
864 make_disasm_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
865 locator
= init_and_make_win (locator
,
875 init_gen_win_info (&tui_win_list
[win_type
]->generic
,
876 tui_win_list
[win_type
]->generic
.type
,
878 tui_win_list
[win_type
]->generic
.width
,
879 tui_win_list
[win_type
]->detail
.source_info
.execution_info
->width
,
881 init_gen_win_info (tui_win_list
[win_type
]->detail
.source_info
.execution_info
,
887 tui_make_visible (&tui_win_list
[win_type
]->generic
);
888 tui_make_visible (tui_win_list
[win_type
]->detail
.source_info
.execution_info
);
889 init_gen_win_info (locator
,
896 tui_win_list
[win_type
]->detail
.source_info
.has_locator
= TRUE
;
897 tui_make_visible (locator
);
898 tui_show_locator_content ();
899 tui_add_to_source_windows (tui_win_list
[win_type
]);
900 tui_set_current_layout_to (new_layout
);
903 /* init_gen_win_info().
906 init_gen_win_info (struct tui_gen_win_info
*win_info
,
907 enum tui_win_type type
,
908 int height
, int width
,
909 int origin_x
, int origin_y
)
913 win_info
->type
= type
;
914 win_info
->width
= width
;
915 win_info
->height
= h
;
918 win_info
->viewport_height
= h
- 1;
919 if (win_info
->type
!= CMD_WIN
)
920 win_info
->viewport_height
--;
923 win_info
->viewport_height
= 1;
924 win_info
->origin
.x
= origin_x
;
925 win_info
->origin
.y
= origin_y
;
928 } /* init_gen_win_info */
930 /* init_and_make_win().
933 init_and_make_win (void *opaque_win_info
,
934 enum tui_win_type win_type
,
935 int height
, int width
,
936 int origin_x
, int origin_y
,
939 struct tui_gen_win_info
*generic
;
941 if (opaque_win_info
== NULL
)
943 if (tui_win_is_auxillary (win_type
))
944 opaque_win_info
= (void *) tui_alloc_generic_win_info ();
946 opaque_win_info
= (void *) tui_alloc_win_info (win_type
);
948 if (tui_win_is_auxillary (win_type
))
949 generic
= (struct tui_gen_win_info
*) opaque_win_info
;
951 generic
= &((struct tui_win_info
*) opaque_win_info
)->generic
;
953 if (opaque_win_info
!= NULL
)
955 init_gen_win_info (generic
, win_type
, height
, width
, origin_x
, origin_y
);
956 if (!tui_win_is_auxillary (win_type
))
958 if (generic
->type
== CMD_WIN
)
959 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= FALSE
;
961 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= TRUE
;
963 tui_make_window (generic
, box_it
);
965 return opaque_win_info
;
970 make_source_or_disasm_window (struct tui_win_info
**win_info_ptr
,
971 enum tui_win_type type
,
972 int height
, int origin_y
)
974 struct tui_gen_win_info
*execution_info
= (struct tui_gen_win_info
*) NULL
;
976 /* Create the exeuction info window. */
978 execution_info
= tui_source_exec_info_win_ptr ();
980 execution_info
= tui_disassem_exec_info_win_ptr ();
981 execution_info
= init_and_make_win (execution_info
,
989 /* Now create the source window. */
990 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
993 tui_term_width () - execution_info
->width
,
994 execution_info
->width
,
998 (*win_info_ptr
)->detail
.source_info
.execution_info
= execution_info
;
1002 /* Show the Source/Command or the Disassem layout. */
1004 show_source_or_disasm_and_command (enum tui_layout_type layout_type
)
1006 if (tui_current_layout () != layout_type
)
1008 struct tui_win_info
**win_info_ptr
;
1009 int src_height
, cmd_height
;
1010 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
1012 if (TUI_CMD_WIN
!= NULL
)
1013 cmd_height
= TUI_CMD_WIN
->generic
.height
;
1015 cmd_height
= tui_term_height () / 3;
1016 src_height
= tui_term_height () - cmd_height
;
1018 if (layout_type
== SRC_COMMAND
)
1019 win_info_ptr
= &TUI_SRC_WIN
;
1021 win_info_ptr
= &TUI_DISASM_WIN
;
1023 if ((*win_info_ptr
) == NULL
)
1025 if (layout_type
== SRC_COMMAND
)
1026 make_source_window (win_info_ptr
, src_height
- 1, 0);
1028 make_disasm_window (win_info_ptr
, src_height
- 1, 0);
1029 locator
= init_and_make_win (locator
,
1039 init_gen_win_info (locator
,
1045 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1046 init_gen_win_info (&(*win_info_ptr
)->generic
,
1047 (*win_info_ptr
)->generic
.type
,
1049 (*win_info_ptr
)->generic
.width
,
1050 (*win_info_ptr
)->detail
.source_info
.execution_info
->width
,
1052 init_gen_win_info ((*win_info_ptr
)->detail
.source_info
.execution_info
,
1058 (*win_info_ptr
)->can_highlight
= TRUE
;
1059 tui_make_visible (&(*win_info_ptr
)->generic
);
1060 tui_make_visible ((*win_info_ptr
)->detail
.source_info
.execution_info
);
1062 if ((*win_info_ptr
) != NULL
)
1064 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1065 tui_make_visible (locator
);
1066 tui_show_locator_content ();
1067 tui_show_source_content (*win_info_ptr
);
1069 if (TUI_CMD_WIN
== NULL
)
1071 make_command_window (&TUI_CMD_WIN
, cmd_height
, src_height
);
1072 tui_refresh_win (&TUI_CMD_WIN
->generic
);
1076 init_gen_win_info (&TUI_CMD_WIN
->generic
,
1077 TUI_CMD_WIN
->generic
.type
,
1078 TUI_CMD_WIN
->generic
.height
,
1079 TUI_CMD_WIN
->generic
.width
,
1080 TUI_CMD_WIN
->generic
.origin
.x
,
1081 TUI_CMD_WIN
->generic
.origin
.y
);
1082 TUI_CMD_WIN
->can_highlight
= FALSE
;
1083 tui_make_visible (&TUI_CMD_WIN
->generic
);
1086 tui_set_current_layout_to (layout_type
);