Documentation
¶
Index ¶
- func CannotRedoTitle() string
- func CannotUndoTitle() string
- type Edit
- type Manager
- func (m *Manager) Add(edit Edit)
- func (m *Manager) CanRedo() bool
- func (m *Manager) CanUndo() bool
- func (m *Manager) Clear()
- func (m *Manager) CostLimit() int
- func (m *Manager) Redo()
- func (m *Manager) RedoTitle() string
- func (m *Manager) SetCostLimit(limit int)
- func (m *Manager) Undo()
- func (m *Manager) UndoTitle() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Edit ¶
type Edit interface { // Name returns the localized name of the edit, suitable for displaying in // a user interface menu. Note that no leading "Undo " or "Redo " should // be part of this name, as the Manager will add this. Name() string // Cost returns a cost factor for this edit. When the cost values of the // edits within a given Manager exceed the Manager's defined cost limit, // the oldest edits will be discarded until the cost values are less than // or equal to the Manager's defined limit. Note that if this method // returns a value less than 1, it will be set to 1 for purposes of this // calculation. Cost() int // Undo the state. Undo() // Redo the state. Redo() // Absorb gives this edit a chance to absorb a new edit that is about to // be added to the manager. If this method returns true, it is assumed // this edit has incorporated any necessary state into itself to perform // an undo/redo and the other edit will be discarded. Absorb(other Edit) bool // Release is called when this edit is no longer needed by the Manager. Release() }
Edit defines the required methods an undoable edit must implement.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides management of an undo/redo stack.
func NewManager ¶
func NewManager(costLimit int, recoveryHandler errs.RecoveryHandler) *Manager
NewManager creates a new undo/redo manager.
func (*Manager) Add ¶
Add an edit. If one or more undos have been performed, this will cause any redo capability beyond this point to be lost.
func (*Manager) CostLimit ¶
CostLimit returns the current cost limit permitted by this undo manager.
func (*Manager) SetCostLimit ¶
SetCostLimit sets a new cost limit, potentially trimming existing edits to fit within the new limit. Note that if the most recent edit has a cost larger than the new limit, that last edit (and only that last edit) will still be retained.
Click to show internal directories.
Click to hide internal directories.