forked from Botanical/BotanJS
Proper REDO / UNDO function ( without cursor pos )
This commit is contained in:
parent
f1653727f2
commit
865530709b
@ -57,6 +57,7 @@
|
||||
|
||||
INSERT.prototype.dispose = function()
|
||||
{
|
||||
this.__cursor.moveX( -1 );
|
||||
this.__rec( "", true );
|
||||
};
|
||||
|
||||
@ -68,12 +69,6 @@
|
||||
var contentUndo = this.__contentUndo;
|
||||
var startPos = this.__startPosition;
|
||||
|
||||
if( insertLength < 0 )
|
||||
{
|
||||
startPos += insertLength;
|
||||
insertLength = 0;
|
||||
}
|
||||
|
||||
return function() {
|
||||
var contentRedo = feeder.content.substr( startPos, insertLength );
|
||||
feeder.content =
|
||||
@ -128,8 +123,15 @@
|
||||
|
||||
var f = ContentPosition( feeder );
|
||||
|
||||
this.__contentUndo = feeder.content.substr( f, 1 ) + this.__contentUndo;
|
||||
this.__insertLength --;
|
||||
if( this.__insertLength <= 0 )
|
||||
{
|
||||
this.__contentUndo = feeder.content.substr( f, 1 ) + this.__contentUndo;
|
||||
this.__startPosition --;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.__insertLength --;
|
||||
}
|
||||
|
||||
feeder.content =
|
||||
feeder.content.substring( 0, f )
|
||||
@ -140,7 +142,6 @@
|
||||
var f = ContentPosition( feeder );
|
||||
|
||||
this.__contentUndo += feeder.content.substr( f, 1 );
|
||||
this.__insertLength ++;
|
||||
|
||||
feeder.content =
|
||||
feeder.content.substring( 0, f )
|
||||
|
@ -45,7 +45,7 @@
|
||||
|
||||
e.preventDefault();
|
||||
var kCode = e.keyCode
|
||||
+ ( e.shiftKey ? SHIFT : 0 )
|
||||
+ ( e.shiftKey || e.getModifierState( "CapsLock" ) ? SHIFT : 0 )
|
||||
+ ( e.ctrlKey ? CTRL : 0 );
|
||||
|
||||
var cfeeder = sender.contentFeeder;
|
||||
|
@ -13,19 +13,16 @@
|
||||
if( i == -1 || !this.__steps.length ) return null;
|
||||
|
||||
|
||||
this.__i -= 2;
|
||||
return this.__steps[ i ];
|
||||
return this.__steps[ this.__i = i ];
|
||||
};
|
||||
|
||||
Recorder.prototype.redo = function()
|
||||
{
|
||||
var i = this.__i + 1;
|
||||
if( i == -1 || !this.__steps.length ) return null;
|
||||
var State = this.__steps[ this.__i ];
|
||||
|
||||
var State = this.__steps[ i ];
|
||||
if( State )
|
||||
{
|
||||
this.__i += 2;
|
||||
this.__i ++;
|
||||
return State;
|
||||
}
|
||||
|
||||
@ -35,9 +32,7 @@
|
||||
Recorder.prototype.record = function( StateObj )
|
||||
{
|
||||
this.__steps[ this.__i ] = StateObj;
|
||||
StateObj.id = this.__i;
|
||||
|
||||
delete this.__steps[ ++ this.__i ];
|
||||
StateObj.id = this.__i ++;
|
||||
};
|
||||
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "Recorder", Recorder );
|
||||
|
Loading…
Reference in New Issue
Block a user