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} */
this.__cursor = Cursor;
this.__startX = Cursor.aPos;
this.__startState = this.__saveCur();
// Initialize this stack
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()
{
this.__cursor.moveX( -1 );
@@ -46,8 +58,11 @@
var insertLength = this.__insertLength;
var contentUndo = this.__contentUndo;
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() {
var contentRedo = feeder.content.substr( startPos, insertLength );
feeder.content =
@@ -57,7 +72,15 @@
insertLength = contentUndo.length;
contentUndo = contentRedo;
cur.P = st.p;
cur.X = st.x;
cur.Y = st.y;
feeder.panX = st.px;
feeder.panY = st.py;
feeder.pan();
st = ( st == sSt ) ? eSt : sSt;
};
};
@@ -168,7 +191,15 @@
this.__rec( inputChar );
cur.moveX( 1 );
if( inputChar == "\n" )
{
cur.moveY( 1 );
cur.lineStart();
}
else
{
cur.moveX( 1 );
}
};
INSERT.prototype.getMessage = function()