Skip to content

Commit

Permalink
Clean image preview on set preview!
Browse files Browse the repository at this point in the history
Properly clean (`ueberzug`) image preview when disabling it using
for example `set preview!`.

Also change "clearing" to "cleaning" in docs.
  • Loading branch information
jdujava committed Jul 19, 2023
1 parent 23418ad commit e227b89
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ Set the path of a cleaner file.
The file should be executable.
This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled.
Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
Preview clearing is disabled when the value of this option is left empty.
Preview cleaning is disabled when the value of this option is left empty.
cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
Expand Down
2 changes: 1 addition & 1 deletion docstring.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,12 +611,14 @@ func (e *setExpr) eval(app *app, args []string) {
app.ui.echoerr("preview: value should be empty, 'true', or 'false'")
return
}
app.ui.loadFile(app, true)
case "nopreview":
if e.val != "" {
app.ui.echoerrf("nopreview: unexpected value: %s", e.val)
return
}
gOpts.preview = false
app.ui.loadFile(app, true)
case "preview!":
if e.val != "" {
app.ui.echoerrf("preview!: unexpected value: %s", e.val)
Expand All @@ -627,6 +629,7 @@ func (e *setExpr) eval(app *app, args []string) {
return
}
gOpts.preview = !gOpts.preview
app.ui.loadFile(app, true)
case "previewer":
gOpts.previewer = replaceTilde(e.val)
case "promptfmt":
Expand Down
2 changes: 1 addition & 1 deletion lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ Format string of the box drawing characters enabled by the `drawbox` option.
cleaner string (default '') (not called if empty)
.EE
.PP
Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled. Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. Preview clearing is disabled when the value of this option is left empty.
Set the path of a cleaner file. The file should be executable. This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled. Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. Preview cleaning is disabled when the value of this option is left empty.
.PP
.EX
cursoractivefmt string (default "\e033[7m")
Expand Down
8 changes: 4 additions & 4 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,14 +696,14 @@ func (ui *ui) loadFile(app *app, volatile bool) {
onSelect(app)
}

if !gOpts.preview {
return
}

if volatile {
app.nav.previewChan <- ""
}

if !gOpts.preview {
return
}

if curr.IsDir() {
ui.dirPrev = app.nav.loadDir(curr.path)
} else if curr.Mode().IsRegular() {
Expand Down

0 comments on commit e227b89

Please sign in to comment.