Skip to content

Commit

Permalink
[Mouse] Ensure cursor turns into 'hand' over treemacs' buttons.
Browse files Browse the repository at this point in the history
Fixes #1109
  • Loading branch information
Alexander-Miller committed Aug 6, 2024
1 parent 362bfa5 commit 4e7a337
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/elisp/treemacs-extensions.el
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ node for quick retrieval later."
,icon
(propertize ,label-form
'button '(t)
'category t
'category 'treemacs-button
,@(when face `((quote face) ,face))
:custom t
:state ,state
Expand Down Expand Up @@ -445,7 +445,7 @@ additional keys."
,(if icon-closed closed-icon-name icon-closed-form)
(propertize ,root-label
'button '(t)
'category t
'category 'treemacs-button
'face ,root-face
:custom t
:key ,root-key-form
Expand Down Expand Up @@ -480,7 +480,7 @@ additional keys."
(treemacs-dom-node->insert-into-dom! dom-node)
(insert (propertize "Hidden Node\n"
'button '(t)
'category t
'category 'treemacs-button
'invisible t
'skip t
:custom t
Expand All @@ -503,7 +503,7 @@ additional keys."
(insert ,(if icon-closed closed-icon-name icon-closed-form))
(insert (propertize ,root-label
'button '(t)
'category t
'category 'treemacs-button
'face ,root-face
:custom t
:key ,root-key-form
Expand Down
9 changes: 6 additions & 3 deletions src/elisp/treemacs-rendering.el
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
treemacs--expand-file-node
treemacs--expand-tag-node)

;; Ensure mouse cursor turns into a hand over treemacs' buttons
(put 'treemacs-button 'mouse-face 'highlight)

(defvar-local treemacs--projects-end nil
"Marker pointing to position at the end of the last project.
Expand Down Expand Up @@ -238,7 +241,7 @@ DEPTH indicates how deep in the filetree the current button is."
(treemacs-icon-for-dir dir-name 'closed)
(propertize (->> dir-name (funcall treemacs-directory-name-transformer))
'button '(t)
'category t
'category 'treemacs-button
'help-echo nil
'keymap nil
:default-face 'treemacs-directory-face
Expand All @@ -261,7 +264,7 @@ DEPTH indicates how deep in the filetree the current button is."
(treemacs-icon-for-file ,path)
(propertize (->> ,path file-name-nondirectory (funcall treemacs-file-name-transformer))
'button '(t)
'category t
'category 'treemacs-button
'help-echo nil
'keymap nil
:default-face 'treemacs-git-unmodified-face
Expand Down Expand Up @@ -728,7 +731,7 @@ PROJECT: Project Struct"
(insert
(propertize (treemacs-project->name project)
'button '(t)
'category t
'category 'treemacs-button
'face (treemacs--root-face project)
:project project
:default-face 'treemacs-root-face
Expand Down
4 changes: 2 additions & 2 deletions src/elisp/treemacs-tags.el
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ DEPTH: Int"
,prefix
(propertize (car ,item)
'button '(t)
'category t
'category 'treemacs-button
'face 'treemacs-tags-face
'help-echo nil
:path ,path
Expand All @@ -171,7 +171,7 @@ DEPTH: Int"
,prefix
(propertize (car ,node)
'button '(t)
'category t
'category 'treemacs-button
'face 'treemacs-tags-face
'help-echo nil
:path ,path
Expand Down
8 changes: 4 additions & 4 deletions src/elisp/treemacs-treelib.el
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ EXT: `treemacs-extension' instance"
(insert (propertize
label
'button '(t)
'category t
'category 'treemacs-button
:custom t
:key key
:path key
Expand Down Expand Up @@ -645,7 +645,7 @@ EXPAND-DEPTH: Int"
(treemacs-dom-node->insert-into-dom! dom-node)
(insert (propertize "Hidden node"
'button '(t)
'category t
'category 'treemacs-button
'invisible t
'skip t
:custom t
Expand Down Expand Up @@ -696,7 +696,7 @@ LABEL: String"
(apply
#'propertize ,label
'button '(t)
'category t
'category 'treemacs-button
:custom t
:state ,state
:parent ,parent
Expand Down Expand Up @@ -729,7 +729,7 @@ PARENT: Button"
(treemacs-extension->get ext :closed-icon)
(propertize (treemacs-extension->get ext :label)
'button '(t)
'category t
'category 'treemacs-button
:custom t
:key key
:path path
Expand Down
16 changes: 8 additions & 8 deletions test/treemacs-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -1341,17 +1341,17 @@ EXPECTED-3 is the expected expansion of the \"file.txt\" button."
(it "Finds nothing for node without direct children"
(with-temp-buffer
(let* ((root1 (progn
(insert (propertize "Root1" 'button t 'category t :depth 1))
(insert (propertize "Root1" 'button t 'category 'treemacs-button :depth 1))
(beginning-of-line)
(point-marker)))
(input (progn
(end-of-line)
(insert "\n" (propertize " Input" 'button t 'category t :depth 2 :parent root1))
(insert "\n" (propertize " Input" 'button t 'category 'treemacs-button :depth 2 :parent root1))
(beginning-of-line)
(point-marker)))
(_root2 (progn
(end-of-line)
(insert "\n" (propertize "Root2" 'button t 'category t :depth 1))
(insert "\n" (propertize "Root2" 'button t 'category 'treemacs-button :depth 1))
(beginning-of-line)
(point-marker))) )
(-let [result (treemacs-collect-child-nodes input)]
Expand All @@ -1360,27 +1360,27 @@ EXPECTED-3 is the expected expansion of the \"file.txt\" button."
(it "Finds only direct children"
(with-temp-buffer
(let* ((root1 (progn
(insert (propertize "Root1" 'button t 'category t :depth 1))
(insert (propertize "Root1" 'button t 'category 'treemacs-button :depth 1))
(beginning-of-line)
(point-marker)))
(input (progn
(end-of-line)
(insert "\n" (propertize " Input" 'button t 'category t :depth 2 :parent root1))
(insert "\n" (propertize " Input" 'button t 'category 'treemacs-button :depth 2 :parent root1))
(beginning-of-line)
(point-marker)))
(child1 (progn
(end-of-line)
(insert "\n" (propertize " Child1" 'button t 'category t :depth 3 :parent input))
(insert "\n" (propertize " Child1" 'button t 'category 'treemacs-button :depth 3 :parent input))
(beginning-of-line)
(point-marker)))
(_grand-child (progn
(end-of-line)
(insert "\n" (propertize " Grand Child" 'button t 'category t :depth 4 :parent child1))
(insert "\n" (propertize " Grand Child" 'button t 'category 'treemacs-button :depth 4 :parent child1))
(beginning-of-line)
(point-marker)))
(_child2 (progn
(end-of-line)
(insert "\n" (propertize " Child2" 'button t 'category t :depth 3 :parent input))
(insert "\n" (propertize " Child2" 'button t 'category 'treemacs-button :depth 3 :parent input))
(beginning-of-line)
(point-marker))) )
(-let [result (-map #'treemacs--get-label-of (treemacs-collect-child-nodes input))]
Expand Down

0 comments on commit 4e7a337

Please sign in to comment.