fix option processing, async dirs & start select (#759)
This commit is contained in:
1 parent
b4637f91aa
commit
fb66a21577
3 files changed
+215
-142
No files matched your search
@@ -7,12 +7,12 @@ import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func (e *setExpr) eval(app *app, args []string) {
|
||||
// from app only app.ui.echo*() may be used inside this function
|
||||
switch e.opt {
|
||||
case "anchorfind":
|
||||
gOpts.anchorfind = true
|
||||
@@ -40,91 +40,70 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.dircounts = !gOpts.dircounts
|
||||
case "dironly":
|
||||
gOpts.dironly = true
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.pos = true
|
||||
gInvalidate.dir = true
|
||||
case "nodironly":
|
||||
gOpts.dironly = false
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.pos = true
|
||||
gInvalidate.dir = true
|
||||
case "dironly!":
|
||||
gOpts.dironly = !gOpts.dironly
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.pos = true
|
||||
gInvalidate.dir = true
|
||||
case "dirfirst":
|
||||
gOpts.sortType.option |= dirfirstSort
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "nodirfirst":
|
||||
gOpts.sortType.option &= ^dirfirstSort
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "dirfirst!":
|
||||
gOpts.sortType.option ^= dirfirstSort
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "drawbox":
|
||||
gOpts.drawbox = true
|
||||
app.ui.renew()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
app.nav.regCache = make(map[string]*reg)
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.navSize = true
|
||||
gInvalidate.dir = true
|
||||
case "nodrawbox":
|
||||
gOpts.drawbox = false
|
||||
app.ui.renew()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
app.nav.regCache = make(map[string]*reg)
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.navSize = true
|
||||
gInvalidate.dir = true
|
||||
case "drawbox!":
|
||||
gOpts.drawbox = !gOpts.drawbox
|
||||
app.ui.renew()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
app.nav.regCache = make(map[string]*reg)
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.navSize = true
|
||||
gInvalidate.dir = true
|
||||
case "globsearch":
|
||||
gOpts.globsearch = true
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "noglobsearch":
|
||||
gOpts.globsearch = false
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "globsearch!":
|
||||
gOpts.globsearch = !gOpts.globsearch
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "hidden":
|
||||
gOpts.sortType.option |= hiddenSort
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.pos = true
|
||||
gInvalidate.dir = true
|
||||
case "nohidden":
|
||||
gOpts.sortType.option &= ^hiddenSort
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.pos = true
|
||||
gInvalidate.dir = true
|
||||
case "hidden!":
|
||||
gOpts.sortType.option ^= hiddenSort
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.pos = true
|
||||
gInvalidate.dir = true
|
||||
case "icons":
|
||||
gOpts.icons = true
|
||||
case "noicons":
|
||||
@@ -133,31 +112,28 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.icons = !gOpts.icons
|
||||
case "ignorecase":
|
||||
gOpts.ignorecase = true
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "noignorecase":
|
||||
gOpts.ignorecase = false
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "ignorecase!":
|
||||
gOpts.ignorecase = !gOpts.ignorecase
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "ignoredia":
|
||||
gOpts.ignoredia = true
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "noignoredia":
|
||||
gOpts.ignoredia = false
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "ignoredia!":
|
||||
gOpts.ignoredia = !gOpts.ignoredia
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "incfilter":
|
||||
gOpts.incfilter = true
|
||||
case "noincfilter":
|
||||
@@ -173,21 +149,20 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
case "mouse":
|
||||
if !gOpts.mouse {
|
||||
gOpts.mouse = true
|
||||
app.ui.screen.EnableMouse()
|
||||
gInvalidate.mouse = true
|
||||
}
|
||||
case "nomouse":
|
||||
if gOpts.mouse {
|
||||
gOpts.mouse = false
|
||||
app.ui.screen.DisableMouse()
|
||||
gInvalidate.mouse = true
|
||||
}
|
||||
case "mouse!":
|
||||
if gOpts.mouse {
|
||||
gOpts.mouse = false
|
||||
app.ui.screen.DisableMouse()
|
||||
} else {
|
||||
gOpts.mouse = true
|
||||
app.ui.screen.EnableMouse()
|
||||
}
|
||||
gInvalidate.mouse = true
|
||||
case "number":
|
||||
gOpts.number = true
|
||||
case "nonumber":
|
||||
@@ -216,31 +191,28 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.relativenumber = !gOpts.relativenumber
|
||||
case "reverse":
|
||||
gOpts.sortType.option |= reverseSort
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "noreverse":
|
||||
gOpts.sortType.option &= ^reverseSort
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "reverse!":
|
||||
gOpts.sortType.option ^= reverseSort
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "smartcase":
|
||||
gOpts.smartcase = true
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "nosmartcase":
|
||||
gOpts.smartcase = false
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "smartcase!":
|
||||
gOpts.smartcase = !gOpts.smartcase
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "smartdia":
|
||||
gOpts.smartdia = true
|
||||
case "nosmartdia":
|
||||
@@ -283,12 +255,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
gOpts.period = n
|
||||
if n == 0 {
|
||||
app.ticker.Stop()
|
||||
} else {
|
||||
app.ticker.Stop()
|
||||
app.ticker = time.NewTicker(time.Duration(gOpts.period) * time.Second)
|
||||
}
|
||||
gInvalidate.period = true
|
||||
case "scrolloff":
|
||||
n, err := strconv.Atoi(e.val)
|
||||
if err != nil {
|
||||
@@ -329,10 +296,9 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
gOpts.hiddenfiles = toks
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.pos = true
|
||||
gInvalidate.dir = true
|
||||
case "ifs":
|
||||
gOpts.ifs = e.val
|
||||
case "info":
|
||||
@@ -377,7 +343,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
}
|
||||
gOpts.ratios = rats
|
||||
app.ui.wins = getWins(app.ui.screen)
|
||||
app.ui.loadFile(app.nav, true)
|
||||
gInvalidate.dir = true
|
||||
case "shell":
|
||||
gOpts.shell = e.val
|
||||
case "shellflag":
|
||||
@@ -408,8 +374,8 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerr("sortby: value should either be 'natural', 'name', 'size', 'time', 'atime', 'ctime' or 'ext'")
|
||||
return
|
||||
}
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
gInvalidate.sort = true
|
||||
gInvalidate.dir = true
|
||||
case "tempmarks":
|
||||
if e.val != "" {
|
||||
gOpts.tempmarks = "'" + e.val
|
||||
@@ -433,7 +399,6 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("unknown option: %s", e.opt)
|
||||
return
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
func (e *mapExpr) eval(app *app, args []string) {
|
||||
@@ -442,7 +407,6 @@ func (e *mapExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
gOpts.keys[e.keys] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
func (e *cmapExpr) eval(app *app, args []string) {
|
||||
@@ -451,7 +415,6 @@ func (e *cmapExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
gOpts.cmdkeys[e.key] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
func (e *cmdExpr) eval(app *app, args []string) {
|
||||
@@ -460,7 +423,6 @@ func (e *cmdExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
gOpts.cmds[e.name] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
func preChdir(app *app) {
|
||||
@@ -1294,6 +1256,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
if err != nil {
|
||||
log.Printf("getting current directory: %s", err)
|
||||
}
|
||||
log.Printf("todo-cd-eval %s", wd)
|
||||
|
||||
path = replaceTilde(path)
|
||||
if !filepath.IsAbs(path) {
|
||||
|
||||
Reference in new issue
Block a user