keys

package
v0.0.0-...-ae9aa4e Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2015 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 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 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) 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) 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

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