|
|
|
@ -26,7 +26,7 @@ import { |
|
|
|
} from "libmonoformat"; |
|
|
|
} from "libmonoformat"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const W = 120, H = 60; |
|
|
|
let W = 120, H = 60; |
|
|
|
|
|
|
|
|
|
|
|
// --- State -------------------------------------------------------------------
|
|
|
|
// --- State -------------------------------------------------------------------
|
|
|
|
let file: MonoDisplayFile = new MonoDisplayFile([]); |
|
|
|
let file: MonoDisplayFile = new MonoDisplayFile([]); |
|
|
|
@ -185,6 +185,14 @@ async function guardDirty(): Promise<boolean> { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function changeDisplayLayout() { |
|
|
|
|
|
|
|
const sel = document.querySelector('.pv-label select') as HTMLSelectElement; |
|
|
|
|
|
|
|
const [w, h] = sel.value.split('×').map(s => parseInt(s.trim())); |
|
|
|
|
|
|
|
W = w as number; |
|
|
|
|
|
|
|
H = h as number; |
|
|
|
|
|
|
|
((window as any)._mdDriver as MonoDisplayDriver).setSize(W, H); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// --- Helpers -----------------------------------------------------------------
|
|
|
|
// --- Helpers -----------------------------------------------------------------
|
|
|
|
function newSec(): MonoFormatElementsAlways { |
|
|
|
function newSec(): MonoFormatElementsAlways { |
|
|
|
return { |
|
|
|
return { |
|
|
|
@ -425,7 +433,8 @@ function triggerPreview() { |
|
|
|
function buildPreview() { |
|
|
|
function buildPreview() { |
|
|
|
if (!(window as any)._mdDriver) |
|
|
|
if (!(window as any)._mdDriver) |
|
|
|
(window as any)._mdDriver = new MonoDisplayDriver("canvas_root", { onColor: "#EC0", offColor: "#000", fps: 25 }); |
|
|
|
(window as any)._mdDriver = new MonoDisplayDriver("canvas_root", { onColor: "#EC0", offColor: "#000", fps: 25 }); |
|
|
|
(window as any)._mdDriver.load(() => Promise.resolve(file.toBuffer())); |
|
|
|
((window as any)._mdDriver as MonoDisplayDriver).load(() => Promise.resolve(file.toBuffer())); |
|
|
|
|
|
|
|
((window as any)._mdDriver as MonoDisplayDriver).setSize(W, H); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// --- Load / Export -----------------------------------------------------------
|
|
|
|
// --- Load / Export -----------------------------------------------------------
|
|
|
|
@ -933,7 +942,7 @@ async function clearAll() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Expose globals referenced by topbar inline handlers
|
|
|
|
// Expose globals referenced by topbar inline handlers
|
|
|
|
Object.assign(window, { loadBin, exportBin, addSection, clearAll, cycleTheme }); |
|
|
|
Object.assign(window, { loadBin, exportBin, addSection, clearAll, cycleTheme, changeDisplayLayout }); |
|
|
|
|
|
|
|
|
|
|
|
// window.addEventListener("beforeunload", (e) => {
|
|
|
|
// window.addEventListener("beforeunload", (e) => {
|
|
|
|
// if (isDirty) e.preventDefault();
|
|
|
|
// if (isDirty) e.preventDefault();
|
|
|
|
|