diff --git a/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js b/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js index 78ff532..5b5a3e1 100644 --- a/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js +++ b/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js @@ -82,6 +82,9 @@ case "marks": out[ CMD_TYPE ] = "MARKS"; break; + case "mark": + out[ CMD_TYPE ] = "MARK"; + break; case "ver": case "version": out[ CMD_TYPE ] = "VERSION"; @@ -156,7 +159,7 @@ try { 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; } diff --git a/botanjs/src/Components/Vim/Actions/MARK.js b/botanjs/src/Components/Vim/Actions/MARK.js new file mode 100644 index 0000000..1c0e0dd --- /dev/null +++ b/botanjs/src/Components/Vim/Actions/MARK.js @@ -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 ); +})(); diff --git a/botanjs/src/Components/Vim/Actions/MARKS.js b/botanjs/src/Components/Vim/Actions/MARKS.js index 4ffe01f..73cc126 100644 --- a/botanjs/src/Components/Vim/Actions/MARKS.js +++ b/botanjs/src/Components/Vim/Actions/MARKS.js @@ -48,6 +48,8 @@ msg += "\nmark line col file/text"; var feeder = this.__cursor.feeder; + var chopLen = feeder.firstBuffer.cols + 1; + for( var i = 0, j = Keys[ i ]; j != undefined; i ++, j = Keys[ i ] ) { var r = marks.get( j ); @@ -63,7 +65,7 @@ var ll = 3 - col.length; 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" ); diff --git a/botanjs/src/Components/Vim/Actions/VISUAL.js b/botanjs/src/Components/Vim/Actions/VISUAL.js index 6770cac..bb75ba9 100644 --- a/botanjs/src/Components/Vim/Actions/VISUAL.js +++ b/botanjs/src/Components/Vim/Actions/VISUAL.js @@ -48,11 +48,17 @@ return i; }; + /** marker @type {Components.Vim.State.Marks} */ + var MarkSelected = function( marker, PStart, PEnd ) + { + }; + /** @type {Components.Vim.IAction} */ var VISUAL = function( Cursor ) { this.__reset( Cursor ); this.__msg = ""; + Cursor.blink = false; Cursor.pSpace = true; }; diff --git a/botanjs/src/Components/Vim/Controls.js b/botanjs/src/Components/Vim/Controls.js index 7057be3..830a499 100644 --- a/botanjs/src/Components/Vim/Controls.js +++ b/botanjs/src/Components/Vim/Controls.js @@ -287,7 +287,7 @@ case S: // Delete Char and start insert if( ccur.getLine().content != "" ) { - ccur.openRunAction( "DELETE", e, ccur.aPos ); + ccur.openRunAction( "DELETE", e, false, ccur.aPos ); } ccur.openAction( "INSERT", e ); break; @@ -315,9 +315,16 @@ case C: // Then insert ccur.openAction( "DELETE", e ); 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 ccur.openAction( "YANK", e ); break; + case M: // Mark + ccur.openAction( "MARK", e ); + break; case P: // Put ccur.suppressEvent(); @@ -335,7 +342,7 @@ beep(); break; } - ccur.openRunAction( "DELETE", e, ccur.aPos ); + ccur.openRunAction( "DELETE", e, false, ccur.aPos ); break; case SHIFT + U: // Undo previous changes in oneline break; @@ -611,26 +618,13 @@ 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 T: // To this.__captureComp = true; this.__composite( e, function( e2 ) { var oX = ccur.X; - ccur.openRunAction( "TO", e, e2 ); + ccur.openRunAction( "TO", e, false, e2 ); if( ccur.X < oX ) { @@ -648,7 +642,7 @@ this.__captureComp = true; this.__composite( e, function( e2 ) { - ccur.openRunAction( "TO", e, e2 ); + ccur.openRunAction( "TO", e, false, e2 ); }, ANY_KEY ); break; diff --git a/botanjs/src/Components/Vim/Cursor.js b/botanjs/src/Components/Vim/Cursor.js index c1d7ceb..65e4e46 100644 --- a/botanjs/src/Components/Vim/Cursor.js +++ b/botanjs/src/Components/Vim/Cursor.js @@ -566,11 +566,11 @@ }; // 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 ); /** @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 ); this.__pulseMsg = action.getMessage(); action.dispose(); diff --git a/botanjs/src/Components/Vim/Ex/Command.js b/botanjs/src/Components/Vim/Ex/Command.js index 45fdb74..85df394 100644 --- a/botanjs/src/Components/Vim/Ex/Command.js +++ b/botanjs/src/Components/Vim/Ex/Command.js @@ -224,7 +224,7 @@ var cur = this.__cursor; cur.suppressEvent(); - this.__cursor.openRunAction( action, e, this.__command.slice() ); + this.__cursor.openRunAction( action, e, false, this.__command.slice() ); cur.unsuppressEvent(); }; diff --git a/botanjs/src/Components/Vim/State/Marks.js b/botanjs/src/Components/Vim/State/Marks.js index 102af97..9f5412b 100644 --- a/botanjs/src/Components/Vim/State/Marks.js +++ b/botanjs/src/Components/Vim/State/Marks.js @@ -4,6 +4,8 @@ /** @type {System.Debug} */ var debug = __import( "System.Debug" ); + var beep = __import( "Components.Vim.Beep" ); + var Keys = "'ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxy\"[]^.<>"; var Marks = function() @@ -13,7 +15,11 @@ 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 ]; return true; diff --git a/botanjs/src/Components/Vim/VimArea.js b/botanjs/src/Components/Vim/VimArea.js index 8986ce6..6a08d95 100644 --- a/botanjs/src/Components/Vim/VimArea.js +++ b/botanjs/src/Components/Vim/VimArea.js @@ -323,7 +323,7 @@ statusBar.stamp( 1, false ); controls.handler( _self, new ActionEvent( _self, "Escape" ) ); setTimeout( function() { - cursor.openRunAction( "VA_REC", undefined, true ); + cursor.openRunAction( "VA_REC", false, false, true ); _self.__demoActive = false; _self.stage.addEventListeners( _self.__stagedEvents ); }, 100 );