parent
e86b8b34bd
commit
c19d3450a2
1
comp.go
1
comp.go
@ -20,6 +20,7 @@ var (
|
||||
"scrolloff",
|
||||
"tabstop",
|
||||
"ifs",
|
||||
"previewer",
|
||||
"shell",
|
||||
"showinfo",
|
||||
"sortby",
|
||||
|
2
eval.go
2
eval.go
@ -62,6 +62,8 @@ func (e *SetExpr) eval(app *App, args []string) {
|
||||
gOpts.tabstop = n
|
||||
case "ifs":
|
||||
gOpts.ifs = e.val
|
||||
case "previewer":
|
||||
gOpts.previewer = e.val
|
||||
case "shell":
|
||||
gOpts.shell = e.val
|
||||
case "showinfo":
|
||||
|
2
opts.go
2
opts.go
@ -6,6 +6,7 @@ type Opts struct {
|
||||
scrolloff int
|
||||
tabstop int
|
||||
ifs string
|
||||
previewer string
|
||||
shell string
|
||||
showinfo string
|
||||
sortby string
|
||||
@ -21,7 +22,6 @@ func init() {
|
||||
gOpts.preview = true
|
||||
gOpts.scrolloff = 0
|
||||
gOpts.tabstop = 8
|
||||
gOpts.ifs = ""
|
||||
gOpts.shell = envShell
|
||||
gOpts.showinfo = "none"
|
||||
gOpts.sortby = "name"
|
||||
|
13
ui.go
13
ui.go
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"sort"
|
||||
"strconv"
|
||||
@ -255,9 +256,19 @@ func (win *Win) printr(reg *os.File) error {
|
||||
return fmt.Errorf("printing regular file: %s", buf.Err())
|
||||
}
|
||||
|
||||
reg.Seek(0, 0)
|
||||
if len(gOpts.previewer) != 0 {
|
||||
cmd := exec.Command(gOpts.previewer, reg.Name())
|
||||
|
||||
out, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Printf("previewing file: %s", err)
|
||||
}
|
||||
|
||||
buf = bufio.NewScanner(bytes.NewReader(out))
|
||||
} else {
|
||||
reg.Seek(0, 0)
|
||||
buf = bufio.NewScanner(reg)
|
||||
}
|
||||
|
||||
for i := 0; i < win.h && buf.Scan(); i++ {
|
||||
win.print(2, i, fg, bg, buf.Text())
|
||||
|
Loading…
Reference in New Issue
Block a user