Documentation ¶
Index ¶
- Constants
- type HasKeyBindings
- 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) Len() int
- func (k *KeyBindings) Less(i, j int) bool
- func (k *KeyBindings) Parent() KeyBindingsInterface
- func (k *KeyBindings) SeqIndex() int
- func (k *KeyBindings) SetParent(p KeyBindingsInterface)
- func (k KeyBindings) String() string
- func (k *KeyBindings) Swap(i, j int)
- func (k *KeyBindings) UnmarshalJSON(d []byte) error
- type KeyBindingsInterface
- 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 HasKeyBindings ¶
type HasKeyBindings struct {
// contains filtered or unexported fields
}
An utility struct that(same as HasSettings ) is typically embedded in other type structs to make that type implement the KeyBindingsInterface
func (*HasKeyBindings) KeyBindings ¶
func (k *HasKeyBindings) KeyBindings() *KeyBindings
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) Less ¶
func (k *KeyBindings) Less(i, j int) bool
Compares one KeyBinding to another for sorting purposes.
func (*KeyBindings) Parent ¶
func (k *KeyBindings) Parent() KeyBindingsInterface
func (*KeyBindings) SeqIndex ¶
func (k *KeyBindings) SeqIndex() int
func (*KeyBindings) SetParent ¶
func (k *KeyBindings) SetParent(p KeyBindingsInterface)
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 KeyBindingsInterface ¶
type KeyBindingsInterface interface {
KeyBindings() *KeyBindings
}
Defines an interface for types that have keybindings
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 ¶
type KeyPress struct { Text string // the text representation of the key Key Key // the code for the key that was pressed Shift, Super, Alt, Ctrl bool // true if modifier key was pressed }
KeyPress describes a key press event. Note that Key does not distinguish between capital and non-capital letters; use the Text property for this purpose.
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.