gokcehan / lf

Terminal file manager
MIT License
7.67k stars 326 forks source link

Combine mouse keys #1692

Open pzant opened 5 months ago

pzant commented 5 months ago

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.

joelim-work commented 5 months ago

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
pzant commented 5 months ago

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

joelim-work commented 5 months ago

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 commented 5 months ago

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:


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
pzant commented 5 months ago

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

joelim-work commented 5 months ago

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.