From e9aa3bfba623ee888b77db0f5c746378f3756bbb Mon Sep 17 00:00:00 2001 From: cpsdqs Date: Sat, 23 Sep 2017 02:55:56 +0200 Subject: [PATCH] Fix demo having black spots and refactor a bit * Note: black spots are caused by inexplicable palette switch; might need investigation --- js/term/demo.js | 1 - js/term/screen_renderer.js | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/term/demo.js b/js/term/demo.js index 7459e08..7f23aa7 100644 --- a/js/term/demo.js +++ b/js/term/demo.js @@ -281,7 +281,6 @@ class ScrollingTerminal { else if (setForeground) serialized += '\x05' + encode2B(foreground) else if (setBackground) serialized += '\x06' + encode2B(background) if (setAttributes) serialized += '\x04' + encode2B(attributes) - lastStyle = style } serialized += cell[0] diff --git a/js/term/screen_renderer.js b/js/term/screen_renderer.js index 0b3ad4e..452afb4 100644 --- a/js/term/screen_renderer.js +++ b/js/term/screen_renderer.js @@ -53,6 +53,7 @@ module.exports = class ScreenRenderer { set palette (palette) { if (this._palette !== palette) { this._palette = palette + this.resetDrawn() this.scheduleDraw('palette') } } @@ -96,8 +97,8 @@ module.exports = class ScreenRenderer { return `rgb(${red}, ${green}, ${blue})` } - // default to transparent - return 'rgba(0, 0, 0, 0)' + // return error color + return (Date.now() / 1000) % 2 === 0 ? '#f0f' : '#0f0' } /** @@ -413,9 +414,9 @@ module.exports = class ScreenRenderer { let inSelection = this.screen.isInSelection(x, y) let text = this.screen.screen[cell] - let fg = this.screen.screenFG[cell] - let bg = this.screen.screenBG[cell] - let attrs = this.screen.screenAttrs[cell] + let fg = this.screen.screenFG[cell] | 0 + let bg = this.screen.screenBG[cell] | 0 + let attrs = this.screen.screenAttrs[cell] | 0 if (attrs & (1 << 4) && !this.blinkStyleOn) { // blinking is enabled and blink style is off @@ -438,7 +439,7 @@ module.exports = class ScreenRenderer { let font = attrs & FONT_MASK if (!fontGroups.has(font)) fontGroups.set(font, []) - fontGroups.get(font).push([cell, x, y, text, fg, bg, attrs, isCursor, inSelection]) + fontGroups.get(font).push({ cell, x, y, text, fg, bg, attrs, isCursor, inSelection }) updateMap.set(cell, didUpdate) } @@ -507,7 +508,7 @@ module.exports = class ScreenRenderer { // pass 1: backgrounds for (let font of fontGroups.keys()) { for (let data of fontGroups.get(font)) { - let [cell, x, y, text, , bg] = data + let { cell, x, y, text, bg } = data if (redrawMap.get(cell)) { this.drawBackground({ x, y, cellWidth, cellHeight, bg }) @@ -536,7 +537,7 @@ module.exports = class ScreenRenderer { ctx.font = this.screen.getFont(modifiers) for (let data of fontGroups.get(font)) { - let [cell, x, y, text, fg, bg, attrs, isCursor, inSelection] = data + let { cell, x, y, text, fg, bg, attrs, isCursor, inSelection } = data if (redrawMap.get(cell)) { this.drawCharacter({