Commit | Line | Data |
---|---|---|
f377b406 | 1 | /* Specific command window processing. |
f33c6cbf AC |
2 | |
3 | Copyright 1998, 1999, 2000, 2001, 2002 Free Software Foundation, | |
4 | Inc. | |
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 | |
f33c6cbf AC |
25 | /* FIXME: cagney/2002-02-28: The GDB coding standard indicates that |
26 | "defs.h" should be included first. Unfortunatly some systems | |
27 | (currently Debian GNU/Linux) include the <stdbool.h> via <curses.h> | |
28 | and they clash with "bfd.h"'s definiton of true/false. The correct | |
29 | fix is to remove true/false from "bfd.h", however, until that | |
30 | happens, hack around it by including "config.h" and <curses.h> | |
31 | first. */ | |
32 | ||
4e8f7a8b DJ |
33 | #include "config.h" |
34 | #ifdef HAVE_NCURSES_H | |
35 | #include <ncurses.h> | |
36 | #else | |
37 | #ifdef HAVE_CURSES_H | |
38 | #include <curses.h> | |
39 | #endif | |
40 | #endif | |
41 | ||
c906108c | 42 | #include "defs.h" |
9b2d6cca | 43 | #include <ctype.h> |
c906108c SS |
44 | #include "tui.h" |
45 | #include "tuiData.h" | |
46 | #include "tuiWin.h" | |
47 | #include "tuiIO.h" | |
48 | ||
49 | ||
50 | /***************************************** | |
51 | ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** | |
52 | ******************************************/ | |
53 | ||
54 | ||
55 | ||
56 | /***************************************** | |
57 | ** PUBLIC FUNCTIONS ** | |
58 | ******************************************/ | |
59 | ||
60 | /* | |
c5aa993b JM |
61 | ** tuiDispatchCtrlChar(). |
62 | ** Dispatch the correct tui function based upon the control character. | |
63 | */ | |
c906108c | 64 | unsigned int |
eca6576c | 65 | tuiDispatchCtrlChar (unsigned int ch) |
c906108c SS |
66 | { |
67 | TuiWinInfoPtr winInfo = tuiWinWithFocus (); | |
9b2d6cca | 68 | WINDOW *w = cmdWin->generic.handle; |
c906108c SS |
69 | |
70 | /* | |
c5aa993b JM |
71 | ** If the command window has the logical focus, or no-one does |
72 | ** assume it is the command window; in this case, pass the | |
73 | ** character on through and do nothing here. | |
74 | */ | |
c906108c SS |
75 | if (winInfo == (TuiWinInfoPtr) NULL || winInfo == cmdWin) |
76 | return ch; | |
77 | else | |
78 | { | |
79 | unsigned int c = 0, chCopy = ch; | |
80 | register int i; | |
81 | char *term; | |
82 | ||
83 | /* If this is an xterm, page next/prev keys aren't returned | |
c5aa993b JM |
84 | ** by keypad as a single char, so we must handle them here. |
85 | ** Seems like a bug in the curses library? | |
86 | */ | |
c906108c SS |
87 | term = (char *) getenv ("TERM"); |
88 | for (i = 0; (term && term[i]); i++) | |
89 | term[i] = toupper (term[i]); | |
90 | if ((strcmp (term, "XTERM") == 0) && m_isStartSequence (ch)) | |
91 | { | |
92 | unsigned int pageCh = 0, tmpChar; | |
93 | ||
94 | tmpChar = 0; | |
95 | while (!m_isEndSequence (tmpChar)) | |
96 | { | |
9b2d6cca SC |
97 | tmpChar = (int) wgetch (w); |
98 | if (tmpChar == ERR) | |
99 | { | |
100 | return ch; | |
101 | } | |
c906108c SS |
102 | if (!tmpChar) |
103 | break; | |
104 | if (tmpChar == 53) | |
105 | pageCh = KEY_PPAGE; | |
106 | else if (tmpChar == 54) | |
107 | pageCh = KEY_NPAGE; | |
9b2d6cca SC |
108 | else |
109 | { | |
110 | return 0; | |
111 | } | |
c906108c SS |
112 | } |
113 | chCopy = pageCh; | |
114 | } | |
115 | ||
116 | switch (chCopy) | |
117 | { | |
118 | case KEY_NPAGE: | |
119 | tuiScrollForward (winInfo, 0); | |
120 | break; | |
121 | case KEY_PPAGE: | |
122 | tuiScrollBackward (winInfo, 0); | |
123 | break; | |
124 | case KEY_DOWN: | |
125 | case KEY_SF: | |
126 | tuiScrollForward (winInfo, 1); | |
127 | break; | |
128 | case KEY_UP: | |
129 | case KEY_SR: | |
130 | tuiScrollBackward (winInfo, 1); | |
131 | break; | |
132 | case KEY_RIGHT: | |
133 | tuiScrollLeft (winInfo, 1); | |
134 | break; | |
135 | case KEY_LEFT: | |
136 | tuiScrollRight (winInfo, 1); | |
137 | break; | |
138 | case '\f': | |
139 | tuiRefreshAll (); | |
140 | break; | |
141 | default: | |
142 | c = chCopy; | |
143 | break; | |
144 | } | |
145 | return c; | |
146 | } | |
9b2d6cca | 147 | } |