Mercurial > emacs
comparison src/lread.c @ 2044:258362f03d90
(syms_of_lread): Set up Qascii_character.
(Fread_char, Fread_char_exclusive): Use that property
to convert symbols like tab, return, M-return,... to ASCII.
Include termhooks.h.
(read_escape): Handle \H, \A, \s. Use ..._modifier.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 07 Mar 1993 09:25:28 +0000 |
parents | 7c970ef8949d |
children | b6c62e4abf59 |
comparison
equal
deleted
inserted
replaced
2043:a1ab3501653c | 2044:258362f03d90 |
---|---|
31 #ifndef standalone | 31 #ifndef standalone |
32 #include "buffer.h" | 32 #include "buffer.h" |
33 #include "paths.h" | 33 #include "paths.h" |
34 #include "commands.h" | 34 #include "commands.h" |
35 #include "keyboard.h" | 35 #include "keyboard.h" |
36 #include "termhooks.h" | |
36 #endif | 37 #endif |
37 | 38 |
38 #ifdef lint | 39 #ifdef lint |
39 #include <sys/inode.h> | 40 #include <sys/inode.h> |
40 #endif /* lint */ | 41 #endif /* lint */ |
47 #include <math.h> | 48 #include <math.h> |
48 #endif /* LISP_FLOAT_TYPE */ | 49 #endif /* LISP_FLOAT_TYPE */ |
49 | 50 |
50 Lisp_Object Qread_char, Qget_file_char, Qstandard_input; | 51 Lisp_Object Qread_char, Qget_file_char, Qstandard_input; |
51 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; | 52 Lisp_Object Qvariable_documentation, Vvalues, Vstandard_input, Vafter_load_alist; |
53 Lisp_Object Qascii_character; | |
54 | |
55 extern Lisp_Object Qevent_symbol_element_mask; | |
52 | 56 |
53 /* non-zero if inside `load' */ | 57 /* non-zero if inside `load' */ |
54 int load_in_progress; | 58 int load_in_progress; |
55 | 59 |
56 /* Search path for files to be loaded. */ | 60 /* Search path for files to be loaded. */ |
198 } | 202 } |
199 | 203 |
200 if (! NILP (delayed_switch_frame)) | 204 if (! NILP (delayed_switch_frame)) |
201 unread_switch_frame = delayed_switch_frame; | 205 unread_switch_frame = delayed_switch_frame; |
202 | 206 |
203 /* Only ASCII characters are acceptable. */ | 207 /* Only ASCII characters are acceptable. |
208 But convert certain symbols to their ASCII equivalents. */ | |
209 if (XTYPE (val) == Lisp_Symbol) | |
210 { | |
211 Lisp_Object tem, tem1, tem2; | |
212 tem = Fget (val, Qevent_symbol_element_mask); | |
213 if (!NILP (tem)) | |
214 { | |
215 tem1 = Fget (Fcar (tem), Qascii_character); | |
216 /* Merge this symbol's modifier bits | |
217 with the ASCII equivalent of its basic code. */ | |
218 if (!NILP (tem1)) | |
219 XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem))); | |
220 } | |
221 } | |
204 if (XTYPE (val) != Lisp_Int) | 222 if (XTYPE (val) != Lisp_Int) |
205 { | 223 { |
206 unread_command_events = Fcons (val, Qnil); | 224 unread_command_events = Fcons (val, Qnil); |
207 error ("Object read was not a character"); | 225 error ("Non-character input-event"); |
208 } | 226 } |
209 } | 227 } |
210 #else | 228 #else |
211 val = getchar (); | 229 val = getchar (); |
212 #endif | 230 #endif |
239 | 257 |
240 for (;;) | 258 for (;;) |
241 { | 259 { |
242 val = read_char (0, 0, 0, Qnil, 0); | 260 val = read_char (0, 0, 0, Qnil, 0); |
243 | 261 |
262 /* Convert certain symbols (for keys like RET, DEL, TAB) | |
263 to ASCII integers. */ | |
264 if (XTYPE (val) == Lisp_Symbol) | |
265 { | |
266 Lisp_Object tem, tem1; | |
267 tem = Fget (val, Qevent_symbol_element_mask); | |
268 if (!NILP (tem)) | |
269 { | |
270 tem1 = Fget (Fcar (tem), Qascii_character); | |
271 /* Merge this symbol's modifier bits | |
272 with the ASCII equivalent of its basic code. */ | |
273 if (!NILP (tem1)) | |
274 XFASTINT (val) = XINT (tem1) | XINT (Fcar (Fcdr (tem))); | |
275 } | |
276 } | |
244 if (XTYPE (val) == Lisp_Int) | 277 if (XTYPE (val) == Lisp_Int) |
245 break; | 278 break; |
246 | 279 |
247 /* switch-frame events are put off until after the next ASCII | 280 /* switch-frame events are put off until after the next ASCII |
248 character. This is better than signalling an error just | 281 character. This is better than signalling an error just |
788 if (c != '-') | 821 if (c != '-') |
789 error ("Invalid escape character syntax"); | 822 error ("Invalid escape character syntax"); |
790 c = READCHAR; | 823 c = READCHAR; |
791 if (c == '\\') | 824 if (c == '\\') |
792 c = read_escape (readcharfun); | 825 c = read_escape (readcharfun); |
793 return c | CHAR_META; | 826 return c | meta_modifier; |
794 | 827 |
795 case 'S': | 828 case 'S': |
796 c = READCHAR; | 829 c = READCHAR; |
797 if (c != '-') | 830 if (c != '-') |
798 error ("Invalid escape character syntax"); | 831 error ("Invalid escape character syntax"); |
799 c = READCHAR; | 832 c = READCHAR; |
800 if (c == '\\') | 833 if (c == '\\') |
801 c = read_escape (readcharfun); | 834 c = read_escape (readcharfun); |
802 return c | CHAR_SHIFT; | 835 return c | shift_modifier; |
836 | |
837 case 'H': | |
838 c = READCHAR; | |
839 if (c != '-') | |
840 error ("Invalid escape character syntax"); | |
841 c = READCHAR; | |
842 if (c == '\\') | |
843 c = read_escape (readcharfun); | |
844 return c | hyper_modifier; | |
845 | |
846 case 'A': | |
847 c = READCHAR; | |
848 if (c != '-') | |
849 error ("Invalid escape character syntax"); | |
850 c = READCHAR; | |
851 if (c == '\\') | |
852 c = read_escape (readcharfun); | |
853 return c | alt_modifier; | |
854 | |
855 case 's': | |
856 c = READCHAR; | |
857 if (c != '-') | |
858 error ("Invalid escape character syntax"); | |
859 c = READCHAR; | |
860 if (c == '\\') | |
861 c = read_escape (readcharfun); | |
862 return c | super_modifier; | |
803 | 863 |
804 case 'C': | 864 case 'C': |
805 c = READCHAR; | 865 c = READCHAR; |
806 if (c != '-') | 866 if (c != '-') |
807 error ("Invalid escape character syntax"); | 867 error ("Invalid escape character syntax"); |
816 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) | 876 else if ((c & 0137) >= 0101 && (c & 0137) <= 0132) |
817 return (c & (037 | ~0177)); | 877 return (c & (037 | ~0177)); |
818 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) | 878 else if ((c & 0177) >= 0100 && (c & 0177) <= 0137) |
819 return (c & (037 | ~0177)); | 879 return (c & (037 | ~0177)); |
820 else | 880 else |
821 return c | CHAR_CTL; | 881 return c | ctrl_modifier; |
822 | 882 |
823 case '0': | 883 case '0': |
824 case '1': | 884 case '1': |
825 case '2': | 885 case '2': |
826 case '3': | 886 case '3': |
1745 Qread_char = intern ("read-char"); | 1805 Qread_char = intern ("read-char"); |
1746 staticpro (&Qread_char); | 1806 staticpro (&Qread_char); |
1747 | 1807 |
1748 Qget_file_char = intern ("get-file-char"); | 1808 Qget_file_char = intern ("get-file-char"); |
1749 staticpro (&Qget_file_char); | 1809 staticpro (&Qget_file_char); |
1750 } | 1810 |
1811 Qascii_character = intern ("ascii-character"); | |
1812 staticpro (&Qascii_character); | |
1813 } |