Mercurial > emacs
comparison lisp/tooltip.el @ 67485:2865d1195586
(tooltip-mode): Move to start of file so that it
appears at top of customize buffer.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Sat, 10 Dec 2005 21:28:59 +0000 |
parents | 834a001192cb |
children | 525cba59adb2 |
comparison
equal
deleted
inserted
replaced
67484:9377c2eef2c4 | 67485:2865d1195586 |
---|---|
28 ;;; Code: | 28 ;;; Code: |
29 | 29 |
30 (defvar comint-prompt-regexp) | 30 (defvar comint-prompt-regexp) |
31 | 31 |
32 ;;; Customizable settings | 32 ;;; Customizable settings |
33 | |
34 (defgroup tooltip nil | |
35 "Customization group for the `tooltip' package." | |
36 :group 'help | |
37 :group 'gud | |
38 :group 'mouse | |
39 :group 'tools | |
40 :version "21.1" | |
41 :tag "Tool Tips") | |
42 | |
43 (defcustom tooltip-delay 0.7 | |
44 "Seconds to wait before displaying a tooltip the first time." | |
45 :tag "Delay" | |
46 :type 'number | |
47 :group 'tooltip) | |
48 | |
49 (defcustom tooltip-short-delay 0.1 | |
50 "Seconds to wait between subsequent tooltips on different items." | |
51 :tag "Short delay" | |
52 :type 'number | |
53 :group 'tooltip) | |
54 | |
55 (defcustom tooltip-recent-seconds 1 | |
56 "Display tooltips if changing tip items within this many seconds. | |
57 Do so after `tooltip-short-delay'." | |
58 :tag "Recent seconds" | |
59 :type 'number | |
60 :group 'tooltip) | |
61 | |
62 (defcustom tooltip-hide-delay 10 | |
63 "Hide tooltips automatically after this many seconds." | |
64 :tag "Hide delay" | |
65 :type 'number | |
66 :group 'tooltip) | |
67 | |
68 (defcustom tooltip-x-offset 5 | |
69 "X offset, in pixels, for the display of tooltips. | |
70 The offset is relative to the position of the mouse. It must | |
71 be chosen so that the tooltip window doesn't contain the mouse | |
72 when it pops up. | |
73 | |
74 If `tooltip-frame-parameters' includes the `left' parameter, | |
75 the value of `tooltip-x-offset' is ignored." | |
76 :tag "X offset" | |
77 :type 'integer | |
78 :group 'tooltip) | |
79 | |
80 (defcustom tooltip-y-offset +40 | |
81 "Y offset, in pixels, for the display of tooltips. | |
82 The offset is relative to the position of the mouse. It must | |
83 be chosen so that the tooltip window doesn't contain the mouse | |
84 when it pops up. | |
85 | |
86 If `tooltip-frame-parameters' includes the `top' parameter, | |
87 the value of `tooltip-y-offset' is ignored." | |
88 :tag "Y offset" | |
89 :type 'integer | |
90 :group 'tooltip) | |
91 | |
92 (defcustom tooltip-frame-parameters | |
93 '((name . "tooltip") | |
94 (internal-border-width . 2) | |
95 (border-width . 1)) | |
96 "Frame parameters used for tooltips. | |
97 | |
98 If `left' or `top' parameters are included, they specify the absolute | |
99 position to pop up the tooltip." | |
100 :type 'sexp | |
101 :tag "Frame Parameters" | |
102 :group 'tooltip) | |
103 | |
104 (defface tooltip | |
105 '((((class color)) | |
106 :background "lightyellow" | |
107 :foreground "black" | |
108 :inherit variable-pitch) | |
109 (t | |
110 :inherit variable-pitch)) | |
111 "Face for tooltips." | |
112 :group 'tooltip | |
113 :group 'basic-faces) | |
114 | |
115 (defcustom tooltip-use-echo-area nil | |
116 "Use the echo area instead of tooltip frames for help and GUD tooltips." | |
117 :type 'boolean | |
118 :tag "Use echo area" | |
119 :group 'tooltip) | |
120 | |
121 | |
122 ;;; Variables that are not customizable. | |
123 | |
124 (defvar tooltip-hook nil | |
125 "Functions to call to display tooltips. | |
126 Each function is called with one argument EVENT which is a copy of | |
127 the last mouse movement event that occurred.") | |
128 | |
129 (defvar tooltip-timeout-id nil | |
130 "The id of the timeout started when Emacs becomes idle.") | |
131 | |
132 (defvar tooltip-last-mouse-motion-event nil | |
133 "A copy of the last mouse motion event seen.") | |
134 | |
135 (defvar tooltip-hide-time nil | |
136 "Time when the last tooltip was hidden.") | |
137 | |
138 (defvar gud-tooltip-mode) ;; Prevent warning. | |
139 | |
140 ;;; Event accessors | |
141 | |
142 (defun tooltip-event-buffer (event) | |
143 "Return the buffer over which event EVENT occurred. | |
144 This might return nil if the event did not occur over a buffer." | |
145 (let ((window (posn-window (event-end event)))) | |
146 (and window (window-buffer window)))) | |
147 | |
148 ;;; Switching tooltips on/off | 33 ;;; Switching tooltips on/off |
149 | 34 |
150 ;; We don't set track-mouse globally because this is a big redisplay | 35 ;; We don't set track-mouse globally because this is a big redisplay |
151 ;; problem in buffers having a pre-command-hook or such installed, | 36 ;; problem in buffers having a pre-command-hook or such installed, |
152 ;; which does a set-buffer, like the summary buffer of Gnus. Calling | 37 ;; which does a set-buffer, like the summary buffer of Gnus. Calling |
172 (unless (and (boundp 'gud-tooltip-mode) gud-tooltip-mode) | 57 (unless (and (boundp 'gud-tooltip-mode) gud-tooltip-mode) |
173 (remove-hook 'pre-command-hook 'tooltip-hide)) | 58 (remove-hook 'pre-command-hook 'tooltip-hide)) |
174 (remove-hook 'tooltip-hook 'tooltip-help-tips)) | 59 (remove-hook 'tooltip-hook 'tooltip-help-tips)) |
175 (setq show-help-function | 60 (setq show-help-function |
176 (if tooltip-mode 'tooltip-show-help nil))) | 61 (if tooltip-mode 'tooltip-show-help nil))) |
62 | |
63 (defgroup tooltip nil | |
64 "Customization group for the `tooltip' package." | |
65 :group 'help | |
66 :group 'gud | |
67 :group 'mouse | |
68 :group 'tools | |
69 :version "21.1" | |
70 :tag "Tool Tips") | |
71 | |
72 (defcustom tooltip-delay 0.7 | |
73 "Seconds to wait before displaying a tooltip the first time." | |
74 :tag "Delay" | |
75 :type 'number | |
76 :group 'tooltip) | |
77 | |
78 (defcustom tooltip-short-delay 0.1 | |
79 "Seconds to wait between subsequent tooltips on different items." | |
80 :tag "Short delay" | |
81 :type 'number | |
82 :group 'tooltip) | |
83 | |
84 (defcustom tooltip-recent-seconds 1 | |
85 "Display tooltips if changing tip items within this many seconds. | |
86 Do so after `tooltip-short-delay'." | |
87 :tag "Recent seconds" | |
88 :type 'number | |
89 :group 'tooltip) | |
90 | |
91 (defcustom tooltip-hide-delay 10 | |
92 "Hide tooltips automatically after this many seconds." | |
93 :tag "Hide delay" | |
94 :type 'number | |
95 :group 'tooltip) | |
96 | |
97 (defcustom tooltip-x-offset 5 | |
98 "X offset, in pixels, for the display of tooltips. | |
99 The offset is relative to the position of the mouse. It must | |
100 be chosen so that the tooltip window doesn't contain the mouse | |
101 when it pops up. | |
102 | |
103 If `tooltip-frame-parameters' includes the `left' parameter, | |
104 the value of `tooltip-x-offset' is ignored." | |
105 :tag "X offset" | |
106 :type 'integer | |
107 :group 'tooltip) | |
108 | |
109 (defcustom tooltip-y-offset +40 | |
110 "Y offset, in pixels, for the display of tooltips. | |
111 The offset is relative to the position of the mouse. It must | |
112 be chosen so that the tooltip window doesn't contain the mouse | |
113 when it pops up. | |
114 | |
115 If `tooltip-frame-parameters' includes the `top' parameter, | |
116 the value of `tooltip-y-offset' is ignored." | |
117 :tag "Y offset" | |
118 :type 'integer | |
119 :group 'tooltip) | |
120 | |
121 (defcustom tooltip-frame-parameters | |
122 '((name . "tooltip") | |
123 (internal-border-width . 2) | |
124 (border-width . 1)) | |
125 "Frame parameters used for tooltips. | |
126 | |
127 If `left' or `top' parameters are included, they specify the absolute | |
128 position to pop up the tooltip." | |
129 :type 'sexp | |
130 :tag "Frame Parameters" | |
131 :group 'tooltip) | |
132 | |
133 (defface tooltip | |
134 '((((class color)) | |
135 :background "lightyellow" | |
136 :foreground "black" | |
137 :inherit variable-pitch) | |
138 (t | |
139 :inherit variable-pitch)) | |
140 "Face for tooltips." | |
141 :group 'tooltip | |
142 :group 'basic-faces) | |
143 | |
144 (defcustom tooltip-use-echo-area nil | |
145 "Use the echo area instead of tooltip frames for help and GUD tooltips." | |
146 :type 'boolean | |
147 :tag "Use echo area" | |
148 :group 'tooltip) | |
149 | |
150 | |
151 ;;; Variables that are not customizable. | |
152 | |
153 (defvar tooltip-hook nil | |
154 "Functions to call to display tooltips. | |
155 Each function is called with one argument EVENT which is a copy of | |
156 the last mouse movement event that occurred.") | |
157 | |
158 (defvar tooltip-timeout-id nil | |
159 "The id of the timeout started when Emacs becomes idle.") | |
160 | |
161 (defvar tooltip-last-mouse-motion-event nil | |
162 "A copy of the last mouse motion event seen.") | |
163 | |
164 (defvar tooltip-hide-time nil | |
165 "Time when the last tooltip was hidden.") | |
166 | |
167 (defvar gud-tooltip-mode) ;; Prevent warning. | |
168 | |
169 ;;; Event accessors | |
170 | |
171 (defun tooltip-event-buffer (event) | |
172 "Return the buffer over which event EVENT occurred. | |
173 This might return nil if the event did not occur over a buffer." | |
174 (let ((window (posn-window (event-end event)))) | |
175 (and window (window-buffer window)))) | |
177 | 176 |
178 | 177 |
179 ;;; Timeout for tooltip display | 178 ;;; Timeout for tooltip display |
180 | 179 |
181 (defun tooltip-delay () | 180 (defun tooltip-delay () |