Re: [code] [textadept] Number margin styling

From: Robert <>
Date: Sun, 11 Mar 2012 19:23:10 +0100

Hi Mitchell,

thank you.

On Sun, Mar 11, 2012 at 6:21 PM, Mitchell <> wrote:
> On Sun, 11 Mar 2012, Robert wrote:
>> so let's test this new list!
>> I'd like to get a visual cue which "view" is active. In the past I
>> used hiding the scroll bar on a view_{after, before}_switch event.
>> This didn't work too well because hiding the scroll bar can change how
>> long lines are displayed.
>> I thought about changing the number margin color. Is this possible? With
>> TextUI?
>> It might also be useful to hide the number margin for TextRedux dialog
>> buffers.
> I have found buffer.caret_line_visible to be useful in eyeballing the active
> view, but if the caret is scrolled out of position due to view splitting
> then this becomes problematic.
> You should be able to change the margin color on the fly using the
> buffer.style_fore and buffer.style_back tables for l.style_line_number (33),
> but it probably resets when re-styling the view so this may not be the most
> practical route.
> Mitchell
> --
This seems to work, except when creating new views, but that's not a
problem for me.

local line_number_back = buffer.style_back[33]
local current_line_back = buffer.caret_line_back

local function active()
  local buffer = buffer
  buffer.style_back[33] = current_line_back
  buffer.set_fold_margin_colour(1, current_line_back)
  buffer:set_fold_margin_hi_colour(1, current_line_back)

local function inactive()
  local buffer = buffer
  buffer.style_back[33] = line_number_back
  buffer.set_fold_margin_colour(1, line_number_back)
  buffer:set_fold_margin_hi_colour(1, line_number_back)

events.connect(events.VIEW_BEFORE_SWITCH, function() inactive() end)
events.connect(events.VIEW_AFTER_SWITCH, function() active() end)
events.connect(events.BUFFER_AFTER_SWITCH, function() active() end)


You are subscribed to
To change subscription settings, send an e-mail to
To unsubscribe, send an e-mail to
Received on Sun 11 Mar 2012 - 14:23:10 EDT

This archive was generated by hypermail 2.2.0 : Mon 12 Mar 2012 - 06:36:34 EDT