[code] [textadept] Theme enhancements in hg

From: Mitchell <m.att.foicica.com>
Date: Wed, 8 Jul 2020 10:40:03 -0400 (EDT)


I recently committed a change[1] that adds a more Lua-friendly API for themes, and will affect most uses of `view:set_theme()`.

Previously, themes would set colors and styles using `buffer.property` and retrieve colors via `buffer.property_int`. The use of formatted strings has always bothered me, so I added two new tables, `lexer.colors` and `lexer.styles` to define and access colors and styles, respectively. Themes are not required to use these tables, but they are available. For example, instead of:

   local property, property_int = buffer.property, buffer.property_int
   property['color.blue'] = 0xFF0000
   property['style.keyword'] = 'fore:$(color.blue),bold'
   view.edge_colour = property_int['color.grey']

you can write:

   local colors, styles = lexer.colors, lexer.styles
   colors.blue = 0xFF0000
   styles.keyword = {fore = colors.blue, bold = true}
   view.edge_color = colors.grey

With respect to `view:set_theme()` changes, additional properties are now passed as global variables available within a theme (instead of as a property). If you were using the `fontsize` option for overriding the default font size, you'll need to use `size` instead.

   view:set_theme('dark', {font = 'MyFont', fontsize = 14})


   view:set_theme('dark', {font = 'MyFont', size = 14})

Lexers with custom styles may also utilize `lexer.colors` and `lexer.styles` with `lex:add_style()`. An example is here[2].

These changes are available in the current set of nightly builds.


[1]: https://foicica.com/hg/textadept/rev/9d1d413a6edc
[2]: https://foicica.com/hg/scintilla/diff/d51c7ec9ec78/lexlua/diff.lua

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 Wed 08 Jul 2020 - 10:40:03 EDT

This archive was generated by hypermail 2.2.0 : Thu 09 Jul 2020 - 06:34:23 EDT