annotate lisp/term/sun-mouse.el @ 77893:6ac79e15e2cf

* mail/mail-extr.el (mail-extract-address-components): Recognize non-ASCII characters except for NBSP as words.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 04 Jun 2007 23:20:54 +0000
parents e3694f1cb928
children 030ae62d5c57 95d0cdf160ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; sun-mouse.el --- mouse handling for Sun windows
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
74509
f7702c5f335d Update copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68648
diff changeset
3 ;; Copyright (C) 1987, 2001, 2002, 2003, 2004, 2005,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 74509
diff changeset
4 ;; 2006, 2007 Free Software Foundation, Inc.
841
2cdce064065f entered into RCS
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 814
diff changeset
5
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
6 ;; Author: Jeff Peck
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
7 ;; Maintainer: FSF
814
38b2499cb3e9 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
8 ;; Keywords: hardware
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
9
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10 ;; This file is part of GNU Emacs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 ;; any later version.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 ;; GNU General Public License for more details.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
14170
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62402
diff changeset
25 ;; Boston, MA 02110-1301, USA.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
27 ;;; Commentary:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
28
14170
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
29 ;; Jeff Peck, Sun Microsystems, Jan 1987.
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
30 ;; Original idea by Stan Jefferson
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
31
14170
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
32 ;; Modeled after the GNUEMACS keymap interface.
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
33 ;;
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
34 ;; User Functions:
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
35 ;; make-mousemap, copy-mousemap,
14170
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
36 ;; define-mouse, global-set-mouse, local-set-mouse,
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
37 ;; use-global-mousemap, use-local-mousemap,
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
38 ;; mouse-lookup, describe-mouse-bindings
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
39 ;;
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
40 ;; Options:
23cc3f54e536 Update FSF's office address.
Erik Naggum <erik@naggum.no>
parents: 13962
diff changeset
41 ;; extra-click-wait, scrollbar-width
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
42
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
43 ;;; Code:
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 779
diff changeset
44
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
45 (defvar extra-click-wait 150
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
46 "*Number of milliseconds to wait for an extra click.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
47 Set this to zero if you don't want chords or double clicks.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
48
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
49 (defvar scrollbar-width 5
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
50 "*The character width of the scrollbar.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
51 The cursor is deemed to be in the right edge scrollbar if it is this near the
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
52 right edge, and more than two chars past the end of the indicated line.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
53 Setting to nil limits the scrollbar to the edge or vertical dividing bar.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
54
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
55 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
56 ;;; Mousemaps
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
57 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
58 (defun make-mousemap ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
59 "Returns a new mousemap."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
60 (cons 'mousemap nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
61
65100
f8a4e96b69d3 (current-global-mousemap, current-local-mousemap): Declare them before use.
Juanma Barranquero <lekktu@gmail.com>
parents: 64701
diff changeset
62 ;;; initialize mouse maps
f8a4e96b69d3 (current-global-mousemap, current-local-mousemap): Declare them before use.
Juanma Barranquero <lekktu@gmail.com>
parents: 64701
diff changeset
63 (defvar current-global-mousemap (make-mousemap))
f8a4e96b69d3 (current-global-mousemap, current-local-mousemap): Declare them before use.
Juanma Barranquero <lekktu@gmail.com>
parents: 64701
diff changeset
64 (defvar current-local-mousemap nil)
f8a4e96b69d3 (current-global-mousemap, current-local-mousemap): Declare them before use.
Juanma Barranquero <lekktu@gmail.com>
parents: 64701
diff changeset
65 (make-variable-buffer-local 'current-local-mousemap)
f8a4e96b69d3 (current-global-mousemap, current-local-mousemap): Declare them before use.
Juanma Barranquero <lekktu@gmail.com>
parents: 64701
diff changeset
66
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
67 (defun copy-mousemap (mousemap)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
68 "Return a copy of mousemap."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
69 (copy-alist mousemap))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
70
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
71 (defun define-mouse (mousemap mouse-list def)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
72 "Args MOUSEMAP, MOUSE-LIST, DEF. Define MOUSE-LIST in MOUSEMAP as DEF.
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3561
diff changeset
73 MOUSE-LIST is a list of atoms specifying a mouse hit according to these rules:
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
74 * One of these atoms specifies the active region of the definition.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 text, scrollbar, modeline, minibuffer
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76 * One or two or these atoms specify the button or button combination.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
77 left, middle, right, double
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
78 * Any combination of these atoms specify the active shift keys.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
79 control, shift, meta
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
80 * With a single unshifted button, you can add
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
81 up
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
82 to indicate an up-click.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
83 The atom `double' is used with a button designator to denote a double click.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
84 Two button chords are denoted by listing the two buttons.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 See sun-mouse-handler for the treatment of the form DEF."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86 (mousemap-set (mouse-list-to-mouse-code mouse-list) mousemap def))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 (defun global-set-mouse (mouse-list def)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 "Give MOUSE-EVENT-LIST a local definition of DEF.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90 See define-mouse for a description of MOUSE-EVENT-LIST and DEF.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 Note that if MOUSE-EVENT-LIST has a local definition in the current buffer,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 that local definition will continue to shadow any global definition."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
93 (interactive "xMouse event: \nxDefinition: ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 (define-mouse current-global-mousemap mouse-list def))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 (defun local-set-mouse (mouse-list def)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 "Give MOUSE-EVENT-LIST a local definition of DEF.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 See define-mouse for a description of the arguments.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 The definition goes in the current buffer's local mousemap.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 Normally buffers in the same major mode share a local mousemap."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 (interactive "xMouse event: \nxDefinition: ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 (if (null current-local-mousemap)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 (setq current-local-mousemap (make-mousemap)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 (define-mouse current-local-mousemap mouse-list def))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 (defun use-global-mousemap (mousemap)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 "Selects MOUSEMAP as the global mousemap."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 (setq current-global-mousemap mousemap))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 (defun use-local-mousemap (mousemap)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 "Selects MOUSEMAP as the local mousemap.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 nil for MOUSEMAP means no local mousemap."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 (setq current-local-mousemap mousemap))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 ;;; Interface to the Mouse encoding defined in Emacstool.c
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119 ;;; Called when mouse-prefix is sent to emacs, additional
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 ;;; information is read in as a list (button x y time-delta)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
121 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
122 ;;; First, some generally useful functions:
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
123 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 (defun logtest (x y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 "True if any bits set in X are also set in Y.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
127 Just like the Common Lisp function of the same name."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 (not (zerop (logand x y))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
129
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
130
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
131 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 ;;; Hit accessors.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 (defconst sm::ButtonBits 7) ; Lowest 3 bits.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 (defconst sm::ShiftmaskBits 56) ; Second lowest 3 bits (56 = 63 - 7).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 (defconst sm::DoubleBits 64) ; Bit 7.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 (defconst sm::UpBits 128) ; Bit 8.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 ;;; All the useful code bits
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (defmacro sm::hit-code (hit)
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
142 `(nth 0 ,hit))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 ;;; The button, or buttons if a chord.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144 (defmacro sm::hit-button (hit)
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
145 `(logand sm::ButtonBits (nth 0 ,hit)))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 ;;; The shift, control, and meta flags.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
147 (defmacro sm::hit-shiftmask (hit)
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
148 `(logand sm::ShiftmaskBits (nth 0 ,hit)))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 ;;; Set if a double click (but not a chord).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 (defmacro sm::hit-double (hit)
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
151 `(logand sm::DoubleBits (nth 0 ,hit)))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 ;;; Set on button release (as opposed to button press).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 (defmacro sm::hit-up (hit)
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
154 `(logand sm::UpBits (nth 0 ,hit)))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 ;;; Screen x position.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156 (defmacro sm::hit-x (hit) (list 'nth 1 hit))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 ;;; Screen y position.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158 (defmacro sm::hit-y (hit) (list 'nth 2 hit))
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3561
diff changeset
159 ;;; Milliseconds since last hit.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 (defmacro sm::hit-delta (hit) (list 'nth 3 hit))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
162 (defmacro sm::hit-up-p (hit) ; A predicate.
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
163 `(not (zerop (sm::hit-up ,hit))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
164
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 ;;; Loc accessors. for sm::window-xy
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 (defmacro sm::loc-w (loc) (list 'nth 0 loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 (defmacro sm::loc-x (loc) (list 'nth 1 loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 (defmacro sm::loc-y (loc) (list 'nth 2 loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 (defmacro eval-in-buffer (buffer &rest forms)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173 "Macro to switches to BUFFER, evaluates FORMS, returns to original buffer."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
174 ;; When you don't need the complete window context of eval-in-window
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
175 `(let ((StartBuffer (current-buffer)))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176 (unwind-protect
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
177 (progn
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
178 (set-buffer ,buffer)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
179 ,@forms)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
180 (set-buffer StartBuffer))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
181
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
182 (put 'eval-in-buffer 'lisp-indent-function 1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
183
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
184 ;;; this is used extensively by sun-fns.el
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
185 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
186 (defmacro eval-in-window (window &rest forms)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
187 "Switch to WINDOW, evaluate FORMS, return to original window."
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
188 `(let ((OriginallySelectedWindow (selected-window)))
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
189 (unwind-protect
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
190 (progn
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
191 (select-window ,window)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
192 ,@forms)
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
193 (select-window OriginallySelectedWindow))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
194 (put 'eval-in-window 'lisp-indent-function 1)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
197 ;;; handy utility, generalizes window_loop
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
198 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 ;;; It's a macro (and does not evaluate its arguments).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 (defmacro eval-in-windows (form &optional yesmini)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 "Switches to each window and evaluates FORM. Optional argument
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 YESMINI says to include the minibuffer as a window.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 This is a macro, and does not evaluate its arguments."
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
205 `(let ((OriginallySelectedWindow (selected-window)))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
206 (unwind-protect
41608
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
207 (while (progn
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
208 ,form
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
209 (not (eq OriginallySelectedWindow
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
210 (select-window
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
211 (next-window nil ,yesmini))))))
45db352a0971 Converted backquote to the new style.
Sam Steingold <sds@gnu.org>
parents: 41563
diff changeset
212 (select-window OriginallySelectedWindow))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 (put 'eval-in-window 'lisp-indent-function 0)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 (defun move-to-loc (x y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 "Move cursor to window location X, Y.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 Handles wrapped and horizontally scrolled lines correctly."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 (move-to-window-line y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 ;; window-line-end expects this to return the window column it moved to.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 (let ((cc (current-column))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221 (nc (move-to-column
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 (if (zerop (window-hscroll))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 (+ (current-column)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 (min (- (window-width) 2) ; To stay on the line.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 x))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 (+ (window-hscroll) -1
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 (min (1- (window-width)) ; To stay on the line.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 x))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 (- nc cc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 (defun minibuffer-window-p (window)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 "True iff this WINDOW is minibuffer."
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
234 (= (frame-height)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 (nth 3 (window-edges window)) ; The bottom edge.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 ))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239 (defun sun-mouse-handler (&optional hit)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240 "Evaluates the function or list associated with a mouse hit.
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
241 Expecting to read a hit, which is a list: (button x y delta).
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
242 A form bound to button by define-mouse is found by mouse-lookup.
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
243 The variables: *mouse-window*, *mouse-x*, *mouse-y* are bound.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 If the form is a symbol (symbolp), it is funcall'ed with *mouse-window*,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 *mouse-x*, and *mouse-y* as arguments; if the form is a list (listp),
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 the form is eval'ed; if the form is neither of these, it is an error.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 Returns nil."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
248 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 (if (null hit) (setq hit (sm::combined-hits)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250 (let ((loc (sm::window-xy (sm::hit-x hit) (sm::hit-y hit))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
251 (let ((*mouse-window* (sm::loc-w loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 (*mouse-x* (sm::loc-x loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
253 (*mouse-y* (sm::loc-y loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254 (mouse-code (mouse-event-code hit loc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
255 (let ((form (eval-in-buffer (window-buffer *mouse-window*)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256 (mouse-lookup mouse-code))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 (cond ((null form)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258 (if (not (sm::hit-up-p hit)) ; undefined up hits are ok.
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
259 (error "Undefined mouse event: %s"
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
260 (prin1-to-string
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261 (mouse-code-to-mouse-list mouse-code)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 ((symbolp form)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 (setq this-command form)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 (funcall form *mouse-window* *mouse-x* *mouse-y*))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265 ((listp form)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 (setq this-command (car form))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
267 (eval form))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
268 (t
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
269 (error "Mouse action must be symbol or list, but was: %s"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270 form))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
271 ;; Don't let 'sun-mouse-handler get on last-command,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
272 ;; since this function should be transparent.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
273 (if (eq this-command 'sun-mouse-handler)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274 (setq this-command last-command))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 ;; (message (prin1-to-string this-command)) ; to see what your buttons did
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 (defun sm::combined-hits ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 "Read and return next mouse-hit, include possible double click"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
280 (let ((hit1 (mouse-hit-read)))
13962
dd14d8d6e7db (describe-mouse-briefly): Fix message spelling.
Karl Heuer <kwzh@gnu.org>
parents: 3591
diff changeset
281 (if (not (sm::hit-up-p hit1)) ; Up hits don't start doubles or chords.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
282 (let ((hit2 (mouse-second-hit extra-click-wait)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 (if hit2 ; we cons'd it, we can smash it.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 ; (setf (sm::hit-code hit1) (logior (sm::hit-code hit1) ...))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
285 (setcar hit1 (logior (sm::hit-code hit1)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 (sm::hit-code hit2)
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
287 (if (= (sm::hit-button hit1)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 (sm::hit-button hit2))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 sm::DoubleBits 0))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290 hit1))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 (defun mouse-hit-read ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293 "Read mouse-hit list from keyboard. Like (read 'read-char),
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
294 but that uses minibuffer, and mucks up last-command."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
295 (let ((char-list nil) (char nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
296 (while (not (equal 13 ; Carriage return.
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
297 (prog1 (setq char (read-char))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
298 (setq char-list (cons char char-list))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
299 (read (mapconcat 'char-to-string (nreverse char-list) ""))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
300 ))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
301
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
302 ;;; Second Click Hackery....
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
303 ;;; if prefix is not mouse-prefix, need a way to unread the char...
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
304 ;;; or else have mouse flush input queue, or else need a peek at next char.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
305
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
306 ;;; There is no peek, but since one character can be unread, we only
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
307 ;;; have to flush the queue when the command after a mouse click
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
308 ;;; starts with mouse-prefix1 (see below).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
309 ;;; Something to do later: We could buffer the read commands and
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
310 ;;; execute them ourselves after doing the mouse command (using
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
311 ;;; lookup-key ??).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
312
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
313 (defvar mouse-prefix1 24 ; C-x
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
314 "First char of mouse-prefix. Used to detect double clicks and chords.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
315
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
316 (defvar mouse-prefix2 0 ; C-@
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
317 "Second char of mouse-prefix. Used to detect double clicks and chords.")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
318
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
319
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320 (defun mouse-second-hit (hit-wait)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 "Returns the next mouse hit occurring within HIT-WAIT milliseconds."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 (if (sit-for-millisecs hit-wait) nil ; No input within hit-wait millisecs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 (let ((pc1 (read-char)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324 (if (or (not (equal pc1 mouse-prefix1))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 (sit-for-millisecs 3)) ; a mouse prefix will have second char
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1623
diff changeset
326 ;; Can get away with one unread.
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1623
diff changeset
327 (progn (setq unread-command-events (list pc1))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 nil) ; Next input not mouse event.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 (let ((pc2 (read-char)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330 (if (not (equal pc2 mouse-prefix2))
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1623
diff changeset
331 (progn (setq unread-command-events (list pc1)) ; put back the ^X
1623
bdd72dc49c66 * bytecomp.el: Declare unread-command-char an obsolete variable.
Jim Blandy <jimb@redhat.com>
parents: 1543
diff changeset
332 ;;; Too bad can't do two: (setq unread-command-event (list pc1 pc2))
1821
04fb1d3d6992 JimB's changes since January 18th
Jim Blandy <jimb@redhat.com>
parents: 1623
diff changeset
333 ;;; Well, now we can, but I don't understand this code well enough to fix it...
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
334 (ding) ; user will have to retype that pc2.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
335 nil) ; This input is not a mouse event.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
336 ;; Next input has mouse prefix and is within time limit.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
337 (let ((new-hit (mouse-hit-read))) ; Read the new hit.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
338 (if (sm::hit-up-p new-hit) ; Ignore up events when timing.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
339 (mouse-second-hit (- hit-wait (sm::hit-delta new-hit)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
340 new-hit ; New down hit within limit, return it.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
341 ))))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
342
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
343 (defun sm::window-xy (x y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
344 "Find window containing screen coordinates X and Y.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
345 Returns list (window x y) where x and y are relative to window."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
346 (or
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
347 (catch 'found
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
348 (eval-in-windows
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
349 (let ((we (window-edges (selected-window))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
350 (let ((le (nth 0 we))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
351 (te (nth 1 we))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
352 (re (nth 2 we))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
353 (be (nth 3 we)))
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
354 (if (= re (frame-width))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
355 ;; include the continuation column with this window
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
356 (setq re (1+ re)))
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
357 (if (= be (frame-height))
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
358 ;; include partial line at bottom of frame with this window
13962
dd14d8d6e7db (describe-mouse-briefly): Fix message spelling.
Karl Heuer <kwzh@gnu.org>
parents: 3591
diff changeset
359 ;; id est, if window is not multiple of char size.
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
360 (setq be (1+ be)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
361
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
362 (if (and (>= x le) (< x re)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
363 (>= y te) (< y be))
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
364 (throw 'found
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
365 (list (selected-window) (- x le) (- y te))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
366 t)) ; include minibuffer in eval-in-windows
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
367 ;;If x,y from a real mouse click, we shouldn't get here.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
368 (list nil x y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
369 ))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
370
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
371 (defun sm::window-region (loc)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
372 "Parse LOC into a region symbol.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
373 Returns one of (text scrollbar modeline minibuffer)"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
374 (let ((w (sm::loc-w loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
375 (x (sm::loc-x loc))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
376 (y (sm::loc-y loc)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
377 (let ((right (1- (window-width w)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
378 (bottom (1- (window-height w))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
379 (cond ((minibuffer-window-p w) 'minibuffer)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
380 ((>= y bottom) 'modeline)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
381 ((>= x right) 'scrollbar)
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3561
diff changeset
382 ;; far right column (window separator) is always a scrollbar
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
383 ((and scrollbar-width
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
384 ;; mouse within scrollbar-width of edge.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
385 (>= x (- right scrollbar-width))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
386 ;; mouse a few chars past the end of line.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
387 (>= x (+ 2 (window-line-end w x y))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
388 'scrollbar)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
389 (t 'text)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
390
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
391 (defun window-line-end (w x y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
392 "Return WINDOW column (ignore X) containing end of line Y"
779
c2dbf1fe0506 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 658
diff changeset
393 (eval-in-window w (save-excursion (move-to-loc (frame-width) y))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
394
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
395 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
396 ;;; The encoding of mouse events into a mousemap.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
397 ;;; These values must agree with coding in emacstool:
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
398 ;;;
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
399 (defconst sm::keyword-alist
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
400 '((left . 1) (middle . 2) (right . 4)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
401 (shift . 8) (control . 16) (meta . 32) (double . 64) (up . 128)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
402 (text . 256) (scrollbar . 512) (modeline . 1024) (minibuffer . 2048)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
403 ))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
404
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
405 (defun mouse-event-code (hit loc)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
406 "Maps MOUSE-HIT and LOC into a mouse-code."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
407 ;;;Region is a code for one of text, modeline, scrollbar, or minibuffer.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
408 (logior (sm::hit-code hit)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
409 (mouse-region-to-code (sm::window-region loc))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
410
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
411 (defun mouse-region-to-code (region)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
412 "Returns partial mouse-code for specified REGION."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
413 (cdr (assq region sm::keyword-alist)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
414
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
415 (defun mouse-list-to-mouse-code (mouse-list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416 "Map a MOUSE-LIST to a mouse-code."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 (apply 'logior
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
418 (mapcar (function (lambda (x)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
419 (cdr (assq x sm::keyword-alist))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
420 mouse-list)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
421
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
422 (defun mouse-code-to-mouse-list (mouse-code)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
423 "Map a MOUSE-CODE to a mouse-list."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
424 (apply 'nconc (mapcar
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
425 (function (lambda (x)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
426 (if (logtest mouse-code (cdr x))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
427 (list (car x)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
428 sm::keyword-alist)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
429
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
430 (defun mousemap-set (code mousemap value)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
431 (let* ((alist (cdr mousemap))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
432 (assq-result (assq code alist)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
433 (if assq-result
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
434 (setcdr assq-result value)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
435 (setcdr mousemap (cons (cons code value) alist)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
436
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
437 (defun mousemap-get (code mousemap)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
438 (cdr (assq code (cdr mousemap))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
439
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
440 (defun mouse-lookup (mouse-code)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
441 "Look up MOUSE-EVENT and return the definition. nil means undefined."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
442 (or (mousemap-get mouse-code current-local-mousemap)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
443 (mousemap-get mouse-code current-global-mousemap)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
444
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
445 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
446 ;;; I (jpeck) don't understand the utility of the next four functions
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
447 ;;; ask Steven Greenbaum <froud@kestrel>
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
448 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
449 (defun mouse-mask-lookup (mask list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
450 "Args MASK (a bit mask) and LIST (a list of (code . form) pairs).
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
451 Returns a list of elements of LIST whose code or'ed with MASK is non-zero."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
452 (let ((result nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
453 (while list
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
454 (if (logtest mask (car (car list)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
455 (setq result (cons (car list) result)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
456 (setq list (cdr list)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
457 result))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
458
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
459 (defun mouse-union (l l-unique)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
460 "Return the union of list of mouse (code . form) pairs L and L-UNIQUE,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
461 where L-UNIQUE is considered to be union'ized already."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
462 (let ((result l-unique))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
463 (while l
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
464 (let ((code-form-pair (car l)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465 (if (not (assq (car code-form-pair) result))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 (setq result (cons code-form-pair result))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
467 (setq l (cdr l)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
468 result))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
469
3561
1c1a6e2961c2 (mouse-union-first-preferred): Renamed from mouse-union-first-prefered.
Richard M. Stallman <rms@gnu.org>
parents: 2636
diff changeset
470 (defun mouse-union-first-preferred (l1 l2)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
471 "Return the union of lists of mouse (code . form) pairs L1 and L2,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
472 based on the code's, with preference going to elements in L1."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
473 (mouse-union l2 (mouse-union l1 nil)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
474
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
475 (defun mouse-code-function-pairs-of-region (region)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
476 "Return a list of (code . function) pairs, where each code is
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
477 currently set in the REGION."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
478 (let ((mask (mouse-region-to-code region)))
3561
1c1a6e2961c2 (mouse-union-first-preferred): Renamed from mouse-union-first-prefered.
Richard M. Stallman <rms@gnu.org>
parents: 2636
diff changeset
479 (mouse-union-first-preferred
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
480 (mouse-mask-lookup mask (cdr current-local-mousemap))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
481 (mouse-mask-lookup mask (cdr current-global-mousemap))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
482 )))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
483
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
484 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
485 ;;; Functions for DESCRIBE-MOUSE-BINDINGS
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
486 ;;; And other mouse documentation functions
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
487 ;;; Still need a good procedure to print out a help sheet in readable format.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
488 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
489
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
490 (defun one-line-doc-string (function)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
491 "Returns first line of documentation string for FUNCTION.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
492 If there is no documentation string, then the string
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
493 \"No documentation\" is returned."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
494 (while (consp function) (setq function (car function)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
495 (let ((doc (documentation function)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
496 (if (null doc)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
497 "No documentation."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
498 (string-match "^.*$" doc)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
499 (substring doc 0 (match-end 0)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
500
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
501 (defun print-mouse-format (binding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
502 (princ (car binding))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
503 (princ ": ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
504 (mapcar (function
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
505 (lambda (mouse-list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
506 (princ mouse-list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
507 (princ " ")))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
508 (cdr binding))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
509 (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
510 (princ " ")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
511 (princ (one-line-doc-string (car binding)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
512 (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
513 )
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
514
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
515 (defun print-mouse-bindings (region)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
516 "Prints mouse-event bindings for REGION."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
517 (mapcar 'print-mouse-format (sm::event-bindings region)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
518
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
519 (defun sm::event-bindings (region)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
520 "Returns an alist of (function . (mouse-list1 ... mouse-listN)) for REGION,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
521 where each mouse-list is bound to the function in REGION."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
522 (let ((mouse-bindings (mouse-code-function-pairs-of-region region))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
523 (result nil))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
524 (while mouse-bindings
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
525 (let* ((code-function-pair (car mouse-bindings))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
526 (current-entry (assoc (cdr code-function-pair) result)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
527 (if current-entry
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
528 (setcdr current-entry
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
529 (cons (mouse-code-to-mouse-list (car code-function-pair))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
530 (cdr current-entry)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
531 (setq result (cons (cons (cdr code-function-pair)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
532 (list (mouse-code-to-mouse-list
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
533 (car code-function-pair))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
534 result))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
535 (setq mouse-bindings (cdr mouse-bindings))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
536 )
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
537 result))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
538
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
539 (defun describe-mouse-bindings ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
540 "Lists all current mouse-event bindings."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
541 (interactive)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
542 (with-output-to-temp-buffer "*Help*"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
543 (princ "Text Region") (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
544 (princ "---- ------") (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
545 (print-mouse-bindings 'text) (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
546 (princ "Modeline Region") (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
547 (princ "-------- ------") (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
548 (print-mouse-bindings 'modeline) (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
549 (princ "Scrollbar Region") (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
550 (princ "--------- ------") (terpri)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
551 (print-mouse-bindings 'scrollbar)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
552
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
553 (defun describe-mouse-briefly (mouse-list)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
554 "Print a short description of the function bound to MOUSE-LIST."
13962
dd14d8d6e7db (describe-mouse-briefly): Fix message spelling.
Karl Heuer <kwzh@gnu.org>
parents: 3591
diff changeset
555 (interactive "xDescribe mouse list briefly: ")
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
556 (let ((function (mouse-lookup (mouse-list-to-mouse-code mouse-list))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
557 (if function
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
558 (message "%s runs the command %s" mouse-list function)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
559 (message "%s is undefined" mouse-list))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
560
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
561 (defun mouse-help-menu (function-and-binding)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
562 (cons (prin1-to-string (car function-and-binding))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
563 (menu-create ; Two sub-menu items of form ("String" . nil)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
564 (list (list (one-line-doc-string (car function-and-binding)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
565 (list (prin1-to-string (cdr function-and-binding)))))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
566
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
567 (defun mouse-help-region (w x y &optional region)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
568 "Displays a menu of mouse functions callable in this region."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
569 (let* ((region (or region (sm::window-region (list w x y))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
570 (mlist (mapcar (function mouse-help-menu)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
571 (sm::event-bindings region)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
572 (menu (menu-create (cons (list (symbol-name region)) mlist)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
573 (item (sun-menu-evaluate w 0 y menu))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
574 )))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
575
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
576 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
577 ;;; Menu interface functions
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
578 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
579 ;;; use defmenu, because this interface is subject to change
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
580 ;;; really need a menu-p, but we use vectorp and the context...
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
581 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
582 (defun menu-create (items)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
583 "Functional form for defmenu, given a list of ITEMS returns a menu.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
584 Each ITEM is a (STRING . VALUE) pair."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
585 (apply 'vector items)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
586 )
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
587
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
588 (defmacro defmenu (menu &rest itemlist)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
589 "Defines MENU to be a menu, the ITEMS are (STRING . VALUE) pairs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
590 See sun-menu-evaluate for interpretation of ITEMS."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
591 (list 'defconst menu (funcall 'menu-create itemlist))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
592 )
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
593
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
594 (defun sun-menu-evaluate (*menu-window* *menu-x* *menu-y* menu)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
595 "Display a pop-up menu in WINDOW at X Y and evaluate selected item
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
596 of MENU. MENU (or its symbol-value) should be a menu defined by defmenu.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
597 A menu ITEM is a (STRING . FORM) pair;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
598 the FORM associated with the selected STRING is evaluated,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
599 and the resulting value is returned. Generally these FORMs are
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
600 evaluated for their side-effects rather than their values.
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
601 If the selected form is a menu or a symbol whose value is a menu,
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
602 then it is displayed and evaluated as a pullright menu item.
42706
be541feb06cc Fix typo.
Pavel Janík <Pavel@Janik.cz>
parents: 41608
diff changeset
603 If the FORM of the first ITEM is nil, the STRING of the item
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3561
diff changeset
604 is used as a label for the menu, i.e. it's inverted and not selectable."
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
605
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
606 (if (symbolp menu) (setq menu (symbol-value menu)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
607 (eval (sun-menu-internal *menu-window* *menu-x* *menu-y* 4 menu)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
608
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
609 (defun sun-get-frame-data (code)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
610 "Sends the tty-sub-window escape sequence CODE to terminal,
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
611 and returns a cons of the two numbers in returned escape sequence.
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
612 That is it returns (cons <car> <cdr>) from \"\\E[n;<car>;<cdr>t\".
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
613 CODE values: 13 = Tool-Position, 14 = Size-in-Pixels, 18 = Size-in-Chars."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
614 (send-string-to-terminal (concat "\033[" (int-to-string code) "t"))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
615 (let (char str x y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
616 (while (not (equal 116 (setq char (read-char)))) ; #\t = 116
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
617 (setq str (cons char str)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
618 (setq str (mapconcat 'char-to-string (nreverse str) ""))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
619 (string-match ";[0-9]*" str)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
620 (setq y (substring str (1+ (match-beginning 0)) (match-end 0)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
621 (setq str (substring str (match-end 0)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
622 (string-match ";[0-9]*" str)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
623 (setq x (substring str (1+ (match-beginning 0)) (match-end 0)))
62402
a7e02ef1e3d6 Replace `string-to-int' by `string-to-number'.
Juanma Barranquero <lekktu@gmail.com>
parents: 52401
diff changeset
624 (cons (string-to-number y) (string-to-number x))))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
625
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
626 (defun sm::font-size ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
627 "Returns font size in pixels: (cons Ysize Xsize)"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
628 (let ((pix (sun-get-frame-data 14)) ; returns size in pixels
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
629 (chr (sun-get-frame-data 18))) ; returns size in chars
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
630 (cons (/ (car pix) (car chr)) (/ (cdr pix) (cdr chr)))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
631
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
632 (defvar sm::menu-kludge-x nil
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
633 "Cached frame-to-window X-Offset for sm::menu-kludge")
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
634 (defvar sm::menu-kludge-y nil
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
635 "Cached frame-to-window Y-Offset for sm::menu-kludge")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
636
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
637 (defun sm::menu-kludge ()
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
638 "If sunfns.c uses <Menu_Base_Kludge> this function must be here!"
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
639 (or sm::menu-kludge-y
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
640 (let ((fs (sm::font-size)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
641 (setq sm::menu-kludge-y (+ 8 (car fs)) ; a title line and borders
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
642 sm::menu-kludge-x 4))) ; best values depend on .defaults/Menu
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
643 (let ((wl (sun-get-frame-data 13))) ; returns frame location
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
644 (cons (+ (car wl) sm::menu-kludge-y)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
645 (+ (cdr wl) sm::menu-kludge-x))))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
646
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
647 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
648 ;;; Function interface to selection/region
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3561
diff changeset
649 ;;; primitive functions are defined in sunfns.c
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
650 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
651 (defun sun-yank-selection ()
1543
acdf9d64d086 Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 841
diff changeset
652 "Set mark and yank the contents of the current sunwindows selection.
acdf9d64d086 Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 841
diff changeset
653 Insert contents into the current buffer at point."
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
654 (interactive "*")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
655 (set-mark-command nil)
41563
224b0d23d2ee (sun-yank-selection): Use insert instead of insert-string.
Pavel Janík <Pavel@Janik.cz>
parents: 25307
diff changeset
656 (insert (sun-get-selection)))
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
657
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
658 (defun sun-select-region (beg end)
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
659 "Set the sunwindows selection to the region in the current buffer."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
660 (interactive "r")
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
661 (sun-set-selection (buffer-substring beg end)))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
662
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
663 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
664 ;;; Support for emacstool
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
665 ;;; This closes the window instead of stopping emacs.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
666 ;;;
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
667 (defun suspend-emacstool (&optional stuffstring)
1543
acdf9d64d086 Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 841
diff changeset
668 "Suspend emacstool.
acdf9d64d086 Doc fix.
Christopher Zaborsky <rogue@erratum.com>
parents: 841
diff changeset
669 If running under as a detached process emacstool,
49599
5ade352e8d1c Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents: 42706
diff changeset
670 you don't want to suspend (there is no way to resume),
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
671 just close the window, and wait for reopening."
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
672 (interactive)
2636
0b90475af405 * sun-mouse.el (suspend-emacstool): Run suspend-hook, not
Jim Blandy <jimb@redhat.com>
parents: 2112
diff changeset
673 (run-hooks 'suspend-hook)
35
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
674 (if stuffstring (send-string-to-terminal stuffstring))
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
675 (send-string-to-terminal "\033[2t") ; To close EmacsTool window.
63b375f17a65 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
676 (run-hooks 'suspend-resume-hook))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 35
diff changeset
677
25229
d53ca1c2f809 (sun-mouse): Provide `sun-mouse', not `term/sun-mouse'.
Karl Heuer <kwzh@gnu.org>
parents: 17303
diff changeset
678 (provide 'sun-mouse)
25307
91079038d4a3 Provide term/sun-mouse.
Dave Love <fx@gnu.org>
parents: 25229
diff changeset
679 (provide 'term/sun-mouse) ; have to (require 'term/sun-mouse)
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 35
diff changeset
680
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 49599
diff changeset
681 ;;; arch-tag: 6e879372-b899-4509-833f-d7f6250e309a
658
7cbd4fcd8b0f *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
682 ;;; sun-mouse.el ends here