Some sort of UNDO / REDO ( not functional yet )

This commit is contained in:
2016-03-17 04:57:43 +08:00
parent bc3c511c6f
commit f1653727f2
11 changed files with 472 additions and 47 deletions

View File

@@ -13,7 +13,8 @@
if( i == -1 || !this.__steps.length ) return null;
return this.__steps[ this.__i = i ];
this.__i -= 2;
return this.__steps[ i ];
};
Recorder.prototype.redo = function()
@@ -24,7 +25,7 @@
var State = this.__steps[ i ];
if( State )
{
this.__i = i;
this.__i += 2;
return State;
}
@@ -34,6 +35,8 @@
Recorder.prototype.record = function( StateObj )
{
this.__steps[ this.__i ] = StateObj;
StateObj.id = this.__i;
delete this.__steps[ ++ this.__i ];
};

View File

@@ -1,13 +1,19 @@
(function(){
var ns = __namespace( "Components.Vim.State" );
/** @type {Components.Vim.DateTime} */
var RelativeTime = __import( "Components.Vim.DateTime.RelativeTime" );
var Stack = function()
{
};
Stack.prototype.store = function( handler )
{
this.__handler = handler;
this.__time = new Date();
this.id = 0;
};
Stack.prototype.play = function()
@@ -15,5 +21,10 @@
if( this.__handler ) this.__handler();
};
__readOnly( Stack.prototype, "time", function()
{
return RelativeTime( this.__time );
} );
ns[ NS_EXPORT ]( EX_CLASS, "Stack", Stack );
})();