]>
Commit | Line | Data |
---|---|---|
f377b406 SC |
1 | /* Specific command window processing. |
2 | Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | |
3 | Contributed by Hewlett-Packard Company. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
c906108c | 21 | |
4e8f7a8b DJ |
22 | /* If we need <curses.h>, we must include it before we get "bfd.h". */ |
23 | #include "config.h" | |
24 | #ifdef HAVE_NCURSES_H | |
25 | #include <ncurses.h> | |
26 | #else | |
27 | #ifdef HAVE_CURSES_H | |
28 | #include <curses.h> | |
29 | #endif | |
30 | #endif | |
31 | ||
c906108c | 32 | #include "defs.h" |
9b2d6cca | 33 | #include <ctype.h> |
c906108c SS |
34 | #include "tui.h" |
35 | #include "tuiData.h" | |
36 | #include "tuiWin.h" | |
37 | #include "tuiIO.h" | |
38 | ||
39 | ||
40 | /***************************************** | |
41 | ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** | |
42 | ******************************************/ | |
43 | ||
44 | ||
45 | ||
46 | /***************************************** | |
47 | ** PUBLIC FUNCTIONS ** | |
48 | ******************************************/ | |
49 | ||
50 | /* | |
c5aa993b JM |
51 | ** tuiDispatchCtrlChar(). |
52 | ** Dispatch the correct tui function based upon the control character. | |
53 | */ | |
c906108c | 54 | unsigned int |
eca6576c | 55 | tuiDispatchCtrlChar (unsigned int ch) |
c906108c SS |
56 | { |
57 | TuiWinInfoPtr winInfo = tuiWinWithFocus (); | |
9b2d6cca | 58 | WINDOW *w = cmdWin->generic.handle; |
c906108c SS |
59 | |
60 | /* | |
c5aa993b JM |
61 | ** If the command window has the logical focus, or no-one does |
62 | ** assume it is the command window; in this case, pass the | |
63 | ** character on through and do nothing here. | |
64 | */ | |
c906108c SS |
65 | if (winInfo == (TuiWinInfoPtr) NULL || winInfo == cmdWin) |
66 | return ch; | |
67 | else | |
68 | { | |
69 | unsigned int c = 0, chCopy = ch; | |
70 | register int i; | |
71 | char *term; | |
72 | ||
73 | /* If this is an xterm, page next/prev keys aren't returned | |
c5aa993b JM |
74 | ** by keypad as a single char, so we must handle them here. |
75 | ** Seems like a bug in the curses library? | |
76 | */ | |
c906108c SS |
77 | term = (char *) getenv ("TERM"); |
78 | for (i = 0; (term && term[i]); i++) | |
79 | term[i] = toupper (term[i]); | |
80 | if ((strcmp (term, "XTERM") == 0) && m_isStartSequence (ch)) | |
81 | { | |
82 | unsigned int pageCh = 0, tmpChar; | |
83 | ||
84 | tmpChar = 0; | |
85 | while (!m_isEndSequence (tmpChar)) | |
86 | { | |
9b2d6cca SC |
87 | tmpChar = (int) wgetch (w); |
88 | if (tmpChar == ERR) | |
89 | { | |
90 | return ch; | |
91 | } | |
c906108c SS |
92 | if (!tmpChar) |
93 | break; | |
94 | if (tmpChar == 53) | |
95 | pageCh = KEY_PPAGE; | |
96 | else if (tmpChar == 54) | |
97 | pageCh = KEY_NPAGE; | |
9b2d6cca SC |
98 | else |
99 | { | |
100 | return 0; | |
101 | } | |
c906108c SS |
102 | } |
103 | chCopy = pageCh; | |
104 | } | |
105 | ||
106 | switch (chCopy) | |
107 | { | |
108 | case KEY_NPAGE: | |
109 | tuiScrollForward (winInfo, 0); | |
110 | break; | |
111 | case KEY_PPAGE: | |
112 | tuiScrollBackward (winInfo, 0); | |
113 | break; | |
114 | case KEY_DOWN: | |
115 | case KEY_SF: | |
116 | tuiScrollForward (winInfo, 1); | |
117 | break; | |
118 | case KEY_UP: | |
119 | case KEY_SR: | |
120 | tuiScrollBackward (winInfo, 1); | |
121 | break; | |
122 | case KEY_RIGHT: | |
123 | tuiScrollLeft (winInfo, 1); | |
124 | break; | |
125 | case KEY_LEFT: | |
126 | tuiScrollRight (winInfo, 1); | |
127 | break; | |
128 | case '\f': | |
129 | tuiRefreshAll (); | |
130 | break; | |
131 | default: | |
132 | c = chCopy; | |
133 | break; | |
134 | } | |
135 | return c; | |
136 | } | |
9b2d6cca | 137 | } |