keyseq

package
v0.5.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInSequence = errors.New("expected a key sequence")
View Source
var ErrNoMatch = errors.New("could not match key to any action")

Functions

func EachDepth

func EachDepth(t Trie, proc func(Node) bool)

func EachWidth

func EachWidth(t Trie, proc func(Node) bool)

func EventToString

func EventToString(ev termbox.Event) (string, error)

EventToString returns human readable name for a given termbox.Event

Types

type Key

type Key struct {
	Modifier ModifierKey // Alt, etc
	Key      termbox.Key
	Ch       rune
}

Key is data in one trie node in the KeySequence

func NewKeyFromKey

func NewKeyFromKey(k termbox.Key) Key

func (Key) Compare

func (k Key) Compare(x Key) int

func (Key) String

func (k Key) String() string

type KeyList

type KeyList []Key

KeyList is just the list of keys

func ToKeyList

func ToKeyList(ksk string) (KeyList, error)

func (KeyList) Equals

func (k KeyList) Equals(x KeyList) bool

func (KeyList) String

func (kl KeyList) String() string

type Keyseq

type Keyseq struct {
	*Matcher
	// contains filtered or unexported fields
}

func New

func New() *Keyseq

func (*Keyseq) AcceptKey

func (k *Keyseq) AcceptKey(key Key) (interface{}, error)

func (*Keyseq) CancelChain

func (k *Keyseq) CancelChain()

func (*Keyseq) Current

func (k *Keyseq) Current() keyseqMatcher

func (*Keyseq) InMiddleOfChain

func (k *Keyseq) InMiddleOfChain() bool

type Match

type Match struct {
	Index   int
	Pattern KeyList
	Value   interface{}
}

type Matcher

type Matcher struct {
	*TernaryTrie
}

func NewMatcher

func NewMatcher() *Matcher

func (*Matcher) Add

func (m *Matcher) Add(pattern KeyList, v interface{})

func (*Matcher) Clear

func (m *Matcher) Clear()

func (*Matcher) Compile

func (m *Matcher) Compile() error

func (*Matcher) Match

func (m *Matcher) Match(text KeyList) <-chan Match

type ModifierKey

type ModifierKey int
const (
	ModNone ModifierKey = iota
	ModAlt
	ModMax
)

func ToKey

func ToKey(key string) (k termbox.Key, modifier ModifierKey, ch rune, err error)

func (ModifierKey) String

func (m ModifierKey) String() string

type Node

type Node interface {
	Get(k Key) Node
	GetList(k KeyList) Node
	Dig(k Key) (Node, bool)
	HasChildren() bool
	Size() int
	Each(func(Node) bool)
	RemoveAll()

	Label() Key
	Value() interface{}
	SetValue(v interface{})
}

func Children

func Children(n Node) []Node

func Get

func Get(t Trie, k KeyList) Node

func Put

func Put(t Trie, k KeyList, v interface{}) Node

type TernaryNode

type TernaryNode struct {
	// contains filtered or unexported fields
}

func NewTernaryNode

func NewTernaryNode(l Key) *TernaryNode

func (*TernaryNode) Balance

func (n *TernaryNode) Balance()

func (*TernaryNode) Dig

func (n *TernaryNode) Dig(k Key) (node Node, isnew bool)

func (*TernaryNode) Each

func (n *TernaryNode) Each(proc func(Node) bool)

func (*TernaryNode) FirstChild

func (n *TernaryNode) FirstChild() *TernaryNode

func (*TernaryNode) Get

func (n *TernaryNode) Get(k Key) Node

func (*TernaryNode) GetList

func (n *TernaryNode) GetList(k KeyList) Node

func (*TernaryNode) HasChildren

func (n *TernaryNode) HasChildren() bool

func (*TernaryNode) Label

func (n *TernaryNode) Label() Key

func (*TernaryNode) RemoveAll

func (n *TernaryNode) RemoveAll()

func (*TernaryNode) SetValue

func (n *TernaryNode) SetValue(v interface{})

func (*TernaryNode) Size

func (n *TernaryNode) Size() int

func (*TernaryNode) Value

func (n *TernaryNode) Value() interface{}

type TernaryTrie

type TernaryTrie struct {
	// contains filtered or unexported fields
}

func NewTernaryTrie

func NewTernaryTrie() *TernaryTrie

func (*TernaryTrie) Balance

func (t *TernaryTrie) Balance()

func (*TernaryTrie) Get

func (t *TernaryTrie) Get(k Key) Node

func (*TernaryTrie) GetList

func (t *TernaryTrie) GetList(k KeyList) Node

func (*TernaryTrie) Put

func (t *TernaryTrie) Put(k KeyList, v interface{}) Node

func (*TernaryTrie) Root

func (t *TernaryTrie) Root() Node

func (*TernaryTrie) Size

func (t *TernaryTrie) Size() int

type Trie

type Trie interface {
	Root() Node
	GetList(KeyList) Node
	Get(Key) Node
	Put(KeyList, interface{}) Node
	Size() int
}

func NewTrie

func NewTrie() Trie

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL