Mercurial > emacs
comparison lisp/tooltip.el @ 93905:529aa606e975
(tooltip-mode): Set tooltip-show-help-non-mode as
show-help-function when turning tooltip off.
(tooltip-show): Call tooltip-show-help-non-mode if use-echo-area.
(tooltip-trunc-str, tooltip-show-help-non-mode): New.
author | Jan Djärv <jan.h.d@swipnet.se> |
---|---|
date | Wed, 09 Apr 2008 09:34:06 +0000 |
parents | 107ccd98fa12 |
children | 7ae01d17160f |
comparison
equal
deleted
inserted
replaced
93904:41ee2cc9680d | 93905:529aa606e975 |
---|---|
65 (add-hook 'tooltip-hook 'tooltip-help-tips)) | 65 (add-hook 'tooltip-hook 'tooltip-help-tips)) |
66 (unless (and (boundp 'gud-tooltip-mode) gud-tooltip-mode) | 66 (unless (and (boundp 'gud-tooltip-mode) gud-tooltip-mode) |
67 (remove-hook 'pre-command-hook 'tooltip-hide)) | 67 (remove-hook 'pre-command-hook 'tooltip-hide)) |
68 (remove-hook 'tooltip-hook 'tooltip-help-tips)) | 68 (remove-hook 'tooltip-hook 'tooltip-help-tips)) |
69 (setq show-help-function | 69 (setq show-help-function |
70 (if tooltip-mode 'tooltip-show-help nil))) | 70 (if tooltip-mode 'tooltip-show-help 'tooltip-show-help-non-mode))) |
71 | 71 |
72 | 72 |
73 ;;; Customizable settings | 73 ;;; Customizable settings |
74 | 74 |
75 (defcustom tooltip-delay 0.7 | 75 (defcustom tooltip-delay 0.7 |
226 position. | 226 position. |
227 | 227 |
228 Optional second arg USE-ECHO-AREA non-nil means to show tooltip | 228 Optional second arg USE-ECHO-AREA non-nil means to show tooltip |
229 in echo area." | 229 in echo area." |
230 (if use-echo-area | 230 (if use-echo-area |
231 (message "%s" text) | 231 (tooltip-show-help-non-mode text) |
232 (condition-case error | 232 (condition-case error |
233 (let ((params (copy-sequence tooltip-frame-parameters)) | 233 (let ((params (copy-sequence tooltip-frame-parameters)) |
234 (fg (face-attribute 'tooltip :foreground)) | 234 (fg (face-attribute 'tooltip :foreground)) |
235 (bg (face-attribute 'tooltip :background))) | 235 (bg (face-attribute 'tooltip :background))) |
236 (when (stringp fg) | 236 (when (stringp fg) |
314 ;;; Tooltip help. | 314 ;;; Tooltip help. |
315 | 315 |
316 (defvar tooltip-help-message nil | 316 (defvar tooltip-help-message nil |
317 "The last help message received via `tooltip-show-help'.") | 317 "The last help message received via `tooltip-show-help'.") |
318 | 318 |
319 (defun tooltip-trunc-str (str maxlen pieces) | |
320 (let ((s (car pieces))) | |
321 (if (and pieces (< (+ (length str) (length s) 2) maxlen)) | |
322 (tooltip-trunc-str (concat str | |
323 (if (> (length str) 0) ", " "") | |
324 s) | |
325 maxlen (cdr pieces)) | |
326 (if (> (length str) 0) str s)))) | |
327 | |
328 (defun tooltip-show-help-non-mode (msg) | |
329 "Function installed as `show-help-function' when tooltip is off." | |
330 (message "%s" (if msg | |
331 (tooltip-trunc-str "" (frame-parameter nil 'width) | |
332 (split-string msg "\n" t)) | |
333 ""))) | |
334 | |
319 (defun tooltip-show-help (msg) | 335 (defun tooltip-show-help (msg) |
320 "Function installed as `show-help-function'. | 336 "Function installed as `show-help-function'. |
321 MSG is either a help string to display, or nil to cancel the display." | 337 MSG is either a help string to display, or nil to cancel the display." |
322 (let ((previous-help tooltip-help-message)) | 338 (let ((previous-help tooltip-help-message)) |
323 (setq tooltip-help-message msg) | 339 (setq tooltip-help-message msg) |