Documentation ¶
Index ¶
- type Log
- func (l *Log) BeginEntry(cursorPos uint64)
- func (l *Log) CommitEntry(cursorPos uint64)
- func (l *Log) HasUnsavedChanges() bool
- func (l *Log) RedoToNextCommitted() (hasEntry bool, ops []Op, cursor uint64)
- func (l *Log) TrackOp(op Op)
- func (l *Log) TrackSave()
- func (l *Log) UndoToLastCommitted() (hasEntry bool, ops []Op, cursor uint64)
- type LogEntry
- type Op
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) BeginEntry ¶ added in v1.0.0
BeginEntry starts a new undo entry. This should be called before tracking any operations.
func (*Log) CommitEntry ¶ added in v1.0.0
CommitEntry completes an undo entry. This should be called after BeginEntry. If no operations were tracked, this does nothing.
func (*Log) HasUnsavedChanges ¶
HasUnsavedChanges returns whether the log has unsaved changes.
func (*Log) RedoToNextCommitted ¶ added in v1.0.0
RedoToNextCommitted returns operations to to transform the document to its state after the next entry. It also moves the current position forward in the log.
func (*Log) TrackOp ¶
TrackOp tracks a change to the document. This appends a new, uncommitted change and invalidates any future changes.
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.