Home Download Buy Blog Forum Support

creating theme for custom scope on the fly

creating theme for custom scope on the fly

Postby aroberge on Sat Mar 05, 2011 8:20 pm

Hi,

I'm working on a plugin that uses view.add_regions(..., ..., scope,...) to add visual information, where I would like to use a "scope" name which would not present in a standard theme file. The only way I know to make this work is to have the user of the plugin edit his/her favourite theme to add the appropriate information. I would like to do this in a more flexible way as follows:

if the scope name is defined in the theme file [1], use it, otherwise "create" such a scope programmatically - something like:

if scope_exists(scope):
view.add_regions(..., ..., scope, ...)
else:
view.add_regions(..., ..., my_scope, ...)

where my_scope is a way to assign a given foreground colour. [2]

I have no idea if it is possible to do (in a plugin) either [1] or [2] or both... but it would be really nice.

Any ideas?
aroberge
 
Posts: 21
Joined: Sat Feb 12, 2011 1:03 am

Re: creating theme for custom scope on the fly

Postby jps on Sun Mar 06, 2011 4:31 am

It's not possible, and I'm not sure how it could work - without knowing the background color of the theme the user is using, how could you ensure that your color would be different?

I suggest using a common scope, and adding your own suffix, such as "invalid.lint_error", which will allow your region to have a default color for most color schemes, but still allow a color scheme to assign it a specific color.
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: creating theme for custom scope on the fly

Postby aroberge on Sun Mar 06, 2011 2:00 pm

jps wrote:It's not possible, and I'm not sure how it could work - without knowing the background color of the theme the user is using, how could you ensure that your color would be different?

I was thinking of then giving the option of setting this color via a user-set preference - which is something less of a burden to ask of a user than modifying a theme.
jps wrote:I suggest using a common scope, and adding your own suffix, such as "invalid.lint_error", which will allow your region to have a default color for most color schemes, but still allow a color scheme to assign it a specific color.


Thanks; that's what I will do.
aroberge
 
Posts: 21
Joined: Sat Feb 12, 2011 1:03 am


Return to Plugin Development

Who is online

Users browsing this forum: Google [Bot] and 4 guests