Re: [code] [textadept] New Theme and Settings Proposal

From: akshat jiwan <>
Date: Fri, 17 May 2013 13:38:32 +0800 (SGT)

This is great !! which version of text adept will implement this? I am still using an older version so I guess it is time for me to upgrade.  ________________________________ From: Mitchell <> To: Sent: Friday, 17 May 2013 11:00 AM Subject: [code] [textadept] New Theme and Settings Proposal Hi, I've been working on a new implementation for themes and settings and have something workable that I'd like to share as a proposal. Themes are now a single Lua file (e.g. light.lua). No more keeping track of buffer.lua, lexer.lua, and view.lua files. All color and style settings are done via buffer properties instead of the custom Lua tables in lexer.lua. This allows themes to share Textadept's Lua state instead of residing in a separate lexer Lua state. Here's an example:   local buffer = buffer   local property, property_int =, buffer.property_int   -- Normal colors.   property[''] = 0x4D4D99   property['color.yellow'] = 0x4D9999   property[''] = 0x4D994D   ...   -- Token styles.   property['style.nothing'] = ''   property['style.class'] = 'fore:$(color.yellow)'   property['style.comment'] = 'fore:$(color.grey)'   property['style.constant'] = 'fore:$('   property['style.error'] = 'fore:$(,italics'   ...   -- Caret and Selection Styles.   buffer:set_sel_fore(true, property_int['color.light_black'])   buffer:set_sel_back(true, property_int['color.light_grey']) Notice that view properties have access to theme colors now. It was so annoying matching colors in lexer.lua with view.lua... With the previous theme implementation, any changes, however small, required you to copy a theme to your *~/.textadept/themes/* and edit it. We know that for Lua modules at least, a *post_init.lua* file solves this issue. We can do something similar with themes now. Suppose I wanted to tweak the "error" style above to make the background color red instead of the foreground, but keep everything the same. I would create a *~/.textadept/themes/light.lua* with this:   dofile(_HOME..'/themes/light.lua')['style.error'] = 'back:$(,italic' Similarly I could tweak the default font and keep everything else the same:   dofile(_HOME..'/themes/light.lua')   local style =['style.default']   style = style..',font:DejaVu Sans Mono,size:11'['style.default'] = style In either case, I now add the following to my *~/.textadept/init.lua*:   gui.set_theme('light') This will load my modified light.lua theme, not Textadept's default one. So what about the old view.lua and buffer.lua? Are they still grouped in with themes? No :) Textadept has a new *settings.lua* that contains all non-color buffer properties. For example:   -- Multiple Selection and Virtual Space   buffer.multiple_selection = true   buffer.additional_selection_typing = true   ...   -- Line Number Margin.   local width = 4 * buffer:text_width(c.STYLE_LINENUMBER, '9')   buffer.margin_width_n[0] = width + (not CURSES and 4 or 0)   ...   -- Tabs and Indentation Guides.   -- Note: tab and indentation settings apply to individual buffers.   buffer.tab_width = 2   buffer.use_tabs = false   --buffer.indent = 2   buffer.tab_indents = true   buffer.back_space_un_indents = true   ... This *settings.lua* file is run every time a new buffer or view is created. If you have a *~/.textadept/settings.lua*, it will be run after Textadept's, so you have the option of overwriting Textadept's defaults. I am quite happy with cutting the legacy buffer and view settings crap out of themes and leaving them to be just colors. Those of you that have wanted this will be happy too I hope :) That and simpler theme modification by using buffer properties. I'm also happy to hide the separate lexer Lua state that causes confusion in themes and feels dirty. Perhaps *settings.lua* is a bit mis-leading since one might want to put module options in there (e.g. _M.textadept.editing.AUTO_PAIR), but I'm fairly confident the manual will make things clear. Thoughts and suggestions are very welcome. Cheers, Mitchell -- You are subscribed to To change subscription settings, send an e-mail to To unsubscribe, send an e-mail to

You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Fri 17 May 2013 - 01:38:32 EDT

This archive was generated by hypermail 2.2.0 : Fri 17 May 2013 - 06:53:01 EDT