|
|
@ -28,6 +28,7 @@ function du (str) { |
|
|
|
|
|
|
|
|
|
|
|
/* eslint-disable no-multi-spaces */ |
|
|
|
/* eslint-disable no-multi-spaces */ |
|
|
|
const TOPIC_SCREEN_OPTS = 'O' |
|
|
|
const TOPIC_SCREEN_OPTS = 'O' |
|
|
|
|
|
|
|
const TOPIC_STATIC_OPTS = 'P' |
|
|
|
const TOPIC_CONTENT = 'S' |
|
|
|
const TOPIC_CONTENT = 'S' |
|
|
|
const TOPIC_TITLE = 'T' |
|
|
|
const TOPIC_TITLE = 'T' |
|
|
|
const TOPIC_BUTTONS = 'B' |
|
|
|
const TOPIC_BUTTONS = 'B' |
|
|
@ -85,6 +86,16 @@ module.exports = class ScreenParser { |
|
|
|
return text |
|
|
|
return text |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let collectColor = () => { |
|
|
|
|
|
|
|
let c = du(strArray[ci++]) |
|
|
|
|
|
|
|
if (c & 0x10000) { // support for trueColor
|
|
|
|
|
|
|
|
c &= 0xFFF |
|
|
|
|
|
|
|
c |= (du(strArray[ci++]) & 0xFFF) << 12 |
|
|
|
|
|
|
|
c += 256 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return c |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const updates = [] |
|
|
|
const updates = [] |
|
|
|
|
|
|
|
|
|
|
|
while (ci < strArray.length) { |
|
|
|
while (ci < strArray.length) { |
|
|
@ -94,8 +105,8 @@ module.exports = class ScreenParser { |
|
|
|
const height = du(strArray[ci++]) |
|
|
|
const height = du(strArray[ci++]) |
|
|
|
const width = du(strArray[ci++]) |
|
|
|
const width = du(strArray[ci++]) |
|
|
|
const theme = du(strArray[ci++]) |
|
|
|
const theme = du(strArray[ci++]) |
|
|
|
const defFG = (du(strArray[ci++]) & 0xFFFF) | ((du(strArray[ci++]) & 0xFFFF) << 16) |
|
|
|
const defFG = collectColor() |
|
|
|
const defBG = (du(strArray[ci++]) & 0xFFFF) | ((du(strArray[ci++]) & 0xFFFF) << 16) |
|
|
|
const defBG = collectColor() |
|
|
|
|
|
|
|
|
|
|
|
// process attributes
|
|
|
|
// process attributes
|
|
|
|
const attributes = du(strArray[ci++]) |
|
|
|
const attributes = du(strArray[ci++]) |
|
|
@ -153,6 +164,7 @@ module.exports = class ScreenParser { |
|
|
|
reverseVideo, |
|
|
|
reverseVideo, |
|
|
|
debugEnabled |
|
|
|
debugEnabled |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_CURSOR) { |
|
|
|
} else if (topic === TOPIC_CURSOR) { |
|
|
|
// cursor position
|
|
|
|
// cursor position
|
|
|
|
const y = du(strArray[ci++]) |
|
|
|
const y = du(strArray[ci++]) |
|
|
@ -165,28 +177,44 @@ module.exports = class ScreenParser { |
|
|
|
y, |
|
|
|
y, |
|
|
|
hanging |
|
|
|
hanging |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_STATIC_OPTS) { |
|
|
|
|
|
|
|
const fontStack = collectOneTerminatedString() |
|
|
|
|
|
|
|
const fontSize = du(strArray[ci++]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updates.push({ |
|
|
|
|
|
|
|
topic: 'static-opts', |
|
|
|
|
|
|
|
fontStack, |
|
|
|
|
|
|
|
fontSize |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_TITLE) { |
|
|
|
} else if (topic === TOPIC_TITLE) { |
|
|
|
updates.push({ topic: 'title', title: collectOneTerminatedString() }) |
|
|
|
updates.push({ topic: 'title', title: collectOneTerminatedString() }) |
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_BUTTONS) { |
|
|
|
} else if (topic === TOPIC_BUTTONS) { |
|
|
|
const count = du(strArray[ci++]) |
|
|
|
const count = du(strArray[ci++]) |
|
|
|
|
|
|
|
|
|
|
|
let labels = [] |
|
|
|
let labels = [] |
|
|
|
|
|
|
|
let colors = [] |
|
|
|
for (let j = 0; j < count; j++) { |
|
|
|
for (let j = 0; j < count; j++) { |
|
|
|
text = collectOneTerminatedString() |
|
|
|
colors.push(collectColor()) |
|
|
|
labels.push(text) |
|
|
|
labels.push(collectOneTerminatedString()) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
updates.push({ |
|
|
|
updates.push({ |
|
|
|
topic: 'button-labels', |
|
|
|
topic: 'buttons-update', |
|
|
|
labels |
|
|
|
labels, |
|
|
|
|
|
|
|
colors |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_BACKDROP) { |
|
|
|
} else if (topic === TOPIC_BACKDROP) { |
|
|
|
updates.push({ topic: 'backdrop', image: collectOneTerminatedString() }) |
|
|
|
updates.push({ topic: 'backdrop', image: collectOneTerminatedString() }) |
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_BELL) { |
|
|
|
} else if (topic === TOPIC_BELL) { |
|
|
|
updates.push({ topic: 'bell' }) |
|
|
|
updates.push({ topic: 'bell' }) |
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_INTERNAL) { |
|
|
|
} else if (topic === TOPIC_INTERNAL) { |
|
|
|
// debug info
|
|
|
|
// debug info
|
|
|
|
|
|
|
|
|
|
|
|
const flags = du(strArray[ci++]) |
|
|
|
const flags = du(strArray[ci++]) |
|
|
|
const cursorAttrs = du(strArray[ci++]) |
|
|
|
const cursorAttrs = du(strArray[ci++]) |
|
|
|
const regionStart = du(strArray[ci++]) |
|
|
|
const regionStart = du(strArray[ci++]) |
|
|
@ -194,6 +222,10 @@ module.exports = class ScreenParser { |
|
|
|
const charsetGx = du(strArray[ci++]) |
|
|
|
const charsetGx = du(strArray[ci++]) |
|
|
|
const charsetG0 = strArray[ci++] |
|
|
|
const charsetG0 = strArray[ci++] |
|
|
|
const charsetG1 = strArray[ci++] |
|
|
|
const charsetG1 = strArray[ci++] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let cursorFg = collectColor() |
|
|
|
|
|
|
|
let cursorBg = collectColor() |
|
|
|
|
|
|
|
|
|
|
|
const freeHeap = du(strArray[ci++]) |
|
|
|
const freeHeap = du(strArray[ci++]) |
|
|
|
const clientCount = du(strArray[ci++]) |
|
|
|
const clientCount = du(strArray[ci++]) |
|
|
|
|
|
|
|
|
|
|
@ -206,9 +238,12 @@ module.exports = class ScreenParser { |
|
|
|
charsetGx, |
|
|
|
charsetGx, |
|
|
|
charsetG0, |
|
|
|
charsetG0, |
|
|
|
charsetG1, |
|
|
|
charsetG1, |
|
|
|
|
|
|
|
cursorFg, |
|
|
|
|
|
|
|
cursorBg, |
|
|
|
freeHeap, |
|
|
|
freeHeap, |
|
|
|
clientCount |
|
|
|
clientCount |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} else if (topic === TOPIC_CONTENT) { |
|
|
|
} else if (topic === TOPIC_CONTENT) { |
|
|
|
// set screen content
|
|
|
|
// set screen content
|
|
|
|
const frameY = du(strArray[ci++]) |
|
|
|
const frameY = du(strArray[ci++]) |
|
|
|