annotate lisp/packages/balloon-help.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 8fc7fe29b841
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; Balloon help for XEmacs (requires 19.12 or later)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;; Copyright (C) 1995 Kyle E. Jones
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; A copy of the GNU General Public License can be obtained from this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;; program's author (send electronic mail to kyle@uunet.uu.net) or from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;; Send bug reports to kyle@wonderworks.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; Balloon help pops up a small frame to display help text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; relating to objects that the mouse cursor passes over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; Installation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; Byte-compile the file balloon-help.el (with M-x byte-compile-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; and put the .elc file in a directory in your load-path. Add the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; following line to your .emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; (require 'balloon-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; For 19.12 users:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; If you are using fvwm, [tv]twm or ol[v]wm, you can also add
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; the following lines to various configuration file to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; minimal decorations on the balloon help frames.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; In .emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; (setq balloon-help-frame-name "balloon-help")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; For ol[v]wm use this in .Xdefaults:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; olvwm.NoDecor: balloon-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; olwm.MinimalDecor: balloon-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; For fvvm use this in your .fvwmrc:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; NoTitle balloon-help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; Style "balloon-help" NoTitle, NoHandles, BorderWidth 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; For twm use this in your .twmrc:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; NoTitle { "balloon-help" }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; Under 19.13 and later versions the balloon-help frame uses a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; transient window that is not normally decorated by window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; managers. So the window manager directives should not be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; needed for XEmacs 19.13 and beyond.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (provide 'balloon-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defvar balloon-help-version "1.02"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 "Version string for Balloon Help.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defvar balloon-help-mode t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 "*Non-nil means Balloon help mode is enabled.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defvar balloon-help-timeout 1500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 "*Display help after this many milliseconds of mouse inactivity.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defvar balloon-help-foreground "black"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "*The foreground color for displaying balloon help text.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (defvar balloon-help-background "rgb:c0/c0/c0"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 "*The background color for the balloon help frame.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (defvar balloon-help-background-pixmap ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 "*The background pixmap for the balloon help frame.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (defvar balloon-help-font "fixed"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 "*The font for displaying balloon help text.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defvar balloon-help-border-color "black"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "*The color for displaying balloon help frame's border.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (defvar balloon-help-use-sound nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 "*Non-nil value means play a sound to herald the appearance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 and disappearance of the help frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 `balloon-help-appears' will be played when the frame appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 `balloon-help-disappears' will be played when the frame disappears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 See the documentation for the function load-sound-file to see how
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 define sounds.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defvar balloon-help-frame-name nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "*The frame name to use for the frame to display the balloon help.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;;; End of user variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defvar mouse-motion-hook mouse-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 "Hooks to be run whenever the user moves the mouse.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 Each hook is called with one argument, the mouse motion event.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun mouse-motion-hook (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "Run the hooks attached to mouse-motion-hook."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (run-hook-with-args 'mouse-motion-hook event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (setq mouse-motion-handler 'mouse-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defvar balloon-help-frame nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "Balloon help is displayed in this frame.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (defvar balloon-help-help-object nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 "Object that the mouse is over that has a help property, nil otherwise.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defvar balloon-help-help-object-x nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 "Last horizontal mouse position over balloon-help-help-object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvar balloon-help-help-object-y nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "Last vertical mouse position over balloon-help-help-object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (defvar balloon-help-buffer nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 "Buffer used to display balloon help.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (defvar balloon-help-timeout-id nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 "Timeout id for the balloon help timeout.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (defvar balloon-help-display-pending nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 "Non-nil value means the help frame will be visible as soon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 as the X server gets around to displaying it. Nil means it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 will be invisible as soon as the X server decides to hide it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defvar balloon-help-bar-cursor nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (defun balloon-help-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "Toggle Balloon Help mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 With arg, turn Balloon Help mode on iff arg is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 With Balloon Help enabled, a small frame is displayed whenever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 the mouse rests on an object that has a help property of some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 kind. The text of that help property is displayed in the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 For extents, the 'balloon-help' property is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 checked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 For toolbar buttons, the help-string slot of the toolbar button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 is checked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 If the value is a string, it is used as the help message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 If the property's value is a symbol, it is assumed to be the name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 of a function and it will be called with one argument, the object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 under the mouse, and the return value of that function will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 used as the help message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (setq balloon-help-mode (or (and arg (> (prefix-numeric-value arg) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (and (null arg) (null balloon-help-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if (null balloon-help-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (balloon-help-undisplay-help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defun balloon-help-displayed ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (and (frame-live-p balloon-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (frame-visible-p balloon-help-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defun balloon-help-motion-hook (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ((null balloon-help-mode) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ((button-press-event-p event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (setq balloon-help-help-object nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (if balloon-help-timeout-id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (disable-timeout balloon-help-timeout-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (if (balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (balloon-help-undisplay-help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (let* ((buffer (event-buffer event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (frame (event-frame event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (point (and buffer (event-point event)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (glyph-extent (event-glyph-extent event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (glyph-extent (if (and glyph-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (extent-property glyph-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 'balloon-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 glyph-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (extent (and point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (extent-at point buffer 'balloon-help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (button (event-toolbar-button event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (button (if (and button (toolbar-button-help-string button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (object (or glyph-extent extent button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (id balloon-help-timeout-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (if (null object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (if (and balloon-help-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (not (eq frame balloon-help-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (setq balloon-help-help-object nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (if id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (disable-timeout id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if (balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (balloon-help-undisplay-help))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (let* ((params (frame-parameters frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (top (cdr (assq 'top params)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (left (cdr (assq 'left params)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (xtop-toolbar-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (if (specifier-instance top-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (specifier-instance top-toolbar-height)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (xleft-toolbar-width
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if (specifier-instance left-toolbar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (specifier-instance left-toolbar-width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (menubar-height (if current-menubar 22 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (setq balloon-help-help-object-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (+ left xleft-toolbar-width (event-x-pixel event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 balloon-help-help-object-y
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (+ top xtop-toolbar-height menubar-height
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (event-y-pixel event))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (cond ((eq frame balloon-help-frame) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ((eq object balloon-help-help-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (if (balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (balloon-help-move-help-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ((balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (setq balloon-help-help-object object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (balloon-help-display-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (setq balloon-help-help-object object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (if id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (disable-timeout id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (setq balloon-help-timeout-id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (add-timeout (/ balloon-help-timeout 1000.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (function balloon-help-display-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 nil)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (defun balloon-help-pre-command-hook (&rest ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (setq balloon-help-help-object nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (if (balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (balloon-help-undisplay-help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (fset 'balloon-help-post-command-hook 'balloon-help-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (fset 'balloon-help-mouse-leave-frame-hook 'balloon-help-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (fset 'balloon-help-deselect-frame-hook 'balloon-help-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (defun balloon-help-display-help (&rest ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (setq balloon-help-timeout-id nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (if balloon-help-help-object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (let* ((object balloon-help-help-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (help (or (and (extent-live-p object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (extent-property object 'balloon-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (and (toolbar-button-p object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (toolbar-button-help-string object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (and (stringp object) object))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 ;; if help is non-null and is not a string, run it as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; function to produuce the help string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (if (or (null help) (not (symbolp help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (condition-case data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (setq help (funcall help object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (setq help (format "help function signaled: %S" data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (if (stringp help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (if (not (bufferp balloon-help-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (setq balloon-help-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (get-buffer-create " *balloon-help*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (if (not (frame-live-p balloon-help-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (setq balloon-help-frame (balloon-help-make-help-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (setq bar-cursor t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (set-buffer balloon-help-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (insert help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (insert ?\n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; help strings longer than 2 lines have the last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; line stolen by the minibuffer, so make sure the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; last line is blank. Make the top line blank for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; some symmetry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (if (< 2 (count-lines (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; add a second blank line at the end to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;; prevent the modeline bar from clipping the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ;; descenders of the last line of text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (insert ?\n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (insert ?\n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;; cursor will be at point-min because we're just
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;; moving point which doesn't affect window-point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ;; when the window isn't selected. Indent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; everything so that the cursor will be over a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;; space. The 1-pixel bar cursor will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 ;; completely invisible this way.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (indent-rigidly (point-min) (point-max) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (balloon-help-move-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (balloon-help-resize-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (balloon-help-expose-help-frame))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (defun balloon-help-undisplay-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq bar-cursor balloon-help-bar-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (balloon-help-hide-help-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (defun balloon-help-hide-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (if (balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (make-frame-invisible balloon-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (if (and balloon-help-use-sound balloon-help-display-pending)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (play-sound 'balloon-help-disappears))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (setq balloon-help-display-pending nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (defun balloon-help-expose-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (if (not (balloon-help-displayed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (make-frame-visible balloon-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (if (and balloon-help-use-sound (null balloon-help-display-pending))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (play-sound 'balloon-help-appears))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq balloon-help-display-pending t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (defun balloon-help-resize-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (set-buffer balloon-help-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (let ((longest 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (lines 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (done nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (window-min-height 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (window-min-width 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (while (not done)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (end-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (setq longest (max longest (current-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 done (not (= 0 (forward-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (and (not done) (setq lines (1+ lines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (set-frame-size balloon-help-frame (+ 1 longest) lines))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (defun balloon-help-make-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (setq balloon-help-bar-cursor bar-cursor)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (set-buffer balloon-help-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (set-buffer-menubar nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (let* ((x (balloon-help-compute-help-frame-x-location))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (y (balloon-help-compute-help-frame-y-location))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (window-min-height 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (window-min-width 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (frame (make-frame (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 '(initially-unmapped . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; try to evade frame decorations
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (cons 'name (or balloon-help-frame-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "xclock"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 '(border-width . 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (cons 'border-color balloon-help-border-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (cons 'top y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (cons 'left x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (cons 'popup (selected-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 '(width . 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 '(height . 1)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (set-face-font 'default balloon-help-font frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (set-face-foreground 'default balloon-help-foreground frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (set-face-background 'default balloon-help-background frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (set-face-background-pixmap 'default balloon-help-background-pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (set-window-buffer (frame-selected-window frame) balloon-help-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (set-specifier has-modeline-p (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (set-specifier top-toolbar-height (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (set-specifier left-toolbar-width (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (set-specifier right-toolbar-width (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (set-specifier bottom-toolbar-height (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (set-specifier top-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (set-specifier left-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (set-specifier right-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (set-specifier bottom-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (set-specifier scrollbar-width (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (set-specifier scrollbar-height (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (set-specifier modeline-shadow-thickness (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (set-face-background 'modeline balloon-help-background frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 frame )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defun balloon-help-compute-help-frame-x-location ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (max 0 (+ 32 balloon-help-help-object-x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun balloon-help-compute-help-frame-y-location ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (max 0 (+ 48 balloon-help-help-object-y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (defun balloon-help-move-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (let ((x (balloon-help-compute-help-frame-x-location))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (y (balloon-help-compute-help-frame-y-location)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (set-frame-position balloon-help-frame x y)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (add-hook 'mouse-motion-hook 'balloon-help-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (add-hook 'pre-command-hook 'balloon-help-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (add-hook 'post-command-hook 'balloon-help-post-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (add-hook 'mouse-leave-frame-hook 'balloon-help-mouse-leave-frame-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (add-hook 'deselect-frame-hook 'balloon-help-deselect-frame-hook)