implement search/search-back and search-next/prev

Closes #38.
This commit is contained in:
Gokcehan committed 2016-12-24 15:57:57 +03:00
1 parent af113e71ef
commit f7e778591a
6 files changed
+37 -4

No files matched your search

+21
View File
@@ -180,6 +180,7 @@ type nav struct {
marks map[string]bool
saves map[string]bool
height int
search string
}
func getDirs(wd string, height int) []*dir {
@@ -352,6 +353,26 @@ func (nav *nav) cd(wd string) error {
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) {
if nav.marks[path] {
delete(nav.marks, path)