2 Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
3 2007 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
35 #include "key.h" /* XCTRL and ALT macros */
39 * Common handler for standard movement keys in a text area. Provided
40 * functions are called with the "data" argument. backfn and forfn also
41 * get an argument indicating how many lines to scroll. Return 1 if
42 * the key was handled, 0 otherwise.
45 check_movement_keys (int key
, int page_size
, void *data
, movefn backfn
,
46 movefn forfn
, movefn topfn
, movefn bottomfn
)
61 (*backfn
) (data
, page_size
- 1);
66 (*forfn
) (data
, page_size
- 1);
70 case KEY_M_CTRL
| KEY_HOME
:
71 case KEY_M_CTRL
| KEY_PPAGE
:
78 case KEY_M_CTRL
| KEY_END
:
79 case KEY_M_CTRL
| KEY_NPAGE
:
82 (*bottomfn
) (data
, 0);
87 (*backfn
) (data
, page_size
- 1);
91 (*forfn
) (data
, page_size
- 1);
95 (*backfn
) (data
, page_size
/ 2);
99 (*forfn
) (data
, page_size
/ 2);
107 (*bottomfn
) (data
, 0);
111 return MSG_NOT_HANDLED
;
116 /* Classification routines */
117 int is_abort_char (int c
)
119 return (c
== XCTRL('c') || c
== XCTRL('g') || c
== ESC_CHAR
||
123 void mc_raw_mode (void)
128 void mc_noraw_mode (void)
133 /* This flag is set by xterm detection routine in function main() */
134 /* It is used by function view_other_cmd() */
137 /* The following routines only work on xterm terminals */
139 void do_enter_ca_mode (void)
143 fprintf (stdout
, /* ESC_STR ")0" */ ESC_STR
"7" ESC_STR
"[?47h");
147 void do_exit_ca_mode (void)
151 fprintf (stdout
, ESC_STR
"[?47l" ESC_STR
"8" ESC_STR
"[m");
155 /* This table is a mapping between names and the constants we use
156 * We use this to allow users to define alternate definitions for
157 * certain keys that may be missing from the terminal database
159 key_code_name_t key_name_conv_tab
[] = {
160 /* KEY_F(0) is not here, since we are mapping it to f10, so there is no reason
161 to define f0 as well. Also, it makes Learn keys a bunch of problems :( */
162 { KEY_F(1), "f1", N_("Function key 1") },
163 { KEY_F(2), "f2", N_("Function key 2") },
164 { KEY_F(3), "f3", N_("Function key 3") },
165 { KEY_F(4), "f4", N_("Function key 4") },
166 { KEY_F(5), "f5", N_("Function key 5") },
167 { KEY_F(6), "f6", N_("Function key 6") },
168 { KEY_F(7), "f7", N_("Function key 7") },
169 { KEY_F(8), "f8", N_("Function key 8") },
170 { KEY_F(9), "f9", N_("Function key 9") },
171 { KEY_F(10), "f10", N_("Function key 10") },
172 { KEY_F(11), "f11", N_("Function key 11") },
173 { KEY_F(12), "f12", N_("Function key 12") },
174 { KEY_F(13), "f13", N_("Function key 13") },
175 { KEY_F(14), "f14", N_("Function key 14") },
176 { KEY_F(15), "f15", N_("Function key 15") },
177 { KEY_F(16), "f16", N_("Function key 16") },
178 { KEY_F(17), "f17", N_("Function key 17") },
179 { KEY_F(18), "f18", N_("Function key 18") },
180 { KEY_F(19), "f19", N_("Function key 19") },
181 { KEY_F(20), "f20", N_("Function key 20") },
182 { KEY_BACKSPACE
, "bs", N_("Backspace key") },
183 { KEY_END
, "end", N_("End key") },
184 { KEY_UP
, "up", N_("Up arrow key") },
185 { KEY_DOWN
, "down", N_("Down arrow key") },
186 { KEY_LEFT
, "left", N_("Left arrow key") },
187 { KEY_RIGHT
, "right", N_("Right arrow key") },
188 { KEY_HOME
, "home", N_("Home key") },
189 { KEY_NPAGE
, "pgdn", N_("Page Down key") },
190 { KEY_PPAGE
, "pgup", N_("Page Up key") },
191 { KEY_IC
, "insert", N_("Insert key") },
192 { KEY_DC
, "delete", N_("Delete key") },
193 { ALT('\t'), "complete", N_("Completion/M-tab") },
194 { KEY_KP_ADD
, "kpplus", N_("+ on keypad") },
195 { KEY_KP_SUBTRACT
,"kpminus", N_("- on keypad") },
196 { KEY_KP_MULTIPLY
,"kpasterix", N_("* on keypad") },
197 /* From here on, these won't be shown in Learn keys (no space) */
198 { KEY_LEFT
, "kpleft", N_("Left arrow keypad") },
199 { KEY_RIGHT
, "kpright", N_("Right arrow keypad") },
200 { KEY_UP
, "kpup", N_("Up arrow keypad") },
201 { KEY_DOWN
, "kpdown", N_("Down arrow keypad") },
202 { KEY_HOME
, "kphome", N_("Home on keypad") },
203 { KEY_END
, "kpend", N_("End on keypad") },
204 { KEY_NPAGE
, "kpnpage", N_("Page Down keypad") },
205 { KEY_PPAGE
, "kpppage", N_("Page Up keypad") },
206 { KEY_IC
, "kpinsert", N_("Insert on keypad") },
207 { KEY_DC
, "kpdelete", N_("Delete on keypad") },
208 { (int) '\n', "kpenter", N_("Enter on keypad") },
209 { (int) '/', "kpslash", N_("Slash on keypad") },
210 { (int) '#', "kpnumlock", N_("NumLock on keypad") },
214 /* Return the code associated with the symbolic name keyname */
215 int lookup_key (char *keyname
)
219 for (i
= 0; key_name_conv_tab
[i
].code
; i
++){
220 if ( g_strcasecmp (key_name_conv_tab
[i
].name
, keyname
))
222 return key_name_conv_tab
[i
].code
;