1 /* TUI layout window management.
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
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 2 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, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
33 #include "tui/tui-data.h"
34 #include "tui/tui-windata.h"
35 #include "tui/tui-wingeneral.h"
36 #include "tui/tui-stack.h"
37 #include "tui/tui-regs.h"
38 #include "tui/tui-win.h"
39 #include "tui/tui-winsource.h"
40 #include "tui/tui-disasm.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
*, enum tui_win_type
, int, int, int, int);
50 static void init_and_make_win (void **, enum tui_win_type
, 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
* *, enum tui_win_type
, int, int);
53 static void make_command_window (struct tui_win_info
* *, int, int);
54 static void make_source_window (struct tui_win_info
* *, int, int);
55 static void make_disasm_window (struct tui_win_info
* *, int, int);
56 static void make_data_window (struct tui_win_info
* *, int, int);
57 static void show_source_command (void);
58 static void show_disasm_command (void);
59 static void show_source_disasm_command (void);
60 static void show_data (enum tui_layout_type
);
61 static enum tui_layout_type
next_layout (void);
62 static enum tui_layout_type
prev_layout (void);
63 static void tui_layout_command (char *, int);
64 static void tui_toggle_layout_command (char *, int);
65 static void tui_toggle_split_layout_command (char *, int);
66 static CORE_ADDR
extract_display_start_addr (void);
67 static void tui_handle_xdb_layout (struct tui_layout_def
*);
70 /***************************************
72 ***************************************/
74 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
76 /* Show the screen layout defined. */
78 show_layout (enum tui_layout_type layout
)
80 enum tui_layout_type cur_layout
= tui_current_layout ();
82 if (layout
!= cur_layout
)
85 ** Since the new layout may cause changes in window size, we
86 ** 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
|| layout
== DISASSEM_DATA_COMMAND
)
94 tui_refresh_all (tui_win_list
);
98 /* First make the current layout be invisible */
99 tui_make_all_invisible ();
100 tui_make_invisible (tui_locator_win_info_ptr ());
104 /* Now show the new layout */
106 show_source_command ();
107 tui_add_to_source_windows (TUI_SRC_WIN
);
109 case DISASSEM_COMMAND
:
110 show_disasm_command ();
111 tui_add_to_source_windows (TUI_DISASM_WIN
);
113 case SRC_DISASSEM_COMMAND
:
114 show_source_disasm_command ();
115 tui_add_to_source_windows (TUI_SRC_WIN
);
116 tui_add_to_source_windows (TUI_DISASM_WIN
);
126 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
127 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
128 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
129 UNDEFINED_LAYOUT, then the data window is populated according to
130 regs_display_type. */
132 tui_set_layout (enum tui_layout_type layout_type
,
133 enum tui_register_display_type regs_display_type
)
135 enum tui_status status
= TUI_SUCCESS
;
137 if (layout_type
!= UNDEFINED_LAYOUT
|| regs_display_type
!= TUI_UNDEFINED_REGS
)
139 enum tui_layout_type cur_layout
= tui_current_layout (), new_layout
= UNDEFINED_LAYOUT
;
140 int regs_populate
= FALSE
;
141 CORE_ADDR addr
= extract_display_start_addr ();
142 struct tui_win_info
* new_win_with_focus
= (struct tui_win_info
*) NULL
;
143 struct tui_win_info
* win_with_focus
= tui_win_with_focus ();
144 struct tui_layout_def
* layout_def
= tui_layout_def ();
147 if (layout_type
== UNDEFINED_LAYOUT
&&
148 regs_display_type
!= TUI_UNDEFINED_REGS
)
150 if (cur_layout
== SRC_DISASSEM_COMMAND
)
151 new_layout
= DISASSEM_DATA_COMMAND
;
152 else if (cur_layout
== SRC_COMMAND
|| cur_layout
== SRC_DATA_COMMAND
)
153 new_layout
= SRC_DATA_COMMAND
;
154 else if (cur_layout
== DISASSEM_COMMAND
||
155 cur_layout
== DISASSEM_DATA_COMMAND
)
156 new_layout
= DISASSEM_DATA_COMMAND
;
159 new_layout
= layout_type
;
161 regs_populate
= (new_layout
== SRC_DATA_COMMAND
||
162 new_layout
== DISASSEM_DATA_COMMAND
||
163 regs_display_type
!= TUI_UNDEFINED_REGS
);
164 if (new_layout
!= cur_layout
|| regs_display_type
!= TUI_UNDEFINED_REGS
)
166 if (new_layout
!= cur_layout
)
168 show_layout (new_layout
);
170 ** Now determine where focus should be
172 if (win_with_focus
!= TUI_CMD_WIN
)
177 tui_set_win_focus_to (TUI_SRC_WIN
);
178 layout_def
->display_mode
= SRC_WIN
;
179 layout_def
->split
= FALSE
;
181 case DISASSEM_COMMAND
:
182 /* the previous layout was not showing
183 ** code. this can happen if there is no
185 ** 1. if the source file is in another dir OR
186 ** 2. if target was compiled without -g
187 ** We still want to show the assembly though!
189 addr
= tui_get_begin_asm_address ();
190 tui_set_win_focus_to (TUI_DISASM_WIN
);
191 layout_def
->display_mode
= DISASSEM_WIN
;
192 layout_def
->split
= FALSE
;
194 case SRC_DISASSEM_COMMAND
:
195 /* the previous layout was not showing
196 ** code. this can happen if there is no
198 ** 1. if the source file is in another dir OR
199 ** 2. if target was compiled without -g
200 ** We still want to show the assembly though!
202 addr
= tui_get_begin_asm_address ();
203 if (win_with_focus
== TUI_SRC_WIN
)
204 tui_set_win_focus_to (TUI_SRC_WIN
);
206 tui_set_win_focus_to (TUI_DISASM_WIN
);
207 layout_def
->split
= TRUE
;
209 case SRC_DATA_COMMAND
:
210 if (win_with_focus
!= TUI_DATA_WIN
)
211 tui_set_win_focus_to (TUI_SRC_WIN
);
213 tui_set_win_focus_to (TUI_DATA_WIN
);
214 layout_def
->display_mode
= SRC_WIN
;
215 layout_def
->split
= FALSE
;
217 case DISASSEM_DATA_COMMAND
:
218 /* the previous layout was not showing
219 ** code. this can happen if there is no
221 ** 1. if the source file is in another dir OR
222 ** 2. if target was compiled without -g
223 ** We still want to show the assembly though!
225 addr
= tui_get_begin_asm_address ();
226 if (win_with_focus
!= TUI_DATA_WIN
)
227 tui_set_win_focus_to (TUI_DISASM_WIN
);
229 tui_set_win_focus_to (TUI_DATA_WIN
);
230 layout_def
->display_mode
= DISASSEM_WIN
;
231 layout_def
->split
= FALSE
;
237 if (new_win_with_focus
!= (struct tui_win_info
*) NULL
)
238 tui_set_win_focus_to (new_win_with_focus
);
240 ** Now update the window content
242 if (!regs_populate
&&
243 (new_layout
== SRC_DATA_COMMAND
||
244 new_layout
== DISASSEM_DATA_COMMAND
))
245 tui_display_all_data ();
247 tui_update_source_windows_with_addr (addr
);
251 tui_show_registers (TUI_DATA_WIN
->detail
.data_display_info
.current_group
);
256 status
= TUI_FAILURE
;
261 /* Add the specified window to the layout in a logical way. This
262 means setting up the most logical layout given the window to be
265 tui_add_win_to_layout (enum tui_win_type type
)
267 enum tui_layout_type cur_layout
= tui_current_layout ();
272 if (cur_layout
!= SRC_COMMAND
&&
273 cur_layout
!= SRC_DISASSEM_COMMAND
&&
274 cur_layout
!= SRC_DATA_COMMAND
)
276 tui_clear_source_windows_detail ();
277 if (cur_layout
== DISASSEM_DATA_COMMAND
)
278 show_layout (SRC_DATA_COMMAND
);
280 show_layout (SRC_COMMAND
);
284 if (cur_layout
!= DISASSEM_COMMAND
&&
285 cur_layout
!= SRC_DISASSEM_COMMAND
&&
286 cur_layout
!= DISASSEM_DATA_COMMAND
)
288 tui_clear_source_windows_detail ();
289 if (cur_layout
== SRC_DATA_COMMAND
)
290 show_layout (DISASSEM_DATA_COMMAND
);
292 show_layout (DISASSEM_COMMAND
);
296 if (cur_layout
!= SRC_DATA_COMMAND
&&
297 cur_layout
!= DISASSEM_DATA_COMMAND
)
299 if (cur_layout
== DISASSEM_COMMAND
)
300 show_layout (DISASSEM_DATA_COMMAND
);
302 show_layout (SRC_DATA_COMMAND
);
311 /* Answer the height of a window. If it hasn't been created yet,
312 answer what the height of a window would be based upon its type and
315 tui_default_win_height (enum tui_win_type type
, enum tui_layout_type layout
)
319 if (tui_win_list
[type
] != (struct tui_win_info
*) NULL
)
320 h
= tui_win_list
[type
]->generic
.height
;
326 case DISASSEM_COMMAND
:
327 if (TUI_CMD_WIN
== NULL
)
328 h
= tui_term_height () / 2;
330 h
= tui_term_height () - TUI_CMD_WIN
->generic
.height
;
332 case SRC_DISASSEM_COMMAND
:
333 case SRC_DATA_COMMAND
:
334 case DISASSEM_DATA_COMMAND
:
335 if (TUI_CMD_WIN
== NULL
)
336 h
= tui_term_height () / 3;
338 h
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
) / 2;
350 /* Answer the height of a window. If it hasn't been created yet,
351 answer what the height of a window would be based upon its type and
354 tui_default_win_viewport_height (enum tui_win_type type
,
355 enum tui_layout_type layout
)
359 h
= tui_default_win_height (type
, layout
);
361 if (tui_win_list
[type
] == TUI_CMD_WIN
)
370 /* Function to initialize gdb commands, for tui window layout
373 _initialize_tui_layout (void)
375 add_com ("layout", class_tui
, tui_layout_command
, _("\
376 Change the layout of windows.\n\
377 Usage: layout prev | next | <layout_name> \n\
379 src : Displays source and command windows.\n\
380 asm : Displays disassembly and command windows.\n\
381 split : Displays source, disassembly and command windows.\n\
382 regs : Displays register window. If existing layout\n\
383 is source/command or assembly/command, the \n\
384 register window is displayed. If the\n\
385 source/assembly/command (split) is displayed, \n\
386 the register window is displayed with \n\
387 the window that has current logical focus.\n"));
390 add_com ("td", class_tui
, tui_toggle_layout_command
, _("\
391 Toggle between Source/Command and Disassembly/Command layouts.\n"));
392 add_com ("ts", class_tui
, tui_toggle_split_layout_command
, _("\
393 Toggle between Source/Command or Disassembly/Command and \n\
394 Source/Disassembly/Command layouts.\n"));
399 /*************************
400 ** STATIC LOCAL FUNCTIONS
401 **************************/
404 /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
405 REGS, $REGS, $GREGS, $FREGS, $SREGS. */
407 tui_set_layout_for_display_command (const char *layout_name
)
409 enum tui_status status
= TUI_SUCCESS
;
411 if (layout_name
!= (char *) NULL
)
415 enum tui_layout_type new_layout
= UNDEFINED_LAYOUT
;
416 enum tui_register_display_type dpy_type
= TUI_UNDEFINED_REGS
;
417 enum tui_layout_type cur_layout
= tui_current_layout ();
419 buf_ptr
= (char *) xstrdup (layout_name
);
420 for (i
= 0; (i
< strlen (layout_name
)); i
++)
421 buf_ptr
[i
] = toupper (buf_ptr
[i
]);
423 /* First check for ambiguous input */
424 if (strlen (buf_ptr
) <= 1 && (*buf_ptr
== 'S' || *buf_ptr
== '$'))
426 warning (_("Ambiguous command input."));
427 status
= TUI_FAILURE
;
431 if (subset_compare (buf_ptr
, "SRC"))
432 new_layout
= SRC_COMMAND
;
433 else if (subset_compare (buf_ptr
, "ASM"))
434 new_layout
= DISASSEM_COMMAND
;
435 else if (subset_compare (buf_ptr
, "SPLIT"))
436 new_layout
= SRC_DISASSEM_COMMAND
;
437 else if (subset_compare (buf_ptr
, "REGS") ||
438 subset_compare (buf_ptr
, TUI_GENERAL_SPECIAL_REGS_NAME
) ||
439 subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
) ||
440 subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
) ||
441 subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
443 if (cur_layout
== SRC_COMMAND
|| cur_layout
== SRC_DATA_COMMAND
)
444 new_layout
= SRC_DATA_COMMAND
;
446 new_layout
= DISASSEM_DATA_COMMAND
;
448 /* could ifdef out the following code. when compile with -z, there are null
449 pointer references that cause a core dump if 'layout regs' is the first
450 layout command issued by the user. HP has asked us to hook up this code
453 if (subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
))
455 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!=
457 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!=
459 dpy_type
= TUI_SFLOAT_REGS
;
462 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
464 else if (subset_compare (buf_ptr
,
465 TUI_GENERAL_SPECIAL_REGS_NAME
))
466 dpy_type
= TUI_GENERAL_AND_SPECIAL_REGS
;
467 else if (subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
))
468 dpy_type
= TUI_GENERAL_REGS
;
469 else if (subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
470 dpy_type
= TUI_SPECIAL_REGS
;
471 else if (TUI_DATA_WIN
)
473 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
!=
476 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
478 dpy_type
= TUI_GENERAL_REGS
;
481 /* end of potential ifdef
484 /* if ifdefed out code above, then assume that the user wishes to display the
485 general purpose registers
488 /* dpy_type = TUI_GENERAL_REGS;
491 else if (subset_compare (buf_ptr
, "NEXT"))
492 new_layout
= next_layout ();
493 else if (subset_compare (buf_ptr
, "PREV"))
494 new_layout
= prev_layout ();
496 status
= TUI_FAILURE
;
499 tui_set_layout (new_layout
, dpy_type
);
503 status
= TUI_FAILURE
;
510 extract_display_start_addr (void)
512 enum tui_layout_type cur_layout
= tui_current_layout ();
515 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
520 case SRC_DATA_COMMAND
:
521 find_line_pc (cursal
.symtab
,
522 TUI_SRC_WIN
->detail
.source_info
.start_line_or_addr
.u
.line_no
,
526 case DISASSEM_COMMAND
:
527 case SRC_DISASSEM_COMMAND
:
528 case DISASSEM_DATA_COMMAND
:
529 addr
= TUI_DISASM_WIN
->detail
.source_info
.start_line_or_addr
.u
.addr
;
541 tui_handle_xdb_layout (struct tui_layout_def
* layout_def
)
543 if (layout_def
->split
)
545 tui_set_layout (SRC_DISASSEM_COMMAND
, TUI_UNDEFINED_REGS
);
546 tui_set_win_focus_to (tui_win_list
[layout_def
->display_mode
]);
550 if (layout_def
->display_mode
== SRC_WIN
)
551 tui_set_layout (SRC_COMMAND
, TUI_UNDEFINED_REGS
);
553 tui_set_layout (DISASSEM_DATA_COMMAND
, layout_def
->regs_display_type
);
559 tui_toggle_layout_command (char *arg
, int from_tty
)
561 struct tui_layout_def
* layout_def
= tui_layout_def ();
563 /* Make sure the curses mode is enabled. */
565 if (layout_def
->display_mode
== SRC_WIN
)
566 layout_def
->display_mode
= DISASSEM_WIN
;
568 layout_def
->display_mode
= SRC_WIN
;
570 if (!layout_def
->split
)
571 tui_handle_xdb_layout (layout_def
);
576 tui_toggle_split_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 layout_def
->split
= (!layout_def
->split
);
583 tui_handle_xdb_layout (layout_def
);
588 tui_layout_command (char *arg
, int from_tty
)
590 /* Make sure the curses mode is enabled. */
593 /* Switch to the selected layout. */
594 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
595 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE
);
599 /* Answer the previous layout to cycle to. */
600 static enum tui_layout_type
603 enum tui_layout_type new_layout
;
605 new_layout
= tui_current_layout ();
606 if (new_layout
== UNDEFINED_LAYOUT
)
607 new_layout
= SRC_COMMAND
;
611 if (new_layout
== UNDEFINED_LAYOUT
)
612 new_layout
= SRC_COMMAND
;
619 /* Answer the next layout to cycle to. */
620 static enum tui_layout_type
623 enum tui_layout_type new_layout
;
625 new_layout
= tui_current_layout ();
626 if (new_layout
== SRC_COMMAND
)
627 new_layout
= DISASSEM_DATA_COMMAND
;
631 if (new_layout
== UNDEFINED_LAYOUT
)
632 new_layout
= DISASSEM_DATA_COMMAND
;
641 make_command_window (struct tui_win_info
* * win_info_ptr
, int height
, int origin_y
)
643 init_and_make_win ((void **) win_info_ptr
,
651 (*win_info_ptr
)->can_highlight
= FALSE
;
656 ** make_source_window().
659 make_source_window (struct tui_win_info
* * win_info_ptr
, int height
, int origin_y
)
661 make_source_or_disasm_window (win_info_ptr
, SRC_WIN
, height
, origin_y
);
664 } /* make_source_window */
668 ** make_disasm_window().
671 make_disasm_window (struct tui_win_info
* * win_info_ptr
, int height
, int origin_y
)
673 make_source_or_disasm_window (win_info_ptr
, DISASSEM_WIN
, height
, origin_y
);
676 } /* make_disasm_window */
680 make_data_window (struct tui_win_info
* * win_info_ptr
, int height
, int origin_y
)
682 init_and_make_win ((void **) win_info_ptr
,
693 /* Show the Source/Command layout. */
695 show_source_command (void)
697 show_source_or_disasm_and_command (SRC_COMMAND
);
701 /* Show the Dissassem/Command layout. */
703 show_disasm_command (void)
705 show_source_or_disasm_and_command (DISASSEM_COMMAND
);
709 /* Show the Source/Disassem/Command layout. */
711 show_source_disasm_command (void)
713 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
715 int cmd_height
, src_height
, asm_height
;
717 if (TUI_CMD_WIN
!= NULL
)
718 cmd_height
= TUI_CMD_WIN
->generic
.height
;
720 cmd_height
= tui_term_height () / 3;
722 src_height
= (tui_term_height () - cmd_height
) / 2;
723 asm_height
= tui_term_height () - (src_height
+ cmd_height
);
725 if (TUI_SRC_WIN
== NULL
)
726 make_source_window (&TUI_SRC_WIN
, src_height
, 0);
729 init_gen_win_info (&TUI_SRC_WIN
->generic
,
730 TUI_SRC_WIN
->generic
.type
,
732 TUI_SRC_WIN
->generic
.width
,
733 TUI_SRC_WIN
->detail
.source_info
.execution_info
->width
,
735 TUI_SRC_WIN
->can_highlight
= TRUE
;
736 init_gen_win_info (TUI_SRC_WIN
->detail
.source_info
.execution_info
,
742 tui_make_visible (&TUI_SRC_WIN
->generic
);
743 tui_make_visible (TUI_SRC_WIN
->detail
.source_info
.execution_info
);
744 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;;
746 if (TUI_SRC_WIN
!= NULL
)
748 struct tui_gen_win_info
* locator
= tui_locator_win_info_ptr ();
750 tui_show_source_content (TUI_SRC_WIN
);
751 if (TUI_DISASM_WIN
== NULL
)
753 make_disasm_window (&TUI_DISASM_WIN
, asm_height
, src_height
- 1);
754 init_and_make_win ((void **) & locator
,
759 (src_height
+ asm_height
) - 1,
764 init_gen_win_info (locator
,
769 (src_height
+ asm_height
) - 1);
770 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
772 &TUI_DISASM_WIN
->generic
,
773 TUI_DISASM_WIN
->generic
.type
,
775 TUI_DISASM_WIN
->generic
.width
,
776 TUI_DISASM_WIN
->detail
.source_info
.execution_info
->width
,
778 init_gen_win_info (TUI_DISASM_WIN
->detail
.source_info
.execution_info
,
784 TUI_DISASM_WIN
->can_highlight
= TRUE
;
785 tui_make_visible (&TUI_DISASM_WIN
->generic
);
786 tui_make_visible (TUI_DISASM_WIN
->detail
.source_info
.execution_info
);
788 if (TUI_DISASM_WIN
!= NULL
)
790 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;
791 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
792 tui_make_visible (locator
);
793 tui_show_locator_content ();
794 tui_show_source_content (TUI_DISASM_WIN
);
796 if (TUI_CMD_WIN
== NULL
)
797 make_command_window (&TUI_CMD_WIN
,
799 tui_term_height () - cmd_height
);
802 init_gen_win_info (&TUI_CMD_WIN
->generic
,
803 TUI_CMD_WIN
->generic
.type
,
804 TUI_CMD_WIN
->generic
.height
,
805 TUI_CMD_WIN
->generic
.width
,
807 TUI_CMD_WIN
->generic
.origin
.y
);
808 TUI_CMD_WIN
->can_highlight
= FALSE
;
809 tui_make_visible (&TUI_CMD_WIN
->generic
);
811 if (TUI_CMD_WIN
!= NULL
)
812 tui_refresh_win (&TUI_CMD_WIN
->generic
);
815 tui_set_current_layout_to (SRC_DISASSEM_COMMAND
);
820 /* Show the Source/Data/Command or the Dissassembly/Data/Command
823 show_data (enum tui_layout_type new_layout
)
825 int total_height
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
);
826 int src_height
, data_height
;
827 enum tui_win_type win_type
;
828 struct tui_gen_win_info
* locator
= tui_locator_win_info_ptr ();
831 data_height
= total_height
/ 2;
832 src_height
= total_height
- data_height
;
833 tui_make_all_invisible ();
834 tui_make_invisible (locator
);
835 make_data_window (&TUI_DATA_WIN
, data_height
, 0);
836 TUI_DATA_WIN
->can_highlight
= TRUE
;
837 if (new_layout
== SRC_DATA_COMMAND
)
840 win_type
= DISASSEM_WIN
;
841 if (tui_win_list
[win_type
] == NULL
)
843 if (win_type
== SRC_WIN
)
844 make_source_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
846 make_disasm_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
847 init_and_make_win ((void **) & locator
,
857 init_gen_win_info (&tui_win_list
[win_type
]->generic
,
858 tui_win_list
[win_type
]->generic
.type
,
860 tui_win_list
[win_type
]->generic
.width
,
861 tui_win_list
[win_type
]->detail
.source_info
.execution_info
->width
,
863 init_gen_win_info (tui_win_list
[win_type
]->detail
.source_info
.execution_info
,
869 tui_make_visible (&tui_win_list
[win_type
]->generic
);
870 tui_make_visible (tui_win_list
[win_type
]->detail
.source_info
.execution_info
);
871 init_gen_win_info (locator
,
878 tui_win_list
[win_type
]->detail
.source_info
.has_locator
= TRUE
;
879 tui_make_visible (locator
);
880 tui_show_locator_content ();
881 tui_add_to_source_windows (tui_win_list
[win_type
]);
882 tui_set_current_layout_to (new_layout
);
886 ** init_gen_win_info().
889 init_gen_win_info (struct tui_gen_win_info
* win_info
, enum tui_win_type type
,
890 int height
, int width
, int origin_x
, int origin_y
)
894 win_info
->type
= type
;
895 win_info
->width
= width
;
896 win_info
->height
= h
;
899 win_info
->viewport_height
= h
- 1;
900 if (win_info
->type
!= CMD_WIN
)
901 win_info
->viewport_height
--;
904 win_info
->viewport_height
= 1;
905 win_info
->origin
.x
= origin_x
;
906 win_info
->origin
.y
= origin_y
;
909 } /* init_gen_win_info */
912 ** init_and_make_win().
915 init_and_make_win (void ** win_info_ptr
, enum tui_win_type win_type
,
916 int height
, int width
, int origin_x
, int origin_y
, int box_it
)
918 void *opaque_win_info
= *win_info_ptr
;
919 struct tui_gen_win_info
* generic
;
921 if (opaque_win_info
== NULL
)
923 if (tui_win_is_auxillary (win_type
))
924 opaque_win_info
= (void *) tui_alloc_generic_win_info ();
926 opaque_win_info
= (void *) tui_alloc_win_info (win_type
);
928 if (tui_win_is_auxillary (win_type
))
929 generic
= (struct tui_gen_win_info
*) opaque_win_info
;
931 generic
= &((struct tui_win_info
*) opaque_win_info
)->generic
;
933 if (opaque_win_info
!= NULL
)
935 init_gen_win_info (generic
, win_type
, height
, width
, origin_x
, origin_y
);
936 if (!tui_win_is_auxillary (win_type
))
938 if (generic
->type
== CMD_WIN
)
939 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= FALSE
;
941 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= TRUE
;
943 tui_make_window (generic
, box_it
);
945 *win_info_ptr
= opaque_win_info
;
950 make_source_or_disasm_window (struct tui_win_info
* * win_info_ptr
, enum tui_win_type type
,
951 int height
, int origin_y
)
953 struct tui_gen_win_info
* execution_info
= (struct tui_gen_win_info
*) NULL
;
956 ** Create the exeuction info window.
959 execution_info
= tui_source_exec_info_win_ptr ();
961 execution_info
= tui_disassem_exec_info_win_ptr ();
962 init_and_make_win ((void **) & execution_info
,
970 ** Now create the source window.
972 init_and_make_win ((void **) win_info_ptr
,
975 tui_term_width () - execution_info
->width
,
976 execution_info
->width
,
980 (*win_info_ptr
)->detail
.source_info
.execution_info
= execution_info
;
984 /* Show the Source/Command or the Disassem layout. */
986 show_source_or_disasm_and_command (enum tui_layout_type layout_type
)
988 if (tui_current_layout () != layout_type
)
990 struct tui_win_info
* *win_info_ptr
;
991 int src_height
, cmd_height
;
992 struct tui_gen_win_info
* locator
= tui_locator_win_info_ptr ();
994 if (TUI_CMD_WIN
!= NULL
)
995 cmd_height
= TUI_CMD_WIN
->generic
.height
;
997 cmd_height
= tui_term_height () / 3;
998 src_height
= tui_term_height () - cmd_height
;
1001 if (layout_type
== SRC_COMMAND
)
1002 win_info_ptr
= &TUI_SRC_WIN
;
1004 win_info_ptr
= &TUI_DISASM_WIN
;
1006 if ((*win_info_ptr
) == NULL
)
1008 if (layout_type
== SRC_COMMAND
)
1009 make_source_window (win_info_ptr
, src_height
- 1, 0);
1011 make_disasm_window (win_info_ptr
, src_height
- 1, 0);
1012 init_and_make_win ((void **) & locator
,
1022 init_gen_win_info (locator
,
1028 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1030 &(*win_info_ptr
)->generic
,
1031 (*win_info_ptr
)->generic
.type
,
1033 (*win_info_ptr
)->generic
.width
,
1034 (*win_info_ptr
)->detail
.source_info
.execution_info
->width
,
1036 init_gen_win_info ((*win_info_ptr
)->detail
.source_info
.execution_info
,
1042 (*win_info_ptr
)->can_highlight
= TRUE
;
1043 tui_make_visible (&(*win_info_ptr
)->generic
);
1044 tui_make_visible ((*win_info_ptr
)->detail
.source_info
.execution_info
);
1046 if ((*win_info_ptr
) != NULL
)
1048 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1049 tui_make_visible (locator
);
1050 tui_show_locator_content ();
1051 tui_show_source_content (*win_info_ptr
);
1053 if (TUI_CMD_WIN
== NULL
)
1055 make_command_window (&TUI_CMD_WIN
, cmd_height
, src_height
);
1056 tui_refresh_win (&TUI_CMD_WIN
->generic
);
1060 init_gen_win_info (&TUI_CMD_WIN
->generic
,
1061 TUI_CMD_WIN
->generic
.type
,
1062 TUI_CMD_WIN
->generic
.height
,
1063 TUI_CMD_WIN
->generic
.width
,
1064 TUI_CMD_WIN
->generic
.origin
.x
,
1065 TUI_CMD_WIN
->generic
.origin
.y
);
1066 TUI_CMD_WIN
->can_highlight
= FALSE
;
1067 tui_make_visible (&TUI_CMD_WIN
->generic
);
1070 tui_set_current_layout_to (layout_type
);