Skip to content

Commit

Permalink
feat: Add unfold node on click
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jun 20, 2024
1 parent f2ab092 commit 92b2d2e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ts-fold.el
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ For example, Lua, Ruby, etc."
"Face used to display the fold replacement text."
:group 'ts-fold)

(defface ts-fold-replacement-mouse-face
'((t :foreground "#808080" :box (:line-width -1 :style released-button)))
"Face used to when mouse hovering replacement text."
:group 'ts-fold)

(defface ts-fold-fringe-face
'((t ()))
"Face used to display fringe contents."
Expand Down Expand Up @@ -340,13 +345,18 @@ This function is borrowed from `tree-sitter-node-at-point'."
(when range
(let* ((beg (car range))
(end (cdr range))
(ov (make-overlay beg end)))
(ov (make-overlay beg end))
(map (make-sparse-keymap)))
(keymap-set map "<mouse-1>" #'ts-fold-open)
(overlay-put ov 'creator 'ts-fold)
(overlay-put ov 'priority ts-fold-priority)
(overlay-put ov 'invisible 'ts-fold)
(overlay-put ov 'display (or (and ts-fold-summary-show
(ts-fold-summary--get (buffer-substring beg end)))
ts-fold-replacement))
(propertize ts-fold-replacement
'mouse-face 'ts-fold-replacement-mouse-face
'help-echo "mouse-1: unfold this node"
'keymap map)))
(overlay-put ov 'face 'ts-fold-replacement-face)
(overlay-put ov 'modification-hooks '(ts-fold--on-change))
(overlay-put ov 'insert-in-front-hooks '(ts-fold--on-change))
Expand Down

0 comments on commit 92b2d2e

Please sign in to comment.