Add ability to use image previewers (#531)

* Return early on error in nav.preview

* nav.checkReg now returns a boolean instead of calling nav.preview

* Pass width, height, x, and y parameters to preview script

* Check previewer for exit code

If non-zero the preview will be assumed to have side-effects.

* Add the cleaner option

This is called upon selection changes if the previous preview was
volatile. To this end, volatilePreview was added to the nav struct
This commit is contained in:
neeshy authored and GitHub committed 2020-12-24 16:13:20 +03:00
1 parent c2fe88e9a0
commit 82f03102a5
9 files changed
+98 -25

No files matched your search

+9 -1
View File
@@ -118,6 +118,7 @@ The following options can be used to customize the behavior of lf:
period int (default 0)
preview bool (default on)
previewer string (default '')
cleaner string (default '')
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[1m%f\033[0m")
ratios []int (default '1:2:3')
relativenumber bool (default off)
@@ -591,10 +592,17 @@ Files containing the null character (U+0000) in the read portion are considered
Set the path of a previewer file to filter the content of regular files for previewing.
The file should be executable.
Two arguments are passed to the file, first is the current file name, and second is the height of preview pane.
Five arguments are passed to the file, first is the current file name; the second, third, fourth, and fifth are height, width, horizontal position, and vertical position of preview pane respectively.
SIGPIPE signal is sent when enough lines are read.
If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled. This means that if the file is selected in the future, the previewer is called once again.
Preview filtering is disabled and files are displayed as they are when the value of this option is left empty.
cleaner string (default '') (not called if empty)
Set the path of a cleaner file. This file will be called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled.
The file should be executable.
Preview clearing is disabled when the value of this option is left empty.
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%w/\033[0m\033[1m%f\033[0m")
Format string of the prompt shown in the top line.