[Geany-Users] Highlighting the lexical scope relative to the cursor position

James Brierley jmb8710 at xxxxx
Sat Dec 21 19:30:39 UTC 2013

On 20/12/13 01:03, Matthew Brush wrote:
> This would probably make a good plugin.
> It should be possible, at least for languages who's lexer supports
> folding and where folding is roughly equivalent to scope. Maybe
> something like:
>    * find the current line's fold level
>    * walk backwards each line until the fold level decreases
>        - store that line's start position
>    * walk forwards each line until the fold level decreases
>        - store that line's end position
>    * for each character/cell in between start and end, change style

Indeed, most languages are folded with respect to scope. I hadn’t 
thought of that because I don’t tend to use folds much. This is more or 
less the kind of simple algorithm I had in mind, but more general than 
the concrete brackets/parens example. Good idea.

> You could probably also do something similar but calculate the XY pixel
> coordinates of a box around the scope and draw an overlay window at that
> box's size and position, allowing input to go through to the Scintilla
> widget underneath (similar effect to XCode's scope highlighting). This
> is kind of a similar effect as my "blackout" experiment except around
> the scope box instead of the whole editor widget:
> http://codebrainz.ca/images/blackout-demo.png

Interesting idea. I think I’d do it the simpler and less radical way though.

Sounds like writing a little plugin is going on my to-do list then.

Thanks guys,


"Unix is the worst computer operating system, except
all the others that have been tried."

More information about the Users mailing list