diff options
| author | Gerd Moellmann | 2001-01-04 20:38:02 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-01-04 20:38:02 +0000 |
| commit | 06f76f9fb80d8741de7cf2ae502a30552ed98dfe (patch) | |
| tree | 0054baa6d8bf98d5a7ca3c8881e3e35881004a40 | |
| parent | edf36fe614a1b32d507f1bd9c9c12ffa80de8866 (diff) | |
| download | emacs-06f76f9fb80d8741de7cf2ae502a30552ed98dfe.tar.gz emacs-06f76f9fb80d8741de7cf2ae502a30552ed98dfe.zip | |
(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.
| -rw-r--r-- | lisp/tooltip.el | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lisp/tooltip.el b/lisp/tooltip.el index f9d58802d7e..3457760f97d 100644 --- a/lisp/tooltip.el +++ b/lisp/tooltip.el | |||
| @@ -1,6 +1,6 @@ | |||
| 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 |
| @@ -247,14 +247,14 @@ With ARG, turn tooltip mode on if and only if ARG is positive." | |||
| 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))) |
| @@ -305,7 +305,7 @@ ACTIVATEP non-nil means activate mouse motion events." | |||
| 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 | ||
| @@ -330,11 +330,11 @@ change the existing association. Value is the resulting alist." | |||
| 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 |
| @@ -350,7 +350,7 @@ change the existing association. Value is the resulting alist." | |||
| 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 | ||
| @@ -502,22 +502,27 @@ 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). |
| 508 | (tooltip-hide) | 510 | ;; Keep what we have. |
| 509 | (tooltip-add-timeout)) | 511 | ) |
| 510 | (t | 512 | (t |
| 511 | (tooltip-disable-timeout) | 513 | ;; A different help. Remove a previous tooltip, and |
| 512 | (tooltip-add-timeout))))) | 514 | ;; display a new one, with some delay. |
| 515 | (tooltip-hide) | ||
| 516 | (tooltip-start-delayed-tip))))) | ||
| 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 | ||