~adnano/astronaut

121edc7513148a3e3ae981ac88e9878ceb1d533b — Adnan Maolood 1 year, 9 months ago f4e5bba
command: Move find prev/next to separate commands
2 files changed, 25 insertions(+), 16 deletions(-)

M command.go
M config/astronaut.conf
M command.go => command.go +23 -14
@@ 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
}


M config/astronaut.conf => config/astronaut.conf +2 -2
@@ 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 "