Mercurial > emacs
comparison lisp/progmodes/gud.el @ 67486:3d94a55776e3
(gud-tooltip-modes, gud-tooltip-display):
Add the gud groupname.
(gud-tooltip-mode): Add the tooltip groupname. Move in front
of other defcustoms with that groupname.
(gud-tooltip-echo-area): Add the gud groupname. Remove tag to
avoid conflict with tooltip-use-echo-area.
author | Nick Roberts <nickrob@snap.net.nz> |
---|---|
date | Sat, 10 Dec 2005 21:32:22 +0000 |
parents | adbf404cf806 |
children | dda3dc3d3548 |
comparison
equal
deleted
inserted
replaced
67485:2865d1195586 | 67486:3d94a55776e3 |
---|---|
3219 | 3219 |
3220 | 3220 |
3221 ;;; tooltips for GUD | 3221 ;;; tooltips for GUD |
3222 | 3222 |
3223 ;;; Customizable settings | 3223 ;;; Customizable settings |
3224 (defcustom gud-tooltip-modes '(gud-mode c-mode c++-mode fortran-mode) | |
3225 "List of modes for which to enable GUD tips." | |
3226 :type 'sexp | |
3227 :tag "GUD modes" | |
3228 :group 'tooltip) | |
3229 | |
3230 (defcustom gud-tooltip-display | |
3231 '((eq (tooltip-event-buffer gud-tooltip-event) | |
3232 (marker-buffer gud-overlay-arrow-position))) | |
3233 "List of forms determining where GUD tooltips are displayed. | |
3234 | |
3235 Forms in the list are combined with AND. The default is to display | |
3236 only tooltips in the buffer containing the overlay arrow." | |
3237 :type 'sexp | |
3238 :tag "GUD buffers predicate" | |
3239 :group 'tooltip) | |
3240 | |
3241 (defcustom gud-tooltip-echo-area nil | |
3242 "Use the echo area instead of frames for GUD tooltips." | |
3243 :type 'boolean | |
3244 :tag "Use echo area" | |
3245 :group 'tooltip) | |
3246 | |
3247 (define-obsolete-variable-alias 'tooltip-gud-modes | |
3248 'gud-tooltip-modes "22.1") | |
3249 (define-obsolete-variable-alias 'tooltip-gud-display | |
3250 'gud-tooltip-display "22.1") | |
3251 | |
3252 ;;; Reacting on mouse movements | |
3253 | |
3254 (defun gud-tooltip-change-major-mode () | |
3255 "Function added to `change-major-mode-hook' when tooltip mode is on." | |
3256 (add-hook 'post-command-hook 'gud-tooltip-activate-mouse-motions-if-enabled)) | |
3257 | |
3258 (defun gud-tooltip-activate-mouse-motions-if-enabled () | |
3259 "Reconsider for all buffers whether mouse motion events are desired." | |
3260 (remove-hook 'post-command-hook | |
3261 'gud-tooltip-activate-mouse-motions-if-enabled) | |
3262 (dolist (buffer (buffer-list)) | |
3263 (save-excursion | |
3264 (set-buffer buffer) | |
3265 (if (and gud-tooltip-mode | |
3266 (memq major-mode gud-tooltip-modes)) | |
3267 (gud-tooltip-activate-mouse-motions t) | |
3268 (gud-tooltip-activate-mouse-motions nil))))) | |
3269 | |
3270 (defvar gud-tooltip-mouse-motions-active nil | |
3271 "Locally t in a buffer if tooltip processing of mouse motion is enabled.") | |
3272 | |
3273 (defun gud-tooltip-activate-mouse-motions (activatep) | |
3274 "Activate/deactivate mouse motion events for the current buffer. | |
3275 ACTIVATEP non-nil means activate mouse motion events." | |
3276 (if activatep | |
3277 (progn | |
3278 (make-local-variable 'gud-tooltip-mouse-motions-active) | |
3279 (setq gud-tooltip-mouse-motions-active t) | |
3280 (make-local-variable 'track-mouse) | |
3281 (setq track-mouse t)) | |
3282 (when gud-tooltip-mouse-motions-active | |
3283 (kill-local-variable 'gud-tooltip-mouse-motions-active) | |
3284 (kill-local-variable 'track-mouse)))) | |
3285 | |
3286 (defun gud-tooltip-mouse-motion (event) | |
3287 "Command handler for mouse movement events in `global-map'." | |
3288 (interactive "e") | |
3289 (tooltip-hide) | |
3290 (when (car (mouse-pixel-position)) | |
3291 (setq tooltip-last-mouse-motion-event (copy-sequence event)) | |
3292 (tooltip-start-delayed-tip))) | |
3293 | |
3294 ;;; Tips for `gud' | |
3295 | |
3296 (defvar gud-tooltip-original-filter nil | |
3297 "Process filter to restore after GUD output has been received.") | |
3298 | |
3299 (defvar gud-tooltip-dereference nil | |
3300 "Non-nil means print expressions with a `*' in front of them. | |
3301 For C this would dereference a pointer expression.") | |
3302 | |
3303 (defvar gud-tooltip-event nil | |
3304 "The mouse movement event that led to a tooltip display. | |
3305 This event can be examined by forms in GUD-TOOLTIP-DISPLAY.") | |
3306 | |
3307 (defun toggle-gud-tooltip-dereference () | |
3308 "Toggle whether tooltips should show `* expr' or `expr'." | |
3309 (interactive) | |
3310 (setq gud-tooltip-dereference (not gud-tooltip-dereference)) | |
3311 (when (interactive-p) | |
3312 (message "Dereferencing is now %s." | |
3313 (if gud-tooltip-dereference "on" "off")))) | |
3314 | |
3315 (define-obsolete-function-alias 'tooltip-gud-toggle-dereference | |
3316 'toggle-gud-tooltip-dereference "22.1") | |
3317 | 3224 |
3318 ;;;###autoload | 3225 ;;;###autoload |
3319 (define-minor-mode gud-tooltip-mode | 3226 (define-minor-mode gud-tooltip-mode |
3320 "Toggle the display of GUD tooltips." | 3227 "Toggle the display of GUD tooltips." |
3321 :global t | 3228 :global t |
3322 :group 'gud | 3229 :group 'gud |
3230 :group 'tooltip | |
3323 (require 'tooltip) | 3231 (require 'tooltip) |
3324 (if gud-tooltip-mode | 3232 (if gud-tooltip-mode |
3325 (progn | 3233 (progn |
3326 (add-hook 'change-major-mode-hook 'gud-tooltip-change-major-mode) | 3234 (add-hook 'change-major-mode-hook 'gud-tooltip-change-major-mode) |
3327 (add-hook 'pre-command-hook 'tooltip-hide) | 3235 (add-hook 'pre-command-hook 'tooltip-hide) |
3349 (gdb-create-define-alist) | 3257 (gdb-create-define-alist) |
3350 (add-hook 'after-save-hook | 3258 (add-hook 'after-save-hook |
3351 'gdb-create-define-alist nil t)))))) | 3259 'gdb-create-define-alist nil t)))))) |
3352 (kill-local-variable 'gdb-define-alist) | 3260 (kill-local-variable 'gdb-define-alist) |
3353 (remove-hook 'after-save-hook 'gdb-create-define-alist t)))) | 3261 (remove-hook 'after-save-hook 'gdb-create-define-alist t)))) |
3262 | |
3263 (defcustom gud-tooltip-modes '(gud-mode c-mode c++-mode fortran-mode) | |
3264 "List of modes for which to enable GUD tooltips." | |
3265 :type 'sexp | |
3266 :tag "GUD modes" | |
3267 :group 'gud | |
3268 :group 'tooltip) | |
3269 | |
3270 (defcustom gud-tooltip-display | |
3271 '((eq (tooltip-event-buffer gud-tooltip-event) | |
3272 (marker-buffer gud-overlay-arrow-position))) | |
3273 "List of forms determining where GUD tooltips are displayed. | |
3274 | |
3275 Forms in the list are combined with AND. The default is to display | |
3276 only tooltips in the buffer containing the overlay arrow." | |
3277 :type 'sexp | |
3278 :tag "GUD buffers predicate" | |
3279 :group 'gud | |
3280 :group 'tooltip) | |
3281 | |
3282 (defcustom gud-tooltip-echo-area nil | |
3283 "Use the echo area instead of frames for GUD tooltips." | |
3284 :type 'boolean | |
3285 :group 'gud | |
3286 :group 'tooltip) | |
3287 | |
3288 (define-obsolete-variable-alias 'tooltip-gud-modes | |
3289 'gud-tooltip-modes "22.1") | |
3290 (define-obsolete-variable-alias 'tooltip-gud-display | |
3291 'gud-tooltip-display "22.1") | |
3292 | |
3293 ;;; Reacting on mouse movements | |
3294 | |
3295 (defun gud-tooltip-change-major-mode () | |
3296 "Function added to `change-major-mode-hook' when tooltip mode is on." | |
3297 (add-hook 'post-command-hook 'gud-tooltip-activate-mouse-motions-if-enabled)) | |
3298 | |
3299 (defun gud-tooltip-activate-mouse-motions-if-enabled () | |
3300 "Reconsider for all buffers whether mouse motion events are desired." | |
3301 (remove-hook 'post-command-hook | |
3302 'gud-tooltip-activate-mouse-motions-if-enabled) | |
3303 (dolist (buffer (buffer-list)) | |
3304 (save-excursion | |
3305 (set-buffer buffer) | |
3306 (if (and gud-tooltip-mode | |
3307 (memq major-mode gud-tooltip-modes)) | |
3308 (gud-tooltip-activate-mouse-motions t) | |
3309 (gud-tooltip-activate-mouse-motions nil))))) | |
3310 | |
3311 (defvar gud-tooltip-mouse-motions-active nil | |
3312 "Locally t in a buffer if tooltip processing of mouse motion is enabled.") | |
3313 | |
3314 (defun gud-tooltip-activate-mouse-motions (activatep) | |
3315 "Activate/deactivate mouse motion events for the current buffer. | |
3316 ACTIVATEP non-nil means activate mouse motion events." | |
3317 (if activatep | |
3318 (progn | |
3319 (make-local-variable 'gud-tooltip-mouse-motions-active) | |
3320 (setq gud-tooltip-mouse-motions-active t) | |
3321 (make-local-variable 'track-mouse) | |
3322 (setq track-mouse t)) | |
3323 (when gud-tooltip-mouse-motions-active | |
3324 (kill-local-variable 'gud-tooltip-mouse-motions-active) | |
3325 (kill-local-variable 'track-mouse)))) | |
3326 | |
3327 (defun gud-tooltip-mouse-motion (event) | |
3328 "Command handler for mouse movement events in `global-map'." | |
3329 (interactive "e") | |
3330 (tooltip-hide) | |
3331 (when (car (mouse-pixel-position)) | |
3332 (setq tooltip-last-mouse-motion-event (copy-sequence event)) | |
3333 (tooltip-start-delayed-tip))) | |
3334 | |
3335 ;;; Tips for `gud' | |
3336 | |
3337 (defvar gud-tooltip-original-filter nil | |
3338 "Process filter to restore after GUD output has been received.") | |
3339 | |
3340 (defvar gud-tooltip-dereference nil | |
3341 "Non-nil means print expressions with a `*' in front of them. | |
3342 For C this would dereference a pointer expression.") | |
3343 | |
3344 (defvar gud-tooltip-event nil | |
3345 "The mouse movement event that led to a tooltip display. | |
3346 This event can be examined by forms in GUD-TOOLTIP-DISPLAY.") | |
3347 | |
3348 (defun toggle-gud-tooltip-dereference () | |
3349 "Toggle whether tooltips should show `* expr' or `expr'." | |
3350 (interactive) | |
3351 (setq gud-tooltip-dereference (not gud-tooltip-dereference)) | |
3352 (when (interactive-p) | |
3353 (message "Dereferencing is now %s." | |
3354 (if gud-tooltip-dereference "on" "off")))) | |
3355 | |
3356 (define-obsolete-function-alias 'tooltip-gud-toggle-dereference | |
3357 'toggle-gud-tooltip-dereference "22.1") | |
3354 | 3358 |
3355 ; This will only display data that comes in one chunk. | 3359 ; This will only display data that comes in one chunk. |
3356 ; Larger arrays (say 400 elements) are displayed in | 3360 ; Larger arrays (say 400 elements) are displayed in |
3357 ; the tooltip incompletely and spill over into the gud buffer. | 3361 ; the tooltip incompletely and spill over into the gud buffer. |
3358 ; Switching the process-filter creates timing problems and | 3362 ; Switching the process-filter creates timing problems and |