From 12a617fce5f7d0737107c29de337f78b4b4d98bc Mon Sep 17 00:00:00 2001 From: nuintun Date: Wed, 25 Nov 2015 00:19:23 +0800 Subject: [PATCH] update files --- static/css/index.css | 4 ++++ static/js/components/app-main/index.js | 6 +++--- static/js/terminal/index.js | 1 + static/js/terminal/lib/focused.js | 30 ++++++++++++++++++++++++++ static/js/terminal/lib/open.js | 2 +- static/js/terminal/lib/refresh.js | 2 +- 6 files changed, 40 insertions(+), 5 deletions(-) create mode 100644 static/js/terminal/lib/focused.js diff --git a/static/css/index.css b/static/css/index.css index ffd2c40..e018ea5 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -494,3 +494,7 @@ header [class*=" icon-"] { height: calc(100% - 32px); background: url(../images/no-data.png) center no-repeat; } +.ui-terminal-cursor { + color: #181818; + background-color: #fff; +} diff --git a/static/js/components/app-main/index.js b/static/js/components/app-main/index.js index 3bef3f2..990e5ca 100644 --- a/static/js/components/app-main/index.js +++ b/static/js/components/app-main/index.js @@ -118,7 +118,7 @@ module.exports = Vue.component('app-main', { '', ' \u001b[31mreturn\u001b[39m \u001b[37mhypernal\u001b[39m\u001b[90m;\u001b[39m', '\u001b[33m}\u001b[39m\u001b[90m;\u001b[39m', - new Date().toISOString() + new Date().toISOString() + '\r\n' ].join('\r\n'); if (!runtime) { @@ -126,8 +126,8 @@ module.exports = Vue.component('app-main', { xterm.open(); xtermNode.appendChild(xterm.element); - xterm.showCursor(); - xterm.startBlink(); + xterm.focus(); + //xterm.startBlink(); console.log(xterm); diff --git a/static/js/terminal/index.js b/static/js/terminal/index.js index 4912691..27b1987 100644 --- a/static/js/terminal/index.js +++ b/static/js/terminal/index.js @@ -97,6 +97,7 @@ require('./lib/range')(Terminal); require('./lib/util')(Terminal); require('./lib/cursor')(Terminal); +require('./lib/focused')(Terminal); require('./lib/scrollDisp')(Terminal); diff --git a/static/js/terminal/lib/focused.js b/static/js/terminal/lib/focused.js new file mode 100644 index 0000000..00a0c94 --- /dev/null +++ b/static/js/terminal/lib/focused.js @@ -0,0 +1,30 @@ +/** + * Created by nuintun on 2015/11/25. + */ + +'use strict'; + +module.exports = function (Terminal){ + Terminal.focus = null; + + Terminal.prototype.focus = function (){ + if (Terminal.focus === this) return; + + if (Terminal.focus) { + Terminal.focus.blur(); + } + + this.showCursor(); + + Terminal.focus = this; + }; + + Terminal.prototype.blur = function (){ + if (Terminal.focus !== this) return; + + this.cursorState = 0; + this.refresh(this.y, this.y); + + Terminal.focus = null; + }; +}; diff --git a/static/js/terminal/lib/open.js b/static/js/terminal/lib/open.js index 9183a11..3578724 100644 --- a/static/js/terminal/lib/open.js +++ b/static/js/terminal/lib/open.js @@ -33,7 +33,7 @@ module.exports = function (Terminal){ var div; this.element = document.createElement('div'); - this.element.className = 'terminal'; + this.element.className = 'ui-terminal'; this.children = []; for (; i < this.rows; i++) { diff --git a/static/js/terminal/lib/refresh.js b/static/js/terminal/lib/refresh.js index eaeb296..ad833c1 100644 --- a/static/js/terminal/lib/refresh.js +++ b/static/js/terminal/lib/refresh.js @@ -58,7 +58,7 @@ module.exports = function (Terminal){ if (data !== this.defAttr) { if (data === -1) { - out += ''; + out += ''; } else { out += '