Re: [code] [textadept] Theming

From: Mitchell <m.att.foicica.com>
Date: Fri, 21 Jun 2013 15:53:57 -0400 (Eastern Daylight Time)

Robert,

On Tue, 11 Jun 2013, Robert wrote:

> Hi,
>
> I like the new theming style and the string-based formatting is easy
> to get adjusted to.
> Some things I noticed:
>
> * I don't think it makes much sense to have set_theme show a list of
> themes if used interactively, I used to use this feature (and was pro
> keeping it when you asked about it recently) but without the selection
> persisting, it doesn't feel quite right. Maybe someone writes a tool
> to create such a selection and change the value in `init.lua` but this
> probably doesn't belong in Textadept core. Without persistence people
> will certainly complain about it...
> Also it's quite simple to edit `init.lua` and try out a new theme with
> a call to `reset`.

You're right. I removed it and put a note in the manual to call
`gui.set_theme()` from *~/.textadept/init.lua*.

> * What do you think about having a font adjusting API like
>
> set_theme(theme, font, fontsize) e.g.
>
> set_theme('darker', 'Monaco', 12)
>
> The last two options would be optional and would otherwise be set to
> the values now present in each theme.

Something more powerful is now in hg. `gui.set_theme()` accepts optional
key-value argument pairs for properties. In your case, you would call it
like this:

     gui.set_theme('darker', 'font', 'Monaco', 'fontsize', 12)

You can use this to tweak other things like single colors or single
styles. The manual makes a note of this too.

> * There are a few occasions of named colors in a few lexers:
> diff.lua
> 36: {'addition', 'fore:$(color.green)'},
> 37: {'deletion', 'fore:$(color.red)'},
> 38: {'change', 'fore:$(color.yellow)'},
>
> [snip]

Latest hg now has the ability for themes to connect to the
'language_module_loaded' event to set per-lexer themes as outlined
previously in the manual. For example:

     -- File *~/.textadept/themes/my_theme.lua*
     -- ...
     events.connect('language_module_loaded', function(lang)
       if lang == 'diff' then
         buffer.property['style.addition'] = ...
         buffer.property['style.deletion'] = ...
         buffer.property['style.change'] = ...
       end
     end

Unfortunately since the 'mime_types' module loads after 'gui',
`events.LANGUAGE_MODULE_LOADED` is not yet available in themes, hence why
you have to use the string literal. However, if you want to do this from
your init.lua, you can use the constant.

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Fri 21 Jun 2013 - 15:53:57 EDT

This archive was generated by hypermail 2.2.0 : Sat 22 Jun 2013 - 06:29:38 EDT