annotate lisp/packages/balloon-help.el @ 194:2947057885e5

Added tag r20-3b23 for changeset f53b5ca2e663
author cvs
date Mon, 13 Aug 2007 09:58:32 +0200
parents 489f57a838ef
children 41ff10fd062f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
1 ;;; Balloon help for XEmacs (requires 19.15 or later)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;;; Copyright (C) 1995, 1997 Kyle E. Jones
0
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 ;; Balloon help pops up a small frame to display help text
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; relating to objects that the mouse cursor passes over.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; Installation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; Byte-compile the file balloon-help.el (with M-x byte-compile-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; 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
28 ;; following line to your .emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; (require 'balloon-help)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
31 ;; (balloon-help-mode 1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
33 ;; The balloon-help frame is a transient window that is not
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
34 ;; normally decorated by window managers, so the following
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
35 ;; window manager directives may not be needed. But if they
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
36 ;; are:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
38 ;; For ol[v]wm use this in .Xdefaults:
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
39 ;; olvwm.NoDecor: balloon-help
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
40 ;; or
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
41 ;; olwm.MinimalDecor: balloon-help
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;;
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
43 ;; For fvvm version 1 use this in your .fvwmrc:
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
44 ;; NoTitle balloon-help
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
45 ;; or
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
46 ;; Style "balloon-help" NoTitle, NoHandles, BorderWidth 0
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
48 ;; For twm use this in your .twmrc:
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
49 ;; NoTitle { "balloon-help" }
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
50 ;;
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 (provide 'balloon-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
54 (require 'custom)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
55
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
56 (defgroup balloon-help nil
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
57 "Balloon-help support in XEmacs"
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
58 :group 'frames)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
59
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
60 (defvar balloon-help-version "1.06"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 "Version string for Balloon Help.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
189
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
63 (defcustom balloon-help-mode nil
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
64 "*Non-nil means Balloon help mode is enabled."
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
65 :type 'boolean
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
66 :set (lambda (symbol value)
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
67 (balloon-help-mode (or value 0)))
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
68 :initialize 'custom-initialize-default
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
69 :require 'balloon-help
489f57a838ef Import from CVS: tag r20-3b21
cvs
parents: 165
diff changeset
70 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
72 (defcustom balloon-help-timeout 1500
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
73 "*Display help after this many milliseconds of mouse inactivity."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
74 :type 'integer
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
75 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
77 (defcustom balloon-help-foreground "black"
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
78 "*The foreground color for displaying balloon help text."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
79 :type 'string
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
80 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
82 (defcustom balloon-help-background "gray80"
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
83 "*The background color for the balloon help frame."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
84 :type 'string
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
85 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
87 (defcustom balloon-help-background-pixmap ""
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
88 "*The background pixmap for the balloon help frame."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
89 :type 'string
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
90 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
92 (defcustom balloon-help-font "variable"
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
93 "*The font for displaying balloon help text."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
94 :type 'string
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
95 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
97 (defcustom balloon-help-border-color "black"
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
98 "*The color for displaying balloon help frame's border."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
99 :type 'string
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
100 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
102 (defcustom balloon-help-border-width 1
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
103 "*The width of the balloon help frame's border."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
104 :type 'integer
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
105 :group 'balloon-help)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
106
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
107 (defcustom balloon-help-use-sound nil
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "*Non-nil value means play a sound to herald the appearance
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 and disappearance of the help frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 `balloon-help-appears' will be played when the frame appears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 `balloon-help-disappears' will be played when the frame disappears.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 See the documentation for the function load-sound-file to see how
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
115 define sounds."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
116 :type 'boolean
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
117 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
119 (defcustom balloon-help-frame-name "balloon-help"
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
120 "*The frame name to use for the frame to display the balloon help."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
121 :type 'string
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
122 :group 'balloon-help)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
124 (defcustom balloon-help-aggressively-follow-mouse nil
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
125 "*Non-nil means the balloon should move with the mouse even if the mouse
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
126 is over the same object as the last mouse motion event."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
127 :type 'boolean
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
128 :group 'balloon-help)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
129
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;;; End of user variables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (defvar mouse-motion-hook mouse-motion-handler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 "Hooks to be run whenever the user moves the mouse.
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
136 Each hook is called with one argument, the mouse motion event.
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
137 This hooks variable does not exist unless the \"balloon-help\" library
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
138 has been loaded.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defun mouse-motion-hook (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 "Run the hooks attached to mouse-motion-hook."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (run-hook-with-args 'mouse-motion-hook event))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (setq mouse-motion-handler 'mouse-motion-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (defvar balloon-help-frame nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 "Balloon help is displayed in this frame.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
149 (defvar balloon-help-junk-frame nil
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
150 "Junk parent frame of balloon-help-frame.")
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
151
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defvar balloon-help-help-object nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 "Object that the mouse is over that has a help property, nil otherwise.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defvar balloon-help-help-object-x nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "Last horizontal mouse position over balloon-help-help-object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (defvar balloon-help-help-object-y nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 "Last vertical mouse position over balloon-help-help-object.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
161 (defvar balloon-help-buffer (get-buffer-create " *balloon-help*")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "Buffer used to display balloon 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 (defvar balloon-help-timeout-id nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 "Timeout id for the balloon help timeout.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defvar balloon-help-display-pending nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "Non-nil value means the help frame will be visible as soon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 as the X server gets around to displaying it. Nil means it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 will be invisible as soon as the X server decides to hide it.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun balloon-help-mode (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "Toggle Balloon Help mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 With arg, turn Balloon Help mode on iff arg is positive.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 With Balloon Help enabled, a small frame is displayed whenever
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 the mouse rests on an object that has a help property of some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 kind. The text of that help property is displayed in the frame.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 For extents, the 'balloon-help' property is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 checked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 For toolbar buttons, the help-string slot of the toolbar button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 is checked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 If the value is a string, it is used as the help message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 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
189 of a function and it will be called with one argument, the object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 under the mouse, and the return value of that function will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 used as the help message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (setq balloon-help-mode (or (and arg (> (prefix-numeric-value arg) 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (and (null arg) (null balloon-help-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (if (null balloon-help-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (balloon-help-undisplay-help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defun balloon-help-displayed ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (and (frame-live-p balloon-help-frame)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
200 (frame-visible-p balloon-help-frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
201 (eq (frame-device balloon-help-frame) (selected-device))))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
202
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
203 (defun balloon-help (&optional event)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
204 "Display Balloon Help for the object under EVENT.
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
205 If EVENT is nil, then point in the selected window is used instead.
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
206 See the documentation for balloon-help-mode to find out what this means.
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
207 This command must be bound to a mouse event."
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
208 (interactive "e")
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
209 (unless (device-on-window-system-p)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
210 (error "Cannot display balloon help on %s device" (device-type)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
211 (let ((balloon-help-mode t))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
212 (balloon-help-motion-hook event))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
213 (when balloon-help-timeout-id
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
214 (disable-timeout balloon-help-timeout-id)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
215 (setq balloon-help-timeout-id nil))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
216 (balloon-help-display-help))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun balloon-help-motion-hook (event)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ((null balloon-help-mode) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (t
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
222 (let* ((buffer (if event (event-buffer event) (current-buffer)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
223 (frame (if event (event-frame event) (selected-frame)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
224 (point (if event (event-point event) (point)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
225 (modeline-point (if event (event-modeline-position event)))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
226 (modeline-extent (and modeline-point
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
227 (map-extents
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
228 (function (lambda (e ignored) e))
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
229 (symbol-value-in-buffer
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
230 'generated-modeline-string
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
231 buffer)
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
232 modeline-point modeline-point
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
233 nil nil
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
234 'balloon-help)))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
235 (glyph-extent (and event (event-glyph-extent event)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (glyph-extent (if (and glyph-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (extent-property glyph-extent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 'balloon-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 glyph-extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (extent (and point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (extent-at point buffer 'balloon-help)))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
242 (button (and event (event-toolbar-button event)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (button (if (and button (toolbar-button-help-string button))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 button
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 nil))
114
8619ce7e4c50 Import from CVS: tag r20-1b9
cvs
parents: 102
diff changeset
246 (object (or modeline-extent glyph-extent extent button))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (id balloon-help-timeout-id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (if (null object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (if (and balloon-help-frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (not (eq frame balloon-help-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (setq balloon-help-help-object nil)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
253 (when id
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
254 (disable-timeout id)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
255 (setq balloon-help-timeout-id nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (if (balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (balloon-help-undisplay-help))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (let* ((params (frame-parameters frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (top (cdr (assq 'top params)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (left (cdr (assq 'left params)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (xtop-toolbar-height
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
262 (if (and (specifier-instance top-toolbar-visible-p frame)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
263 (specifier-instance top-toolbar frame))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
264 (specifier-instance top-toolbar-height frame)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (xleft-toolbar-width
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
267 (if (and (specifier-instance left-toolbar-visible-p frame)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
268 (specifier-instance left-toolbar frame))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
269 (specifier-instance left-toolbar-width frame)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 0))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
271 (menubar-height
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
272 (if (and buffer
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
273 (specifier-instance menubar-visible-p)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
274 (save-excursion (set-buffer buffer) current-menubar))
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
275 22 0)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (setq balloon-help-help-object-x
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
277 (if event
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
278 (+ left xleft-toolbar-width
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
279 (event-x-pixel event))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
280 (/ (* (device-pixel-width) 2) 5))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 balloon-help-help-object-y
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
282 (if event
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
283 (+ top xtop-toolbar-height menubar-height
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
284 (event-y-pixel event))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
285 (/ (* (device-pixel-height) 2) 5))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (cond ((eq frame balloon-help-frame) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ((eq object balloon-help-help-object)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
288 (if (and (balloon-help-displayed)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
289 balloon-help-aggressively-follow-mouse)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (balloon-help-move-help-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ((balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (setq balloon-help-help-object object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (balloon-help-display-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (setq balloon-help-help-object object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (disable-timeout id))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq balloon-help-timeout-id
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (add-timeout (/ balloon-help-timeout 1000.0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (function balloon-help-display-help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 nil)))))))))
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-display-help (&rest ignored)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq balloon-help-timeout-id nil)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
305 (if (and balloon-help-help-object (device-on-window-system-p))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (let* ((object balloon-help-help-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (help (or (and (extent-live-p object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (extent-property object 'balloon-help))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (and (toolbar-button-p object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (toolbar-button-help-string object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (and (stringp object) object))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; if help is non-null and is not a string, run it as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; function to produuce the help string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (if (or (null help) (not (symbolp help)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (condition-case data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (setq help (funcall help object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (setq help (format "help function signaled: %S" data)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (if (stringp help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (save-excursion
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
322 (if (or (not (frame-live-p balloon-help-frame))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
323 (not (eq (selected-device)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
324 (frame-device balloon-help-frame))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq balloon-help-frame (balloon-help-make-help-frame)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (set-buffer balloon-help-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (insert help)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (insert ?\n))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
331 ;;; ;; help strings longer than 2 lines have the last
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
332 ;;; ;; line stolen by the minibuffer, so make sure the
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
333 ;;; ;; last line is blank. Make the top line blank for
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
334 ;;; ;; some symmetry.
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
335 ;;; (if (< 2 (count-lines (point-min) (point-max)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
336 ;;; (progn
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
337 ;;; (insert ?\n)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
338 ;;; ;; add a second blank line at the end to
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
339 ;;; ;; prevent the modeline bar from clipping the
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
340 ;;; ;; descenders of the last line of text.
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
341 ;;; (insert ?\n)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
342 ;;; (goto-char (point-min))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
343 ;;; (insert ?\n)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
344 ;; indent everything by a space for readability
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (indent-rigidly (point-min) (point-max) 1)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
346 (balloon-help-set-frame-properties)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
347 (balloon-help-resize-help-frame)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (balloon-help-move-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (balloon-help-expose-help-frame))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (defun balloon-help-undisplay-help ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (balloon-help-hide-help-frame))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defun balloon-help-hide-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (if (balloon-help-displayed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (make-frame-invisible balloon-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (if (and balloon-help-use-sound balloon-help-display-pending)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (play-sound 'balloon-help-disappears))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (setq balloon-help-display-pending nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun balloon-help-expose-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (if (not (balloon-help-displayed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (make-frame-visible balloon-help-frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (if (and balloon-help-use-sound (null balloon-help-display-pending))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (play-sound 'balloon-help-appears))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (setq balloon-help-display-pending t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
370 (defun balloon-help-set-frame-properties ()
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
371 (let ((frame balloon-help-frame))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
372 ;; don't set the font unconditionally because it makes the
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
373 ;; frame size flap visibly while XEmacs figures out the new
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
374 ;; frame size.
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
375 (if (not (equal (face-font 'default frame) balloon-help-font))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
376 (set-face-font 'default balloon-help-font frame))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
377 (set-face-foreground 'default balloon-help-foreground frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
378 (set-face-background 'default balloon-help-background frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
379 (set-face-background 'modeline balloon-help-background frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
380 (set-face-background-pixmap 'default balloon-help-background-pixmap frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
381 (set-frame-property frame 'border-color balloon-help-border-color)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
382 (set-frame-property frame 'border-width balloon-help-border-width)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
383
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
384 ;;;(defun balloon-help-resize-help-frame ()
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
385 ;;; (save-excursion
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
386 ;;; (set-buffer balloon-help-buffer)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
387 ;;; (let ((longest 0)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
388 ;;; (lines 0)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
389 ;;; (done nil)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
390 ;;; (window-min-height 1)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
391 ;;; (window-min-width 1))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
392 ;;; (goto-char (point-min))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
393 ;;; (while (not done)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
394 ;;; (end-of-line)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
395 ;;; (setq longest (max longest (current-column))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
396 ;;; done (not (= 0 (forward-line))))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
397 ;;; (and (not done) (setq lines (1+ lines))))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
398 ;;; (set-frame-size balloon-help-frame (+ 1 longest) lines))))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
399
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (defun balloon-help-resize-help-frame ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (set-buffer balloon-help-buffer)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
403 (let* ((longest 0)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
404 (lines 0)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
405 (done nil)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
406 (inst (vector 'string ':data nil))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
407 (window (frame-selected-window balloon-help-frame))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
408 (font-width (font-width (face-font 'default) balloon-help-frame))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
409 start width
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
410 (window-min-height 1)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
411 (window-min-width 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (while (not done)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
414 (setq start (point))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (end-of-line)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
416 (aset inst 2 (buffer-substring start (point)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
417 (setq longest (max longest (glyph-width (make-glyph inst) window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 done (not (= 0 (forward-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (and (not done) (setq lines (1+ lines))))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
420 (setq width (/ longest font-width)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
421 width (if (> longest (* width font-width)) (1+ width) width))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
422 (set-frame-size balloon-help-frame (+ 0 width) lines))))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
423
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
424 (defun balloon-help-compute-help-frame-y-location ()
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
425 (let* ((device-bottom (device-pixel-height
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
426 (frame-device balloon-help-frame)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
427 (y-pos (max 0 (+ 48 balloon-help-help-object-y)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
428 (height (frame-pixel-height balloon-help-frame))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
429 (bottom (+ y-pos height)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
430 (if (>= bottom device-bottom)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
431 (setq y-pos (max 0 (- y-pos (- bottom device-bottom)))))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
432 y-pos ))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
433
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
434 (defun balloon-help-compute-help-frame-x-location ()
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
435 (let* ((device-right (device-pixel-width (frame-device balloon-help-frame)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
436 (x-pos (max 0 (+ 32 balloon-help-help-object-x)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
437 (width (frame-pixel-width balloon-help-frame))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
438 (right (+ x-pos width)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
439 (if (>= right device-right)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
440 (setq x-pos (max 0 (- x-pos (- right device-right)))))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
441 x-pos ))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
442
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
443 (defun balloon-help-move-help-frame ()
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
444 (let ((x (balloon-help-compute-help-frame-x-location))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
445 (y (balloon-help-compute-help-frame-y-location)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
446 (set-frame-position balloon-help-frame x y)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
448 (defun balloon-help-make-junk-frame ()
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
449 (let ((window-min-height 1)
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
450 (window-min-width 1))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
451 (when (framep balloon-help-junk-frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
452 (delete-frame balloon-help-junk-frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
453 (setq balloon-help-junk-frame nil))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
454 (prog1
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
455 (setq balloon-help-junk-frame
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
456 (make-frame '(minibuffer t
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
457 initially-unmapped t
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
458 width 1
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
459 height 1)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
460 (set-window-buffer (frame-selected-window balloon-help-junk-frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
461 balloon-help-buffer))))
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
462
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (defun balloon-help-make-help-frame ()
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
464 (when (framep balloon-help-frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
465 (delete-frame balloon-help-frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
466 (setq balloon-help-frame nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (set-buffer balloon-help-buffer)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
469 (setq truncate-lines t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (set-buffer-menubar nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (let* ((x (balloon-help-compute-help-frame-x-location))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (y (balloon-help-compute-help-frame-y-location))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (window-min-height 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (window-min-width 1)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
475 (junk-frame (balloon-help-make-junk-frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (frame (make-frame (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 '(initially-unmapped . t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; try to evade frame decorations
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
479 (cons 'name balloon-help-frame-name)
102
a145efe76779 Import from CVS: tag r20-1b3
cvs
parents: 98
diff changeset
480 (cons 'border-width balloon-help-border-width)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (cons 'border-color balloon-help-border-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (cons 'top y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (cons 'left x)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
484 (cons 'popup junk-frame)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
485 (cons 'minibuffer
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
486 (minibuffer-window junk-frame))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 '(width . 3)
165
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 138
diff changeset
488 '(height . 1)
5a88923fcbfe Import from CVS: tag r20-3b9
cvs
parents: 138
diff changeset
489 '(balloon-help . t)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (set-face-font 'default balloon-help-font frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (set-face-foreground 'default balloon-help-foreground frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (set-face-background 'default balloon-help-background frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (set-face-background-pixmap 'default balloon-help-background-pixmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (set-window-buffer (frame-selected-window frame) balloon-help-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (set-specifier has-modeline-p (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (set-specifier top-toolbar-height (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (set-specifier left-toolbar-width (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (set-specifier right-toolbar-width (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (set-specifier bottom-toolbar-height (cons frame 0))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
501 (set-specifier top-toolbar-visible-p (cons frame nil))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
502 (set-specifier left-toolbar-visible-p (cons frame nil))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
503 (set-specifier right-toolbar-visible-p (cons frame nil))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
504 (set-specifier bottom-toolbar-visible-p (cons frame nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (set-specifier top-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (set-specifier left-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (set-specifier right-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (set-specifier bottom-toolbar (cons frame nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (set-specifier scrollbar-width (cons frame 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (set-specifier scrollbar-height (cons frame 0))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
511 (set-specifier text-cursor-visible-p (cons frame nil))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
512 (set-specifier has-modeline-p (cons frame nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (set-specifier modeline-shadow-thickness (cons frame 0))
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
514 (set-specifier (glyph-image truncation-glyph) [nothing] frame '(x))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (set-face-background 'modeline balloon-help-background frame)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 frame )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
518 (defun balloon-help-pre-command-hook ()
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
519 (unless (eq this-command 'balloon-help)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
520 (balloon-help-go-away)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
521
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
522 (defun balloon-help-go-away (&rest ignored)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
523 (setq balloon-help-help-object nil)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
524 (if (balloon-help-displayed)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
525 (balloon-help-undisplay-help)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
527 (defun balloon-help-mouse-leave-frame-hook (&rest ignored)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
528 (let* ((mouse (mouse-position))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
529 (window (car mouse)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
530 (if (or (null window) (not (eq (window-frame window) balloon-help-frame)))
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
531 (balloon-help-go-away))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
533 ;; loses with ClickToFocus under fvwm
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
534 ;;(fset 'balloon-help-deselect-frame-hook 'balloon-help-go-away)
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
535 ;;(add-hook 'deselect-frame-hook 'balloon-help-deselect-frame-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (add-hook 'mouse-motion-hook 'balloon-help-motion-hook)
138
6608ceec7cf8 Import from CVS: tag r20-2b3
cvs
parents: 114
diff changeset
538
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (add-hook 'pre-command-hook 'balloon-help-pre-command-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (add-hook 'mouse-leave-frame-hook 'balloon-help-mouse-leave-frame-hook)