diff options
| author | Jim Blandy | 1993-05-22 17:57:17 +0000 |
|---|---|---|
| committer | Jim Blandy | 1993-05-22 17:57:17 +0000 |
| commit | d205953bff8106259ac290a9fa8d2dcba886c686 (patch) | |
| tree | c146f7047dd2b953a179ea2d1cefce230c792d0d /src | |
| parent | 929787e104051f3ba7c5bee9d696e754bb8db6fc (diff) | |
| download | emacs-d205953bff8106259ac290a9fa8d2dcba886c686.tar.gz emacs-d205953bff8106259ac290a9fa8d2dcba886c686.zip | |
(make_ctrl_char): New function.
(make_lispy_event): Call it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/keyboard.c | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index d4a488e8047..42aff6bb76d 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -1236,24 +1236,34 @@ int | |||
| 1236 | make_ctrl_char (c) | 1236 | make_ctrl_char (c) |
| 1237 | int c; | 1237 | int c; |
| 1238 | { | 1238 | { |
| 1239 | /* If it's already a control character, don't mess with it. */ | 1239 | /* Save the upper bits here. */ |
| 1240 | if ((c & 0160) == 0) | 1240 | int upper = c & ~0177; |
| 1241 | ; | 1241 | |
| 1242 | /* Making ? a control character should result in DEL. */ | 1242 | c &= 0177; |
| 1243 | 1243 | ||
| 1244 | else if ((c & 0177) == '?') | 1244 | /* Everything in the columns containing the upper-case letters |
| 1245 | c |= 0177; | 1245 | denotes a control character. */ |
| 1246 | 1246 | if (c >= 0100 && c < 0140) | |
| 1247 | /* ASCII control chars are made from letters (both cases), | 1247 | { |
| 1248 | as well as the non-letters within 0100...0137. */ | 1248 | int oc = c; |
| 1249 | else if ((c & 0137) >= 'A' && (c & 0137) <= 'Z') | 1249 | c &= ~0140; |
| 1250 | c = (c & (037 | ~0177)); | 1250 | /* Set the shift modifier for a control char |
| 1251 | else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) | 1251 | made from a shifted letter. But only for letters! */ |
| 1252 | c = (c & (037 | ~0177)); | 1252 | if (oc >= 'A' && oc <= 'Z') |
| 1253 | 1253 | c |= shift_modifier; | |
| 1254 | /* Anything else must get its high control bit set. */ | 1254 | } |
| 1255 | else | 1255 | |
| 1256 | c = c | ctrl_modifier; | 1256 | /* The lower-case letters denote control characters too. */ |
| 1257 | else if (c >= 'a' && c <= 'z') | ||
| 1258 | c &= ~0140; | ||
| 1259 | |||
| 1260 | /* Include the bits for control and shift | ||
| 1261 | only if the basic ASCII code can't indicate them. */ | ||
| 1262 | else if (c >= ' ') | ||
| 1263 | c |= ctrl_modifier; | ||
| 1264 | |||
| 1265 | /* Replace the high bits. */ | ||
| 1266 | c |= (upper & ~ctrl_modifier); | ||
| 1257 | 1267 | ||
| 1258 | return c; | 1268 | return c; |
| 1259 | } | 1269 | } |
| @@ -2106,23 +2116,11 @@ make_lispy_event (event) | |||
| 2106 | /* Turn ASCII characters into control characters | 2116 | /* Turn ASCII characters into control characters |
| 2107 | when proper. */ | 2117 | when proper. */ |
| 2108 | if (event->modifiers & ctrl_modifier) | 2118 | if (event->modifiers & ctrl_modifier) |
| 2109 | { | 2119 | c = make_ctrl_char (c); |
| 2110 | if (c >= 0100 && c < 0140) | 2120 | |
| 2111 | { | 2121 | /* Add in the other modifier bits. We took care of ctrl_modifier |
| 2112 | int oc = c; | 2122 | just above, and the shift key was taken care of by the X code, |
| 2113 | c &= ~0140; | 2123 | and applied to control characters by make_ctrl_char. */ |
| 2114 | /* Set the shift modifier for a control char | ||
| 2115 | made from a shifted letter. But only for letters! */ | ||
| 2116 | if (oc >= 'A' && oc <= 'Z') | ||
| 2117 | c |= shift_modifier; | ||
| 2118 | } | ||
| 2119 | else if (c >= 'a' && c <= 'z') | ||
| 2120 | c &= ~0140; | ||
| 2121 | /* Include the bits for control and shift | ||
| 2122 | only if the basic ASCII code can't indicate them. */ | ||
| 2123 | else | ||
| 2124 | c |= ctrl_modifier; | ||
| 2125 | } | ||
| 2126 | c |= (event->modifiers | 2124 | c |= (event->modifiers |
| 2127 | & (meta_modifier | alt_modifier | 2125 | & (meta_modifier | alt_modifier |
| 2128 | | hyper_modifier | super_modifier)); | 2126 | | hyper_modifier | super_modifier)); |