From 73cb0a4b2b575302c95e3860ebb91cdd9078a720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 30 Sep 2017 17:48:03 +0200 Subject: [PATCH] Interpret bold 0-7 as bold 8-15 (matches Xterm reference impl), add SEQ_SKIP --- js/term/index.js | 2 +- js/term/screen_parser.js | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/js/term/index.js b/js/term/index.js index 77a1268..6600abd 100644 --- a/js/term/index.js +++ b/js/term/index.js @@ -40,7 +40,7 @@ module.exports = function (opts) { }) conn.on('disconnect', () => { // console.log('*disconnect') - showSplash({ title: 'Disconnected' }) + showSplash({ title: 'Disconnected' }, 500) screen.screen = [] screen.screenFG = [] screen.screenBG = [] diff --git a/js/term/screen_parser.js b/js/term/screen_parser.js index 2c0dbea..cd48554 100644 --- a/js/term/screen_parser.js +++ b/js/term/screen_parser.js @@ -2,6 +2,7 @@ const $ = require('../lib/chibi') const { qs } = require('../utils') // constants for decoding the update blob +const SEQ_SKIP = 1 const SEQ_REPEAT = 2 const SEQ_SET_COLORS = 3 const SEQ_SET_ATTRS = 4 @@ -266,6 +267,12 @@ module.exports = class ScreenParser { let myAttrs = attrs let hasFG = attrs & ATTR_FG let hasBG = attrs & ATTR_BG + + // use 0,0 if no fg/bg. this is to match back-end implementation + // and allow leaving out fg/bg setting for cells with none + if (!hasFG) fg = 0 + if (!hasBG) bg = 0 + if ((myAttrs & MASK_BLINK) !== 0 && ((lastChar === ' ' && ((myAttrs & MASK_LINE_ATTR) === 0)) || // no line styles (fg === bg && hasFG && hasBG) // invisible text @@ -283,8 +290,15 @@ module.exports = class ScreenParser { let cellYInFrame = Math.floor(cell / frameWidth) let index = (frameY + cellYInFrame) * this.screen.window.width + frameX + cellXInFrame + let cellFg = fg + + // 8 dark system colors turn bright when bold + if ((myAttrs & ATTR_BOLD) && !(myAttrs & ATTR_FAINT) && hasFG && fg < 8) { + cellFg += 8 + } + this.screen.screen[index] = lastChar - this.screen.screenFG[index] = fg + this.screen.screenFG[index] = cellFg this.screen.screenBG[index] = bg this.screen.screenAttrs[index] = myAttrs } @@ -293,16 +307,20 @@ module.exports = class ScreenParser { let character = strArray[ci++] let charCode = character.codePointAt(0) - let data + let data, count switch (charCode) { case SEQ_REPEAT: - let count = du(strArray[ci++]) + count = du(strArray[ci++]) for (let j = 0; j < count; j++) { pushCell() if (++cell > screenLength) break } break + case SEQ_SKIP: + cell += du(strArray[ci++]) + break + case SEQ_SET_COLORS: data = du(strArray[ci++]) fg = data & 0xFF @@ -364,6 +382,9 @@ module.exports = class ScreenParser { load (str) { const content = str.substr(1) + // This is a good place for debugging the message + // console.log(str) + switch (str[0]) { case 'U': this.loadUpdate(content)