aboutsummaryrefslogtreecommitdiffstats
path: root/src/term.c
diff options
context:
space:
mode:
authorEric S. Raymond1993-03-11 08:13:27 +0000
committerEric S. Raymond1993-03-11 08:13:27 +0000
commit01d8deb089712bbf45f718a7d9647b965a521576 (patch)
treeaeddf48569134ab5151d2de16bf0b3d9b951ed05 /src/term.c
parentd043f1a41bb43bde4b86c192eb53bbebb5d8da8e (diff)
downloademacs-01d8deb089712bbf45f718a7d9647b965a521576.tar.gz
emacs-01d8deb089712bbf45f718a7d9647b965a521576.zip
Added lots more cookies to fkey_table[], and code to do even more.
Diffstat (limited to 'src/term.c')
-rw-r--r--src/term.c162
1 files changed, 126 insertions, 36 deletions
diff --git a/src/term.c b/src/term.c
index 3019d63f22b..bf3087e0b9f 100644
--- a/src/term.c
+++ b/src/term.c
@@ -1140,49 +1140,97 @@ calculate_costs (frame)
1140 cmcostinit (); /* set up cursor motion costs */ 1140 cmcostinit (); /* set up cursor motion costs */
1141} 1141}
1142 1142
1143/* Find the escape codes sent by the function keys for Vfunction_key_map.
1144 This function scans the termcap function key sequence entries, and
1145 adds entries to Vfunction_key_map for each function key it finds. */
1146
1147struct fkey_table { 1143struct fkey_table {
1148 char *cap, *name; 1144 char *cap, *name;
1149}; 1145};
1150 1146
1147 /* Termcap capability names that correspond directly to X keysyms.
1148 Some of these (marked "terminfo") aren't supplied by old-style
1149 (Berkeley) termcap entries. They're listed in X keysym order;
1150 except we put the keypad keys first, so that if they clash with
1151 other keys (as on the IBM PC keyboard) they get overridden.
1152 */
1153
1151static struct fkey_table keys[] = { 1154static struct fkey_table keys[] = {
1152 "kl", "left", 1155 "kh", "home", /* termcap */
1153 "kr", "right", 1156 "kl", "left", /* termcap */
1154 "ku", "up", 1157 "ku", "up", /* termcap */
1155 "kd", "down", 1158 "kr", "right", /* termcap */
1156 "K2", "center", 1159 "kd", "down", /* termcap */
1157 "k1", "f1", 1160 "%8", "prior", /* terminfo */
1158 "k2", "f2", 1161 "%5", "next", /* terminfo */
1159 "k3", "f3", 1162 "@7", "end", /* terminfo */
1160 "k4", "f4", 1163 "@1", "begin", /* terminfo */
1161 "k5", "f5", 1164 "*6", "select", /* terminfo */
1162 "k6", "f6", 1165 "%9", "print", /* terminfo */
1163 "k7", "f7", 1166 "@4", "execute", /* terminfo --- actually the `command' key */
1164 "k8", "f8", 1167 /*
1165 "k9", "f9", 1168 * "insert" --- see below
1166 "F1", "f11", 1169 */
1167 "F2", "f12", 1170 "&8", "undo", /* terminfo */
1168 "kh", "home", 1171 "%0", "redo", /* terminfo */
1169 "kH", "home-down", 1172 "%7", "menu", /* terminfo --- actually the `options' key */
1170 "ka", "clear-tabs", 1173 "@0", "find", /* terminfo */
1171 "kt", "clear-tab", 1174 "@2", "cancel", /* terminfo */
1172 "kT", "set-tab", 1175 "%1", "help", /* terminfo */
1173 "kC", "clear", 1176 /*
1174 "kL", "deleteline", 1177 * "break" goes here, but can't be reliably intercepted with termcap
1175 "kM", "exit-insert", 1178 */
1176 "kE", "clear-eol", 1179 "&4", "reset", /* terminfo --- actually `restart' */
1177 "kS", "clear-eos", 1180 /*
1178 "kI", "insert", 1181 * "system" and "user" --- no termcaps
1179 "kA", "insertline", 1182 */
1180 "kN", "next", 1183 "kE", "clearline", /* terminfo */
1181 "kP", "prior", 1184 "kA", "insertline", /* terminfo */
1182 "kF", "scroll-forward", 1185 "kL", "deleteline", /* terminfo */
1183 "kR", "scroll-reverse" 1186 "kI", "insertchar", /* terminfo */
1187 "kD", "deletechar", /* terminfo */
1188 "kB", "backtab", /* terminfo */
1189 /*
1190 * "kp_backtab", "kp-space", "kp-tab" --- no termcaps
1191 */
1192 "@8", "kp-enter", /* terminfo */
1193 /*
1194 * "kp-f1", "kp-f2", "kp-f3" "kp-f4",
1195 * "kp-multiply", "kp-add", "kp-separator",
1196 * "kp-subtract", "kp-decimal", "kp-divide", "kp-0";
1197 * --- no termcaps for any of these.
1198 */
1199 "K4", "kp-1", /* terminfo */
1200 /*
1201 * "kp-2" --- no termcap
1202 */
1203 "K5", "kp-3", /* terminfo */
1204 /*
1205 * "kp-4" --- no termcap
1206 */
1207 "K2", "kp-5", /* terminfo */
1208 /*
1209 * "kp-6" --- no termcap
1210 */
1211 "K1", "kp-7", /* terminfo */
1212 /*
1213 * "kp-8" --- no termcap
1214 */
1215 "K3", "kp-9", /* terminfo */
1216 /*
1217 * "kp-equal" --- no termcap
1218 */
1219 "k1", "f1",
1220 "k2", "f2",
1221 "k3", "f3",
1222 "k4", "f4",
1223 "k5", "f5",
1224 "k6", "f6",
1225 "k7", "f7",
1226 "k8", "f8",
1227 "k9", "f9",
1184 }; 1228 };
1185 1229
1230/* Find the escape codes sent by the function keys for Vfunction_key_map.
1231 This function scans the termcap function key sequence entries, and
1232 adds entries to Vfunction_key_map for each function key it finds. */
1233
1186void 1234void
1187term_get_fkeys (address) 1235term_get_fkeys (address)
1188 char **address; 1236 char **address;
@@ -1222,6 +1270,48 @@ term_get_fkeys (address)
1222 build_string (k0), 1270 build_string (k0),
1223 Fmake_vector (make_number (1), intern (k0_name))); 1271 Fmake_vector (make_number (1), intern (k0_name)));
1224 } 1272 }
1273
1274 /* Set up cookies for numbered function keys above f10. */
1275 {
1276 char fcap[3], fkey[4];
1277
1278 fcap[0] = 'k'; fcap[2] = '\0';
1279 for (i = 11; i < 64; i++)
1280 {
1281 if (i <= 19)
1282 fcap[1] = '1' + i - 11;
1283 else if (i <= 45)
1284 fcap[1] = 'A' + i - 11;
1285 else
1286 fcap[1] = 'a' + i - 11;
1287
1288 if (tgetstr(fcap))
1289 {
1290 (void) sprintf(fkey, "f%d", i);
1291 Fdefine_key (Vfunction_key_map,
1292 build_string (fcap),
1293 Fmake_vector (make_number (1), intern (fkey)));
1294 }
1295 }
1296 }
1297
1298 /*
1299 * Various mappings to try and get a better fit.
1300 */
1301 {
1302#define CONDITIONAL_REASSIGN(cap1, cap2, sym) \
1303 if (!tigetstr(cap1) && tgetstr(cap2)) \
1304 Fdefine_key (Vfunction_key_map, \
1305 build_string (cap2), \
1306 Fmake_vector (make_number (1), intern (sym)))
1307
1308 /* if there's no key_next keycap, map key_npage to `next' keysym */
1309 CONDITIONAL_REASSIGN("%5", "kN", "next");
1310 /* if there's no key_prev keycap, map key_ppage to `previous' keysym */
1311 CONDITIONAL_REASSIGN("%8", "kP", "previous");
1312 /* if there's no key_dc keycap, map key_ic to `insert' keysym */
1313 CONDITIONAL_REASSIGN("kD", "kI", "insert");
1314 }
1225} 1315}
1226 1316
1227 1317