2004-02-10 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / tui / tui-command.c
1 /* Specific command window processing.
2
3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
4 Foundation, Inc.
5
6 Contributed by Hewlett-Packard Company.
7
8 This file is part of GDB.
9
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.
14
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.
19
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., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
24
25 #include "defs.h"
26 #include <ctype.h>
27 #include "tui/tui.h"
28 #include "tui/tui-data.h"
29 #include "tui/tui-win.h"
30 #include "tui/tui-io.h"
31
32 #include "gdb_curses.h"
33
34
35 /*****************************************
36 ** STATIC LOCAL FUNCTIONS FORWARD DECLS **
37 ******************************************/
38
39
40
41 /*****************************************
42 ** PUBLIC FUNCTIONS **
43 ******************************************/
44
45 /* Dispatch the correct tui function based upon the control character. */
46 unsigned int
47 tui_dispatch_ctrl_char (unsigned int ch)
48 {
49 struct tui_win_info *win_info = tui_win_with_focus ();
50 WINDOW *w = TUI_CMD_WIN->generic.handle;
51
52 /*
53 ** If the command window has the logical focus, or no-one does
54 ** assume it is the command window; in this case, pass the
55 ** character on through and do nothing here.
56 */
57 if (win_info == NULL || win_info == TUI_CMD_WIN)
58 return ch;
59 else
60 {
61 unsigned int c = 0, ch_copy = ch;
62 int i;
63 char *term;
64
65 /* If this is an xterm, page next/prev keys aren't returned
66 ** by keypad as a single char, so we must handle them here.
67 ** Seems like a bug in the curses library?
68 */
69 term = (char *) getenv ("TERM");
70 for (i = 0; (term && term[i]); i++)
71 term[i] = toupper (term[i]);
72 if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch))
73 {
74 unsigned int page_ch = 0;
75 unsigned int tmp_char;
76
77 tmp_char = 0;
78 while (!key_is_end_sequence (tmp_char))
79 {
80 tmp_char = (int) wgetch (w);
81 if (tmp_char == ERR)
82 {
83 return ch;
84 }
85 if (!tmp_char)
86 break;
87 if (tmp_char == 53)
88 page_ch = KEY_PPAGE;
89 else if (tmp_char == 54)
90 page_ch = KEY_NPAGE;
91 else
92 {
93 return 0;
94 }
95 }
96 ch_copy = page_ch;
97 }
98
99 switch (ch_copy)
100 {
101 case KEY_NPAGE:
102 tui_scroll_forward (win_info, 0);
103 break;
104 case KEY_PPAGE:
105 tui_scroll_backward (win_info, 0);
106 break;
107 case KEY_DOWN:
108 case KEY_SF:
109 tui_scroll_forward (win_info, 1);
110 break;
111 case KEY_UP:
112 case KEY_SR:
113 tui_scroll_backward (win_info, 1);
114 break;
115 case KEY_RIGHT:
116 tui_scroll_left (win_info, 1);
117 break;
118 case KEY_LEFT:
119 tui_scroll_right (win_info, 1);
120 break;
121 case '\f':
122 tui_refresh_all_win ();
123 break;
124 default:
125 c = ch_copy;
126 break;
127 }
128 return c;
129 }
130 }
This page took 0.043076 seconds and 4 git commands to generate.