origami.el icon indicating copy to clipboard operation
origami.el copied to clipboard

Mouse support

Open NiltonVolpato opened this issue 7 months ago • 0 comments

I added some very rudimentary mouse support for it. It seems to be working fine for me, but it may have some quirks Ideally it would be nice to have a separate column on the left side and it could show + or - to let us know that something can be expanded or collapsed on that line (but I haven't yet tried to understand in enough detail how origami represents that information).

;; Toggles the collapsed/expanded state of node by clicking
;; on the left margin.
(defun my/origami-mouse-toggle-node (event)
  (interactive "e")
  (let* ((posn (event-start event))
         (col (car (posn-col-row posn))))
    (when (<= col 5)
      (origami-forward-toggle-node
       (window-buffer (posn-window posn)) (posn-point posn)))))

;; Code folding/collapsing
(use-package origami
  :hook (prog-mode . origami-mode)
  :bind (:map origami-mode-map
              ;; mouse bindings
              ([down-mouse-1] . my/origami-mouse-toggle-node)
              ;; keyboard bindings
              ("C-c f o" . origami-open-node)
              ("C-c f c" . origami-close-node)
              ("C-c f a" . origami-toggle-all)))

NiltonVolpato avatar May 20 '25 10:05 NiltonVolpato