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

6
ui.go
View File

@ -449,6 +449,12 @@ func (ui *ui) renew() {
ui.menuWin.renew(wtot, 1, 0, htot-2) 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) { func (ui *ui) print(msg string) {
ui.msg = msg ui.msg = msg
log.Print(msg) log.Print(msg)