Re: Key bindings

From: Brian Schott <briancsch....at.gmail.com>
Date: Wed, 03 Feb 2010 20:08:39 -0800

If I do this:

keys['s('] = {function() if buffer.get_sel_text() ~= '' then
m_editing.enclose("parens") end end}

or this:

keys['s('] = {function() if buffer.get_sel_text() == '' then return true
else m_editing.enclose("parens") end end}

it becomes impossible to insert a '(' character into the buffer. "return
false" seems to be the only way to allow the event to be handled further.

On 02/03/10 19:41, mitchell wrote:
> Brian,
>
>> The "return false" part of the function there signals to Textadept that
>> it should let other input handlers handle the event.
>
> This is not the case (at least it shouldn't be!). According to LuaDoc:
>
> Events can be given any number of arguments. These arguments will be
> passed to the event's handler functions. If a handler returns either
> true or false explicitly, all subsequent handlers are not called. This
> is useful if you want to stop the propagation of an event like a
> keypress.
>
> Mitchell
>
>> If there's a
>> selection, the selection is enclosed in brackets, otherwise it just goes
>> on to add the character. (You may have noticed that I modified the
>> "enclose_in" function to do a few extra things such as C-style /* */
>> comments.)
>>
>> On 02/03/10 09:15, Rob wrote:
>>
>>> Thanks for the update and sharing the key commands.
>>> Brian, what is the expected output if nothing is selected and you type
>>> for example a bracket? Did you disable the automatic closing of
>>> quotes, brackets etc.?
>
Received on Wed 03 Feb 2010 - 23:08:39 EST

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