30 lines
593 B
TypeScript
30 lines
593 B
TypeScript
import faux from "./builtins.ts";
|
|
import { getKeysPressed, shiftKeyDown, shiftMap } from "./keyboard.ts";
|
|
import { font } from "./font.ts";
|
|
|
|
let line = "";
|
|
|
|
const update = () => {
|
|
for (const key of getKeysPressed()) {
|
|
let char = String.fromCharCode(key).toLowerCase();
|
|
if (shiftKeyDown()) {
|
|
if (char in shiftMap) {
|
|
char = shiftMap[char as keyof typeof shiftMap];
|
|
} else {
|
|
char = char.toUpperCase();
|
|
}
|
|
}
|
|
if (char in font) {
|
|
line += char;
|
|
}
|
|
}
|
|
}
|
|
|
|
const draw = () => {
|
|
faux.clear_screen();
|
|
faux.draw_text(0, 0, "> "+line);
|
|
}
|
|
|
|
export const repl = {
|
|
update, draw
|
|
} |