From cfcac66020120b1b074f24487c478d723b4bf5e5 Mon Sep 17 00:00:00 2001 From: cpsdqs Date: Fri, 29 Sep 2017 14:09:57 +0200 Subject: [PATCH] Keep themes in renderer --- js/term/screen_parser.js | 8 ++------ js/term/screen_renderer.js | 4 ++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/term/screen_parser.js b/js/term/screen_parser.js index c35e184..86e10e1 100644 --- a/js/term/screen_parser.js +++ b/js/term/screen_parser.js @@ -1,6 +1,5 @@ const $ = require('../lib/chibi') const { qs } = require('../utils') -const { themes } = require('./themes') // constants for decoding the update blob const SEQ_REPEAT = 2 @@ -84,7 +83,6 @@ module.exports = class ScreenParser { console.log(`topic ${topic}`) if (topic === TOPIC_SCREEN_OPTS) { - const newHeight = du(strArray[ci++]) const newWidth = du(strArray[ci++]) const theme = du(strArray[ci++]) @@ -92,10 +90,8 @@ module.exports = class ScreenParser { const defBg = du(strArray[ci++]) | (du(strArray[ci++]) << 12) const attributes = du(strArray[ci++]) - // themeing - if (theme >= 0 && theme < themes.length) { - this.screen.renderer.palette = themes[theme] - } + // theming + this.screen.renderer.loadTheme(theme) this.screen.renderer.setDefaultColors(defFg, defBg) // apply size diff --git a/js/term/screen_renderer.js b/js/term/screen_renderer.js index 4eb9420..a98bb86 100644 --- a/js/term/screen_renderer.js +++ b/js/term/screen_renderer.js @@ -76,6 +76,10 @@ module.exports = class ScreenRenderer { } } + loadTheme (i) { + if (i in themes) this.palette = themes[i] + } + setDefaultColors (fg, bg) { this.defaultFgNum = fg this.defaultBgNum = bg