forked from Botanical/BotanJS
added g8, v ( hightlight only )
Some structural changes on VimControls
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
this.__rec( "", true );
|
||||
};
|
||||
|
||||
INSERT.prototype.allowMovement = false;
|
||||
|
||||
INSERT.prototype.__saveCur = function()
|
||||
{
|
||||
var c = this.__cursor;
|
||||
@@ -80,7 +82,8 @@
|
||||
insertLength = contentUndo.length;
|
||||
contentUndo = contentRedo;
|
||||
|
||||
cur.P = st.p;
|
||||
cur.PStart = st.p;
|
||||
cur.PEnd = st.p + 1;
|
||||
cur.X = st.x;
|
||||
cur.Y = st.y;
|
||||
feeder.panX = st.px;
|
||||
|
52
botanjs/src/Components/Vim/Actions/PRINT_HEX.js
Normal file
52
botanjs/src/Components/Vim/Actions/PRINT_HEX.js
Normal file
@@ -0,0 +1,52 @@
|
||||
(function(){
|
||||
var ns = __namespace( "Components.Vim.Actions" );
|
||||
|
||||
/** @type {Components.Vim.State.Stack} */
|
||||
var Stack = __import( "Components.Vim.State.Stack" );
|
||||
/** @type {System.Debug} */
|
||||
var debug = __import( "System.Debug" );
|
||||
|
||||
/** @type {Components.Vim.Cursor.IAction} */
|
||||
var PRINT_HEX = function( Cursor )
|
||||
{
|
||||
/** @type {Components.Vim.Cursor} */
|
||||
this.__cursor = Cursor;
|
||||
};
|
||||
|
||||
PRINT_HEX.prototype.dispose = function()
|
||||
{
|
||||
};
|
||||
|
||||
PRINT_HEX.prototype.handler = function( e )
|
||||
{
|
||||
e.preventDefault();
|
||||
var str = unescape( encodeURIComponent( this.__cursor.feeder.content[ this.__cursor.aPos ] ) );
|
||||
var l = str.length;
|
||||
var msg = [];
|
||||
for( var i = 0; i < l; i ++ )
|
||||
{
|
||||
msg[i] = str[i] == "\n"
|
||||
? "a"
|
||||
: str.charCodeAt( i ).toString( 16 )
|
||||
;
|
||||
|
||||
if( msg[i].length == 1 )
|
||||
{
|
||||
msg[i] = "0" + msg[i];
|
||||
}
|
||||
else if( msg[i].length == 0 )
|
||||
{
|
||||
msg[i] = "00";
|
||||
}
|
||||
}
|
||||
|
||||
this.__msg = msg.join( " " );
|
||||
};
|
||||
|
||||
PRINT_HEX.prototype.getMessage = function()
|
||||
{
|
||||
return this.__msg;
|
||||
};
|
||||
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "PRINT_HEX", PRINT_HEX );
|
||||
})();
|
67
botanjs/src/Components/Vim/Actions/VISUAL.js
Normal file
67
botanjs/src/Components/Vim/Actions/VISUAL.js
Normal file
@@ -0,0 +1,67 @@
|
||||
(function(){
|
||||
var ns = __namespace( "Components.Vim.Actions" );
|
||||
|
||||
/** @type {Components.Vim.State.Stack} */
|
||||
var Stack = __import( "Components.Vim.State.Stack" );
|
||||
/** @type {System.Debug} */
|
||||
var debug = __import( "System.Debug" );
|
||||
|
||||
var Mesg = __import( "Components.Vim.Message" );
|
||||
|
||||
/** @type {Components.Vim.Cursor.IAction} */
|
||||
var VISUAL = function( Cursor )
|
||||
{
|
||||
/** @type {Components.Vim.Cursor} */
|
||||
this.__cursor = Cursor;
|
||||
this.__startaP = Cursor.aPos;
|
||||
this.__start = Cursor.PStart;
|
||||
this.__selStart = Cursor.PStart;
|
||||
|
||||
Cursor.blink = false;
|
||||
};
|
||||
|
||||
VISUAL.prototype.allowMovement = true;
|
||||
|
||||
VISUAL.prototype.dispose = function()
|
||||
{
|
||||
this.__cursor.blink = true;
|
||||
this.__cursor.PStart = this.__selStart;
|
||||
this.__cursor.PEnd = this.__selStart + 1;
|
||||
};
|
||||
|
||||
|
||||
VISUAL.prototype.handler = function( e )
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
if( [ 16, 17, 18 ].indexOf( e.keyCode ) != -1 ) return;
|
||||
var cur = this.__cursor;
|
||||
var prevPos = this.__start;
|
||||
var newPos = cur.PStart;
|
||||
|
||||
var posDiff = newPos - prevPos;
|
||||
if( 0 <= posDiff )
|
||||
{
|
||||
this.__selStart = newPos;
|
||||
newPos = newPos + 1;
|
||||
}
|
||||
else if( posDiff < 0 )
|
||||
{
|
||||
prevPos += posDiff;
|
||||
newPos = this.__start + 1;
|
||||
this.__selStart = prevPos;
|
||||
}
|
||||
|
||||
cur.PStart = prevPos;
|
||||
cur.PEnd = newPos;
|
||||
};
|
||||
|
||||
VISUAL.prototype.getMessage = function()
|
||||
{
|
||||
var msg = Mesg( "VISUAL" );
|
||||
|
||||
return msg;
|
||||
};
|
||||
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "VISUAL", VISUAL );
|
||||
})();
|
Reference in New Issue
Block a user