I’ve extended the default JavaScript syntax definitions to include a special comment block to have them highlighted in a bright colour. I’d like to write a small plugin to automagically gold these blocks when they come into view, and unfold them when they are scrolled out of view.
How I envision this happening is by getting the visible region with sublime.View’s visibleRegion method, somehow getting all the comment blocks that have the special scope, and getting Regions for them, and using sublime.Region’s intersects method to see which ones are in view and folding them.
The problem is I have no idea on how to
- get all the comment blocks’ regions by scope
- fold/unfold regions programmatically.
I also couldn’t find any way to detect when a view has been scrolled, but I’d be content with triggering the folding and unfolding when the user has been inactive for 2 seconds or something similar.
Any hints on where to start reading up on things or any other tips on how to tackle this would be greatly appreciated!
The documentation sources I’ve been able to find are the official API reference and plugin examples and the unofficial documentation’s Python API reference, if there are other good docs out there I’d love to hear about them!