added g8, v ( hightlight only )

Some structural changes on VimControls
This commit is contained in:
2016-03-22 02:08:07 +08:00
parent 8769e69f35
commit e52c312af5
8 changed files with 307 additions and 138 deletions

View File

@@ -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;

View 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 );
})();

View 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 );
})();