Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff --git a/browser/main.js b/browser/main.js index cc36f55..6588cd8 100644 --- a/browser/main.js +++ b/browser/main.js @@ -17,4 +17,5 @@ socket.on('snapshot', function (data) { for (var prop in data) { term[prop] = data[prop]; } + term.refresh(0, 29); }); \ No newline at end of file diff --git a/browser/term.js b/browser/term.js index 7423080..1d3cb06 100644 --- a/browser/term.js +++ b/browser/term.js @@ -150,7 +150,8 @@ Terminal.prototype.refresh = function(start, end) { , defAttr , fgColor , bgColor - , row; + , row + , isInverse; for (y = start; y <= end; y++) { row = y + this.ydisp; @@ -187,14 +188,19 @@ Terminal.prototype.refresh = function(start, end) { out += '<span style="'; fgColor = (data >> 3) & 7; bgColor = data & 7; - if (fgColor !== 7) { + isInverse = (data >> 8) & 8; + if (fgColor !== 7 || isInverse) { out += 'color:' - + this.fgColors[fgColor] + + (!isInverse + ? this.fgColors[fgColor] + : this.bgColors[bgColor]) + ';'; } - if (bgColor !== 0) { + if (bgColor !== 0 || isInverse) { out += 'background-color:' - + this.bgColors[bgColor] + + (isInverse + ? this.fgColors[fgColor] + : this.bgColors[bgColor]) + ';'; } if ((data >> 8) & 1) { @@ -1640,12 +1646,18 @@ Terminal.prototype.charAttributes = function(params) { } else if (p === 4) { // underlined text this.curAttr = this.curAttr | (4 << 8); + } else if (p === 7) { + // inverse text + this.curAttr = this.curAttr | (8 << 8); } else if (p === 22) { // not bold this.curAttr = this.curAttr & ~(1 << 8); } else if (p === 24) { // not underlined this.curAttr = this.curAttr & ~(4 << 8); + } else if (p === 27) { + // not inverse text + this.curAttr = this.curAttr & ~(8 << 8); } else if (p === 39) { // reset fg p = this.curAttr & 7; diff --git a/master_terminal/term.js b/master_terminal/term.js index c16206b..e0dbb4e 100644 --- a/master_terminal/term.js +++ b/master_terminal/term.js @@ -152,7 +152,8 @@ Terminal.prototype.refresh = function(start, end) { , defAttr , fgColor , bgColor - , row; + , row + , isInverse; for (y = start; y <= end; y++) { row = y + this.ydisp; @@ -189,14 +190,19 @@ Terminal.prototype.refresh = function(start, end) { out += '<span style="'; fgColor = (data >> 3) & 7; bgColor = data & 7; - if (fgColor !== 7) { + isInverse = (data >> 8) & 8; + if (fgColor !== 7 || isInverse) { out += 'color:' - + this.fgColors[fgColor] + + (!isInverse + ? this.fgColors[fgColor] + : this.bgColors[bgColor]) + ';'; } - if (bgColor !== 0) { + if (bgColor !== 0 || isInverse) { out += 'background-color:' - + this.bgColors[bgColor] + + (isInverse + ? this.fgColors[fgColor] + : this.bgColors[bgColor]) + ';'; } if ((data >> 8) & 1) { @@ -1642,12 +1648,18 @@ Terminal.prototype.charAttributes = function(params) { } else if (p === 4) { // underlined text this.curAttr = this.curAttr | (4 << 8); + } else if (p === 7) { + // inverse text + this.curAttr = this.curAttr | (8 << 8); } else if (p === 22) { // not bold this.curAttr = this.curAttr & ~(1 << 8); } else if (p === 24) { // not underlined this.curAttr = this.curAttr & ~(4 << 8); + } else if (p === 27) { + // not inverse text + this.curAttr = this.curAttr & ~(8 << 8); } else if (p === 39) { // reset fg p = this.curAttr & 7; diff --git a/server/app.js b/server/app.js index c820649..f5c01c6 100644 --- a/server/app.js +++ b/server/app.js @@ -12,6 +12,8 @@ var mterm = new (require('../master_terminal'))(80, 30), io, handlers = {}; +mterm.open(); + function isObject(obj) { return typeof obj === 'object' && obj !== null; }
- Loading branch information