Mercurial > emacs
comparison lisp/tooltip.el @ 35069:d19eadb47c76
(tooltip-cancel-delayed-tip)
(tooltip-start-delayed-tip): Renamed from tooltip-disable-timeout
and tooltip-add-timeout.
(tooltip-show): Set border color from faces's foreground.
(tooltip-show-help-function): If called with the same help string
as last time, do nothing.
(tooltip-help-tips): Don't set tooltip-help-message to nil.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Thu, 04 Jan 2001 20:38:02 +0000 |
parents | bb5e7a8b6f4c |
children | c00e94a506a2 |
comparison
equal
deleted
inserted
replaced
35068:e6fe439553cf | 35069:d19eadb47c76 |
---|---|
1 ;;; tooltip.el --- Show tooltip windows | 1 ;;; tooltip.el --- Show tooltip windows |
2 | 2 |
3 ;; Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1997, 1999, 2000, 2001 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Gerd Moellmann <gerd@acm.org> | 5 ;; Author: Gerd Moellmann <gerd@acm.org> |
6 ;; Keywords: help c mouse tools | 6 ;; Keywords: help c mouse tools |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
245 (< (- now tooltip-hide-time) tooltip-recent-seconds)) | 245 (< (- now tooltip-hide-time) tooltip-recent-seconds)) |
246 (setq delay tooltip-short-delay)) | 246 (setq delay tooltip-short-delay)) |
247 delay)) | 247 delay)) |
248 | 248 |
249 | 249 |
250 (defun tooltip-disable-timeout () | 250 (defun tooltip-cancel-delayed-tip () |
251 "Disable the tooltip timeout." | 251 "Disable the tooltip timeout." |
252 (when tooltip-timeout-id | 252 (when tooltip-timeout-id |
253 (disable-timeout tooltip-timeout-id) | 253 (disable-timeout tooltip-timeout-id) |
254 (setq tooltip-timeout-id nil))) | 254 (setq tooltip-timeout-id nil))) |
255 | 255 |
256 | 256 |
257 (defun tooltip-add-timeout () | 257 (defun tooltip-start-delayed-tip () |
258 "Add a one-shot timeout to call function tooltip-timeout." | 258 "Add a one-shot timeout to call function tooltip-timeout." |
259 (setq tooltip-timeout-id | 259 (setq tooltip-timeout-id |
260 (add-timeout (tooltip-delay) 'tooltip-timeout nil))) | 260 (add-timeout (tooltip-delay) 'tooltip-timeout nil))) |
261 | 261 |
262 | 262 |
303 "Command handler for mouse movement events in `global-map'." | 303 "Command handler for mouse movement events in `global-map'." |
304 (interactive "e") | 304 (interactive "e") |
305 (tooltip-hide) | 305 (tooltip-hide) |
306 (when (car (mouse-pixel-position)) | 306 (when (car (mouse-pixel-position)) |
307 (setq tooltip-last-mouse-motion-event (copy-sequence event)) | 307 (setq tooltip-last-mouse-motion-event (copy-sequence event)) |
308 (tooltip-add-timeout))) | 308 (tooltip-start-delayed-tip))) |
309 | 309 |
310 | 310 |
311 | 311 |
312 ;;; Displaying tips | 312 ;;; Displaying tips |
313 | 313 |
328 (message "%s" text) | 328 (message "%s" text) |
329 (condition-case error | 329 (condition-case error |
330 (let ((params (copy-sequence tooltip-frame-parameters)) | 330 (let ((params (copy-sequence tooltip-frame-parameters)) |
331 (fg (face-attribute 'tooltip :foreground)) | 331 (fg (face-attribute 'tooltip :foreground)) |
332 (bg (face-attribute 'tooltip :background))) | 332 (bg (face-attribute 'tooltip :background))) |
333 (unless (eq 'unspecified fg) | 333 (when (stringp fg) |
334 (setq params (tooltip-set-param params 'foreground-color fg))) | 334 (setq params (tooltip-set-param params 'foreground-color fg)) |
335 (unless (eq 'unspecified bg) | 335 (setq params (tooltip-set-param params 'border-color fg))) |
336 (setq params (tooltip-set-param params 'background-color bg)) | 336 (when (stringp bg) |
337 (setq params (tooltip-set-param params 'border-color bg))) | 337 (setq params (tooltip-set-param params 'background-color bg))) |
338 (x-show-tip (propertize text 'face 'tooltip) | 338 (x-show-tip (propertize text 'face 'tooltip) |
339 (selected-frame) | 339 (selected-frame) |
340 params | 340 params |
341 nil | 341 nil |
342 tooltip-x-offset | 342 tooltip-x-offset |
348 | 348 |
349 | 349 |
350 (defun tooltip-hide (&optional ignored-arg) | 350 (defun tooltip-hide (&optional ignored-arg) |
351 "Hide a tooltip, if one is displayed. | 351 "Hide a tooltip, if one is displayed. |
352 Value is non-nil if tooltip was open." | 352 Value is non-nil if tooltip was open." |
353 (tooltip-disable-timeout) | 353 (tooltip-cancel-delayed-tip) |
354 (when (x-hide-tip) | 354 (when (x-hide-tip) |
355 (setq tooltip-hide-time (float-time)))) | 355 (setq tooltip-hide-time (float-time)))) |
356 | 356 |
357 | 357 |
358 | 358 |
500 "Function installed as `show-help-function'. | 500 "Function installed as `show-help-function'. |
501 MSG is either a help string to display, or nil to cancel the display." | 501 MSG is either a help string to display, or nil to cancel the display." |
502 (let ((previous-help tooltip-help-message)) | 502 (let ((previous-help tooltip-help-message)) |
503 (setq tooltip-help-message msg) | 503 (setq tooltip-help-message msg) |
504 (cond ((null msg) | 504 (cond ((null msg) |
505 ;; Cancel display. This also cancels a delayed tip, if | |
506 ;; there is one. | |
505 (tooltip-hide)) | 507 (tooltip-hide)) |
506 ((or (not (stringp previous-help)) | 508 ((equal previous-help msg) |
507 (not (string= msg previous-help))) | 509 ;; Same help as before (but possibly the mouse has moved). |
510 ;; Keep what we have. | |
511 ) | |
512 (t | |
513 ;; A different help. Remove a previous tooltip, and | |
514 ;; display a new one, with some delay. | |
508 (tooltip-hide) | 515 (tooltip-hide) |
509 (tooltip-add-timeout)) | 516 (tooltip-start-delayed-tip))))) |
510 (t | |
511 (tooltip-disable-timeout) | |
512 (tooltip-add-timeout))))) | |
513 | 517 |
514 | 518 |
515 (defun tooltip-help-tips (event) | 519 (defun tooltip-help-tips (event) |
516 "Hook function to display a help tooltip. | 520 "Hook function to display a help tooltip. |
521 This is installed on the hook `tooltip-hook', which is run when | |
522 the the timer with ID `tooltip-timeout-id' fires. | |
517 Value is non-nil if this function handled the tip." | 523 Value is non-nil if this function handled the tip." |
518 (when (stringp tooltip-help-message) | 524 (when (stringp tooltip-help-message) |
519 (tooltip-show tooltip-help-message) | 525 (tooltip-show tooltip-help-message) |
520 (setq tooltip-help-message nil) | |
521 t)) | 526 t)) |
522 | 527 |
523 | 528 |
524 | 529 |
525 ;;; Do this after all functions have been defined that are called from | 530 ;;; Do this after all functions have been defined that are called from |