Proper REDO / UNDO function ( without cursor pos )

This commit is contained in:
2016-03-17 06:08:38 +08:00
parent f1653727f2
commit 865530709b
3 changed files with 15 additions and 19 deletions

View File

@@ -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 )