new colors decoding

cpsdqs/unified-input
Ondřej Hruška 7 years ago
parent c07a6162f2
commit 810782a7f2
  1. 44
      jssrc/term_screen.js

@ -8,10 +8,11 @@ const frakturExceptions = {
} }
// constants for decoding the update blob // constants for decoding the update blob
const SEQ_SET_COLOR_ATTR = 1
const SEQ_REPEAT = 2 const SEQ_REPEAT = 2
const SEQ_SET_COLOR = 3 const SEQ_SET_COLORS = 3
const SEQ_SET_ATTR = 4 const SEQ_SET_ATTRS = 4
const SEQ_SET_FG = 5
const SEQ_SET_BG = 6
const SELECTION_BG = '#b2d7fe' const SELECTION_BG = '#b2d7fe'
const SELECTION_FG = '#333' const SELECTION_FG = '#333'
@ -1021,43 +1022,44 @@ class TermScreen {
this.screenAttrs[cell] = myAttrs this.screenAttrs[cell] = myAttrs
} }
let blinkAttr = 0
while (i < strArray.length && cell < screenLength) { while (i < strArray.length && cell < screenLength) {
let character = strArray[i++] let character = strArray[i++]
let charCode = character.codePointAt(0) let charCode = character.codePointAt(0)
let data let data
switch (charCode) { switch (charCode) {
case SEQ_SET_COLOR_ATTR: case SEQ_REPEAT:
let count = parse2B(strArray[i] + strArray[i + 1])
i += 2
for (let j = 0; j < count; j++) {
setCellContent(cell)
if (++cell > screenLength) break
}
break
case SEQ_SET_COLORS:
data = parse3B(strArray[i] + strArray[i + 1] + strArray[i + 2]) data = parse3B(strArray[i] + strArray[i + 1] + strArray[i + 2])
i += 3 i += 3
fg = data & 0xF fg = data & 0xFF
bg = data >> 4 & 0xF bg = (data >> 8) & 0xFF
attrs = data >> 8 & 0xFF
blinkAttr = attrs & MASK_BLINK
break break
case SEQ_SET_COLOR: case SEQ_SET_ATTRS:
data = parse2B(strArray[i] + strArray[i + 1]) data = parse2B(strArray[i] + strArray[i + 1])
i += 2 i += 2
fg = data & 0xF attrs = data & 0xFF
bg = data >> 4 & 0xF
break break
case SEQ_SET_ATTR: case SEQ_SET_FG:
data = parse2B(strArray[i] + strArray[i + 1]) data = parse2B(strArray[i] + strArray[i + 1])
i += 2 i += 2
attrs = data & 0xFF fg = data & 0xFF
blinkAttr = attrs & MASK_BLINK
break break
case SEQ_REPEAT: case SEQ_SET_BG:
let count = parse2B(strArray[i] + strArray[i + 1]) data = parse2B(strArray[i] + strArray[i + 1])
i += 2 i += 2
for (let j = 0; j < count; j++) { bg = data & 0xFF
setCellContent(cell)
if (++cell > screenLength) break
}
break break
default: default:

Loading…
Cancel
Save