From 99eccf36b3b6664d1fedfe8bb65d74427937605d Mon Sep 17 00:00:00 2001 From: nuintun Date: Thu, 26 Nov 2015 23:00:11 +0800 Subject: [PATCH] update files --- static/js/components/app-main/index.js | 31 +++++++++++--------------- static/js/terminal/lib/focused.js | 4 ++-- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/static/js/components/app-main/index.js b/static/js/components/app-main/index.js index 6d8af2c..2d76d7d 100644 --- a/static/js/components/app-main/index.js +++ b/static/js/components/app-main/index.js @@ -53,26 +53,34 @@ function scroll(xterm, parent){ * @param xtermNode */ function createXTerm(name, xtermNode){ + var timer; var runtime = window.AppRuntime[name]; if (runtime) { runtime.xterm.focus(); - xtermNode.innerHTML = runtime.xterm.screen; } else { var xterm = new Terminal({ rows: 66, scrollback: 66, - cursorBlink: false, convertEOL: true, fgColor: 'inherit', - bgColor: 'transparent' + bgColor: 'transparent', + onscreen: function (screen){ + if (Terminal.focus === this) { + clearTimeout(timer); + + timer = setTimeout(function (){ + xtermNode.innerHTML = screen; + + scroll(xterm, xtermNode); + }, 0); + } + } }); xterm.open(); xterm.focus(); - xtermNode.innerHTML = xterm.screen; - window.AppRuntime[name] = { xterm: xterm }; @@ -181,8 +189,6 @@ module.exports = Vue.component('app-main', { context.expandCommand = trigger && trigger.contains(target); }, false); - var timer; - ipc.on('emulator', function (event, type, project, data){ var runtime = window.AppRuntime[project.name]; @@ -199,18 +205,7 @@ module.exports = Vue.component('app-main', { break; } - clearTimeout(timer); runtime.xterm.write(data); - - if (project.name === context.project.name) { - timer = setTimeout(function (){ - var xtermNode = context.$els.terminal; - - xtermNode.innerHTML = runtime.xterm.screen; - - scroll(runtime.xterm, xtermNode); - }, 0); - } } else { event.sender.send('emulator', project, 'stop'); } diff --git a/static/js/terminal/lib/focused.js b/static/js/terminal/lib/focused.js index 7e4a494..0e0ed25 100644 --- a/static/js/terminal/lib/focused.js +++ b/static/js/terminal/lib/focused.js @@ -17,6 +17,8 @@ module.exports = function (Terminal){ Terminal.focus.blur(); } + Terminal.focus = this; + if (this.cursor) { this.showCursor(); } @@ -24,8 +26,6 @@ module.exports = function (Terminal){ if (this.cursorBlink) { this.startBlink(); } - - Terminal.focus = this; }; /**