From c2385c6f36d346d6524a4119109f52d4fd975244 Mon Sep 17 00:00:00 2001 From: Olaf Rogalsky Date: Tue, 24 Mar 2015 21:04:00 -0400 Subject: [PATCH] * lisp/xt-mouse.el: Add mouse-tracking support. Fixes: debbugs:19416 * lisp/xt-mouse.el: Add mouse-tracking support. (xterm-mouse-translate-1): Handle mouse-movement events. (xterm-mouse--read-event-sequence-1000) (xterm-mouse--read-event-sequence-1006): Delete functions. (xterm-mouse--read-event-sequence): New function that handles both at the same time. Handle mouse-movements. (xterm-mouse--read-utf8-char, xterm-mouse--read-number-from-terminal): New functions. (xterm-mouse-event): Simplify. (xterm-mouse-tracking-enable-sequence) (xterm-mouse-tracking-disable-sequence): Enable mouse tracking. * lisp/mouse.el (mouse-drag-line): Also ignore `vertical-line' prefix events. --- etc/NEWS | 2 + lisp/ChangeLog | 16 +++++ lisp/mouse.el | 3 +- lisp/xt-mouse.el | 185 ++++++++++++++++++++++++++++++++++--------------------- 4 files changed, 136 insertions(+), 70 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index cb319340678..5a19fc391e7 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -217,6 +217,8 @@ Unicode standards. * Changes in Specialized Modes and Packages in Emacs 25.1 +** xterm-mouse-mode now supports mouse-tracking (if your xterm supports it). + ** package.el *** `package-install-from-buffer' and `package-install-file' work on directories. This follows the same rules as installing from a .tar file, except the diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 3b8fa7d66c7..0d2f59227e9 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,19 @@ +2015-03-25 Olaf Rogalsky + + * xt-mouse.el: Add mouse-tracking support (bug#19416). + (xterm-mouse-translate-1): Handle mouse-movement events. + (xterm-mouse--read-event-sequence-1000) + (xterm-mouse--read-event-sequence-1006): Delete functions. + (xterm-mouse--read-event-sequence): New function that handles both at + the same time. Handle mouse-movements. + (xterm-mouse--read-utf8-char, xterm-mouse--read-number-from-terminal): + New functions. + (xterm-mouse-event): Simplify. + (xterm-mouse-tracking-enable-sequence) + (xterm-mouse-tracking-disable-sequence): Enable mouse tracking. + + * mouse.el (mouse-drag-line): Also ignore `vertical-line' prefix events. + 2015-03-24 Michael Albinus * net/tramp-sh.el (tramp-do-file-attributes-with-ls) diff --git a/lisp/mouse.el b/lisp/mouse.el index c50913f4636..5f3fa5d7694 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -486,9 +486,10 @@ must be one of the symbols `header', `mode', or `vertical'." `(menu-item "" ,(lambda () (interactive) (funcall exitfun)) :filter ,(lambda (cmd) (if dragged cmd))))) ;; Some of the events will of course end up looked up - ;; with a mode-line or header-line prefix ... + ;; with a mode-line, header-line or vertical-line prefix ... (define-key map [mode-line] map) (define-key map [header-line] map) + (define-key map [vertical-line] map) ;; ... and some maybe even with a right- or bottom-divider ;; prefix. (define-key map [right-divider] map) diff --git a/lisp/xt-mouse.el b/lisp/xt-mouse.el index b87c1a28937..7f1e72260ae 100644 --- a/lisp/xt-mouse.el +++ b/lisp/xt-mouse.el @@ -60,6 +60,7 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)." (ev-data (nth 1 event)) (ev-where (nth 1 ev-data)) (vec (vector event)) + (is-move (eq 'mouse-movement ev-command)) (is-down (string-match "down-" (symbol-name ev-command)))) ;; Mouse events symbols must have an 'event-kind property with @@ -71,6 +72,7 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)." (is-down (setf (terminal-parameter nil 'xterm-mouse-last-down) event) vec) + (is-move vec) (t (let* ((down (terminal-parameter nil 'xterm-mouse-last-down)) (down-data (nth 1 down)) @@ -132,65 +134,89 @@ http://invisible-island.net/xterm/ctlseqs/ctlseqs.html)." (fdiff (- f (* 1.0 maxwrap dbig)))) (+ (truncate fdiff) (* maxwrap dbig)))))) -;; Normal terminal mouse click reporting: expect three bytes, of the -;; form . Return a list (EVENT-TYPE X Y). -(defun xterm-mouse--read-event-sequence-1000 () - (let* ((code (- (read-event) 32)) - (type - ;; For buttons > 3, the release-event looks differently - ;; (see xc/programs/xterm/button.c, function EditorButton), - ;; and come in a release-event only, no down-event. - (cond ((>= code 64) - (format "mouse-%d" (- code 60))) - ((memq code '(8 9 10)) - (format "M-down-mouse-%d" (- code 7))) - ((memq code '(3 11)) - (let ((down (car (terminal-parameter - nil 'xterm-mouse-last-down)))) - (when (and down (string-match "[0-9]" (symbol-name down))) - (format (if (eq code 3) "mouse-%s" "M-mouse-%s") - (match-string 0 (symbol-name down)))))) - ((memq code '(0 1 2)) - (format "down-mouse-%d" (+ 1 code))))) - (x (- (read-event) 33)) - (y (- (read-event) 33))) - (and type (wholenump x) (wholenump y) - (list (intern type) x y)))) - -;; XTerm's 1006-mode terminal mouse click reporting has the form -;;