;;; xt-mouse.el --- support the mouse when emacs run in an xterm
-;; Copyright (C) 1994, 2000, 2001 Free Software Foundation
+;; Copyright (C) 1994, 2000, 2001, 2002, 2003,
+;; 2004, 2005 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:
-;; Enable mouse support when running inside an xterm or Linux console.
+;; Enable mouse support when running inside an xterm.
;; This is actually useful when you are running X11 locally, but is
;; working on remote machine over a modem line or through a gateway.
;; It works by translating xterm escape codes into generic emacs mouse
;; events so it should work with any package that uses the mouse.
-;; The xterm mouse escape codes are supposedly also supported by the
-;; Linux console, but I have not been able to verify this.
-
;; You don't have to turn off xterm mode to use the normal xterm mouse
;; functionality, it is still available by holding down the SHIFT key
;; when you press the mouse button.
;;; 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:
(t
(setq xterm-mouse-last type)
(format "down-mouse-%d" (+ 1 type))))))
- (w (window-at x y)))
+ (w (window-at x y))
+ (ltrb (window-edges w))
+ (left (nth 0 ltrb))
+ (top (nth 1 ltrb)))
+
(setq xterm-mouse-x x
xterm-mouse-y y)
(if w
- (list mouse (posn-at-x-y x (if menu-bar-mode (- y 1) y) 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 (if menu-bar-mode (- y 1) y) w)))))))
+ (append (list nil 'menu-bar) (nthcdr 2 (posn-at-x-y x y w t)))))))
;;;###autoload
(define-minor-mode xterm-mouse-mode
"Toggle 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."
- nil " Mouse" nil :global t
+Turn it on to use Emacs mouse commands, and off to use xterm mouse commands.
+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