From 26c6e9635d6528ca4e488a54b81b55cb0d9e7937 Mon Sep 17 00:00:00 2001 From: nuintun Date: Fri, 27 Nov 2015 09:56:53 +0800 Subject: [PATCH] update files --- static/js/components/app-main/index.js | 25 ++++++++----------------- static/js/terminal/index.js | 2 +- static/js/terminal/lib/close.js | 10 +++++----- static/js/terminal/lib/csi/mode.js | 4 ++-- static/js/terminal/lib/esc/reset.js | 9 ++++----- static/js/terminal/lib/open.js | 16 ++++++++-------- static/js/terminal/lib/refresh.js | 6 +++--- static/js/terminal/lib/resize.js | 12 ++++++------ static/js/terminal/lib/write.js | 4 ++-- 9 files changed, 39 insertions(+), 49 deletions(-) diff --git a/static/js/components/app-main/index.js b/static/js/components/app-main/index.js index 775d69e..e57b610 100644 --- a/static/js/components/app-main/index.js +++ b/static/js/components/app-main/index.js @@ -53,36 +53,24 @@ function scroll(xterm, parent){ * @param xtermNode */ function createXTerm(name, xtermNode){ - var timer; var runtime = window.AppRuntime[name]; + xtermNode.innerHTML = ''; + if (runtime) { runtime.xterm.focus(); + xtermNode.appendChild(runtime.xterm.element); } else { var xterm = new Terminal({ rows: 66, scrollback: 66, convertEOL: true, fgColor: 'inherit', - bgColor: 'transparent', - onscreen: function (screen){ - if (this.isFocused()) { - setImmediate(function (){ - xtermNode.innerHTML = screen; - scroll(xterm, xtermNode); - }); - //clearTimeout(timer); - - //timer = setTimeout(function (){ - // xtermNode.innerHTML = screen; - //}, 0); - // - //scroll(xterm, xtermNode); - } - } + bgColor: 'transparent' }); xterm.open(); + xtermNode.appendChild(xterm.element); window.AppRuntime[name] = { xterm: xterm @@ -193,10 +181,13 @@ module.exports = Vue.component('app-main', { }, false); ipc.on('emulator', function (event, type, project, data){ + var xtermNode = context.$els.terminal; var runtime = window.AppRuntime[project.name]; if (runtime) { + xtermNode.innerHTML = ''; runtime.xterm.write(data + ''); + xtermNode.appendChild(runtime.xterm.element); } else { event.sender.send('emulator', project, 'stop'); } diff --git a/static/js/terminal/index.js b/static/js/terminal/index.js index 362abc8..aac25d4 100644 --- a/static/js/terminal/index.js +++ b/static/js/terminal/index.js @@ -110,7 +110,7 @@ function Terminal(options){ this.charsets = [null]; // misc - this.element = null; + this.screen = null; this.children = []; this.refreshStart = null; this.refreshEnd = null; diff --git a/static/js/terminal/lib/close.js b/static/js/terminal/lib/close.js index 6d0801c..c72724d 100644 --- a/static/js/terminal/lib/close.js +++ b/static/js/terminal/lib/close.js @@ -15,16 +15,16 @@ module.exports = function (Terminal){ this.writable = false; this.write = function (){}; this.ondata = function (){}; - this.ondataTitle = function (){}; + this.ontitle = function (){}; - if (this.element) { - var parent = this.element.parentNode; + if (this.screen) { + var parent = this.screen.parentNode; if (parent) { - parent.removeChild(this.element); + parent.removeChild(this.screen); } - this.element = null; + this.screen = null; } }; }; diff --git a/static/js/terminal/lib/csi/mode.js b/static/js/terminal/lib/csi/mode.js index 24e9e03..790b0e9 100644 --- a/static/js/terminal/lib/csi/mode.js +++ b/static/js/terminal/lib/csi/mode.js @@ -157,7 +157,7 @@ module.exports = function (Terminal){ // -this.vt200Mouse = params === 1000; // -this.normalMouse = params > 1000; // -this.mouseEvents = true; - // -this.element.style.cursor = 'default'; + // -this.screen.style.cursor = 'default'; break; // send focusin/focusout events case 1004: @@ -364,7 +364,7 @@ module.exports = function (Terminal){ // -this.vt200Mouse = false; // -this.normalMouse = false; // -this.mouseEvents = false; - // -this.element.style.cursor = ''; + // -this.screen.style.cursor = ''; break; // send focusin/focusout events case 1004: diff --git a/static/js/terminal/lib/esc/reset.js b/static/js/terminal/lib/esc/reset.js index 126154c..5105482 100644 --- a/static/js/terminal/lib/esc/reset.js +++ b/static/js/terminal/lib/esc/reset.js @@ -9,21 +9,20 @@ module.exports = function (Terminal){ Terminal.prototype.reset = function (){ var parent; - if (this.element) { - parent = this.element.parentNode; + if (this.screen) { + parent = this.screen.parentNode; if (parent) { - parent.removeChild(this.element); + parent.removeChild(this.screen); } } Terminal.call(this, this.options); this.open(); - this.refresh(0, this.rows - 1); if (parent) { - parent.appendChild(this.element); + parent.appendChild(this.screen); } }; }; diff --git a/static/js/terminal/lib/open.js b/static/js/terminal/lib/open.js index 12a5381..77a3eee 100644 --- a/static/js/terminal/lib/open.js +++ b/static/js/terminal/lib/open.js @@ -32,16 +32,16 @@ module.exports = function (Terminal){ var div; var i = 0; - this.element = document.createElement('div'); - this.element.className = 'ui-terminal'; - this.element.style.outline = 'none'; + this.screen = document.createElement('div'); + this.screen.className = 'ui-terminal'; + this.screen.style.outline = 'none'; - this.element.setAttribute('tabindex', '0'); - this.element.setAttribute('spellcheck', 'false'); + this.screen.setAttribute('tabindex', '0'); + this.screen.setAttribute('spellcheck', 'false'); // sync default bg/fg colors - this.element.style.backgroundColor = this.bgColor; - this.element.style.color = this.fgColor; + this.screen.style.backgroundColor = this.bgColor; + this.screen.style.color = this.fgColor; // Create the lines for our terminal. this.children = []; @@ -49,7 +49,7 @@ module.exports = function (Terminal){ for (; i < this.rows; i++) { div = document.createElement('div'); - this.element.appendChild(div); + this.screen.appendChild(div); this.children.push(div); } diff --git a/static/js/terminal/lib/refresh.js b/static/js/terminal/lib/refresh.js index e1e72ef..726923a 100644 --- a/static/js/terminal/lib/refresh.js +++ b/static/js/terminal/lib/refresh.js @@ -22,12 +22,12 @@ module.exports = function (Terminal){ * @param end */ Terminal.prototype.refresh = function (start, end){ - var parent = this.element ? this.element.parentNode : null; + var parent = this.screen ? this.screen.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 (optimize) { - parent.removeChild(this.element); + parent.removeChild(this.screen); } width = this.cols; @@ -154,7 +154,7 @@ module.exports = function (Terminal){ } if (optimize) { - parent.appendChild(this.element); + parent.appendChild(this.screen); } }; }; diff --git a/static/js/terminal/lib/resize.js b/static/js/terminal/lib/resize.js index 9199e86..684466c 100644 --- a/static/js/terminal/lib/resize.js +++ b/static/js/terminal/lib/resize.js @@ -11,7 +11,7 @@ module.exports = function (Terminal){ * @param y */ Terminal.prototype.resize = function (x, y){ - var line, element, i, j, ch; + var line, screen, i, j, ch; if (x < 1) x = 1; @@ -48,7 +48,7 @@ module.exports = function (Terminal){ j = this.rows; if (j < y) { - element = this.element; + screen = this.screen; while (j++ < y) { if (this.lines.length < y + this.ybase) { @@ -58,7 +58,7 @@ module.exports = function (Terminal){ if (this.children.length < y) { line = this.document.createElement('div'); - element.appendChild(line); + screen.appendChild(line); this.children.push(line); } @@ -70,11 +70,11 @@ module.exports = function (Terminal){ } if (this.children.length > y) { - element = this.children.pop(); + screen = this.children.pop(); - if (!element) continue; + if (!screen) continue; - element.parentNode.removeChild(element); + screen.parentNode.removeChild(screen); } } } diff --git a/static/js/terminal/lib/write.js b/static/js/terminal/lib/write.js index 2f06f7b..7b71132 100644 --- a/static/js/terminal/lib/write.js +++ b/static/js/terminal/lib/write.js @@ -38,10 +38,10 @@ module.exports = function (Terminal){ var context = this; - this.element.style.borderColor = 'white'; + this.screen.style.borderColor = 'white'; setTimeout(function (){ - context.element.style.borderColor = ''; + context.screen.style.borderColor = ''; }, 10); if (this.popOnBell) this.focus();