~adnano/astronaut

87208dd19021c2448492e8c08120896984f45d47 — Adnan Maolood a month ago 728e095
config: Rename hints to follow
3 files changed, 18 insertions(+), 17 deletions(-)

M browser.go
M config.go
M config/astronaut.conf
M browser.go => browser.go +4 -3
@@ 640,13 640,14 @@ func (b *Browser) FollowMode() error {
		return nil
	}

	if len(b.config.Hints.Chars) == 0 {
		return fmt.Errorf("no hint chars configured")
	letters := b.config.Follow.Letters
	if len(letters) == 0 {
		return fmt.Errorf("no label letters configured")
	}

	// Label hints
	hintMap := map[string]Hint{}
	for i, label := range makeHintLabels(b.config.Hints.Chars, len(hints)) {
	for i, label := range makeHintLabels(letters, len(hints)) {
		hints[i].Label = label
		hintMap[label] = hints[i]
	}

M config.go => config.go +12 -12
@@ 11,7 11,7 @@ import (
type Config struct {
	Display DisplayConfig
	Search  SearchConfig
	Hints   HintsConfig
	Follow  FollowConfig
	Binds   Binds
}



@@ 24,8 24,8 @@ type SearchConfig struct {
	URL *url.URL
}

type HintsConfig struct {
	Chars string
type FollowConfig struct {
	Letters string
}

// Parse parses the settings from the given configuration.


@@ 37,8 37,8 @@ func (c *Config) Parse(block scfg.Block) error {
			err = c.Display.parse(d)
		case "search":
			err = c.Search.parse(d)
		case "hints":
			err = c.Hints.parse(d)
		case "follow":
			err = c.Follow.parse(d)
		case "bind":
			err = c.Binds.parse(d)
		}


@@ 95,18 95,18 @@ func (c *SearchConfig) parse(d *scfg.Directive) error {
	return nil
}

func (c *HintsConfig) parse(d *scfg.Directive) error {
func (c *FollowConfig) parse(d *scfg.Directive) error {
	for _, d := range d.Children {
		switch d.Name {
		case "chars":
			var chars string
			if err := d.ParseParams(&chars); err != nil {
		case "letters":
			var letters string
			if err := d.ParseParams(&letters); err != nil {
				return err
			}
			if len(chars) < 2 {
				return fmt.Errorf("directive %q: expected at least two chars", d.Name)
			if len(letters) < 2 {
				return fmt.Errorf("directive %q: expected at least two letters", d.Name)
			}
			c.Chars = chars
			c.Letters = letters
		}
	}
	return nil

M config/astronaut.conf => config/astronaut.conf +2 -2
@@ 7,8 7,8 @@ search {
	url gemini://geminispace.info/search
}

hints {
	chars asdfjkl
follow {
	letters asdfjkl
}

bind : prompt