forked from Botanical/BotanJS
Some interfaces
This commit is contained in:
parent
cbec2c7475
commit
52e4733fcc
38
botanjs/src/Components/Vim/Actions/INSERT.js
Normal file
38
botanjs/src/Components/Vim/Actions/INSERT.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
(function(){
|
||||||
|
var ns = __namespace( "Components.Vim.Actions" );
|
||||||
|
|
||||||
|
/** @type {Dandelion} */
|
||||||
|
var Dand = __import( "Dandelion" );
|
||||||
|
/** @type {Dandelion.IDOMElement} */
|
||||||
|
var IDOMElement = __import( "Dandelion.IDOMElement" );
|
||||||
|
/** @type {Dandelion.IDOMObject} */
|
||||||
|
var IDOMObject = __import( "Dandelion.IDOMObject" );
|
||||||
|
/** @type {System.Cycle} */
|
||||||
|
var Cycle = __import( "System.Cycle" );
|
||||||
|
/** @type {System.Debug} */
|
||||||
|
var debug = __import( "System.Debug" );
|
||||||
|
|
||||||
|
var Mesg = __import( "Components.Vim.Message" );
|
||||||
|
|
||||||
|
/** @type {Components.Vim.Cursor.IAction} */
|
||||||
|
var INSERT = function( Cursor )
|
||||||
|
{
|
||||||
|
/** @type {Components.Vim.Cursor} */
|
||||||
|
this.cursor = Cursor;
|
||||||
|
};
|
||||||
|
|
||||||
|
INSERT.prototype.dispose = function()
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
INSERT.prototype.getMessage = function()
|
||||||
|
{
|
||||||
|
var l = this.cursor.feeder.firstBuffer.cols;
|
||||||
|
var msg = Mesg( "INSERT" );
|
||||||
|
|
||||||
|
for( var i = msg.length; i < l; i ++ ) msg += " ";
|
||||||
|
return msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
ns[ NS_EXPORT ]( EX_CLASS, "INSERT", INSERT );
|
||||||
|
})();
|
@ -12,6 +12,8 @@
|
|||||||
/** @type {System.Debug} */
|
/** @type {System.Debug} */
|
||||||
var debug = __import( "System.Debug" );
|
var debug = __import( "System.Debug" );
|
||||||
|
|
||||||
|
var Actions = __import( "Components.Vim.Actions.*" );
|
||||||
|
|
||||||
var GetLine = function( buffs, l )
|
var GetLine = function( buffs, l )
|
||||||
{
|
{
|
||||||
/** @type {Components.Vim.LineBuffer} */
|
/** @type {Components.Vim.LineBuffer} */
|
||||||
@ -76,6 +78,9 @@
|
|||||||
|
|
||||||
// The resulting position
|
// The resulting position
|
||||||
this.P = 0;
|
this.P = 0;
|
||||||
|
|
||||||
|
/** @type {Components.Vim.IAction} */
|
||||||
|
this.action = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Can only be 1, -1
|
// Can only be 1, -1
|
||||||
@ -210,6 +215,15 @@
|
|||||||
this.updatePosition();
|
this.updatePosition();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Cursor.prototype.openInsert = function()
|
||||||
|
{
|
||||||
|
var feeder = this.feeder;
|
||||||
|
if( this.action ) this.action.dispose();
|
||||||
|
this.action = new Actions[ "INSERT" ];
|
||||||
|
|
||||||
|
feeder.dispatcher.dispatchEvent( new BotanEvent( "VisualUpdate" ) );
|
||||||
|
};
|
||||||
|
|
||||||
Cursor.prototype.getLine = function()
|
Cursor.prototype.getLine = function()
|
||||||
{
|
{
|
||||||
var feeder = this.feeder;
|
var feeder = this.feeder;
|
||||||
@ -225,6 +239,12 @@
|
|||||||
return line;
|
return line;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
__readOnly( Cursor.prototype, "message", function()
|
||||||
|
{
|
||||||
|
return this.action && this.action.getMessage();
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
__readOnly( Cursor.prototype, "position", function()
|
__readOnly( Cursor.prototype, "position", function()
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
if( text )
|
if( text )
|
||||||
{
|
{
|
||||||
text = text();
|
text = text();
|
||||||
|
if( text == undefined || text === "" ) continue;
|
||||||
|
|
||||||
display += text.substr( 0, avail );
|
display += text.substr( 0, avail );
|
||||||
i = display.length - 1;
|
i = display.length - 1;
|
||||||
}
|
}
|
||||||
|
@ -50,11 +50,13 @@
|
|||||||
var kCode = e.keyCode + ( e.shiftKey ? 1000 : 0 );
|
var kCode = e.keyCode + ( e.shiftKey ? 1000 : 0 );
|
||||||
|
|
||||||
var cfeeder = sender.contentFeeder;
|
var cfeeder = sender.contentFeeder;
|
||||||
|
var sfeeder = sender.statusFeeder;
|
||||||
switch( kCode )
|
switch( kCode )
|
||||||
{
|
{
|
||||||
// Cursor movements
|
// Cursor movements
|
||||||
|
case 8: // Backspace, go back 1 char, regardless of line
|
||||||
|
break;
|
||||||
case 72: // h
|
case 72: // h
|
||||||
case 8: // Backspace
|
|
||||||
cfeeder.cursor.moveX( -1 );
|
cfeeder.cursor.moveX( -1 );
|
||||||
break;
|
break;
|
||||||
case 74: // j
|
case 74: // j
|
||||||
@ -67,9 +69,24 @@
|
|||||||
cfeeder.cursor.moveX( 1 );
|
cfeeder.cursor.moveX( 1 );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Insert
|
||||||
case 65: // a
|
case 65: // a
|
||||||
case 1065: // A
|
cfeeder.cursor.openInsert();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 1065: // A, append at the line end
|
||||||
|
break;
|
||||||
|
case 73: // i
|
||||||
|
break;
|
||||||
|
case 1073: // I, append before the line start, after spaces
|
||||||
|
break;
|
||||||
|
|
||||||
|
// remove characters
|
||||||
|
case 88: // x, remove in cursor
|
||||||
|
break;
|
||||||
|
case 1088: // X, remove before cursor
|
||||||
|
break;
|
||||||
|
|
||||||
case 1072: // H, First line buffer
|
case 1072: // H, First line buffer
|
||||||
break;
|
break;
|
||||||
case 1076: // L, Last line buffer
|
case 1076: // L, Last line buffer
|
||||||
@ -171,6 +188,10 @@
|
|||||||
return mesg( cfeeder.docPos );
|
return mesg( cfeeder.docPos );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
statusBar.stamp( 0, function(){
|
||||||
|
return cfeeder.cursor.message;
|
||||||
|
} );
|
||||||
|
|
||||||
sfeeder.init( statusBar.statusText );
|
sfeeder.init( statusBar.statusText );
|
||||||
|
|
||||||
var Update = function()
|
var Update = function()
|
||||||
|
Loading…
Reference in New Issue
Block a user