]>
Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* Specific command window processing. |
f33c6cbf | 2 | |
6aba47ca DJ |
3 | Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007 |
4 | Free Software Foundation, Inc. | |
f33c6cbf | 5 | |
f377b406 SC |
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 | |
88d83552 EZ |
22 | Foundation, Inc., 51 Franklin Street, Fifth Floor, |
23 | Boston, MA 02110-1301, USA. */ | |
c906108c | 24 | |
96ec9981 DJ |
25 | #include "defs.h" |
26 | #include <ctype.h> | |
d7b2e967 AC |
27 | #include "tui/tui.h" |
28 | #include "tui/tui-data.h" | |
29 | #include "tui/tui-win.h" | |
30 | #include "tui/tui-io.h" | |
f33c6cbf | 31 | |
6a83354a | 32 | #include "gdb_curses.h" |
88289b6e | 33 | #include "gdb_string.h" |
4e8f7a8b | 34 | |
c906108c SS |
35 | |
36 | /***************************************** | |
37 | ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** | |
38 | ******************************************/ | |
39 | ||
40 | ||
41 | ||
42 | /***************************************** | |
43 | ** PUBLIC FUNCTIONS ** | |
44 | ******************************************/ | |
45 | ||
1cc6d956 MS |
46 | /* Dispatch the correct tui function based upon the control |
47 | character. */ | |
c906108c | 48 | unsigned int |
b0a30fce | 49 | tui_dispatch_ctrl_char (unsigned int ch) |
c906108c | 50 | { |
6d012f14 | 51 | struct tui_win_info *win_info = tui_win_with_focus (); |
c906108c | 52 | |
ca9d4aea SC |
53 | /* Handle the CTRL-L refresh for each window. */ |
54 | if (ch == '\f') | |
55 | tui_refresh_all_win (); | |
56 | ||
57 | /* If the command window has the logical focus, or no-one does | |
1cc6d956 MS |
58 | assume it is the command window; in this case, pass the character |
59 | on through and do nothing here. */ | |
6d012f14 | 60 | if (win_info == NULL || win_info == TUI_CMD_WIN) |
c906108c SS |
61 | return ch; |
62 | else | |
63 | { | |
6ba8e26f | 64 | unsigned int c = 0, ch_copy = ch; |
d02c80cd | 65 | int i; |
c906108c SS |
66 | char *term; |
67 | ||
68 | /* If this is an xterm, page next/prev keys aren't returned | |
c5aa993b JM |
69 | ** by keypad as a single char, so we must handle them here. |
70 | ** Seems like a bug in the curses library? | |
71 | */ | |
c906108c | 72 | term = (char *) getenv ("TERM"); |
bbe6b987 | 73 | if (term) |
c906108c | 74 | { |
bbe6b987 AS |
75 | for (i = 0; term[i]; i++) |
76 | term[i] = toupper (term[i]); | |
77 | if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch)) | |
c906108c | 78 | { |
bbe6b987 AS |
79 | unsigned int page_ch = 0; |
80 | unsigned int tmp_char; | |
ca9d4aea | 81 | WINDOW *w = TUI_CMD_WIN->generic.handle; |
bbe6b987 AS |
82 | |
83 | tmp_char = 0; | |
84 | while (!key_is_end_sequence (tmp_char)) | |
9b2d6cca | 85 | { |
bbe6b987 AS |
86 | tmp_char = (int) wgetch (w); |
87 | if (tmp_char == ERR) | |
88 | { | |
89 | return ch; | |
90 | } | |
91 | if (!tmp_char) | |
92 | break; | |
93 | if (tmp_char == 53) | |
94 | page_ch = KEY_PPAGE; | |
95 | else if (tmp_char == 54) | |
96 | page_ch = KEY_NPAGE; | |
97 | else | |
98 | { | |
99 | return 0; | |
100 | } | |
9b2d6cca | 101 | } |
bbe6b987 | 102 | ch_copy = page_ch; |
c906108c | 103 | } |
c906108c SS |
104 | } |
105 | ||
6ba8e26f | 106 | switch (ch_copy) |
c906108c SS |
107 | { |
108 | case KEY_NPAGE: | |
6d012f14 | 109 | tui_scroll_forward (win_info, 0); |
c906108c SS |
110 | break; |
111 | case KEY_PPAGE: | |
6d012f14 | 112 | tui_scroll_backward (win_info, 0); |
c906108c SS |
113 | break; |
114 | case KEY_DOWN: | |
115 | case KEY_SF: | |
6d012f14 | 116 | tui_scroll_forward (win_info, 1); |
c906108c SS |
117 | break; |
118 | case KEY_UP: | |
119 | case KEY_SR: | |
6d012f14 | 120 | tui_scroll_backward (win_info, 1); |
c906108c SS |
121 | break; |
122 | case KEY_RIGHT: | |
6d012f14 | 123 | tui_scroll_left (win_info, 1); |
c906108c SS |
124 | break; |
125 | case KEY_LEFT: | |
6d012f14 | 126 | tui_scroll_right (win_info, 1); |
c906108c SS |
127 | break; |
128 | case '\f': | |
ca9d4aea | 129 | break; |
c906108c | 130 | default: |
6ba8e26f | 131 | c = ch_copy; |
c906108c SS |
132 | break; |
133 | } | |
134 | return c; | |
135 | } | |
9b2d6cca | 136 | } |