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

From: Mitchell <m.att.foicica.com>
Date: Mon, 20 May 2013 08:46:52 -0400 (EDT)

Robert,

On Sat, 18 May 2013, Robert wrote:

> Hi Mitchell,
>
> On Fri, May 17, 2013 at 7:30 AM, Mitchell <m.att.foicica.com> wrote:
>> 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.
>
> like everyone else I am very happy about the general direction of this.
> Some thoughts and ideas below.
>
>> Similarly I could tweak the default font and keep everything else the same:
>>
>> dofile(_HOME..'/themes/light.lua')
>> local style = buffer.property['style.default']
>> style = style..',font:DejaVu Sans Mono,size:11'
>> buffer.property['style.default'] = style
>>
>> In either case, I now add the following to my *~/.textadept/init.lua*:
>>
>> gui.set_theme('light')
>
> Would it somehow be possible to change fonts even more easily? For
> example globale variables
> _FONT = 'DejaVu Sans Mono'
> _FONTSIZE = 12
> to be set in *init.lua*?

No, I don't like the idea of cluttering the Lua State with more globals.
Besides, if a user sets _FONT or _FONTSIZE, do they expect the font to
change automatically? Or do they have to call an update() function? It's
tricky.

> Another option could be saving them along with the theme name in *theme*:
> -- Contents of theme:
> black
> DejaVu Sans Mono
> 12

That requires having and parsing a structured theme file which to me is a
no-no.

>> 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.
>
> How about calling it *properties.lua*? 'Buffer properties' and 'view
> properties' are already established terms in the manual and (to me at
> least) 'properties' sounds less "general" than 'settings'.

That's a great suggestion!

> Also, have you considered just using events? Or is this not possible,
> does *settings.lua* somehow need to be loaded from the lexer side as
> well?

I could definately use events, but I thought that having a list of
settings (preferrably in a separate file) that users could copy-paste into
their *~/.textadept/* and modify would be easier than having them look in
*core/gui.lua* for the correct `events.VIEW_NEW` or `events.BUFFER_NEW`
handler and copying the code into a new set of handlers in their
*init.lua*.

*settings.lua* does not need to be loaded from the lexer side. With this
new proposal, the "lexer side" stays separate from the "Textadept side".

> Changeset 1439 [1] introduces using events for setting the language
> module specific properties so this would fit in nicely. It could be
> bound to a THEME_SET event or something (to avoid the buffer and view
> specific distinction).

It's an interesting idea. I will investigate it.

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 Mon 20 May 2013 - 08:46:52 EDT

This archive was generated by hypermail 2.2.0 : Tue 21 May 2013 - 06:42:29 EDT