Clean image preview on set preview! (#1350)

Properly clean (`ueberzug`) image preview when disabling it using
for example `set preview!`.

Also change "clearing" to "cleaning" in docs.
This commit is contained in:
Jonáš Dujava authored and GitHub committed 2023-07-22 14:24:35 +03:00
1 parent 23418adc00
commit 42c16f1882
5 files changed
+10 -7

No files matched your search

+1 -1
View File
@@ -674,7 +674,7 @@ Set the path of a cleaner file.
The file should be executable. 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. 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. 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") cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m") cursorparentfmt string (default "\033[7m")
+1 -1
View File
@@ -706,7 +706,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 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 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, file, (1) current file name, (2) width, (3) height, (4) horizontal position,
and (5) vertical position of preview pane respectively. Preview clearing is and (5) vertical position of preview pane respectively. Preview cleaning is
disabled when the value of this option is left empty. disabled when the value of this option is left empty.
cursoractivefmt string (default "\033[7m") cursoractivefmt string (default "\033[7m")
+3
View File
@@ -611,12 +611,14 @@ func (e *setExpr) eval(app *app, args []string) {
app.ui.echoerr("preview: value should be empty, 'true', or 'false'") app.ui.echoerr("preview: value should be empty, 'true', or 'false'")
return return
} }
app.ui.loadFile(app, true)
case "nopreview": case "nopreview":
if e.val != "" { if e.val != "" {
app.ui.echoerrf("nopreview: unexpected value: %s", e.val) app.ui.echoerrf("nopreview: unexpected value: %s", e.val)
return return
} }
gOpts.preview = false gOpts.preview = false
app.ui.loadFile(app, true)
case "preview!": case "preview!":
if e.val != "" { if e.val != "" {
app.ui.echoerrf("preview!: unexpected value: %s", e.val) app.ui.echoerrf("preview!: unexpected value: %s", e.val)
@@ -627,6 +629,7 @@ func (e *setExpr) eval(app *app, args []string) {
return return
} }
gOpts.preview = !gOpts.preview gOpts.preview = !gOpts.preview
app.ui.loadFile(app, true)
case "previewer": case "previewer":
gOpts.previewer = replaceTilde(e.val) gOpts.previewer = replaceTilde(e.val)
case "promptfmt": case "promptfmt":
+1 -1
View File
@@ -825,7 +825,7 @@ Format string of the box drawing characters enabled by the `drawbox` option.
cleaner string (default '') (not called if empty) cleaner string (default '') (not called if empty)
.EE .EE
.PP .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 .PP
.EX .EX
cursoractivefmt string (default "\e033[7m") cursoractivefmt string (default "\e033[7m")
+4 -4
View File
@@ -696,14 +696,14 @@ func (ui *ui) loadFile(app *app, volatile bool) {
onSelect(app) onSelect(app)
} }
if !gOpts.preview {
return
}
if volatile { if volatile {
app.nav.previewChan <- "" app.nav.previewChan <- ""
} }
if !gOpts.preview {
return
}
if curr.IsDir() { if curr.IsDir() {
ui.dirPrev = app.nav.loadDir(curr.path) ui.dirPrev = app.nav.loadDir(curr.path)
} else if curr.Mode().IsRegular() { } else if curr.Mode().IsRegular() {