annotate lisp/packages/balloon-help.el @ 147:e186c2b7192d xemacs-20-2

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