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", "wrapscan",
"nowrapscan", "nowrapscan",
"wrapscan!", "wrapscan!",
"wrapscroll",
"nowrapscroll",
"wrapscroll!",
"number", "number",
"nonumber", "nonumber",
"number!", "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) smartcase boolean (default on)
smartdia boolean (default off) smartdia boolean (default off)
wrapscan boolean (default on) wrapscan boolean (default on)
wrapscroll boolean (default off)
number boolean (default off) number boolean (default off)
relativenumber boolean (default off) relativenumber boolean (default off)
findlen integer (default 1) (zero to prompt until single match) 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) smartcase boolean (default on)
smartdia boolean (default off) smartdia boolean (default off)
wrapscan boolean (default on) wrapscan boolean (default on)
wrapscroll boolean (default off)
number boolean (default off) number boolean (default off)
relativenumber boolean (default off) relativenumber boolean (default off)
findlen integer (default 1) (zero to prompt until single match) 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 gOpts.wrapscan = false
case "wrapscan!": case "wrapscan!":
gOpts.wrapscan = !gOpts.wrapscan gOpts.wrapscan = !gOpts.wrapscan
case "wrapscroll":
gOpts.wrapscroll = true
case "nowrapscroll":
gOpts.wrapscroll = false
case "wrapscroll!":
gOpts.wrapscroll = !gOpts.wrapscroll
case "number": case "number":
gOpts.number = true gOpts.number = true
case "nonumber": 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) smartcase boolean (default on)
smartdia boolean (default off) smartdia boolean (default off)
wrapscan boolean (default on) wrapscan boolean (default on)
wrapscroll boolean (default off)
number boolean (default off) number boolean (default off)
relativenumber boolean (default off) relativenumber boolean (default off)
findlen integer (default 1) (zero to prompt until single match) 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() dir := nav.currDir()
if dir.ind == 0 { if dir.ind == 0 {
if gOpts.wrapscroll {
nav.bottom()
}
return return
} }
@ -462,6 +465,9 @@ func (nav *nav) down(dist int) {
maxind := len(dir.files) - 1 maxind := len(dir.files) - 1
if dir.ind >= maxind { if dir.ind >= maxind {
if gOpts.wrapscroll {
nav.top()
}
return return
} }

View File

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