This commit is contained in:
斟酌 鵬兄 2016-03-15 05:22:37 +08:00
parent ee26a7dcc8
commit b7c693be07
11 changed files with 193 additions and 24 deletions

View File

@ -19,9 +19,7 @@
INSERT.prototype.handler = function( e ) INSERT.prototype.handler = function( e )
{ {
e.preventDefault(); e.preventDefault();
if( e.key.length == "1" ) var inputChar = e.key;
{
}
}; };
INSERT.prototype.getMessage = function() INSERT.prototype.getMessage = function()

View File

@ -5,19 +5,29 @@
var Controls = function( sender, e ) var Controls = function( sender, e )
{ {
// Action Mode handled by the actions themselves // Neve capture these keys
var cfeeder = sender.contentFeeder;
if( cfeeder.cursor.action )
{
cfeeder.cursor.action.handler( e );
return;
}
if( e.altKey if( e.altKey
// F2 - F12 // F2 - F12
|| ( 112 < e.keyCode && e.keyCode < 124 ) || ( 112 < e.keyCode && e.keyCode < 124 )
) return; ) return;
// Action Mode handled by the actions themselves
var cfeeder = sender.contentFeeder;
if( cfeeder.cursor.action )
{
// Esc OR Ctrl+c
if( e.keyCode == 27 || ( e.ctrlKey && e.keyCode == 67 ) )
{
e.preventDefault();
cfeeder.cursor.closeAction();
}
else
{
cfeeder.cursor.action.handler( e );
}
return;
}
e.preventDefault(); e.preventDefault();
if( e.ctrlKey ) if( e.ctrlKey )
@ -50,7 +60,7 @@
// Insert // Insert
case 65: // a case 65: // a
cfeeder.cursor.openInsert(); cfeeder.cursor.openAction( "INSERT" );
break; break;
case 1065: // A, append at the line end case 1065: // A, append at the line end

View File

@ -71,7 +71,6 @@
// The resulting position // The resulting position
this.P = 0; this.P = 0;
/** @type {Components.Vim.IAction} */
this.action = null; this.action = null;
}; };
@ -207,13 +206,21 @@
this.updatePosition(); this.updatePosition();
}; };
Cursor.prototype.openInsert = function() Cursor.prototype.openAction = function( name )
{ {
var feeder = this.feeder;
if( this.action ) this.action.dispose(); if( this.action ) this.action.dispose();
this.action = new (Actions[ "INSERT" ])( this ); this.action = new (Actions[ name ])( this );
feeder.dispatcher.dispatchEvent( new BotanEvent( "VisualUpdate" ) ); this.feeder.dispatcher.dispatchEvent( new BotanEvent( "VisualUpdate" ) );
};
Cursor.prototype.closeAction = function()
{
if( !this.action ) return;
this.action.dispose();
this.action = null;
this.feeder.dispatcher.dispatchEvent( new BotanEvent( "VisualUpdate" ) );
}; };
Cursor.prototype.getLine = function() Cursor.prototype.getLine = function()

View File

@ -49,9 +49,6 @@
this.rows = element.rows; this.rows = element.rows;
this.cols = element.cols; this.cols = element.cols;
this.PosX = 1;
this.PosY = 1;
this.__active = false; this.__active = false;
var _self = this; var _self = this;
@ -64,10 +61,6 @@
this.VisualizeVimFrame( element.value ); this.VisualizeVimFrame( element.value );
}; };
VimArea.prototype.startInput = function( mode )
{
};
VimArea.prototype.select = function( sel ) VimArea.prototype.select = function( sel )
{ {
if( !this.__active ) return; if( !this.__active ) return;

View File

@ -0,0 +1,43 @@
/** @constructor */
Components.Vim.Cursor = function(){};
/** @type {Components.Vim.LineFeeder} */
Components.Vim.Cursor.feeder;
/** @type {Components.Vim.IAction} */
Components.Vim.Cursor.action;
/** @type Function */
Components.Vim.Cursor.moveX;
/** @type Function */
Components.Vim.Cursor.moveY;
/** @type Function */
Components.Vim.Cursor.lineStart;
/** @type Function */
Components.Vim.Cursor.lineEnd;
/** @type Function */
Components.Vim.Cursor.updatePosition;
/** @type Function */
Components.Vim.Cursor.openAction;
/** @type Function */
Components.Vim.Cursor.closeAction;
/** @type {Array} */
Components.Vim.Cursor.lineBuffers;
/** @type Number */
Components.Vim.Cursor.pX;
/** @type Number */
Components.Vim.Cursor.P;
/** @type Number */
Components.Vim.Cursor.X;
/** @type Number */
Components.Vim.Cursor.Y;
/** @type Number */
Components.Vim.Cursor.cols;
/** @type message */
Components.Vim.Cursor.string;
/** @type Object */
Components.Vim.Cursor.position;
/** @type Number */
Components.Vim.Cursor.position.start;
/** @type Number */
Components.Vim.Cursor.position.end;

View File

@ -0,0 +1,9 @@
/** @constructor */
Components.Vim.IAction = function(){};
/** @type Function */
Components.Vim.IAction.dispose;
/** @type Function */
Components.Vim.IAction.handler;
/** @type Function */
Components.Vim.IAction.getMessage;

View File

@ -0,0 +1,42 @@
/** @constructor */
Components.Vim.LineBuffer = function(){};
/** @type {Components.Vim.LineBuffer} */
Components.Vim.LineBuffer.next;
/** @type {Components.Vim.LineBuffer} */
Components.Vim.LineBuffer.prev;
/** @type {Components.Vim.LineBuffer} */
Components.Vim.LineBuffer.nextLine;
/** @type EventDispatcher */
Components.Vim.LineBuffer.dispatcher;
/** @type Function */
Components.Vim.LineBuffer.softReset;
/** @type Function */
Components.Vim.LineBuffer.pan;
/** @type Function */
Components.Vim.LineBuffer.render;
/** @type Function */
Components.Vim.LineBuffer.setRender;
/** @type Function */
Components.Vim.LineBuffer.init;
/** @type Function */
Components.Vim.LineBuffer.setWrap;
/** @type Array */
Components.Vim.LineBuffer.visualLines;
/** @type Boolean */
Components.Vim.LineBuffer.placeholder;
/** @type Boolean */
Components.Vim.LineBuffer.br;
/** @type Number */
Components.Vim.LineBuffer.cols;
/** @type Number */
Components.Vim.LineBuffer.lineNum;
/** @type Number */
Components.Vim.LineBuffer.tabWidth;
/** @type Number */
Components.Vim.LineBuffer.linesOccupied;
/** @type String */
Components.Vim.LineBuffer.content;

View File

@ -0,0 +1,44 @@
/** @constructor */
Components.Vim.LineFeeder = function(){};
/** @type {Components.Vim.Cursor} */
Components.Vim.LineFeeder.cursor;
/** @type {Components.Vim.LineBuffer} */
Components.Vim.LineFeeder.firstBuffer;
/** @type {Components.Vim.LineBuffer} */
Components.Vim.LineFeeder.lastBuffer;
/** @type EventDispatcher */
Components.Vim.LineFeeder.dispatcher;
/** @type Function */
Components.Vim.LineFeeder.softReset;
/** @type Function */
Components.Vim.LineFeeder.pan;
/** @type Function */
Components.Vim.LineFeeder.render;
/** @type Function */
Components.Vim.LineFeeder.setRender;
/** @type Function */
Components.Vim.LineFeeder.init;
/** @type Function */
Components.Vim.LineFeeder.setWrap;
/** @type {Array} */
Components.Vim.LineFeeder.lineBuffers;
/** @type Boolean */
Components.Vim.LineFeeder.EOF;
/** @type Number */
Components.Vim.LineFeeder.panX;
/** @type Number */
Components.Vim.LineFeeder.panY;
/** @type Number */
Components.Vim.LineFeeder.moreAt;
/** @type Number */
Components.Vim.LineFeeder.linesOccupied;
/** @type String */
Components.Vim.LineFeeder.docPos;
/** @type String */
Components.Vim.LineFeeder.lineStat;
/** @type {String} */
Components.Vim.LineFeeder.content;

View File

@ -0,0 +1,7 @@
/** @constructor */
Components.Vim.StatusBar = function(){};
/** @type Function */
Components.Vim.StatusBar.stamp;
/** @type String */
Components.Vim.StatusBar.statusText;

View File

@ -0,0 +1,14 @@
/** @constructor */
Components.Vim.VimArea = function(){};
/** @type {Components.Vim.LineFeeder} */
Components.Vim.VimArea.contentFeeder;
/** @type {Components.Vim.LineFeeder} */
Components.Vim.VimArea.statusFeeder;
/** @type {Components.Vim.StatusBar} */
Components.Vim.VimArea.statusBar;
/** @type {Number} */
Components.Vim.VimArea.rows;
/** @type {Number} */
Components.Vim.VimArea.cols;

View File

@ -0,0 +1,2 @@
/** @object */
Components.Vim = {};