Dirfirst option and numerical sorting (#27)
* Create option dirfirst, and add numerical sorting * Add only dirfirst option
This commit is contained in:
parent
d36e272272
commit
2345e16794
3
comp.go
3
comp.go
@ -49,6 +49,9 @@ var (
|
||||
"preview",
|
||||
"nopreview",
|
||||
"preview!",
|
||||
"dirfirst",
|
||||
"nodirfirst",
|
||||
"dirfirst!",
|
||||
"scrolloff",
|
||||
"tabstop",
|
||||
"ifs",
|
||||
|
1
doc.go
1
doc.go
@ -46,6 +46,7 @@ The following options can be used to customize the behavior of lf.
|
||||
|
||||
hidden bool (default off)
|
||||
preview bool (default on)
|
||||
dirfirst bool (default on)
|
||||
scrolloff int (default 0)
|
||||
tabstop int (default 8)
|
||||
ifs string (default "") (not exported if empty)
|
||||
|
@ -50,6 +50,7 @@ The following options can be used to customize the behavior of lf.
|
||||
|
||||
hidden bool (default off)
|
||||
preview bool (default on)
|
||||
dirfirst bool (default on)
|
||||
scrolloff int (default 0)
|
||||
tabstop int (default 8)
|
||||
ifs string (default "") (not exported if empty)
|
||||
|
9
eval.go
9
eval.go
@ -26,6 +26,15 @@ func (e *SetExpr) eval(app *App, args []string) {
|
||||
gOpts.preview = false
|
||||
case "preview!":
|
||||
gOpts.preview = !gOpts.preview
|
||||
case "dirfirst":
|
||||
gOpts.dirfirst = true
|
||||
app.nav.renew(app.nav.height)
|
||||
case "nodirfirst":
|
||||
gOpts.dirfirst = false
|
||||
app.nav.renew(app.nav.height)
|
||||
case "dirfirst!":
|
||||
gOpts.dirfirst = !gOpts.dirfirst
|
||||
app.nav.renew(app.nav.height)
|
||||
case "scrolloff":
|
||||
n, err := strconv.Atoi(e.val)
|
||||
if err != nil {
|
||||
|
6
nav.go
6
nav.go
@ -107,9 +107,11 @@ func organizeFiles(fi []os.FileInfo) []os.FileInfo {
|
||||
log.Printf("unknown sorting type: %s", gOpts.sortby)
|
||||
}
|
||||
|
||||
// TODO: these should be optional
|
||||
sort.Stable(ByNum(fi))
|
||||
if gOpts.dirfirst {
|
||||
sort.Stable(ByDir(fi))
|
||||
}
|
||||
//TODO this should be optional
|
||||
sort.Stable(ByNum(fi))
|
||||
|
||||
return fi
|
||||
}
|
||||
|
2
opts.go
2
opts.go
@ -10,6 +10,7 @@ var gOpts struct {
|
||||
shell string
|
||||
showinfo string
|
||||
sortby string
|
||||
dirfirst bool
|
||||
ratios []int
|
||||
keys map[string]Expr
|
||||
cmds map[string]Expr
|
||||
@ -23,6 +24,7 @@ func init() {
|
||||
gOpts.shell = envShell
|
||||
gOpts.showinfo = "none"
|
||||
gOpts.sortby = "name"
|
||||
gOpts.dirfirst = true
|
||||
gOpts.ratios = []int{1, 2, 3}
|
||||
|
||||
gOpts.keys = make(map[string]Expr)
|
||||
|
Loading…
Reference in New Issue
Block a user