lf icon indicating copy to clipboard operation
lf copied to clipboard

Combine mouse keys

Open pzant opened this issue 10 months ago • 6 comments

Is it possible to combine mouse keys? I have bind : toggle, but I want use it with scroll or lkm for multiple selection, something like <m-3+m-down> :down; toggle.

pzant avatar Apr 22 '24 19:04 pzant

I don't think it's supported, the closest alternative I can find is to combine mouse keys with ctrl:

map <c-m-down> :down; toggle

joelim-work avatar Apr 23 '24 08:04 joelim-work

This makes no sense and I can't perform most actions with on hand with the mouse. So ctrl bind is not a solution.

pzant avatar Apr 23 '24 12:04 pzant

Mouse support was added in #963. I don't know the history behind the change, but I'm guessing mouse events aren't stored in ui.keyAcc because then it wouldn't be possible to map it to the default behavior, which is hard-coded since unlike key events, mouse events have the position (x, y coordinates) as additional context.

joelim-work avatar Apr 23 '24 17:04 joelim-work

This makes no sense and I can't perform most actions with on hand with the mouse. So ctrl bind is not a solution.

So after looking into this further, I have come to the conclusion that this kind of use case is actually what doesn't make much sense. I'm not sure which one it is, but you are looking to trigger an action either when:

  • <m-3> and <m-down> are pressed in sequence. It would be possible to change lf to do this, but it would be tedious and impractical to use, e.g. to select 10 files you would have to press <m-3>, followed by <m-down>, followed by <m-3> again, etc., repeating this 10 times.
  • <m-3> and <m-down> are pressed simultaneously. But this is simply not how mouse events work. Unlike ctrl, <m-3> is not a key modifier and trying to press it along with <m-down> will just generate two separate events, one for each key.

If you must use a mouse for everything, then the only other suggestion I have is to use <m-3> to set a 'mode' where scrolling also selects files, something like this:

set mouse

cmd enable_scroll_select :{{
    map <m-down> :down; toggle
    map <m-up> :toggle; up
    map <m-3> disable_scroll_select
}}

cmd disable_scroll_select :{{
    map <m-down> down
    map <m-up> up
    map <m-3> enable_scroll_select
}}

# set initial mode
disable_scroll_select

joelim-work avatar Apr 24 '24 08:04 joelim-work

@joelim-work Great solution, thanks! But still I think that in the future it is worth adding extended mouse binding.

pzant avatar Apr 24 '24 12:04 pzant

Yeah from a theoretical perspective, if it's possible to map sequences of keys (e.g. map ab for pressing a followed by b), then it should be possible to include mouse events as well (e.g. map a<m-1> for pressing a followed by mouse button 1). But I don't know how useful that would actually be in practice.

I guess this issue can be left open in case someone else is interested in this.

joelim-work avatar Apr 25 '24 04:04 joelim-work