forked from Botanical/BotanJS
Added c command
This commit is contained in:
parent
2fda27b7be
commit
0e84b4c260
@ -15,7 +15,7 @@
|
||||
var occurence = __import( "System.utils.Perf.CountSubstr" );
|
||||
|
||||
/** @type {Components.Vim.IAction} */
|
||||
var DELETE = function( Cursor )
|
||||
var DELETE = function( Cursor, e )
|
||||
{
|
||||
/** @type {Components.Vim.Cursor} */
|
||||
this.__cursor = Cursor;
|
||||
@ -23,6 +23,10 @@
|
||||
this.__startX = Cursor.aPos;
|
||||
this.__panY = this.__cursor.feeder.panY;
|
||||
|
||||
this.__cMode = e.kMap( "c" );
|
||||
this.__cMode_c = false;
|
||||
this.__enterEvent = e;
|
||||
|
||||
Cursor.suppressEvent();
|
||||
};
|
||||
|
||||
@ -30,7 +34,26 @@
|
||||
|
||||
DELETE.prototype.dispose = function()
|
||||
{
|
||||
this.__cursor.unsuppressEvent();
|
||||
var cur = this.__cursor;
|
||||
cur.unsuppressEvent();
|
||||
|
||||
if( this.__cMode )
|
||||
{
|
||||
if( this.__cMode_c ) // Append, a
|
||||
{
|
||||
cur.fixTab();
|
||||
cur.moveX( 1, false, true, true );
|
||||
}
|
||||
else // Insert, i
|
||||
{
|
||||
cur.moveX( -1, true );
|
||||
cur.moveX( 1, true, true, true );
|
||||
}
|
||||
|
||||
setTimeout( function() {
|
||||
cur.openAction( "INSERT", this.__enterEvent );
|
||||
}, 20 );
|
||||
}
|
||||
};
|
||||
|
||||
DELETE.prototype.handler = function( e, sp, newLine )
|
||||
@ -117,6 +140,13 @@
|
||||
sp = cur.aPos;
|
||||
cur.lineStart();
|
||||
}
|
||||
else if( this.__cMode && e.kMap( "c" ) )
|
||||
{
|
||||
cur.lineEnd();
|
||||
sp = cur.aPos;
|
||||
cur.lineStart( true );
|
||||
this.__cMode_c = true;
|
||||
}
|
||||
else if( e.range )
|
||||
{
|
||||
sp = e.range.close;
|
||||
|
@ -311,6 +311,7 @@
|
||||
break;
|
||||
|
||||
case D: // Del with motion
|
||||
case C: // Then insert
|
||||
ccur.openAction( "DELETE", e );
|
||||
break;
|
||||
case Y: // Yank with motion
|
||||
@ -743,6 +744,7 @@
|
||||
{
|
||||
j += lines[i].content.length;
|
||||
}
|
||||
j += Math.max( 0, Math.floor( j / dispLine.cols ) - 1 );
|
||||
ccur.moveX( j );
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,6 @@
|
||||
var ntabs = occurence( rline.substring( s + 1, e + 1 ), "\t" );
|
||||
if( 1 < ntabs && rline[ e ] == "\t" ) ntabs --;
|
||||
x += ntabs * tabStep + isLF;
|
||||
x += Math.max( 0, Math.floor( d / line.cols ) - 1 );
|
||||
|
||||
// Reset the distance to 1 as x is now calculated
|
||||
d = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user