Re: [textadept] Highlight matching braces

From: Robert <>
Date: Sat, 16 Oct 2010 11:16:49 +0200

On Fri, Oct 15, 2010 at 4:51 AM, mitchell <> wrote:

> Hi,
> On Wed, 6 Oct 2010, Robert wrote:
> On Tue, Sep 28, 2010 at 4:06 PM, mitchell <> wrote:
>>> Robert,
>>> currently ta highlights a brace if it is to the right of the cursor.
>>>> To have the highlighting as well when I'm before the brace, for
>>>> example to see which one was closed by the just inserted one
>>>> I came up with the attached solution. There are two ways to handle
>>>> being between two braces, for example Scite highlights the left, Gvim
>>>> the right one. I prefer Scite's way, for the aforementioned reason.
>>>> Would you consider this for inclusion?
>>> I like how SciTE does it too, and I would have implemented this a long
>>> time
>>> ago but I am concerned about performance. 'update_ui' is called A LOT.
>>> The
>>> more API calls that are made, the slower performance is. I haven't done a
>>> study, so maybe I'm too paranoid.
> I tried to implement this just now, but I have two problems: I use a block
> caret so a ((foo)) sequence with the caret on the second '(' results in an
> undesirable highlight. Also, for the caret on 'f' in (foo), brace matching
> (ctrl+e) does not work. Additional fixes would be necessary. I don't think
> the added complexity is worth it.
> mitchell
> Thanks for looking into this. How about, in the spirit of extensibility,
adding a return value to
the event connecting so that I could easily disable the default highlighting
without having a modified editing.lua? The latter would mean I would have to
keep track of changes in editing.lua in new releases and couldn't turn it
easily into a plugin.

In modules/textadept/editing.lua:
highlighting = events.connect('update_ui',
  function() -- highlights matching braces

In my init.lua/plugin:
events.disconnect('update_ui', _m.textadept.editing.highlighting)
events.connect('update_ui', my_highlight_match_braces_function)

As an alternative I could disable the setting "highlight_braces" and then
have my adapted function.
The same would apply to the strip whitespace before saving issue [1], so
thanks for introducing the "save_strips_ws".


Received on Sat 16 Oct 2010 - 05:16:49 EDT

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