very basic code editing!
This commit is contained in:
8
repl.ts
8
repl.ts
@ -3,6 +3,7 @@ import { getKeysPressed, shiftKeyDown, shiftMap, K } from "./keyboard.ts";
|
||||
import { font } from "./font.ts";
|
||||
import { addToContext, evalCode } from "./runcode.ts";
|
||||
import { clearScreen, fillRect } from "./window.ts";
|
||||
import { COLOR } from "./colors.ts";
|
||||
|
||||
const lineHeight = 6;
|
||||
|
||||
@ -41,6 +42,7 @@ addToContext("print", print);
|
||||
addToContext("printVal", printVal);
|
||||
|
||||
const update = () => {
|
||||
// TODO: model this after the newer editmode.ts version using getKeyboardString
|
||||
for (const key of getKeysPressed()) {
|
||||
let char = String.fromCharCode(key).toLowerCase();
|
||||
if (shiftKeyDown()) {
|
||||
@ -108,7 +110,7 @@ const update = () => {
|
||||
|
||||
const drawTextAbove = () => {
|
||||
textLinesAbove.forEach((line, i) => {
|
||||
fillRect(0, 1+i*lineHeight, 4*(line.length+1)+1, lineHeight+1, 0);
|
||||
fillRect(0, 1+i*lineHeight, 4*(line.length+1)+1, lineHeight+1, COLOR.BLACK);
|
||||
drawText(-1, 1+i*lineHeight, line);
|
||||
});
|
||||
}
|
||||
@ -118,8 +120,8 @@ const draw = () => {
|
||||
|
||||
drawTextAbove();
|
||||
|
||||
fillRect(0, 1+textLinesAbove.length*lineHeight, 4*(2+maxLineLen+1)+1, lineHeight+1, 0);
|
||||
fillRect((2+index)*4, textLinesAbove.length*lineHeight+1, 4, lineHeight-1, 3);
|
||||
fillRect(0, 1+textLinesAbove.length*lineHeight, 4*(2+maxLineLen+1)+1, lineHeight+1, COLOR.BLACK);
|
||||
fillRect((2+index)*4, textLinesAbove.length*lineHeight+1, 4, lineHeight-1, COLOR.RED);
|
||||
drawText(-1, 1+textLinesAbove.length*lineHeight, "> "+currentLine);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user