comparison lisp/tooltip.el @ 48925:cd1c70649388

(tooltip-gud-tips): Output tooltip without switching process filter (gdba in gdb-ui.el only). (gdb-tooltip-print): New function. (tooltip-gud-process-output): Undo previous change. (tooltip-strip-annotations): Remove.
author Nick Roberts <nickrob@snap.net.nz>
date Sun, 22 Dec 2002 00:21:06 +0000
parents 572f41d9a2ea
children e88404e8f2cf
comparison
equal deleted inserted replaced
48924:cd327aadc095 48925:cd1c70649388
27 ;;; Code: 27 ;;; Code:
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 (require 'gdb-ui))
33 34
34 35
35 ;;; Customizable settings 36 ;;; Customizable settings
36 37
37 (defgroup tooltip nil 38 (defgroup tooltip nil
409 (when (interactive-p) 410 (when (interactive-p)
410 (message "Dereferencing is now %s." 411 (message "Dereferencing is now %s."
411 (if tooltip-gud-dereference "on" "off")))) 412 (if tooltip-gud-dereference "on" "off"))))
412 413
413 ; This will only display data that comes in one chunk. 414 ; This will only display data that comes in one chunk.
414 ; The prompt is lost in first chunk so needn't be stripped.
415 ; Larger arrays (say 400 elements) are displayed in 415 ; Larger arrays (say 400 elements) are displayed in
416 ; the tootip incompletely (only the last chunk is displayed 416 ; the tootip incompletely and spill over into the gud buffer.
417 ; with the rest going to the gud buffer).
418 ; Switching the process-filter creates timing problems and 417 ; Switching the process-filter creates timing problems and
419 ; it may be difficult to do better. 418 ; it may be difficult to do better. gdba in gdb-ui.el
419 ; gets round this problem.
420 (defun tooltip-gud-process-output (process output) 420 (defun tooltip-gud-process-output (process output)
421 "Process debugger output and show it in a tooltip window." 421 "Process debugger output and show it in a tooltip window."
422 (set-process-filter process tooltip-gud-original-filter) 422 (set-process-filter process tooltip-gud-original-filter)
423 (case gud-minor-mode 423 (tooltip-show (tooltip-strip-prompt process output)))
424 (gdba (tooltip-show (tooltip-strip-annotations output)))
425 (t (tooltip-show (tooltip-strip-prompt process output)))))
426
427 ; this is derived from gdb-output-burst in gdb-ui.el. It
428 ; also only processes data that comes in one chunk properly.
429 (defun tooltip-strip-annotations (string)
430 "Strip annotations from the output of the gdb process."
431 (save-match-data
432 (let ((output ""))
433
434 ;; Process all the complete markers in this chunk.
435 (while (string-match "\n\032\032\\(.*\\)\n" string)
436
437 ;; Stuff prior to the match is just ordinary output.
438 ;; It is either concatenated to OUTPUT or directed
439 ;; elsewhere.
440 (setq output
441 (gdb-concat-output
442 output
443 (substring string 0 (match-beginning 0))))
444
445 ;; Take that stuff off the string.
446 (setq string (substring string (match-end 0))))
447 output)))
448 424
449 (defun tooltip-gud-print-command (expr) 425 (defun tooltip-gud-print-command (expr)
450 "Return a suitable command to print the expression EXPR. 426 "Return a suitable command to print the expression EXPR.
451 If TOOLTIP-GUD-DEREFERENCE is t, also prepend a `*' to EXPR." 427 If TOOLTIP-GUD-DEREFERENCE is t, also prepend a `*' to EXPR."
452 (when tooltip-gud-dereference 428 (when tooltip-gud-dereference
476 (eval (cons 'and tooltip-gud-display)))) 452 (eval (cons 'and tooltip-gud-display))))
477 (let ((expr (tooltip-expr-to-print event))) 453 (let ((expr (tooltip-expr-to-print event)))
478 (when expr 454 (when expr
479 (let ((cmd (tooltip-gud-print-command expr))) 455 (let ((cmd (tooltip-gud-print-command expr)))
480 (unless (null cmd) ; CMD can be nil if unknown debugger 456 (unless (null cmd) ; CMD can be nil if unknown debugger
481 (setq tooltip-gud-original-filter (process-filter process)) 457 (case gud-minor-mode
482 (set-process-filter process 'tooltip-gud-process-output) 458 (gdba (gdb-enqueue-input
483 (gud-basic-call cmd) 459 (list (concat cmd "\n") 'gdb-tooltip-print)))
484 expr))))))) 460 (t
461 (setq tooltip-gud-original-filter (process-filter process))
462 (set-process-filter process 'tooltip-gud-process-output)
463 (gud-basic-call cmd)))
464 expr)))))))
465
466 (defun gdb-tooltip-print ()
467 (tooltip-show
468 (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
469 (buffer-string))))
485 470
486 471
487 ;;; Tooltip help. 472 ;;; Tooltip help.
488 473
489 (defvar tooltip-help-message nil 474 (defvar tooltip-help-message nil