Sublime Forum

Can we create a command to change the stype of a region?

#1

Say I have a commmand that add custom regions. Is there some way to make those custom regions change their style - Say, from the style of the keyword scope to the style of the constant.language scope?

0 Likes

#2

I believe the only way to modify the style of an existing region would be:

  • Use view.get_regions() to grab the set of regions that contains the region that you want to modify
  • Remove the region(s) you want to modify from the list and then use view.add_regions() to add the original list back with the original style and key
  • Add the region you removed with view.add_regions() using a different key and style

This is easy to do if you’re the one that wrote the command that added the regions in the first place and harder if you’re not, since you need to know the key to use to get at the regions .

0 Likes

#3

Reafing the docs on add_regions, it seems as if it only can color a region with the colir of a scope, but not properly dtyle it (e.g. set it to transparent background, blue foreground, and italics), which is what I’d want to do.

0 Likes

#4

Ahh, I see; sorry, I misinterpreted what you meant there. Yes, the main style of the text is defined by the combination of the syntax and the color scheme that’s in use; regions can only call areas to your attention, not change the underlying style.

0 Likes