1 /* TUI layout window management.
3 Copyright (C) 1998-2015 Free Software Foundation, Inc.
5 Contributed by Hewlett-Packard Company.
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
23 #include "arch-utils.h"
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"
39 #include "tui/tui-layout.h"
40 #include "gdb_curses.h"
42 /*******************************
44 ********************************/
45 static void show_layout (enum tui_layout_type
);
46 static void init_gen_win_info (struct tui_gen_win_info
*,
49 static void *init_and_make_win (void *, enum tui_win_type
,
50 int, int, int, int, int);
51 static void show_source_or_disasm_and_command (enum tui_layout_type
);
52 static void make_source_or_disasm_window (struct tui_win_info
**,
55 static void make_command_window (struct tui_win_info
**, int, int);
56 static void make_source_window (struct tui_win_info
**, int, int);
57 static void make_disasm_window (struct tui_win_info
**, int, int);
58 static void make_data_window (struct tui_win_info
**, int, int);
59 static void show_source_command (void);
60 static void show_disasm_command (void);
61 static void show_source_disasm_command (void);
62 static void show_data (enum tui_layout_type
);
63 static enum tui_layout_type
next_layout (void);
64 static enum tui_layout_type
prev_layout (void);
65 static void tui_layout_command (char *, int);
66 static void tui_toggle_layout_command (char *, int);
67 static void tui_toggle_split_layout_command (char *, int);
68 static void extract_display_start_addr (struct gdbarch
**, CORE_ADDR
*);
69 static void tui_handle_xdb_layout (struct tui_layout_def
*);
72 /***************************************
74 ***************************************/
76 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
78 /* Show the screen layout defined. */
80 show_layout (enum tui_layout_type layout
)
82 enum tui_layout_type cur_layout
= tui_current_layout ();
84 if (layout
!= cur_layout
)
86 /* Since the new layout may cause changes in window size, we
87 should free the content and reallocate on next display of
89 tui_free_all_source_wins_content ();
90 tui_clear_source_windows ();
91 if (layout
== SRC_DATA_COMMAND
92 || layout
== DISASSEM_DATA_COMMAND
)
95 tui_refresh_all (tui_win_list
);
99 /* First make the current layout be invisible. */
100 tui_make_all_invisible ();
101 tui_make_invisible (tui_locator_win_info_ptr ());
105 /* Now show the new layout. */
107 show_source_command ();
108 tui_add_to_source_windows (TUI_SRC_WIN
);
110 case DISASSEM_COMMAND
:
111 show_disasm_command ();
112 tui_add_to_source_windows (TUI_DISASM_WIN
);
114 case SRC_DISASSEM_COMMAND
:
115 show_source_disasm_command ();
116 tui_add_to_source_windows (TUI_SRC_WIN
);
117 tui_add_to_source_windows (TUI_DISASM_WIN
);
127 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
128 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
129 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
130 UNDEFINED_LAYOUT, then the data window is populated according to
131 regs_display_type. */
133 tui_set_layout (enum tui_layout_type layout_type
,
134 enum tui_register_display_type regs_display_type
)
136 enum tui_status status
= TUI_SUCCESS
;
138 if (layout_type
!= UNDEFINED_LAYOUT
139 || regs_display_type
!= TUI_UNDEFINED_REGS
)
141 enum tui_layout_type cur_layout
= tui_current_layout (),
142 new_layout
= UNDEFINED_LAYOUT
;
143 int regs_populate
= FALSE
;
144 struct gdbarch
*gdbarch
;
146 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
147 struct tui_layout_def
*layout_def
= tui_layout_def ();
149 extract_display_start_addr (&gdbarch
, &addr
);
151 if (layout_type
== UNDEFINED_LAYOUT
152 && regs_display_type
!= TUI_UNDEFINED_REGS
)
154 if (cur_layout
== SRC_DISASSEM_COMMAND
)
155 new_layout
= DISASSEM_DATA_COMMAND
;
156 else if (cur_layout
== SRC_COMMAND
157 || cur_layout
== SRC_DATA_COMMAND
)
158 new_layout
= SRC_DATA_COMMAND
;
159 else if (cur_layout
== DISASSEM_COMMAND
160 || cur_layout
== DISASSEM_DATA_COMMAND
)
161 new_layout
= DISASSEM_DATA_COMMAND
;
164 new_layout
= layout_type
;
166 regs_populate
= (new_layout
== SRC_DATA_COMMAND
167 || new_layout
== DISASSEM_DATA_COMMAND
168 || regs_display_type
!= TUI_UNDEFINED_REGS
);
169 if (new_layout
!= cur_layout
170 || regs_display_type
!= TUI_UNDEFINED_REGS
)
172 if (new_layout
!= cur_layout
)
174 show_layout (new_layout
);
176 /* Now determine where focus should be. */
177 if (win_with_focus
!= TUI_CMD_WIN
)
182 tui_set_win_focus_to (TUI_SRC_WIN
);
183 layout_def
->display_mode
= SRC_WIN
;
184 layout_def
->split
= FALSE
;
186 case DISASSEM_COMMAND
:
187 /* The previous layout was not showing code.
188 This can happen if there is no source
191 1. if the source file is in another dir OR
192 2. if target was compiled without -g
193 We still want to show the assembly though! */
195 tui_get_begin_asm_address (&gdbarch
, &addr
);
196 tui_set_win_focus_to (TUI_DISASM_WIN
);
197 layout_def
->display_mode
= DISASSEM_WIN
;
198 layout_def
->split
= FALSE
;
200 case SRC_DISASSEM_COMMAND
:
201 /* The previous layout was not showing code.
202 This can happen if there is no source
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! */
209 tui_get_begin_asm_address (&gdbarch
, &addr
);
210 if (win_with_focus
== TUI_SRC_WIN
)
211 tui_set_win_focus_to (TUI_SRC_WIN
);
213 tui_set_win_focus_to (TUI_DISASM_WIN
);
214 layout_def
->split
= TRUE
;
216 case SRC_DATA_COMMAND
:
217 if (win_with_focus
!= TUI_DATA_WIN
)
218 tui_set_win_focus_to (TUI_SRC_WIN
);
220 tui_set_win_focus_to (TUI_DATA_WIN
);
221 layout_def
->display_mode
= SRC_WIN
;
222 layout_def
->split
= FALSE
;
224 case DISASSEM_DATA_COMMAND
:
225 /* The previous layout was not showing code.
226 This can happen if there is no source
229 1. if the source file is in another dir OR
230 2. if target was compiled without -g
231 We still want to show the assembly though! */
233 tui_get_begin_asm_address (&gdbarch
, &addr
);
234 if (win_with_focus
!= TUI_DATA_WIN
)
235 tui_set_win_focus_to (TUI_DISASM_WIN
);
237 tui_set_win_focus_to (TUI_DATA_WIN
);
238 layout_def
->display_mode
= DISASSEM_WIN
;
239 layout_def
->split
= FALSE
;
246 * Now update the window content.
249 && (new_layout
== SRC_DATA_COMMAND
250 || new_layout
== DISASSEM_DATA_COMMAND
))
251 tui_display_all_data ();
253 tui_update_source_windows_with_addr (gdbarch
, addr
);
257 tui_show_registers (TUI_DATA_WIN
->detail
.data_display_info
.current_group
);
262 status
= TUI_FAILURE
;
267 /* Add the specified window to the layout in a logical way. This
268 means setting up the most logical layout given the window to be
271 tui_add_win_to_layout (enum tui_win_type type
)
273 enum tui_layout_type cur_layout
= tui_current_layout ();
278 if (cur_layout
!= SRC_COMMAND
279 && cur_layout
!= SRC_DISASSEM_COMMAND
280 && cur_layout
!= SRC_DATA_COMMAND
)
282 tui_clear_source_windows_detail ();
283 if (cur_layout
== DISASSEM_DATA_COMMAND
)
284 show_layout (SRC_DATA_COMMAND
);
286 show_layout (SRC_COMMAND
);
290 if (cur_layout
!= DISASSEM_COMMAND
291 && cur_layout
!= SRC_DISASSEM_COMMAND
292 && cur_layout
!= DISASSEM_DATA_COMMAND
)
294 tui_clear_source_windows_detail ();
295 if (cur_layout
== SRC_DATA_COMMAND
)
296 show_layout (DISASSEM_DATA_COMMAND
);
298 show_layout (DISASSEM_COMMAND
);
302 if (cur_layout
!= SRC_DATA_COMMAND
303 && cur_layout
!= DISASSEM_DATA_COMMAND
)
305 if (cur_layout
== DISASSEM_COMMAND
)
306 show_layout (DISASSEM_DATA_COMMAND
);
308 show_layout (SRC_DATA_COMMAND
);
317 /* Answer the height of a window. If it hasn't been created yet,
318 answer what the height of a window would be based upon its type and
321 tui_default_win_height (enum tui_win_type type
,
322 enum tui_layout_type layout
)
326 if (tui_win_list
[type
] != (struct tui_win_info
*) NULL
)
327 h
= tui_win_list
[type
]->generic
.height
;
333 case DISASSEM_COMMAND
:
334 if (TUI_CMD_WIN
== NULL
)
335 h
= tui_term_height () / 2;
337 h
= tui_term_height () - TUI_CMD_WIN
->generic
.height
;
339 case SRC_DISASSEM_COMMAND
:
340 case SRC_DATA_COMMAND
:
341 case DISASSEM_DATA_COMMAND
:
342 if (TUI_CMD_WIN
== NULL
)
343 h
= tui_term_height () / 3;
345 h
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
) / 2;
357 /* Answer the height of a window. If it hasn't been created yet,
358 answer what the height of a window would be based upon its type and
361 tui_default_win_viewport_height (enum tui_win_type type
,
362 enum tui_layout_type layout
)
366 h
= tui_default_win_height (type
, layout
);
368 if (tui_win_list
[type
] == TUI_CMD_WIN
)
377 /* Function to initialize gdb commands, for tui window layout
380 /* Provide a prototype to silence -Wmissing-prototypes. */
381 extern initialize_file_ftype _initialize_tui_layout
;
384 _initialize_tui_layout (void)
386 add_com ("layout", class_tui
, tui_layout_command
, _("\
387 Change the layout of windows.\n\
388 Usage: layout prev | next | <layout_name> \n\
390 src : Displays source and command windows.\n\
391 asm : Displays disassembly and command windows.\n\
392 split : Displays source, disassembly and command windows.\n\
393 regs : Displays register window. If existing layout\n\
394 is source/command or assembly/command, the \n\
395 register window is displayed. If the\n\
396 source/assembly/command (split) is displayed, \n\
397 the register window is displayed with \n\
398 the window that has current logical focus.\n"));
401 add_com ("td", class_tui
, tui_toggle_layout_command
, _("\
402 Toggle between Source/Command and Disassembly/Command layouts.\n"));
403 add_com ("ts", class_tui
, tui_toggle_split_layout_command
, _("\
404 Toggle between Source/Command or Disassembly/Command and \n\
405 Source/Disassembly/Command layouts.\n"));
410 /*************************
411 ** STATIC LOCAL FUNCTIONS
412 **************************/
415 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
416 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
418 tui_set_layout_for_display_command (const char *layout_name
)
420 enum tui_status status
= TUI_SUCCESS
;
422 if (layout_name
!= (char *) NULL
)
426 enum tui_layout_type new_layout
= UNDEFINED_LAYOUT
;
427 enum tui_register_display_type dpy_type
= TUI_UNDEFINED_REGS
;
428 enum tui_layout_type cur_layout
= tui_current_layout ();
430 buf_ptr
= (char *) xstrdup (layout_name
);
431 for (i
= 0; (i
< strlen (layout_name
)); i
++)
432 buf_ptr
[i
] = toupper (buf_ptr
[i
]);
434 /* First check for ambiguous input. */
435 if (strlen (buf_ptr
) <= 1
436 && (*buf_ptr
== 'S' || *buf_ptr
== '$'))
438 warning (_("Ambiguous command input."));
439 status
= TUI_FAILURE
;
443 if (subset_compare (buf_ptr
, "SRC"))
444 new_layout
= SRC_COMMAND
;
445 else if (subset_compare (buf_ptr
, "ASM"))
446 new_layout
= DISASSEM_COMMAND
;
447 else if (subset_compare (buf_ptr
, "SPLIT"))
448 new_layout
= SRC_DISASSEM_COMMAND
;
449 else if (subset_compare (buf_ptr
, "REGS")
450 || subset_compare (buf_ptr
, TUI_GENERAL_SPECIAL_REGS_NAME
)
451 || subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
)
452 || subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
)
453 || subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
455 if (cur_layout
== SRC_COMMAND
456 || cur_layout
== SRC_DATA_COMMAND
)
457 new_layout
= SRC_DATA_COMMAND
;
459 new_layout
= DISASSEM_DATA_COMMAND
;
461 /* Could ifdef out the following code. when compile with
462 -z, there are null pointer references that cause a
463 core dump if 'layout regs' is the first layout
464 command issued by the user. HP has asked us to hook
465 up this code. - edie epstein */
466 if (subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
))
468 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
470 && TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
472 dpy_type
= TUI_SFLOAT_REGS
;
475 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
477 else if (subset_compare (buf_ptr
,
478 TUI_GENERAL_SPECIAL_REGS_NAME
))
479 dpy_type
= TUI_GENERAL_AND_SPECIAL_REGS
;
480 else if (subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
))
481 dpy_type
= TUI_GENERAL_REGS
;
482 else if (subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
483 dpy_type
= TUI_SPECIAL_REGS
;
484 else if (TUI_DATA_WIN
)
486 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
487 != TUI_UNDEFINED_REGS
)
489 = TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
491 dpy_type
= TUI_GENERAL_REGS
;
494 /* End of potential ifdef.
497 /* If ifdefed out code above, then assume that the user
498 wishes to display the general purpose registers .
501 /* dpy_type = TUI_GENERAL_REGS; */
503 else if (subset_compare (buf_ptr
, "NEXT"))
504 new_layout
= next_layout ();
505 else if (subset_compare (buf_ptr
, "PREV"))
506 new_layout
= prev_layout ();
508 status
= TUI_FAILURE
;
510 tui_set_layout (new_layout
, dpy_type
);
515 status
= TUI_FAILURE
;
522 extract_display_start_addr (struct gdbarch
**gdbarch_p
, CORE_ADDR
*addr_p
)
524 enum tui_layout_type cur_layout
= tui_current_layout ();
525 struct gdbarch
*gdbarch
= get_current_arch ();
528 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
533 case SRC_DATA_COMMAND
:
534 gdbarch
= TUI_SRC_WIN
->detail
.source_info
.gdbarch
;
535 find_line_pc (cursal
.symtab
,
536 TUI_SRC_WIN
->detail
.source_info
.start_line_or_addr
.u
.line_no
,
540 case DISASSEM_COMMAND
:
541 case SRC_DISASSEM_COMMAND
:
542 case DISASSEM_DATA_COMMAND
:
543 gdbarch
= TUI_DISASM_WIN
->detail
.source_info
.gdbarch
;
544 addr
= TUI_DISASM_WIN
->detail
.source_info
.start_line_or_addr
.u
.addr
;
551 *gdbarch_p
= gdbarch
;
557 tui_handle_xdb_layout (struct tui_layout_def
*layout_def
)
559 if (layout_def
->split
)
561 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
562 tui_set_win_focus_to (tui_win_list
[layout_def
->display_mode
]);
566 if (layout_def
->display_mode
== SRC_WIN
)
567 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
569 tui_set_layout (DISASSEM_DATA_COMMAND
, layout_def
->regs_display_type
);
575 tui_toggle_layout_command (char *arg
, int from_tty
)
577 struct tui_layout_def
*layout_def
= tui_layout_def ();
579 /* Make sure the curses mode is enabled. */
581 if (layout_def
->display_mode
== SRC_WIN
)
582 layout_def
->display_mode
= DISASSEM_WIN
;
584 layout_def
->display_mode
= SRC_WIN
;
586 if (!layout_def
->split
)
587 tui_handle_xdb_layout (layout_def
);
592 tui_toggle_split_layout_command (char *arg
, int from_tty
)
594 struct tui_layout_def
*layout_def
= tui_layout_def ();
596 /* Make sure the curses mode is enabled. */
598 layout_def
->split
= (!layout_def
->split
);
599 tui_handle_xdb_layout (layout_def
);
604 tui_layout_command (char *arg
, int from_tty
)
606 /* Make sure the curses mode is enabled. */
609 /* Switch to the selected layout. */
610 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
611 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE
);
615 /* Answer the previous layout to cycle to. */
616 static enum tui_layout_type
619 enum tui_layout_type new_layout
;
621 new_layout
= tui_current_layout ();
622 if (new_layout
== UNDEFINED_LAYOUT
)
623 new_layout
= SRC_COMMAND
;
627 if (new_layout
== UNDEFINED_LAYOUT
)
628 new_layout
= SRC_COMMAND
;
635 /* Answer the next layout to cycle to. */
636 static enum tui_layout_type
639 enum tui_layout_type new_layout
;
641 new_layout
= tui_current_layout ();
642 if (new_layout
== SRC_COMMAND
)
643 new_layout
= DISASSEM_DATA_COMMAND
;
647 if (new_layout
== UNDEFINED_LAYOUT
)
648 new_layout
= DISASSEM_DATA_COMMAND
;
657 make_command_window (struct tui_win_info
**win_info_ptr
,
658 int height
, int origin_y
)
660 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
668 (*win_info_ptr
)->can_highlight
= FALSE
;
672 /* make_source_window().
675 make_source_window (struct tui_win_info
**win_info_ptr
,
676 int height
, int origin_y
)
678 make_source_or_disasm_window (win_info_ptr
, SRC_WIN
, height
, origin_y
);
681 } /* make_source_window */
684 /* make_disasm_window().
687 make_disasm_window (struct tui_win_info
**win_info_ptr
,
688 int height
, int origin_y
)
690 make_source_or_disasm_window (win_info_ptr
, DISASSEM_WIN
, height
, origin_y
);
693 } /* make_disasm_window */
697 make_data_window (struct tui_win_info
**win_info_ptr
,
698 int height
, int origin_y
)
700 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
711 /* Show the Source/Command layout. */
713 show_source_command (void)
715 show_source_or_disasm_and_command (SRC_COMMAND
);
719 /* Show the Dissassem/Command layout. */
721 show_disasm_command (void)
723 show_source_or_disasm_and_command (DISASSEM_COMMAND
);
727 /* Show the Source/Disassem/Command layout. */
729 show_source_disasm_command (void)
731 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
733 int cmd_height
, src_height
, asm_height
;
735 if (TUI_CMD_WIN
!= NULL
)
736 cmd_height
= TUI_CMD_WIN
->generic
.height
;
738 cmd_height
= tui_term_height () / 3;
740 src_height
= (tui_term_height () - cmd_height
) / 2;
741 asm_height
= tui_term_height () - (src_height
+ cmd_height
);
743 if (TUI_SRC_WIN
== NULL
)
744 make_source_window (&TUI_SRC_WIN
, src_height
, 0);
747 init_gen_win_info (&TUI_SRC_WIN
->generic
,
748 TUI_SRC_WIN
->generic
.type
,
750 TUI_SRC_WIN
->generic
.width
,
751 TUI_SRC_WIN
->detail
.source_info
.execution_info
->width
,
753 TUI_SRC_WIN
->can_highlight
= TRUE
;
754 init_gen_win_info (TUI_SRC_WIN
->detail
.source_info
.execution_info
,
760 tui_make_visible (&TUI_SRC_WIN
->generic
);
761 tui_make_visible (TUI_SRC_WIN
->detail
.source_info
.execution_info
);
762 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;;
764 if (TUI_SRC_WIN
!= NULL
)
766 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
768 tui_show_source_content (TUI_SRC_WIN
);
769 if (TUI_DISASM_WIN
== NULL
)
771 make_disasm_window (&TUI_DISASM_WIN
, asm_height
, src_height
- 1);
772 locator
= init_and_make_win (locator
,
777 (src_height
+ asm_height
) - 1,
782 init_gen_win_info (locator
,
787 (src_height
+ asm_height
) - 1);
788 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
789 init_gen_win_info (&TUI_DISASM_WIN
->generic
,
790 TUI_DISASM_WIN
->generic
.type
,
792 TUI_DISASM_WIN
->generic
.width
,
793 TUI_DISASM_WIN
->detail
.source_info
.execution_info
->width
,
795 init_gen_win_info (TUI_DISASM_WIN
->detail
.source_info
.execution_info
,
801 TUI_DISASM_WIN
->can_highlight
= TRUE
;
802 tui_make_visible (&TUI_DISASM_WIN
->generic
);
803 tui_make_visible (TUI_DISASM_WIN
->detail
.source_info
.execution_info
);
805 if (TUI_DISASM_WIN
!= NULL
)
807 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;
808 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
809 tui_make_visible (locator
);
810 tui_show_locator_content ();
811 tui_show_source_content (TUI_DISASM_WIN
);
813 if (TUI_CMD_WIN
== NULL
)
814 make_command_window (&TUI_CMD_WIN
,
816 tui_term_height () - cmd_height
);
819 init_gen_win_info (&TUI_CMD_WIN
->generic
,
820 TUI_CMD_WIN
->generic
.type
,
821 TUI_CMD_WIN
->generic
.height
,
822 TUI_CMD_WIN
->generic
.width
,
824 TUI_CMD_WIN
->generic
.origin
.y
);
825 TUI_CMD_WIN
->can_highlight
= FALSE
;
826 tui_make_visible (&TUI_CMD_WIN
->generic
);
828 if (TUI_CMD_WIN
!= NULL
)
829 tui_refresh_win (&TUI_CMD_WIN
->generic
);
832 tui_set_current_layout_to (SRC_DISASSEM_COMMAND
);
837 /* Show the Source/Data/Command or the Dissassembly/Data/Command
840 show_data (enum tui_layout_type new_layout
)
842 int total_height
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
);
843 int src_height
, data_height
;
844 enum tui_win_type win_type
;
845 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
848 data_height
= total_height
/ 2;
849 src_height
= total_height
- data_height
;
850 tui_make_all_invisible ();
851 tui_make_invisible (locator
);
852 make_data_window (&TUI_DATA_WIN
, data_height
, 0);
853 TUI_DATA_WIN
->can_highlight
= TRUE
;
854 if (new_layout
== SRC_DATA_COMMAND
)
857 win_type
= DISASSEM_WIN
;
858 if (tui_win_list
[win_type
] == NULL
)
860 if (win_type
== SRC_WIN
)
861 make_source_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
863 make_disasm_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
864 locator
= init_and_make_win (locator
,
874 init_gen_win_info (&tui_win_list
[win_type
]->generic
,
875 tui_win_list
[win_type
]->generic
.type
,
877 tui_win_list
[win_type
]->generic
.width
,
878 tui_win_list
[win_type
]->detail
.source_info
.execution_info
->width
,
880 init_gen_win_info (tui_win_list
[win_type
]->detail
.source_info
.execution_info
,
886 tui_make_visible (&tui_win_list
[win_type
]->generic
);
887 tui_make_visible (tui_win_list
[win_type
]->detail
.source_info
.execution_info
);
888 init_gen_win_info (locator
,
895 tui_win_list
[win_type
]->detail
.source_info
.has_locator
= TRUE
;
896 tui_make_visible (locator
);
897 tui_show_locator_content ();
898 tui_add_to_source_windows (tui_win_list
[win_type
]);
899 tui_set_current_layout_to (new_layout
);
902 /* init_gen_win_info().
905 init_gen_win_info (struct tui_gen_win_info
*win_info
,
906 enum tui_win_type type
,
907 int height
, int width
,
908 int origin_x
, int origin_y
)
912 win_info
->type
= type
;
913 win_info
->width
= width
;
914 win_info
->height
= h
;
917 win_info
->viewport_height
= h
- 1;
918 if (win_info
->type
!= CMD_WIN
)
919 win_info
->viewport_height
--;
922 win_info
->viewport_height
= 1;
923 win_info
->origin
.x
= origin_x
;
924 win_info
->origin
.y
= origin_y
;
927 } /* init_gen_win_info */
929 /* init_and_make_win().
932 init_and_make_win (void *opaque_win_info
,
933 enum tui_win_type win_type
,
934 int height
, int width
,
935 int origin_x
, int origin_y
,
938 struct tui_gen_win_info
*generic
;
940 if (opaque_win_info
== NULL
)
942 if (tui_win_is_auxillary (win_type
))
943 opaque_win_info
= (void *) tui_alloc_generic_win_info ();
945 opaque_win_info
= (void *) tui_alloc_win_info (win_type
);
947 if (tui_win_is_auxillary (win_type
))
948 generic
= (struct tui_gen_win_info
*) opaque_win_info
;
950 generic
= &((struct tui_win_info
*) opaque_win_info
)->generic
;
952 if (opaque_win_info
!= NULL
)
954 init_gen_win_info (generic
, win_type
, height
, width
, origin_x
, origin_y
);
955 if (!tui_win_is_auxillary (win_type
))
957 if (generic
->type
== CMD_WIN
)
958 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= FALSE
;
960 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= TRUE
;
962 tui_make_window (generic
, box_it
);
964 return opaque_win_info
;
969 make_source_or_disasm_window (struct tui_win_info
**win_info_ptr
,
970 enum tui_win_type type
,
971 int height
, int origin_y
)
973 struct tui_gen_win_info
*execution_info
= (struct tui_gen_win_info
*) NULL
;
975 /* Create the exeuction info window. */
977 execution_info
= tui_source_exec_info_win_ptr ();
979 execution_info
= tui_disassem_exec_info_win_ptr ();
980 execution_info
= init_and_make_win (execution_info
,
988 /* Now create the source window. */
989 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
992 tui_term_width () - execution_info
->width
,
993 execution_info
->width
,
997 (*win_info_ptr
)->detail
.source_info
.execution_info
= execution_info
;
1001 /* Show the Source/Command or the Disassem layout. */
1003 show_source_or_disasm_and_command (enum tui_layout_type layout_type
)
1005 if (tui_current_layout () != layout_type
)
1007 struct tui_win_info
**win_info_ptr
;
1008 int src_height
, cmd_height
;
1009 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
1011 if (TUI_CMD_WIN
!= NULL
)
1012 cmd_height
= TUI_CMD_WIN
->generic
.height
;
1014 cmd_height
= tui_term_height () / 3;
1015 src_height
= tui_term_height () - cmd_height
;
1017 if (layout_type
== SRC_COMMAND
)
1018 win_info_ptr
= &TUI_SRC_WIN
;
1020 win_info_ptr
= &TUI_DISASM_WIN
;
1022 if ((*win_info_ptr
) == NULL
)
1024 if (layout_type
== SRC_COMMAND
)
1025 make_source_window (win_info_ptr
, src_height
- 1, 0);
1027 make_disasm_window (win_info_ptr
, src_height
- 1, 0);
1028 locator
= init_and_make_win (locator
,
1038 init_gen_win_info (locator
,
1044 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1045 init_gen_win_info (&(*win_info_ptr
)->generic
,
1046 (*win_info_ptr
)->generic
.type
,
1048 (*win_info_ptr
)->generic
.width
,
1049 (*win_info_ptr
)->detail
.source_info
.execution_info
->width
,
1051 init_gen_win_info ((*win_info_ptr
)->detail
.source_info
.execution_info
,
1057 (*win_info_ptr
)->can_highlight
= TRUE
;
1058 tui_make_visible (&(*win_info_ptr
)->generic
);
1059 tui_make_visible ((*win_info_ptr
)->detail
.source_info
.execution_info
);
1061 if ((*win_info_ptr
) != NULL
)
1063 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1064 tui_make_visible (locator
);
1065 tui_show_locator_content ();
1066 tui_show_source_content (*win_info_ptr
);
1068 if (TUI_CMD_WIN
== NULL
)
1070 make_command_window (&TUI_CMD_WIN
, cmd_height
, src_height
);
1071 tui_refresh_win (&TUI_CMD_WIN
->generic
);
1075 init_gen_win_info (&TUI_CMD_WIN
->generic
,
1076 TUI_CMD_WIN
->generic
.type
,
1077 TUI_CMD_WIN
->generic
.height
,
1078 TUI_CMD_WIN
->generic
.width
,
1079 TUI_CMD_WIN
->generic
.origin
.x
,
1080 TUI_CMD_WIN
->generic
.origin
.y
);
1081 TUI_CMD_WIN
->can_highlight
= FALSE
;
1082 tui_make_visible (&TUI_CMD_WIN
->generic
);
1085 tui_set_current_layout_to (layout_type
);