Каркас Undo\Redo для ваших программ. Может кому пригодится.
rem
History module
end rem
Function CanUndo:Byte()
Return Not undoList.IsEmpty()
End Function
Function Undo()
If undoList.IsEmpty() Then Return
Local h:THistory = THistory(undoList.RemoveLast())
h.Undo()
redoList.AddFirst(h)
End Function
Function CanRedo:Byte()
Return Not redoList.IsEmpty()
End Function
Function Redo()
If redoList.IsEmpty() Then Return
Local h:THistory = THistory(redoList.RemoveFirst())
h.Redo()
undoList.AddLast(h)
End Function
Type THistory Abstract
Method New()
If Not redoList.IsEmpty()
redoList = New TList
End If
undoList.AddLast(Self)
If undoList.Count() > MAX_HISTORY
undoList.RemoveFirst()
End If
End Method
Method Undo() Abstract
Method Redo() Abstract
End Type
Const MAX_HISTORY:Int = 100
Global undoList:TList = New TList
Global redoList:TList = New TList