commit 9f7c0c4b7dc2b9578fd7245edc01ad9743b3b412
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2017-01-28T06:37:58Z |
| subject | Display session data in textarea instead of prompt |
commit 9f7c0c4b7dc2b9578fd7245edc01ad9743b3b412
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2017-01-28T06:37:58Z
Display session data in textarea instead of prompt
---
botanjs/src/Components/Vim/Actions/VA_REC.js | 15 ++++++++----
botanjs/src/Components/Vim/VimArea.js | 34 +++++++++++++++++++++++++++
botanjs/src/externs/Components.Vim.VimArea.js | 2 ++
3 files changed, 47 insertions(+), 4 deletions(-)
diff --git a/botanjs/src/Components/Vim/Actions/VA_REC.js b/botanjs/src/Components/Vim/Actions/VA_REC.js
index e86f503..7685eb3 100644
--- a/botanjs/src/Components/Vim/Actions/VA_REC.js
+++ b/botanjs/src/Components/Vim/Actions/VA_REC.js
@@ -27,9 +27,9 @@
this.__cursor.unsuppressEvent();
};
- VA_REC.prototype.handler = function( e, endReplay )
+ VA_REC.prototype.handler = function( e, args, range )
{
- if( endReplay )
+ if( args == true )
{
var msg = Mesg( "VA_REC_END" );
var lastLine = Mesg( "WAIT_FOR_INPUT" );
@@ -60,9 +60,16 @@
if( session.started )
{
session.__dispose();
- this.__msg = "Exported Session Data";
+ var head = "Press Escape to conitnue edit\n===\n";
+ var data = JSON.stringify( session.data );
+
+ var element = sender.element;
setTimeout( function() {
- window.prompt( "Session data ( Ctrl + C )", JSON.stringify( session.data ) );
+ inst.display(
+ head + data, function(){
+ element.selectionStart = head.length;
+ element.selectionEnd = element.selectionStart + data.length;
+ } );
}, 1 );
return;
}
diff --git a/botanjs/src/Components/Vim/VimArea.js b/botanjs/src/Components/Vim/VimArea.js
index 30228b5..a6c825d 100644
--- a/botanjs/src/Components/Vim/VimArea.js
+++ b/botanjs/src/Components/Vim/VimArea.js
@@ -267,6 +267,40 @@
this.dispatchEvent( new BotanEvent( "Visualized" ) );
};
+ VimArea.prototype.display = function( data, handler )
+ {
+ var _self = this;
+ var stage = this.stage;
+ var cursor = this.__cursor;
+
+ var evts = this.__stagedEvents;
+ for( var i in evts ) stage.removeEventListener( evts[ i ] );
+ cursor.suppressEvent();
+ this.__active = false;
+
+ stage.removeAttribute( "data-vimarea" );
+ setTimeout( function() {
+ stage.element.value = data;
+ if( handler ) handler();
+ }, 100 );
+
+ var ContinueEdit = new EventKey( "KeyDown", function( e ) {
+ var evt = new ActionEvent( _self, e );
+ if( evt.kMap( "Escape" ) )
+ {
+ stage.removeEventListener( ContinueEdit );
+ stage.setAttribute( new DataKey( "vimarea", 1 ) );
+ stage.addEventListeners( _self.__stagedEvents );
+ cursor.unsuppressEvent();
+ cursor.feeder.dispatcher.dispatchEvent( new BotanEvent( "VisualUpdate" ) );
+ _self.__active = true;
+ stage.element.focus();
+ }
+ } );
+
+ stage.addEventListener( ContinueEdit );
+ };
+
VimArea.prototype.demo = function( seq )
{
if( this.__demoActive ) return;
diff --git a/botanjs/src/externs/Components.Vim.VimArea.js b/botanjs/src/externs/Components.Vim.VimArea.js
index 6e191f5..756c6c3 100644
--- a/botanjs/src/externs/Components.Vim.VimArea.js
+++ b/botanjs/src/externs/Components.Vim.VimArea.js
@@ -14,6 +14,8 @@ Components.Vim.VimArea.statusBar;
/** @type Function */
Components.Vim.VimArea.demo;
+/** @type Function */
+Components.Vim.VimArea.display;
/** @type Number */
Components.Vim.VimArea.index;