Documentation
¶
Overview ¶
Package history provides undo/redo functionality via a change history stack.
Index ¶
Constants ¶
View Source
const DefaultMaxHistory = 100
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionType ¶
type ActionType int
ActionType indicates whether text was inserted or deleted.
const ( InsertAction ActionType = iota DeleteAction )
type Change ¶
type Change struct {
Type ActionType
Text []byte // Text inserted or text deleted
StartPosition types.Position // Where the change began
EndPosition types.Position // Position after inserted text, or end position of deleted text
CursorBefore types.Position // Cursor position *before* this change was applied
}
Change represents a single, reversible text operation.
type EditorInterface ¶
type EditorInterface interface {
GetBuffer() buffer.Buffer
SetCursor(types.Position)
GetEventManager() *event.Manager
ScrollToCursor()
}
EditorInterface defines the methods the history manager needs from the editor/buffer.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles the undo/redo stack.
func NewManager ¶
func NewManager(editor EditorInterface, maxHistory int) *Manager
NewManager creates a history manager.
func (*Manager) Clear ¶
func (m *Manager) Clear()
Clear resets the history stack. Call this on file load.
func (*Manager) RecordChange ¶
RecordChange adds a new change, clearing any redo history.
Click to show internal directories.
Click to hide internal directories.