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",
|
"preview",
|
||||||
"nopreview",
|
"nopreview",
|
||||||
"preview!",
|
"preview!",
|
||||||
|
"reverse",
|
||||||
|
"noreverse",
|
||||||
|
"reverse!",
|
||||||
"scrolloff",
|
"scrolloff",
|
||||||
"tabstop",
|
"tabstop",
|
||||||
"filesep",
|
"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)
|
dirfirst bool (default on)
|
||||||
hidden bool (default off)
|
hidden bool (default off)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
|
reverse bool (default off)
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
tabstop int (default 8)
|
tabstop int (default 8)
|
||||||
filesep string (default ":")
|
filesep string (default ":")
|
||||||
|
@ -55,6 +55,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
dirfirst bool (default on)
|
dirfirst bool (default on)
|
||||||
hidden bool (default off)
|
hidden bool (default off)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
|
reverse bool (default off)
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
tabstop int (default 8)
|
tabstop int (default 8)
|
||||||
filesep string (default ":")
|
filesep string (default ":")
|
||||||
|
9
eval.go
9
eval.go
@ -35,6 +35,15 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.preview = false
|
gOpts.preview = false
|
||||||
case "preview!":
|
case "preview!":
|
||||||
gOpts.preview = !gOpts.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":
|
case "scrolloff":
|
||||||
n, err := strconv.Atoi(e.val)
|
n, err := strconv.Atoi(e.val)
|
||||||
if err != nil {
|
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)
|
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 {
|
if gOpts.dirfirst {
|
||||||
sortFilesStable(fi, func(i, j int) bool {
|
sortFilesStable(fi, func(i, j int) bool {
|
||||||
if fi[i].IsDir() == fi[j].IsDir() {
|
if fi[i].IsDir() == fi[j].IsDir() {
|
||||||
|
2
opts.go
2
opts.go
@ -6,6 +6,7 @@ var gOpts struct {
|
|||||||
dirfirst bool
|
dirfirst bool
|
||||||
hidden bool
|
hidden bool
|
||||||
preview bool
|
preview bool
|
||||||
|
reverse bool
|
||||||
scrolloff int
|
scrolloff int
|
||||||
tabstop int
|
tabstop int
|
||||||
filesep string
|
filesep string
|
||||||
@ -24,6 +25,7 @@ func init() {
|
|||||||
gOpts.dirfirst = true
|
gOpts.dirfirst = true
|
||||||
gOpts.hidden = false
|
gOpts.hidden = false
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
|
gOpts.reverse = false
|
||||||
gOpts.scrolloff = 0
|
gOpts.scrolloff = 0
|
||||||
gOpts.tabstop = 8
|
gOpts.tabstop = 8
|
||||||
gOpts.filesep = ":"
|
gOpts.filesep = ":"
|
||||||
|
Loading…
Reference in New Issue
Block a user