comparison lisp/progmodes/gdb-ui.el @ 72429:ae19dce6b114

(gdb-locals-watch-map, gdb-locals-watch-map-1): Suppress keymap first. (gdb-edit-locals-map-1): New variable. (gdb-edit-locals-value): New function. (gdb-stack-list-locals-handler): Use them.
author Nick Roberts <nickrob@snap.net.nz>
date Thu, 17 Aug 2006 11:44:40 +0000
parents 17d65e848c72
children 4bb2db64b4a1
comparison
equal deleted inserted replaced
72428:608323e2c0e3 72429:ae19dce6b114
382 (call-process shell-file-name 382 (call-process shell-file-name
383 (if (file-exists-p file) file nil) 383 (if (file-exists-p file) file nil)
384 (list t nil) nil "-c" 384 (list t nil) nil "-c"
385 (concat gdb-cpp-define-alist-program " " 385 (concat gdb-cpp-define-alist-program " "
386 gdb-cpp-define-alist-flags))))) 386 gdb-cpp-define-alist-flags)))))
387 (define-list (split-string output "\n" t)) 387 (define-list (split-string output "\n" t)) (name))
388 (name))
389 (setq gdb-define-alist nil) 388 (setq gdb-define-alist nil)
390 (dolist (define define-list) 389 (dolist (define define-list)
391 (setq name (nth 1 (split-string define "[( ]"))) 390 (setq name (nth 1 (split-string define "[( ]")))
392 (push (cons name define) gdb-define-alist)))) 391 (push (cons name define) gdb-define-alist))))
393 392
2655 "server info locals\n" 2654 "server info locals\n"
2656 gdb-info-locals-handler) 2655 gdb-info-locals-handler)
2657 2656
2658 (defvar gdb-locals-watch-map 2657 (defvar gdb-locals-watch-map
2659 (let ((map (make-sparse-keymap))) 2658 (let ((map (make-sparse-keymap)))
2659 (suppress-keymap map)
2660 (define-key map "\r" (lambda () (interactive) 2660 (define-key map "\r" (lambda () (interactive)
2661 (beginning-of-line) 2661 (beginning-of-line)
2662 (gud-watch))) 2662 (gud-watch)))
2663 (define-key map [mouse-2] (lambda (event) (interactive "e") 2663 (define-key map [mouse-2] (lambda (event) (interactive "e")
2664 (mouse-set-point event) 2664 (mouse-set-point event)
3510 (defconst gdb-stack-list-locals-regexp 3510 (defconst gdb-stack-list-locals-regexp
3511 "{.*?name=\"\\(.*?\\)\",.*?type=\"\\(.*?\\)\"") 3511 "{.*?name=\"\\(.*?\\)\",.*?type=\"\\(.*?\\)\"")
3512 3512
3513 (defvar gdb-locals-watch-map-1 3513 (defvar gdb-locals-watch-map-1
3514 (let ((map (make-sparse-keymap))) 3514 (let ((map (make-sparse-keymap)))
3515 (suppress-keymap map)
3516 (define-key map "\r" 'gud-watch)
3515 (define-key map [mouse-2] 'gud-watch) 3517 (define-key map [mouse-2] 'gud-watch)
3516 map) 3518 map)
3517 "Keymap to create watch expression of a complex data type local variable.") 3519 "Keymap to create watch expression of a complex data type local variable.")
3520
3521 (defvar gdb-edit-locals-map-1
3522 (let ((map (make-sparse-keymap)))
3523 (suppress-keymap map)
3524 (define-key map "\r" 'gdb-edit-locals-value)
3525 (define-key map [mouse-2] 'gdb-edit-locals-value)
3526 map)
3527 "Keymap to edit value of a simple data type local variable.")
3528
3529 (defun gdb-edit-locals-value (&optional event)
3530 "Assign a value to a variable displayed in the locals buffer."
3531 (interactive (list last-input-event))
3532 (save-excursion
3533 (if event (posn-set-point (event-end event)))
3534 (beginning-of-line)
3535 (let* ((var (current-word))
3536 (value (read-string (format "New value (%s): " var))))
3537 (gdb-enqueue-input
3538 (list (concat gdb-server-prefix"set variable " var " = " value "\n")
3539 'ignore))))))
3518 3540
3519 ;; Dont display values of arrays or structures. 3541 ;; Dont display values of arrays or structures.
3520 ;; These can be expanded using gud-watch. 3542 ;; These can be expanded using gud-watch.
3521 (defun gdb-stack-list-locals-handler () 3543 (defun gdb-stack-list-locals-handler ()
3522 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals-1 3544 (setq gdb-pending-triggers (delq 'gdb-invalidate-locals-1
3541 (let ((buf (gdb-get-buffer 'gdb-locals-buffer))) 3563 (let ((buf (gdb-get-buffer 'gdb-locals-buffer)))
3542 (and buf (with-current-buffer buf 3564 (and buf (with-current-buffer buf
3543 (let* ((window (get-buffer-window buf 0)) 3565 (let* ((window (get-buffer-window buf 0))
3544 (start (window-start window)) 3566 (start (window-start window))
3545 (p (window-point window)) 3567 (p (window-point window))
3546 (buffer-read-only nil)) 3568 (buffer-read-only nil) (name) (value))
3547 (erase-buffer) 3569 (erase-buffer)
3548 (dolist (local locals-list) 3570 (dolist (local locals-list)
3549 (setq name (car local)) 3571 (setq name (car local))
3550 (if (or (not (nth 2 local)) 3572 (setq value (nth 2 local))
3551 (string-match "^\\0x" (nth 2 local))) 3573 (if (or (not value)
3574 (string-match "^\\0x" value))
3552 (add-text-properties 0 (length name) 3575 (add-text-properties 0 (length name)
3553 `(mouse-face highlight 3576 `(mouse-face highlight
3554 help-echo "mouse-2: create watch expression" 3577 help-echo "mouse-2: create watch expression"
3555 local-map ,gdb-locals-watch-map-1) 3578 local-map ,gdb-locals-watch-map-1)
3556 name)) 3579 name)
3580 (add-text-properties 0 (length value)
3581 `(mouse-face highlight
3582 help-echo "mouse-2: edit value"
3583 local-map ,gdb-edit-locals-map-1)
3584 value))
3557 (insert 3585 (insert
3558 (concat name "\t" (nth 1 local) 3586 (concat name "\t" (nth 1 local)
3559 "\t" (nth 2 local) "\n"))) 3587 "\t" (nth 2 local) "\n")))
3560 (set-window-start window start) 3588 (set-window-start window start)
3561 (set-window-point window p)))))))) 3589 (set-window-point window p))))))))