Add Wrap Scroll functionality. Fixes #126 (#166)

This commit is contained in:
David Pedersen 2019-05-12 16:21:45 +02:00 committed by gokcehan
parent 13fe1931cd
commit e815adc6a6
7 changed files with 20 additions and 0 deletions

View File

@ -108,6 +108,9 @@ var (
"wrapscan",
"nowrapscan",
"wrapscan!",
"wrapscroll",
"nowrapscroll",
"wrapscroll!",
"number",
"nonumber",
"number!",

1
doc.go
View File

@ -111,6 +111,7 @@ The following options can be used to customize the behavior of lf:
smartcase boolean (default on)
smartdia boolean (default off)
wrapscan boolean (default on)
wrapscroll boolean (default off)
number boolean (default off)
relativenumber boolean (default off)
findlen integer (default 1) (zero to prompt until single match)

View File

@ -114,6 +114,7 @@ The following options can be used to customize the behavior of lf:
smartcase boolean (default on)
smartdia boolean (default off)
wrapscan boolean (default on)
wrapscroll boolean (default off)
number boolean (default off)
relativenumber boolean (default off)
findlen integer (default 1) (zero to prompt until single match)

View File

@ -143,6 +143,12 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.wrapscan = false
case "wrapscan!":
gOpts.wrapscan = !gOpts.wrapscan
case "wrapscroll":
gOpts.wrapscroll = true
case "nowrapscroll":
gOpts.wrapscroll = false
case "wrapscroll!":
gOpts.wrapscroll = !gOpts.wrapscroll
case "number":
gOpts.number = true
case "nonumber":

1
lf.1
View File

@ -126,6 +126,7 @@ The following options can be used to customize the behavior of lf:
smartcase boolean (default on)
smartdia boolean (default off)
wrapscan boolean (default on)
wrapscroll boolean (default off)
number boolean (default off)
relativenumber boolean (default off)
findlen integer (default 1) (zero to prompt until single match)

6
nav.go
View File

@ -445,6 +445,9 @@ func (nav *nav) up(dist int) {
dir := nav.currDir()
if dir.ind == 0 {
if gOpts.wrapscroll {
nav.bottom()
}
return
}
@ -462,6 +465,9 @@ func (nav *nav) down(dist int) {
maxind := len(dir.files) - 1
if dir.ind >= maxind {
if gOpts.wrapscroll {
nav.top()
}
return
}

View File

@ -37,6 +37,7 @@ var gOpts struct {
ignoredia bool
smartdia bool
wrapscan bool
wrapscroll bool
number bool
relativenumber bool
findlen int
@ -72,6 +73,7 @@ func init() {
gOpts.ignoredia = false
gOpts.smartdia = false
gOpts.wrapscan = true
gOpts.wrapscroll = false
gOpts.number = false
gOpts.relativenumber = false
gOpts.findlen = 1