forked from Botanical/BotanJS
Put command
This commit is contained in:
@@ -151,9 +151,9 @@
|
||||
feeder.content = c.substring( 0, s ) + c.substring( e + 1 );
|
||||
|
||||
// Try to keep the original panning if possible
|
||||
cur.feeder.pan( undefined
|
||||
, this.__panY < cur.feeder.panY
|
||||
? this.__panY - cur.feeder.panY
|
||||
feeder.pan( undefined
|
||||
, this.__panY < feeder.panY
|
||||
? this.__panY - feeder.panY
|
||||
: undefined
|
||||
);
|
||||
|
||||
|
@@ -29,7 +29,7 @@
|
||||
/** @type {Components.Vim.Cursor} */
|
||||
this.__cursor = Cursor;
|
||||
|
||||
this.__Stator = new Stator( Cursor );
|
||||
this.__stator = new Stator( Cursor );
|
||||
|
||||
// Initialize this stack
|
||||
this.__rec( "", true );
|
||||
@@ -55,7 +55,7 @@
|
||||
) return;
|
||||
|
||||
this.__stack.store(
|
||||
this.__Stator.save( this.__insertLength, this.__contentUndo )
|
||||
this.__stator.save( this.__insertLength, this.__contentUndo )
|
||||
);
|
||||
|
||||
this.__cursor.rec.record( this.__stack );
|
||||
|
81
botanjs/src/Components/Vim/Actions/PUT.js
Normal file
81
botanjs/src/Components/Vim/Actions/PUT.js
Normal file
@@ -0,0 +1,81 @@
|
||||
(function(){
|
||||
var ns = __namespace( "Components.Vim.Actions" );
|
||||
|
||||
var Mesg = __import( "Components.Vim.Message" );
|
||||
|
||||
/** @type {Components.Vim.State.Stator} */
|
||||
var Stator = __import( "Components.Vim.State.Stator" );
|
||||
/** @type {Components.Vim.State.Stack} */
|
||||
var Stack = __import( "Components.Vim.State.Stack" );
|
||||
|
||||
var Mesg = __import( "Components.Vim.Message" );
|
||||
var occurence = __import( "System.utils.Perf.CountSubstr" );
|
||||
|
||||
/** @type {Components.Vim.Cursor.IAction} */
|
||||
var PUT = function( Cursor )
|
||||
{
|
||||
/** @type {Components.Vim.Cursor} */
|
||||
this.__cursor = Cursor;
|
||||
this.__stator = new Stator( Cursor );
|
||||
this.__msg = "";
|
||||
};
|
||||
|
||||
PUT.prototype.allowMovement = false;
|
||||
|
||||
PUT.prototype.dispose = function()
|
||||
{
|
||||
};
|
||||
|
||||
PUT.prototype.handler = function( e )
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
// TODO: Get the input for determinating registers
|
||||
var inputStack = false;
|
||||
|
||||
var cput = this.__cursor.Vim.registers.get( inputStack );
|
||||
if( !cput ) return true;
|
||||
|
||||
var clen = cput.length;
|
||||
var nLines = occurence( cput, "\n" );
|
||||
|
||||
var cur = this.__cursor;
|
||||
var feeder = cur.feeder;
|
||||
|
||||
var aP = cur.aPos;
|
||||
|
||||
feeder.content = feeder.content.substring( 0, aP )
|
||||
+ cput
|
||||
+ feeder.content.substring( aP );
|
||||
|
||||
cur.suppressEvent();
|
||||
feeder.pan();
|
||||
|
||||
cur.moveTo( 0 < nLines ? aP : aP + clen, true );
|
||||
|
||||
var stack = new Stack();
|
||||
|
||||
stack.store( this.__stator.save( clen, "" ) );
|
||||
cur.rec.record( stack );
|
||||
|
||||
this.__put = cput;
|
||||
|
||||
if( nLines )
|
||||
{
|
||||
this.__msg = Mesg( "LINE_MORE", nLines );
|
||||
}
|
||||
|
||||
cur.moveX( -1 );
|
||||
cur.unsuppressEvent();
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
PUT.prototype.getMessage = function()
|
||||
{
|
||||
console.log( this.__msg );
|
||||
return this.__msg;
|
||||
};
|
||||
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "PUT", PUT );
|
||||
})();
|
@@ -76,6 +76,12 @@
|
||||
}
|
||||
|
||||
Action.handler( e, this.__startaP );
|
||||
|
||||
if( Action.constructor != DELETE )
|
||||
{
|
||||
cur.moveTo( this.__startaP );
|
||||
}
|
||||
|
||||
this.__leaveMesg = Action.getMessage();
|
||||
|
||||
Action.dispose();
|
||||
|
Reference in New Issue
Block a user