Refactor and fix getColor returning undefined

box-drawing
cpsdqs 7 years ago
parent 52bde8c266
commit a196f9a9de
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 11
      js/term/screen_parser.js
  2. 2
      js/term/screen_renderer.js

@ -1,6 +1,6 @@
const $ = require('../lib/chibi')
const { qs } = require('../utils')
const { themes, defThemes } = require('./themes')
const { themes } = require('./themes')
// constants for decoding the update blob
const SEQ_REPEAT = 2
@ -160,7 +160,7 @@ module.exports = class ScreenParser {
case SEQ_REPEAT:
let count = strArray[i++].codePointAt(0) - 1
for (let j = 0; j < count; j++) {
setCellContent(cell)
setCellContent()
if (++cell > screenLength) break
}
break
@ -189,7 +189,7 @@ module.exports = class ScreenParser {
default:
if (charCode < 32) character = '\ufffd'
lastChar = character
setCellContent(cell)
setCellContent()
cell++
}
}
@ -223,7 +223,10 @@ module.exports = class ScreenParser {
/**
* Loads a message from the server, and optionally a theme.
* @param {string} str - the message
* @param {object} [opts] - options { [int] theme, [int] defaultFg, [int] defaultBg }
* @param {object} [opts] - options
* @param {number} [opts.theme] - theme
* @param {number} [opts.defaultFg] - default foreground
* @param {number} [opts.defaultBg] - default background
*/
load (str, opts = null) {
const content = str.substr(1)

@ -89,7 +89,7 @@ module.exports = class ScreenRenderer {
*/
getColor (i) {
// return palette color if it exists
if (i < 16) return this.palette[i]
if (i < 16 && i in this.palette) return this.palette[i]
// -1 for selection foreground, -2 for selection background
if (i === -1) return SELECTION_FG

Loading…
Cancel
Save