Re: [textadept] Re: Set the font size from home directroy

From: Robert <ro....at.web.de>
Date: Fri, 9 Jul 2010 20:08:07 +0200

On Fri, Jul 9, 2010 at 4:16 PM, mitchell <c....at.caladbolg.net> wrote:
> On Wed, 30 Jun 2010, Robert wrote:
>
>> Hi,
>>
>> an idea for simplifying slight theme modifications (without having to
>> copy themes):
>> A file ~/.textadept/themes/buffer.lua could be processed (if it
>> exists) after the usual theme loading for opened files or new buffers.
>> There one could simply have, e.g.
>>
>> [snip]
>>
>> Maybe, a themes/view.lua as well?
>
> Having separate ~/.textadept/{buffer,view}.lua would just cause more
> confusion I think.
>
>>
>> Another thing I experimented with this morning is the setting of the
>> theme. I put the following function in core/init.lua:
>>
>> [snip]
>>
>> So I can switch_theme('light') from the command entry.
>> Is there another way to trigger whatever it is that is happening when
>> a new buffer is created?
>
> events.emit('buffer_new') should work I think.
>
>> The only issue I encountered so far is when switching to the Scite
>> theme as some things are defined/undefined in their view.luas so some
>> settings from the old theme persist. Is there a way to reset every
>> theming?
>
> Not without writing code to reset the buffer and view defaults.
>
>> (And if no session files are loaded, the default light theme
>> is loaded, the "set_theme" is only applied once I open a file)
>> I think it would be nice to have functionality like this (maybe in
>> 3.1), one could have the themes selectable in the menu, switch themes
>> in init.lua adjusted to day time :-)
>
> An interesting idea, but I'm not sure the added complexity is worth it. I'd
> be curious to see a refined version though.
>
> mitchell
>

Thanks for the hints with the theme switching, I'll try them out.
As for the minor theme modifications. I experimented a bit with having
an environment variable
with buffer properties (which was not working well) and with the
following (in my init.lua):

function set_buffer_properties()
  local buffer = buffer
  local c = _SCINTILLA.constants
  buffer.zoom = 1
  buffer.indent = 2
  buffer.edge_column = 80
  buffer.edge_mode = 1
  buffer.margin_width_n[0] = 4 + 3 * -- line number margin
    buffer:text_width(c.STYLE_LINENUMBER, '9')
end

events.connect('file_opened', set_buffer_properties)
events.connect('buffer_new', set_buffer_properties)
events.connect('view_new', set_buffer_properties)
events.connect('reset_after', function ()
  for i=1, #_VIEWS do
    gui.goto_view(1, false)
    view:focus()
    set_buffer_properties()
  end
end)

The last function is only necessary to have changes applied in all
views. Just like the function in the language modules
"set_buffer_properties" could be used for global modifications without
having to change the theme files.
There are some modules that require changes to the theme, multi-edit
and line wrap, and there have been quite a few questions on the
mailing list how to do minor theme modifications. Maybe this could be
the way to get this functionality, maybe an empty function could be
added to the user init.lua when it is created.

Robert
Received on Fri 09 Jul 2010 - 14:08:07 EDT

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:49:13 EST