forked from Botanical/BotanJS
InputEvent carrying range
This commit is contained in:
parent
a7d2e80f4a
commit
9faf2b4921
@ -128,7 +128,7 @@
|
|||||||
this.__ccur = this.__cfeeder.cursor;
|
this.__ccur = this.__cfeeder.cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
Controls.prototype.__comp = function( kCode, handler )
|
Controls.prototype.__comp = function( e, handler )
|
||||||
{
|
{
|
||||||
if( handler )
|
if( handler )
|
||||||
{
|
{
|
||||||
@ -141,6 +141,8 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var kCode = e.keyCode;
|
||||||
|
|
||||||
for( var i = 0; i < this.__compReg.length; i ++ )
|
for( var i = 0; i < this.__compReg.length; i ++ )
|
||||||
{
|
{
|
||||||
var compReg = this.__compReg[i];
|
var compReg = this.__compReg[i];
|
||||||
@ -150,7 +152,7 @@
|
|||||||
{
|
{
|
||||||
if( compReg.i == keys.length )
|
if( compReg.i == keys.length )
|
||||||
{
|
{
|
||||||
compReg.handler();
|
compReg.handler( e );
|
||||||
this.__compReg = null;
|
this.__compReg = null;
|
||||||
this.__cMovement = false;
|
this.__cMovement = false;
|
||||||
}
|
}
|
||||||
@ -249,7 +251,7 @@
|
|||||||
{
|
{
|
||||||
if( !e.ModKeys )
|
if( !e.ModKeys )
|
||||||
{
|
{
|
||||||
this.__comp( kCode );
|
this.__comp( e );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -312,23 +314,26 @@
|
|||||||
|
|
||||||
this.__cMovement = true;
|
this.__cMovement = true;
|
||||||
// Word boundary
|
// Word boundary
|
||||||
this.__comp( kCode, function(){
|
this.__comp( e, function( e2 ) {
|
||||||
var WordMatch = analyzer.wordAt( ccur.aPos );
|
var WordMatch = analyzer.wordAt( ccur.aPos );
|
||||||
|
|
||||||
debug.Info( "Word: "
|
debug.Info( "Word: "
|
||||||
+ ccur.feeder.content.substring( WordMatch.open, WordMatch.close + 1 )
|
+ ccur.feeder.content.substring( WordMatch.open, WordMatch.close + 1 )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
e2.__range = WordMatch;
|
||||||
|
|
||||||
}, W );
|
}, W );
|
||||||
this.__comp( kCode, function(){
|
this.__comp( e, function(){
|
||||||
debug.Info( "Bracket boundary [" );
|
debug.Info( "Bracket boundary [" );
|
||||||
}, S_BRACKET_L );
|
}, S_BRACKET_L );
|
||||||
this.__comp( kCode, function(){
|
this.__comp( e, function(){
|
||||||
debug.Info( "Bracket boundary ]" );
|
debug.Info( "Bracket boundary ]" );
|
||||||
}, S_BRACKET_R );
|
}, S_BRACKET_R );
|
||||||
this.__comp( kCode, function(){
|
this.__comp( e, function(){
|
||||||
debug.Info( "Bracket boundary {" );
|
debug.Info( "Bracket boundary {" );
|
||||||
}, SHIFT + S_BRACKET_L );
|
}, SHIFT + S_BRACKET_L );
|
||||||
this.__comp( kCode, function(){
|
this.__comp( e, function(){
|
||||||
debug.Info( "Bracket boundary }" );
|
debug.Info( "Bracket boundary }" );
|
||||||
analyzer.bracketAt( ccur.aPos );
|
analyzer.bracketAt( ccur.aPos );
|
||||||
}, SHIFT + S_BRACKET_R );
|
}, SHIFT + S_BRACKET_R );
|
||||||
@ -336,11 +341,11 @@
|
|||||||
|
|
||||||
case G: // Go to top
|
case G: // Go to top
|
||||||
this.__cMovement = true;
|
this.__cMovement = true;
|
||||||
this.__comp( kCode, function(){
|
this.__comp( e, function(){
|
||||||
ccur.moveY( -Number.MAX_VALUE );
|
ccur.moveY( -Number.MAX_VALUE );
|
||||||
ccur.moveX( -Number.MAX_VALUE, true );
|
ccur.moveX( -Number.MAX_VALUE, true );
|
||||||
}, G );
|
}, G );
|
||||||
this.__comp( kCode, function(){
|
this.__comp( e, function(){
|
||||||
ccur.openRunAction( "PRINT_HEX", e );
|
ccur.openRunAction( "PRINT_HEX", e );
|
||||||
}, _8 );
|
}, _8 );
|
||||||
break;
|
break;
|
||||||
@ -420,6 +425,8 @@
|
|||||||
|
|
||||||
this.__modKeys = c == KEY_SHIFT || c == KEY_CTRL || c == KEY_ALT;
|
this.__modKeys = c == KEY_SHIFT || c == KEY_CTRL || c == KEY_ALT;
|
||||||
this.__key = e.key;
|
this.__key = e.key;
|
||||||
|
|
||||||
|
this.__range = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
__readOnly( InputEvent.prototype, "target", function() { return this.__target; } );
|
__readOnly( InputEvent.prototype, "target", function() { return this.__target; } );
|
||||||
@ -428,6 +435,19 @@
|
|||||||
__readOnly( InputEvent.prototype, "ModKeys", function() { return this.__modKeys; } );
|
__readOnly( InputEvent.prototype, "ModKeys", function() { return this.__modKeys; } );
|
||||||
__readOnly( InputEvent.prototype, "Escape", function() { return this.__escape; } );
|
__readOnly( InputEvent.prototype, "Escape", function() { return this.__escape; } );
|
||||||
|
|
||||||
|
__readOnly( InputEvent.prototype, "range", function() {
|
||||||
|
|
||||||
|
/** @type {Components.Vim.Syntax.TokenMatch} */
|
||||||
|
var r = this.__range;
|
||||||
|
|
||||||
|
if( r && r.open == -1 && r.close == -1 )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
} );
|
||||||
|
|
||||||
InputEvent.prototype.kMap = function( map )
|
InputEvent.prototype.kMap = function( map )
|
||||||
{
|
{
|
||||||
return this.__kCode == Map( map );
|
return this.__kCode == Map( map );
|
||||||
|
@ -262,7 +262,7 @@
|
|||||||
if( p < Len ) while( word.test( c[ ++ j ] ) );
|
if( p < Len ) while( word.test( c[ ++ j ] ) );
|
||||||
|
|
||||||
var tMatch = new TokenMatch();
|
var tMatch = new TokenMatch();
|
||||||
tMatch.__open = i + 1;
|
tMatch.__open = 0 < i ? i + 1 : 0;
|
||||||
tMatch.__close = j - 1;
|
tMatch.__close = j - 1;
|
||||||
|
|
||||||
return tMatch;
|
return tMatch;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
]
|
]
|
||||||
,
|
,
|
||||||
[
|
[
|
||||||
, [ 0x0250, 0x02AF ] // IPA Extensions
|
[ 0x0250, 0x02AF ] // IPA Extensions
|
||||||
, [ 0x02B0, 0x02FF ] // Spacing Modifier Letters
|
, [ 0x02B0, 0x02FF ] // Spacing Modifier Letters
|
||||||
, [ 0x0300, 0x036F ] // Combining Diacritical Marks
|
, [ 0x0300, 0x036F ] // Combining Diacritical Marks
|
||||||
, [ 0x0370, 0x03FF ] // Greek and Coptic
|
, [ 0x0370, 0x03FF ] // Greek and Coptic
|
||||||
@ -129,7 +129,7 @@
|
|||||||
]
|
]
|
||||||
,
|
,
|
||||||
[ // CJK scripts and symbols
|
[ // CJK scripts and symbols
|
||||||
, [ 0x2E80, 0x2EFF ] // CJK Radicals Supplement
|
[ 0x2E80, 0x2EFF ] // CJK Radicals Supplement
|
||||||
, [ 0x2F00, 0x2FDF ] // Kangxi Radicals
|
, [ 0x2F00, 0x2FDF ] // Kangxi Radicals
|
||||||
, [ 0x2FF0, 0x2FFF ] // Ideographic Description Characters
|
, [ 0x2FF0, 0x2FFF ] // Ideographic Description Characters
|
||||||
, [ 0x3000, 0x303F ] // CJK Symbols and Punctuation
|
, [ 0x3000, 0x303F ] // CJK Symbols and Punctuation
|
||||||
@ -177,7 +177,7 @@
|
|||||||
]
|
]
|
||||||
,
|
,
|
||||||
[ // Surrogates
|
[ // Surrogates
|
||||||
, [ 0xD800, 0xDBFF ] // High Surrogates
|
[ 0xD800, 0xDBFF ] // High Surrogates
|
||||||
, [ 0xDC00, 0xDFFF ] // Low Surrogates
|
, [ 0xDC00, 0xDFFF ] // Low Surrogates
|
||||||
, [ 0xE000, 0xF8FF ] // Private Use Area
|
, [ 0xE000, 0xF8FF ] // Private Use Area
|
||||||
, [ 0xF900, 0xFAFF ] // CJK Compatibility Ideographs
|
, [ 0xF900, 0xFAFF ] // CJK Compatibility Ideographs
|
||||||
@ -197,7 +197,7 @@
|
|||||||
// Basic Latin
|
// Basic Latin
|
||||||
[ 0x0021, 0x002F ], [ 0x003A, 0x0040 ], [ 0x005B, 0x0060 ], [ 0x007B, 0x007E ],
|
[ 0x0021, 0x002F ], [ 0x003A, 0x0040 ], [ 0x005B, 0x0060 ], [ 0x007B, 0x007E ],
|
||||||
// C1 Controls and Latin-1 Supplement (Extended ASCII)
|
// C1 Controls and Latin-1 Supplement (Extended ASCII)
|
||||||
[ 0x00A1, 0x00AC ], [ 0x00AE, 0x00BF ],
|
[ 0x00A1, 0x00AC ], [ 0x00AE, 0x00BF ]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ Components.Vim.Controls.InputEvent = function(){};
|
|||||||
|
|
||||||
/** @type {Components.Vim.VimArea} */
|
/** @type {Components.Vim.VimArea} */
|
||||||
Components.Vim.Controls.InputEvent.target;
|
Components.Vim.Controls.InputEvent.target;
|
||||||
|
/** @type {Components.Vim.Syntax.TokenMatch} */
|
||||||
|
Components.Vim.Controls.InputEvent.range;
|
||||||
/** @type String */
|
/** @type String */
|
||||||
Components.Vim.Controls.InputEvent.key;
|
Components.Vim.Controls.InputEvent.key;
|
||||||
/** @type Boolean */
|
/** @type Boolean */
|
||||||
|
Loading…
Reference in New Issue
Block a user