Allow variable width in font
This commit is contained in:
6
repl.ts
6
repl.ts
@@ -52,7 +52,7 @@ const update = () => {
|
||||
char = char.toUpperCase();
|
||||
}
|
||||
}
|
||||
if (char in font) {
|
||||
if (char in font.chars) {
|
||||
currentLine = currentLine.slice(0, index)+char+currentLine.slice(index);
|
||||
index += 1;
|
||||
} else if (key === K.BACKSPACE) {
|
||||
@@ -111,7 +111,7 @@ const update = () => {
|
||||
const drawTextAbove = () => {
|
||||
textLinesAbove.forEach((line, i) => {
|
||||
fillRect(0, 1+i*lineHeight, 4*(line.length+1)+1, lineHeight+1, COLOR.BLACK);
|
||||
drawText(-1, 1+i*lineHeight, line);
|
||||
drawText(0, 1+i*lineHeight, line);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ const draw = () => {
|
||||
|
||||
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);
|
||||
drawText(0, 1+textLinesAbove.length*lineHeight, "> "+currentLine);
|
||||
}
|
||||
|
||||
export const repl = {
|
||||
|
||||
Reference in New Issue
Block a user