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 extract_display_start_addr (struct gdbarch
**, CORE_ADDR
*);
69 /***************************************
71 ***************************************/
73 #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
75 /* Show the screen layout defined. */
77 show_layout (enum tui_layout_type layout
)
79 enum tui_layout_type cur_layout
= tui_current_layout ();
81 if (layout
!= cur_layout
)
83 /* Since the new layout may cause changes in window size, we
84 should free the content and reallocate on next display of
86 tui_free_all_source_wins_content ();
87 tui_clear_source_windows ();
88 if (layout
== SRC_DATA_COMMAND
89 || layout
== DISASSEM_DATA_COMMAND
)
92 tui_refresh_all (tui_win_list
);
96 /* First make the current layout be invisible. */
97 tui_make_all_invisible ();
98 tui_make_invisible (tui_locator_win_info_ptr ());
102 /* Now show the new layout. */
104 show_source_command ();
105 tui_add_to_source_windows (TUI_SRC_WIN
);
107 case DISASSEM_COMMAND
:
108 show_disasm_command ();
109 tui_add_to_source_windows (TUI_DISASM_WIN
);
111 case SRC_DISASSEM_COMMAND
:
112 show_source_disasm_command ();
113 tui_add_to_source_windows (TUI_SRC_WIN
);
114 tui_add_to_source_windows (TUI_DISASM_WIN
);
124 /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
125 SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
126 If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
127 UNDEFINED_LAYOUT, then the data window is populated according to
128 regs_display_type. */
130 tui_set_layout (enum tui_layout_type layout_type
,
131 enum tui_register_display_type regs_display_type
)
133 enum tui_status status
= TUI_SUCCESS
;
135 if (layout_type
!= UNDEFINED_LAYOUT
136 || regs_display_type
!= TUI_UNDEFINED_REGS
)
138 enum tui_layout_type cur_layout
= tui_current_layout (),
139 new_layout
= UNDEFINED_LAYOUT
;
140 int regs_populate
= FALSE
;
141 struct gdbarch
*gdbarch
;
143 struct tui_win_info
*win_with_focus
= tui_win_with_focus ();
144 struct tui_layout_def
*layout_def
= tui_layout_def ();
146 extract_display_start_addr (&gdbarch
, &addr
);
148 if (layout_type
== UNDEFINED_LAYOUT
149 && regs_display_type
!= TUI_UNDEFINED_REGS
)
151 if (cur_layout
== SRC_DISASSEM_COMMAND
)
152 new_layout
= DISASSEM_DATA_COMMAND
;
153 else if (cur_layout
== SRC_COMMAND
154 || cur_layout
== SRC_DATA_COMMAND
)
155 new_layout
= SRC_DATA_COMMAND
;
156 else if (cur_layout
== DISASSEM_COMMAND
157 || cur_layout
== DISASSEM_DATA_COMMAND
)
158 new_layout
= DISASSEM_DATA_COMMAND
;
161 new_layout
= layout_type
;
163 regs_populate
= (new_layout
== SRC_DATA_COMMAND
164 || new_layout
== DISASSEM_DATA_COMMAND
165 || regs_display_type
!= TUI_UNDEFINED_REGS
);
166 if (new_layout
!= cur_layout
167 || regs_display_type
!= TUI_UNDEFINED_REGS
)
169 if (new_layout
!= cur_layout
)
171 show_layout (new_layout
);
173 /* Now determine where focus should be. */
174 if (win_with_focus
!= TUI_CMD_WIN
)
179 tui_set_win_focus_to (TUI_SRC_WIN
);
180 layout_def
->display_mode
= SRC_WIN
;
181 layout_def
->split
= FALSE
;
183 case DISASSEM_COMMAND
:
184 /* The previous layout was not showing code.
185 This can happen if there is no source
188 1. if the source file is in another dir OR
189 2. if target was compiled without -g
190 We still want to show the assembly though! */
192 tui_get_begin_asm_address (&gdbarch
, &addr
);
193 tui_set_win_focus_to (TUI_DISASM_WIN
);
194 layout_def
->display_mode
= DISASSEM_WIN
;
195 layout_def
->split
= FALSE
;
197 case SRC_DISASSEM_COMMAND
:
198 /* The previous layout was not showing code.
199 This can happen if there is no source
202 1. if the source file is in another dir OR
203 2. if target was compiled without -g
204 We still want to show the assembly though! */
206 tui_get_begin_asm_address (&gdbarch
, &addr
);
207 if (win_with_focus
== TUI_SRC_WIN
)
208 tui_set_win_focus_to (TUI_SRC_WIN
);
210 tui_set_win_focus_to (TUI_DISASM_WIN
);
211 layout_def
->split
= TRUE
;
213 case SRC_DATA_COMMAND
:
214 if (win_with_focus
!= TUI_DATA_WIN
)
215 tui_set_win_focus_to (TUI_SRC_WIN
);
217 tui_set_win_focus_to (TUI_DATA_WIN
);
218 layout_def
->display_mode
= SRC_WIN
;
219 layout_def
->split
= FALSE
;
221 case DISASSEM_DATA_COMMAND
:
222 /* The previous layout was not showing code.
223 This can happen if there is no source
226 1. if the source file is in another dir OR
227 2. if target was compiled without -g
228 We still want to show the assembly though! */
230 tui_get_begin_asm_address (&gdbarch
, &addr
);
231 if (win_with_focus
!= TUI_DATA_WIN
)
232 tui_set_win_focus_to (TUI_DISASM_WIN
);
234 tui_set_win_focus_to (TUI_DATA_WIN
);
235 layout_def
->display_mode
= DISASSEM_WIN
;
236 layout_def
->split
= FALSE
;
243 * Now update the window content.
246 && (new_layout
== SRC_DATA_COMMAND
247 || new_layout
== DISASSEM_DATA_COMMAND
))
248 tui_display_all_data ();
250 tui_update_source_windows_with_addr (gdbarch
, addr
);
254 tui_show_registers (TUI_DATA_WIN
->detail
.data_display_info
.current_group
);
259 status
= TUI_FAILURE
;
264 /* Add the specified window to the layout in a logical way. This
265 means setting up the most logical layout given the window to be
268 tui_add_win_to_layout (enum tui_win_type type
)
270 enum tui_layout_type cur_layout
= tui_current_layout ();
275 if (cur_layout
!= SRC_COMMAND
276 && cur_layout
!= SRC_DISASSEM_COMMAND
277 && cur_layout
!= SRC_DATA_COMMAND
)
279 tui_clear_source_windows_detail ();
280 if (cur_layout
== DISASSEM_DATA_COMMAND
)
281 show_layout (SRC_DATA_COMMAND
);
283 show_layout (SRC_COMMAND
);
287 if (cur_layout
!= DISASSEM_COMMAND
288 && cur_layout
!= SRC_DISASSEM_COMMAND
289 && cur_layout
!= DISASSEM_DATA_COMMAND
)
291 tui_clear_source_windows_detail ();
292 if (cur_layout
== SRC_DATA_COMMAND
)
293 show_layout (DISASSEM_DATA_COMMAND
);
295 show_layout (DISASSEM_COMMAND
);
299 if (cur_layout
!= SRC_DATA_COMMAND
300 && cur_layout
!= DISASSEM_DATA_COMMAND
)
302 if (cur_layout
== DISASSEM_COMMAND
)
303 show_layout (DISASSEM_DATA_COMMAND
);
305 show_layout (SRC_DATA_COMMAND
);
314 /* Answer the height of a window. If it hasn't been created yet,
315 answer what the height of a window would be based upon its type and
318 tui_default_win_height (enum tui_win_type type
,
319 enum tui_layout_type layout
)
323 if (tui_win_list
[type
] != (struct tui_win_info
*) NULL
)
324 h
= tui_win_list
[type
]->generic
.height
;
330 case DISASSEM_COMMAND
:
331 if (TUI_CMD_WIN
== NULL
)
332 h
= tui_term_height () / 2;
334 h
= tui_term_height () - TUI_CMD_WIN
->generic
.height
;
336 case SRC_DISASSEM_COMMAND
:
337 case SRC_DATA_COMMAND
:
338 case DISASSEM_DATA_COMMAND
:
339 if (TUI_CMD_WIN
== NULL
)
340 h
= tui_term_height () / 3;
342 h
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
) / 2;
354 /* Answer the height of a window. If it hasn't been created yet,
355 answer what the height of a window would be based upon its type and
358 tui_default_win_viewport_height (enum tui_win_type type
,
359 enum tui_layout_type layout
)
363 h
= tui_default_win_height (type
, layout
);
365 if (tui_win_list
[type
] == TUI_CMD_WIN
)
374 /* Function to initialize gdb commands, for tui window layout
377 /* Provide a prototype to silence -Wmissing-prototypes. */
378 extern initialize_file_ftype _initialize_tui_layout
;
381 _initialize_tui_layout (void)
383 add_com ("layout", class_tui
, tui_layout_command
, _("\
384 Change the layout of windows.\n\
385 Usage: layout prev | next | <layout_name> \n\
387 src : Displays source and command windows.\n\
388 asm : Displays disassembly and command windows.\n\
389 split : Displays source, disassembly and command windows.\n\
390 regs : Displays register window. If existing layout\n\
391 is source/command or assembly/command, the \n\
392 register window is displayed. If the\n\
393 source/assembly/command (split) is displayed, \n\
394 the register window is displayed with \n\
395 the window that has current logical focus.\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
425 && (*buf_ptr
== 'S' || *buf_ptr
== '$'))
427 warning (_("Ambiguous command input."));
428 status
= TUI_FAILURE
;
432 if (subset_compare (buf_ptr
, "SRC"))
433 new_layout
= SRC_COMMAND
;
434 else if (subset_compare (buf_ptr
, "ASM"))
435 new_layout
= DISASSEM_COMMAND
;
436 else if (subset_compare (buf_ptr
, "SPLIT"))
437 new_layout
= SRC_DISASSEM_COMMAND
;
438 else if (subset_compare (buf_ptr
, "REGS")
439 || subset_compare (buf_ptr
, TUI_GENERAL_SPECIAL_REGS_NAME
)
440 || subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
)
441 || subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
)
442 || subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
444 if (cur_layout
== SRC_COMMAND
445 || cur_layout
== SRC_DATA_COMMAND
)
446 new_layout
= SRC_DATA_COMMAND
;
448 new_layout
= DISASSEM_DATA_COMMAND
;
450 /* Could ifdef out the following code. when compile with
451 -z, there are null pointer references that cause a
452 core dump if 'layout regs' is the first layout
453 command issued by the user. HP has asked us to hook
454 up this code. - edie epstein */
455 if (subset_compare (buf_ptr
, TUI_FLOAT_REGS_NAME
))
457 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
459 && TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
461 dpy_type
= TUI_SFLOAT_REGS
;
464 TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
466 else if (subset_compare (buf_ptr
,
467 TUI_GENERAL_SPECIAL_REGS_NAME
))
468 dpy_type
= TUI_GENERAL_AND_SPECIAL_REGS
;
469 else if (subset_compare (buf_ptr
, TUI_GENERAL_REGS_NAME
))
470 dpy_type
= TUI_GENERAL_REGS
;
471 else if (subset_compare (buf_ptr
, TUI_SPECIAL_REGS_NAME
))
472 dpy_type
= TUI_SPECIAL_REGS
;
473 else if (TUI_DATA_WIN
)
475 if (TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
476 != TUI_UNDEFINED_REGS
)
478 = TUI_DATA_WIN
->detail
.data_display_info
.regs_display_type
;
480 dpy_type
= TUI_GENERAL_REGS
;
483 /* End of potential ifdef.
486 /* If ifdefed out code above, then assume that the user
487 wishes to display the general purpose registers .
490 /* dpy_type = TUI_GENERAL_REGS; */
492 else if (subset_compare (buf_ptr
, "NEXT"))
493 new_layout
= next_layout ();
494 else if (subset_compare (buf_ptr
, "PREV"))
495 new_layout
= prev_layout ();
497 status
= TUI_FAILURE
;
499 tui_set_layout (new_layout
, dpy_type
);
504 status
= TUI_FAILURE
;
511 extract_display_start_addr (struct gdbarch
**gdbarch_p
, CORE_ADDR
*addr_p
)
513 enum tui_layout_type cur_layout
= tui_current_layout ();
514 struct gdbarch
*gdbarch
= get_current_arch ();
517 struct symtab_and_line cursal
= get_current_source_symtab_and_line ();
522 case SRC_DATA_COMMAND
:
523 gdbarch
= TUI_SRC_WIN
->detail
.source_info
.gdbarch
;
524 find_line_pc (cursal
.symtab
,
525 TUI_SRC_WIN
->detail
.source_info
.start_line_or_addr
.u
.line_no
,
529 case DISASSEM_COMMAND
:
530 case SRC_DISASSEM_COMMAND
:
531 case DISASSEM_DATA_COMMAND
:
532 gdbarch
= TUI_DISASM_WIN
->detail
.source_info
.gdbarch
;
533 addr
= TUI_DISASM_WIN
->detail
.source_info
.start_line_or_addr
.u
.addr
;
540 *gdbarch_p
= gdbarch
;
546 tui_layout_command (char *arg
, int from_tty
)
548 /* Make sure the curses mode is enabled. */
551 /* Switch to the selected layout. */
552 if (tui_set_layout_for_display_command (arg
) != TUI_SUCCESS
)
553 warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE
);
557 /* Answer the previous layout to cycle to. */
558 static enum tui_layout_type
563 new_layout
= tui_current_layout ();
564 if (new_layout
== UNDEFINED_LAYOUT
)
565 new_layout
= SRC_COMMAND
;
569 if (new_layout
== UNDEFINED_LAYOUT
)
570 new_layout
= SRC_COMMAND
;
573 return (enum tui_layout_type
) new_layout
;
577 /* Answer the next layout to cycle to. */
578 static enum tui_layout_type
583 new_layout
= tui_current_layout ();
584 if (new_layout
== SRC_COMMAND
)
585 new_layout
= DISASSEM_DATA_COMMAND
;
589 if (new_layout
== UNDEFINED_LAYOUT
)
590 new_layout
= DISASSEM_DATA_COMMAND
;
593 return (enum tui_layout_type
) new_layout
;
599 make_command_window (struct tui_win_info
**win_info_ptr
,
600 int height
, int origin_y
)
602 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
610 (*win_info_ptr
)->can_highlight
= FALSE
;
614 /* make_source_window().
617 make_source_window (struct tui_win_info
**win_info_ptr
,
618 int height
, int origin_y
)
620 make_source_or_disasm_window (win_info_ptr
, SRC_WIN
, height
, origin_y
);
623 } /* make_source_window */
626 /* make_disasm_window().
629 make_disasm_window (struct tui_win_info
**win_info_ptr
,
630 int height
, int origin_y
)
632 make_source_or_disasm_window (win_info_ptr
, DISASSEM_WIN
, height
, origin_y
);
635 } /* make_disasm_window */
639 make_data_window (struct tui_win_info
**win_info_ptr
,
640 int height
, int origin_y
)
642 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
653 /* Show the Source/Command layout. */
655 show_source_command (void)
657 show_source_or_disasm_and_command (SRC_COMMAND
);
661 /* Show the Dissassem/Command layout. */
663 show_disasm_command (void)
665 show_source_or_disasm_and_command (DISASSEM_COMMAND
);
669 /* Show the Source/Disassem/Command layout. */
671 show_source_disasm_command (void)
673 if (tui_current_layout () != SRC_DISASSEM_COMMAND
)
675 int cmd_height
, src_height
, asm_height
;
677 if (TUI_CMD_WIN
!= NULL
)
678 cmd_height
= TUI_CMD_WIN
->generic
.height
;
680 cmd_height
= tui_term_height () / 3;
682 src_height
= (tui_term_height () - cmd_height
) / 2;
683 asm_height
= tui_term_height () - (src_height
+ cmd_height
);
685 if (TUI_SRC_WIN
== NULL
)
686 make_source_window (&TUI_SRC_WIN
, src_height
, 0);
689 init_gen_win_info (&TUI_SRC_WIN
->generic
,
690 TUI_SRC_WIN
->generic
.type
,
692 TUI_SRC_WIN
->generic
.width
,
693 TUI_SRC_WIN
->detail
.source_info
.execution_info
->width
,
695 TUI_SRC_WIN
->can_highlight
= TRUE
;
696 init_gen_win_info (TUI_SRC_WIN
->detail
.source_info
.execution_info
,
702 tui_make_visible (&TUI_SRC_WIN
->generic
);
703 tui_make_visible (TUI_SRC_WIN
->detail
.source_info
.execution_info
);
704 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;;
706 if (TUI_SRC_WIN
!= NULL
)
708 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
710 tui_show_source_content (TUI_SRC_WIN
);
711 if (TUI_DISASM_WIN
== NULL
)
713 make_disasm_window (&TUI_DISASM_WIN
, asm_height
, src_height
- 1);
714 locator
= init_and_make_win (locator
,
719 (src_height
+ asm_height
) - 1,
724 init_gen_win_info (locator
,
729 (src_height
+ asm_height
) - 1);
730 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
731 init_gen_win_info (&TUI_DISASM_WIN
->generic
,
732 TUI_DISASM_WIN
->generic
.type
,
734 TUI_DISASM_WIN
->generic
.width
,
735 TUI_DISASM_WIN
->detail
.source_info
.execution_info
->width
,
737 init_gen_win_info (TUI_DISASM_WIN
->detail
.source_info
.execution_info
,
743 TUI_DISASM_WIN
->can_highlight
= TRUE
;
744 tui_make_visible (&TUI_DISASM_WIN
->generic
);
745 tui_make_visible (TUI_DISASM_WIN
->detail
.source_info
.execution_info
);
747 if (TUI_DISASM_WIN
!= NULL
)
749 TUI_SRC_WIN
->detail
.source_info
.has_locator
= FALSE
;
750 TUI_DISASM_WIN
->detail
.source_info
.has_locator
= TRUE
;
751 tui_make_visible (locator
);
752 tui_show_locator_content ();
753 tui_show_source_content (TUI_DISASM_WIN
);
755 if (TUI_CMD_WIN
== NULL
)
756 make_command_window (&TUI_CMD_WIN
,
758 tui_term_height () - cmd_height
);
761 init_gen_win_info (&TUI_CMD_WIN
->generic
,
762 TUI_CMD_WIN
->generic
.type
,
763 TUI_CMD_WIN
->generic
.height
,
764 TUI_CMD_WIN
->generic
.width
,
766 TUI_CMD_WIN
->generic
.origin
.y
);
767 TUI_CMD_WIN
->can_highlight
= FALSE
;
768 tui_make_visible (&TUI_CMD_WIN
->generic
);
770 if (TUI_CMD_WIN
!= NULL
)
771 tui_refresh_win (&TUI_CMD_WIN
->generic
);
774 tui_set_current_layout_to (SRC_DISASSEM_COMMAND
);
779 /* Show the Source/Data/Command or the Dissassembly/Data/Command
782 show_data (enum tui_layout_type new_layout
)
784 int total_height
= (tui_term_height () - TUI_CMD_WIN
->generic
.height
);
785 int src_height
, data_height
;
786 enum tui_win_type win_type
;
787 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
790 data_height
= total_height
/ 2;
791 src_height
= total_height
- data_height
;
792 tui_make_all_invisible ();
793 tui_make_invisible (locator
);
794 make_data_window (&TUI_DATA_WIN
, data_height
, 0);
795 TUI_DATA_WIN
->can_highlight
= TRUE
;
796 if (new_layout
== SRC_DATA_COMMAND
)
799 win_type
= DISASSEM_WIN
;
800 if (tui_win_list
[win_type
] == NULL
)
802 if (win_type
== SRC_WIN
)
803 make_source_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
805 make_disasm_window (&tui_win_list
[win_type
], src_height
, data_height
- 1);
806 locator
= init_and_make_win (locator
,
816 init_gen_win_info (&tui_win_list
[win_type
]->generic
,
817 tui_win_list
[win_type
]->generic
.type
,
819 tui_win_list
[win_type
]->generic
.width
,
820 tui_win_list
[win_type
]->detail
.source_info
.execution_info
->width
,
822 init_gen_win_info (tui_win_list
[win_type
]->detail
.source_info
.execution_info
,
828 tui_make_visible (&tui_win_list
[win_type
]->generic
);
829 tui_make_visible (tui_win_list
[win_type
]->detail
.source_info
.execution_info
);
830 init_gen_win_info (locator
,
837 tui_win_list
[win_type
]->detail
.source_info
.has_locator
= TRUE
;
838 tui_make_visible (locator
);
839 tui_show_locator_content ();
840 tui_add_to_source_windows (tui_win_list
[win_type
]);
841 tui_set_current_layout_to (new_layout
);
844 /* init_gen_win_info().
847 init_gen_win_info (struct tui_gen_win_info
*win_info
,
848 enum tui_win_type type
,
849 int height
, int width
,
850 int origin_x
, int origin_y
)
854 win_info
->type
= type
;
855 win_info
->width
= width
;
856 win_info
->height
= h
;
859 win_info
->viewport_height
= h
- 1;
860 if (win_info
->type
!= CMD_WIN
)
861 win_info
->viewport_height
--;
864 win_info
->viewport_height
= 1;
865 win_info
->origin
.x
= origin_x
;
866 win_info
->origin
.y
= origin_y
;
869 } /* init_gen_win_info */
871 /* init_and_make_win().
874 init_and_make_win (void *opaque_win_info
,
875 enum tui_win_type win_type
,
876 int height
, int width
,
877 int origin_x
, int origin_y
,
880 struct tui_gen_win_info
*generic
;
882 if (opaque_win_info
== NULL
)
884 if (tui_win_is_auxillary (win_type
))
885 opaque_win_info
= (void *) tui_alloc_generic_win_info ();
887 opaque_win_info
= (void *) tui_alloc_win_info (win_type
);
889 if (tui_win_is_auxillary (win_type
))
890 generic
= (struct tui_gen_win_info
*) opaque_win_info
;
892 generic
= &((struct tui_win_info
*) opaque_win_info
)->generic
;
894 if (opaque_win_info
!= NULL
)
896 init_gen_win_info (generic
, win_type
, height
, width
, origin_x
, origin_y
);
897 if (!tui_win_is_auxillary (win_type
))
899 if (generic
->type
== CMD_WIN
)
900 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= FALSE
;
902 ((struct tui_win_info
*) opaque_win_info
)->can_highlight
= TRUE
;
904 tui_make_window (generic
, box_it
);
906 return opaque_win_info
;
911 make_source_or_disasm_window (struct tui_win_info
**win_info_ptr
,
912 enum tui_win_type type
,
913 int height
, int origin_y
)
915 struct tui_gen_win_info
*execution_info
= (struct tui_gen_win_info
*) NULL
;
917 /* Create the exeuction info window. */
919 execution_info
= tui_source_exec_info_win_ptr ();
921 execution_info
= tui_disassem_exec_info_win_ptr ();
922 execution_info
= init_and_make_win (execution_info
,
930 /* Now create the source window. */
931 *win_info_ptr
= init_and_make_win (*win_info_ptr
,
934 tui_term_width () - execution_info
->width
,
935 execution_info
->width
,
939 (*win_info_ptr
)->detail
.source_info
.execution_info
= execution_info
;
943 /* Show the Source/Command or the Disassem layout. */
945 show_source_or_disasm_and_command (enum tui_layout_type layout_type
)
947 if (tui_current_layout () != layout_type
)
949 struct tui_win_info
**win_info_ptr
;
950 int src_height
, cmd_height
;
951 struct tui_gen_win_info
*locator
= tui_locator_win_info_ptr ();
953 if (TUI_CMD_WIN
!= NULL
)
954 cmd_height
= TUI_CMD_WIN
->generic
.height
;
956 cmd_height
= tui_term_height () / 3;
957 src_height
= tui_term_height () - cmd_height
;
959 if (layout_type
== SRC_COMMAND
)
960 win_info_ptr
= &TUI_SRC_WIN
;
962 win_info_ptr
= &TUI_DISASM_WIN
;
964 if ((*win_info_ptr
) == NULL
)
966 if (layout_type
== SRC_COMMAND
)
967 make_source_window (win_info_ptr
, src_height
- 1, 0);
969 make_disasm_window (win_info_ptr
, src_height
- 1, 0);
970 locator
= init_and_make_win (locator
,
980 init_gen_win_info (locator
,
986 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
987 init_gen_win_info (&(*win_info_ptr
)->generic
,
988 (*win_info_ptr
)->generic
.type
,
990 (*win_info_ptr
)->generic
.width
,
991 (*win_info_ptr
)->detail
.source_info
.execution_info
->width
,
993 init_gen_win_info ((*win_info_ptr
)->detail
.source_info
.execution_info
,
999 (*win_info_ptr
)->can_highlight
= TRUE
;
1000 tui_make_visible (&(*win_info_ptr
)->generic
);
1001 tui_make_visible ((*win_info_ptr
)->detail
.source_info
.execution_info
);
1003 if ((*win_info_ptr
) != NULL
)
1005 (*win_info_ptr
)->detail
.source_info
.has_locator
= TRUE
;
1006 tui_make_visible (locator
);
1007 tui_show_locator_content ();
1008 tui_show_source_content (*win_info_ptr
);
1010 if (TUI_CMD_WIN
== NULL
)
1012 make_command_window (&TUI_CMD_WIN
, cmd_height
, src_height
);
1013 tui_refresh_win (&TUI_CMD_WIN
->generic
);
1017 init_gen_win_info (&TUI_CMD_WIN
->generic
,
1018 TUI_CMD_WIN
->generic
.type
,
1019 TUI_CMD_WIN
->generic
.height
,
1020 TUI_CMD_WIN
->generic
.width
,
1021 TUI_CMD_WIN
->generic
.origin
.x
,
1022 TUI_CMD_WIN
->generic
.origin
.y
);
1023 TUI_CMD_WIN
->can_highlight
= FALSE
;
1024 tui_make_visible (&TUI_CMD_WIN
->generic
);
1027 tui_set_current_layout_to (layout_type
);