keys

package
v0.0.0-...-3e0bf09 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2014 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
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 Key

type Key rune
const (
	// map to dingbats...
	F1 Key = 0x2701 + iota
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
	Insert
	PageUp
	PageDown
	Home
	End
	Break
	Any Key = unicode.MaxRune
)

func (Key) String

func (k Key) String() string

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) Len

func (k *KeyBindings) Len() int

Returns the number of KeyBindings.

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

type KeyPress struct {
	Key                     Key
	Shift, Super, Alt, Ctrl bool
}

A Key press with the given Key and modifiers.

func (KeyPress) Index

func (k KeyPress) Index() (ret int)

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

func (k KeyPress) IsCharacter() bool

Returns whether this KeyPress is a print character or not.

func (KeyPress) String

func (k KeyPress) String() (ret string)

func (*KeyPress) UnmarshalJSON

func (k *KeyPress) UnmarshalJSON(d []byte) error

Jump to

Keyboard shortcuts

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