Merge remote-tracking branch 'vim/master' into Astro

This commit is contained in:
斟酌 鵬兄 2017-03-20 12:47:21 +08:00
commit 6945834de5
9 changed files with 80 additions and 24 deletions

View File

@ -82,6 +82,9 @@
case "marks": case "marks":
out[ CMD_TYPE ] = "MARKS"; out[ CMD_TYPE ] = "MARKS";
break; break;
case "mark":
out[ CMD_TYPE ] = "MARK";
break;
case "ver": case "ver":
case "version": case "version":
out[ CMD_TYPE ] = "VERSION"; out[ CMD_TYPE ] = "VERSION";
@ -156,7 +159,7 @@
try try
{ {
this.__cursor.openRunAction( this.__cursor.openRunAction(
cmd[ CMD_TYPE ], e, cmd[ CMD_ARGS ], cmd[ CMD_RANGE ] cmd[ CMD_TYPE ], e, false, cmd[ CMD_ARGS ], cmd[ CMD_RANGE ]
); );
this.__msg = this.__cursor.message; this.__msg = this.__cursor.message;
} }

View File

@ -0,0 +1,45 @@
(function(){
var ns = __namespace( "Components.Vim.Actions" );
/** @type {System.Debug} */
var debug = __import( "System.Debug" );
var beep = __import( "Components.Vim.Beep" );
/** @type {Components.Vim.IAction} */
var MARK = function( Cursor )
{
/** @type {Components.Vim.Cursor} */
this.__cursor = Cursor;
this.__msg = "";
};
MARK.prototype.dispose = function() { };
MARK.prototype.handler = function( e, cmd )
{
e.preventDefault();
/** @type {Components.Vim.State.Marks} */
var marks = e.target.marks;
var ccur = this.__cursor;
if( cmd && cmd[0] )
{
marks.set( cmd.join( "" ).trim(), ccur.getLine().lineNum, ccur.aX );
}
else
{
marks.set( e.key, ccur.getLine().lineNum, ccur.aX );
}
return true;
};
MARK.prototype.getMessage = function()
{
return this.__msg;
};
ns[ NS_EXPORT ]( EX_CLASS, "MARK", MARK );
})();

View File

@ -48,6 +48,8 @@
msg += "\nmark line col file/text"; msg += "\nmark line col file/text";
var feeder = this.__cursor.feeder; var feeder = this.__cursor.feeder;
var chopLen = feeder.firstBuffer.cols + 1;
for( var i = 0, j = Keys[ i ]; j != undefined; i ++, j = Keys[ i ] ) for( var i = 0, j = Keys[ i ]; j != undefined; i ++, j = Keys[ i ] )
{ {
var r = marks.get( j ); var r = marks.get( j );
@ -63,7 +65,7 @@
var ll = 3 - col.length; var ll = 3 - col.length;
for( var il = 0; il < ll; il ++ ) col = " " + col; for( var il = 0; il < ll; il ++ ) col = " " + col;
msg += "\n " + j + " " + line + " " + col + " " + t; msg += ( "\n " + j + " " + line + " " + col + " " + t ).substring( 0, chopLen );
} }
var lastLine = Mesg( "WAIT_FOR_INPUT" ); var lastLine = Mesg( "WAIT_FOR_INPUT" );

View File

@ -48,11 +48,17 @@
return i; return i;
}; };
/** marker @type {Components.Vim.State.Marks} */
var MarkSelected = function( marker, PStart, PEnd )
{
};
/** @type {Components.Vim.IAction} */ /** @type {Components.Vim.IAction} */
var VISUAL = function( Cursor ) var VISUAL = function( Cursor )
{ {
this.__reset( Cursor ); this.__reset( Cursor );
this.__msg = ""; this.__msg = "";
Cursor.blink = false; Cursor.blink = false;
Cursor.pSpace = true; Cursor.pSpace = true;
}; };

View File

@ -287,7 +287,7 @@
case S: // Delete Char and start insert case S: // Delete Char and start insert
if( ccur.getLine().content != "" ) if( ccur.getLine().content != "" )
{ {
ccur.openRunAction( "DELETE", e, ccur.aPos ); ccur.openRunAction( "DELETE", e, false, ccur.aPos );
} }
ccur.openAction( "INSERT", e ); ccur.openAction( "INSERT", e );
break; break;
@ -315,9 +315,16 @@
case C: // Then insert case C: // Then insert
ccur.openAction( "DELETE", e ); ccur.openAction( "DELETE", e );
break; break;
case SHIFT + S: // Synonym to cc
var c = new ActionEvent( this.__vimArea, "c" );
ccur.openRunAction( "DELETE", c, c );
break;
case Y: // Yank with motion case Y: // Yank with motion
ccur.openAction( "YANK", e ); ccur.openAction( "YANK", e );
break; break;
case M: // Mark
ccur.openAction( "MARK", e );
break;
case P: // Put case P: // Put
ccur.suppressEvent(); ccur.suppressEvent();
@ -335,7 +342,7 @@
beep(); beep();
break; break;
} }
ccur.openRunAction( "DELETE", e, ccur.aPos ); ccur.openRunAction( "DELETE", e, false, ccur.aPos );
break; break;
case SHIFT + U: // Undo previous changes in oneline case SHIFT + U: // Undo previous changes in oneline
break; break;
@ -611,26 +618,13 @@
break; break;
case M:
this.__captureComp = true;
var marks = this.__vimArea.marks;
this.__composite( e, function( e2 ) {
var line = ccur.getLine().lineNum;
if( !marks.set( e2.key, line, ccur.aX ) )
{
beep();
}
}, ANY_KEY );
break;
case SHIFT + T: // To case SHIFT + T: // To
case T: // To case T: // To
this.__captureComp = true; this.__captureComp = true;
this.__composite( e, function( e2 ) { this.__composite( e, function( e2 ) {
var oX = ccur.X; var oX = ccur.X;
ccur.openRunAction( "TO", e, e2 ); ccur.openRunAction( "TO", e, false, e2 );
if( ccur.X < oX ) if( ccur.X < oX )
{ {
@ -648,7 +642,7 @@
this.__captureComp = true; this.__captureComp = true;
this.__composite( e, function( e2 ) { this.__composite( e, function( e2 ) {
ccur.openRunAction( "TO", e, e2 ); ccur.openRunAction( "TO", e, false, e2 );
}, ANY_KEY ); }, ANY_KEY );
break; break;

View File

@ -566,11 +566,11 @@
}; };
// Open, Run, then close an action // Open, Run, then close an action
Cursor.prototype.openRunAction = function( name, e, arg1, arg2, arg3, arg4, arg5 ) Cursor.prototype.openRunAction = function( name, e, eO, arg1, arg2, arg3, arg4, arg5 )
{ {
debug.Info( "OpenRunAction: " + name ); debug.Info( "OpenRunAction: " + name );
/** @type {Components.Vim.IAction} */ /** @type {Components.Vim.IAction} */
var action = new (Actions[ name ])( this ); var action = new (Actions[ name ])( this, eO );
action.handler( e, arg1, arg2, arg3, arg4, arg5 ); action.handler( e, arg1, arg2, arg3, arg4, arg5 );
this.__pulseMsg = action.getMessage(); this.__pulseMsg = action.getMessage();
action.dispose(); action.dispose();

View File

@ -224,7 +224,7 @@
var cur = this.__cursor; var cur = this.__cursor;
cur.suppressEvent(); cur.suppressEvent();
this.__cursor.openRunAction( action, e, this.__command.slice() ); this.__cursor.openRunAction( action, e, false, this.__command.slice() );
cur.unsuppressEvent(); cur.unsuppressEvent();
}; };

View File

@ -4,6 +4,8 @@
/** @type {System.Debug} */ /** @type {System.Debug} */
var debug = __import( "System.Debug" ); var debug = __import( "System.Debug" );
var beep = __import( "Components.Vim.Beep" );
var Keys = "'ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy\"[]^.<>"; var Keys = "'ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy\"[]^.<>";
var Marks = function() var Marks = function()
@ -13,7 +15,11 @@
Marks.prototype.set = function( t, line, col ) Marks.prototype.set = function( t, line, col )
{ {
if( Keys.indexOf( t ) == -1 ) return false; if( Keys.indexOf( t ) == -1 )
{
beep();
return false;
}
this.__marks[ t ] = [ line, col ]; this.__marks[ t ] = [ line, col ];
return true; return true;

View File

@ -323,7 +323,7 @@
statusBar.stamp( 1, false ); statusBar.stamp( 1, false );
controls.handler( _self, new ActionEvent( _self, "Escape" ) ); controls.handler( _self, new ActionEvent( _self, "Escape" ) );
setTimeout( function() { setTimeout( function() {
cursor.openRunAction( "VA_REC", undefined, true ); cursor.openRunAction( "VA_REC", false, false, true );
_self.__demoActive = false; _self.__demoActive = false;
_self.stage.addEventListeners( _self.__stagedEvents ); _self.stage.addEventListeners( _self.__stagedEvents );
}, 100 ); }, 100 );