sort directory preview when options are changed

This commit is contained in:
Gokcehan 2018-04-18 21:52:45 +03:00
parent 8eb9055622
commit 09b1daaade
2 changed files with 16 additions and 0 deletions

10
eval.go
View File

@ -20,12 +20,15 @@ func (e *setExpr) eval(app *app, args []string) {
case "dirfirst":
gOpts.dirfirst = true
app.nav.sort()
app.ui.sort()
case "nodirfirst":
gOpts.dirfirst = false
app.nav.sort()
app.ui.sort()
case "dirfirst!":
gOpts.dirfirst = !gOpts.dirfirst
app.nav.sort()
app.ui.sort()
case "drawbox":
gOpts.drawbox = true
app.ui.renew()
@ -47,12 +50,15 @@ func (e *setExpr) eval(app *app, args []string) {
case "hidden":
gOpts.hidden = true
app.nav.sort()
app.ui.sort()
case "nohidden":
gOpts.hidden = false
app.nav.sort()
app.ui.sort()
case "hidden!":
gOpts.hidden = !gOpts.hidden
app.nav.sort()
app.ui.sort()
case "ignorecase":
gOpts.ignorecase = true
case "noignorecase":
@ -68,12 +74,15 @@ func (e *setExpr) eval(app *app, args []string) {
case "reverse":
gOpts.reverse = true
app.nav.sort()
app.ui.sort()
case "noreverse":
gOpts.reverse = false
app.nav.sort()
app.ui.sort()
case "reverse!":
gOpts.reverse = !gOpts.reverse
app.nav.sort()
app.ui.sort()
case "smartcase":
gOpts.smartcase = true
case "nosmartcase":
@ -125,6 +134,7 @@ func (e *setExpr) eval(app *app, args []string) {
}
gOpts.sortby = e.val
app.nav.sort()
app.ui.sort()
case "timefmt":
gOpts.timefmt = e.val
case "ratios":

6
ui.go
View File

@ -449,6 +449,12 @@ func (ui *ui) renew() {
ui.menuWin.renew(wtot, 1, 0, htot-2)
}
func (ui *ui) sort() {
name := ui.dirPrev.name()
ui.dirPrev.sort()
ui.dirPrev.find(name, ui.wins[0].h)
}
func (ui *ui) print(msg string) {
ui.msg = msg
log.Print(msg)