Aaiu, cursor position

This commit is contained in:
斟酌 鵬兄 2016-03-19 19:05:07 +08:00
parent b17ca21420
commit dc63a882e3
3 changed files with 46 additions and 11 deletions

View File

@ -27,12 +27,24 @@
/** @type {Components.Vim.Cursor} */ /** @type {Components.Vim.Cursor} */
this.__cursor = Cursor; this.__cursor = Cursor;
this.__startX = Cursor.aPos; this.__startState = this.__saveCur();
// Initialize this stack // Initialize this stack
this.__rec( "", true ); this.__rec( "", true );
}; };
INSERT.prototype.__saveCur = function()
{
var c = this.__cursor;
return {
p: c.P
, x: c.X
, y: c.Y
, px: c.feeder.panX
, py: c.feeder.panY
};
}
INSERT.prototype.dispose = function() INSERT.prototype.dispose = function()
{ {
this.__cursor.moveX( -1 ); this.__cursor.moveX( -1 );
@ -46,8 +58,11 @@
var insertLength = this.__insertLength; var insertLength = this.__insertLength;
var contentUndo = this.__contentUndo; var contentUndo = this.__contentUndo;
var startPos = this.__startPosition; var startPos = this.__startPosition;
var startX = this.__startX; var sSt = this.__startState;
var eSt = this.__saveCur();
var st = sSt;
// Calling this repeatedly will swap between UNDO / REDO state
return function() { return function() {
var contentRedo = feeder.content.substr( startPos, insertLength ); var contentRedo = feeder.content.substr( startPos, insertLength );
feeder.content = feeder.content =
@ -57,7 +72,15 @@
insertLength = contentUndo.length; insertLength = contentUndo.length;
contentUndo = contentRedo; contentUndo = contentRedo;
cur.P = st.p;
cur.X = st.x;
cur.Y = st.y;
feeder.panX = st.px;
feeder.panY = st.py;
feeder.pan(); feeder.pan();
st = ( st == sSt ) ? eSt : sSt;
}; };
}; };
@ -168,7 +191,15 @@
this.__rec( inputChar ); this.__rec( inputChar );
cur.moveX( 1 ); if( inputChar == "\n" )
{
cur.moveY( 1 );
cur.lineStart();
}
else
{
cur.moveX( 1 );
}
}; };
INSERT.prototype.getMessage = function() INSERT.prototype.getMessage = function()

View File

@ -55,6 +55,7 @@
}; };
Controls.prototype.__comboT = function( e ) { return false; }; Controls.prototype.__comboT = function( e ) { return false; };
Controls.prototype.__comboD = function( e ) { return false; };
// < // <
Controls.prototype.__comboLeftShift = function( e ) { return false; }; Controls.prototype.__comboLeftShift = function( e ) { return false; };
@ -65,6 +66,7 @@
Controls.prototype.__comboKey = function( e ) Controls.prototype.__comboKey = function( e )
{ {
return this.__comboG( e ) return this.__comboG( e )
|| this.__comboD( e )
|| this.__comboT( e ) || this.__comboT( e )
|| this.__comboLeftShift( e ) || this.__comboLeftShift( e )
|| this.__comboRightShift( e ); || this.__comboRightShift( e );
@ -159,11 +161,12 @@
break; break;
// Insert // Insert
case SHIFT + A: // Append at the line end
ccur.lineEnd();
case A: // Append case A: // Append
cMoveX( 1, true, true ); cMoveX( 1, true, true );
ccur.openAction( "INSERT" );
break;
case I: // Insert case I: // Insert
ccur.openAction( "INSERT" );
break; break;
case U: // Undo case U: // Undo
ccur.openRunAction( "UNDO", e ); ccur.openRunAction( "UNDO", e );
@ -173,8 +176,6 @@
break; break;
case X: // Del case X: // Del
break; break;
case SHIFT + A: // Append at the line end
break;
case SHIFT + X: // Delete before case SHIFT + X: // Delete before
break; break;
case SHIFT + U: // Undo previous changes in oneline case SHIFT + U: // Undo previous changes in oneline

View File

@ -112,11 +112,14 @@
var buffs = this.feeder.lineBuffers; var buffs = this.feeder.lineBuffers;
if( penentrate && x < 0 && ( 0 < this.feeder.panY || 0 < this.Y ) ) if( penentrate )
{ {
this.moveY( -1 ); if( x < 0 && ( 0 < this.feeder.panY || 0 < this.Y ) )
this.lineEnd( phantomSpace ); {
return; this.moveY( -1 );
this.lineEnd( phantomSpace );
return;
}
} }
/** @type {Components.Vim.LineBuffer} */ /** @type {Components.Vim.LineBuffer} */