comparison src/events.c @ 4780:2fd201d73a92

Call character_to_event on characters received from XIM, event-Xt.c src/ChangeLog addition: 2009-12-17 Aidan Kehoe <kehoea@parhasard.net> * events.h (character_to_event_meta_behavior): New enumeration, describing what character_to_event should do with characters in the range ?\x80-?\xFF, and passed as the third argument to character_to_event instead of the binary use_console_meta_flag. * events.c (character_to_event, Fcharacter_to_event): * event-unixoid.c (read_event_from_tty_or_stream_desc): * event-stream.c (maybe_kbd_translate, maybe_kbd_translate): * event-msw.c (mswindows_need_event): Use the new enumeration. * event-Xt.c (x_to_emacs_keysym): Call character_to_event when we receive XLookupChars events, passing latin_1_maps_to_itself as the meta_behavior flag, addressing the problem FKtPp sees in 87bpi9mwpu.fsf@yahoo.com.cn
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 17 Dec 2009 17:51:38 +0000
parents 141c2920ea48
children 6ef8256a020a 19a72041c5ed e0db3c197671
comparison
equal deleted inserted replaced
4779:fd98353950a4 4780:2fd201d73a92
1193 default: 1193 default:
1194 return 0; 1194 return 0;
1195 } 1195 }
1196 } 1196 }
1197 1197
1198 /* USE_CONSOLE_META_FLAG is as in `character-to-event'. 1198 /* META_BEHAVIOR can be one of the following values, defined in events.h:
1199
1200 high_bit_is_meta
1201 use_console_meta_flag
1202 latin_1_maps_to_itself
1203
1199 DO_BACKSPACE_MAPPING means that if CON is a TTY, and C is a the TTY's 1204 DO_BACKSPACE_MAPPING means that if CON is a TTY, and C is a the TTY's
1200 backspace character, the event will have keysym `backspace' instead of 1205 backspace character, the event will have keysym `backspace' instead of
1201 '(control h). It is clearly correct to do this conversion is the 1206 '(control h). It is clearly correct to do this conversion is the
1202 character was just read from a TTY, clearly incorrect inside of 1207 character was just read from a TTY, clearly incorrect inside of
1203 define-key, which must be able to handle all consoles. #### What about 1208 define-key, which must be able to handle all consoles. #### What about
1243 mappings. Of course, feedback from users of the Russian C-x facility 1248 mappings. Of course, feedback from users of the Russian C-x facility
1244 is still needed. */ 1249 is still needed. */
1245 1250
1246 void 1251 void
1247 character_to_event (Ichar c, Lisp_Event *event, struct console *con, 1252 character_to_event (Ichar c, Lisp_Event *event, struct console *con,
1248 int use_console_meta_flag, 1253 character_to_event_meta_behavior meta_behavior,
1249 int USED_IF_TTY (do_backspace_mapping)) 1254 int USED_IF_TTY (do_backspace_mapping))
1250 { 1255 {
1251 Lisp_Object k = Qnil; 1256 Lisp_Object k = Qnil;
1252 int m = 0; 1257 int m = 0;
1253 if (EVENT_TYPE (event) == dead_event) 1258 if (EVENT_TYPE (event) == dead_event)
1254 invalid_argument ("character-to-event called with a deallocated event!", Qunbound); 1259 invalid_argument ("character-to-event called with a deallocated event!", Qunbound);
1255 1260
1256 #ifndef MULE 1261 #ifndef MULE
1257 c &= 255; 1262 c &= 255;
1258 #endif 1263 #endif
1259 if (c > 127 && c <= 255) 1264 if (meta_behavior != latin_1_maps_to_itself && c > 127 && c <= 255)
1260 { 1265 {
1261 /* #### What if the user wanted a Latin-1 char? Perhaps the answer
1262 is what was suggested above.
1263 */
1264 int meta_flag = 1; 1266 int meta_flag = 1;
1265 if (use_console_meta_flag && CONSOLE_TTY_P (con)) 1267 if (meta_behavior == use_console_meta_flag && CONSOLE_TTY_P (con))
1266 meta_flag = TTY_FLAGS (con).meta_key; 1268 meta_flag = TTY_FLAGS (con).meta_key;
1267 switch (meta_flag) 1269 switch (meta_flag)
1268 { 1270 {
1269 case 0: /* ignore top bit; it's parity */ 1271 case 0: /* ignore top bit; it's parity */
1270 c -= 128; 1272 c -= 128;
1449 1451
1450 Beware that character-to-event and event-to-character are not strictly 1452 Beware that character-to-event and event-to-character are not strictly
1451 inverse functions, since events contain much more information than the 1453 inverse functions, since events contain much more information than the
1452 Lisp character object type can encode. 1454 Lisp character object type can encode.
1453 */ 1455 */
1454 (keystroke, event, console, use_console_meta_flag)) 1456 (keystroke, event, console, use_console_meta_flag_))
1455 { 1457 {
1456 struct console *con = decode_console (console); 1458 struct console *con = decode_console (console);
1457 if (NILP (event)) 1459 if (NILP (event))
1458 event = Fmake_event (Qnil, Qnil); 1460 event = Fmake_event (Qnil, Qnil);
1459 else 1461 else
1462 key_desc_list_to_event (keystroke, event, 1); 1464 key_desc_list_to_event (keystroke, event, 1);
1463 else 1465 else
1464 { 1466 {
1465 CHECK_CHAR_COERCE_INT (keystroke); 1467 CHECK_CHAR_COERCE_INT (keystroke);
1466 character_to_event (XCHAR (keystroke), XEVENT (event), con, 1468 character_to_event (XCHAR (keystroke), XEVENT (event), con,
1467 !NILP (use_console_meta_flag), 1); 1469 (NILP (use_console_meta_flag_) ?
1470 high_bit_is_meta : use_console_meta_flag), 1);
1468 } 1471 }
1469 return event; 1472 return event;
1470 } 1473 }
1471 1474
1472 void 1475 void