Documentation ¶
Index ¶
- Constants
- type Key
- type KeyBinding
- type KeyBindings
- func (k *KeyBindings) Action(qc func(key string, operator Op, operand interface{}, match_all bool) bool) (kb *KeyBinding)
- func (k *KeyBindings) DropLessEqualKeys(count int)
- func (k *KeyBindings) Filter(kp KeyPress) (ret KeyBindings)
- func (k *KeyBindings) KeyOff() int
- func (k *KeyBindings) Len() int
- func (k *KeyBindings) Less(i, j int) bool
- func (k *KeyBindings) Merge(other *KeyBindings)
- func (k KeyBindings) String() string
- func (k *KeyBindings) Swap(i, j int)
- func (k *KeyBindings) UnmarshalJSON(d []byte) error
- type KeyContext
- type KeyPress
Constants ¶
const ( Left Key = 0x2190 + iota Up Right Down Enter = '\n' Escape = 0x001B Backspace = 0x0008 Delete = 0x007F KeypadEnter = '\n' )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyBinding ¶
type KeyBinding struct { Keys []KeyPress Command string Args map[string]interface{} Context []KeyContext // contains filtered or unexported fields }
A single KeyBinding for which after pressing the given sequence of Keys, and the Context matches, the Command will be invoked with the provided Args.
type KeyBindings ¶
type KeyBindings struct { Bindings []*KeyBinding // contains filtered or unexported fields }
func (*KeyBindings) Action ¶
func (k *KeyBindings) Action(qc func(key string, operator Op, operand interface{}, match_all bool) bool) (kb *KeyBinding)
Tries to resolve all the current KeyBindings in k to a single action. If any action is appropriate as determined by context, the return value will be the specific KeyBinding that is possible to execute now, otherwise it is nil.
func (*KeyBindings) DropLessEqualKeys ¶
func (k *KeyBindings) DropLessEqualKeys(count int)
Drops all KeyBindings that are a sequence of key presses less or equal to the given number.
func (*KeyBindings) Filter ¶
func (k *KeyBindings) Filter(kp KeyPress) (ret KeyBindings)
Filters the KeyBindings, returning a new KeyBindings object containing a subset of matches for the given key press.
func (*KeyBindings) KeyOff ¶
func (k *KeyBindings) KeyOff() int
func (*KeyBindings) Less ¶
func (k *KeyBindings) Less(i, j int) bool
Compares one KeyBinding to another for sorting purposes.
func (*KeyBindings) Merge ¶
func (k *KeyBindings) Merge(other *KeyBindings)
func (KeyBindings) String ¶
func (k KeyBindings) String() string
func (*KeyBindings) Swap ¶
func (k *KeyBindings) Swap(i, j int)
Swaps the two KeyBindings at the given positions.
func (*KeyBindings) UnmarshalJSON ¶
func (k *KeyBindings) UnmarshalJSON(d []byte) error
type KeyContext ¶
type KeyContext struct {
// contains filtered or unexported fields
}
A Context definition for which a key binding is to be considered.
func (*KeyContext) UnmarshalJSON ¶
func (k *KeyContext) UnmarshalJSON(d []byte) error
type KeyPress ¶
A Key press with the given Key and modifiers.
func (KeyPress) Index ¶
Returns an index used for sorting key presses. TODO(.): This is in no way a unique index with quite a lot of collisions and potentially resulting in bad lookups.
func (KeyPress) IsCharacter ¶
Returns whether this KeyPress is a print character or not.