* lisp/xml.el: Handle entity and character reference expansion correctly.
[emacs.git] / lisp / t-mouse.el
blobe0fbe8c3bdb5a2cbcabe352d2b05d0477b288470
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-2012 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.
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 mouse support in GNU/Linux consoles (GPM Mouse mode).
69 With a prefix argument ARG, enable GPM Mouse mode if ARG is
70 positive, and disable it otherwise. If called from Lisp, enable
71 the mode if ARG is omitted or nil.
73 This allows the use of the mouse when operating on a GNU/Linux console,
74 in the same way as you can use the mouse under X11.
75 It relies on the `gpm' daemon being activated."
76 :global t :group 'mouse :init-value t
77 (dolist (terminal (terminal-list))
78 (when (and (eq t (terminal-live-p terminal))
79 (not (eq gpm-mouse-mode
80 (terminal-parameter terminal 'gpm-mouse-active))))
81 ;; Simulate selecting a terminal by selecting one of its frames ;-(
82 (with-selected-frame (car (frames-on-display-list terminal))
83 (if gpm-mouse-mode (gpm-mouse-enable) (gpm-mouse-disable))))))
85 (provide 't-mouse)
87 ;;; t-mouse.el ends here