From 121edc7513148a3e3ae981ac88e9878ceb1d533b Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Thu, 25 Nov 2021 13:38:10 -0500 Subject: [PATCH] command: Move find prev/next to separate commands --- command.go | 37 +++++++++++++++++++++++-------------- config/astronaut.conf | 4 ++-- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/command.go b/command.go index d91291a..840555b 100644 --- a/command.go +++ b/command.go @@ -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 } diff --git a/config/astronaut.conf b/config/astronaut.conf index 8cdd7c8..f2ec76b 100644 --- a/config/astronaut.conf +++ b/config/astronaut.conf @@ -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 " -- 2.38.5