From 33813cd46d4016aea9dad6d628141570c7cb7756 Mon Sep 17 00:00:00 2001 From: KLuka Date: Thu, 5 Mar 2015 16:15:12 +0100 Subject: [PATCH] Issue #245: Blank screen in Chrome 31.0.1650.57 Applied patch and fixed some formating. Patch: https://code.google.com/p/shellinabox/issues/detail?id=245#c5 --- shellinabox/vt100.jspp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/shellinabox/vt100.jspp b/shellinabox/vt100.jspp index 6ec0efa..e5f31ab 100755 --- a/shellinabox/vt100.jspp +++ b/shellinabox/vt100.jspp @@ -175,7 +175,7 @@ function VT100(container) { } this.getUserSettings(); this.initializeElements(container); - this.maxScrollbackLines = 500; + this.maxScrollbackLines = 2000; this.npar = 0; this.par = [ ]; this.isQuestionMark = false; @@ -1157,8 +1157,12 @@ VT100.prototype.resizer = function() { // still get confused if somebody enters a character that is wider/narrower // than normal. This can happen if the browser tries to substitute a // characters from a different font. - this.cursor.style.width = this.cursorWidth + 'px'; - this.cursor.style.height = this.cursorHeight + 'px'; + if (this.cursorWidth > 0) { + this.cursor.style.width = this.cursorWidth + 'px'; + } + if (this.cursorHeight > 0) { + this.cursor.style.height = this.cursorHeight + 'px'; + } // Adjust height for one pixel padding of the #vt100 element. // The latter is necessary to properly display the inactive cursor. @@ -1531,8 +1535,20 @@ VT100.prototype.insertBlankLine = function(y, color, style) { }; VT100.prototype.updateWidth = function() { - this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/ - this.cursorWidth*this.scale); + // if the cursorWidth is zero, something is wrong. Try to get it some other way. + if (this.cursorWidth <= 0) { + if (this.cursor.clientWidth <= 0) { + // Rats, this.cursor.clientWidth is zero too. Best guess? + this.terminalWidth = 80; + } else { + // update the size. + this.cursorWidth = this.cursor.clientWidth; + this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale); + } + } else { + this.terminalWidth = Math.floor(this.console[this.currentScreen].offsetWidth/this.cursorWidth*this.scale); + } + return this.terminalWidth; };