Documentation
¶
Overview ¶
Package engine is a small real-time Vim emulator: feed it keystrokes, it mutates buffer/cursor/mode state and reports what happened.
Index ¶
- Variables
- type Event
- type EventKind
- type Goal
- type Mode
- type Pos
- type Simulator
- func (s *Simulator) BlockSelection() (r0, r1, c0, c1 int)
- func (s *Simulator) LastCommand() string
- func (s *Simulator) LastSearch() string
- func (s *Simulator) Pending() string
- func (s *Simulator) Press(key string) Event
- func (s *Simulator) Recording() bool
- func (s *Simulator) Selection() (Pos, Pos)
- func (s *Simulator) WordAtCursor() string
Constants ¶
This section is empty.
Variables ¶
View Source
var GoalTypes = []string{
"cursorOnWord", "bufferEquals", "lineDeleted",
"wordDeleted", "containsText", "searchMatchActive", "commandRun",
}
GoalTypes lists every valid Goal.Type, for content validation.
Functions ¶
This section is empty.
Types ¶
type Goal ¶
type Goal struct {
Type string `json:"type"`
Word string `json:"word,omitempty"`
Line string `json:"line,omitempty"`
Lines []string `json:"lines,omitempty"`
Text string `json:"text,omitempty"`
Term string `json:"term,omitempty"`
Command string `json:"command,omitempty"`
}
Goal is a challenge success condition, decoded straight from lesson JSON.
type Simulator ¶
type Simulator struct {
Buffer []string
Cursor Pos
Mode Mode
// AllowedKeys restricts normal-mode commands; nil allows everything.
AllowedKeys map[string]bool
SearchQuery string
CmdQuery string // the command being typed after :
VisualAnchor Pos // where v was pressed; the selection's fixed end
BlockAnchor Pos // where ctrl+v was pressed; the block's fixed corner
// contains filtered or unexported fields
}
func (*Simulator) BlockSelection ¶ added in v1.0.0
BlockSelection exposes the rectangle's inclusive bounds for rendering.
func (*Simulator) LastCommand ¶ added in v1.0.0
func (*Simulator) LastSearch ¶
func (*Simulator) Pending ¶
Pending returns the visible pending state ("d", "3", "3d", "di", "g") for the HUD.
func (*Simulator) Recording ¶ added in v1.0.0
Recording reports whether a macro is being recorded (for the HUD).
func (*Simulator) Selection ¶ added in v1.0.0
Selection returns the visual range ordered start ≤ end (inclusive).
func (*Simulator) WordAtCursor ¶
WordAtCursor returns the space-delimited word under the cursor, or "".
Click to show internal directories.
Click to hide internal directories.