133965Sjdp/* General functions for the WDB TUI. 2130561Sobrien 333965Sjdp Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software 433965Sjdp Foundation, Inc. 533965Sjdp 633965Sjdp Contributed by Hewlett-Packard Company. 733965Sjdp 833965Sjdp This file is part of GDB. 933965Sjdp 1033965Sjdp This program is free software; you can redistribute it and/or modify 1133965Sjdp it under the terms of the GNU General Public License as published by 1233965Sjdp the Free Software Foundation; either version 2 of the License, or 1333965Sjdp (at your option) any later version. 1433965Sjdp 1533965Sjdp This program is distributed in the hope that it will be useful, 1633965Sjdp but WITHOUT ANY WARRANTY; without even the implied warranty of 1733965Sjdp MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1833965Sjdp GNU General Public License for more details. 19218822Sdim 20218822Sdim You should have received a copy of the GNU General Public License 2133965Sjdp along with this program; if not, write to the Free Software 2233965Sjdp Foundation, Inc., 59 Temple Place - Suite 330, 2333965Sjdp Boston, MA 02111-1307, USA. */ 2433965Sjdp 2533965Sjdp#include "defs.h" 2633965Sjdp#include "gdbcmd.h" 2733965Sjdp#include "tui/tui.h" 28130561Sobrien#include "tui/tui-hooks.h" 2933965Sjdp#include "tui/tui-data.h" 3033965Sjdp#include "tui/tui-layout.h" 3133965Sjdp#include "tui/tui-io.h" 3233965Sjdp#include "tui/tui-regs.h" 3333965Sjdp#include "tui/tui-stack.h" 3433965Sjdp#include "tui/tui-win.h" 3533965Sjdp#include "tui/tui-winsource.h" 3633965Sjdp#include "tui/tui-windata.h" 3733965Sjdp#include "target.h" 3833965Sjdp#include "frame.h" 3933965Sjdp#include "breakpoint.h" 4033965Sjdp#include "inferior.h" 4133965Sjdp#include "symtab.h" 4233965Sjdp#include "source.h" 4333965Sjdp 4433965Sjdp#include <stdio.h> 4533965Sjdp#include <stdlib.h> 4633965Sjdp#include <ctype.h> 4733965Sjdp#ifdef HAVE_TERM_H 4833965Sjdp#include <term.h> 4933965Sjdp#endif 5033965Sjdp#include <signal.h> 5133965Sjdp#include <fcntl.h> 5233965Sjdp#if 0 5333965Sjdp#include <termio.h> 5433965Sjdp#endif 5533965Sjdp#include <setjmp.h> 5633965Sjdp 5733965Sjdp#include "gdb_curses.h" 5833965Sjdp 5933965Sjdp/* This redefines CTRL if it is not already defined, so it must come 6033965Sjdp after terminal state releated include files like <term.h> and 6133965Sjdp "gdb_ncurses.h". */ 6233965Sjdp#include "readline/readline.h" 6333965Sjdp 6433965Sjdp/* Tells whether the TUI is active or not. */ 6533965Sjdpint tui_active = 0; 6633965Sjdpstatic int tui_finish_init = 1; 6733965Sjdp 6833965Sjdpenum tui_key_mode tui_current_key_mode = TUI_COMMAND_MODE; 6933965Sjdp 7033965Sjdpstruct tui_char_command 7133965Sjdp{ 7233965Sjdp unsigned char key; 7333965Sjdp const char* cmd; 7433965Sjdp}; 7533965Sjdp 7633965Sjdp/* Key mapping to gdb commands when the TUI is using the single key mode. */ 7733965Sjdpstatic const struct tui_char_command tui_commands[] = { 7833965Sjdp { 'c', "continue" }, 7933965Sjdp { 'd', "down" }, 8033965Sjdp { 'f', "finish" }, 8133965Sjdp { 'n', "next" }, 8233965Sjdp { 'r', "run" }, 8333965Sjdp { 's', "step" }, 8433965Sjdp { 'u', "up" }, 8533965Sjdp { 'v', "info locals" }, 8633965Sjdp { 'w', "where" }, 8733965Sjdp { 0, 0 }, 8833965Sjdp}; 8933965Sjdp 9033965Sjdpstatic Keymap tui_keymap; 9133965Sjdpstatic Keymap tui_readline_standard_keymap; 9233965Sjdp 9333965Sjdp/* TUI readline command. 9433965Sjdp Switch the output mode between TUI/standard gdb. */ 9533965Sjdpstatic int 9633965Sjdptui_rl_switch_mode (int notused1, int notused2) 9733965Sjdp{ 9833965Sjdp if (tui_active) 9933965Sjdp { 10033965Sjdp tui_disable (); 10133965Sjdp rl_prep_terminal (0); 10233965Sjdp } 10333965Sjdp else 10433965Sjdp { 10533965Sjdp rl_deprep_terminal (); 10633965Sjdp tui_enable (); 10733965Sjdp } 10833965Sjdp 10933965Sjdp /* Clear the readline in case switching occurred in middle of something. */ 11033965Sjdp if (rl_end) 11133965Sjdp rl_kill_text (0, rl_end); 11233965Sjdp 11333965Sjdp /* Since we left the curses mode, the terminal mode is restored to 11433965Sjdp some previous state. That state may not be suitable for readline 11533965Sjdp to work correctly (it may be restored in line mode). We force an 11633965Sjdp exit of the current readline so that readline is re-entered and it 11733965Sjdp will be able to setup the terminal for its needs. By re-entering 11833965Sjdp in readline, we also redisplay its prompt in the non-curses mode. */ 11933965Sjdp rl_newline (1, '\n'); 12033965Sjdp 12133965Sjdp /* Make sure the \n we are returning does not repeat the last command. */ 12233965Sjdp dont_repeat (); 12333965Sjdp return 0; 12433965Sjdp} 12533965Sjdp 12633965Sjdp/* TUI readline command. 12733965Sjdp Change the TUI layout to show a next layout. 12833965Sjdp This function is bound to CTRL-X 2. It is intended to provide 12933965Sjdp a functionality close to the Emacs split-window command. We always 13033965Sjdp show two windows (src+asm), (src+regs) or (asm+regs). */ 13133965Sjdpstatic int 13233965Sjdptui_rl_change_windows (int notused1, int notused2) 13333965Sjdp{ 13433965Sjdp if (!tui_active) 13533965Sjdp tui_rl_switch_mode (0/*notused*/, 0/*notused*/); 13633965Sjdp 13733965Sjdp if (tui_active) 13833965Sjdp { 13933965Sjdp enum tui_layout_type new_layout; 14033965Sjdp enum tui_register_display_type regs_type = TUI_UNDEFINED_REGS; 14133965Sjdp 14233965Sjdp new_layout = tui_current_layout (); 14333965Sjdp 14433965Sjdp /* Select a new layout to have a rolling layout behavior 14533965Sjdp with always two windows (except when undefined). */ 14633965Sjdp switch (new_layout) 14733965Sjdp { 14833965Sjdp case SRC_COMMAND: 14933965Sjdp new_layout = SRC_DISASSEM_COMMAND; 15033965Sjdp break; 15133965Sjdp 15233965Sjdp case DISASSEM_COMMAND: 15333965Sjdp new_layout = SRC_DISASSEM_COMMAND; 15433965Sjdp break; 15533965Sjdp 15633965Sjdp case SRC_DATA_COMMAND: 15733965Sjdp new_layout = SRC_DISASSEM_COMMAND; 15833965Sjdp break; 15933965Sjdp 16033965Sjdp case SRC_DISASSEM_COMMAND: 16133965Sjdp new_layout = DISASSEM_DATA_COMMAND; 16233965Sjdp break; 16333965Sjdp 16433965Sjdp case DISASSEM_DATA_COMMAND: 16533965Sjdp new_layout = SRC_DATA_COMMAND; 16633965Sjdp break; 16733965Sjdp 16833965Sjdp default: 16933965Sjdp new_layout = SRC_COMMAND; 17033965Sjdp break; 17133965Sjdp } 172130561Sobrien tui_set_layout (new_layout, regs_type); 17333965Sjdp } 17433965Sjdp return 0; 17533965Sjdp} 17633965Sjdp 177130561Sobrien/* TUI readline command. 17833965Sjdp Delete the second TUI window to only show one. */ 17933965Sjdpstatic int 18033965Sjdptui_rl_delete_other_windows (int notused1, int notused2) 18133965Sjdp{ 18233965Sjdp if (!tui_active) 183130561Sobrien tui_rl_switch_mode (0/*notused*/, 0/*notused*/); 18433965Sjdp 18533965Sjdp if (tui_active) 186130561Sobrien { 18733965Sjdp enum tui_layout_type new_layout; 18833965Sjdp enum tui_register_display_type regs_type = TUI_UNDEFINED_REGS; 18933965Sjdp 190130561Sobrien new_layout = tui_current_layout (); 19133965Sjdp 19233965Sjdp /* Kill one window. */ 193130561Sobrien switch (new_layout) 19433965Sjdp { 19533965Sjdp case SRC_COMMAND: 196130561Sobrien case SRC_DATA_COMMAND: 19733965Sjdp case SRC_DISASSEM_COMMAND: 198130561Sobrien default: 199130561Sobrien new_layout = SRC_COMMAND; 20033965Sjdp break; 20133965Sjdp 20233965Sjdp case DISASSEM_COMMAND: 20333965Sjdp case DISASSEM_DATA_COMMAND: 20433965Sjdp new_layout = DISASSEM_COMMAND; 205130561Sobrien break; 206130561Sobrien } 20733965Sjdp tui_set_layout (new_layout, regs_type); 20833965Sjdp } 20933965Sjdp return 0; 210130561Sobrien} 21133965Sjdp 21233965Sjdp/* TUI readline command. 21333965Sjdp Switch the active window to give the focus to a next window. */ 21433965Sjdpstatic int 21533965Sjdptui_rl_other_window (int count, int key) 216130561Sobrien{ 21733965Sjdp struct tui_win_info * win_info; 21833965Sjdp 21933965Sjdp if (!tui_active) 220130561Sobrien tui_rl_switch_mode (0/*notused*/, 0/*notused*/); 22133965Sjdp 22233965Sjdp win_info = tui_next_win (tui_win_with_focus ()); 22333965Sjdp if (win_info) 224130561Sobrien { 22533965Sjdp tui_set_win_focus_to (win_info); 22633965Sjdp if (TUI_DATA_WIN && TUI_DATA_WIN->generic.is_visible) 22733965Sjdp tui_refresh_data_win (); 228130561Sobrien keypad (TUI_CMD_WIN->generic.handle, (win_info != TUI_CMD_WIN)); 22933965Sjdp } 23033965Sjdp return 0; 23133965Sjdp} 23233965Sjdp 23333965Sjdp/* TUI readline command. 23433965Sjdp Execute the gdb command bound to the specified key. */ 235130561Sobrienstatic int 236130561Sobrientui_rl_command_key (int count, int key) 23733965Sjdp{ 23833965Sjdp int i; 23933965Sjdp 24033965Sjdp reinitialize_more_filter (); 241130561Sobrien for (i = 0; tui_commands[i].cmd; i++) 24233965Sjdp { 24333965Sjdp if (tui_commands[i].key == key) 24433965Sjdp { 24533965Sjdp /* Must save the command because it can be modified 24633965Sjdp by execute_command. */ 247130561Sobrien char* cmd = alloca (strlen (tui_commands[i].cmd) + 1); 24833965Sjdp strcpy (cmd, tui_commands[i].cmd); 24933965Sjdp execute_command (cmd, TRUE); 250130561Sobrien return 0; 25133965Sjdp } 25233965Sjdp } 25333965Sjdp return 0; 25433965Sjdp} 25533965Sjdp 256130561Sobrien/* TUI readline command. 25733965Sjdp Temporarily leave the TUI SingleKey mode to allow editing 25833965Sjdp a gdb command with the normal readline. Once the command 25933965Sjdp is executed, the TUI SingleKey mode is installed back. */ 26033965Sjdpstatic int 261130561Sobrientui_rl_command_mode (int count, int key) 26233965Sjdp{ 26333965Sjdp tui_set_key_mode (TUI_ONE_COMMAND_MODE); 26433965Sjdp return rl_insert (count, key); 265130561Sobrien} 26633965Sjdp 26733965Sjdp/* TUI readline command. 26833965Sjdp Switch between TUI SingleKey mode and gdb readline editing. */ 269130561Sobrienstatic int 27033965Sjdptui_rl_next_keymap (int notused1, int notused2) 27133965Sjdp{ 27233965Sjdp if (!tui_active) 27333965Sjdp tui_rl_switch_mode (0/*notused*/, 0/*notused*/); 27433965Sjdp 27533965Sjdp tui_set_key_mode (tui_current_key_mode == TUI_COMMAND_MODE 276130561Sobrien ? TUI_SINGLE_KEY_MODE : TUI_COMMAND_MODE); 27733965Sjdp return 0; 27833965Sjdp} 27933965Sjdp 280130561Sobrien/* Readline hook to redisplay ourself the gdb prompt. 281130561Sobrien In the SingleKey mode, the prompt is not printed so that 28233965Sjdp the command window is cleaner. It will be displayed if 28333965Sjdp we temporarily leave the SingleKey mode. */ 28433965Sjdpstatic int 28533965Sjdptui_rl_startup_hook (void) 28633965Sjdp{ 287130561Sobrien rl_already_prompted = 1; 288130561Sobrien if (tui_current_key_mode != TUI_COMMAND_MODE) 28933965Sjdp tui_set_key_mode (TUI_SINGLE_KEY_MODE); 29033965Sjdp tui_redisplay_readline (); 291130561Sobrien return 0; 29233965Sjdp} 29333965Sjdp 29433965Sjdp/* Change the TUI key mode by installing the appropriate readline keymap. */ 29533965Sjdpvoid 29633965Sjdptui_set_key_mode (enum tui_key_mode mode) 29733965Sjdp{ 29833965Sjdp tui_current_key_mode = mode; 299130561Sobrien rl_set_keymap (mode == TUI_SINGLE_KEY_MODE 300130561Sobrien ? tui_keymap : tui_readline_standard_keymap); 301130561Sobrien tui_show_locator_content (); 30233965Sjdp} 30333965Sjdp 304130561Sobrien/* Initialize readline and configure the keymap for the switching 305130561Sobrien key shortcut. */ 306130561Sobrienvoid 30733965Sjdptui_initialize_readline (void) 30833965Sjdp{ 30933965Sjdp int i; 31033965Sjdp Keymap tui_ctlx_keymap; 311130561Sobrien 312130561Sobrien rl_initialize (); 313104834Sobrien 31433965Sjdp rl_add_defun ("tui-switch-mode", tui_rl_switch_mode, -1); 31533965Sjdp rl_add_defun ("gdb-command", tui_rl_command_key, -1); 31633965Sjdp rl_add_defun ("next-keymap", tui_rl_next_keymap, -1); 31733965Sjdp 318130561Sobrien tui_keymap = rl_make_bare_keymap (); 319130561Sobrien tui_ctlx_keymap = rl_make_bare_keymap (); 32033965Sjdp tui_readline_standard_keymap = rl_get_keymap (); 32133965Sjdp 32233965Sjdp for (i = 0; tui_commands[i].cmd; i++) 32333965Sjdp rl_bind_key_in_map (tui_commands[i].key, tui_rl_command_key, tui_keymap); 32433965Sjdp 32533965Sjdp rl_generic_bind (ISKMAP, "\\C-x", (char*) tui_ctlx_keymap, tui_keymap); 32633965Sjdp 327130561Sobrien /* Bind all other keys to tui_rl_command_mode so that we switch 32833965Sjdp temporarily from SingleKey mode and can enter a gdb command. */ 32933965Sjdp for (i = ' '; i < 0x7f; i++) 33033965Sjdp { 33133965Sjdp int j; 33233965Sjdp 33333965Sjdp for (j = 0; tui_commands[j].cmd; j++) 33433965Sjdp if (tui_commands[j].key == i) 33533965Sjdp break; 336130561Sobrien 337130561Sobrien if (tui_commands[j].cmd) 338130561Sobrien continue; 33933965Sjdp 34033965Sjdp rl_bind_key_in_map (i, tui_rl_command_mode, tui_keymap); 34133965Sjdp } 34233965Sjdp 34333965Sjdp rl_bind_key_in_map ('a', tui_rl_switch_mode, emacs_ctlx_keymap); 344130561Sobrien rl_bind_key_in_map ('a', tui_rl_switch_mode, tui_ctlx_keymap); 345130561Sobrien rl_bind_key_in_map ('A', tui_rl_switch_mode, emacs_ctlx_keymap); 346130561Sobrien rl_bind_key_in_map ('A', tui_rl_switch_mode, tui_ctlx_keymap); 34733965Sjdp rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, emacs_ctlx_keymap); 34833965Sjdp rl_bind_key_in_map (CTRL ('A'), tui_rl_switch_mode, tui_ctlx_keymap); 349130561Sobrien rl_bind_key_in_map ('1', tui_rl_delete_other_windows, emacs_ctlx_keymap); 35033965Sjdp rl_bind_key_in_map ('1', tui_rl_delete_other_windows, tui_ctlx_keymap); 35133965Sjdp rl_bind_key_in_map ('2', tui_rl_change_windows, emacs_ctlx_keymap); 352130561Sobrien rl_bind_key_in_map ('2', tui_rl_change_windows, tui_ctlx_keymap); 35333965Sjdp rl_bind_key_in_map ('o', tui_rl_other_window, emacs_ctlx_keymap); 35433965Sjdp rl_bind_key_in_map ('o', tui_rl_other_window, tui_ctlx_keymap); 35533965Sjdp rl_bind_key_in_map ('q', tui_rl_next_keymap, tui_keymap); 356130561Sobrien rl_bind_key_in_map ('s', tui_rl_next_keymap, emacs_ctlx_keymap); 35733965Sjdp rl_bind_key_in_map ('s', tui_rl_next_keymap, tui_ctlx_keymap); 35833965Sjdp} 35933965Sjdp 36033965Sjdp/* Enter in the tui mode (curses). 36133965Sjdp When in normal mode, it installs the tui hooks in gdb, redirects 36233965Sjdp the gdb output, configures the readline to work in tui mode. 36333965Sjdp When in curses mode, it does nothing. */ 36433965Sjdpvoid 36533965Sjdptui_enable (void) 36633965Sjdp{ 367130561Sobrien if (tui_active) 368130561Sobrien return; 36933965Sjdp 37033965Sjdp /* To avoid to initialize curses when gdb starts, there is a defered 371130561Sobrien curses initialization. This initialization is made only once 37233965Sjdp and the first time the curses mode is entered. */ 37333965Sjdp if (tui_finish_init) 37433965Sjdp { 37533965Sjdp WINDOW *w; 37633965Sjdp 377130561Sobrien w = initscr (); 37833965Sjdp 37933965Sjdp cbreak (); 380130561Sobrien noecho (); 38133965Sjdp /*timeout (1);*/ 38233965Sjdp nodelay(w, FALSE); 383130561Sobrien nl(); 38433965Sjdp keypad (w, TRUE); 38533965Sjdp rl_initialize (); 38633965Sjdp tui_set_term_height_to (LINES); 387130561Sobrien tui_set_term_width_to (COLS); 38833965Sjdp def_prog_mode (); 38933965Sjdp 39033965Sjdp tui_show_frame_info (0); 391130561Sobrien tui_set_layout (SRC_COMMAND, TUI_UNDEFINED_REGS); 392130561Sobrien tui_set_win_focus_to (TUI_SRC_WIN); 39333965Sjdp keypad (TUI_CMD_WIN->generic.handle, TRUE); 39433965Sjdp wrefresh (TUI_CMD_WIN->generic.handle); 395130561Sobrien tui_finish_init = 0; 39633965Sjdp } 39733965Sjdp else 398130561Sobrien { 39933965Sjdp /* Save the current gdb setting of the terminal. 40033965Sjdp Curses will restore this state when endwin() is called. */ 40133965Sjdp def_shell_mode (); 402130561Sobrien clearok (stdscr, TRUE); 403130561Sobrien } 40433965Sjdp 40533965Sjdp /* Install the TUI specific hooks. */ 40633965Sjdp tui_install_hooks (); 40733965Sjdp rl_startup_hook = tui_rl_startup_hook; 408130561Sobrien 40933965Sjdp tui_update_variables (); 41033965Sjdp 41133965Sjdp tui_setup_io (1); 412130561Sobrien 41333965Sjdp tui_active = 1; 41433965Sjdp if (deprecated_selected_frame) 415130561Sobrien tui_show_frame_info (deprecated_selected_frame); 41633965Sjdp 41733965Sjdp /* Restore TUI keymap. */ 418130561Sobrien tui_set_key_mode (tui_current_key_mode); 41933965Sjdp tui_refresh_all_win (); 42033965Sjdp 42133965Sjdp /* Update gdb's knowledge of its terminal. */ 42233965Sjdp target_terminal_save_ours (); 42333965Sjdp tui_update_gdb_sizes (); 42433965Sjdp} 42533965Sjdp 42633965Sjdp/* Leave the tui mode. 42733965Sjdp Remove the tui hooks and configure the gdb output and readline 42833965Sjdp back to their original state. The curses mode is left so that 42933965Sjdp the terminal setting is restored to the point when we entered. */ 43033965Sjdpvoid 431130561Sobrientui_disable (void) 43233965Sjdp{ 43333965Sjdp if (!tui_active) 43433965Sjdp return; 43533965Sjdp 436130561Sobrien /* Restore initial readline keymap. */ 43733965Sjdp rl_set_keymap (tui_readline_standard_keymap); 43833965Sjdp 43933965Sjdp /* Remove TUI hooks. */ 44033965Sjdp tui_remove_hooks (); 441130561Sobrien rl_startup_hook = 0; 44233965Sjdp rl_already_prompted = 0; 44333965Sjdp 44433965Sjdp /* Leave curses and restore previous gdb terminal setting. */ 445130561Sobrien endwin (); 44633965Sjdp 44733965Sjdp /* gdb terminal has changed, update gdb internal copy of it 44833965Sjdp so that terminal management with the inferior works. */ 44933965Sjdp tui_setup_io (0); 450130561Sobrien 451130561Sobrien /* Update gdb's knowledge of its terminal. */ 45233965Sjdp target_terminal_save_ours (); 45333965Sjdp 45433965Sjdp tui_active = 0; 455130561Sobrien tui_update_gdb_sizes (); 456130561Sobrien} 45733965Sjdp 45833965Sjdpvoid 45933965Sjdpstrcat_to_buf (char *buf, int buflen, const char *item_to_add) 46033965Sjdp{ 461130561Sobrien if (item_to_add != (char *) NULL && buf != (char *) NULL) 46233965Sjdp { 46333965Sjdp if ((strlen (buf) + strlen (item_to_add)) <= buflen) 46433965Sjdp strcat (buf, item_to_add); 46533965Sjdp else 46633965Sjdp strncat (buf, item_to_add, (buflen - strlen (buf))); 46733965Sjdp } 468130561Sobrien} 46933965Sjdp 47033965Sjdp#if 0 47133965Sjdp/* Solaris <sys/termios.h> defines CTRL. */ 47233965Sjdp#ifndef CTRL 47333965Sjdp#define CTRL(x) (x & ~0140) 474130561Sobrien#endif 47533965Sjdp 47633965Sjdp#define FILEDES 2 47733965Sjdp#define CHK(val, dft) (val<=0 ? dft : val) 47833965Sjdp 479130561Sobrienstatic void 48033965Sjdptui_reset (void) 48133965Sjdp{ 48233965Sjdp struct termio mode; 48333965Sjdp 484130561Sobrien /* 48533965Sjdp ** reset the teletype mode bits to a sensible state. 48633965Sjdp ** Copied tset.c 48733965Sjdp */ 488130561Sobrien#if ! defined (USG) && defined (TIOCGETC) 48933965Sjdp struct tchars tbuf; 49033965Sjdp#endif /* !USG && TIOCGETC */ 49133965Sjdp#ifdef UCB_NTTY 492130561Sobrien struct ltchars ltc; 49333965Sjdp 49433965Sjdp if (ldisc == NTTYDISC) 49533965Sjdp { 496130561Sobrien ioctl (FILEDES, TIOCGLTC, <c); 49733965Sjdp ltc.t_suspc = CHK (ltc.t_suspc, CTRL ('Z')); 49833965Sjdp ltc.t_dsuspc = CHK (ltc.t_dsuspc, CTRL ('Y')); 49933965Sjdp ltc.t_rprntc = CHK (ltc.t_rprntc, CTRL ('R')); 500130561Sobrien ltc.t_flushc = CHK (ltc.t_flushc, CTRL ('O')); 501130561Sobrien ltc.t_werasc = CHK (ltc.t_werasc, CTRL ('W')); 50233965Sjdp ltc.t_lnextc = CHK (ltc.t_lnextc, CTRL ('V')); 50333965Sjdp ioctl (FILEDES, TIOCSLTC, <c); 50433965Sjdp } 505130561Sobrien#endif /* UCB_NTTY */ 506130561Sobrien#ifndef USG 50733965Sjdp#ifdef TIOCGETC 50833965Sjdp ioctl (FILEDES, TIOCGETC, &tbuf); 50933965Sjdp tbuf.t_intrc = CHK (tbuf.t_intrc, CTRL ('?')); 510130561Sobrien tbuf.t_quitc = CHK (tbuf.t_quitc, CTRL ('\\')); 511130561Sobrien tbuf.t_startc = CHK (tbuf.t_startc, CTRL ('Q')); 51233965Sjdp tbuf.t_stopc = CHK (tbuf.t_stopc, CTRL ('S')); 51333965Sjdp tbuf.t_eofc = CHK (tbuf.t_eofc, CTRL ('D')); 51433965Sjdp /* brkc is left alone */ 51533965Sjdp ioctl (FILEDES, TIOCSETC, &tbuf); 51633965Sjdp#endif /* TIOCGETC */ 51733965Sjdp mode.sg_flags &= ~(RAW 51833965Sjdp#ifdef CBREAK 51933965Sjdp | CBREAK 52033965Sjdp#endif /* CBREAK */ 521130561Sobrien | VTDELAY | ALLDELAY); 52233965Sjdp mode.sg_flags |= XTABS | ECHO | CRMOD | ANYP; 52333965Sjdp#else /*USG */ 52433965Sjdp ioctl (FILEDES, TCGETA, &mode); 525130561Sobrien mode.c_cc[VINTR] = CHK (mode.c_cc[VINTR], CTRL ('?')); 52633965Sjdp mode.c_cc[VQUIT] = CHK (mode.c_cc[VQUIT], CTRL ('\\')); 527130561Sobrien mode.c_cc[VEOF] = CHK (mode.c_cc[VEOF], CTRL ('D')); 52833965Sjdp 52933965Sjdp mode.c_iflag &= ~(IGNBRK | PARMRK | INPCK | INLCR | IGNCR | IUCLC | IXOFF); 530130561Sobrien mode.c_iflag |= (BRKINT | ISTRIP | ICRNL | IXON); 53133965Sjdp mode.c_oflag &= ~(OLCUC | OCRNL | ONOCR | ONLRET | OFILL | OFDEL | 53233965Sjdp NLDLY | CRDLY | TABDLY | BSDLY | VTDLY | FFDLY); 53333965Sjdp mode.c_oflag |= (OPOST | ONLCR); 53433965Sjdp mode.c_cflag &= ~(CSIZE | PARODD | CLOCAL); 53533965Sjdp#ifndef hp9000s800 536130561Sobrien mode.c_cflag |= (CS8 | CREAD); 53733965Sjdp#else /*hp9000s800 */ 53833965Sjdp mode.c_cflag |= (CS8 | CSTOPB | CREAD); 53933965Sjdp#endif /* hp9000s800 */ 540130561Sobrien mode.c_lflag &= ~(XCASE | ECHONL | NOFLSH); 54133965Sjdp mode.c_lflag |= (ISIG | ICANON | ECHO | ECHOK); 54233965Sjdp ioctl (FILEDES, TCSETAW, &mode); 54333965Sjdp#endif /* USG */ 544130561Sobrien 54533965Sjdp return; 546130561Sobrien} 547130561Sobrien#endif 54833965Sjdp 54933965Sjdpvoid 55033965Sjdptui_show_source (const char *file, int line) 551130561Sobrien{ 55233965Sjdp struct symtab_and_line cursal = get_current_source_symtab_and_line (); 55333965Sjdp /* make sure that the source window is displayed */ 55433965Sjdp tui_add_win_to_layout (SRC_WIN); 55533965Sjdp 55633965Sjdp tui_update_source_windows_with_line (cursal.symtab, line); 557130561Sobrien tui_update_locator_filename (file); 55833965Sjdp} 55933965Sjdp 56033965Sjdpvoid 561130561Sobrientui_show_assembly (CORE_ADDR addr) 562130561Sobrien{ 56333965Sjdp tui_add_win_to_layout (DISASSEM_WIN); 56433965Sjdp tui_update_source_windows_with_addr (addr); 56533965Sjdp} 56633965Sjdp 56733965Sjdpint 568130561Sobrientui_is_window_visible (enum tui_win_type type) 56933965Sjdp{ 57033965Sjdp if (tui_active == 0) 57133965Sjdp return 0; 572130561Sobrien 57333965Sjdp if (tui_win_list[type] == 0) 57433965Sjdp return 0; 57533965Sjdp 576130561Sobrien return tui_win_list[type]->generic.is_visible; 57733965Sjdp} 57833965Sjdp 57933965Sjdpint 58033965Sjdptui_get_command_dimension (int *width, int *height) 581130561Sobrien{ 58233965Sjdp if (!tui_active || (TUI_CMD_WIN == NULL)) 58333965Sjdp { 58433965Sjdp return 0; 585130561Sobrien } 58633965Sjdp 58733965Sjdp *width = TUI_CMD_WIN->generic.width; 58833965Sjdp *height = TUI_CMD_WIN->generic.height; 58933965Sjdp return 1; 590130561Sobrien} 59133965Sjdp