Added wq. Added custom wc which writes for copy to clipboard

This commit is contained in:
斟酌 鵬兄 2018-11-20 18:04:23 +08:00
parent 17c4cc4d18
commit 4462d7ba3d
3 changed files with 40 additions and 3 deletions

View File

@ -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":

View File

@ -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;

View File

@ -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 ) );