Page 1 of 1

highlight code tree node

Posted: 26.05.2024 13:49
by SamC
Hello,
I found that the nearest codetree node from current caret will be highlighted,however,that highlight is not worked for user defined codetree node.
Like the picture below,the caret is at line9, the nearest codetree node is at line6 which is user defined node, but the highlight node is at line4 which is built-in node.
Is it possible to highlight user defined node( mark2) in this case?
BTW, is it possible to change the background color of current node?
Thanks!
20240526_213931.png
20240526_213931.png (10.66 KiB) Viewed 8416 times

Re: highlight code tree node

Posted: 26.05.2024 14:33
by main Alexey
>Is it possible to highlight user defined node( mark2) in this case?
No, because the 'bookmark' tree node is not considered by app, when app is searching for current tree node. app considers only nodes calculated by tree-helper or lexer. It is not simple to change, sorry. Bookmark tree node is not 'internal' for app.

EDIT.
Next thinking: maybe it's possible to change the plugin 'code-tree bookmarks' for this. pls study its code. plugin can handle the on_state with APPSTATE_CODETREE_SET_SELECTION .
>BTW, is it possible to change the background color of current node?
As your screenshot shows, current node HAS the special highlight. So what more do you suggest?

Re: highlight code tree node

Posted: 26.05.2024 14:51
by SamC
Thanks, Any api to change the node highlight color? I will try to mark the bookmark node with different color.

Edit:
Any api to highlight several certain codetree nodes? Didn't find relevant commands in Tree_proc.

Re: highlight code tree node

Posted: 26.05.2024 15:49
by main Alexey
No, app don't have the API to change color of nodes.

Re: highlight code tree node

Posted: 26.05.2024 15:55
by main Alexey
But we have TREE_ITEM_SET_ICON, so you can make .png icon file 16x16, load it to imagelist (get imagelist handle: TREE_GET_IMAGELIST), and assign icon to any node.

Re: highlight code tree node

Posted: 26.05.2024 16:30
by main Alexey
I made this proposal
https://github.com/Alexey-T/CudaText/issues/5536
wait until it will be added, and then you can add 'state image index' per each node. using the same imagelist.

Re: highlight code tree node

Posted: 26.05.2024 17:35
by main Alexey
Plugin 'code-tree bookmarks' fixed and updated. Now clicking on bookmark line in editor - makes tree selection on correct bookmark node.

Re: highlight code tree node

Posted: 27.05.2024 01:40
by SamC
main Alexey wrote: 26.05.2024 17:35 Plugin 'code-tree bookmarks' fixed and updated. Now clicking on bookmark line in editor - makes tree selection on correct bookmark node.
Thanks,the following API is used to set the range of code item~
TREE_ITEM_SET_RANGE: Should be used only for code-tree. Sets range for tree-item. Param "text" must be 4-tuple of int (start_x, start_y, end_x, end_y).

Re: highlight code tree node

Posted: 27.05.2024 05:34
by main Alexey
Yes, this API. it was used not OK, author set the range of lenght= 1 char. I fixed it to set range of length= line_len.

Re: highlight code tree node

Posted: 27.05.2024 13:00
by main Alexey
Note, if you click below the last bookmark , or between 2 bookmarks, codetree cannot sync to bookmark node. you must click exactly on bookmarked line (before the line end).