From 887e6a74d4be9a512864f0ec4d549e42e95ad006 Mon Sep 17 00:00:00 2001 From: nuintun Date: Thu, 26 Nov 2015 17:13:52 +0800 Subject: [PATCH] update files --- bin/emulator.js | 6 ------ static/js/components/app-main/index.js | 11 +++++++++-- static/js/terminal/lib/refresh.js | 7 +++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/bin/emulator.js b/bin/emulator.js index c18952b..8c6ced5 100644 --- a/bin/emulator.js +++ b/bin/emulator.js @@ -34,8 +34,6 @@ Emulator.prototype = { exec: function (){ var parsed = normalizeExecArgs.apply(null, arguments); - console.log(JSON.stringify(parsed, null, 2)); - return spawn(parsed.shell, parsed.args, parsed.options); } }; @@ -95,10 +93,6 @@ module.exports = { env[item.name] = item.value }); - env['COLORTERM'] = 'true'; - env['DEBUG_FD'] = '1'; - env['DEBUG_COLORS'] = 'true'; - emulator = new Emulator({ env: env, cwd: project.path, diff --git a/static/js/components/app-main/index.js b/static/js/components/app-main/index.js index c3f457c..e0cea8f 100644 --- a/static/js/components/app-main/index.js +++ b/static/js/components/app-main/index.js @@ -192,6 +192,8 @@ module.exports = Vue.component('app-main', { context.expandCommand = trigger && trigger.contains(target); }, false); + var step = 0; + ipc.on('emulator', function (event, type, project, data){ var runtime = window.AppRuntime[project.name]; @@ -199,17 +201,22 @@ module.exports = Vue.component('app-main', { switch (type) { case 'data': data += ''; + step++; break; case 'error': data = '执行出现错误: ' + data; + step = 0; break; case 'close': data = '\u001b[32m命令执行完毕\u001b[39m\r\n'; + step = 0; break; } - runtime.xterm.write(data + ''); - scroll(runtime.xterm); + setTimeout(function (){ + runtime.xterm.write(data + ''); + scroll(runtime.xterm); + }, 10 * step); } else { event.sender.send('emulator', project, 'stop'); } diff --git a/static/js/terminal/lib/refresh.js b/static/js/terminal/lib/refresh.js index 658e516..e1e72ef 100644 --- a/static/js/terminal/lib/refresh.js +++ b/static/js/terminal/lib/refresh.js @@ -23,9 +23,10 @@ module.exports = function (Terminal){ */ Terminal.prototype.refresh = function (start, end){ var parent = this.element ? this.element.parentNode : null; + var optimize = parent && end - start >= this.rows / 2; var x, y, i, line, out, ch, width, data, attr, fgColor, bgColor, flags, row; - if (parent && end - start >= this.rows / 2) { + if (optimize) { parent.removeChild(this.element); } @@ -152,6 +153,8 @@ module.exports = function (Terminal){ this.children[y].innerHTML = out; } - if (parent) parent.appendChild(this.element); + if (optimize) { + parent.appendChild(this.element); + } }; };