Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Log ¶
type Log struct {
// contains filtered or unexported fields
}
Log tracks changes to a document and generates undo/redo operations.
func (*Log) Checkpoint ¶
func (l *Log) Checkpoint()
Checkpoint marks the current entry as a checkpoint.
func (*Log) HasUnsavedChanges ¶
HasUnsavedChanges returns whether the log has unsaved changes.
func (*Log) RedoToNextCheckpoint ¶
RedoToNextCheckpoint returns operations to to transform the document to its state at the next checkpoint. It also moves the current position forward in the log.
func (*Log) TrackLoad ¶
func (l *Log) TrackLoad()
TrackLoad removes all changes and resets the savepoint.
func (*Log) TrackOp ¶
TrackOp tracks a change to the document. This appends a new, uncommitted change and invalidates any future changes.
func (*Log) TrackSave ¶
func (l *Log) TrackSave()
TrackSave moves the savepoint to the current entry.
func (*Log) UndoToLastCheckpoint ¶
UndoToLastCheckpoint returns operations to transform the document back to its state at the previous checkpoint. It also moves the current position backwards in the log.
type Op ¶
type Op struct {
// contains filtered or unexported fields
}
Op represents an insert or delete operation on a document.
func (Op) NumRunesToDelete ¶
NumRunesToDelete returns the number of runes deleted at the position. This will be zero if TextToInsert is a non-empty string.
func (Op) TextToInsert ¶
TextToInsert returns the text inserted by the op. This will be an empty string if NumRunesToDelete is greater than zero.