Documentation
¶
Overview ¶
Package kit holds the shared vocabulary for declaring default command modules: key-sequence builders, signature helpers, option and completion constructors. Module packages import it to keep their bindings terse
Index ¶
- Variables
- func Alt(r rune) command.KeyBinding
- func AltSpecial(s command.Special) command.KeyBinding
- func BoolOr(p *bool, def bool) bool
- func Char(r rune) command.KeyBinding
- func Continuation(fn command.KeyAction) command.Run
- func Ctrl(r rune) command.KeyBinding
- func EditorBoolOption(key string, get EditorGetter[bool], set EditorSetter[bool]) command.Option
- func EditorNullableIntOption(key string, dflt int, get EditorGetter[*int], set EditorSetter[*int]) command.Option
- func FileCompleter(e *view.Editor, _ *command.Args, input string) []command.Completion
- func FileSig(sig command.Signature) command.Signature
- func IntOr(p *int, def int) int
- func KeyBinding(alts ...command.KeyBinding) []command.KeyBinding
- func Keys(alts ...command.KeyBinding) map[string][]command.KeyBinding
- func Label(label string, prefix command.KeyBinding, modes ...string) command.PrefixLabel
- func Leader(ch rune) map[string][]command.KeyBinding
- func MinArgs(n int) command.Signature
- func OptionalArg() command.Signature
- func Or(alts ...command.KeyBinding) command.KeyBinding
- func Prefixed(prefix command.KeyBinding) func(...command.KeyBinding) command.KeyBinding
- func Runner(fn command.Action) command.Run
- func Seq(parts ...command.KeyBinding) command.KeyBinding
- func Shift(s command.Special) command.KeyBinding
- func Sig() command.Signature
- func Special(s command.Special) command.KeyBinding
- func StaticSig(sig command.Signature, items ...string) command.Signature
- func Window(subs ...command.KeyBinding) map[string][]command.KeyBinding
- type EditorGetter
- type EditorSetter
Constants ¶
This section is empty.
Variables ¶
var ( LeaderBinding = Or(Char(' '), Ctrl('\\')) // LeaderPrefix enters the shared leader menu, reachable by Space or Ctrl-\ LeaderPrefix = Prefixed(LeaderBinding) )
var ( Up = Special(command.Up) Down = Special(command.Down) Left = Special(command.Left) Right = Special(command.Right) Home = Special(command.Home) End = Special(command.End) PgUp = Special(command.PageUp) PgDn = Special(command.PageDown) Tab = Special(command.Tab) Esc = Special(command.Escape) Ret = Special(command.Enter) Del = Special(command.Delete) Bksp = Special(command.Backspace) )
Terse bindings for the plain special keys, named by their keycap form
Functions ¶
func AltSpecial ¶
func AltSpecial(s command.Special) command.KeyBinding
AltSpecial is the binding for Alt held with a special key
func Char ¶
func Char(r rune) command.KeyBinding
Char is the single-key binding for a rune, adding Shift for an uppercase
func Continuation ¶
Continuation wraps a KeyAction into a command Run
func EditorBoolOption ¶
EditorBoolOption builds a toggleable option over a bool editor value
func EditorNullableIntOption ¶
func EditorNullableIntOption( key string, dflt int, get EditorGetter[*int], set EditorSetter[*int], ) command.Option
EditorNullableIntOption builds an option over a nullable int editor value, reporting dflt when unset
func FileCompleter ¶
FileCompleter completes a positional argument against filesystem entries under the editor's working directory
func KeyBinding ¶
func KeyBinding(alts ...command.KeyBinding) []command.KeyBinding
KeyBinding unions alternatives into the one-element binding list a mode maps to, for building a per-mode Keys map by hand
func Keys ¶
func Keys(alts ...command.KeyBinding) map[string][]command.KeyBinding
Keys builds the all-modes ("*") binding map from the given alternatives
func Label ¶
func Label( label string, prefix command.KeyBinding, modes ...string, ) command.PrefixLabel
Label names a prefix key sequence for the pending-key hint popup
func Leader ¶
func Leader(ch rune) map[string][]command.KeyBinding
Leader binds ch under the shared leader (see LeaderPrefix)
func OptionalArg ¶
OptionalArg is a signature accepting zero or one positional argument
func Or ¶
func Or(alts ...command.KeyBinding) command.KeyBinding
Or unions its arguments into a single binding of alternative sequences, so any one of them triggers the command or enters the shared prefix state
func Prefixed ¶
func Prefixed( prefix command.KeyBinding, ) func(...command.KeyBinding) command.KeyBinding
Prefixed returns a builder that joins prefix ahead of any of the sub-bindings
func Seq ¶
func Seq(parts ...command.KeyBinding) command.KeyBinding
Seq concatenates parts into sequences, expanding an Or at any position into the cross-product of the alternatives around it
func Shift ¶
func Shift(s command.Special) command.KeyBinding
Shift is the binding for Shift held with a special key
func Special ¶
func Special(s command.Special) command.KeyBinding
Special is the binding for a special key
func Window ¶
func Window(subs ...command.KeyBinding) map[string][]command.KeyBinding
Window binds each sub under the Ctrl-w window chord or the leader's w menu, so window management shares the leader wherever the leader is reachable
Types ¶
type EditorGetter ¶
EditorGetter reads a typed value from the editor
type EditorSetter ¶
EditorSetter writes a typed value to the editor