parent
af113e71ef
commit
f7e778591a
2
comp.go
2
comp.go
@ -31,6 +31,8 @@ var (
|
|||||||
"read-shell-async",
|
"read-shell-async",
|
||||||
"search",
|
"search",
|
||||||
"search-back",
|
"search-back",
|
||||||
|
"search-next",
|
||||||
|
"search-prev",
|
||||||
"toggle",
|
"toggle",
|
||||||
"invert",
|
"invert",
|
||||||
"yank",
|
"yank",
|
||||||
|
2
doc.go
2
doc.go
@ -29,6 +29,8 @@ The following commands are provided by lf with default keybindings:
|
|||||||
read-shell-async (default "&")
|
read-shell-async (default "&")
|
||||||
search (default "/")
|
search (default "/")
|
||||||
search-back (default "?")
|
search-back (default "?")
|
||||||
|
search-next (default "n")
|
||||||
|
search-prev (default "N")
|
||||||
toggle (default "<space>")
|
toggle (default "<space>")
|
||||||
invert (default "v")
|
invert (default "v")
|
||||||
yank (default "y")
|
yank (default "y")
|
||||||
|
@ -33,6 +33,8 @@ The following commands are provided by lf with default keybindings:
|
|||||||
read-shell-async (default "&")
|
read-shell-async (default "&")
|
||||||
search (default "/")
|
search (default "/")
|
||||||
search-back (default "?")
|
search-back (default "?")
|
||||||
|
search-next (default "n")
|
||||||
|
search-prev (default "N")
|
||||||
toggle (default "<space>")
|
toggle (default "<space>")
|
||||||
invert (default "v")
|
invert (default "v")
|
||||||
yank (default "y")
|
yank (default "y")
|
||||||
|
12
eval.go
12
eval.go
@ -262,6 +262,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.cmdpref = "/"
|
app.ui.cmdpref = "/"
|
||||||
case "search-back":
|
case "search-back":
|
||||||
app.ui.cmdpref = "?"
|
app.ui.cmdpref = "?"
|
||||||
|
case "search-next":
|
||||||
|
app.nav.searchNext()
|
||||||
|
case "search-prev":
|
||||||
|
app.nav.searchPrev()
|
||||||
case "toggle":
|
case "toggle":
|
||||||
app.nav.toggle()
|
app.nav.toggle()
|
||||||
case "invert":
|
case "invert":
|
||||||
@ -405,12 +409,12 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.runShell(s, nil, false, true)
|
app.runShell(s, nil, false, true)
|
||||||
case "/":
|
case "/":
|
||||||
log.Printf("search: %s", s)
|
log.Printf("search: %s", s)
|
||||||
app.ui.message = "sorry, search is not implemented yet!"
|
app.nav.search = s
|
||||||
// TODO: implement
|
app.nav.searchNext()
|
||||||
case "?":
|
case "?":
|
||||||
log.Printf("search-back: %s", s)
|
log.Printf("search-back: %s", s)
|
||||||
app.ui.message = "sorry, search-back is not implemented yet!"
|
app.nav.search = s
|
||||||
// TODO: implement
|
app.nav.searchPrev()
|
||||||
default:
|
default:
|
||||||
log.Printf("entering unknown execution prefix: %q", app.ui.cmdpref)
|
log.Printf("entering unknown execution prefix: %q", app.ui.cmdpref)
|
||||||
}
|
}
|
||||||
|
21
nav.go
21
nav.go
@ -180,6 +180,7 @@ type nav struct {
|
|||||||
marks map[string]bool
|
marks map[string]bool
|
||||||
saves map[string]bool
|
saves map[string]bool
|
||||||
height int
|
height int
|
||||||
|
search string
|
||||||
}
|
}
|
||||||
|
|
||||||
func getDirs(wd string, height int) []*dir {
|
func getDirs(wd string, height int) []*dir {
|
||||||
@ -352,6 +353,26 @@ func (nav *nav) cd(wd string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) searchNext() {
|
||||||
|
last := nav.currDir()
|
||||||
|
for i := last.ind + 1; i < len(last.fi); i++ {
|
||||||
|
if strings.Contains(last.fi[i].Name(), nav.search) {
|
||||||
|
nav.down(i - last.ind)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) searchPrev() {
|
||||||
|
last := nav.currDir()
|
||||||
|
for i := last.ind - 1; i > 0; i-- {
|
||||||
|
if strings.Contains(last.fi[i].Name(), nav.search) {
|
||||||
|
nav.up(last.ind - i)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) toggleMark(path string) {
|
func (nav *nav) toggleMark(path string) {
|
||||||
if nav.marks[path] {
|
if nav.marks[path] {
|
||||||
delete(nav.marks, path)
|
delete(nav.marks, path)
|
||||||
|
2
opts.go
2
opts.go
@ -54,6 +54,8 @@ func init() {
|
|||||||
gOpts.keys["&"] = &callExpr{"read-shell-async", nil}
|
gOpts.keys["&"] = &callExpr{"read-shell-async", nil}
|
||||||
gOpts.keys["/"] = &callExpr{"search", nil}
|
gOpts.keys["/"] = &callExpr{"search", nil}
|
||||||
gOpts.keys["?"] = &callExpr{"search-back", nil}
|
gOpts.keys["?"] = &callExpr{"search-back", nil}
|
||||||
|
gOpts.keys["n"] = &callExpr{"search-next", nil}
|
||||||
|
gOpts.keys["N"] = &callExpr{"search-prev", nil}
|
||||||
gOpts.keys["<space>"] = &callExpr{"toggle", nil}
|
gOpts.keys["<space>"] = &callExpr{"toggle", nil}
|
||||||
gOpts.keys["v"] = &callExpr{"invert", nil}
|
gOpts.keys["v"] = &callExpr{"invert", nil}
|
||||||
gOpts.keys["y"] = &callExpr{"yank", nil}
|
gOpts.keys["y"] = &callExpr{"yank", nil}
|
||||||
|
Loading…
Reference in New Issue
Block a user