Documentation
¶
Overview ¶
TODO: this should be moved to 'control/editor' imo
Index ¶
Constants ¶
const ( // TextEditModeNormal is the "normal mode" of the editor, i.E. key inputs are // not used for input directly, but for navigation and manipulation of the // text. TextEditModeNormal = 0 // TextEditModeInsert is the "insert mode" of the editor, i.E. key inputs are // used for input directly. TextEditModeInsert = 1 )
Variables ¶
This section is empty.
Functions ¶
func ToConfigIdentifierString ¶
ToConfigIdentifierString converts the given key to its configuration identfier.
Types ¶
type Actionspec ¶ added in v0.8.0
type Actionspec string
type CapturingOverlay ¶
type CapturingOverlay struct {
Processor SimpleInputProcessor
}
CapturingOverlay is a wrapper over a SimpleInputProcessor that always claims to capture input, which can be a desirable behavior for modal overlays.
func CapturingOverlayWrap ¶
func CapturingOverlayWrap(s SimpleInputProcessor) *CapturingOverlay
CapturingOverlayWrap returns a wrapper over the given SimpleInputProcessor that always captures all input.
func (*CapturingOverlay) CapturesInput ¶
func (o *CapturingOverlay) CapturesInput() bool
CapturesInput returns whether this processor "captures" input, i.E. whether it ought to take priority in processing over other processors; this is always the case for the capturing overlay.
func (*CapturingOverlay) GetHelp ¶
func (o *CapturingOverlay) GetHelp() Help
GetHelp returns the input help map for this processor.
func (*CapturingOverlay) ProcessInput ¶
func (o *CapturingOverlay) ProcessInput(k Key) bool
ProcessInput attempts to process the provided input. Returns whether the provided input "applied", i.E. the processor performed an action based on the input. This defers to the underlying processor.
type InputConfig ¶ added in v0.8.0
type InputConfig struct { Editor map[Keyspec]Actionspec `yaml:"editor"` StringEditor ModedSpec `yaml:"string-editor"` }
type Key ¶
type Key struct { Mod tcell.ModMask Key tcell.Key Ch rune }
Key represents a key input.
NOTE:
currently barely generifying tcell's input type; could eventually be properly generified for other input sources.
func ConfigKeyspecToKeys ¶
ConfigKeyspecToKeys converts full key sequence specification strings (e.g. "<space>qw" meaning the SPACE key, then the Q key, then the W key) to the appropriate sequence of Keys (or an error, if invalid).
func KeyFromTcellEvent ¶
func KeyFromTcellEvent(e *tcell.EventKey) Key
KeyFromTcellEvent formats a tcell.EventKey to a Key as this package expects it. Any Key for a tcell.EventKey should be converted by this function.
func KeyIdentifierToKey ¶
KeyIdentifierToKey converts the given special identifier to the appropriate key (or an error, if invalid).
func (*Key) ToDebugString ¶
ToDebugString returns a debug string for this key.
type ModalInputProcessor ¶
type ModalInputProcessor interface { SimpleInputProcessor // ApplyModalOverlay applies an overlay to this processor. // It returns the processors index, by which in the future, all overlays down // to and including this overlay can be removed ApplyModalOverlay(SimpleInputProcessor) (index uint) // PopModalOverlay removes the topmost overlay from this processor. PopModalOverlay() error // PopModalOverlays pops all overlays down to and including the one at the // specified index. PopModalOverlays(index uint) }
ModalInputProcessor is an input processor that (additionally to SimpleInputProcessor) can be temporarily overlaid with any number of additional input processors, which can be removed one-by-one of the top or by their indices.
type ModedSpec ¶ added in v0.8.0
type ModedSpec struct { Normal map[Keyspec]Actionspec `yaml:"normal"` Insert map[Keyspec]Actionspec `yaml:"insert"` }
type Node ¶
Node is a node in a Tree. It can have child nodes or an action.
NOTE:
must not have children if it has an action, and must not have an action if it has children.
func NewLeaf ¶
NewLeaf returns a pointer to a new action leaf Node without children.
NOTE: to construct an intermediate node with no aciton, prefer NewNode.
func NewNode ¶
func NewNode() *Node
NewNode returns a pointer to a new empty node Node with initialized children.
NOTE: to construct a leaf with an action, prefer NewLeaf.
type SimpleInputProcessor ¶
type SimpleInputProcessor interface { // CapturesInput returns whether this processor "captures" input, i.E. whether // it ought to take priority in processing over other processors. // This is useful, e.g., for prioritizing processors with partial input // sequences or for such overlays, that are to take complete priority by // completely gobbling all input. CapturesInput() bool // ProcessInput attempts to process the provided input. // Returns whether the provided input "applied", i.E. the processor performed // an action based on the input. ProcessInput(key Key) bool // GetHelp returns the input help map for this processor. GetHelp() Help }
SimpleInputProcessor can process the input it is configured for and provide help information for that configuration. It can also "capture" input to ensure its precedence over other processors, e.g. when it has partial input.
type TextEditMode ¶
type TextEditMode = int
TextEditMode enumerates the possible modes of modal text editing.
type Tree ¶
Tree represents an input tree, which can contain various input sequences that terminate in an action.
Example:
tree: mapping: x +-y | +-z -> action1 "xyz" -> action1 +-z -> action2 "xz" -> action2 z -> action3 "z" -> action3
func ConstructInputTree ¶
ConstructInputTree construct a Tree for the given mappings of input sequence strings to actions. If the given mapping is invalid, this returns an error.
func (*Tree) CapturesInput ¶
CapturesInput returns whether this processor "captures" input, i.E. whether it ought to take priority in processing over other processors. This is useful, e.g., for prioritizing processors with partial input sequences or for such overlays, that are to take complete priority by completely gobbling all input.
func (*Tree) ProcessInput ¶
ProcessInput attempts to process the provided input. Returns whether the provided input "applied", i.E. the processor performed an action based on the input.