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