add ignorecase option for case insensitive search

Mentioned in #69.
This commit is contained in:
Gokcehan 2017-07-15 17:18:37 +03:00
parent 9e69ce94ca
commit ca7a3ccab4
6 changed files with 16 additions and 0 deletions

View File

@ -59,6 +59,9 @@ var (
"hidden",
"nohidden",
"hidden!",
"ignorecase",
"noignorecase",
"ignorecase!",
"preview",
"nopreview",
"preview!",

1
doc.go
View File

@ -72,6 +72,7 @@ The following options can be used to customize the behavior of lf:
dirfirst boolean (default on)
globsearch boolean (default off)
hidden boolean (default off)
ignorecase boolean (default off)
preview boolean (default on)
reverse boolean (default off)
wrapscan boolean (default on)

View File

@ -76,6 +76,7 @@ The following options can be used to customize the behavior of lf:
dirfirst boolean (default on)
globsearch boolean (default off)
hidden boolean (default off)
ignorecase boolean (default off)
preview boolean (default on)
reverse boolean (default off)
wrapscan boolean (default on)

View File

@ -41,6 +41,12 @@ func (e *setExpr) eval(app *app, args []string) {
case "hidden!":
gOpts.hidden = !gOpts.hidden
app.nav.renew(app.nav.height)
case "ignorecase":
gOpts.ignorecase = true
case "noignorecase":
gOpts.ignorecase = false
case "ignorecase!":
gOpts.ignorecase = !gOpts.ignorecase
case "preview":
gOpts.preview = true
case "nopreview":

3
nav.go
View File

@ -369,6 +369,9 @@ func (nav *nav) cd(wd string) error {
}
func match(pattern, name string) (matched bool, err error) {
if gOpts.ignorecase {
pattern, name = strings.ToLower(pattern), strings.ToLower(name)
}
if gOpts.globsearch {
return filepath.Match(pattern, name)
} else {

View File

@ -7,6 +7,7 @@ var gOpts struct {
dirfirst bool
globsearch bool
hidden bool
ignorecase bool
preview bool
reverse bool
wrapscan bool
@ -30,6 +31,7 @@ func init() {
gOpts.dirfirst = true
gOpts.globsearch = false
gOpts.hidden = false
gOpts.ignorecase = false
gOpts.preview = true
gOpts.reverse = false
gOpts.wrapscan = true