dape icon indicating copy to clipboard operation
dape copied to clipboard

Feature request: Replicate the GUD tool bar (in tool-bar-mode) for convenient mouse usage

Open phil-s opened this issue 1 year ago • 3 comments

This would be a useful enhancement to the UI, and relevant icons are already included in Emacs.

E.g. gdb uses:

(setq-local tool-bar-map gud-tool-bar-map)

and the tool bar definition is:

(defvar gud-tool-bar-map
  (let ((map (make-sparse-keymap)))
    (dolist (x '((gud-break . "gud/break")
		 (gud-remove . "gud/remove")
		 (gud-print . "gud/print")
		 (gud-pstar . "gud/pstar")
		 (gud-pp . "gud/pp")
		 (gud-watch . "gud/watch")
		 (gud-run . "gud/run")
		 (gud-go . "gud/go")
		 (gud-stop-subjob . "gud/stop")
		 (gud-cont . "gud/cont")
		 (gud-until . "gud/until")
		 (gud-next . "gud/next")
		 (gud-step . "gud/step")
		 (gud-finish . "gud/finish")
		 (gud-nexti . "gud/nexti")
		 (gud-stepi . "gud/stepi")
		 (gud-up . "gud/up")
		 (gud-down . "gud/down")
		 (gud-goto-info . "info"))
	       map)
      (tool-bar-local-item-from-menu
       (car x) (cdr x) map gud-minor-mode-map))))

phil-s avatar Nov 12 '24 09:11 phil-s

Hey!

I agree! If you have the time and have done your FSF assignment feel free to submit an PR. If not I will get around to it eventually.

svaante avatar Nov 13 '24 21:11 svaante

I've done my FSF copyright assignment for Emacs, yes. I'm not sure I'll get to it in a timely manner, so if you feel inspired then please do beat me to it :) Hopefully I can take a stab at it sometime soon, though.

phil-s avatar Nov 13 '24 23:11 phil-s

Maybe most people in Emacs don't use tool-bar?? I tried adding the tool-bar button to dape, but it didn't work, so I used modelline instead, haha ~~~ Give another idea. I love it:

Image

  (defvar dape-mode-line-buttons
    (let ((make-button
           (lambda (char fn)
             (propertize char
                         'mouse-face 'mode-line-highlight
                         'help-echo (format "Click to run `%s`" fn)
                         'local-map (let ((map (make-sparse-keymap)))
                                      (define-key map [mode-line mouse-1] fn)
                                      map)))))
      (concat
       "["
       (funcall make-button "🔄" #'dape-restart) " "
       (funcall make-button "▶️" #'dape-continue) " "
       (funcall make-button "⏸️" #'dape-pause) " "
       (funcall make-button "⏩" #'dape-next) " "
       (funcall make-button "⤵" #'dape-step-in) " "
       (funcall make-button "⤴️" #'dape-step-out) " "
       (funcall make-button "⏹️" #'dape-quit)
       "]"))
    "Modeline buttons for Dape commands.")

  (defun dape--remove-mode-line-buttons ()
    "Remove Dape buttons from `mode-line-misc-info`."
    (setq mode-line-misc-info
          (remove '(:eval dape-mode-line-buttons) mode-line-misc-info))
    (force-mode-line-update))

  (defun dape--remove-mode-line-buttons (&rest _)
    "Remove Dape buttons from `mode-line-misc-info`."
    (setq mode-line-misc-info
          (remove '(:eval dape-mode-line-buttons) mode-line-misc-info))
    (force-mode-line-update))

  ;; add the dape hook 
  (add-hook 'dape-start-hook #'dape--add-mode-line-buttons)
  (advice-add 'dape-quit :after #'dape--remove-mode-line-buttons);; because no  quit-hook, so it

ISouthRain avatar May 16 '25 11:05 ISouthRain