;;; xt-mouse.el --- support the mouse when emacs run in an xterm
-;; Copyright (C) 1994, 2000, 2001, 2005 Free Software Foundation
+;; Copyright (C) 1994, 2000, 2001, 2002, 2003,
+;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
;; Keywords: mouse, terminals
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
;;; Todo:
-;; The xterm mouse escape codes are supposedly also supported by the
-;; Linux console, but I have not been able to verify this.
-
;; Support multi-click -- somehow.
;;; Code:
(let* ((type (- (xterm-mouse-event-read) #o40))
(x (- (xterm-mouse-event-read) #o40 1))
(y (- (xterm-mouse-event-read) #o40 1))
+ (time (current-time))
+ (timestamp (+ ( * (nth 1 time) 1000 ) (/ (nth 2 time) 1000)))
(mouse (intern
;; For buttons > 3, the release-event looks
;; differently (see xc/programs/xterm/button.c,
(setq xterm-mouse-x x
xterm-mouse-y y)
- (if w
- (list mouse (posn-at-x-y (- x left) (- y top) w t))
- (list mouse
- (append (list nil 'menu-bar) (nthcdr 2 (posn-at-x-y x y w t)))))))
+ (setq
+ last-input-event
+ (list mouse
+ (let ((event (if w
+ (posn-at-x-y (- x left) (- y top) w t)
+ (append (list nil 'menu-bar)
+ (nthcdr 2 (posn-at-x-y x y w t))))))
+ (setcar (nthcdr 3 event) timestamp)
+ event)))))
;;;###autoload
(define-minor-mode xterm-mouse-mode
With prefix arg, turn XTerm mouse mode on iff arg is positive.
Turn it on to use Emacs mouse commands, and off to use xterm mouse commands.
-This works in terminal emulators compatible with xterm. Only single clicks
-are supported. When turned on, the normal xterm mouse functionality is still
-available by holding down the SHIFT key while pressing the mouse button."
- nil " Mouse" nil :global t :group 'mouse
+This works in terminal emulators compatible with xterm. It only
+works for simple uses of the mouse. Basically, only non-modified
+single clicks are supported. When turned on, the normal xterm
+mouse functionality for such clicks is still available by holding
+down the SHIFT key while pressing the mouse button."
+ :global t :group 'mouse
(if xterm-mouse-mode
;; Turn it on
(unless window-system