Re: [code] MMB click on tab bar (FR)

From: Mitchell <m.att.foicica.com>
Date: Thu, 7 Nov 2019 12:45:59 -0500 (EST)

Hi Lukas,

On Fri, 13 Sep 2019, Procházka Lukáš Ing. wrote:

> Hello Mitchell,
>
> great news -
>
> On Thu, 12 Sep 2019 22:58:46 +0200, Mitchell <m.att.foicica.com> wrote:
>
>> Hi Lukas,
>>
>> On Wed, 11 Sep 2019, Procházka Lukáš Ing. wrote:
>>
>>> Hello Mitchell,
>>>
>>> many editors allow to close the active document clicking by the middle
>>> mouse
>>> button (MMB) on the document tab.
>>>
>>> Would it be possible to generate an event when user clicks by MMB on the
>>> tab
>>> bar, witch an additional info about buffer being clicked?
>>>
>>> (This is just a feature request, not necessary needs to be implemented.)
>>
>> Yes, it would be possible to generate such an event. Right now,
>> *src/textadept.c*'s `t_tabbuttonpress()` function discards any button
>> clicks except for right-click. You'd want to allow for middle-clicks and
>> then emit a new event into Textadept's Lua state, something like:
>>
>> lL_event(lua, "tab_middle_clicked", LUA_TNUMBER, page_num + 1, -1);
>>
>> where `page_num` is the page you determine was clicked (code that can help
>> is in `t_tabbuttonpress()`).
>
> - could it be implemented into the upcoming TA version?
>
> - Also an additional info about keys being pressed herewith (Ctrl/Shift/Alt)
> would be nice, maybe this:
>
> ----
> lL_event(lua, "tab_middle_clicked", LUA_TNUMBER, page_num + 1,
> event_mod(SHIFT), event_mod(CONTROL),
> event_mod(MOD1), event_mod(META), event_mod(LOCK),
> -1);
> ----
>
> (I'm using just the TA executables (with Lua add-ins) - and I'd rather not
> try to built the .exe from sources - I'm familiar with Visual Studio but not
> with MinGW nor other C-building tools.)

I've committed changes to the `events.TAB_CLICKED` event to include the mouse button number used[1], as well as any key modifiers held down. You will be able to close buffers on middle-click via something like:

   events.connect(events.TAB_CLICKED, function(button)
     if button == 2 then io.close_buffer() end
   end)

This will be in tonight's nightly build and in the next release.

Cheers,
Mitchell

[1]: https://foicica.com/hg/textadept/rev/38bfe9d21cdd

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 07 Nov 2019 - 12:45:59 EST

This archive was generated by hypermail 2.2.0 : Fri 08 Nov 2019 - 06:31:48 EST