aboutsummaryrefslogtreecommitdiffstats
path: root/src/keymap.c
diff options
context:
space:
mode:
authorRichard M. Stallman1993-03-07 23:32:54 +0000
committerRichard M. Stallman1993-03-07 23:32:54 +0000
commit6ba6e250c91e29d12ff51100f01998b2db397b2e (patch)
tree333f0098d564740b68977cd556739daa2d40932b /src/keymap.c
parentdc70cea7815c4464cb237df1cee36d4cb7e5f7c0 (diff)
downloademacs-6ba6e250c91e29d12ff51100f01998b2db397b2e.tar.gz
emacs-6ba6e250c91e29d12ff51100f01998b2db397b2e.zip
Include termhooks.h.
(push_key_description): Handle all modifiers. Handle large character codes. (Fkey_description): Move the meta bit, if arg is string. (Fsingle_key_description): Don't alter integer value. Make tem long enough. (Flookup_key): Use meta_modifier as meta-bit if from vector. (Fdefine_key): Likewise.
Diffstat (limited to 'src/keymap.c')
-rw-r--r--src/keymap.c89
1 files changed, 78 insertions, 11 deletions
diff --git a/src/keymap.c b/src/keymap.c
index fabe1c8c2bb..f088af6a7d6 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -25,6 +25,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25#include "commands.h" 25#include "commands.h"
26#include "buffer.h" 26#include "buffer.h"
27#include "keyboard.h" 27#include "keyboard.h"
28#include "termhooks.h"
28 29
29#define min(a, b) ((a) < (b) ? (a) : (b)) 30#define min(a, b) ((a) < (b) ? (a) : (b))
30 31
@@ -506,6 +507,7 @@ the front of KEYMAP.")
506 register Lisp_Object tem; 507 register Lisp_Object tem;
507 register Lisp_Object cmd; 508 register Lisp_Object cmd;
508 int metized = 0; 509 int metized = 0;
510 int meta_bit;
509 int length; 511 int length;
510 struct gcpro gcpro1, gcpro2, gcpro3; 512 struct gcpro gcpro1, gcpro2, gcpro3;
511 513
@@ -521,13 +523,18 @@ the front of KEYMAP.")
521 523
522 GCPRO3 (keymap, key, def); 524 GCPRO3 (keymap, key, def);
523 525
526 if (XTYPE (key) == Lisp_Vector)
527 meta_bit = meta_modifier;
528 else
529 meta_bit = 0x80;
530
524 idx = 0; 531 idx = 0;
525 while (1) 532 while (1)
526 { 533 {
527 c = Faref (key, make_number (idx)); 534 c = Faref (key, make_number (idx));
528 535
529 if (XTYPE (c) == Lisp_Int 536 if (XTYPE (c) == Lisp_Int
530 && XINT (c) >= 0200 537 && (XINT (c) & meta_bit)
531 && !metized) 538 && !metized)
532 { 539 {
533 c = meta_prefix_char; 540 c = meta_prefix_char;
@@ -595,6 +602,7 @@ recognize the default bindings, just as `read-key-sequence' does.")
595 int metized = 0; 602 int metized = 0;
596 int length; 603 int length;
597 int t_ok = ! NILP (accept_default); 604 int t_ok = ! NILP (accept_default);
605 int meta_bit;
598 606
599 keymap = get_keymap (keymap); 607 keymap = get_keymap (keymap);
600 608
@@ -606,13 +614,18 @@ recognize the default bindings, just as `read-key-sequence' does.")
606 if (length == 0) 614 if (length == 0)
607 return keymap; 615 return keymap;
608 616
617 if (XTYPE (key) == Lisp_Vector)
618 meta_bit = meta_modifier;
619 else
620 meta_bit = 0x80;
621
609 idx = 0; 622 idx = 0;
610 while (1) 623 while (1)
611 { 624 {
612 c = Faref (key, make_number (idx)); 625 c = Faref (key, make_number (idx));
613 626
614 if (XTYPE (c) == Lisp_Int 627 if (XTYPE (c) == Lisp_Int
615 && XINT (c) >= 0200 628 && (XINT (c) & meta_bit)
616 && !metized) 629 && !metized)
617 { 630 {
618 c = meta_prefix_char; 631 c = meta_prefix_char;
@@ -621,7 +634,7 @@ recognize the default bindings, just as `read-key-sequence' does.")
621 else 634 else
622 { 635 {
623 if (XTYPE (c) == Lisp_Int) 636 if (XTYPE (c) == Lisp_Int)
624 XSETINT (c, XINT (c) & 0177); 637 XSETINT (c, XINT (c) & ~meta_bit);
625 638
626 metized = 0; 639 metized = 0;
627 idx++; 640 idx++;
@@ -1112,6 +1125,22 @@ spaces are put between sequence elements, etc.")
1112 (keys) 1125 (keys)
1113 Lisp_Object keys; 1126 Lisp_Object keys;
1114{ 1127{
1128 if (XTYPE (keys) == Lisp_String)
1129 {
1130 Lisp_Object vector;
1131 int i;
1132 vector = Fmake_vector (Flength (keys), Qnil);
1133 for (i = 0; i < XSTRING (keys)->size; i++)
1134 {
1135 if (XSTRING (keys)->data[i] & 0x80)
1136 XFASTINT (XVECTOR (vector)->contents[i])
1137 = meta_modifier | (XSTRING (keys)->data[i] & ~0x80);
1138 else
1139 XFASTINT (XVECTOR (vector)->contents[i])
1140 = XSTRING (keys)->data[i];
1141 }
1142 keys = vector;
1143 }
1115 return Fmapconcat (Qsingle_key_description, keys, build_string (" ")); 1144 return Fmapconcat (Qsingle_key_description, keys, build_string (" "));
1116} 1145}
1117 1146
@@ -1120,11 +1149,41 @@ push_key_description (c, p)
1120 register unsigned int c; 1149 register unsigned int c;
1121 register char *p; 1150 register char *p;
1122{ 1151{
1123 if (c >= 0200) 1152 if (c & alt_modifier)
1153 {
1154 *p++ = 'A';
1155 *p++ = '-';
1156 c -= alt_modifier;
1157 }
1158 if (c & ctrl_modifier)
1159 {
1160 *p++ = 'C';
1161 *p++ = '-';
1162 c -= ctrl_modifier;
1163 }
1164 if (c & hyper_modifier)
1165 {
1166 *p++ = 'H';
1167 *p++ = '-';
1168 c -= hyper_modifier;
1169 }
1170 if (c & meta_modifier)
1124 { 1171 {
1125 *p++ = 'M'; 1172 *p++ = 'M';
1126 *p++ = '-'; 1173 *p++ = '-';
1127 c -= 0200; 1174 c -= meta_modifier;
1175 }
1176 if (c & shift_modifier)
1177 {
1178 *p++ = 'S';
1179 *p++ = '-';
1180 c -= shift_modifier;
1181 }
1182 if (c & super_modifier)
1183 {
1184 *p++ = 's';
1185 *p++ = '-';
1186 c -= super_modifier;
1128 } 1187 }
1129 if (c < 040) 1188 if (c < 040)
1130 { 1189 {
@@ -1134,7 +1193,7 @@ push_key_description (c, p)
1134 *p++ = 'S'; 1193 *p++ = 'S';
1135 *p++ = 'C'; 1194 *p++ = 'C';
1136 } 1195 }
1137 else if (c == Ctl('I')) 1196 else if (c == '\t')
1138 { 1197 {
1139 *p++ = 'T'; 1198 *p++ = 'T';
1140 *p++ = 'A'; 1199 *p++ = 'A';
@@ -1174,8 +1233,18 @@ push_key_description (c, p)
1174 *p++ = 'P'; 1233 *p++ = 'P';
1175 *p++ = 'C'; 1234 *p++ = 'C';
1176 } 1235 }
1177 else 1236 else if (c < 256)
1178 *p++ = c; 1237 *p++ = c;
1238 else
1239 {
1240 *p++ = '\\';
1241 *p++ = (7 & (c >> 15)) + '0';
1242 *p++ = (7 & (c >> 12)) + '0';
1243 *p++ = (7 & (c >> 9)) + '0';
1244 *p++ = (7 & (c >> 6)) + '0';
1245 *p++ = (7 & (c >> 3)) + '0';
1246 *p++ = (7 & (c >> 0)) + '0';
1247 }
1179 1248
1180 return p; 1249 return p;
1181} 1250}
@@ -1186,16 +1255,14 @@ Control characters turn into C-whatever, etc.")
1186 (key) 1255 (key)
1187 Lisp_Object key; 1256 Lisp_Object key;
1188{ 1257{
1189 register unsigned char c; 1258 char tem[20];
1190 char tem[6];
1191 1259
1192 key = EVENT_HEAD (key); 1260 key = EVENT_HEAD (key);
1193 1261
1194 switch (XTYPE (key)) 1262 switch (XTYPE (key))
1195 { 1263 {
1196 case Lisp_Int: /* Normal character */ 1264 case Lisp_Int: /* Normal character */
1197 c = XINT (key) & 0377; 1265 *push_key_description (XUINT (key), tem) = 0;
1198 *push_key_description (c, tem) = 0;
1199 return build_string (tem); 1266 return build_string (tem);
1200 1267
1201 case Lisp_Symbol: /* Function key or event-symbol */ 1268 case Lisp_Symbol: /* Function key or event-symbol */