#+1
As a sidenote to this - I have a plugin concept that could greatly benefit from this functionality. The plugin essentially allows users to define arbitrary code folding points ( as opposed to the default indentation-based system ) by implementing headers, which they can also use to quickly fold/zoom code, open specific sections in new views, navigate sections via quickpanel, etc.
Here are a few other demos.
Some areas where I could see benefit would be - rather than headers occupying the same line-space as code, headers could be in non-code space like:
1> here is
2> some code
////////// This Is A Header /////////
3> here is some more code
I believe this would allow for faster performance by allowing headers to be queried solely within block decorations, rather than performing a RegEx search over the entirety of code.
Some implementations of block decorations that would be useful:
-
tag
: used to quickly group all block decorations of a particular tag into an array via
tagArray = view.get_decorations( "tagName" )
-
data{}
: “hidden” dictionary to store associated content ( EG: in the case of my header example,"indentation_level": 3
could be a stored value ) -
callback
: allows callbacks to be run upon clicking block decorations ( Some sort of method to differentiate left, right, & double clicks might be useful. Also, allow keybinding contexts to implement thetag
property along withis_block_decoration
) -
decoration.begin()
&decoration.end()
: return the same results as theirregion
counterparts -
fold markers : allow text to be folded “into” block decorations manually ( +1 for automatic fold-regions in between decorations as an option )