From 48d1899ec88dce3ebf4203c2a74908981d1bca0f Mon Sep 17 00:00:00 2001 From: Ilya Grigoriev Date: Sun, 13 Nov 2022 05:54:54 -0800 Subject: [PATCH] When clicking on file preview, only open files on right-click (+ doc fix) (#975) * When clicking on file preview, only open files on right-click Currently, when mouse is on, I often click on the preview accidentally since it's such a large target. Moreover, there is very little space I can click without having the `lf` state change drastically (since I must click on the current file for the preview to stay the same). This commit prevents that. * (Minor): Change example in docs to work around a bug Currently, the example fails confusingly for newer versions of `tput`. See https://github.com/gokcehan/lf/issues/718. --- doc.go | 7 ++++--- docstring.go | 7 ++++--- lf.1 | 7 ++++--- ui.go | 3 +++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/doc.go b/doc.go index af9b9c04..3ae7a7e8 100644 --- a/doc.go +++ b/doc.go @@ -218,10 +218,10 @@ The following additional keybindings are provided by default: If the 'mouse' option is enabled, mouse buttons have the following default effects: Left mouse button - Click on a file or directory to select it. To open a file, click on the preview. + Click on a file or directory to select it. Right mouse button - Enter a directory or open a file. + Enter a directory or open a file. Also works on the preview window. Scroll wheel Scroll up or down. @@ -1204,7 +1204,8 @@ So now you can display a message in the current client by calling the following Since lf does not have control flow syntax, remote commands are used for such needs. For example, you can configure the number of columns in the ui with respect to the terminal width as follows: - cmd recol %{{ + cmd recol ${{ + # Use ${{ instead of %{{ to work around https://github.com/gokcehan/lf/issues/718. w=$(tput cols) if [ $w -le 80 ]; then lf -remote "send $id set ratios 1:2" diff --git a/docstring.go b/docstring.go index 58e0405e..90c13b53 100644 --- a/docstring.go +++ b/docstring.go @@ -223,10 +223,10 @@ If the 'mouse' option is enabled, mouse buttons have the following default effects: Left mouse button - Click on a file or directory to select it. To open a file, click on the preview. + Click on a file or directory to select it. Right mouse button - Enter a directory or open a file. + Enter a directory or open a file. Also works on the preview window. Scroll wheel Scroll up or down. @@ -1286,7 +1286,8 @@ Since lf does not have control flow syntax, remote commands are used for such needs. For example, you can configure the number of columns in the ui with respect to the terminal width as follows: - cmd recol %{{ + cmd recol ${{ + # Use ${{ instead of %{{ to work around https://github.com/gokcehan/lf/issues/718. w=$(tput cols) if [ $w -le 80 ]; then lf -remote "send $id set ratios 1:2" diff --git a/lf.1 b/lf.1 index c9e45853..798053b1 100644 --- a/lf.1 +++ b/lf.1 @@ -247,12 +247,12 @@ If the 'mouse' option is enabled, mouse buttons have the following default effec .PP .EX Left mouse button - Click on a file or directory to select it. To open a file, click on the preview. + Click on a file or directory to select it. .EE .PP .EX Right mouse button - Enter a directory or open a file. + Enter a directory or open a file. Also works on the preview window. .EE .PP .EX @@ -1435,7 +1435,8 @@ All clients have a unique id number but you may not be aware of the id number wh Since lf does not have control flow syntax, remote commands are used for such needs. For example, you can configure the number of columns in the ui with respect to the terminal width as follows: .PP .EX - cmd recol %{{ + cmd recol ${{ + # Use ${{ instead of %{{ to work around https://github.com/gokcehan/lf/issues/718. w=$(tput cols) if [ $w -le 80 ]; then lf -remote "send $id set ratios 1:2" diff --git a/ui.go b/ui.go index da15d474..f2c018a3 100644 --- a/ui.go +++ b/ui.go @@ -1209,6 +1209,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr { if err != nil { return nil } else if !curr.IsDir() || gOpts.dirpreviews { + if tev.Buttons() != tcell.Button2 { + return nil + } return &callExpr{"open", nil, 1} } dir = ui.dirPrev