mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-06 13:38:30 +09:00
various mouse nav fixes, font rom update
This commit is contained in:
@@ -3703,13 +3703,12 @@ function openRetunePopup() {
|
||||
if (sel < 0) sel = 0
|
||||
let scroll = centerScroll(sel, 0, listH, n)
|
||||
|
||||
// OK/Cancel button placement (bottom inside row)
|
||||
const btnRow = py + ph - 2
|
||||
const labelOK = `[ OK ]`.length
|
||||
const labelCan = `[ Cancel ]`.length
|
||||
const totalW = labelOK + 2 + labelCan
|
||||
const btnXOk = px + ((pw - totalW) >>> 1)
|
||||
const btnXCan = btnXOk + labelOK + 2
|
||||
let done = false
|
||||
let confirmed = false
|
||||
const buttons = makePopupButtonRow(py + ph - 2, px, pw, [
|
||||
{ label: 'OK', action: () => { confirmed = true; done = true }, default: true },
|
||||
{ label: 'Cancel', action: () => { done = true } },
|
||||
])
|
||||
|
||||
const repaint = () => {
|
||||
con.color_pair(230, colPopupBack)
|
||||
@@ -4089,8 +4088,18 @@ const MOUSE_POPUP_STACK = []
|
||||
|
||||
// Wrap push/pop so closing a popup also drops any onHoverLeave that would otherwise
|
||||
// be invoked against the popup's stale regions on the next mouse move.
|
||||
//
|
||||
// When the pop happens with a mouse button still held, the popup was almost certainly
|
||||
// closed by a click. We arm `swallowResidualClick` so the trailing mouse_up (and any
|
||||
// echo mouse_down from that same physical click) doesn't leak into the panel that the
|
||||
// popup was covering. A keyboard close leaves no button held, so this is a no-op.
|
||||
let swallowResidualClick = false
|
||||
function pushMousePopup(regions) { MOUSE_POPUP_STACK.push(regions); lastHoveredRegion = null }
|
||||
function popMousePopup() { MOUSE_POPUP_STACK.pop(); lastHoveredRegion = null }
|
||||
function popMousePopup() {
|
||||
MOUSE_POPUP_STACK.pop()
|
||||
lastHoveredRegion = null
|
||||
if ((sys.peek(-37) & 0x07) !== 0) swallowResidualClick = true
|
||||
}
|
||||
|
||||
function pixelToCell(px, py) {
|
||||
return [(py / CELL_PH | 0) + 1, (px / CELL_PW | 0) + 1] // [cy, cx], 1-indexed
|
||||
@@ -4108,6 +4117,16 @@ function dispatchMouseEvent(event) {
|
||||
const t = event[0]
|
||||
if (t !== 'mouse_down' && t !== 'mouse_wheel' && t !== 'mouse_up' && t !== 'mouse_move') return false
|
||||
|
||||
// Eat residual events from the click that just closed a popup. The flag is armed
|
||||
// by popMousePopup when a button was still held at pop time; it clears on the
|
||||
// matching mouse_up so the next fresh press goes through normally.
|
||||
if (swallowResidualClick && MOUSE_POPUP_STACK.length === 0) {
|
||||
if (t === 'mouse_up') { swallowResidualClick = false; return true }
|
||||
if (t === 'mouse_down') { return true }
|
||||
if (t === 'mouse_move') { return true }
|
||||
// mouse_wheel passes through — it's its own gesture, not part of the closing click
|
||||
}
|
||||
|
||||
const [cy, cx] = pixelToCell(event[1], event[2])
|
||||
const pool = (MOUSE_POPUP_STACK.length > 0)
|
||||
? MOUSE_POPUP_STACK[MOUSE_POPUP_STACK.length - 1]
|
||||
|
||||
@@ -737,6 +737,7 @@ function actActivate() {
|
||||
firstRunLatch = true
|
||||
con.curs_set(0); clearScr()
|
||||
refreshFilePanelCache(windowMode)
|
||||
pendingPostExecDrain = true
|
||||
redraw()
|
||||
}
|
||||
}
|
||||
@@ -927,6 +928,7 @@ function actMore() {
|
||||
firstRunLatch = true
|
||||
con.curs_set(0); clearScr()
|
||||
refreshFilePanelCache(windowMode)
|
||||
pendingPostExecDrain = true
|
||||
redraw()
|
||||
}
|
||||
}
|
||||
@@ -985,11 +987,17 @@ function setupPanelMouseRegions() {
|
||||
}
|
||||
},
|
||||
onClick: (cy, cx, btn) => {
|
||||
if (btn !== 1) return
|
||||
const target = scroll[windowMode] + rowIdx
|
||||
if (target >= dirFileList[windowMode].length) return
|
||||
cursor[windowMode] = target
|
||||
actActivate()
|
||||
if (btn === 1) {
|
||||
cursor[windowMode] = target
|
||||
actActivate()
|
||||
}
|
||||
else if (btn === 2) {
|
||||
cursor[windowMode] = target
|
||||
drawFilePanel()
|
||||
actMore()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -1026,11 +1034,19 @@ _redraw()
|
||||
// like fsh.js can hand off with the mouse button still held; without this,
|
||||
// input.withEvent's first call edge-detects that as a fresh mouse_down at the
|
||||
// cursor and activates whichever file row happens to sit there.
|
||||
input.withEvent(() => {})
|
||||
//
|
||||
// The same problem reappears after every child app returns, but draining
|
||||
// inside the dispatcher callback is undone by TVDOS.SYS:1235 (input.withEvent
|
||||
// unconditionally writes inputwork.oldMouse = its-stale-local-snapshot at the
|
||||
// end of the outer call). So actActivate / actMore set pendingPostExecDrain
|
||||
// and the main loop calls drainInheritedInput() AFTER input.withEvent returns.
|
||||
function drainInheritedInput() { input.withEvent(() => {}) }
|
||||
drainInheritedInput()
|
||||
|
||||
let redrawRequested = false
|
||||
let exit = false
|
||||
let firstRunLatch = true
|
||||
let pendingPostExecDrain = false
|
||||
|
||||
while (!exit) {
|
||||
input.withEvent(event => {
|
||||
@@ -1066,6 +1082,16 @@ while (!exit) {
|
||||
_redraw()
|
||||
}
|
||||
})
|
||||
|
||||
// Re-baseline mouse state AFTER input.withEvent returns so its trailing
|
||||
// `inputwork.oldMouse = mouse` (TVDOS.SYS:1235) doesn't overwrite the
|
||||
// freshly-correct state with the stale snapshot taken at the start of the
|
||||
// outer call. Without this, a child app exited by a click leaves zfm with
|
||||
// oldBtns=0 while the user is still holding → spurious mouse_down next poll.
|
||||
if (pendingPostExecDrain) {
|
||||
pendingPostExecDrain = false
|
||||
drainInheritedInput()
|
||||
}
|
||||
}
|
||||
|
||||
con.curs_set(1)
|
||||
|
||||
@@ -385,6 +385,10 @@ const ag_workMid = new Float32Array(AG_WORK_N)
|
||||
const ag_workTmp = new Float32Array(AG_WORK_N >> 1)
|
||||
const ag_bandEnergy = new Float32Array(AG_N_BANDS)
|
||||
|
||||
// Sub-500 Hz residual — drops out of the wavelet modulator set on purpose,
|
||||
// but we keep its RMS around to drive the bass mark.
|
||||
let ag_bassEnergy = 0
|
||||
|
||||
// Persistence buffer — float intensity per cell, plus the glyph last written
|
||||
// there. Decay shrinks intensity each frame; new beam samples overwrite the
|
||||
// glyph and bump intensity.
|
||||
@@ -397,6 +401,7 @@ const ag_cellFg = new Int16Array(AG_VIS_H * AG_VIS_W).fill(-1)
|
||||
const ag_waveGlyph = new Int16Array(AG_LANE_W * 3).fill(-1)
|
||||
const ag_stereoGlyph = new Int16Array(AG_LANE_W).fill(-1)
|
||||
const ag_stereoFg = new Int16Array(AG_LANE_W).fill(-1)
|
||||
let ag_lastBassFg = -1
|
||||
|
||||
// Render rate-limiter — playmp2 spins ~32 Hz, playtad ~1 Hz, playwav ~100 Hz
|
||||
// at decode time. Clamp visual refresh to 20 Hz so each caller can spam
|
||||
@@ -579,6 +584,16 @@ function ag_analyseHaar() {
|
||||
ag_bandEnergy[lv] = rms > 1 ? 1 : rms
|
||||
len = half
|
||||
}
|
||||
// Residual approximation in ag_workMid[0..len-1] holds the sub-500 Hz
|
||||
// energy that the modulator pipeline intentionally discards. Reuse it
|
||||
// to drive the bass mark.
|
||||
let bassSumSq = 0
|
||||
for (let i = 0; i < len; i++) {
|
||||
const v = ag_workMid[i]
|
||||
bassSumSq += v * v
|
||||
}
|
||||
const bassRms = Math.sqrt(bassSumSq / len) * 1.8
|
||||
ag_bassEnergy = bassRms > 1 ? 1 : bassRms
|
||||
}
|
||||
|
||||
// ── Wavescope (rows 3..5) ──────────────────────────────────────────────────
|
||||
@@ -652,6 +667,16 @@ const AG_XY_CY = AG_VIS_H >> 1 // centre row
|
||||
const AG_XY_SX = 18 // (L−R) → horizontal extent ±36 cells
|
||||
const AG_XY_SY = 9 // (L+R) → vertical extent ±18 cells
|
||||
|
||||
// Bass mark: 2×2 cell indicator pinned to the centre of the vectorscope so
|
||||
// the bass "subwoofer" sits underneath the beam's pivot point. Half-blocks
|
||||
// form a compact 16×16-pixel "dot" centred in the 16×32-pixel 2×2 area.
|
||||
const AG_BASS_VIS_R0 = AG_XY_CY - 1
|
||||
const AG_BASS_VIS_C0 = AG_XY_CX - 1
|
||||
const AG_BASS_VIS_R1 = AG_BASS_VIS_R0 + 1
|
||||
const AG_BASS_VIS_C1 = AG_BASS_VIS_C0 + 1
|
||||
const AG_BASS_SCR_R = AG_ROW_VIS_TOP + AG_BASS_VIS_R0
|
||||
const AG_BASS_SCR_C = AG_COL_INSIDE_L + AG_BASS_VIS_C0
|
||||
|
||||
// Glyphs.
|
||||
const AG_G_DOT = 0xFA // ·
|
||||
const AG_G_BSL = 0x5C // \\
|
||||
@@ -741,7 +766,10 @@ function ag_drawVisualiser() {
|
||||
for (let r = 0; r < AG_VIS_H; r++) {
|
||||
const rowOff = r * AG_VIS_W
|
||||
const screenY = AG_ROW_VIS_TOP + r
|
||||
const inBassRow = (r === AG_BASS_VIS_R0 || r === AG_BASS_VIS_R1)
|
||||
for (let c = 0; c < AG_VIS_W; c++) {
|
||||
// Bass mark owns its 2×2 cells — let ag_drawBassMark() paint them.
|
||||
if (inBassRow && (c === AG_BASS_VIS_C0 || c === AG_BASS_VIS_C1)) continue
|
||||
const idx = rowOff + c
|
||||
const e = ag_persist[idx]
|
||||
let levelIdx = (e * 5) | 0
|
||||
@@ -758,6 +786,25 @@ function ag_drawVisualiser() {
|
||||
}
|
||||
}
|
||||
|
||||
// ── Bass mark (rows 29-30, cols 2-3) ───────────────────────────────────────
|
||||
// Brightness-only indicator driven by the sub-500 Hz residual of the Haar
|
||||
// pyramid. Uses indices 1..4 of the beam palette so the dot never falls all
|
||||
// the way to background — a quiet track still shows a faint amber ember.
|
||||
|
||||
function ag_drawBassMark() {
|
||||
let idx = (ag_bassEnergy * 4) | 0
|
||||
if (idx > 3) idx = 3
|
||||
if (idx < 0) idx = 0
|
||||
const fg = AG_BEAM_PAL[idx + 1]
|
||||
if (fg === ag_lastBassFg) return
|
||||
ag_lastBassFg = fg
|
||||
ag_color(fg, AG_COL_BG)
|
||||
ag_mvprn(AG_BASS_SCR_R, AG_BASS_SCR_C, 0xDC)
|
||||
ag_mvprn(AG_BASS_SCR_R, AG_BASS_SCR_C + 1, 0xDC)
|
||||
ag_mvprn(AG_BASS_SCR_R + 1, AG_BASS_SCR_C, 0xDF)
|
||||
ag_mvprn(AG_BASS_SCR_R + 1, AG_BASS_SCR_C + 1, 0xDF)
|
||||
}
|
||||
|
||||
// ── Stereo energy bar (row 31) ─────────────────────────────────────────────
|
||||
//
|
||||
// Same idea as playtaud.drawStereo() but driven by raw PCM: for each sample,
|
||||
@@ -840,6 +887,8 @@ function audioInit(params) {
|
||||
ag_cellGlyph.fill(-1); ag_cellFg.fill(-1)
|
||||
ag_waveGlyph.fill(-1)
|
||||
ag_stereoGlyph.fill(-1); ag_stereoFg.fill(-1)
|
||||
ag_bassEnergy = 0
|
||||
ag_lastBassFg = -1
|
||||
|
||||
con.curs_set(0)
|
||||
con.clear()
|
||||
@@ -861,6 +910,7 @@ function audioRender() {
|
||||
ag_updateXYScope()
|
||||
ag_drawWavescope()
|
||||
ag_drawVisualiser()
|
||||
ag_drawBassMark()
|
||||
ag_drawStereo()
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ function showDialog(opts) {
|
||||
|
||||
const c = opts.colours || {}
|
||||
const fg = (c.fg != null) ? c.fg : 254
|
||||
const bg = (c.bg != null) ? c.bg : 242
|
||||
const bg = (c.bg != null) ? c.bg : 243
|
||||
const fieldBg = (c.fieldBg != null) ? c.fieldBg : 240
|
||||
const dimFg = (c.dimFg != null) ? c.dimFg : 249
|
||||
const hlFg = (c.hlFg != null) ? c.hlFg : 230
|
||||
@@ -323,25 +323,26 @@ function showDialog(opts) {
|
||||
print(f.label + ':')
|
||||
|
||||
// Top border
|
||||
con.color_pair(frameFg, bg)
|
||||
con.color_pair(fieldBg, bg)
|
||||
con.move(fbRow, fbCol)
|
||||
print('\u00DA' + '\u00C4'.repeat(fw) + '\u00BF')
|
||||
print('\u00EC' + '\u00A9'.repeat(fw) + '\u00ED')
|
||||
|
||||
// Side borders + content
|
||||
con.color_pair(frameFg, bg)
|
||||
con.move(fbRow + 1, fbCol)
|
||||
print('\u00B3')
|
||||
print('\u00AB')
|
||||
|
||||
con.color_pair(fg, fieldBg)
|
||||
const s = fieldScroll(cursors[i], fw)
|
||||
const vis = values[i].substring(s, s + fw)
|
||||
print(vis.padEnd(fw, ' '))
|
||||
con.color_pair(frameFg, bg)
|
||||
|
||||
con.color_pair(fieldBg, bg)
|
||||
con.move(fbRow + 1, fbCol + fw + 1)
|
||||
print('\u00B3')
|
||||
print('\u00AA')
|
||||
|
||||
// Bottom border
|
||||
con.move(fbRow + 2, fbCol)
|
||||
print('\u00C0' + '\u00C4'.repeat(fw) + '\u00D9')
|
||||
print('\u00F4' + '\u00AC'.repeat(fw) + '\u00F5')
|
||||
con.color_pair(fg, bg)
|
||||
}
|
||||
|
||||
@@ -484,7 +485,7 @@ function showDialog(opts) {
|
||||
render()
|
||||
return
|
||||
}
|
||||
if (ks === '') {
|
||||
if (ks === '\x08') {
|
||||
const cur = cursors[focusIdx]
|
||||
if (cur > 0) {
|
||||
const v = values[focusIdx]
|
||||
@@ -494,7 +495,7 @@ function showDialog(opts) {
|
||||
}
|
||||
return
|
||||
}
|
||||
if (ks === '<FORWARD_DEL>' || ks === '<DEL>') {
|
||||
if (ks === '<DEL>') {
|
||||
const cur = cursors[focusIdx]
|
||||
const v = values[focusIdx]
|
||||
if (cur < v.length) {
|
||||
|
||||
Reference in New Issue
Block a user