commit 4462d7ba3d2401fa2e7ffc951ae34a6a2d9cf1c2
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2018-11-20T10:04:23Z |
| subject | Added wq. Added custom wc which writes for copy to clipboard |
commit 4462d7ba3d2401fa2e7ffc951ae34a6a2d9cf1c2
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2018-11-20T10:04:23Z
Added wq. Added custom wc which writes for copy to clipboard
---
.../src/Components/Vim/Actions/EDITOR_COMMAND.js | 7 +++++
botanjs/src/Components/Vim/Actions/WRITE.js | 34 ++++++++++++++++++++--
botanjs/src/Components/Vim/VimArea.js | 2 +-
3 files changed, 40 insertions(+), 3 deletions(-)
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 );
+ }
- var msg = Mesg( "WRITE", Vim.stage.element.id, occurance( Vim.content, "\n" ), Vim.content.length );
+ 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 ) );