Bind Ctrl+MouseWheel to scroll up/down (#1051)
On my system, Shift+Mouse is captured by the terminal and
Alt+Mouse only works for one of the alt keys. Hence I picked
Ctrl.
This also allows binding of Ctrl+MouseButtons (but doesn't set
any such bindings).
As a minor bonus, that should allow using Ctrl+Click to select
`lf`'s terminal without moving the cursor no matter where you
click. On tmux, this doesn't work out of the box and requires
a change to `tmux.conf` along the following lines:
bind-key -T root C-MouseDown1Pane select-pane -t = \; send-keys -M
You can omit the `send-keys -M` if you never want to pass
`Ctrl+Click` to any of your terminal apps. (Then it will work
without this PR).
This commit is contained in:
1 parent
a4fa5d36c9
commit
2fe5e4d54e
5 files changed
+14
-6
No files matched your search
@@ -226,7 +226,7 @@ If the 'mouse' option is enabled, mouse buttons have the following default effec
|
||||
Enter a directory or open a file. Also works on the preview window.
|
||||
|
||||
Scroll wheel
|
||||
Scroll up or down.
|
||||
Move up or down. If Ctrl is pressed, scroll up or down.
|
||||
|
||||
# Configuration
|
||||
|
||||
|
||||
+1
-1
@@ -231,7 +231,7 @@ effects:
|
||||
Enter a directory or open a file. Also works on the preview window.
|
||||
|
||||
Scroll wheel
|
||||
Scroll up or down.
|
||||
Move up or down. If Ctrl is pressed, scroll up or down.
|
||||
|
||||
# Configuration
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ If the 'mouse' option is enabled, mouse buttons have the following default effec
|
||||
.PP
|
||||
.EX
|
||||
Scroll wheel
|
||||
Scroll up or down.
|
||||
Move up or down. If Ctrl is pressed, scroll up or down.
|
||||
.EE
|
||||
.SH CONFIGURATION
|
||||
Configuration files should be located at:
|
||||
|
||||
@@ -139,6 +139,7 @@ func init() {
|
||||
gOpts.keys["<c-b>"] = &callExpr{"page-up", nil, 1}
|
||||
gOpts.keys["<pgup>"] = &callExpr{"page-up", nil, 1}
|
||||
gOpts.keys["<c-y>"] = &callExpr{"scroll-up", nil, 1}
|
||||
gOpts.keys["<c-m-up>"] = &callExpr{"scroll-up", nil, 1}
|
||||
gOpts.keys["j"] = &callExpr{"down", nil, 1}
|
||||
gOpts.keys["<down>"] = &callExpr{"down", nil, 1}
|
||||
gOpts.keys["<m-down>"] = &callExpr{"down", nil, 1}
|
||||
@@ -146,6 +147,7 @@ func init() {
|
||||
gOpts.keys["<c-f>"] = &callExpr{"page-down", nil, 1}
|
||||
gOpts.keys["<pgdn>"] = &callExpr{"page-down", nil, 1}
|
||||
gOpts.keys["<c-e>"] = &callExpr{"scroll-down", nil, 1}
|
||||
gOpts.keys["<c-m-down>"] = &callExpr{"scroll-down", nil, 1}
|
||||
gOpts.keys["h"] = &callExpr{"updir", nil, 1}
|
||||
gOpts.keys["<left>"] = &callExpr{"updir", nil, 1}
|
||||
gOpts.keys["l"] = &callExpr{"open", nil, 1}
|
||||
|
||||
@@ -1182,12 +1182,18 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
||||
case tcell.ButtonNone:
|
||||
return nil
|
||||
}
|
||||
if tev.Modifiers() == tcell.ModCtrl {
|
||||
button = "<c-" + button[1:]
|
||||
}
|
||||
if expr, ok := gOpts.keys[button]; ok {
|
||||
return expr
|
||||
}
|
||||
|
||||
if tev.Buttons() != tcell.Button1 && tev.Buttons() != tcell.Button2 {
|
||||
return nil
|
||||
if button != "<m-1>" && button != "<m-2>" {
|
||||
ui.echoerrf("unknown mapping: %s", button)
|
||||
ui.keyAcc = nil
|
||||
ui.keyCount = nil
|
||||
ui.menuBuf = nil
|
||||
return draw
|
||||
}
|
||||
|
||||
x, y := tev.Position()
|
||||
|
||||
Reference in new issue
Block a user