forked from Botanical/BotanJS
Aaiu, cursor position
This commit is contained in:
@@ -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()
|
||||
|
Reference in New Issue
Block a user