Mercurial > emacs
annotate lisp/obsolete/bg-mouse.el @ 67197:d385ac115b9f
* FOR-RELEASE: Icons installed. Partial completion bug fixed.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Tue, 29 Nov 2005 03:14:49 +0000 |
parents | 4377043d399d |
children | e8a3fb527b77 |
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 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
4 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
5 ;; Author: John Robinson <jr@bbn-unix.arpa> |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
6 ;; Stephen Gildea <gildea@bbn.com> |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
7 ;; Maintainer: FSF |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
8 ;; Keywords: hardware |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
9 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
11 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
12 ;; 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
|
13 ;; 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
|
14 ;; 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
|
15 ;; any later version. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
16 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
17 ;; 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
|
18 ;; 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
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
20 ;; GNU General Public License for more details. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
21 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
22 ;; 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
|
23 ;; 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
|
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
25 ;; Boston, MA 02110-1301, USA. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
26 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
27 ;;; Commentary: |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
28 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
29 ;;; Code: |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
30 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
31 ;;; 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
|
32 ;;; Modularized and enhanced by gildea@bbn.com Nov 1987 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
33 ;;; Time stamp <89/03/21 14:27:08 gildea> |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
34 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
35 ;;; User customization option: |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
36 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
37 (defvar bg-mouse-fast-select-window nil |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
38 "*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
|
39 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
40 ;;; 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
|
41 ;;; 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
|
42 (defconst bg-button-r 1) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
43 (defconst bg-button-m 2) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
44 (defconst bg-button-c 2) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
45 (defconst bg-button-l 4) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
46 (defconst bg-in-modeline 8) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
47 (defconst bg-in-scrollbar 16) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
48 (defconst bg-in-minibuf 24) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
49 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
50 ;;; semicolon screws up indenting, so use this instead |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
51 (defconst semicolon ?\;) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
52 |
65137
4377043d399d
Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents:
65118
diff
changeset
|
53 (defvar bg-mouse-x) |
4377043d399d
Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents:
65118
diff
changeset
|
54 (defvar bg-mouse-y) |
4377043d399d
Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents:
65118
diff
changeset
|
55 (defvar bg-cursor-window) |
4377043d399d
Move the `defvar's to the top level.
Juanma Barranquero <lekktu@gmail.com>
parents:
65118
diff
changeset
|
56 ;; 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
|
57 ;; 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
|
58 (defvar mouse-map) |
65118
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
59 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
60 ;;; Defuns: |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
61 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
62 (defun bg-mouse-report (prefix-arg) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
63 "Read, parse, and execute a BBN BitGraph mouse click. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
64 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
65 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
|
66 --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
|
67 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
|
68 -C- move point and yank | just select that window. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
69 LC- yank-pop | |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
70 -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
|
71 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
72 on modeline: on \"scroll bar\": in minibuffer: |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
73 L-- scroll-up line to top execute-extended-command |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
74 --R scroll-down line to bottom eval-expression |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
75 -C- proportional goto-char line to middle suspend-emacs |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
76 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
77 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
|
78 (interactive "P") |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
79 (bg-get-tty-num semicolon) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
80 (let* |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
81 ((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
|
82 (/ (bg-get-tty-num semicolon) 9))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
83 (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
|
84 (/ (bg-get-tty-num semicolon) 16))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
85 (bg-mouse-buttons (% (bg-get-tty-num ?c) 8)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
86 (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
|
87 (bg-cursor-window (selected-window)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
88 (edges (window-edges bg-mouse-window)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
89 (minibuf-p (= screen-mouse-y (1- (frame-height)))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
90 (in-modeline-p (and (not minibuf-p) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
91 (= screen-mouse-y (1- (nth 3 edges))))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
92 (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
|
93 (>= screen-mouse-x (1- (nth 2 edges))))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
94 (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
|
95 (in-minibuf-p (and minibuf-p |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
96 (not bg-mouse-window))) ;minibuf must be inactive |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
97 (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
|
98 (if in-modeline-p bg-in-modeline 0) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
99 (if in-scrollbar-p bg-in-scrollbar 0))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
100 (bg-command |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
101 (lookup-key mouse-map |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
102 (char-to-string (+ bg-mode-bits bg-mouse-buttons)))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
103 (bg-mouse-x (- screen-mouse-x (nth 0 edges))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
104 (bg-mouse-y (- screen-mouse-y (nth 1 edges)))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
105 (cond ((or in-modeline-p in-scrollbar-p) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
106 (select-window bg-mouse-window) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
107 (bg-command-execute bg-command) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
108 (select-window bg-cursor-window)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
109 ((or same-window-p in-minibuf-p) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
110 (bg-command-execute bg-command)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
111 (t ;in another window |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
112 (select-window bg-mouse-window) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
113 (if bg-mouse-fast-select-window |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
114 (bg-command-execute bg-command))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
115 ))) |
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 ;;; Library of commands: |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
119 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
120 (defun bg-set-point () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
121 "Move point to location of BitGraph mouse." |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
122 (interactive) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
123 (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
|
124 (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
|
125 (setq temporary-goal-column bg-mouse-x)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
126 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
127 (defun bg-set-mark () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
128 "Set mark at location of BitGraph mouse." |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
129 (interactive) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
130 (push-mark) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
131 (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
|
132 (exchange-point-and-mark)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
133 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
134 (defun bg-yank () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
135 "Move point to location of BitGraph mouse and yank." |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
136 (interactive "*") |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
137 (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
|
138 (setq this-command 'yank) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
139 (yank)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
140 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
141 (defun yank-pop-1 () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
142 (interactive "*") |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
143 (yank-pop 1)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
144 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
145 (defun bg-yank-or-pop () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
146 "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
|
147 was a yank, do a yank-pop." |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
148 (interactive "*") |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
149 (if (eq last-command 'yank) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
150 (yank-pop 1) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
151 (bg-yank))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
152 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
153 ;;; 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
|
154 (defconst bg-most-positive-fixnum 8388607) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
155 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
156 (defun bg-move-by-percentage () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
157 "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
|
158 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
|
159 (interactive) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
160 ;; check carefully for overflow in intermediate calculations |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
161 (goto-char |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
162 (cond ((zerop bg-mouse-x) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
163 0) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
164 ((< (buffer-size) (/ bg-most-positive-fixnum bg-mouse-x)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
165 ;; no danger of overflow: compute it exactly |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
166 (/ (* bg-mouse-x (buffer-size)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
167 (1- (window-width)))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
168 (t |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
169 ;; overflow possible: approximate |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
170 (* (/ (buffer-size) (1- (window-width))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
171 bg-mouse-x)))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
172 (beginning-of-line) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
173 (what-cursor-position)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
174 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
175 (defun bg-mouse-line-to-top () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
176 "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
|
177 (interactive) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
178 (scroll-up bg-mouse-y)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
179 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
180 (defun bg-mouse-line-to-center () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
181 "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
|
182 of the window" |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
183 (interactive) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
184 (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
|
185 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
186 (defun bg-mouse-line-to-bottom () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
187 "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
|
188 (interactive) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
189 (scroll-up (+ bg-mouse-y (- 2 (window-height))))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
190 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
191 (defun bg-kill-region () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
192 (interactive "*") |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
193 (kill-region (region-beginning) (region-end))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
194 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
195 (defun bg-insert-moused-sexp () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
196 "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
|
197 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
|
198 (interactive) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
199 (let ((moused-text |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
200 (save-excursion |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
201 (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
|
202 (if (looking-at "\\s)") |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
203 (forward-char 1) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
204 (forward-sexp 1)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
205 (buffer-substring (save-excursion (backward-sexp 1) (point)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
206 (point))))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
207 (select-window bg-cursor-window) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
208 (delete-horizontal-space) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
209 (cond |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
210 ((bolp) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
211 (indent-according-to-mode)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
212 ;; 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
|
213 ;; Why? Because it does the right thing most often. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
214 ((save-excursion (forward-char -1) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
215 (and (not (looking-at "\\s\"")) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
216 (looking-at "[`'\"\\]\\|\\s("))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
217 nil) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
218 (t |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
219 (insert " "))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
220 (insert moused-text) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
221 (or (eolp) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
222 (looking-at "\\s.\\|\\s)") |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
223 (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
|
224 (save-excursion (insert " "))))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
225 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
226 ;;; Utility functions: |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
227 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
228 (defun bg-get-tty-num (term-char) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
229 "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
|
230 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
|
231 (let |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
232 ((num 0) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
233 (char (- (read-char) 48))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
234 (while (and (>= char 0) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
235 (<= char 9)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
236 (setq num (+ (* num 10) char)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
237 (setq char (- (read-char) 48))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
238 (or (eq term-char (+ char 48)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
239 (progn |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
240 (bg-program-mouse) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
241 (error |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
242 "Invalid data format in bg-mouse command: mouse reinitialized."))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
243 num)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
244 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
245 ;;; 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
|
246 ;;; allow for the width of the prompt. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
247 (defun bg-move-point-to-x-y (x y) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
248 "Position cursor in window coordinates. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
249 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
|
250 (move-to-window-line y) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
251 ;; 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
|
252 (let ((zero-column (current-column)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
253 (scroll-offset (window-hscroll))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
254 ;; scrolling takes up column 0 to display the $ |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
255 (if (> scroll-offset 0) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
256 (setq scroll-offset (1- scroll-offset))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
257 (move-to-column (+ zero-column scroll-offset x)) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
258 )) |
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 ;;; 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
|
261 ;;; 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
|
262 (defun bg-window-from-x-y (x y) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
263 "Find window corresponding to screen coordinates. |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
264 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
|
265 (get-window-with-predicate (lambda (w) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
266 (coordinates-in-window-p (cons x y) w)))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
267 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
268 (defun bg-command-execute (bg-command) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
269 (if (commandp bg-command) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
270 (command-execute bg-command) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
271 (ding))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
272 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
273 (defun bg-program-mouse () |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
274 (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
|
275 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
276 ;;; 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
|
277 ;;; 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
|
278 ;;; 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
|
279 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
280 (or (keymapp mouse-map) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
281 (setq mouse-map (make-keymap))) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
282 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
283 (defun bind-bg-mouse-click (click-code function) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
284 "Bind bg-mouse CLICK-CODE to run FUNCTION." |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
285 (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
|
286 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
287 (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
|
288 (bind-bg-mouse-click bg-button-m 'bg-yank) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
289 (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
|
290 (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
|
291 (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
|
292 (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
|
293 (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
|
294 (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
|
295 (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
|
296 (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
|
297 (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
|
298 (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
|
299 (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
|
300 (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
|
301 (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
|
302 (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
|
303 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
304 (provide 'bg-mouse) |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
305 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
306 ;;; arch-tag: b3d06605-2971-44b1-be2c-e49c24e1a8d3 |
a7267c763125
bg-mouse.el: Moved from term/.
Juanma Barranquero <lekktu@gmail.com>
parents:
diff
changeset
|
307 ;;; bg-mouse.el ends here |