Fix parser derp, show internal info if available

box-drawing
cpsdqs 7 years ago
parent b2c14d34e7
commit 7c91203528
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 1
      js/term/buttons.js
  2. 16
      js/term/debug_screen.js
  3. 38
      js/term/screen_parser.js

@ -34,7 +34,6 @@ module.exports = function initButtons (input) {
// sync with DOM // sync with DOM
let update = function updateButtons () { let update = function updateButtons () {
console.log(labels)
if (labels.length > buttons.length) { if (labels.length > buttons.length) {
for (let i = buttons.length; i < labels.length; i++) { for (let i = buttons.length; i < labels.length; i++) {
pushButton() pushButton()

@ -247,14 +247,30 @@ module.exports = function attachDebugScreen (screen) {
return `((${y},${x})=${cell}:${hexcode}:F${cellFG}:B${cellBG}:A${cellAttrs.toString(2)})` return `((${y},${x})=${cell}:${hexcode}:F${cellFG}:B${cellBG}:A${cellAttrs.toString(2)})`
} }
let internalInfo = {}
updateToolbar = () => { updateToolbar = () => {
if (!toolbarAttached) return if (!toolbarAttached) return
let text = `C((${screen.cursor.y},${screen.cursor.x}),hang:${screen.cursor.hanging},vis:${screen.cursor.visible})` let text = `C((${screen.cursor.y},${screen.cursor.x}),hang:${screen.cursor.hanging},vis:${screen.cursor.visible})`
if (mouseHoverCell) { if (mouseHoverCell) {
text += ' m' + getCellData(mouseHoverCell[1] * screen.window.width + mouseHoverCell[0]) text += ' m' + getCellData(mouseHoverCell[1] * screen.window.width + mouseHoverCell[0])
} }
if ('flags' in internalInfo) {
// we got ourselves some internal data
text += ' '
text += ` flags:${internalInfo.flags}`
text += ` curAttrs:${internalInfo.cursorAttrs}`
text += ` Region:${internalInfo.regionStart}->${internalInfo.regionEnd}`
text += ` Charset:${internalInfo.charsetGx} (0:${internalInfo.charsetG0},1:${internalInfo.charsetG1})`
text += ` Heap:${internalInfo.freeHeap}`
text += ` Clients:${internalInfo.clientCount}`
}
dataDisplay.textContent = text dataDisplay.textContent = text
} }
screen.on('draw', updateToolbar) screen.on('draw', updateToolbar)
screen.on('internal', data => {
internalInfo = data
updateToolbar()
})
} }

@ -212,8 +212,8 @@ module.exports = class ScreenParser {
this.screen.beep() this.screen.beep()
} 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++])
@ -222,15 +222,25 @@ module.exports = class ScreenParser {
const charsetG0 = strArray[ci++] const charsetG0 = strArray[ci++]
const charsetG1 = strArray[ci++] const charsetG1 = strArray[ci++]
const freeHeap = du(strArray[ci++]) const freeHeap = du(strArray[ci++])
const numClients = du(strArray[ci++]) const clientCount = du(strArray[ci++])
// TODO do something with those
this.emit('internal', {
flags,
cursorAttrs,
regionStart,
regionEnd,
charsetGx,
charsetG0,
charsetG1,
freeHeap,
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++])
const frameX = du(strArray[ci++]) const frameX = du(strArray[ci++])
const frameHeight = du(strArray[ci++]) // FIXME unused, useless data! const frameHeight = du(strArray[ci++])
const frameWidth = du(strArray[ci++]) const frameWidth = du(strArray[ci++])
// content // content
@ -239,7 +249,7 @@ module.exports = class ScreenParser {
let attrs = 0 let attrs = 0
let cell = 0 // cell index let cell = 0 // cell index
let lastChar = ' ' let lastChar = ' '
let screenLength = this.screen.window.width * this.screen.window.height let screenLength = frameWidth * frameHeight
if (resized) { if (resized) {
this.screen.updateSize() this.screen.updateSize()
@ -258,11 +268,13 @@ module.exports = class ScreenParser {
let myAttrs = attrs let myAttrs = attrs
let hasFG = attrs & ATTR_FG let hasFG = attrs & ATTR_FG
let hasBG = attrs & ATTR_BG let hasBG = attrs & ATTR_BG
let cellFG = fg
let cellBG = bg
// use 0,0 if no fg/bg. this is to match back-end implementation // use 0,0 if no fg/bg. this is to match back-end implementation
// and allow leaving out fg/bg setting for cells with none // and allow leaving out fg/bg setting for cells with none
if (!hasFG) fg = 0 if (!hasFG) cellFG = 0
if (!hasBG) bg = 0 if (!hasBG) cellBG = 0
if ((myAttrs & MASK_BLINK) !== 0 && if ((myAttrs & MASK_BLINK) !== 0 &&
((lastChar === ' ' && ((myAttrs & MASK_LINE_ATTR) === 0)) || // no line styles ((lastChar === ' ' && ((myAttrs & MASK_LINE_ATTR) === 0)) || // no line styles
@ -281,16 +293,14 @@ module.exports = class ScreenParser {
let cellYInFrame = Math.floor(cell / frameWidth) let cellYInFrame = Math.floor(cell / frameWidth)
let index = (frameY + cellYInFrame) * this.screen.window.width + frameX + cellXInFrame let index = (frameY + cellYInFrame) * this.screen.window.width + frameX + cellXInFrame
let cellFg = fg
// 8 dark system colors turn bright when bold // 8 dark system colors turn bright when bold
if ((myAttrs & ATTR_BOLD) && !(myAttrs & ATTR_FAINT) && hasFG && fg < 8) { if ((myAttrs & ATTR_BOLD) && !(myAttrs & ATTR_FAINT) && hasFG && cellFG < 8) {
cellFg += 8 cellFG += 8
} }
this.screen.screen[index] = lastChar this.screen.screen[index] = lastChar
this.screen.screenFG[index] = cellFg this.screen.screenFG[index] = cellFG
this.screen.screenBG[index] = bg this.screen.screenBG[index] = cellBG
this.screen.screenAttrs[index] = myAttrs this.screen.screenAttrs[index] = myAttrs
} }

Loading…
Cancel
Save