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