Commit bf31a093 authored by Nick Roberts's avatar Nick Roberts
Browse files

(xterm-mouse-translate, xterm-mouse-event): Enable

mouse clicks on mode-line, header-line and margin.
(event-type): Give mouse event symbols an 'event-kind property
with value 'mouse-click.
parent a1c9fd19
......@@ -43,14 +43,17 @@
;; Support multi-click -- somehow.
;; Clicking on the mode-line does not work, although it should.
;;; Code:
(define-key function-key-map "\e[M" 'xterm-mouse-translate)
(defvar xterm-mouse-last)
;; Mouse events symbols must have an 'event-kind property with
;; the value 'mouse-click.
(dolist (event-type '(mouse-1 mouse-2 mouse-3))
(put event-type 'event-kind 'mouse-click))
(defun xterm-mouse-translate (event)
"Read a click and release event from XTerm."
......@@ -78,7 +81,7 @@
(click-where (nth 1 click-data)))
(if (memq down-binding '(nil ignore))
(if (and (symbolp click-where)
(not (eq 'menu-bar click-where)))
(consp click-where))
(vector (list click-where click-data) click)
(vector click))
(setq unread-command-events
......@@ -92,10 +95,9 @@
(list (intern (format "drag-mouse-%d"
(+ 1 xterm-mouse-last)))
down-data click-data))
down-data click-data)))))
(if (and (symbolp down-where)
(not (eq 'menu-bar down-where)))
(consp down-where))
(vector (list down-where down-data) down)
(vector down))))))))
......@@ -124,30 +126,6 @@
(let* ((type (- (xterm-mouse-event-read) #o40))
(x (- (xterm-mouse-event-read) #o40 1))
(y (- (xterm-mouse-event-read) #o40 1))
(point (cons x y))
(window (window-at x y))
(where (if window
(coordinates-in-window-p point window)
(pos (if (consp where)
(select-window window)
(goto-char (window-start window))
(move-to-window-line (-
(cdr where)
(if (or header-line-format
(move-to-column (- (+ (car where) (current-column)
(if (string-match "\\` \\*Minibuf"
(- (minibuffer-prompt-width))
(max 0 (1- (window-hscroll))))
(mouse (intern
;; For buttons > 3, the release-event looks
;; differently (see xc/programs/xterm/button.c,
......@@ -159,12 +137,16 @@
(format "mouse-%d" (+ 1 xterm-mouse-last)))
(setq xterm-mouse-last type)
(format "down-mouse-%d" (+ 1 type)))))))
(format "down-mouse-%d" (+ 1 type))))))
(w (window-at x y)))
(setq xterm-mouse-x x
xterm-mouse-y y)
(list mouse
(list window pos point
(/ (nth 2 (current-time)) 1000)))))
(if w
(list mouse (posn-at-x-y x (if menu-bar-mode (- y 1) y) w))
(list mouse
(append (list nil 'menu-bar)
(nthcdr 2 (posn-at-x-y
x (if menu-bar-mode (- y 1) y) w)))))))
(define-minor-mode xterm-mouse-mode
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment