Documentation
¶
Overview ¶
Package vimedit is a vim-style line-buffer editing engine for the playground model editor. It has no rendering or UI dependencies: the host feeds keys in and reads the buffer, cursor, mode and status back out.
The buffer is a slice of lines, each an immutable []rune (copy-on-write), so an undo snapshot is a shallow copy of the outer slice and every keypress costs O(line length) or O(lines) pointer work, never a join/split of the whole text.
Index ¶
- type Action
- type Editor
- func (e *Editor) CommandLine() string
- func (e *Editor) Cursor() Pos
- func (e *Editor) HandleKey(k Key) Action
- func (e *Editor) InsertText(s string)
- func (e *Editor) Line(i int) []rune
- func (e *Editor) LineCount() int
- func (e *Editor) Mode() Mode
- func (e *Editor) Pending() string
- func (e *Editor) Revision() uint64
- func (e *Editor) Selection() (Selection, bool)
- func (e *Editor) SetTop(top int)
- func (e *Editor) SetValue(s string)
- func (e *Editor) SetViewportHeight(h int)
- func (e *Editor) Status() string
- func (e *Editor) Value() string
- type Key
- type Mode
- type Pos
- type Selection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Editor ¶
type Editor struct {
// contains filtered or unexported fields
}
Editor is the editing engine. Create it with New; methods take a pointer receiver but the type itself is safe to store by value.
func (*Editor) CommandLine ¶
CommandLine is the prompt char plus typed text in Command mode, else "".
func (*Editor) InsertText ¶
InsertText inserts pasted text at the cursor as one undo step.
func (*Editor) Pending ¶
Pending is the not-yet-complete count/operator/prefix keys, for a showcmd area.
func (*Editor) Selection ¶
Selection returns the Visual selection; ok only in Visual and VisualLine.
func (*Editor) SetValue ¶
SetValue replaces the buffer, resets the cursor, history and mode (Insert).
func (*Editor) SetViewportHeight ¶
SetViewportHeight sets the page size used by ctrl+d/u/f/b and H/M/L.
type Key ¶
type Key struct {
Name string // e.g. "a", "ctrl+d", "esc", "enter", "space", "backspace"
Text string // printable text, "" for control and named keys
}
Key is one key press, mirroring tea.KeyPressMsg.