diff options
| author | Po Lu | 2022-02-16 10:53:00 +0800 |
|---|---|---|
| committer | Po Lu | 2022-02-16 10:53:00 +0800 |
| commit | f1d535da1ed2e7a70c6cf28fdcdca31d3f86a3f5 (patch) | |
| tree | 75a6922c25dea7dd9d80f0e1b8b9dab55799b34a | |
| parent | 0a9c8855b0ce9618219ef70bb489107ce7194ba1 (diff) | |
| download | emacs-f1d535da1ed2e7a70c6cf28fdcdca31d3f86a3f5.tar.gz emacs-f1d535da1ed2e7a70c6cf28fdcdca31d3f86a3f5.zip | |
Decode keyboard input as latin-1 whenever appropriate
* src/keyboard.c (kbd_buffer_get_event_1): Use `coding'
property if present.
* src/termhooks.h (enum event_kind): Document meaning of
`coding' property on text strings.
* src/xterm.c (handle_one_xevent): Set coding property on text
to latin-1 if it was obtained with XLookupString.
| -rw-r--r-- | src/keyboard.c | 10 | ||||
| -rw-r--r-- | src/termhooks.h | 12 | ||||
| -rw-r--r-- | src/xterm.c | 14 |
3 files changed, 34 insertions, 2 deletions
diff --git a/src/keyboard.c b/src/keyboard.c index 800632aa25d..0747ab48205 100644 --- a/src/keyboard.c +++ b/src/keyboard.c | |||
| @@ -3838,7 +3838,12 @@ clear_event (struct input_event *event) | |||
| 3838 | static Lisp_Object | 3838 | static Lisp_Object |
| 3839 | kbd_buffer_get_event_1 (Lisp_Object arg) | 3839 | kbd_buffer_get_event_1 (Lisp_Object arg) |
| 3840 | { | 3840 | { |
| 3841 | return code_convert_string (arg, Vlocale_coding_system, | 3841 | Lisp_Object coding_system = Fget_text_property (make_fixnum (0), |
| 3842 | Qcoding, arg); | ||
| 3843 | |||
| 3844 | return code_convert_string (arg, (!NILP (coding_system) | ||
| 3845 | ? coding_system | ||
| 3846 | : Vlocale_coding_system), | ||
| 3842 | Qnil, 0, false, 0); | 3847 | Qnil, 0, false, 0); |
| 3843 | } | 3848 | } |
| 3844 | 3849 | ||
| @@ -12477,6 +12482,9 @@ See also `pre-command-hook'. */); | |||
| 12477 | DEFSYM (Qtouchscreen_end, "touchscreen-end"); | 12482 | DEFSYM (Qtouchscreen_end, "touchscreen-end"); |
| 12478 | DEFSYM (Qtouchscreen_update, "touchscreen-update"); | 12483 | DEFSYM (Qtouchscreen_update, "touchscreen-update"); |
| 12479 | DEFSYM (Qpinch, "pinch"); | 12484 | DEFSYM (Qpinch, "pinch"); |
| 12485 | |||
| 12486 | DEFSYM (Qcoding, "coding"); | ||
| 12487 | |||
| 12480 | Fset (Qecho_area_clear_hook, Qnil); | 12488 | Fset (Qecho_area_clear_hook, Qnil); |
| 12481 | 12489 | ||
| 12482 | DEFVAR_LISP ("lucid-menu-bar-dirty-flag", Vlucid_menu_bar_dirty_flag, | 12490 | DEFVAR_LISP ("lucid-menu-bar-dirty-flag", Vlucid_menu_bar_dirty_flag, |
diff --git a/src/termhooks.h b/src/termhooks.h index 4276d8ac2f2..0a9ab61afab 100644 --- a/src/termhooks.h +++ b/src/termhooks.h | |||
| @@ -90,7 +90,17 @@ enum event_kind | |||
| 90 | decoded and the decoded | 90 | decoded and the decoded |
| 91 | string's characters will be | 91 | string's characters will be |
| 92 | used as .code | 92 | used as .code |
| 93 | individually. */ | 93 | individually. |
| 94 | |||
| 95 | The string can have a | ||
| 96 | property `coding', which | ||
| 97 | should be a symbol | ||
| 98 | describing a coding system | ||
| 99 | to use to decode the string. | ||
| 100 | |||
| 101 | If it is nil, then the | ||
| 102 | locale coding system will | ||
| 103 | be used. */ | ||
| 94 | NON_ASCII_KEYSTROKE_EVENT, /* .code is a number identifying the | 104 | NON_ASCII_KEYSTROKE_EVENT, /* .code is a number identifying the |
| 95 | function key. A code N represents | 105 | function key. A code N represents |
| 96 | a key whose name is | 106 | a key whose name is |
diff --git a/src/xterm.c b/src/xterm.c index 568351d2e3d..bd8d5f892f3 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -9132,6 +9132,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 9132 | static XComposeStatus compose_status; | 9132 | static XComposeStatus compose_status; |
| 9133 | XEvent configureEvent; | 9133 | XEvent configureEvent; |
| 9134 | XEvent next_event; | 9134 | XEvent next_event; |
| 9135 | Lisp_Object coding; | ||
| 9135 | 9136 | ||
| 9136 | *finish = X_EVENT_NORMAL; | 9137 | *finish = X_EVENT_NORMAL; |
| 9137 | 9138 | ||
| @@ -9784,6 +9785,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 9784 | case KeyPress: | 9785 | case KeyPress: |
| 9785 | x_display_set_last_user_time (dpyinfo, event->xkey.time); | 9786 | x_display_set_last_user_time (dpyinfo, event->xkey.time); |
| 9786 | ignore_next_mouse_click_timeout = 0; | 9787 | ignore_next_mouse_click_timeout = 0; |
| 9788 | coding = Qlatin_1; | ||
| 9787 | 9789 | ||
| 9788 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) | 9790 | #if defined (USE_X_TOOLKIT) || defined (USE_GTK) |
| 9789 | /* Dispatch KeyPress events when in menu. */ | 9791 | /* Dispatch KeyPress events when in menu. */ |
| @@ -9884,6 +9886,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 9884 | &xkey, (char *) copy_bufptr, | 9886 | &xkey, (char *) copy_bufptr, |
| 9885 | copy_bufsiz, &keysym, | 9887 | copy_bufsiz, &keysym, |
| 9886 | &status_return); | 9888 | &status_return); |
| 9889 | coding = Qnil; | ||
| 9887 | if (status_return == XBufferOverflow) | 9890 | if (status_return == XBufferOverflow) |
| 9888 | { | 9891 | { |
| 9889 | copy_bufsiz = nbytes + 1; | 9892 | copy_bufsiz = nbytes + 1; |
| @@ -10053,6 +10056,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 10053 | inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; | 10056 | inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; |
| 10054 | inev.ie.arg = make_unibyte_string ((char *) copy_bufptr, nbytes); | 10057 | inev.ie.arg = make_unibyte_string ((char *) copy_bufptr, nbytes); |
| 10055 | 10058 | ||
| 10059 | Fput_text_property (make_fixnum (0), make_fixnum (nbytes), | ||
| 10060 | Qcoding, coding, inev.ie.arg); | ||
| 10061 | |||
| 10056 | if (keysym == NoSymbol) | 10062 | if (keysym == NoSymbol) |
| 10057 | break; | 10063 | break; |
| 10058 | } | 10064 | } |
| @@ -11444,6 +11450,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 11444 | ptrdiff_t i; | 11450 | ptrdiff_t i; |
| 11445 | struct xi_device_t *device; | 11451 | struct xi_device_t *device; |
| 11446 | 11452 | ||
| 11453 | coding = Qlatin_1; | ||
| 11454 | |||
| 11447 | device = xi_device_from_id (dpyinfo, xev->deviceid); | 11455 | device = xi_device_from_id (dpyinfo, xev->deviceid); |
| 11448 | 11456 | ||
| 11449 | if (!device || !device->master_p) | 11457 | if (!device || !device->master_p) |
| @@ -11571,6 +11579,7 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 11571 | &xkey, (char *) copy_bufptr, | 11579 | &xkey, (char *) copy_bufptr, |
| 11572 | copy_bufsiz, &keysym, | 11580 | copy_bufsiz, &keysym, |
| 11573 | &status_return); | 11581 | &status_return); |
| 11582 | coding = Qnil; | ||
| 11574 | 11583 | ||
| 11575 | if (status_return == XBufferOverflow) | 11584 | if (status_return == XBufferOverflow) |
| 11576 | { | 11585 | { |
| @@ -11617,6 +11626,8 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 11617 | if (overflow) | 11626 | if (overflow) |
| 11618 | nbytes = 0; | 11627 | nbytes = 0; |
| 11619 | } | 11628 | } |
| 11629 | |||
| 11630 | coding = Qnil; | ||
| 11620 | } | 11631 | } |
| 11621 | else | 11632 | else |
| 11622 | #endif | 11633 | #endif |
| @@ -11748,6 +11759,9 @@ handle_one_xevent (struct x_display_info *dpyinfo, | |||
| 11748 | 11759 | ||
| 11749 | inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; | 11760 | inev.ie.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT; |
| 11750 | inev.ie.arg = make_unibyte_string (copy_bufptr, nbytes); | 11761 | inev.ie.arg = make_unibyte_string (copy_bufptr, nbytes); |
| 11762 | |||
| 11763 | Fput_text_property (make_fixnum (0), make_fixnum (nbytes), | ||
| 11764 | Qcoding, coding, inev.ie.arg); | ||
| 11751 | goto xi_done_keysym; | 11765 | goto xi_done_keysym; |
| 11752 | } | 11766 | } |
| 11753 | 11767 | ||