diff options
author | Eli Zaretskii <eliz@gnu.org> | 2023-01-26 10:54:43 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2023-01-26 10:54:43 +0200 |
commit | f8c95d1a7681e861fc22d2a040cda0ddfe23eff4 (patch) | |
tree | 7c2d8b30218e72ba671e3939be194c4b56f850db /lisp | |
parent | 4bf7cb71edc2694c9939ae27594e9a1e3b79e1c6 (diff) | |
download | emacs-f8c95d1a7681e861fc22d2a040cda0ddfe23eff4.tar.gz emacs-f8c95d1a7681e861fc22d2a040cda0ddfe23eff4.tar.bz2 emacs-f8c95d1a7681e861fc22d2a040cda0ddfe23eff4.zip |
Fix xt-mouse on terminals that report UTF-8 encoded coordinates
* lisp/xt-mouse.el (xterm-mouse--read-coordinate): Fix conversion
of mouse coordinates in rxvt-unicode. Patches by Vladimir
Panteleev <git@cy.md> and Jared Finder <jared@finder.org>.
(Bug#61022)
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/xt-mouse.el | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index adfa480bc0f..4ccd35d5277 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el @@ -151,16 +151,22 @@ If `xterm-mouse-utf-8' was non-nil when `turn-on-xterm-mouse-tracking-on-terminal' was called, reads the coordinate as an UTF-8 code unit sequence; otherwise, reads a single byte." - (let ((previous-keyboard-coding-system (keyboard-coding-system))) + (let ((previous-keyboard-coding-system (keyboard-coding-system)) + (utf-8-p (terminal-parameter nil 'xterm-mouse-utf-8)) + ;; Prevent conversions inside 'read-char' due to input method, + ;; when we call 'read-char' below with 2nd argument non-nil. + (input-method-function nil)) (unwind-protect (progn - (set-keyboard-coding-system - (if (terminal-parameter nil 'xterm-mouse-utf-8) - 'utf-8-unix - 'no-conversion)) - ;; Wait only a little; we assume that the entire escape sequence - ;; has already been sent when this function is called. - (read-char nil nil 0.1)) + (set-keyboard-coding-system (if utf-8-p 'utf-8-unix 'no-conversion)) + (read-char nil + ;; Force 'read-char' to decode UTF-8 sequences if + ;; 'xterm-mouse-utf-8' is non-nil. + utf-8-p + ;; Wait only a little; we assume that the entire + ;; escape sequence has already been sent when + ;; this function is called. + 0.1)) (set-keyboard-coding-system previous-keyboard-coding-system)))) ;; In default mode, each numeric parameter of XTerm's mouse report is |