From 13d19d84f9de0c0746fa2b68bdf4909744a045da Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Fri, 29 Jan 2021 19:36:27 +0300 Subject: [PATCH] add 'mouse' option to enable/disable mouse events cc #268 #570 --- client.go | 4 +++- complete.go | 3 +++ doc.go | 5 +++++ docstring.go | 5 +++++ eval.go | 18 ++++++++++++++++++ lf.1 | 7 +++++++ opts.go | 2 ++ ui.go | 4 +++- 8 files changed, 46 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 0be507bd..9fc56261 100644 --- a/client.go +++ b/client.go @@ -21,7 +21,9 @@ func run() { } else if err = screen.Init(); err != nil { log.Fatalf("initializing screen: %s", err) } - screen.EnableMouse() + if gOpts.mouse { + screen.EnableMouse() + } f, err := os.Create(gLogPath) if err != nil { diff --git a/complete.go b/complete.go index 5f85ab28..84110744 100644 --- a/complete.go +++ b/complete.go @@ -97,6 +97,9 @@ var ( "incsearch", "noincsearch", "incsearch!", + "mouse", + "nomouse", + "mouse!", "number", "nonumber", "number!", diff --git a/doc.go b/doc.go index b96c8f79..0c1a5044 100644 --- a/doc.go +++ b/doc.go @@ -114,6 +114,7 @@ The following options can be used to customize the behavior of lf: ignoredia bool (default on) incsearch bool (default off) info []string (default '') + mouse bool (default off) number bool (default off) period int (default 0) preview bool (default on) @@ -569,6 +570,10 @@ List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information. + mouse bool (default off) + +Send mouse events as input. + number bool (default off) Show the position number for directory items at the left side of pane. diff --git a/docstring.go b/docstring.go index 67ca426a..ab045fe2 100644 --- a/docstring.go +++ b/docstring.go @@ -117,6 +117,7 @@ The following options can be used to customize the behavior of lf: ignoredia bool (default on) incsearch bool (default off) info []string (default '') + mouse bool (default off) number bool (default off) period int (default 0) preview bool (default on) @@ -600,6 +601,10 @@ Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information. + mouse bool (default off) + +Send mouse events as input. + number bool (default off) Show the position number for directory items at the left side of pane. When diff --git a/eval.go b/eval.go index 346e6a48..f2b31f9f 100644 --- a/eval.go +++ b/eval.go @@ -110,6 +110,24 @@ func (e *setExpr) eval(app *app, args []string) { gOpts.incsearch = false case "incsearch!": gOpts.incsearch = !gOpts.incsearch + case "mouse": + if !gOpts.mouse { + gOpts.mouse = true + app.ui.screen.EnableMouse() + } + case "nomouse": + if gOpts.mouse { + gOpts.mouse = false + app.ui.screen.DisableMouse() + } + case "mouse!": + if gOpts.mouse { + gOpts.mouse = false + app.ui.screen.DisableMouse() + } else { + gOpts.mouse = true + app.ui.screen.EnableMouse() + } case "number": gOpts.number = true case "nonumber": diff --git a/lf.1 b/lf.1 index 21a56e94..cad48b3d 100644 --- a/lf.1 +++ b/lf.1 @@ -128,6 +128,7 @@ The following options can be used to customize the behavior of lf: ignoredia bool (default on) incsearch bool (default off) info []string (default '') + mouse bool (default off) number bool (default off) period int (default 0) preview bool (default on) @@ -691,6 +692,12 @@ Jump to the first match after each keystroke during searching. .PP List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information. .PP +.EX + mouse bool (default off) +.EE +.PP +Send mouse events as input. +.PP .EX number bool (default off) .EE diff --git a/opts.go b/opts.go index ce3ace02..0250e453 100644 --- a/opts.go +++ b/opts.go @@ -36,6 +36,7 @@ var gOpts struct { ignorecase bool ignoredia bool incsearch bool + mouse bool number bool preview bool relativenumber bool @@ -75,6 +76,7 @@ func init() { gOpts.ignorecase = true gOpts.ignoredia = true gOpts.incsearch = false + gOpts.mouse = false gOpts.number = false gOpts.preview = true gOpts.relativenumber = false diff --git a/ui.go b/ui.go index 1173f9c6..c59698d8 100644 --- a/ui.go +++ b/ui.go @@ -1122,7 +1122,9 @@ func (ui *ui) resume() { } else if err = screen.Init(); err != nil { log.Fatalf("initializing screen: %s", err) } - screen.EnableMouse() + if gOpts.mouse { + screen.EnableMouse() + } ui.screen = screen