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.
This commit is contained in:
Ilya Grigoriev authored and GitHub committed 2022-11-13 16:54:54 +03:00
1 parent a94015d221
commit 48d1899ec8
4 files changed
+15 -9

No files matched your search

+4 -3
View File
@@ -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: If the 'mouse' option is enabled, mouse buttons have the following default effects:
Left mouse button 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 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 wheel
Scroll up or down. 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. 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: 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) w=$(tput cols)
if [ $w -le 80 ]; then if [ $w -le 80 ]; then
lf -remote "send $id set ratios 1:2" lf -remote "send $id set ratios 1:2"
+4 -3
View File
@@ -223,10 +223,10 @@ If the 'mouse' option is enabled, mouse buttons have the following default
effects: effects:
Left mouse button 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 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 wheel
Scroll up or down. 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 needs. For example, you can configure the number of columns in the ui with
respect to the terminal width as follows: 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) w=$(tput cols)
if [ $w -le 80 ]; then if [ $w -le 80 ]; then
lf -remote "send $id set ratios 1:2" lf -remote "send $id set ratios 1:2"
+4 -3
View File
@@ -247,12 +247,12 @@ If the 'mouse' option is enabled, mouse buttons have the following default effec
.PP .PP
.EX .EX
Left mouse button 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 .EE
.PP .PP
.EX .EX
Right mouse button Right mouse button
Enter a directory or open a file. Enter a directory or open a file. Also works on the preview window.
.EE .EE
.PP .PP
.EX .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: 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 .PP
.EX .EX
cmd recol %{{ cmd recol ${{
# Use ${{ instead of %{{ to work around https://github.com/gokcehan/lf/issues/718.
w=$(tput cols) w=$(tput cols)
if [ $w -le 80 ]; then if [ $w -le 80 ]; then
lf -remote "send $id set ratios 1:2" lf -remote "send $id set ratios 1:2"
+3
View File
@@ -1209,6 +1209,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
if err != nil { if err != nil {
return nil return nil
} else if !curr.IsDir() || gOpts.dirpreviews { } else if !curr.IsDir() || gOpts.dirpreviews {
if tev.Buttons() != tcell.Button2 {
return nil
}
return &callExpr{"open", nil, 1} return &callExpr{"open", nil, 1}
} }
dir = ui.dirPrev dir = ui.dirPrev