47 lines
No EOL
1 KiB
JavaScript
47 lines
No EOL
1 KiB
JavaScript
/**
|
|
* Ajax.org Code Editor (ACE)
|
|
*
|
|
* @copyright 2010, Ajax.org Services B.V.
|
|
* @license LGPLv3 <http://www.gnu.org/licenses/lgpl-3.0.txt>
|
|
* @author Fabian Jakobs <fabian AT ajax DOT org>
|
|
*/
|
|
require.def("ace/UndoManager", function() {
|
|
|
|
var UndoManager = function() {
|
|
this.$undoStack = [];
|
|
this.$redoStack = [];
|
|
};
|
|
|
|
(function() {
|
|
|
|
/*this.$doc = null;
|
|
this.setDocument = function(doc) {
|
|
this.$doc = doc;
|
|
};*/
|
|
|
|
this.execute = function(options) {
|
|
var deltas = options.args[0];
|
|
this.$doc = options.args[1];
|
|
this.$undoStack.push(deltas);
|
|
};
|
|
|
|
this.undo = function() {
|
|
var deltas = this.$undoStack.pop();
|
|
if (deltas) {
|
|
this.$doc.undoChanges(deltas);
|
|
this.$redoStack.push(deltas);
|
|
}
|
|
};
|
|
|
|
this.redo = function() {
|
|
var deltas = this.$redoStack.pop();
|
|
if (deltas) {
|
|
this.$doc.redoChanges(deltas);
|
|
this.$undoStack.push(deltas);
|
|
}
|
|
};
|
|
|
|
}).call(UndoManager.prototype);
|
|
|
|
return UndoManager;
|
|
}); |