annotate lisp/obsolete/bg-mouse.el @ 72428:608323e2c0e3

*** empty log message ***
author Nick Roberts <nickrob@snap.net.nz>
date Thu, 17 Aug 2006 11:44:05 +0000
parents e8a3fb527b77
children e3694f1cb928
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
65118
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
1 ;;; bg-mouse.el --- GNU Emacs code for BBN Bitgraph mouse
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
2
68640
e8a3fb527b77 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65137
diff changeset
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005,
e8a3fb527b77 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 65137
diff changeset
4 ;; 2006 Free Software Foundation, Inc.
65118
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
5
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
6 ;; Author: John Robinson <jr@bbn-unix.arpa>
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
7 ;; Stephen Gildea <gildea@bbn.com>
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
8 ;; Maintainer: FSF
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
9 ;; Keywords: hardware
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
10
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
12
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
16 ;; any later version.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
17
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
22
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
26 ;; Boston, MA 02110-1301, USA.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
27
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
28 ;;; Commentary:
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
29
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
30 ;;; Code:
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
31
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
32 ;;; Original version by John Robinson (jr@bbn-unix.arpa, bbncca!jr), Oct 1985
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
33 ;;; Modularized and enhanced by gildea@bbn.com Nov 1987
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
34 ;;; Time stamp <89/03/21 14:27:08 gildea>
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
35
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
36 ;;; User customization option:
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
37
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
38 (defvar bg-mouse-fast-select-window nil
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
39 "*Non-nil for mouse hits to select new window, then execute; else just select.")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
40
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
41 ;;; These numbers are summed to make the index into the mouse-map.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
42 ;;; The low three bits correspond to what the mouse actually sends.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
43 (defconst bg-button-r 1)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
44 (defconst bg-button-m 2)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
45 (defconst bg-button-c 2)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
46 (defconst bg-button-l 4)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
47 (defconst bg-in-modeline 8)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
48 (defconst bg-in-scrollbar 16)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
49 (defconst bg-in-minibuf 24)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
50
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
51 ;;; semicolon screws up indenting, so use this instead
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
52 (defconst semicolon ?\;)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
53
65137
4377043d399d Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents: 65118
diff changeset
54 (defvar bg-mouse-x)
4377043d399d Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents: 65118
diff changeset
55 (defvar bg-mouse-y)
4377043d399d Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents: 65118
diff changeset
56 (defvar bg-cursor-window)
4377043d399d Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents: 65118
diff changeset
57 ;; This variable does not exist since 1991, so it's a safe bet
4377043d399d Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents: 65118
diff changeset
58 ;; this package is not really used anymore. Still...
4377043d399d Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents: 65118
diff changeset
59 (defvar mouse-map)
65118
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
60
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
61 ;;; Defuns:
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
62
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
63 (defun bg-mouse-report (prefix-arg)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
64 "Read, parse, and execute a BBN BitGraph mouse click.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
65
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
66 L-- move point | These apply for mouse click in a window.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
67 --R set mark | If bg-mouse-fast-select-window is nil,
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
68 L-R kill region | these commands on a nonselected window
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
69 -C- move point and yank | just select that window.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
70 LC- yank-pop |
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
71 -CR or LCR undo | \"Scroll bar\" is right-hand window column.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
72
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
73 on modeline: on \"scroll bar\": in minibuffer:
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
74 L-- scroll-up line to top execute-extended-command
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
75 --R scroll-down line to bottom eval-expression
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
76 -C- proportional goto-char line to middle suspend-emacs
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
77
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
78 To reinitialize the mouse if the terminal is reset, type ESC : RET"
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
79 (interactive "P")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
80 (bg-get-tty-num semicolon)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
81 (let*
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
82 ((screen-mouse-x (min (1- (frame-width)) ;don't hit column 86!
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
83 (/ (bg-get-tty-num semicolon) 9)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
84 (screen-mouse-y (- (1- (frame-height)) ;assume default font size.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
85 (/ (bg-get-tty-num semicolon) 16)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
86 (bg-mouse-buttons (% (bg-get-tty-num ?c) 8))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
87 (bg-mouse-window (bg-window-from-x-y screen-mouse-x screen-mouse-y))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
88 (bg-cursor-window (selected-window))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
89 (edges (window-edges bg-mouse-window))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
90 (minibuf-p (= screen-mouse-y (1- (frame-height))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
91 (in-modeline-p (and (not minibuf-p)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
92 (= screen-mouse-y (1- (nth 3 edges)))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
93 (in-scrollbar-p (and (not minibuf-p) (not in-modeline-p)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
94 (>= screen-mouse-x (1- (nth 2 edges)))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
95 (same-window-p (eq bg-mouse-window bg-cursor-window))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
96 (in-minibuf-p (and minibuf-p
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
97 (not bg-mouse-window))) ;minibuf must be inactive
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
98 (bg-mode-bits (+ (if in-minibuf-p bg-in-minibuf 0)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
99 (if in-modeline-p bg-in-modeline 0)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
100 (if in-scrollbar-p bg-in-scrollbar 0)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
101 (bg-command
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
102 (lookup-key mouse-map
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
103 (char-to-string (+ bg-mode-bits bg-mouse-buttons))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
104 (bg-mouse-x (- screen-mouse-x (nth 0 edges)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
105 (bg-mouse-y (- screen-mouse-y (nth 1 edges))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
106 (cond ((or in-modeline-p in-scrollbar-p)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
107 (select-window bg-mouse-window)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
108 (bg-command-execute bg-command)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
109 (select-window bg-cursor-window))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
110 ((or same-window-p in-minibuf-p)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
111 (bg-command-execute bg-command))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
112 (t ;in another window
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
113 (select-window bg-mouse-window)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
114 (if bg-mouse-fast-select-window
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
115 (bg-command-execute bg-command)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
116 )))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
117
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
118
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
119 ;;; Library of commands:
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
120
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
121 (defun bg-set-point ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
122 "Move point to location of BitGraph mouse."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
123 (interactive)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
124 (bg-move-point-to-x-y bg-mouse-x bg-mouse-y)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
125 (setq this-command 'next-line) ;make subsequent line moves work
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
126 (setq temporary-goal-column bg-mouse-x))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
127
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
128 (defun bg-set-mark ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
129 "Set mark at location of BitGraph mouse."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
130 (interactive)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
131 (push-mark)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
132 (bg-move-point-to-x-y bg-mouse-x bg-mouse-y)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
133 (exchange-point-and-mark))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
134
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
135 (defun bg-yank ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
136 "Move point to location of BitGraph mouse and yank."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
137 (interactive "*")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
138 (bg-move-point-to-x-y bg-mouse-x bg-mouse-y)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
139 (setq this-command 'yank)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
140 (yank))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
141
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
142 (defun yank-pop-1 ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
143 (interactive "*")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
144 (yank-pop 1))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
145
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
146 (defun bg-yank-or-pop ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
147 "Move point to location of BitGraph mouse and yank. If last command
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
148 was a yank, do a yank-pop."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
149 (interactive "*")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
150 (if (eq last-command 'yank)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
151 (yank-pop 1)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
152 (bg-yank)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
153
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
154 ;;; In 18.51, Emacs Lisp doesn't provide most-positive-fixnum
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
155 (defconst bg-most-positive-fixnum 8388607)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
156
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
157 (defun bg-move-by-percentage ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
158 "Go to location in buffer that is the same percentage of the way
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
159 through the buffer as the BitGraph mouse's X position in the window."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
160 (interactive)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
161 ;; check carefully for overflow in intermediate calculations
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
162 (goto-char
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
163 (cond ((zerop bg-mouse-x)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
164 0)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
165 ((< (buffer-size) (/ bg-most-positive-fixnum bg-mouse-x))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
166 ;; no danger of overflow: compute it exactly
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
167 (/ (* bg-mouse-x (buffer-size))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
168 (1- (window-width))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
169 (t
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
170 ;; overflow possible: approximate
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
171 (* (/ (buffer-size) (1- (window-width)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
172 bg-mouse-x))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
173 (beginning-of-line)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
174 (what-cursor-position))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
175
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
176 (defun bg-mouse-line-to-top ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
177 "Scroll the line pointed to by the BitGraph mouse to the top of the window."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
178 (interactive)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
179 (scroll-up bg-mouse-y))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
180
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
181 (defun bg-mouse-line-to-center ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
182 "Scroll the line pointed to by the BitGraph mouse to the center
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
183 of the window"
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
184 (interactive)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
185 (scroll-up (/ (+ 2 bg-mouse-y bg-mouse-y (- (window-height))) 2)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
186
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
187 (defun bg-mouse-line-to-bottom ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
188 "Scroll the line pointed to by the mouse to the bottom of the window."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
189 (interactive)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
190 (scroll-up (+ bg-mouse-y (- 2 (window-height)))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
191
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
192 (defun bg-kill-region ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
193 (interactive "*")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
194 (kill-region (region-beginning) (region-end)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
195
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
196 (defun bg-insert-moused-sexp ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
197 "Insert a copy of the word (actually sexp) that the mouse is pointing at.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
198 Sexp is inserted into the buffer at point (where the text cursor is)."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
199 (interactive)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
200 (let ((moused-text
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
201 (save-excursion
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
202 (bg-move-point-to-x-y bg-mouse-x bg-mouse-y)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
203 (if (looking-at "\\s)")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
204 (forward-char 1)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
205 (forward-sexp 1))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
206 (buffer-substring (save-excursion (backward-sexp 1) (point))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
207 (point)))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
208 (select-window bg-cursor-window)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
209 (delete-horizontal-space)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
210 (cond
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
211 ((bolp)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
212 (indent-according-to-mode))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
213 ;; In Lisp assume double-quote is closing; in Text assume opening.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
214 ;; Why? Because it does the right thing most often.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
215 ((save-excursion (forward-char -1)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
216 (and (not (looking-at "\\s\""))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
217 (looking-at "[`'\"\\]\\|\\s(")))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
218 nil)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
219 (t
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
220 (insert " ")))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
221 (insert moused-text)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
222 (or (eolp)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
223 (looking-at "\\s.\\|\\s)")
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
224 (and (looking-at "'") (looking-at "\\sw")) ;hack for text mode
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
225 (save-excursion (insert " ")))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
226
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
227 ;;; Utility functions:
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
228
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
229 (defun bg-get-tty-num (term-char)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
230 "Read from terminal until TERM-CHAR is read, and return intervening number.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
231 If non-numeric not matching TERM-CHAR, reprogram the mouse and signal an error."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
232 (let
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
233 ((num 0)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
234 (char (- (read-char) 48)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
235 (while (and (>= char 0)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
236 (<= char 9))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
237 (setq num (+ (* num 10) char))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
238 (setq char (- (read-char) 48)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
239 (or (eq term-char (+ char 48))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
240 (progn
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
241 (bg-program-mouse)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
242 (error
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
243 "Invalid data format in bg-mouse command: mouse reinitialized.")))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
244 num))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
245
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
246 ;;; Note that this fails in the minibuf because move-to-column doesn't
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
247 ;;; allow for the width of the prompt.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
248 (defun bg-move-point-to-x-y (x y)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
249 "Position cursor in window coordinates.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
250 X and Y are 0-based character positions in the window."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
251 (move-to-window-line y)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
252 ;; if not on a wrapped line, zero-column will be 0
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
253 (let ((zero-column (current-column))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
254 (scroll-offset (window-hscroll)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
255 ;; scrolling takes up column 0 to display the $
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
256 (if (> scroll-offset 0)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
257 (setq scroll-offset (1- scroll-offset)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
258 (move-to-column (+ zero-column scroll-offset x))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
259 ))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
260
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
261 ;;; Returns the window that screen position (x, y) is in or nil if none,
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
262 ;;; meaning we are in the echo area with a non-active minibuffer.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
263 (defun bg-window-from-x-y (x y)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
264 "Find window corresponding to screen coordinates.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
265 X and Y are 0-based character positions on the screen."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
266 (get-window-with-predicate (lambda (w)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
267 (coordinates-in-window-p (cons x y) w))))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
268
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
269 (defun bg-command-execute (bg-command)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
270 (if (commandp bg-command)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
271 (command-execute bg-command)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
272 (ding)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
273
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
274 (defun bg-program-mouse ()
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
275 (send-string-to-terminal "\e:0;7;;;360;512;9;16;9;16c"))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
276
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
277 ;;; Note that the doc string for mouse-map (as defined in subr.el)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
278 ;;; says it is for the X-window mouse. This is wrong; that keymap
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
279 ;;; should be used for your mouse no matter what terminal you have.
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
280
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
281 (or (keymapp mouse-map)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
282 (setq mouse-map (make-keymap)))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
283
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
284 (defun bind-bg-mouse-click (click-code function)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
285 "Bind bg-mouse CLICK-CODE to run FUNCTION."
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
286 (define-key mouse-map (char-to-string click-code) function))
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
287
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
288 (bind-bg-mouse-click bg-button-l 'bg-set-point)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
289 (bind-bg-mouse-click bg-button-m 'bg-yank)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
290 (bind-bg-mouse-click bg-button-r 'bg-set-mark)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
291 (bind-bg-mouse-click (+ bg-button-l bg-button-m) 'yank-pop-1)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
292 (bind-bg-mouse-click (+ bg-button-l bg-button-r) 'bg-kill-region)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
293 (bind-bg-mouse-click (+ bg-button-m bg-button-r) 'undo)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
294 (bind-bg-mouse-click (+ bg-button-l bg-button-m bg-button-r) 'undo)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
295 (bind-bg-mouse-click (+ bg-in-modeline bg-button-l) 'scroll-up)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
296 (bind-bg-mouse-click (+ bg-in-modeline bg-button-m) 'bg-move-by-percentage)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
297 (bind-bg-mouse-click (+ bg-in-modeline bg-button-r) 'scroll-down)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
298 (bind-bg-mouse-click (+ bg-in-scrollbar bg-button-l) 'bg-mouse-line-to-top)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
299 (bind-bg-mouse-click (+ bg-in-scrollbar bg-button-m) 'bg-mouse-line-to-center)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
300 (bind-bg-mouse-click (+ bg-in-scrollbar bg-button-r) 'bg-mouse-line-to-bottom)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
301 (bind-bg-mouse-click (+ bg-in-minibuf bg-button-l) 'execute-extended-command)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
302 (bind-bg-mouse-click (+ bg-in-minibuf bg-button-m) 'suspend-emacs)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
303 (bind-bg-mouse-click (+ bg-in-minibuf bg-button-r) 'eval-expression)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
304
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
305 (provide 'bg-mouse)
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
306
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
307 ;;; arch-tag: b3d06605-2971-44b1-be2c-e49c24e1a8d3
a7267c763125 bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff changeset
308 ;;; bg-mouse.el ends here