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 SS |
21 | |
22 | #include "defs.h" | |
9b2d6cca | 23 | #include <ctype.h> |
c906108c SS |
24 | #include "tui.h" |
25 | #include "tuiData.h" | |
26 | #include "tuiWin.h" | |
27 | #include "tuiIO.h" | |
28 | ||
29 | ||
30 | /***************************************** | |
31 | ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** | |
32 | ******************************************/ | |
33 | ||
34 | ||
35 | ||
36 | /***************************************** | |
37 | ** PUBLIC FUNCTIONS ** | |
38 | ******************************************/ | |
39 | ||
40 | /* | |
c5aa993b JM |
41 | ** tuiDispatchCtrlChar(). |
42 | ** Dispatch the correct tui function based upon the control character. | |
43 | */ | |
c906108c | 44 | unsigned int |
eca6576c | 45 | tuiDispatchCtrlChar (unsigned int ch) |
c906108c SS |
46 | { |
47 | TuiWinInfoPtr winInfo = tuiWinWithFocus (); | |
9b2d6cca | 48 | WINDOW *w = cmdWin->generic.handle; |
c906108c SS |
49 | |
50 | /* | |
c5aa993b JM |
51 | ** If the command window has the logical focus, or no-one does |
52 | ** assume it is the command window; in this case, pass the | |
53 | ** character on through and do nothing here. | |
54 | */ | |
c906108c SS |
55 | if (winInfo == (TuiWinInfoPtr) NULL || winInfo == cmdWin) |
56 | return ch; | |
57 | else | |
58 | { | |
59 | unsigned int c = 0, chCopy = ch; | |
60 | register int i; | |
61 | char *term; | |
62 | ||
63 | /* If this is an xterm, page next/prev keys aren't returned | |
c5aa993b JM |
64 | ** by keypad as a single char, so we must handle them here. |
65 | ** Seems like a bug in the curses library? | |
66 | */ | |
c906108c SS |
67 | term = (char *) getenv ("TERM"); |
68 | for (i = 0; (term && term[i]); i++) | |
69 | term[i] = toupper (term[i]); | |
70 | if ((strcmp (term, "XTERM") == 0) && m_isStartSequence (ch)) | |
71 | { | |
72 | unsigned int pageCh = 0, tmpChar; | |
73 | ||
74 | tmpChar = 0; | |
75 | while (!m_isEndSequence (tmpChar)) | |
76 | { | |
9b2d6cca SC |
77 | tmpChar = (int) wgetch (w); |
78 | if (tmpChar == ERR) | |
79 | { | |
80 | return ch; | |
81 | } | |
c906108c SS |
82 | if (!tmpChar) |
83 | break; | |
84 | if (tmpChar == 53) | |
85 | pageCh = KEY_PPAGE; | |
86 | else if (tmpChar == 54) | |
87 | pageCh = KEY_NPAGE; | |
9b2d6cca SC |
88 | else |
89 | { | |
90 | return 0; | |
91 | } | |
c906108c SS |
92 | } |
93 | chCopy = pageCh; | |
94 | } | |
95 | ||
96 | switch (chCopy) | |
97 | { | |
98 | case KEY_NPAGE: | |
99 | tuiScrollForward (winInfo, 0); | |
100 | break; | |
101 | case KEY_PPAGE: | |
102 | tuiScrollBackward (winInfo, 0); | |
103 | break; | |
104 | case KEY_DOWN: | |
105 | case KEY_SF: | |
106 | tuiScrollForward (winInfo, 1); | |
107 | break; | |
108 | case KEY_UP: | |
109 | case KEY_SR: | |
110 | tuiScrollBackward (winInfo, 1); | |
111 | break; | |
112 | case KEY_RIGHT: | |
113 | tuiScrollLeft (winInfo, 1); | |
114 | break; | |
115 | case KEY_LEFT: | |
116 | tuiScrollRight (winInfo, 1); | |
117 | break; | |
118 | case '\f': | |
119 | tuiRefreshAll (); | |
120 | break; | |
121 | default: | |
122 | c = chCopy; | |
123 | break; | |
124 | } | |
125 | return c; | |
126 | } | |
9b2d6cca | 127 | } |