tui-layout.c revision 1.1 1 1.1 christos /* TUI layout window management.
2 1.1 christos
3 1.1 christos Copyright (C) 1998-2014 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos Contributed by Hewlett-Packard Company.
6 1.1 christos
7 1.1 christos This file is part of GDB.
8 1.1 christos
9 1.1 christos This program is free software; you can redistribute it and/or modify
10 1.1 christos it under the terms of the GNU General Public License as published by
11 1.1 christos the Free Software Foundation; either version 3 of the License, or
12 1.1 christos (at your option) any later version.
13 1.1 christos
14 1.1 christos This program is distributed in the hope that it will be useful,
15 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
16 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 1.1 christos GNU General Public License for more details.
18 1.1 christos
19 1.1 christos You should have received a copy of the GNU General Public License
20 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 1.1 christos
22 1.1 christos #include "defs.h"
23 1.1 christos #include "arch-utils.h"
24 1.1 christos #include "command.h"
25 1.1 christos #include "symtab.h"
26 1.1 christos #include "frame.h"
27 1.1 christos #include "source.h"
28 1.1 christos #include <ctype.h>
29 1.1 christos
30 1.1 christos #include "tui/tui.h"
31 1.1 christos #include "tui/tui-data.h"
32 1.1 christos #include "tui/tui-windata.h"
33 1.1 christos #include "tui/tui-wingeneral.h"
34 1.1 christos #include "tui/tui-stack.h"
35 1.1 christos #include "tui/tui-regs.h"
36 1.1 christos #include "tui/tui-win.h"
37 1.1 christos #include "tui/tui-winsource.h"
38 1.1 christos #include "tui/tui-disasm.h"
39 1.1 christos #include "tui/tui-layout.h"
40 1.1 christos
41 1.1 christos #include <string.h>
42 1.1 christos #include "gdb_curses.h"
43 1.1 christos
44 1.1 christos /*******************************
45 1.1 christos ** Static Local Decls
46 1.1 christos ********************************/
47 1.1 christos static void show_layout (enum tui_layout_type);
48 1.1 christos static void init_gen_win_info (struct tui_gen_win_info *,
49 1.1 christos enum tui_win_type,
50 1.1 christos int, int, int, int);
51 1.1 christos static void *init_and_make_win (void *, enum tui_win_type,
52 1.1 christos int, int, int, int, int);
53 1.1 christos static void show_source_or_disasm_and_command (enum tui_layout_type);
54 1.1 christos static void make_source_or_disasm_window (struct tui_win_info **,
55 1.1 christos enum tui_win_type,
56 1.1 christos int, int);
57 1.1 christos static void make_command_window (struct tui_win_info **, int, int);
58 1.1 christos static void make_source_window (struct tui_win_info **, int, int);
59 1.1 christos static void make_disasm_window (struct tui_win_info **, int, int);
60 1.1 christos static void make_data_window (struct tui_win_info **, int, int);
61 1.1 christos static void show_source_command (void);
62 1.1 christos static void show_disasm_command (void);
63 1.1 christos static void show_source_disasm_command (void);
64 1.1 christos static void show_data (enum tui_layout_type);
65 1.1 christos static enum tui_layout_type next_layout (void);
66 1.1 christos static enum tui_layout_type prev_layout (void);
67 1.1 christos static void tui_layout_command (char *, int);
68 1.1 christos static void tui_toggle_layout_command (char *, int);
69 1.1 christos static void tui_toggle_split_layout_command (char *, int);
70 1.1 christos static void extract_display_start_addr (struct gdbarch **, CORE_ADDR *);
71 1.1 christos static void tui_handle_xdb_layout (struct tui_layout_def *);
72 1.1 christos
73 1.1 christos
74 1.1 christos /***************************************
75 1.1 christos ** DEFINITIONS
76 1.1 christos ***************************************/
77 1.1 christos
78 1.1 christos #define LAYOUT_USAGE "Usage: layout prev | next | <layout_name> \n"
79 1.1 christos
80 1.1 christos /* Show the screen layout defined. */
81 1.1 christos static void
82 1.1 christos show_layout (enum tui_layout_type layout)
83 1.1 christos {
84 1.1 christos enum tui_layout_type cur_layout = tui_current_layout ();
85 1.1 christos
86 1.1 christos if (layout != cur_layout)
87 1.1 christos {
88 1.1 christos /* Since the new layout may cause changes in window size, we
89 1.1 christos should free the content and reallocate on next display of
90 1.1 christos source/asm. */
91 1.1 christos tui_free_all_source_wins_content ();
92 1.1 christos tui_clear_source_windows ();
93 1.1 christos if (layout == SRC_DATA_COMMAND
94 1.1 christos || layout == DISASSEM_DATA_COMMAND)
95 1.1 christos {
96 1.1 christos show_data (layout);
97 1.1 christos tui_refresh_all (tui_win_list);
98 1.1 christos }
99 1.1 christos else
100 1.1 christos {
101 1.1 christos /* First make the current layout be invisible. */
102 1.1 christos tui_make_all_invisible ();
103 1.1 christos tui_make_invisible (tui_locator_win_info_ptr ());
104 1.1 christos
105 1.1 christos switch (layout)
106 1.1 christos {
107 1.1 christos /* Now show the new layout. */
108 1.1 christos case SRC_COMMAND:
109 1.1 christos show_source_command ();
110 1.1 christos tui_add_to_source_windows (TUI_SRC_WIN);
111 1.1 christos break;
112 1.1 christos case DISASSEM_COMMAND:
113 1.1 christos show_disasm_command ();
114 1.1 christos tui_add_to_source_windows (TUI_DISASM_WIN);
115 1.1 christos break;
116 1.1 christos case SRC_DISASSEM_COMMAND:
117 1.1 christos show_source_disasm_command ();
118 1.1 christos tui_add_to_source_windows (TUI_SRC_WIN);
119 1.1 christos tui_add_to_source_windows (TUI_DISASM_WIN);
120 1.1 christos break;
121 1.1 christos default:
122 1.1 christos break;
123 1.1 christos }
124 1.1 christos }
125 1.1 christos }
126 1.1 christos }
127 1.1 christos
128 1.1 christos
129 1.1 christos /* Function to set the layout to SRC_COMMAND, DISASSEM_COMMAND,
130 1.1 christos SRC_DISASSEM_COMMAND, SRC_DATA_COMMAND, or DISASSEM_DATA_COMMAND.
131 1.1 christos If the layout is SRC_DATA_COMMAND, DISASSEM_DATA_COMMAND, or
132 1.1 christos UNDEFINED_LAYOUT, then the data window is populated according to
133 1.1 christos regs_display_type. */
134 1.1 christos enum tui_status
135 1.1 christos tui_set_layout (enum tui_layout_type layout_type,
136 1.1 christos enum tui_register_display_type regs_display_type)
137 1.1 christos {
138 1.1 christos enum tui_status status = TUI_SUCCESS;
139 1.1 christos
140 1.1 christos if (layout_type != UNDEFINED_LAYOUT
141 1.1 christos || regs_display_type != TUI_UNDEFINED_REGS)
142 1.1 christos {
143 1.1 christos enum tui_layout_type cur_layout = tui_current_layout (),
144 1.1 christos new_layout = UNDEFINED_LAYOUT;
145 1.1 christos int regs_populate = FALSE;
146 1.1 christos struct gdbarch *gdbarch;
147 1.1 christos CORE_ADDR addr;
148 1.1 christos struct tui_win_info *win_with_focus = tui_win_with_focus ();
149 1.1 christos struct tui_layout_def *layout_def = tui_layout_def ();
150 1.1 christos
151 1.1 christos extract_display_start_addr (&gdbarch, &addr);
152 1.1 christos
153 1.1 christos if (layout_type == UNDEFINED_LAYOUT
154 1.1 christos && regs_display_type != TUI_UNDEFINED_REGS)
155 1.1 christos {
156 1.1 christos if (cur_layout == SRC_DISASSEM_COMMAND)
157 1.1 christos new_layout = DISASSEM_DATA_COMMAND;
158 1.1 christos else if (cur_layout == SRC_COMMAND
159 1.1 christos || cur_layout == SRC_DATA_COMMAND)
160 1.1 christos new_layout = SRC_DATA_COMMAND;
161 1.1 christos else if (cur_layout == DISASSEM_COMMAND
162 1.1 christos || cur_layout == DISASSEM_DATA_COMMAND)
163 1.1 christos new_layout = DISASSEM_DATA_COMMAND;
164 1.1 christos }
165 1.1 christos else
166 1.1 christos new_layout = layout_type;
167 1.1 christos
168 1.1 christos regs_populate = (new_layout == SRC_DATA_COMMAND
169 1.1 christos || new_layout == DISASSEM_DATA_COMMAND
170 1.1 christos || regs_display_type != TUI_UNDEFINED_REGS);
171 1.1 christos if (new_layout != cur_layout
172 1.1 christos || regs_display_type != TUI_UNDEFINED_REGS)
173 1.1 christos {
174 1.1 christos if (new_layout != cur_layout)
175 1.1 christos {
176 1.1 christos show_layout (new_layout);
177 1.1 christos
178 1.1 christos /* Now determine where focus should be. */
179 1.1 christos if (win_with_focus != TUI_CMD_WIN)
180 1.1 christos {
181 1.1 christos switch (new_layout)
182 1.1 christos {
183 1.1 christos case SRC_COMMAND:
184 1.1 christos tui_set_win_focus_to (TUI_SRC_WIN);
185 1.1 christos layout_def->display_mode = SRC_WIN;
186 1.1 christos layout_def->split = FALSE;
187 1.1 christos break;
188 1.1 christos case DISASSEM_COMMAND:
189 1.1 christos /* The previous layout was not showing code.
190 1.1 christos This can happen if there is no source
191 1.1 christos available:
192 1.1 christos
193 1.1 christos 1. if the source file is in another dir OR
194 1.1 christos 2. if target was compiled without -g
195 1.1 christos We still want to show the assembly though! */
196 1.1 christos
197 1.1 christos tui_get_begin_asm_address (&gdbarch, &addr);
198 1.1 christos tui_set_win_focus_to (TUI_DISASM_WIN);
199 1.1 christos layout_def->display_mode = DISASSEM_WIN;
200 1.1 christos layout_def->split = FALSE;
201 1.1 christos break;
202 1.1 christos case SRC_DISASSEM_COMMAND:
203 1.1 christos /* The previous layout was not showing code.
204 1.1 christos This can happen if there is no source
205 1.1 christos available:
206 1.1 christos
207 1.1 christos 1. if the source file is in another dir OR
208 1.1 christos 2. if target was compiled without -g
209 1.1 christos We still want to show the assembly though! */
210 1.1 christos
211 1.1 christos tui_get_begin_asm_address (&gdbarch, &addr);
212 1.1 christos if (win_with_focus == TUI_SRC_WIN)
213 1.1 christos tui_set_win_focus_to (TUI_SRC_WIN);
214 1.1 christos else
215 1.1 christos tui_set_win_focus_to (TUI_DISASM_WIN);
216 1.1 christos layout_def->split = TRUE;
217 1.1 christos break;
218 1.1 christos case SRC_DATA_COMMAND:
219 1.1 christos if (win_with_focus != TUI_DATA_WIN)
220 1.1 christos tui_set_win_focus_to (TUI_SRC_WIN);
221 1.1 christos else
222 1.1 christos tui_set_win_focus_to (TUI_DATA_WIN);
223 1.1 christos layout_def->display_mode = SRC_WIN;
224 1.1 christos layout_def->split = FALSE;
225 1.1 christos break;
226 1.1 christos case DISASSEM_DATA_COMMAND:
227 1.1 christos /* The previous layout was not showing code.
228 1.1 christos This can happen if there is no source
229 1.1 christos available:
230 1.1 christos
231 1.1 christos 1. if the source file is in another dir OR
232 1.1 christos 2. if target was compiled without -g
233 1.1 christos We still want to show the assembly though! */
234 1.1 christos
235 1.1 christos tui_get_begin_asm_address (&gdbarch, &addr);
236 1.1 christos if (win_with_focus != TUI_DATA_WIN)
237 1.1 christos tui_set_win_focus_to (TUI_DISASM_WIN);
238 1.1 christos else
239 1.1 christos tui_set_win_focus_to (TUI_DATA_WIN);
240 1.1 christos layout_def->display_mode = DISASSEM_WIN;
241 1.1 christos layout_def->split = FALSE;
242 1.1 christos break;
243 1.1 christos default:
244 1.1 christos break;
245 1.1 christos }
246 1.1 christos }
247 1.1 christos /*
248 1.1 christos * Now update the window content.
249 1.1 christos */
250 1.1 christos if (!regs_populate
251 1.1 christos && (new_layout == SRC_DATA_COMMAND
252 1.1 christos || new_layout == DISASSEM_DATA_COMMAND))
253 1.1 christos tui_display_all_data ();
254 1.1 christos
255 1.1 christos tui_update_source_windows_with_addr (gdbarch, addr);
256 1.1 christos }
257 1.1 christos if (regs_populate)
258 1.1 christos {
259 1.1 christos tui_show_registers (TUI_DATA_WIN->detail.data_display_info.current_group);
260 1.1 christos }
261 1.1 christos }
262 1.1 christos }
263 1.1 christos else
264 1.1 christos status = TUI_FAILURE;
265 1.1 christos
266 1.1 christos return status;
267 1.1 christos }
268 1.1 christos
269 1.1 christos /* Add the specified window to the layout in a logical way. This
270 1.1 christos means setting up the most logical layout given the window to be
271 1.1 christos added. */
272 1.1 christos void
273 1.1 christos tui_add_win_to_layout (enum tui_win_type type)
274 1.1 christos {
275 1.1 christos enum tui_layout_type cur_layout = tui_current_layout ();
276 1.1 christos
277 1.1 christos switch (type)
278 1.1 christos {
279 1.1 christos case SRC_WIN:
280 1.1 christos if (cur_layout != SRC_COMMAND
281 1.1 christos && cur_layout != SRC_DISASSEM_COMMAND
282 1.1 christos && cur_layout != SRC_DATA_COMMAND)
283 1.1 christos {
284 1.1 christos tui_clear_source_windows_detail ();
285 1.1 christos if (cur_layout == DISASSEM_DATA_COMMAND)
286 1.1 christos show_layout (SRC_DATA_COMMAND);
287 1.1 christos else
288 1.1 christos show_layout (SRC_COMMAND);
289 1.1 christos }
290 1.1 christos break;
291 1.1 christos case DISASSEM_WIN:
292 1.1 christos if (cur_layout != DISASSEM_COMMAND
293 1.1 christos && cur_layout != SRC_DISASSEM_COMMAND
294 1.1 christos && cur_layout != DISASSEM_DATA_COMMAND)
295 1.1 christos {
296 1.1 christos tui_clear_source_windows_detail ();
297 1.1 christos if (cur_layout == SRC_DATA_COMMAND)
298 1.1 christos show_layout (DISASSEM_DATA_COMMAND);
299 1.1 christos else
300 1.1 christos show_layout (DISASSEM_COMMAND);
301 1.1 christos }
302 1.1 christos break;
303 1.1 christos case DATA_WIN:
304 1.1 christos if (cur_layout != SRC_DATA_COMMAND
305 1.1 christos && cur_layout != DISASSEM_DATA_COMMAND)
306 1.1 christos {
307 1.1 christos if (cur_layout == DISASSEM_COMMAND)
308 1.1 christos show_layout (DISASSEM_DATA_COMMAND);
309 1.1 christos else
310 1.1 christos show_layout (SRC_DATA_COMMAND);
311 1.1 christos }
312 1.1 christos break;
313 1.1 christos default:
314 1.1 christos break;
315 1.1 christos }
316 1.1 christos }
317 1.1 christos
318 1.1 christos
319 1.1 christos /* Answer the height of a window. If it hasn't been created yet,
320 1.1 christos answer what the height of a window would be based upon its type and
321 1.1 christos the layout. */
322 1.1 christos int
323 1.1 christos tui_default_win_height (enum tui_win_type type,
324 1.1 christos enum tui_layout_type layout)
325 1.1 christos {
326 1.1 christos int h;
327 1.1 christos
328 1.1 christos if (tui_win_list[type] != (struct tui_win_info *) NULL)
329 1.1 christos h = tui_win_list[type]->generic.height;
330 1.1 christos else
331 1.1 christos {
332 1.1 christos switch (layout)
333 1.1 christos {
334 1.1 christos case SRC_COMMAND:
335 1.1 christos case DISASSEM_COMMAND:
336 1.1 christos if (TUI_CMD_WIN == NULL)
337 1.1 christos h = tui_term_height () / 2;
338 1.1 christos else
339 1.1 christos h = tui_term_height () - TUI_CMD_WIN->generic.height;
340 1.1 christos break;
341 1.1 christos case SRC_DISASSEM_COMMAND:
342 1.1 christos case SRC_DATA_COMMAND:
343 1.1 christos case DISASSEM_DATA_COMMAND:
344 1.1 christos if (TUI_CMD_WIN == NULL)
345 1.1 christos h = tui_term_height () / 3;
346 1.1 christos else
347 1.1 christos h = (tui_term_height () - TUI_CMD_WIN->generic.height) / 2;
348 1.1 christos break;
349 1.1 christos default:
350 1.1 christos h = 0;
351 1.1 christos break;
352 1.1 christos }
353 1.1 christos }
354 1.1 christos
355 1.1 christos return h;
356 1.1 christos }
357 1.1 christos
358 1.1 christos
359 1.1 christos /* Answer the height of a window. If it hasn't been created yet,
360 1.1 christos answer what the height of a window would be based upon its type and
361 1.1 christos the layout. */
362 1.1 christos int
363 1.1 christos tui_default_win_viewport_height (enum tui_win_type type,
364 1.1 christos enum tui_layout_type layout)
365 1.1 christos {
366 1.1 christos int h;
367 1.1 christos
368 1.1 christos h = tui_default_win_height (type, layout);
369 1.1 christos
370 1.1 christos if (tui_win_list[type] == TUI_CMD_WIN)
371 1.1 christos h -= 1;
372 1.1 christos else
373 1.1 christos h -= 2;
374 1.1 christos
375 1.1 christos return h;
376 1.1 christos }
377 1.1 christos
378 1.1 christos
379 1.1 christos /* Function to initialize gdb commands, for tui window layout
380 1.1 christos manipulation. */
381 1.1 christos
382 1.1 christos /* Provide a prototype to silence -Wmissing-prototypes. */
383 1.1 christos extern initialize_file_ftype _initialize_tui_layout;
384 1.1 christos
385 1.1 christos void
386 1.1 christos _initialize_tui_layout (void)
387 1.1 christos {
388 1.1 christos add_com ("layout", class_tui, tui_layout_command, _("\
389 1.1 christos Change the layout of windows.\n\
390 1.1 christos Usage: layout prev | next | <layout_name> \n\
391 1.1 christos Layout names are:\n\
392 1.1 christos src : Displays source and command windows.\n\
393 1.1 christos asm : Displays disassembly and command windows.\n\
394 1.1 christos split : Displays source, disassembly and command windows.\n\
395 1.1 christos regs : Displays register window. If existing layout\n\
396 1.1 christos is source/command or assembly/command, the \n\
397 1.1 christos register window is displayed. If the\n\
398 1.1 christos source/assembly/command (split) is displayed, \n\
399 1.1 christos the register window is displayed with \n\
400 1.1 christos the window that has current logical focus.\n"));
401 1.1 christos if (xdb_commands)
402 1.1 christos {
403 1.1 christos add_com ("td", class_tui, tui_toggle_layout_command, _("\
404 1.1 christos Toggle between Source/Command and Disassembly/Command layouts.\n"));
405 1.1 christos add_com ("ts", class_tui, tui_toggle_split_layout_command, _("\
406 1.1 christos Toggle between Source/Command or Disassembly/Command and \n\
407 1.1 christos Source/Disassembly/Command layouts.\n"));
408 1.1 christos }
409 1.1 christos }
410 1.1 christos
411 1.1 christos
412 1.1 christos /*************************
413 1.1 christos ** STATIC LOCAL FUNCTIONS
414 1.1 christos **************************/
415 1.1 christos
416 1.1 christos
417 1.1 christos /* Function to set the layout to SRC, ASM, SPLIT, NEXT, PREV, DATA,
418 1.1 christos REGS, $REGS, $GREGS, $FREGS, $SREGS. */
419 1.1 christos enum tui_status
420 1.1 christos tui_set_layout_for_display_command (const char *layout_name)
421 1.1 christos {
422 1.1 christos enum tui_status status = TUI_SUCCESS;
423 1.1 christos
424 1.1 christos if (layout_name != (char *) NULL)
425 1.1 christos {
426 1.1 christos int i;
427 1.1 christos char *buf_ptr;
428 1.1 christos enum tui_layout_type new_layout = UNDEFINED_LAYOUT;
429 1.1 christos enum tui_register_display_type dpy_type = TUI_UNDEFINED_REGS;
430 1.1 christos enum tui_layout_type cur_layout = tui_current_layout ();
431 1.1 christos
432 1.1 christos buf_ptr = (char *) xstrdup (layout_name);
433 1.1 christos for (i = 0; (i < strlen (layout_name)); i++)
434 1.1 christos buf_ptr[i] = toupper (buf_ptr[i]);
435 1.1 christos
436 1.1 christos /* First check for ambiguous input. */
437 1.1 christos if (strlen (buf_ptr) <= 1
438 1.1 christos && (*buf_ptr == 'S' || *buf_ptr == '$'))
439 1.1 christos {
440 1.1 christos warning (_("Ambiguous command input."));
441 1.1 christos status = TUI_FAILURE;
442 1.1 christos }
443 1.1 christos else
444 1.1 christos {
445 1.1 christos if (subset_compare (buf_ptr, "SRC"))
446 1.1 christos new_layout = SRC_COMMAND;
447 1.1 christos else if (subset_compare (buf_ptr, "ASM"))
448 1.1 christos new_layout = DISASSEM_COMMAND;
449 1.1 christos else if (subset_compare (buf_ptr, "SPLIT"))
450 1.1 christos new_layout = SRC_DISASSEM_COMMAND;
451 1.1 christos else if (subset_compare (buf_ptr, "REGS")
452 1.1 christos || subset_compare (buf_ptr, TUI_GENERAL_SPECIAL_REGS_NAME)
453 1.1 christos || subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME)
454 1.1 christos || subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME)
455 1.1 christos || subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
456 1.1 christos {
457 1.1 christos if (cur_layout == SRC_COMMAND
458 1.1 christos || cur_layout == SRC_DATA_COMMAND)
459 1.1 christos new_layout = SRC_DATA_COMMAND;
460 1.1 christos else
461 1.1 christos new_layout = DISASSEM_DATA_COMMAND;
462 1.1 christos
463 1.1 christos /* Could ifdef out the following code. when compile with
464 1.1 christos -z, there are null pointer references that cause a
465 1.1 christos core dump if 'layout regs' is the first layout
466 1.1 christos command issued by the user. HP has asked us to hook
467 1.1 christos up this code. - edie epstein */
468 1.1 christos if (subset_compare (buf_ptr, TUI_FLOAT_REGS_NAME))
469 1.1 christos {
470 1.1 christos if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
471 1.1 christos != TUI_SFLOAT_REGS
472 1.1 christos && TUI_DATA_WIN->detail.data_display_info.regs_display_type
473 1.1 christos != TUI_DFLOAT_REGS)
474 1.1 christos dpy_type = TUI_SFLOAT_REGS;
475 1.1 christos else
476 1.1 christos dpy_type =
477 1.1 christos TUI_DATA_WIN->detail.data_display_info.regs_display_type;
478 1.1 christos }
479 1.1 christos else if (subset_compare (buf_ptr,
480 1.1 christos TUI_GENERAL_SPECIAL_REGS_NAME))
481 1.1 christos dpy_type = TUI_GENERAL_AND_SPECIAL_REGS;
482 1.1 christos else if (subset_compare (buf_ptr, TUI_GENERAL_REGS_NAME))
483 1.1 christos dpy_type = TUI_GENERAL_REGS;
484 1.1 christos else if (subset_compare (buf_ptr, TUI_SPECIAL_REGS_NAME))
485 1.1 christos dpy_type = TUI_SPECIAL_REGS;
486 1.1 christos else if (TUI_DATA_WIN)
487 1.1 christos {
488 1.1 christos if (TUI_DATA_WIN->detail.data_display_info.regs_display_type
489 1.1 christos != TUI_UNDEFINED_REGS)
490 1.1 christos dpy_type
491 1.1 christos = TUI_DATA_WIN->detail.data_display_info.regs_display_type;
492 1.1 christos else
493 1.1 christos dpy_type = TUI_GENERAL_REGS;
494 1.1 christos }
495 1.1 christos
496 1.1 christos /* End of potential ifdef.
497 1.1 christos */
498 1.1 christos
499 1.1 christos /* If ifdefed out code above, then assume that the user
500 1.1 christos wishes to display the general purpose registers .
501 1.1 christos */
502 1.1 christos
503 1.1 christos /* dpy_type = TUI_GENERAL_REGS; */
504 1.1 christos }
505 1.1 christos else if (subset_compare (buf_ptr, "NEXT"))
506 1.1 christos new_layout = next_layout ();
507 1.1 christos else if (subset_compare (buf_ptr, "PREV"))
508 1.1 christos new_layout = prev_layout ();
509 1.1 christos else
510 1.1 christos status = TUI_FAILURE;
511 1.1 christos
512 1.1 christos tui_set_layout (new_layout, dpy_type);
513 1.1 christos }
514 1.1 christos xfree (buf_ptr);
515 1.1 christos }
516 1.1 christos else
517 1.1 christos status = TUI_FAILURE;
518 1.1 christos
519 1.1 christos return status;
520 1.1 christos }
521 1.1 christos
522 1.1 christos
523 1.1 christos static void
524 1.1 christos extract_display_start_addr (struct gdbarch **gdbarch_p, CORE_ADDR *addr_p)
525 1.1 christos {
526 1.1 christos enum tui_layout_type cur_layout = tui_current_layout ();
527 1.1 christos struct gdbarch *gdbarch = get_current_arch ();
528 1.1 christos CORE_ADDR addr;
529 1.1 christos CORE_ADDR pc;
530 1.1 christos struct symtab_and_line cursal = get_current_source_symtab_and_line ();
531 1.1 christos
532 1.1 christos switch (cur_layout)
533 1.1 christos {
534 1.1 christos case SRC_COMMAND:
535 1.1 christos case SRC_DATA_COMMAND:
536 1.1 christos gdbarch = TUI_SRC_WIN->detail.source_info.gdbarch;
537 1.1 christos find_line_pc (cursal.symtab,
538 1.1 christos TUI_SRC_WIN->detail.source_info.start_line_or_addr.u.line_no,
539 1.1 christos &pc);
540 1.1 christos addr = pc;
541 1.1 christos break;
542 1.1 christos case DISASSEM_COMMAND:
543 1.1 christos case SRC_DISASSEM_COMMAND:
544 1.1 christos case DISASSEM_DATA_COMMAND:
545 1.1 christos gdbarch = TUI_DISASM_WIN->detail.source_info.gdbarch;
546 1.1 christos addr = TUI_DISASM_WIN->detail.source_info.start_line_or_addr.u.addr;
547 1.1 christos break;
548 1.1 christos default:
549 1.1 christos addr = 0;
550 1.1 christos break;
551 1.1 christos }
552 1.1 christos
553 1.1 christos *gdbarch_p = gdbarch;
554 1.1 christos *addr_p = addr;
555 1.1 christos }
556 1.1 christos
557 1.1 christos
558 1.1 christos static void
559 1.1 christos tui_handle_xdb_layout (struct tui_layout_def *layout_def)
560 1.1 christos {
561 1.1 christos if (layout_def->split)
562 1.1 christos {
563 1.1 christos tui_set_layout (SRC_DISASSEM_COMMAND, TUI_UNDEFINED_REGS);
564 1.1 christos tui_set_win_focus_to (tui_win_list[layout_def->display_mode]);
565 1.1 christos }
566 1.1 christos else
567 1.1 christos {
568 1.1 christos if (layout_def->display_mode == SRC_WIN)
569 1.1 christos tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS);
570 1.1 christos else
571 1.1 christos tui_set_layout (DISASSEM_DATA_COMMAND, layout_def->regs_display_type);
572 1.1 christos }
573 1.1 christos }
574 1.1 christos
575 1.1 christos
576 1.1 christos static void
577 1.1 christos tui_toggle_layout_command (char *arg, int from_tty)
578 1.1 christos {
579 1.1 christos struct tui_layout_def *layout_def = tui_layout_def ();
580 1.1 christos
581 1.1 christos /* Make sure the curses mode is enabled. */
582 1.1 christos tui_enable ();
583 1.1 christos if (layout_def->display_mode == SRC_WIN)
584 1.1 christos layout_def->display_mode = DISASSEM_WIN;
585 1.1 christos else
586 1.1 christos layout_def->display_mode = SRC_WIN;
587 1.1 christos
588 1.1 christos if (!layout_def->split)
589 1.1 christos tui_handle_xdb_layout (layout_def);
590 1.1 christos }
591 1.1 christos
592 1.1 christos
593 1.1 christos static void
594 1.1 christos tui_toggle_split_layout_command (char *arg, int from_tty)
595 1.1 christos {
596 1.1 christos struct tui_layout_def *layout_def = tui_layout_def ();
597 1.1 christos
598 1.1 christos /* Make sure the curses mode is enabled. */
599 1.1 christos tui_enable ();
600 1.1 christos layout_def->split = (!layout_def->split);
601 1.1 christos tui_handle_xdb_layout (layout_def);
602 1.1 christos }
603 1.1 christos
604 1.1 christos
605 1.1 christos static void
606 1.1 christos tui_layout_command (char *arg, int from_tty)
607 1.1 christos {
608 1.1 christos /* Make sure the curses mode is enabled. */
609 1.1 christos tui_enable ();
610 1.1 christos
611 1.1 christos /* Switch to the selected layout. */
612 1.1 christos if (tui_set_layout_for_display_command (arg) != TUI_SUCCESS)
613 1.1 christos warning (_("Invalid layout specified.\n%s"), LAYOUT_USAGE);
614 1.1 christos
615 1.1 christos }
616 1.1 christos
617 1.1 christos /* Answer the previous layout to cycle to. */
618 1.1 christos static enum tui_layout_type
619 1.1 christos next_layout (void)
620 1.1 christos {
621 1.1 christos enum tui_layout_type new_layout;
622 1.1 christos
623 1.1 christos new_layout = tui_current_layout ();
624 1.1 christos if (new_layout == UNDEFINED_LAYOUT)
625 1.1 christos new_layout = SRC_COMMAND;
626 1.1 christos else
627 1.1 christos {
628 1.1 christos new_layout++;
629 1.1 christos if (new_layout == UNDEFINED_LAYOUT)
630 1.1 christos new_layout = SRC_COMMAND;
631 1.1 christos }
632 1.1 christos
633 1.1 christos return new_layout;
634 1.1 christos }
635 1.1 christos
636 1.1 christos
637 1.1 christos /* Answer the next layout to cycle to. */
638 1.1 christos static enum tui_layout_type
639 1.1 christos prev_layout (void)
640 1.1 christos {
641 1.1 christos enum tui_layout_type new_layout;
642 1.1 christos
643 1.1 christos new_layout = tui_current_layout ();
644 1.1 christos if (new_layout == SRC_COMMAND)
645 1.1 christos new_layout = DISASSEM_DATA_COMMAND;
646 1.1 christos else
647 1.1 christos {
648 1.1 christos new_layout--;
649 1.1 christos if (new_layout == UNDEFINED_LAYOUT)
650 1.1 christos new_layout = DISASSEM_DATA_COMMAND;
651 1.1 christos }
652 1.1 christos
653 1.1 christos return new_layout;
654 1.1 christos }
655 1.1 christos
656 1.1 christos
657 1.1 christos
658 1.1 christos static void
659 1.1 christos make_command_window (struct tui_win_info **win_info_ptr,
660 1.1 christos int height, int origin_y)
661 1.1 christos {
662 1.1 christos *win_info_ptr = init_and_make_win (*win_info_ptr,
663 1.1 christos CMD_WIN,
664 1.1 christos height,
665 1.1 christos tui_term_width (),
666 1.1 christos 0,
667 1.1 christos origin_y,
668 1.1 christos DONT_BOX_WINDOW);
669 1.1 christos
670 1.1 christos (*win_info_ptr)->can_highlight = FALSE;
671 1.1 christos }
672 1.1 christos
673 1.1 christos
674 1.1 christos /* make_source_window().
675 1.1 christos */
676 1.1 christos static void
677 1.1 christos make_source_window (struct tui_win_info **win_info_ptr,
678 1.1 christos int height, int origin_y)
679 1.1 christos {
680 1.1 christos make_source_or_disasm_window (win_info_ptr, SRC_WIN, height, origin_y);
681 1.1 christos
682 1.1 christos return;
683 1.1 christos } /* make_source_window */
684 1.1 christos
685 1.1 christos
686 1.1 christos /* make_disasm_window().
687 1.1 christos */
688 1.1 christos static void
689 1.1 christos make_disasm_window (struct tui_win_info **win_info_ptr,
690 1.1 christos int height, int origin_y)
691 1.1 christos {
692 1.1 christos make_source_or_disasm_window (win_info_ptr, DISASSEM_WIN, height, origin_y);
693 1.1 christos
694 1.1 christos return;
695 1.1 christos } /* make_disasm_window */
696 1.1 christos
697 1.1 christos
698 1.1 christos static void
699 1.1 christos make_data_window (struct tui_win_info **win_info_ptr,
700 1.1 christos int height, int origin_y)
701 1.1 christos {
702 1.1 christos *win_info_ptr = init_and_make_win (*win_info_ptr,
703 1.1 christos DATA_WIN,
704 1.1 christos height,
705 1.1 christos tui_term_width (),
706 1.1 christos 0,
707 1.1 christos origin_y,
708 1.1 christos BOX_WINDOW);
709 1.1 christos }
710 1.1 christos
711 1.1 christos
712 1.1 christos
713 1.1 christos /* Show the Source/Command layout. */
714 1.1 christos static void
715 1.1 christos show_source_command (void)
716 1.1 christos {
717 1.1 christos show_source_or_disasm_and_command (SRC_COMMAND);
718 1.1 christos }
719 1.1 christos
720 1.1 christos
721 1.1 christos /* Show the Dissassem/Command layout. */
722 1.1 christos static void
723 1.1 christos show_disasm_command (void)
724 1.1 christos {
725 1.1 christos show_source_or_disasm_and_command (DISASSEM_COMMAND);
726 1.1 christos }
727 1.1 christos
728 1.1 christos
729 1.1 christos /* Show the Source/Disassem/Command layout. */
730 1.1 christos static void
731 1.1 christos show_source_disasm_command (void)
732 1.1 christos {
733 1.1 christos if (tui_current_layout () != SRC_DISASSEM_COMMAND)
734 1.1 christos {
735 1.1 christos int cmd_height, src_height, asm_height;
736 1.1 christos
737 1.1 christos if (TUI_CMD_WIN != NULL)
738 1.1 christos cmd_height = TUI_CMD_WIN->generic.height;
739 1.1 christos else
740 1.1 christos cmd_height = tui_term_height () / 3;
741 1.1 christos
742 1.1 christos src_height = (tui_term_height () - cmd_height) / 2;
743 1.1 christos asm_height = tui_term_height () - (src_height + cmd_height);
744 1.1 christos
745 1.1 christos if (TUI_SRC_WIN == NULL)
746 1.1 christos make_source_window (&TUI_SRC_WIN, src_height, 0);
747 1.1 christos else
748 1.1 christos {
749 1.1 christos init_gen_win_info (&TUI_SRC_WIN->generic,
750 1.1 christos TUI_SRC_WIN->generic.type,
751 1.1 christos src_height,
752 1.1 christos TUI_SRC_WIN->generic.width,
753 1.1 christos TUI_SRC_WIN->detail.source_info.execution_info->width,
754 1.1 christos 0);
755 1.1 christos TUI_SRC_WIN->can_highlight = TRUE;
756 1.1 christos init_gen_win_info (TUI_SRC_WIN->detail.source_info.execution_info,
757 1.1 christos EXEC_INFO_WIN,
758 1.1 christos src_height,
759 1.1 christos 3,
760 1.1 christos 0,
761 1.1 christos 0);
762 1.1 christos tui_make_visible (&TUI_SRC_WIN->generic);
763 1.1 christos tui_make_visible (TUI_SRC_WIN->detail.source_info.execution_info);
764 1.1 christos TUI_SRC_WIN->detail.source_info.has_locator = FALSE;;
765 1.1 christos }
766 1.1 christos if (TUI_SRC_WIN != NULL)
767 1.1 christos {
768 1.1 christos struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
769 1.1 christos
770 1.1 christos tui_show_source_content (TUI_SRC_WIN);
771 1.1 christos if (TUI_DISASM_WIN == NULL)
772 1.1 christos {
773 1.1 christos make_disasm_window (&TUI_DISASM_WIN, asm_height, src_height - 1);
774 1.1 christos locator = init_and_make_win (locator,
775 1.1 christos LOCATOR_WIN,
776 1.1 christos 2 /* 1 */ ,
777 1.1 christos tui_term_width (),
778 1.1 christos 0,
779 1.1 christos (src_height + asm_height) - 1,
780 1.1 christos DONT_BOX_WINDOW);
781 1.1 christos }
782 1.1 christos else
783 1.1 christos {
784 1.1 christos init_gen_win_info (locator,
785 1.1 christos LOCATOR_WIN,
786 1.1 christos 2 /* 1 */ ,
787 1.1 christos tui_term_width (),
788 1.1 christos 0,
789 1.1 christos (src_height + asm_height) - 1);
790 1.1 christos TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
791 1.1 christos init_gen_win_info (&TUI_DISASM_WIN->generic,
792 1.1 christos TUI_DISASM_WIN->generic.type,
793 1.1 christos asm_height,
794 1.1 christos TUI_DISASM_WIN->generic.width,
795 1.1 christos TUI_DISASM_WIN->detail.source_info.execution_info->width,
796 1.1 christos src_height - 1);
797 1.1 christos init_gen_win_info (TUI_DISASM_WIN->detail.source_info.execution_info,
798 1.1 christos EXEC_INFO_WIN,
799 1.1 christos asm_height,
800 1.1 christos 3,
801 1.1 christos 0,
802 1.1 christos src_height - 1);
803 1.1 christos TUI_DISASM_WIN->can_highlight = TRUE;
804 1.1 christos tui_make_visible (&TUI_DISASM_WIN->generic);
805 1.1 christos tui_make_visible (TUI_DISASM_WIN->detail.source_info.execution_info);
806 1.1 christos }
807 1.1 christos if (TUI_DISASM_WIN != NULL)
808 1.1 christos {
809 1.1 christos TUI_SRC_WIN->detail.source_info.has_locator = FALSE;
810 1.1 christos TUI_DISASM_WIN->detail.source_info.has_locator = TRUE;
811 1.1 christos tui_make_visible (locator);
812 1.1 christos tui_show_locator_content ();
813 1.1 christos tui_show_source_content (TUI_DISASM_WIN);
814 1.1 christos
815 1.1 christos if (TUI_CMD_WIN == NULL)
816 1.1 christos make_command_window (&TUI_CMD_WIN,
817 1.1 christos cmd_height,
818 1.1 christos tui_term_height () - cmd_height);
819 1.1 christos else
820 1.1 christos {
821 1.1 christos init_gen_win_info (&TUI_CMD_WIN->generic,
822 1.1 christos TUI_CMD_WIN->generic.type,
823 1.1 christos TUI_CMD_WIN->generic.height,
824 1.1 christos TUI_CMD_WIN->generic.width,
825 1.1 christos 0,
826 1.1 christos TUI_CMD_WIN->generic.origin.y);
827 1.1 christos TUI_CMD_WIN->can_highlight = FALSE;
828 1.1 christos tui_make_visible (&TUI_CMD_WIN->generic);
829 1.1 christos }
830 1.1 christos if (TUI_CMD_WIN != NULL)
831 1.1 christos tui_refresh_win (&TUI_CMD_WIN->generic);
832 1.1 christos }
833 1.1 christos }
834 1.1 christos tui_set_current_layout_to (SRC_DISASSEM_COMMAND);
835 1.1 christos }
836 1.1 christos }
837 1.1 christos
838 1.1 christos
839 1.1 christos /* Show the Source/Data/Command or the Dissassembly/Data/Command
840 1.1 christos layout. */
841 1.1 christos static void
842 1.1 christos show_data (enum tui_layout_type new_layout)
843 1.1 christos {
844 1.1 christos int total_height = (tui_term_height () - TUI_CMD_WIN->generic.height);
845 1.1 christos int src_height, data_height;
846 1.1 christos enum tui_win_type win_type;
847 1.1 christos struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
848 1.1 christos
849 1.1 christos
850 1.1 christos data_height = total_height / 2;
851 1.1 christos src_height = total_height - data_height;
852 1.1 christos tui_make_all_invisible ();
853 1.1 christos tui_make_invisible (locator);
854 1.1 christos make_data_window (&TUI_DATA_WIN, data_height, 0);
855 1.1 christos TUI_DATA_WIN->can_highlight = TRUE;
856 1.1 christos if (new_layout == SRC_DATA_COMMAND)
857 1.1 christos win_type = SRC_WIN;
858 1.1 christos else
859 1.1 christos win_type = DISASSEM_WIN;
860 1.1 christos if (tui_win_list[win_type] == NULL)
861 1.1 christos {
862 1.1 christos if (win_type == SRC_WIN)
863 1.1 christos make_source_window (&tui_win_list[win_type], src_height, data_height - 1);
864 1.1 christos else
865 1.1 christos make_disasm_window (&tui_win_list[win_type], src_height, data_height - 1);
866 1.1 christos locator = init_and_make_win (locator,
867 1.1 christos LOCATOR_WIN,
868 1.1 christos 2 /* 1 */ ,
869 1.1 christos tui_term_width (),
870 1.1 christos 0,
871 1.1 christos total_height - 1,
872 1.1 christos DONT_BOX_WINDOW);
873 1.1 christos }
874 1.1 christos else
875 1.1 christos {
876 1.1 christos init_gen_win_info (&tui_win_list[win_type]->generic,
877 1.1 christos tui_win_list[win_type]->generic.type,
878 1.1 christos src_height,
879 1.1 christos tui_win_list[win_type]->generic.width,
880 1.1 christos tui_win_list[win_type]->detail.source_info.execution_info->width,
881 1.1 christos data_height - 1);
882 1.1 christos init_gen_win_info (tui_win_list[win_type]->detail.source_info.execution_info,
883 1.1 christos EXEC_INFO_WIN,
884 1.1 christos src_height,
885 1.1 christos 3,
886 1.1 christos 0,
887 1.1 christos data_height - 1);
888 1.1 christos tui_make_visible (&tui_win_list[win_type]->generic);
889 1.1 christos tui_make_visible (tui_win_list[win_type]->detail.source_info.execution_info);
890 1.1 christos init_gen_win_info (locator,
891 1.1 christos LOCATOR_WIN,
892 1.1 christos 2 /* 1 */ ,
893 1.1 christos tui_term_width (),
894 1.1 christos 0,
895 1.1 christos total_height - 1);
896 1.1 christos }
897 1.1 christos tui_win_list[win_type]->detail.source_info.has_locator = TRUE;
898 1.1 christos tui_make_visible (locator);
899 1.1 christos tui_show_locator_content ();
900 1.1 christos tui_add_to_source_windows (tui_win_list[win_type]);
901 1.1 christos tui_set_current_layout_to (new_layout);
902 1.1 christos }
903 1.1 christos
904 1.1 christos /* init_gen_win_info().
905 1.1 christos */
906 1.1 christos static void
907 1.1 christos init_gen_win_info (struct tui_gen_win_info *win_info,
908 1.1 christos enum tui_win_type type,
909 1.1 christos int height, int width,
910 1.1 christos int origin_x, int origin_y)
911 1.1 christos {
912 1.1 christos int h = height;
913 1.1 christos
914 1.1 christos win_info->type = type;
915 1.1 christos win_info->width = width;
916 1.1 christos win_info->height = h;
917 1.1 christos if (h > 1)
918 1.1 christos {
919 1.1 christos win_info->viewport_height = h - 1;
920 1.1 christos if (win_info->type != CMD_WIN)
921 1.1 christos win_info->viewport_height--;
922 1.1 christos }
923 1.1 christos else
924 1.1 christos win_info->viewport_height = 1;
925 1.1 christos win_info->origin.x = origin_x;
926 1.1 christos win_info->origin.y = origin_y;
927 1.1 christos
928 1.1 christos return;
929 1.1 christos } /* init_gen_win_info */
930 1.1 christos
931 1.1 christos /* init_and_make_win().
932 1.1 christos */
933 1.1 christos static void *
934 1.1 christos init_and_make_win (void *opaque_win_info,
935 1.1 christos enum tui_win_type win_type,
936 1.1 christos int height, int width,
937 1.1 christos int origin_x, int origin_y,
938 1.1 christos int box_it)
939 1.1 christos {
940 1.1 christos struct tui_gen_win_info *generic;
941 1.1 christos
942 1.1 christos if (opaque_win_info == NULL)
943 1.1 christos {
944 1.1 christos if (tui_win_is_auxillary (win_type))
945 1.1 christos opaque_win_info = (void *) tui_alloc_generic_win_info ();
946 1.1 christos else
947 1.1 christos opaque_win_info = (void *) tui_alloc_win_info (win_type);
948 1.1 christos }
949 1.1 christos if (tui_win_is_auxillary (win_type))
950 1.1 christos generic = (struct tui_gen_win_info *) opaque_win_info;
951 1.1 christos else
952 1.1 christos generic = &((struct tui_win_info *) opaque_win_info)->generic;
953 1.1 christos
954 1.1 christos if (opaque_win_info != NULL)
955 1.1 christos {
956 1.1 christos init_gen_win_info (generic, win_type, height, width, origin_x, origin_y);
957 1.1 christos if (!tui_win_is_auxillary (win_type))
958 1.1 christos {
959 1.1 christos if (generic->type == CMD_WIN)
960 1.1 christos ((struct tui_win_info *) opaque_win_info)->can_highlight = FALSE;
961 1.1 christos else
962 1.1 christos ((struct tui_win_info *) opaque_win_info)->can_highlight = TRUE;
963 1.1 christos }
964 1.1 christos tui_make_window (generic, box_it);
965 1.1 christos }
966 1.1 christos return opaque_win_info;
967 1.1 christos }
968 1.1 christos
969 1.1 christos
970 1.1 christos static void
971 1.1 christos make_source_or_disasm_window (struct tui_win_info **win_info_ptr,
972 1.1 christos enum tui_win_type type,
973 1.1 christos int height, int origin_y)
974 1.1 christos {
975 1.1 christos struct tui_gen_win_info *execution_info = (struct tui_gen_win_info *) NULL;
976 1.1 christos
977 1.1 christos /* Create the exeuction info window. */
978 1.1 christos if (type == SRC_WIN)
979 1.1 christos execution_info = tui_source_exec_info_win_ptr ();
980 1.1 christos else
981 1.1 christos execution_info = tui_disassem_exec_info_win_ptr ();
982 1.1 christos execution_info = init_and_make_win (execution_info,
983 1.1 christos EXEC_INFO_WIN,
984 1.1 christos height,
985 1.1 christos 3,
986 1.1 christos 0,
987 1.1 christos origin_y,
988 1.1 christos DONT_BOX_WINDOW);
989 1.1 christos
990 1.1 christos /* Now create the source window. */
991 1.1 christos *win_info_ptr = init_and_make_win (*win_info_ptr,
992 1.1 christos type,
993 1.1 christos height,
994 1.1 christos tui_term_width () - execution_info->width,
995 1.1 christos execution_info->width,
996 1.1 christos origin_y,
997 1.1 christos BOX_WINDOW);
998 1.1 christos
999 1.1 christos (*win_info_ptr)->detail.source_info.execution_info = execution_info;
1000 1.1 christos }
1001 1.1 christos
1002 1.1 christos
1003 1.1 christos /* Show the Source/Command or the Disassem layout. */
1004 1.1 christos static void
1005 1.1 christos show_source_or_disasm_and_command (enum tui_layout_type layout_type)
1006 1.1 christos {
1007 1.1 christos if (tui_current_layout () != layout_type)
1008 1.1 christos {
1009 1.1 christos struct tui_win_info **win_info_ptr;
1010 1.1 christos int src_height, cmd_height;
1011 1.1 christos struct tui_gen_win_info *locator = tui_locator_win_info_ptr ();
1012 1.1 christos
1013 1.1 christos if (TUI_CMD_WIN != NULL)
1014 1.1 christos cmd_height = TUI_CMD_WIN->generic.height;
1015 1.1 christos else
1016 1.1 christos cmd_height = tui_term_height () / 3;
1017 1.1 christos src_height = tui_term_height () - cmd_height;
1018 1.1 christos
1019 1.1 christos if (layout_type == SRC_COMMAND)
1020 1.1 christos win_info_ptr = &TUI_SRC_WIN;
1021 1.1 christos else
1022 1.1 christos win_info_ptr = &TUI_DISASM_WIN;
1023 1.1 christos
1024 1.1 christos if ((*win_info_ptr) == NULL)
1025 1.1 christos {
1026 1.1 christos if (layout_type == SRC_COMMAND)
1027 1.1 christos make_source_window (win_info_ptr, src_height - 1, 0);
1028 1.1 christos else
1029 1.1 christos make_disasm_window (win_info_ptr, src_height - 1, 0);
1030 1.1 christos locator = init_and_make_win (locator,
1031 1.1 christos LOCATOR_WIN,
1032 1.1 christos 2 /* 1 */ ,
1033 1.1 christos tui_term_width (),
1034 1.1 christos 0,
1035 1.1 christos src_height - 1,
1036 1.1 christos DONT_BOX_WINDOW);
1037 1.1 christos }
1038 1.1 christos else
1039 1.1 christos {
1040 1.1 christos init_gen_win_info (locator,
1041 1.1 christos LOCATOR_WIN,
1042 1.1 christos 2 /* 1 */ ,
1043 1.1 christos tui_term_width (),
1044 1.1 christos 0,
1045 1.1 christos src_height - 1);
1046 1.1 christos (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1047 1.1 christos init_gen_win_info (&(*win_info_ptr)->generic,
1048 1.1 christos (*win_info_ptr)->generic.type,
1049 1.1 christos src_height - 1,
1050 1.1 christos (*win_info_ptr)->generic.width,
1051 1.1 christos (*win_info_ptr)->detail.source_info.execution_info->width,
1052 1.1 christos 0);
1053 1.1 christos init_gen_win_info ((*win_info_ptr)->detail.source_info.execution_info,
1054 1.1 christos EXEC_INFO_WIN,
1055 1.1 christos src_height - 1,
1056 1.1 christos 3,
1057 1.1 christos 0,
1058 1.1 christos 0);
1059 1.1 christos (*win_info_ptr)->can_highlight = TRUE;
1060 1.1 christos tui_make_visible (&(*win_info_ptr)->generic);
1061 1.1 christos tui_make_visible ((*win_info_ptr)->detail.source_info.execution_info);
1062 1.1 christos }
1063 1.1 christos if ((*win_info_ptr) != NULL)
1064 1.1 christos {
1065 1.1 christos (*win_info_ptr)->detail.source_info.has_locator = TRUE;
1066 1.1 christos tui_make_visible (locator);
1067 1.1 christos tui_show_locator_content ();
1068 1.1 christos tui_show_source_content (*win_info_ptr);
1069 1.1 christos
1070 1.1 christos if (TUI_CMD_WIN == NULL)
1071 1.1 christos {
1072 1.1 christos make_command_window (&TUI_CMD_WIN, cmd_height, src_height);
1073 1.1 christos tui_refresh_win (&TUI_CMD_WIN->generic);
1074 1.1 christos }
1075 1.1 christos else
1076 1.1 christos {
1077 1.1 christos init_gen_win_info (&TUI_CMD_WIN->generic,
1078 1.1 christos TUI_CMD_WIN->generic.type,
1079 1.1 christos TUI_CMD_WIN->generic.height,
1080 1.1 christos TUI_CMD_WIN->generic.width,
1081 1.1 christos TUI_CMD_WIN->generic.origin.x,
1082 1.1 christos TUI_CMD_WIN->generic.origin.y);
1083 1.1 christos TUI_CMD_WIN->can_highlight = FALSE;
1084 1.1 christos tui_make_visible (&TUI_CMD_WIN->generic);
1085 1.1 christos }
1086 1.1 christos }
1087 1.1 christos tui_set_current_layout_to (layout_type);
1088 1.1 christos }
1089 1.1 christos }
1090