Mercurial > emacs
comparison lisp/tooltip.el @ 48601:ac47e19224b0
(tooltip-gud-process-output): Handle annotations that
are output with gdba in gdb-ui.el.
(tooltip-strip-annotations): New function.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Sat, 30 Nov 2002 20:58:38 +0000 |
parents | 02ae07f0375b |
children | 572f41d9a2ea |
comparison
equal
deleted
inserted
replaced
48600:88be03de9df4 | 48601:ac47e19224b0 |
---|---|
28 | 28 |
29 (eval-when-compile | 29 (eval-when-compile |
30 (require 'cl) | 30 (require 'cl) |
31 (require 'comint) | 31 (require 'comint) |
32 (require 'gud)) | 32 (require 'gud)) |
33 | |
34 (provide 'tooltip) | |
35 | 33 |
36 | 34 |
37 ;;; Customizable settings | 35 ;;; Customizable settings |
38 | 36 |
39 (defgroup tooltip nil | 37 (defgroup tooltip nil |
51 "Seconds to wait before displaying a tooltip the first time." | 49 "Seconds to wait before displaying a tooltip the first time." |
52 :tag "Delay" | 50 :tag "Delay" |
53 :type 'number | 51 :type 'number |
54 :group 'tooltip) | 52 :group 'tooltip) |
55 | 53 |
56 | |
57 (defcustom tooltip-short-delay 0.1 | 54 (defcustom tooltip-short-delay 0.1 |
58 "Seconds to wait between subsequent tooltips on different items." | 55 "Seconds to wait between subsequent tooltips on different items." |
59 :tag "Short delay" | 56 :tag "Short delay" |
60 :type 'number | 57 :type 'number |
61 :group 'tooltip) | 58 :group 'tooltip) |
62 | |
63 | 59 |
64 (defcustom tooltip-recent-seconds 1 | 60 (defcustom tooltip-recent-seconds 1 |
65 "Display tooltips if changing tip items within this many seconds. | 61 "Display tooltips if changing tip items within this many seconds. |
66 Do so after `tooltip-short-delay'." | 62 Do so after `tooltip-short-delay'." |
67 :tag "Recent seconds" | 63 :tag "Recent seconds" |
68 :type 'number | 64 :type 'number |
69 :group 'tooltip) | 65 :group 'tooltip) |
70 | 66 |
71 | |
72 (defcustom tooltip-hide-delay 10 | 67 (defcustom tooltip-hide-delay 10 |
73 "Hide tooltips automatically after this many seconds." | 68 "Hide tooltips automatically after this many seconds." |
74 :tag "Hide delay" | 69 :tag "Hide delay" |
75 :type 'number | 70 :type 'number |
76 :group 'tooltip) | 71 :group 'tooltip) |
77 | |
78 | 72 |
79 (defcustom tooltip-x-offset nil | 73 (defcustom tooltip-x-offset nil |
80 "X offset, in pixels, for the display of tooltips. | 74 "X offset, in pixels, for the display of tooltips. |
81 The offset is relative to the position of the mouse. It must | 75 The offset is relative to the position of the mouse. It must |
82 be chosen so that the tooltip window doesn't contain the mouse | 76 be chosen so that the tooltip window doesn't contain the mouse |
88 :tag "X offset" | 82 :tag "X offset" |
89 :type '(choice (const :tag "Default" nil) | 83 :type '(choice (const :tag "Default" nil) |
90 (integer :tag "Offset" :value 1)) | 84 (integer :tag "Offset" :value 1)) |
91 :group 'tooltip) | 85 :group 'tooltip) |
92 | 86 |
93 | |
94 (defcustom tooltip-y-offset nil | 87 (defcustom tooltip-y-offset nil |
95 "Y offset, in pixels, for the display of tooltips. | 88 "Y offset, in pixels, for the display of tooltips. |
96 The offset is relative to the position of the mouse. It must | 89 The offset is relative to the position of the mouse. It must |
97 be chosen so that the tooltip window doesn't contain the mouse | 90 be chosen so that the tooltip window doesn't contain the mouse |
98 when it pops up. If the value is nil, the default offset is -10 | 91 when it pops up. If the value is nil, the default offset is -10 |
103 :tag "Y offset" | 96 :tag "Y offset" |
104 :type '(choice (const :tag "Default" nil) | 97 :type '(choice (const :tag "Default" nil) |
105 (integer :tag "Offset" :value 1)) | 98 (integer :tag "Offset" :value 1)) |
106 :group 'tooltip) | 99 :group 'tooltip) |
107 | 100 |
108 | |
109 (defcustom tooltip-frame-parameters | 101 (defcustom tooltip-frame-parameters |
110 '((name . "tooltip") | 102 '((name . "tooltip") |
111 (internal-border-width . 5) | 103 (internal-border-width . 5) |
112 (border-width . 1)) | 104 (border-width . 1)) |
113 "Frame parameters used for tooltips. | 105 "Frame parameters used for tooltips. |
116 position to pop up the tooltip." | 108 position to pop up the tooltip." |
117 :type 'sexp | 109 :type 'sexp |
118 :tag "Frame Parameters" | 110 :tag "Frame Parameters" |
119 :group 'tooltip) | 111 :group 'tooltip) |
120 | 112 |
121 | |
122 (defface tooltip | 113 (defface tooltip |
123 '((((class color)) | 114 '((((class color)) |
124 (:background "lightyellow" :foreground "black")) | 115 (:background "lightyellow" :foreground "black")) |
125 (t ())) | 116 (t ())) |
126 "Face for tooltips." | 117 "Face for tooltips." |
127 :group 'tooltip) | 118 :group 'tooltip) |
128 | |
129 | 119 |
130 (defcustom tooltip-gud-tips-p nil | 120 (defcustom tooltip-gud-tips-p nil |
131 "*Non-nil means show tooltips in GUD sessions. | 121 "*Non-nil means show tooltips in GUD sessions. |
132 Setting this variable directly with `setq' has no effect; | 122 Setting this variable directly with `setq' has no effect; |
133 you should either set it with the Customization facility | 123 you should either set it with the Customization facility |
136 :tag "GUD" | 126 :tag "GUD" |
137 :set #'(lambda (symbol on) | 127 :set #'(lambda (symbol on) |
138 (setq tooltip-gud-tips-p on)) | 128 (setq tooltip-gud-tips-p on)) |
139 :group 'tooltip) | 129 :group 'tooltip) |
140 | 130 |
141 | |
142 (defcustom tooltip-gud-modes '(gud-mode c-mode c++-mode) | 131 (defcustom tooltip-gud-modes '(gud-mode c-mode c++-mode) |
143 "List of modes for which to enable GUD tips." | 132 "List of modes for which to enable GUD tips." |
144 :type 'sexp | 133 :type 'sexp |
145 :tag "GUD modes" | 134 :tag "GUD modes" |
146 :group 'tooltip) | 135 :group 'tooltip) |
147 | 136 |
148 | |
149 (defcustom tooltip-gud-display | 137 (defcustom tooltip-gud-display |
150 '((eq (tooltip-event-buffer tooltip-gud-event) | 138 '((eq (tooltip-event-buffer tooltip-gud-event) |
151 (marker-buffer overlay-arrow-position))) | 139 (marker-buffer overlay-arrow-position))) |
152 "List of forms determining where GUD tooltips are displayed. | 140 "List of forms determining where GUD tooltips are displayed. |
153 | 141 |
154 Forms in the list are combined with AND. The default is to display | 142 Forms in the list are combined with AND. The default is to display |
155 only tooltips in the buffer containing the overlay arrow." | 143 only tooltips in the buffer containing the overlay arrow." |
156 :type 'sexp | 144 :type 'sexp |
157 :tag "GUD buffers predicate" | 145 :tag "GUD buffers predicate" |
158 :group 'tooltip) | 146 :group 'tooltip) |
159 | |
160 | 147 |
161 (defcustom tooltip-use-echo-area nil | 148 (defcustom tooltip-use-echo-area nil |
162 "Use the echo area instead of tooltip frames. | 149 "Use the echo area instead of tooltip frames. |
163 This is only relevant GUD display, since otherwise it is equivalent to | 150 This is only relevant GUD display, since otherwise it is equivalent to |
164 turning off Tooltip mode." | 151 turning off Tooltip mode." |
172 (defvar tooltip-hook nil | 159 (defvar tooltip-hook nil |
173 "Functions to call to display tooltips. | 160 "Functions to call to display tooltips. |
174 Each function is called with one argument EVENT which is a copy of | 161 Each function is called with one argument EVENT which is a copy of |
175 the last mouse movement event that occurred.") | 162 the last mouse movement event that occurred.") |
176 | 163 |
177 | |
178 (defvar tooltip-timeout-id nil | 164 (defvar tooltip-timeout-id nil |
179 "The id of the timeout started when Emacs becomes idle.") | 165 "The id of the timeout started when Emacs becomes idle.") |
180 | 166 |
181 | |
182 (defvar tooltip-last-mouse-motion-event nil | 167 (defvar tooltip-last-mouse-motion-event nil |
183 "A copy of the last mouse motion event seen.") | 168 "A copy of the last mouse motion event seen.") |
184 | 169 |
185 | |
186 (defvar tooltip-hide-time nil | 170 (defvar tooltip-hide-time nil |
187 "Time when the last tooltip was hidden.") | 171 "Time when the last tooltip was hidden.") |
188 | |
189 | 172 |
190 | 173 |
191 ;;; Event accessors | 174 ;;; Event accessors |
192 | 175 |
193 (defun tooltip-event-buffer (event) | 176 (defun tooltip-event-buffer (event) |
194 "Return the buffer over which event EVENT occurred. | 177 "Return the buffer over which event EVENT occurred. |
195 This might return nil if the event did not occur over a buffer." | 178 This might return nil if the event did not occur over a buffer." |
196 (let ((window (posn-window (event-end event)))) | 179 (let ((window (posn-window (event-end event)))) |
197 (and window (window-buffer window)))) | 180 (and window (window-buffer window)))) |
198 | |
199 | 181 |
200 | 182 |
201 ;;; Switching tooltips on/off | 183 ;;; Switching tooltips on/off |
202 | 184 |
203 ;; We don't set track-mouse globally because this is a big redisplay | 185 ;; We don't set track-mouse globally because this is a big redisplay |
226 (setq show-help-function (if on 'tooltip-show-help-function nil)) | 208 (setq show-help-function (if on 'tooltip-show-help-function nil)) |
227 ;; `ignore' is the default binding for mouse movements. | 209 ;; `ignore' is the default binding for mouse movements. |
228 (define-key global-map [mouse-movement] | 210 (define-key global-map [mouse-movement] |
229 (if on 'tooltip-mouse-motion 'ignore)))) | 211 (if on 'tooltip-mouse-motion 'ignore)))) |
230 | 212 |
231 | |
232 | 213 |
233 ;;; Timeout for tooltip display | 214 ;;; Timeout for tooltip display |
234 | 215 |
235 (defun tooltip-delay () | 216 (defun tooltip-delay () |
236 "Return the delay in seconds for the next tooltip." | 217 "Return the delay in seconds for the next tooltip." |
239 (when (and tooltip-hide-time | 220 (when (and tooltip-hide-time |
240 (< (- now tooltip-hide-time) tooltip-recent-seconds)) | 221 (< (- now tooltip-hide-time) tooltip-recent-seconds)) |
241 (setq delay tooltip-short-delay)) | 222 (setq delay tooltip-short-delay)) |
242 delay)) | 223 delay)) |
243 | 224 |
244 | |
245 (defun tooltip-cancel-delayed-tip () | 225 (defun tooltip-cancel-delayed-tip () |
246 "Disable the tooltip timeout." | 226 "Disable the tooltip timeout." |
247 (when tooltip-timeout-id | 227 (when tooltip-timeout-id |
248 (disable-timeout tooltip-timeout-id) | 228 (disable-timeout tooltip-timeout-id) |
249 (setq tooltip-timeout-id nil))) | 229 (setq tooltip-timeout-id nil))) |
250 | 230 |
251 | |
252 (defun tooltip-start-delayed-tip () | 231 (defun tooltip-start-delayed-tip () |
253 "Add a one-shot timeout to call function tooltip-timeout." | 232 "Add a one-shot timeout to call function tooltip-timeout." |
254 (setq tooltip-timeout-id | 233 (setq tooltip-timeout-id |
255 (add-timeout (tooltip-delay) 'tooltip-timeout nil))) | 234 (add-timeout (tooltip-delay) 'tooltip-timeout nil))) |
256 | 235 |
257 | |
258 (defun tooltip-timeout (object) | 236 (defun tooltip-timeout (object) |
259 "Function called when timer with id tooltip-timeout-id fires." | 237 "Function called when timer with id tooltip-timeout-id fires." |
260 (run-hook-with-args-until-success 'tooltip-hook | 238 (run-hook-with-args-until-success 'tooltip-hook |
261 tooltip-last-mouse-motion-event)) | 239 tooltip-last-mouse-motion-event)) |
262 | 240 |
263 | |
264 | 241 |
265 ;;; Reacting on mouse movements | 242 ;;; Reacting on mouse movements |
266 | 243 |
267 (defun tooltip-change-major-mode () | 244 (defun tooltip-change-major-mode () |
268 "Function added to `change-major-mode-hook' when tooltip mode is on." | 245 "Function added to `change-major-mode-hook' when tooltip mode is on." |
269 (add-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled)) | 246 (add-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled)) |
270 | |
271 | 247 |
272 (defun tooltip-activate-mouse-motions-if-enabled () | 248 (defun tooltip-activate-mouse-motions-if-enabled () |
273 "Reconsider for all buffers whether mouse motion events are desired." | 249 "Reconsider for all buffers whether mouse motion events are desired." |
274 (remove-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled) | 250 (remove-hook 'post-command-hook 'tooltip-activate-mouse-motions-if-enabled) |
275 (let ((buffers (buffer-list))) | 251 (let ((buffers (buffer-list))) |
305 (tooltip-hide) | 281 (tooltip-hide) |
306 (when (car (mouse-pixel-position)) | 282 (when (car (mouse-pixel-position)) |
307 (setq tooltip-last-mouse-motion-event (copy-sequence event)) | 283 (setq tooltip-last-mouse-motion-event (copy-sequence event)) |
308 (tooltip-start-delayed-tip))) | 284 (tooltip-start-delayed-tip))) |
309 | 285 |
310 | |
311 | 286 |
312 ;;; Displaying tips | 287 ;;; Displaying tips |
313 | 288 |
314 (defun tooltip-set-param (alist key value) | 289 (defun tooltip-set-param (alist key value) |
315 "Change the value of KEY in alist ALIST to VALUE. | 290 "Change the value of KEY in alist ALIST to VALUE. |
318 (let ((param (assq key alist))) | 293 (let ((param (assq key alist))) |
319 (if (consp param) | 294 (if (consp param) |
320 (setcdr param value) | 295 (setcdr param value) |
321 (push (cons key value) alist)) | 296 (push (cons key value) alist)) |
322 alist)) | 297 alist)) |
323 | |
324 | 298 |
325 (defun tooltip-show (text) | 299 (defun tooltip-show (text) |
326 "Show a tooltip window displaying TEXT. | 300 "Show a tooltip window displaying TEXT. |
327 | 301 |
328 Text larger than `x-max-tooltip-size' (which see) is clipped. | 302 Text larger than `x-max-tooltip-size' (which see) is clipped. |
352 (error | 326 (error |
353 (message "Error while displaying tooltip: %s" error) | 327 (message "Error while displaying tooltip: %s" error) |
354 (sit-for 1) | 328 (sit-for 1) |
355 (message "%s" text))))) | 329 (message "%s" text))))) |
356 | 330 |
357 | |
358 (defun tooltip-hide (&optional ignored-arg) | 331 (defun tooltip-hide (&optional ignored-arg) |
359 "Hide a tooltip, if one is displayed. | 332 "Hide a tooltip, if one is displayed. |
360 Value is non-nil if tooltip was open." | 333 Value is non-nil if tooltip was open." |
361 (tooltip-cancel-delayed-tip) | 334 (tooltip-cancel-delayed-tip) |
362 (when (x-hide-tip) | 335 (when (x-hide-tip) |
363 (setq tooltip-hide-time (float-time)))) | 336 (setq tooltip-hide-time (float-time)))) |
364 | |
365 | 337 |
366 | 338 |
367 ;;; Debugger-related functions | 339 ;;; Debugger-related functions |
368 | 340 |
369 (defun tooltip-identifier-from-point (point) | 341 (defun tooltip-identifier-from-point (point) |
376 (unless (looking-at "[0-9]") | 348 (unless (looking-at "[0-9]") |
377 (skip-syntax-forward "w_") | 349 (skip-syntax-forward "w_") |
378 (when (> (point) start) | 350 (when (> (point) start) |
379 (buffer-substring start (point))))))) | 351 (buffer-substring start (point))))))) |
380 | 352 |
381 | |
382 (defmacro tooltip-region-active-p () | 353 (defmacro tooltip-region-active-p () |
383 "Value is non-nil if the region is currently active." | 354 "Value is non-nil if the region is currently active." |
384 (if (string-match "^GNU" (emacs-version)) | 355 (if (string-match "^GNU" (emacs-version)) |
385 `(and transient-mark-mode mark-active) | 356 `(and transient-mark-mode mark-active) |
386 `(region-active-p))) | 357 `(region-active-p))) |
387 | |
388 | 358 |
389 (defun tooltip-expr-to-print (event) | 359 (defun tooltip-expr-to-print (event) |
390 "Return an expression that should be printed for EVENT. | 360 "Return an expression that should be printed for EVENT. |
391 If a region is active and the mouse is inside the region, print | 361 If a region is active and the mouse is inside the region, print |
392 the region. Otherwise, figure out the identifier around the point | 362 the region. Otherwise, figure out the identifier around the point |
396 (let ((point (posn-point (event-end event)))) | 366 (let ((point (posn-point (event-end event)))) |
397 (if (tooltip-region-active-p) | 367 (if (tooltip-region-active-p) |
398 (when (and (<= (region-beginning) point) (<= point (region-end))) | 368 (when (and (<= (region-beginning) point) (<= point (region-end))) |
399 (buffer-substring (region-beginning) (region-end))) | 369 (buffer-substring (region-beginning) (region-end))) |
400 (tooltip-identifier-from-point point))))) | 370 (tooltip-identifier-from-point point))))) |
401 | |
402 | 371 |
403 (defun tooltip-process-prompt-regexp (process) | 372 (defun tooltip-process-prompt-regexp (process) |
404 "Return regexp matching the prompt of PROCESS at the end of a string. | 373 "Return regexp matching the prompt of PROCESS at the end of a string. |
405 The prompt is taken from the value of COMINT-PROMPT-REGEXP in the buffer | 374 The prompt is taken from the value of COMINT-PROMPT-REGEXP in the buffer |
406 of PROCESS." | 375 of PROCESS." |
412 (if (= (aref prompt-regexp 0) ?^) | 381 (if (= (aref prompt-regexp 0) ?^) |
413 (setq prompt-regexp (substring prompt-regexp 1)) | 382 (setq prompt-regexp (substring prompt-regexp 1)) |
414 (setq prompt-regexp "\\*")) | 383 (setq prompt-regexp "\\*")) |
415 (concat "\n*" prompt-regexp "$"))) | 384 (concat "\n*" prompt-regexp "$"))) |
416 | 385 |
417 | |
418 (defun tooltip-strip-prompt (process output) | 386 (defun tooltip-strip-prompt (process output) |
419 "Return OUTPUT with any prompt of PROCESS stripped from its end." | 387 "Return OUTPUT with any prompt of PROCESS stripped from its end." |
420 (let ((prompt-regexp (tooltip-process-prompt-regexp process))) | 388 (let ((prompt-regexp (tooltip-process-prompt-regexp process))) |
421 (save-match-data | 389 (save-match-data |
422 (when (string-match prompt-regexp output) | 390 (when (string-match prompt-regexp output) |
423 (setq output (substring output 0 (match-beginning 0))))) | 391 (setq output (substring output 0 (match-beginning 0))))) |
424 output)) | 392 output)) |
425 | 393 |
426 | |
427 | 394 |
428 ;;; Tips for `gud' | 395 ;;; Tips for `gud' |
429 | 396 |
430 (defvar tooltip-gud-original-filter nil | 397 (defvar tooltip-gud-original-filter nil |
431 "Process filter to restore after GUD output has been received.") | 398 "Process filter to restore after GUD output has been received.") |
432 | |
433 | 399 |
434 (defvar tooltip-gud-dereference nil | 400 (defvar tooltip-gud-dereference nil |
435 "Non-nil means print expressions with a `*' in front of them. | 401 "Non-nil means print expressions with a `*' in front of them. |
436 For C this would dereference a pointer expression.") | 402 For C this would dereference a pointer expression.") |
437 | 403 |
438 | |
439 (defvar tooltip-gud-event nil | 404 (defvar tooltip-gud-event nil |
440 "The mouse movement event that led to a tooltip display. | 405 "The mouse movement event that led to a tooltip display. |
441 This event can be examined by forms in TOOLTIP-GUD-DISPLAY.") | 406 This event can be examined by forms in TOOLTIP-GUD-DISPLAY.") |
442 | |
443 | 407 |
444 (defun tooltip-gud-toggle-dereference () | 408 (defun tooltip-gud-toggle-dereference () |
445 "Toggle whether tooltips should show `* expr' or `expr'." | 409 "Toggle whether tooltips should show `* expr' or `expr'." |
446 (interactive) | 410 (interactive) |
447 (setq tooltip-gud-dereference (not tooltip-gud-dereference)) | 411 (setq tooltip-gud-dereference (not tooltip-gud-dereference)) |
448 (when (interactive-p) | 412 (when (interactive-p) |
449 (message "Dereferencing is now %s." | 413 (message "Dereferencing is now %s." |
450 (if tooltip-gud-dereference "on" "off")))) | 414 (if tooltip-gud-dereference "on" "off")))) |
451 | 415 |
452 | 416 ; This will only display data that comes in one chunk. |
417 ; The prompt is lost in first chunk so needn't be stripped. | |
418 ; Larger arrays (say 400 elements) are displayed in | |
419 ; the tootip incompletely (only the last chunk is displayed | |
420 ; with the rest going to the gud buffer). | |
421 ; Switching the process-filter creates timing problems and | |
422 ; it may be difficult to do better. | |
453 (defun tooltip-gud-process-output (process output) | 423 (defun tooltip-gud-process-output (process output) |
454 "Process debugger output and show it in a tooltip window." | 424 "Process debugger output and show it in a tooltip window." |
455 (set-process-filter process tooltip-gud-original-filter) | 425 (set-process-filter process tooltip-gud-original-filter) |
456 (tooltip-show (tooltip-strip-prompt process output))) | 426 (case gud-minor-mode |
457 | 427 (gdba (tooltip-show (tooltip-strip-annotations output))) |
428 (t (tooltip-show (tooltip-strip-prompt process output))))) | |
429 | |
430 ; this is derived from gdb-output-burst in gdb-ui.el. It | |
431 ; also only processes data that comes in one chunk properly. | |
432 (defun tooltip-strip-annotations (string) | |
433 "Strip annotations from the output of the gdb process." | |
434 (save-match-data | |
435 (let ((output "")) | |
436 | |
437 ;; Process all the complete markers in this chunk. | |
438 (while (string-match "\n\032\032\\(.*\\)\n" string) | |
439 | |
440 ;; Stuff prior to the match is just ordinary output. | |
441 ;; It is either concatenated to OUTPUT or directed | |
442 ;; elsewhere. | |
443 (setq output | |
444 (gdb-concat-output | |
445 output | |
446 (substring string 0 (match-beginning 0)))) | |
447 | |
448 ;; Take that stuff off the string. | |
449 (setq string (substring string (match-end 0)))) | |
450 output))) | |
458 | 451 |
459 (defun tooltip-gud-print-command (expr) | 452 (defun tooltip-gud-print-command (expr) |
460 "Return a suitable command to print the expression EXPR. | 453 "Return a suitable command to print the expression EXPR. |
461 If TOOLTIP-GUD-DEREFERENCE is t, also prepend a `*' to EXPR." | 454 If TOOLTIP-GUD-DEREFERENCE is t, also prepend a `*' to EXPR." |
462 (when tooltip-gud-dereference | 455 (when tooltip-gud-dereference |
465 ((gdb gdba) (concat "server print " expr)) | 458 ((gdb gdba) (concat "server print " expr)) |
466 (dbx (concat "print " expr)) | 459 (dbx (concat "print " expr)) |
467 (xdb (concat "p " expr)) | 460 (xdb (concat "p " expr)) |
468 (sdb (concat expr "/")) | 461 (sdb (concat expr "/")) |
469 (perldb expr))) | 462 (perldb expr))) |
470 | |
471 | 463 |
472 (defun tooltip-gud-tips (event) | 464 (defun tooltip-gud-tips (event) |
473 "Show tip for identifier or selection under the mouse. | 465 "Show tip for identifier or selection under the mouse. |
474 The mouse must either point at an identifier or inside a selected | 466 The mouse must either point at an identifier or inside a selected |
475 region for the tip window to be shown. If tooltip-gud-dereference is t, | 467 region for the tip window to be shown. If tooltip-gud-dereference is t, |
498 ;;; Tooltip help. | 490 ;;; Tooltip help. |
499 | 491 |
500 (defvar tooltip-help-message nil | 492 (defvar tooltip-help-message nil |
501 "The last help message received via `tooltip-show-help-function'.") | 493 "The last help message received via `tooltip-show-help-function'.") |
502 | 494 |
503 | |
504 (defun tooltip-show-help-function (msg) | 495 (defun tooltip-show-help-function (msg) |
505 "Function installed as `show-help-function'. | 496 "Function installed as `show-help-function'. |
506 MSG is either a help string to display, or nil to cancel the display." | 497 MSG is either a help string to display, or nil to cancel the display." |
507 (let ((previous-help tooltip-help-message)) | 498 (let ((previous-help tooltip-help-message)) |
508 (setq tooltip-help-message msg) | 499 (setq tooltip-help-message msg) |
518 ;; A different help. Remove a previous tooltip, and | 509 ;; A different help. Remove a previous tooltip, and |
519 ;; display a new one, with some delay. | 510 ;; display a new one, with some delay. |
520 (tooltip-hide) | 511 (tooltip-hide) |
521 (tooltip-start-delayed-tip))))) | 512 (tooltip-start-delayed-tip))))) |
522 | 513 |
523 | |
524 (defun tooltip-help-tips (event) | 514 (defun tooltip-help-tips (event) |
525 "Hook function to display a help tooltip. | 515 "Hook function to display a help tooltip. |
526 This is installed on the hook `tooltip-hook', which is run when | 516 This is installed on the hook `tooltip-hook', which is run when |
527 the timer with ID `tooltip-timeout-id' fires. | 517 the timer with ID `tooltip-timeout-id' fires. |
528 Value is non-nil if this function handled the tip." | 518 Value is non-nil if this function handled the tip." |
529 (when (stringp tooltip-help-message) | 519 (when (stringp tooltip-help-message) |
530 (tooltip-show tooltip-help-message) | 520 (tooltip-show tooltip-help-message) |
531 t)) | 521 t)) |
532 | |
533 | 522 |
534 | 523 |
535 ;;; Do this after all functions have been defined that are called from | 524 ;;; Do this after all functions have been defined that are called from |
536 ;;; `tooltip-mode'. The actual default value of `tooltip-mode' is set | 525 ;;; `tooltip-mode'. The actual default value of `tooltip-mode' is set |
537 ;;; in startup.el. | 526 ;;; in startup.el. |
546 :initialize 'custom-initialize-default | 535 :initialize 'custom-initialize-default |
547 :type 'boolean | 536 :type 'boolean |
548 :require 'tooltip | 537 :require 'tooltip |
549 :group 'tooltip) | 538 :group 'tooltip) |
550 | 539 |
540 (provide 'tooltip) | |
551 | 541 |
552 ;;; tooltip.el ends here | 542 ;;; tooltip.el ends here |