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", "hidden",
"nohidden", "nohidden",
"hidden!", "hidden!",
"ignorecase",
"noignorecase",
"ignorecase!",
"preview", "preview",
"nopreview", "nopreview",
"preview!", "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) dirfirst boolean (default on)
globsearch boolean (default off) globsearch boolean (default off)
hidden boolean (default off) hidden boolean (default off)
ignorecase boolean (default off)
preview boolean (default on) preview boolean (default on)
reverse boolean (default off) reverse boolean (default off)
wrapscan boolean (default on) 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) dirfirst boolean (default on)
globsearch boolean (default off) globsearch boolean (default off)
hidden boolean (default off) hidden boolean (default off)
ignorecase boolean (default off)
preview boolean (default on) preview boolean (default on)
reverse boolean (default off) reverse boolean (default off)
wrapscan boolean (default on) wrapscan boolean (default on)

View File

@ -41,6 +41,12 @@ func (e *setExpr) eval(app *app, args []string) {
case "hidden!": case "hidden!":
gOpts.hidden = !gOpts.hidden gOpts.hidden = !gOpts.hidden
app.nav.renew(app.nav.height) app.nav.renew(app.nav.height)
case "ignorecase":
gOpts.ignorecase = true
case "noignorecase":
gOpts.ignorecase = false
case "ignorecase!":
gOpts.ignorecase = !gOpts.ignorecase
case "preview": case "preview":
gOpts.preview = true gOpts.preview = true
case "nopreview": 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) { func match(pattern, name string) (matched bool, err error) {
if gOpts.ignorecase {
pattern, name = strings.ToLower(pattern), strings.ToLower(name)
}
if gOpts.globsearch { if gOpts.globsearch {
return filepath.Match(pattern, name) return filepath.Match(pattern, name)
} else { } else {

View File

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