Add reverse option (#55)
This commit is contained in:
parent
79b874e147
commit
8be854d3ba
3
comp.go
3
comp.go
@ -56,6 +56,9 @@ var (
|
||||
"preview",
|
||||
"nopreview",
|
||||
"preview!",
|
||||
"reverse",
|
||||
"noreverse",
|
||||
"reverse!",
|
||||
"scrolloff",
|
||||
"tabstop",
|
||||
"filesep",
|
||||
|
1
doc.go
1
doc.go
@ -51,6 +51,7 @@ The following options can be used to customize the behavior of lf:
|
||||
dirfirst bool (default on)
|
||||
hidden bool (default off)
|
||||
preview bool (default on)
|
||||
reverse bool (default off)
|
||||
scrolloff int (default 0)
|
||||
tabstop int (default 8)
|
||||
filesep string (default ":")
|
||||
|
@ -55,6 +55,7 @@ The following options can be used to customize the behavior of lf:
|
||||
dirfirst bool (default on)
|
||||
hidden bool (default off)
|
||||
preview bool (default on)
|
||||
reverse bool (default off)
|
||||
scrolloff int (default 0)
|
||||
tabstop int (default 8)
|
||||
filesep string (default ":")
|
||||
|
9
eval.go
9
eval.go
@ -35,6 +35,15 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.preview = false
|
||||
case "preview!":
|
||||
gOpts.preview = !gOpts.preview
|
||||
case "reverse":
|
||||
gOpts.reverse = true
|
||||
app.nav.renew(app.nav.height)
|
||||
case "noreverse":
|
||||
gOpts.reverse = false
|
||||
app.nav.renew(app.nav.height)
|
||||
case "reverse!":
|
||||
gOpts.reverse = !gOpts.reverse
|
||||
app.nav.renew(app.nav.height)
|
||||
case "scrolloff":
|
||||
n, err := strconv.Atoi(e.val)
|
||||
if err != nil {
|
||||
|
6
nav.go
6
nav.go
@ -66,6 +66,12 @@ func getFilesSorted(path string) []*file {
|
||||
log.Printf("unknown sorting type: %s", gOpts.sortby)
|
||||
}
|
||||
|
||||
if gOpts.reverse {
|
||||
for i, j := 0, len(fi)-1; i < j; i, j = i+1, j-1 {
|
||||
fi[i], fi[j] = fi[j], fi[i]
|
||||
}
|
||||
}
|
||||
|
||||
if gOpts.dirfirst {
|
||||
sortFilesStable(fi, func(i, j int) bool {
|
||||
if fi[i].IsDir() == fi[j].IsDir() {
|
||||
|
2
opts.go
2
opts.go
@ -6,6 +6,7 @@ var gOpts struct {
|
||||
dirfirst bool
|
||||
hidden bool
|
||||
preview bool
|
||||
reverse bool
|
||||
scrolloff int
|
||||
tabstop int
|
||||
filesep string
|
||||
@ -24,6 +25,7 @@ func init() {
|
||||
gOpts.dirfirst = true
|
||||
gOpts.hidden = false
|
||||
gOpts.preview = true
|
||||
gOpts.reverse = false
|
||||
gOpts.scrolloff = 0
|
||||
gOpts.tabstop = 8
|
||||
gOpts.filesep = ":"
|
||||
|
Loading…
Reference in New Issue
Block a user