Documentation
¶
Overview ¶
Package vim is the modal editing ZPad offers when Vim mode is on: the modes, the motions and operators, and the text objects. It knows nothing of MyGo's widgets: the app gives a Host the text to read, the caret and selection to move, and the edits to make.
Index ¶
- type Buffer
- type Host
- type Key
- type Mode
- type Range
- type Session
- func (s *Session) GoToLine(h Host, line int)
- func (s *Session) Key(k Key, h Host) bool
- func (s *Session) Mode() Mode
- func (s *Session) Normal(h Host)
- func (s *Session) Pending() bool
- func (s *Session) Reset()
- func (s *Session) Rune(r rune, h Host)
- func (s *Session) SetSearchRange(start, end int)
- func (s *Session) Text(text string, h Host) (left string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer interface {
Len() int
LineCount() int
Line(i int) string
LineStart(i int) int
LineEnd(i int) int
LineOf(offset int) int
Slice(start, end int) string
}
Buffer is the text the session reads, as editor.Snapshot is.
type Host ¶
type Host interface {
Text() Buffer
Cursor() int
SetCursor(offset int)
SetSelection(anchor, head int)
Replace(start, end int, text string)
Undo() bool
Redo() bool
MoveToBracket() bool
Page(forward bool) bool
FindNext(previous bool, currentStart, currentEnd int) (start, end int, ok bool)
OpenCommandLine(kind rune)
Save()
Close()
SaveAndClose()
GoToLine(line int)
Indent() string
ReadOnly() bool
ReadClipboard() string
WriteClipboard(text string)
}
Host is what the session asks of the app. It is implemented by a few lines over an editor.State, so that the session itself needs no UI.
type Key ¶
type Key uint8
Key is a key that is not text: the keys a terminal names, and the few control keys Vim uses.
type Range ¶
Range is a piece of the text: bytes Start to End, End exclusive, and whether the whole lines are meant, as dd and V select.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is one tab's modal state: its mode, the count and operator being typed, the visual selection, and the unnamed register.
func (*Session) Pending ¶
Pending reports whether a count or an operator is being typed, which the app may show in the status bar and underline the caret for.
func (*Session) Reset ¶
func (s *Session) Reset()
Reset puts the session in normal mode with nothing pending, as turning Vim mode off or opening a preview does.
func (*Session) Rune ¶
Rune feeds a typed character, in normal or visual mode. Insert mode is the editor's own, so it is the app's to let through.
func (*Session) SetSearchRange ¶
SetSearchRange remembers the match the app just found, so that n and N continue after it rather than finding it again.