forked from Botanical/BotanJS
Various bug fixes, rename InputEvent to ActionEvent
This commit is contained in:
parent
397239705c
commit
6f7a1cc92c
@ -128,6 +128,8 @@
|
||||
LoopGuard = r.index;
|
||||
}
|
||||
|
||||
this.__msg = PATTERN.join( "" )
|
||||
|
||||
if( e.kMap( "N" ) )
|
||||
{
|
||||
Hit = PrevStack[ PrevStack.length - 2 ];
|
||||
@ -144,10 +146,6 @@
|
||||
Hit = FirstHit;
|
||||
this.__msg = Mesg( "SEARCH_HIT_BOTTOM" );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.__msg = PATTERN.join( "" )
|
||||
}
|
||||
|
||||
if( Hit == undefined )
|
||||
{
|
||||
|
@ -37,7 +37,7 @@
|
||||
var msg = ":register";
|
||||
msg += "\n" + Mesg( "REGISTERS" );
|
||||
|
||||
var regs = "\"0123456789-.:%/=";
|
||||
var regs = "\"0123456789abcdefghijklmnopqrstuvwxyz-.:%/=";
|
||||
for( var i = 0, j = regs[ i ]; j != undefined; i ++, j = regs[ i ] )
|
||||
{
|
||||
var r = reg.get( j );
|
||||
|
@ -47,6 +47,8 @@
|
||||
var COMMA = 188; var FULLSTOP = 190;
|
||||
var SLASH = 191; var BACK_SLASH = 220;
|
||||
|
||||
var QUOTE = 222;
|
||||
|
||||
var ANY_KEY = -1;
|
||||
|
||||
var __maps = {};
|
||||
@ -177,9 +179,8 @@
|
||||
{
|
||||
if( compReg.i == keys.length )
|
||||
{
|
||||
compReg.handler( e );
|
||||
this.__compositeReg = null;
|
||||
this.__cMovement = false;
|
||||
compReg.handler( e );
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -188,7 +189,6 @@
|
||||
|
||||
if( this.__compositeReg ) beep();
|
||||
this.__compositeReg = null;
|
||||
this.__cMovement = false;
|
||||
return false;
|
||||
};
|
||||
|
||||
@ -219,13 +219,13 @@
|
||||
case SHIFT + O: // new line before insert
|
||||
ccur.lineStart();
|
||||
ccur.openAction( "INSERT" );
|
||||
ccur.action.handler( new InputEvent( e.sender, "Enter" ) );
|
||||
ccur.action.handler( new ActionEvent( e.sender, "Enter" ) );
|
||||
ccur.moveY( -1 );
|
||||
break;
|
||||
case O: // new line insert
|
||||
ccur.lineEnd( true );
|
||||
ccur.openAction( "INSERT" );
|
||||
ccur.action.handler( new InputEvent( e.sender, "Enter" ) );
|
||||
ccur.action.handler( new ActionEvent( e.sender, "Enter" ) );
|
||||
break;
|
||||
|
||||
case U: // Undo
|
||||
@ -320,6 +320,60 @@
|
||||
return false;
|
||||
};
|
||||
|
||||
Controls.prototype.__modCommand = function( e )
|
||||
{
|
||||
var catchCommand = false;
|
||||
if( this.__mod )
|
||||
{
|
||||
e.preventDefault();
|
||||
this.__composite( e );
|
||||
return catchCommand;
|
||||
}
|
||||
|
||||
var _self = this;
|
||||
var mod = true;
|
||||
|
||||
var cur = this.__cursor;
|
||||
switch( e.keyCode )
|
||||
{
|
||||
case SHIFT + QUOTE:
|
||||
this.__composite( e, function( e2 ) {
|
||||
e2.target.registers.select( e2.key );
|
||||
_self.__mod = false;
|
||||
}, ANY_KEY );
|
||||
break;
|
||||
case _0: case _1: case _2: case _3: case _4:
|
||||
case _5: case _6: case _7: case _8: case _9:
|
||||
|
||||
var Count = e.key;
|
||||
var recurNum = function( e2 ) {
|
||||
switch( e2.keyCode )
|
||||
{
|
||||
case _0: case _1: case _2:
|
||||
case _3: case _4: case _5:
|
||||
case _6: case _7: case _8: case _9:
|
||||
Count += e2.key;
|
||||
_self.__composite( e2, recurNum, ANY_KEY );
|
||||
return;
|
||||
}
|
||||
|
||||
debug.Info( "Count is: " + Count );
|
||||
catchCommand = true;
|
||||
_self.__mod = false;
|
||||
};
|
||||
|
||||
this.__composite( e, recurNum, ANY_KEY );
|
||||
break;
|
||||
default:
|
||||
mod = false;
|
||||
}
|
||||
|
||||
this.__mod = mod;
|
||||
if( mod ) e.preventDefault();
|
||||
|
||||
return mod;
|
||||
};
|
||||
|
||||
Controls.prototype.__cursorCommand = function( e )
|
||||
{
|
||||
var kCode = e.keyCode;
|
||||
@ -329,6 +383,7 @@
|
||||
if( !e.ModKeys )
|
||||
{
|
||||
this.__composite( e );
|
||||
this.__cMovement = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -520,7 +575,7 @@
|
||||
|
||||
/**
|
||||
* sender @param {Components.Vim.VimArea}
|
||||
* e @param {Components.Vim.Controls.InputEvent}
|
||||
* e @param {Components.Vim.Controls.ActionEvent}
|
||||
* */
|
||||
Controls.prototype.handler = function( sender, e )
|
||||
{
|
||||
@ -567,6 +622,8 @@
|
||||
if( e.canceled ) return;
|
||||
}
|
||||
|
||||
if( this.__modCommand( e ) ) return;
|
||||
|
||||
var cfeeder = this.__cfeeder;
|
||||
var ccur = this.__ccur;
|
||||
|
||||
@ -607,7 +664,7 @@
|
||||
if( this.__actionCommand( e ) ) return;
|
||||
};
|
||||
|
||||
var InputEvent = function( sender, e )
|
||||
var ActionEvent = function( sender, e )
|
||||
{
|
||||
this.__target = sender;
|
||||
this.__canceled = false;
|
||||
@ -641,19 +698,20 @@
|
||||
this.__key = e.key;
|
||||
}
|
||||
|
||||
this.__count = 1;
|
||||
this.__range = null;
|
||||
};
|
||||
|
||||
InputEvent.prototype.cancel = function() { this.__canceled = true; };
|
||||
ActionEvent.prototype.cancel = function() { this.__canceled = true; };
|
||||
|
||||
__readOnly( InputEvent.prototype, "target", function() { return this.__target; } );
|
||||
__readOnly( InputEvent.prototype, "key", function() { return this.__key; } );
|
||||
__readOnly( InputEvent.prototype, "keyCode", function() { return this.__kCode; } );
|
||||
__readOnly( InputEvent.prototype, "ModKeys", function() { return this.__modKeys; } );
|
||||
__readOnly( InputEvent.prototype, "Escape", function() { return this.__escape; } );
|
||||
__readOnly( InputEvent.prototype, "canceled", function() { return this.__canceled; } );
|
||||
__readOnly( ActionEvent.prototype, "target", function() { return this.__target; } );
|
||||
__readOnly( ActionEvent.prototype, "key", function() { return this.__key; } );
|
||||
__readOnly( ActionEvent.prototype, "keyCode", function() { return this.__kCode; } );
|
||||
__readOnly( ActionEvent.prototype, "ModKeys", function() { return this.__modKeys; } );
|
||||
__readOnly( ActionEvent.prototype, "Escape", function() { return this.__escape; } );
|
||||
__readOnly( ActionEvent.prototype, "canceled", function() { return this.__canceled; } );
|
||||
|
||||
__readOnly( InputEvent.prototype, "range", function() {
|
||||
__readOnly( ActionEvent.prototype, "range", function() {
|
||||
|
||||
/** @type {Components.Vim.Syntax.TokenMatch} */
|
||||
var r = this.__range;
|
||||
@ -666,16 +724,20 @@
|
||||
return r;
|
||||
} );
|
||||
|
||||
InputEvent.prototype.kMap = function( map )
|
||||
__readOnly( ActionEvent.prototype, "count", function() {
|
||||
return this.__count;
|
||||
} );
|
||||
|
||||
ActionEvent.prototype.kMap = function( map )
|
||||
{
|
||||
return this.__kCode == Map( map );
|
||||
};
|
||||
|
||||
InputEvent.prototype.preventDefault = function()
|
||||
ActionEvent.prototype.preventDefault = function()
|
||||
{
|
||||
if( this.__e ) this.__e.preventDefault();
|
||||
};
|
||||
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "Controls", Controls );
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "InputEvent", InputEvent );
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "ActionEvent", ActionEvent );
|
||||
})();
|
||||
|
@ -15,6 +15,9 @@
|
||||
*/
|
||||
var ns = __namespace( "Components.Vim.State" );
|
||||
|
||||
/** @type {System.Debug} */
|
||||
var debug = __import( "System.Debug" );
|
||||
|
||||
var Register = function( str, n )
|
||||
{
|
||||
this.__str = str + "";
|
||||
@ -43,7 +46,8 @@
|
||||
{
|
||||
var reg = new Register( str, newLine );
|
||||
this.__unnamed( reg );
|
||||
this.__registers[ 0 ] = reg;
|
||||
this.__registers[ this.__selRegister || 0 ] = reg;
|
||||
this.__selRegister = false;
|
||||
};
|
||||
|
||||
Registers.prototype.change = function( str, newLine )
|
||||
@ -60,16 +64,24 @@
|
||||
}
|
||||
|
||||
r[ 1 ] = reg;
|
||||
this.__selRegister = false;
|
||||
};
|
||||
|
||||
Registers.prototype.get = function( r )
|
||||
{
|
||||
// 0 is one of the registers
|
||||
if( !r && r !== 0 ) r = "\"";
|
||||
if( !r && r !== 0 ) r = this.__selRegister || "\"";
|
||||
|
||||
this.__selRegister = false;
|
||||
return this.__registers[ r ];
|
||||
};
|
||||
|
||||
Registers.prototype.select = function( r )
|
||||
{
|
||||
debug.Info( "Selecting Register: " + r );
|
||||
this.__selRegister = r;
|
||||
};
|
||||
|
||||
ns[ NS_EXPORT ]( EX_CLASS, "Registers", Registers );
|
||||
|
||||
})();
|
||||
|
@ -23,7 +23,7 @@
|
||||
var StatusBar = ns[ NS_INVOKE ]( "StatusBar" );
|
||||
|
||||
var VimControls = ns[ NS_INVOKE ]( "Controls" );
|
||||
var InputEvent = ns[ NS_INVOKE ]( "InputEvent" );
|
||||
var ActionEvent = ns[ NS_INVOKE ]( "ActionEvent" );
|
||||
var mesg = ns[ NS_INVOKE ]( "Message" );
|
||||
|
||||
var Insts = [];
|
||||
@ -38,7 +38,7 @@
|
||||
if ( e.keyCode ) code = e.keyCode;
|
||||
else if ( e.which ) code = e.which;
|
||||
|
||||
handler( sender, new InputEvent( sender, e ) );
|
||||
handler( sender, new ActionEvent( sender, e ) );
|
||||
};
|
||||
};
|
||||
|
||||
|
23
botanjs/src/externs/Components.Vim.Controls.ActionEvent.js
Normal file
23
botanjs/src/externs/Components.Vim.Controls.ActionEvent.js
Normal file
@ -0,0 +1,23 @@
|
||||
/** @constructor */
|
||||
Components.Vim.Controls.ActionEvent = function(){};
|
||||
|
||||
/** @type {Components.Vim.VimArea} */
|
||||
Components.Vim.Controls.ActionEvent.target;
|
||||
/** @type {Components.Vim.Syntax.TokenMatch} */
|
||||
Components.Vim.Controls.ActionEvent.range;
|
||||
/** @type {Components.Vim.Syntax.Number} */
|
||||
Components.Vim.Controls.ActionEvent.count;
|
||||
/** @type String */
|
||||
Components.Vim.Controls.ActionEvent.key;
|
||||
/** @type Boolean */
|
||||
Components.Vim.Controls.ActionEvent.ModKeys;
|
||||
/** @type Boolean */
|
||||
Components.Vim.Controls.ActionEvent.Escape;
|
||||
/** @type Boolean */
|
||||
Components.Vim.Controls.ActionEvent.canceled;
|
||||
/** @type Number */
|
||||
Components.Vim.Controls.ActionEvent.keyCode;
|
||||
/** @type Function */
|
||||
Components.Vim.Controls.ActionEvent.kMap;
|
||||
/** @type Function */
|
||||
Components.Vim.Controls.ActionEvent.cancel;
|
@ -1,21 +0,0 @@
|
||||
/** @constructor */
|
||||
Components.Vim.Controls.InputEvent = function(){};
|
||||
|
||||
/** @type {Components.Vim.VimArea} */
|
||||
Components.Vim.Controls.InputEvent.target;
|
||||
/** @type {Components.Vim.Syntax.TokenMatch} */
|
||||
Components.Vim.Controls.InputEvent.range;
|
||||
/** @type String */
|
||||
Components.Vim.Controls.InputEvent.key;
|
||||
/** @type Boolean */
|
||||
Components.Vim.Controls.InputEvent.ModKeys;
|
||||
/** @type Boolean */
|
||||
Components.Vim.Controls.InputEvent.Escape;
|
||||
/** @type Boolean */
|
||||
Components.Vim.Controls.InputEvent.canceled;
|
||||
/** @type Number */
|
||||
Components.Vim.Controls.InputEvent.keyCode;
|
||||
/** @type Function */
|
||||
Components.Vim.Controls.InputEvent.kMap;
|
||||
/** @type Function */
|
||||
Components.Vim.Controls.InputEvent.cancel;
|
Loading…
Reference in New Issue
Block a user