export files and options for previewer and cleaner

cc #626
This commit is contained in:
Gokcehan 2022-01-27 22:08:13 +03:00
parent 1bb7a17c81
commit 18fb632efa
2 changed files with 15 additions and 12 deletions

13
app.go
View File

@ -448,17 +448,6 @@ func (app *app) loop() {
} }
} }
func (app *app) exportFiles() {
var currFile string
if curr, err := app.nav.currFile(); err == nil {
currFile = curr.path
}
currSelections := app.nav.currSelections()
exportFiles(currFile, currSelections, app.nav.currDir().path)
}
// This function is used to run a shell command. Modes are as follows: // This function is used to run a shell command. Modes are as follows:
// //
// Prefix Wait Async Stdin Stdout Stderr UI action // Prefix Wait Async Stdin Stdout Stderr UI action
@ -467,7 +456,7 @@ func (app *app) exportFiles() {
// ! Yes No Yes Yes Yes Pause and then resume // ! Yes No Yes Yes Yes Pause and then resume
// & No Yes No No No Do nothing // & No Yes No No No Do nothing
func (app *app) runShell(s string, args []string, prefix string) { func (app *app) runShell(s string, args []string, prefix string) {
app.exportFiles() app.nav.exportFiles()
exportOpts() exportOpts()
cmd := shellCommand(s, args) cmd := shellCommand(s, args)

14
nav.go
View File

@ -518,6 +518,17 @@ func (nav *nav) position() {
} }
} }
func (nav *nav) exportFiles() {
var currFile string
if curr, err := nav.currFile(); err == nil {
currFile = curr.path
}
currSelections := nav.currSelections()
exportFiles(currFile, currSelections, nav.currDir().path)
}
func (nav *nav) previewLoop(ui *ui) { func (nav *nav) previewLoop(ui *ui) {
var prev string var prev string
for path := range nav.previewChan { for path := range nav.previewChan {
@ -532,6 +543,8 @@ func (nav *nav) previewLoop(ui *ui) {
} }
} }
if clear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview { if clear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview {
nav.exportFiles()
exportOpts()
cmd := exec.Command(gOpts.cleaner, prev) cmd := exec.Command(gOpts.cleaner, prev)
if err := cmd.Run(); err != nil { if err := cmd.Run(); err != nil {
log.Printf("cleaning preview: %s", err) log.Printf("cleaning preview: %s", err)
@ -568,6 +581,7 @@ func (nav *nav) preview(path string, win *win) {
var reader io.Reader var reader io.Reader
if len(gOpts.previewer) != 0 { if len(gOpts.previewer) != 0 {
nav.exportFiles()
exportOpts() exportOpts()
cmd := exec.Command(gOpts.previewer, path, cmd := exec.Command(gOpts.previewer, path,
strconv.Itoa(win.w), strconv.Itoa(win.w),