Regenerate autotools stuff, grumble.
[emacs.git] / lisp / t-mouse.el
blob059024c4bce0da6e56446bff219cd2def2c0f39d
1 ;;; t-mouse.el --- mouse support within the text terminal
3 ;; Author: Nick Roberts <nickrob@gnu.org>
4 ;; Maintainer: FSF
5 ;; Keywords: mouse gpm linux
7 ;; Copyright (C) 1994-1995, 1998, 2006-2011 Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;;; Commentary:
26 ;; This package provides access to mouse event as reported by the gpm-Linux
27 ;; package. It tries to reproduce the functionality offered by Emacs under X.
28 ;; The "gpm" server runs under Linux, so this package is rather
29 ;; Linux-dependent.
31 ;; The file, t-mouse.el was originally written by Alessandro Rubini and Ian T
32 ;; Zimmerman, and Emacs communicated with gpm through a client program called
33 ;; mev. Now the interface with gpm is directly through a Unix socket, so this
34 ;; file is reduced to a single minor mode macro call.
36 ;;
38 ;;; Code:
40 ;; Prevent warning when compiling in an Emacs without gpm support.
41 (declare-function gpm-mouse-start "term.c" ())
43 (defun gpm-mouse-enable ()
44 "Try to enable gpm mouse support on the current terminal."
45 (let ((activated nil))
46 (unwind-protect
47 (progn
48 (unless (fboundp 'gpm-mouse-start)
49 (error "Emacs must be built with Gpm to use this mode"))
50 (when gpm-mouse-mode
51 (gpm-mouse-start)
52 (set-terminal-parameter nil 'gpm-mouse-active t)
53 (setq activated t)))
54 ;; If something failed to turn it on, try to turn it off as well,
55 ;; just in case.
56 (unless activated (gpm-mouse-disable)))))
58 (defun gpm-mouse-disable ()
59 "Try to disable gpm mouse support on the current terminal."
60 (when (fboundp 'gpm-mouse-stop)
61 (gpm-mouse-stop))
62 (set-terminal-parameter nil 'gpm-mouse-active nil))
64 ;;;###autoload
65 (define-obsolete-function-alias 't-mouse-mode 'gpm-mouse-mode "23.1")
66 ;;;###autoload
67 (define-minor-mode gpm-mouse-mode
68 "Toggle gpm-mouse mode to use the mouse in GNU/Linux consoles.
69 With prefix arg, turn gpm-mouse mode on if arg is positive,
70 otherwise turn it off.
72 This allows the use of the mouse when operating on a GNU/Linux console,
73 in the same way as you can use the mouse under X11.
74 It relies on the `gpm' daemon being activated."
75 :global t :group 'mouse :init-value t
76 (dolist (terminal (terminal-list))
77 (when (and (eq t (terminal-live-p terminal))
78 (not (eq gpm-mouse-mode
79 (terminal-parameter terminal 'gpm-mouse-active))))
80 ;; Simulate selecting a terminal by selecting one of its frames ;-(
81 (with-selected-frame (car (frames-on-display-list terminal))
82 (if gpm-mouse-mode (gpm-mouse-enable) (gpm-mouse-disable))))))
84 (provide 't-mouse)
86 ;;; t-mouse.el ends here