diff --git a/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js b/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js index 5b5a3e1..3f6edb7 100644 --- a/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js +++ b/botanjs/src/Components/Vim/Actions/EDITOR_COMMAND.js @@ -68,7 +68,14 @@ out[ CMD_TYPE ] = "BUFFERS"; break; case "w": + case "wq": + case "wc": case "write": + if( command == "wq" || command == "wc" ) + { + // This puts the "q" / "c" into CMD_ARGS + i --; + } out[ CMD_TYPE ] = "WRITE"; break; case "q": diff --git a/botanjs/src/Components/Vim/Actions/WRITE.js b/botanjs/src/Components/Vim/Actions/WRITE.js index e961735..0db0f75 100644 --- a/botanjs/src/Components/Vim/Actions/WRITE.js +++ b/botanjs/src/Components/Vim/Actions/WRITE.js @@ -26,12 +26,42 @@ { e.preventDefault(); + var wtarget = "DEFAULT"; + if( p ) + { + wtarget = p.join( "" ).trim().toUpperCase(); + } + + var quit = false; + var cur = this.__cursor; var Vim = cur.Vim; - Vim.content = cur.feeder.content.slice( 0, -1 ); + switch( wtarget ) + { + case "C": + var data = cur.feeder.content.slice( 0, -1 ); + var tail = "/* Press Ctrl + C to copy the contents. Escape to continue editing. */" + setTimeout( function() { + Vim.display( + data + tail, function(){ + Vim.stage.element.selectionStart = 0; + Vim.stage.element.selectionEnd = data.length; + } ); + }, 1 ); + break; + case "Q": + quit = true; + default: + Vim.content = cur.feeder.content.slice( 0, -1 ); + } + + if( quit ) + { + Vim.dispose(); + return true; + } var msg = Mesg( "WRITE", Vim.stage.element.id, occurance( Vim.content, "\n" ), Vim.content.length ); - cur.rec.save(); var l = this.__cursor.feeder.firstBuffer.cols; diff --git a/botanjs/src/Components/Vim/VimArea.js b/botanjs/src/Components/Vim/VimArea.js index 7256a5c..7938213 100644 --- a/botanjs/src/Components/Vim/VimArea.js +++ b/botanjs/src/Components/Vim/VimArea.js @@ -288,7 +288,7 @@ var ContinueEdit = new EventKey( "KeyDown", function( e ) { var evt = new ActionEvent( _self, e ); - if( evt.kMap( "Escape" ) ) + if( evt.Escape ) { stage.removeEventListener( ContinueEdit ); stage.setAttribute( new DataKey( "vimarea", 1 ) );