@@ 27,6 27,12 @@ var commands = map[string]Command{
Cleanup: cleanupFind,
Preview: true,
},
+ "findprev": Command{
+ Func: cmdFindPrev,
+ },
+ "findnext": Command{
+ Func: cmdFindNext,
+ },
"follow": Command{
Func: cmdFollow,
},
@@ 90,28 96,31 @@ func cmdFind(b *Browser, args ...string) error {
if text == nil {
return nil
}
-
if len(args) == 0 {
return nil
}
+ text.Find(strings.Join(args, " "))
+ b.view.Invalidate()
+ return nil
+}
- // TODO: Dedicated commands for prev/next?
- switch args[0] {
- case "prev":
- text.FindPrev()
- b.view.Invalidate()
- return nil
- case "next":
- text.FindNext()
- b.view.Invalidate()
+func cmdFindPrev(b *Browser, args ...string) error {
+ text := b.tabs[b.tab].Text()
+ if text == nil {
return nil
- default:
- // return errors.New("usage: find [prev|next]")
}
-
- text.Find(strings.Join(args, " "))
+ text.FindPrev()
b.view.Invalidate()
+ return nil
+}
+func cmdFindNext(b *Browser, args ...string) error {
+ text := b.tabs[b.tab].Text()
+ if text == nil {
+ return nil
+ }
+ text.FindNext()
+ b.view.Invalidate()
return nil
}
@@ 13,8 13,8 @@ follow {
bind : prompt
bind / prompt "find "
-bind N find prev
-bind n find next
+bind N findprev
+bind n findnext
bind f follow
bind J jump
bind o prompt "open "