Add a bunch of TODOs

This commit is contained in:
dylan 2023-05-05 12:28:43 -07:00
parent b58a0d8cb1
commit b87529bf56
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ import { K, getKeyboardString, keyPressed, shiftKeyDown } from "./keyboard.ts";
// deno-lint-ignore prefer-const
let tab: "code" | "sprite" | "map" | "sfx" | "music" = "code";
// TODO: Make scrolling work
const codeTabState = {
scrollX: 0,
scrollY: 0,
@ -139,6 +140,7 @@ const drawCodeField = (code: string, x: number, y: number, w: number, h: number)
if (anchor === focus) {
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.RED);
} else {
// TODO: Draw this selection better
fillRect(x+anchorX*fontWidth-scrollX, y+anchorY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.GREEN);
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.YELLOW);
}
@ -154,7 +156,11 @@ const update = () => {
if (keyboardString) {
codeTabState.insertText(keyboardString);
}
// TODO: Handle ctrl-C, ctrl-V, ctrl-X, ctrl-Z
// TODO: Make ctrl-/ do commenting out (take inspiration from tab)
if (keyPressed(K.ENTER)) {
// TODO: Make this play nicely with indentation
codeTabState.insertText("\n");
}
if (keyPressed(K.TAB)) {

View File

@ -115,6 +115,10 @@ export const shiftKeyDown = () => {
return keyDown(K.SHIFT_LEFT) || keyDown(K.SHIFT_RIGHT);
}
export const ctrlKeyDown = () => {
return keyDown(K.CTRL_LEFT) || keyDown(K.CTRL_RIGHT);
}
export const keyReleased = (key: string | number) => {
if (typeof key === "string") {
key = key.toUpperCase().charCodeAt(0);
@ -131,6 +135,9 @@ export const getKeysPressed = () => {
export const getKeyboardString = () => {
let str = "";
if (ctrlKeyDown()) {
return str;
}
for (const key of getKeysPressed()) {
let char = String.fromCharCode(key).toLowerCase();
if (shiftKeyDown()) {