diff --git a/client.go b/client.go index a9fcf6e7..0be507bd 100644 --- a/client.go +++ b/client.go @@ -21,6 +21,7 @@ func run() { } else if err = screen.Init(); err != nil { log.Fatalf("initializing screen: %s", err) } + screen.EnableMouse() f, err := os.Create(gLogPath) if err != nil { diff --git a/doc.go b/doc.go index 7d4f912f..126266f0 100644 --- a/doc.go +++ b/doc.go @@ -835,6 +835,24 @@ On these terminals, keys combined with the alt key are prefixed with 'a' charact Please note that, some key combinations are not possible due to the way terminals work (e.g. control and h combination sends a backspace key instead). The easiest way to find the name of a key combination is to press the key while lf is running and read the name of the key from the unknown mapping error. +Mouse buttons are prefixed with 'm' character: + + map down # primary + map down # secondary + map down # middle + map down + map down + map down + map down + map down + +Mouse wheel events are also prefixed with 'm' character: + + map down + map down + map down + map down + Push Mappings The usual way to map a key sequence is to assign it to a named or unnamed command. diff --git a/docstring.go b/docstring.go index 64b55405..54f5c5e8 100644 --- a/docstring.go +++ b/docstring.go @@ -909,6 +909,24 @@ instead). The easiest way to find the name of a key combination is to press the key while lf is running and read the name of the key from the unknown mapping error. +Mouse buttons are prefixed with 'm' character: + + map down # primary + map down # secondary + map down # middle + map down + map down + map down + map down + map down + +Mouse wheel events are also prefixed with 'm' character: + + map down + map down + map down + map down + Push Mappings diff --git a/lf.1 b/lf.1 index 6b2c0e24..effa7764 100644 --- a/lf.1 +++ b/lf.1 @@ -1004,6 +1004,28 @@ Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when .EE .PP Please note that, some key combinations are not possible due to the way terminals work (e.g. control and h combination sends a backspace key instead). The easiest way to find the name of a key combination is to press the key while lf is running and read the name of the key from the unknown mapping error. +.PP +Mouse buttons are prefixed with 'm' character: +.PP +.EX + map down # primary + map down # secondary + map down # middle + map down + map down + map down + map down + map down +.EE +.PP +Mouse wheel events are also prefixed with 'm' character: +.PP +.EX + map down + map down + map down + map down +.EE .SH PUSH MAPPINGS The usual way to map a key sequence is to assign it to a named or unnamed command. While this provides a clean way to remap builtin keys as well as other commands, it can be limiting at times. For this reason 'push' command is provided by lf. This command is used to simulate key pushes given as its arguments. You can 'map' a key to a 'push' command with an argument to create various keybindings. .PP diff --git a/ui.go b/ui.go index c2b8751e..61c99522 100644 --- a/ui.go +++ b/ui.go @@ -1018,6 +1018,44 @@ func (ui *ui) readNormalEvent(ev tcell.Event) expr { ui.menuBuf = listBinds(binds) return draw } + case *tcell.EventMouse: + var button string + + switch tev.Buttons() { + case tcell.Button1: + button = "" + case tcell.Button2: + button = "" + case tcell.Button3: + button = "" + case tcell.Button4: + button = "" + case tcell.Button5: + button = "" + case tcell.Button6: + button = "" + case tcell.Button7: + button = "" + case tcell.Button8: + button = "" + case tcell.WheelUp: + button = "" + case tcell.WheelDown: + button = "" + case tcell.WheelLeft: + button = "" + case tcell.WheelRight: + button = "" + case tcell.ButtonNone: + return nil + } + + expr, ok := gOpts.keys[button] + if ok { + return expr + } + + return nil case *tcell.EventResize: return &callExpr{"redraw", nil, 1} case *tcell.EventError: @@ -1084,6 +1122,7 @@ func (ui *ui) resume() { } else if err = screen.Init(); err != nil { log.Fatalf("initializing screen: %s", err) } + screen.EnableMouse() ui.screen = screen