Add a bunch of TODOs
This commit is contained in:
parent
b58a0d8cb1
commit
b87529bf56
@ -8,6 +8,7 @@ import { K, getKeyboardString, keyPressed, shiftKeyDown } from "./keyboard.ts";
|
|||||||
// deno-lint-ignore prefer-const
|
// deno-lint-ignore prefer-const
|
||||||
let tab: "code" | "sprite" | "map" | "sfx" | "music" = "code";
|
let tab: "code" | "sprite" | "map" | "sfx" | "music" = "code";
|
||||||
|
|
||||||
|
// TODO: Make scrolling work
|
||||||
const codeTabState = {
|
const codeTabState = {
|
||||||
scrollX: 0,
|
scrollX: 0,
|
||||||
scrollY: 0,
|
scrollY: 0,
|
||||||
@ -139,6 +140,7 @@ const drawCodeField = (code: string, x: number, y: number, w: number, h: number)
|
|||||||
if (anchor === focus) {
|
if (anchor === focus) {
|
||||||
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.RED);
|
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.RED);
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: Draw this selection better
|
||||||
fillRect(x+anchorX*fontWidth-scrollX, y+anchorY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.GREEN);
|
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);
|
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.YELLOW);
|
||||||
}
|
}
|
||||||
@ -154,7 +156,11 @@ const update = () => {
|
|||||||
if (keyboardString) {
|
if (keyboardString) {
|
||||||
codeTabState.insertText(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)) {
|
if (keyPressed(K.ENTER)) {
|
||||||
|
// TODO: Make this play nicely with indentation
|
||||||
codeTabState.insertText("\n");
|
codeTabState.insertText("\n");
|
||||||
}
|
}
|
||||||
if (keyPressed(K.TAB)) {
|
if (keyPressed(K.TAB)) {
|
||||||
|
@ -115,6 +115,10 @@ export const shiftKeyDown = () => {
|
|||||||
return keyDown(K.SHIFT_LEFT) || keyDown(K.SHIFT_RIGHT);
|
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) => {
|
export const keyReleased = (key: string | number) => {
|
||||||
if (typeof key === "string") {
|
if (typeof key === "string") {
|
||||||
key = key.toUpperCase().charCodeAt(0);
|
key = key.toUpperCase().charCodeAt(0);
|
||||||
@ -131,6 +135,9 @@ export const getKeysPressed = () => {
|
|||||||
|
|
||||||
export const getKeyboardString = () => {
|
export const getKeyboardString = () => {
|
||||||
let str = "";
|
let str = "";
|
||||||
|
if (ctrlKeyDown()) {
|
||||||
|
return str;
|
||||||
|
}
|
||||||
for (const key of getKeysPressed()) {
|
for (const key of getKeysPressed()) {
|
||||||
let char = String.fromCharCode(key).toLowerCase();
|
let char = String.fromCharCode(key).toLowerCase();
|
||||||
if (shiftKeyDown()) {
|
if (shiftKeyDown()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user