diff --git a/static/js/terminal/index.js b/static/js/terminal/index.js index d577bb1..362abc8 100644 --- a/static/js/terminal/index.js +++ b/static/js/terminal/index.js @@ -70,19 +70,15 @@ function Terminal(options){ this.cols = options.cols; this.rows = options.rows; - // set ondata + // set on data callback options.ondata = typeof options.ondata === 'function' ? options.ondata : function (){}; this.ondata = options.ondata; - // set ontitle + // set on title callback options.ontitle = typeof options.ontitle === 'function' ? options.ontitle : function (){}; this.ontitle = options.ontitle; - // set onscreen - options.onscreen = typeof options.onscreen === 'function' ? options.onscreen : function (){}; - this.onscreen = options.onscreen; - - // set convert eol + // set convert end of line options.convertEOL = options.convertEOL === true; this.convertEOL = options.convertEOL; @@ -114,8 +110,8 @@ function Terminal(options){ this.charsets = [null]; // misc - this.screen = ''; - this.screenLines = []; + this.element = null; + this.children = []; this.refreshStart = null; this.refreshEnd = null; this.savedX = null; diff --git a/static/js/terminal/lib/close.js b/static/js/terminal/lib/close.js index 1a398ea..6d0801c 100644 --- a/static/js/terminal/lib/close.js +++ b/static/js/terminal/lib/close.js @@ -10,13 +10,21 @@ module.exports = function (Terminal){ */ Terminal.prototype.close = function (){ this.lines = []; - this.screen = ''; - this.screenLines = []; + this.children = []; this.readable = false; this.writable = false; this.write = function (){}; this.ondata = function (){}; - this.ontitle = function (){}; - this.onscreen = function (){}; + this.ondataTitle = function (){}; + + if (this.element) { + var parent = this.element.parentNode; + + if (parent) { + parent.removeChild(this.element); + } + + this.element = null; + } }; }; diff --git a/static/js/terminal/lib/csi/mode.js b/static/js/terminal/lib/csi/mode.js index 411cb29..24e9e03 100644 --- a/static/js/terminal/lib/csi/mode.js +++ b/static/js/terminal/lib/csi/mode.js @@ -107,7 +107,7 @@ module.exports = function (Terminal){ this.insertMode = true; break; case 20: - this.convertEol = true; + this.convertEOL = true; break; } } else if (this.prefix === '?') { @@ -322,7 +322,7 @@ module.exports = function (Terminal){ this.insertMode = false; break; case 20: - this.convertEol = false; + this.convertEOL = false; break; } } else if (this.prefix === '?') { diff --git a/static/js/terminal/lib/focused.js b/static/js/terminal/lib/focused.js index f8abcf4..7e4a494 100644 --- a/static/js/terminal/lib/focused.js +++ b/static/js/terminal/lib/focused.js @@ -7,14 +7,6 @@ module.exports = function (Terminal){ Terminal.focus = null; - /** - * isFocused - * @returns {boolean} - */ - Terminal.prototype.isFocused = function (){ - return Terminal.focus === this; - }; - /** * focus */ @@ -25,8 +17,6 @@ module.exports = function (Terminal){ Terminal.focus.blur(); } - Terminal.focus = this; - if (this.cursor) { this.showCursor(); } @@ -34,6 +24,8 @@ module.exports = function (Terminal){ if (this.cursorBlink) { this.startBlink(); } + + Terminal.focus = this; }; /** diff --git a/static/js/terminal/lib/open.js b/static/js/terminal/lib/open.js index 99043d9..12a5381 100644 --- a/static/js/terminal/lib/open.js +++ b/static/js/terminal/lib/open.js @@ -29,12 +29,35 @@ module.exports = function (Terminal){ * open */ Terminal.prototype.open = function (){ + var div; + var i = 0; + + this.element = document.createElement('div'); + this.element.className = 'ui-terminal'; + this.element.style.outline = 'none'; + + this.element.setAttribute('tabindex', '0'); + this.element.setAttribute('spellcheck', 'false'); + + // sync default bg/fg colors + this.element.style.backgroundColor = this.bgColor; + this.element.style.color = this.fgColor; + + // Create the lines for our terminal. + this.children = []; + + for (; i < this.rows; i++) { + div = document.createElement('div'); + + this.element.appendChild(div); + this.children.push(div); + } + // XXX - hack, move this somewhere else. if (Terminal.brokenBold === null) { Terminal.brokenBold = isBoldBroken(); } this.refresh(0, this.rows - 1); - this.focus(); }; }; diff --git a/static/js/terminal/lib/options.js b/static/js/terminal/lib/options.js index 6377a91..0db661c 100644 --- a/static/js/terminal/lib/options.js +++ b/static/js/terminal/lib/options.js @@ -11,6 +11,7 @@ module.exports = function (Terminal){ Terminal.cursor = true; Terminal.cursorBlink = true; Terminal.cursorBlinkSpeed = 500; + Terminal.visualBell = true; Terminal.popOnBell = true; Terminal.scrollback = 640; Terminal.screenKeys = false; @@ -23,6 +24,7 @@ module.exports = function (Terminal){ cursor: Terminal.cursor, cursorBlink: Terminal.cursorBlink, cursorBlinkSpeed: Terminal.cursorBlinkSpeed, + visualBell: Terminal.visualBell, popOnBell: Terminal.popOnBell, scrollback: Terminal.scrollback, screenKeys: Terminal.screenKeys, diff --git a/static/js/terminal/lib/refresh.js b/static/js/terminal/lib/refresh.js index 3661b9c..e1e72ef 100644 --- a/static/js/terminal/lib/refresh.js +++ b/static/js/terminal/lib/refresh.js @@ -5,21 +5,6 @@ 'use strict'; module.exports = function (Terminal){ - /** - * screen - * @param foreground - * @param background - * @param content - * @returns {string} - */ - function screen(foreground, background, content){ - var intro = '