Re: Set the font size from home directroy

From: Robert <ro....at.web.de>
Date: Tue, 22 Jun 2010 22:33:11 +0200

On Tue, Jun 22, 2010 at 10:06 PM, Robert <ro....at.web.de> wrote:
> On Tue, Jun 22, 2010 at 5:25 PM, Ryan Pusztai <rpusz....at.gmail.com> wrote:
>> Mitchell,
>>
>> On Tue, Jun 22, 2010 at 11:04 AM, mitchell <mforal.n....at.gmail.com> wrote:
>>>
>>> Well the idea would be to pick the theme you like, copy it to your
>>> ~/.textadept/themes/ folder, and modify the theme from there. You do
>>> not have to modify 3 themes unless you use them all.
>>>
>>> Scintillua's lexer Lua state is separate from Textadept's, so the only
>>> way to modify fonts from init.lua would be through calls to Scintilla
>>> via buffer.style_*. However, I doubt those settings would persist.
>>>
>>
>> Thanks for the quick reply and explanation. It would be very nice if someday
>> it were possible to change things in the lexer, but I completely understand.
>> I will just make the theme "my own" (copy it from the install to
>>  ~/.textadept/themes/ directory)
>> --
>> Regards,
>> Ryan
>>
>
> You could add the following to your init.lua:
>
> events.connect('buffer_after_switch', function()
>  local c = _SCINTILLA.constants
>  local buffer = buffer
>  buffer.zoom = 2
>  buffer.margin_width_n[0] = 4 + 3 * buffer:text_width(c.STYLE_LINENUMBER, '9')
> end
> )
>
> This would (as an example) increase the font size by two points and
> should work even if you change your theme and without requiring you to
> copy over the theme files to your userhome.
>
> From luadoc:
> buffer.zoom: The zoom level added to all font sizes. +: magnify, -: reduce.
>
> It's a bit of a hack, and I'm not sure if that's the best event to
> connect this to. If you create a new view it has the default size
> again so you would have to connect to that too, connecting to
> buffer_new and file_opened would be another alternative.
> (How about chainable events, Mitchell?)
>
> I only tested this briefly but maybe this is an alternative.

Maybe like this in init.lua:
local function fontsize()
  local c = _SCINTILLA.constants
  local buffer = buffer
  buffer.zoom = 1
  buffer.margin_width_n[0] = 4 + 3 * buffer:text_width(c.STYLE_LINENUMBER, '9')
end

events.connect('buffer_after_switch', fontsize)
events.connect('view_after_switch', fontsize)

Using view and buffer has the advantage that you can change the
additional zoom in your init.lua, reset and after switching to the
next buffer you see the change (file_opened would require re-opening
or restart).

Robert
Received on Tue 22 Jun 2010 - 16:33:11 EDT

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