Move away from browser as a main plataform

This commit is contained in:
2026-11-22 21:38:12 -03:00
parent cbd662dc2a
commit 90dd86b336
12 changed files with 166 additions and 150 deletions
+20 -1
View File
@@ -347,7 +347,7 @@ export class EditBox {
}
}
const LIST_ROW_HEIGHT = 40;
export const LIST_ROW_HEIGHT = 40;
const CHECK_SIZE = 20;
// rows of text that scroll with the mouse wheel, like minecraft's selection lists. a row can have a box ticked or not
@@ -421,3 +421,22 @@ export class ListBox {
}
}
}
// text split into lines no wider than width pixels at TEXT_SCALE, at spaces and at its own line breaks
export function wrap_text(text: string, width: number): string[] {
const lines: string[] = [];
for (const line of text.split("\n")) {
let current = "";
for (const word of line.split(" ")) {
const next = current ? `${current} ${word}` : word;
if (current && measure_text(next, TEXT_SCALE) > width) {
lines.push(current);
current = word;
} else {
current = next;
}
}
lines.push(current);
}
return lines;
}