]> code.delx.au - gnu-emacs/blobdiff - lisp/tooltip.el
Romain Francoise's and Ami Fischman's bugfixes.
[gnu-emacs] / lisp / tooltip.el
index bb2a7bf54d9b433235b431507f12f70255addf4c..6ff86b4cf0bd120f947e9b9012c5727d0564fed7 100644 (file)
@@ -29,7 +29,8 @@
 (eval-when-compile
   (require 'cl)
   (require 'comint)
-  (require 'gud))
+  (require 'gud)
+  (require 'gdb-ui))
 
 \f
 ;;; Customizable settings
@@ -112,8 +113,11 @@ position to pop up the tooltip."
 
 (defface tooltip
   '((((class color))
-     (:background "lightyellow" :foreground "black"))
-    (t ()))
+     :background "lightyellow"
+     :foreground "black"
+     :inherit variable-pitch)
+    (t
+     :inherit variable-pitch))
   "Face for tooltips."
   :group 'tooltip)
 
@@ -285,7 +289,7 @@ ACTIVATEP non-nil means activate mouse motion events."
 
 (defun tooltip-set-param (alist key value)
   "Change the value of KEY in alist ALIST to VALUE.
-If there's no association for KEY in ALIST, add one, otherwise 
+If there's no association for KEY in ALIST, add one, otherwise
 change the existing association.  Value is the resulting alist."
   (let ((param (assq key alist)))
     (if (consp param)
@@ -320,7 +324,7 @@ position."
                      tooltip-hide-delay
                      tooltip-x-offset
                      tooltip-y-offset))
-      (error 
+      (error
        (message "Error while displaying tooltip: %s" error)
        (sit-for 1)
        (message "%s" text)))))
@@ -410,41 +414,16 @@ This event can be examined by forms in TOOLTIP-GUD-DISPLAY.")
     (message "Dereferencing is now %s."
             (if tooltip-gud-dereference "on" "off"))))
 
-; This will only display data that comes in one chunk. 
-; The prompt is lost in first chunk so needn't be stripped. 
+; This will only display data that comes in one chunk.
 ; Larger arrays (say 400 elements) are displayed in
-; the tootip incompletely (only the last chunk is displayed
-; with the rest going to the gud buffer).
+; the tootip incompletely and spill over into the gud buffer.
 ; Switching the process-filter creates timing problems and
-; it may be difficult to do better.
+; it may be difficult to do better. gdba in gdb-ui.el
+; gets round this problem.
 (defun tooltip-gud-process-output (process output)
   "Process debugger output and show it in a tooltip window."
   (set-process-filter process tooltip-gud-original-filter)
-  (case gud-minor-mode
-    (gdba (tooltip-show (tooltip-strip-annotations output)))
-    (t (tooltip-show (tooltip-strip-prompt process output)))))
-
-; this is derived from gdb-output-burst in gdb-ui.el. It
-; also only processes data that comes in one chunk properly.
-(defun tooltip-strip-annotations (string)
-  "Strip annotations from the output of the gdb process."
-  (save-match-data
-    (let ((output ""))
-
-      ;; Process all the complete markers in this chunk.
-      (while (string-match "\n\032\032\\(.*\\)\n" string)
-
-       ;; Stuff prior to the match is just ordinary output.
-       ;; It is either concatenated to OUTPUT or directed
-       ;; elsewhere.
-       (setq output
-             (gdb-concat-output 
-              output
-              (substring string 0 (match-beginning 0))))
-
-       ;; Take that stuff off the string.
-       (setq string (substring string (match-end 0))))
-      output)))
+  (tooltip-show (tooltip-strip-prompt process output)))
 
 (defun tooltip-gud-print-command (expr)
   "Return a suitable command to print the expression EXPR.
@@ -478,10 +457,19 @@ This function must return nil if it doesn't handle EVENT."
        (when expr
          (let ((cmd (tooltip-gud-print-command expr)))
            (unless (null cmd)         ; CMD can be nil if unknown debugger
-             (setq tooltip-gud-original-filter (process-filter process))
-             (set-process-filter process 'tooltip-gud-process-output)
-             (gud-basic-call cmd)
-             expr)))))))
+             (case gud-minor-mode
+                   (gdba (gdb-enqueue-input
+                          (list  (concat cmd "\n") 'gdb-tooltip-print)))
+                   (t
+                    (setq tooltip-gud-original-filter (process-filter process))
+                      (set-process-filter process 'tooltip-gud-process-output)
+                      (gud-basic-call cmd)))
+                   expr)))))))
+
+(defun gdb-tooltip-print ()
+  (tooltip-show
+   (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)
+     (buffer-string))))
 
 \f
 ;;; Tooltip help.
@@ -503,7 +491,7 @@ MSG is either a help string to display, or nil to cancel the display."
           ;; Keep what we have.
           )
          (t
-          ;; A different help.  Remove a previous tooltip, and 
+          ;; A different help.  Remove a previous tooltip, and
           ;; display a new one, with some delay.
           (tooltip-hide)
           (tooltip-start-delayed-tip)))))
@@ -536,4 +524,5 @@ use either \\[customize] or the function `tooltip-mode'."
 
 (provide 'tooltip)
 
+;;; arch-tag: 3d61135e-4618-4a78-af28-183f6df5636f
 ;;; tooltip.el ends here