Fix wrong screen coords; show flags in binary

box-drawing
cpsdqs 7 years ago
parent 1d4c41ff5a
commit 57cdd04523
Signed by untrusted user: cpsdqs
GPG Key ID: 3F59586BB7448DD1
  1. 20
      js/term/debug_screen.js
  2. 9
      js/term/screen.js

@ -19,15 +19,15 @@ module.exports = function attachDebugScreen (screen) {
let addCanvas = function () { let addCanvas = function () {
if (!debugCanvas.parentNode) { if (!debugCanvas.parentNode) {
screen.canvas.parentNode.appendChild(debugCanvas) screen.canvas.parentNode.appendChild(debugCanvas)
screen.canvas.parentNode.addEventListener('mousemove', onMouseMove) screen.canvas.addEventListener('mousemove', onMouseMove)
screen.canvas.parentNode.addEventListener('mouseout', onMouseOut) screen.canvas.addEventListener('mouseout', onMouseOut)
} }
} }
let removeCanvas = function () { let removeCanvas = function () {
if (debugCanvas.parentNode) { if (debugCanvas.parentNode) {
debugCanvas.parentNode.removeChild(debugCanvas) debugCanvas.parentNode.removeChild(debugCanvas)
screen.canvas.parentNode.removeEventListener('mousemove', onMouseMove) screen.canvas.removeEventListener('mousemove', onMouseMove)
screen.canvas.parentNode.removeEventListener('mouseout', onMouseOut) screen.canvas.removeEventListener('mouseout', onMouseOut)
onMouseOut() onMouseOut()
} }
} }
@ -261,10 +261,10 @@ module.exports = function attachDebugScreen (screen) {
const formatColor = color => color < 256 ? color : `#${`000000${(color - 256).toString(16)}`.substr(-6)}` const formatColor = color => color < 256 ? color : `#${`000000${(color - 256).toString(16)}`.substr(-6)}`
const getCellData = cell => { const getCellData = cell => {
if (cell < 0 || cell > screen.screen.length) return '(-)' if (cell < 0 || cell > screen.screen.length) return '(-)'
let cellAttrs = screen.renderer.drawnScreenAttrs[cell] let cellAttrs = screen.renderer.drawnScreenAttrs[cell] | 0
let cellFG = formatColor(screen.renderer.drawnScreenFG[cell]) let cellFG = formatColor(screen.renderer.drawnScreenFG[cell]) | 0
let cellBG = formatColor(screen.renderer.drawnScreenBG[cell]) let cellBG = formatColor(screen.renderer.drawnScreenBG[cell]) | 0
let cellCode = (screen.renderer.drawnScreen[cell] || '').codePointAt(0) let cellCode = (screen.renderer.drawnScreen[cell] || '').codePointAt(0) | 0
let hexcode = cellCode.toString(16).toUpperCase() let hexcode = cellCode.toString(16).toUpperCase()
if (hexcode.length < 4) hexcode = `0000${hexcode}`.substr(-4) if (hexcode.length < 4) hexcode = `0000${hexcode}`.substr(-4)
hexcode = `U+${hexcode}` hexcode = `U+${hexcode}`
@ -284,8 +284,8 @@ module.exports = function attachDebugScreen (screen) {
if ('flags' in internalInfo) { if ('flags' in internalInfo) {
// we got ourselves some internal data // we got ourselves some internal data
text += ' ' text += ' '
text += ` flags:${internalInfo.flags}` text += ` flags:${internalInfo.flags.toString(2)}`
text += ` curAttrs:${internalInfo.cursorAttrs}` text += ` curAttrs:${internalInfo.cursorAttrs.toString(2)}`
text += ` Region:${internalInfo.regionStart}->${internalInfo.regionEnd}` text += ` Region:${internalInfo.regionStart}->${internalInfo.regionEnd}`
text += ` Charset:${internalInfo.charsetGx} (0:${internalInfo.charsetG0},1:${internalInfo.charsetG1})` text += ` Charset:${internalInfo.charsetGx} (0:${internalInfo.charsetG0},1:${internalInfo.charsetG1})`
text += ` Heap:${internalInfo.freeHeap}` text += ` Heap:${internalInfo.freeHeap}`

@ -321,11 +321,12 @@ module.exports = class TermScreen extends EventEmitter {
x = x / this._windowScale - this._padding x = x / this._windowScale - this._padding
y = y / this._windowScale - this._padding y = y / this._windowScale - this._padding
x = Math.floor((x + (rounded ? cellSize.width / 2 : 0)) / cellSize.width)
y = Math.floor(y / cellSize.height)
x = Math.max(0, Math.min(this.window.width - 1, x))
y = Math.max(0, Math.min(this.window.height - 1, y))
return [ return [x, y]
Math.floor((x + (rounded ? cellSize.width / 2 : 0)) / cellSize.width),
Math.floor(y / cellSize.height)
]
} }
/** /**

Loading…
Cancel
Save