2016-03-16 10:55:18 +00:00
|
|
|
(function(){
|
|
|
|
var ns = __namespace( "Components.Vim.State" );
|
|
|
|
|
|
|
|
var Recorder = function()
|
|
|
|
{
|
|
|
|
this.__steps = [];
|
|
|
|
this.__i = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
Recorder.prototype.undo = function()
|
|
|
|
{
|
|
|
|
var i = this.__i - 1;
|
|
|
|
if( i == -1 || !this.__steps.length ) return null;
|
|
|
|
|
|
|
|
|
2016-03-16 22:08:38 +00:00
|
|
|
return this.__steps[ this.__i = i ];
|
2016-03-16 10:55:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Recorder.prototype.redo = function()
|
|
|
|
{
|
2016-03-16 22:08:38 +00:00
|
|
|
var State = this.__steps[ this.__i ];
|
2016-03-16 10:55:18 +00:00
|
|
|
|
|
|
|
if( State )
|
|
|
|
{
|
2016-03-16 22:08:38 +00:00
|
|
|
this.__i ++;
|
2016-03-16 10:55:18 +00:00
|
|
|
return State;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
Recorder.prototype.record = function( StateObj )
|
|
|
|
{
|
|
|
|
this.__steps[ this.__i ] = StateObj;
|
2016-03-16 22:08:38 +00:00
|
|
|
StateObj.id = this.__i ++;
|
2016-03-16 10:55:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ns[ NS_EXPORT ]( EX_CLASS, "Recorder", Recorder );
|
|
|
|
})();
|