Use alphabetic characters, so button symbols can be used as identifiers
This commit is contained in:
parent
2ac5f3dff7
commit
1211891f53
14
codetab.ts
14
codetab.ts
@ -1,5 +1,5 @@
|
|||||||
import { clearScreen, fillRect } from "./window.ts";
|
import { clearScreen, fillRect } from "./window.ts";
|
||||||
import { font } from "./font.ts";
|
import { CHAR, font } from "./font.ts";
|
||||||
import { drawText, measureText } from "./builtins.ts";
|
import { drawText, measureText } from "./builtins.ts";
|
||||||
import { COLOR } from "./colors.ts";
|
import { COLOR } from "./colors.ts";
|
||||||
import { getCodeSheet, setSheet } from "./sheet.ts";
|
import { getCodeSheet, setSheet } from "./sheet.ts";
|
||||||
@ -159,15 +159,19 @@ const tokenColors = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const transformForCopy = (text: string) => {
|
const transformForCopy = (text: string) => {
|
||||||
text = text.replaceAll("➡", "➡️");
|
text = text.replaceAll(CHAR.UP, "⬆️");
|
||||||
text = text.replaceAll("⬅", "⬅️");
|
text = text.replaceAll(CHAR.LEFT, "⬅️");
|
||||||
text = text.replaceAll("⬇", "⬇️");
|
text = text.replaceAll(CHAR.DOWN, "⬇️");
|
||||||
text = text.replaceAll("⬆", "⬆️");
|
text = text.replaceAll(CHAR.RIGHT, "➡️");
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
const transformForPaste = (text: string) => {
|
const transformForPaste = (text: string) => {
|
||||||
let newstr = "";
|
let newstr = "";
|
||||||
|
text = text.replaceAll("⬆️", CHAR.UP);
|
||||||
|
text = text.replaceAll("⬅️", CHAR.LEFT);
|
||||||
|
text = text.replaceAll("⬇️", CHAR.DOWN);
|
||||||
|
text = text.replaceAll("➡️", CHAR.RIGHT);
|
||||||
for (const char of text) {
|
for (const char of text) {
|
||||||
if (char in font.chars) {
|
if (char in font.chars) {
|
||||||
newstr += char;
|
newstr += char;
|
||||||
|
35
font.ts
35
font.ts
@ -17,6 +17,13 @@
|
|||||||
// export const fontWidth = 4;
|
// export const fontWidth = 4;
|
||||||
// export const fontHeight = 6;
|
// export const fontHeight = 6;
|
||||||
|
|
||||||
|
export const CHAR = {
|
||||||
|
UP: "À",
|
||||||
|
LEFT: "Á",
|
||||||
|
DOWN: "Â",
|
||||||
|
RIGHT: "Ã",
|
||||||
|
}
|
||||||
|
|
||||||
export type Font = {
|
export type Font = {
|
||||||
height: 6,
|
height: 6,
|
||||||
chars: {[key: string]: Array<number>},
|
chars: {[key: string]: Array<number>},
|
||||||
@ -467,12 +474,12 @@ export const font: Font = {
|
|||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
],
|
],
|
||||||
"\t": [
|
"\t": [
|
||||||
0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
],
|
],
|
||||||
"\n": [
|
"\n": [
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
@ -802,15 +809,15 @@ export const font: Font = {
|
|||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
0, 0, 0,
|
0, 0, 0,
|
||||||
],
|
],
|
||||||
"➡": [
|
[CHAR.UP]: [
|
||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
1, 1, 0, 0, 1, 1, 1,
|
1, 1, 1, 0, 1, 1, 1,
|
||||||
|
1, 1, 0, 0, 0, 1, 1,
|
||||||
1, 1, 0, 0, 0, 1, 1,
|
1, 1, 0, 0, 0, 1, 1,
|
||||||
1, 1, 0, 0, 1, 1, 1,
|
|
||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
],
|
],
|
||||||
"⬅": [
|
[CHAR.LEFT]: [
|
||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
1, 1, 1, 0, 0, 1, 1,
|
1, 1, 1, 0, 0, 1, 1,
|
||||||
1, 1, 0, 0, 0, 1, 1,
|
1, 1, 0, 0, 0, 1, 1,
|
||||||
@ -818,7 +825,7 @@ export const font: Font = {
|
|||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
],
|
],
|
||||||
"⬇": [
|
[CHAR.DOWN]: [
|
||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
1, 1, 0, 0, 0, 1, 1,
|
1, 1, 0, 0, 0, 1, 1,
|
||||||
1, 1, 0, 0, 0, 1, 1,
|
1, 1, 0, 0, 0, 1, 1,
|
||||||
@ -826,11 +833,11 @@ export const font: Font = {
|
|||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
],
|
],
|
||||||
"⬆": [
|
[CHAR.RIGHT]: [
|
||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
1, 1, 1, 0, 1, 1, 1,
|
1, 1, 0, 0, 1, 1, 1,
|
||||||
1, 1, 0, 0, 0, 1, 1,
|
|
||||||
1, 1, 0, 0, 0, 1, 1,
|
1, 1, 0, 0, 0, 1, 1,
|
||||||
|
1, 1, 0, 0, 1, 1, 1,
|
||||||
0, 1, 1, 1, 1, 1, 0,
|
0, 1, 1, 1, 1, 1, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0,
|
||||||
],
|
],
|
||||||
|
10
keyboard.ts
10
keyboard.ts
@ -1,4 +1,4 @@
|
|||||||
import { font } from "./font.ts";
|
import { font, CHAR } from "./font.ts";
|
||||||
|
|
||||||
const keyboard = new Map<number, {first: boolean, repeat: boolean, held: boolean}>();
|
const keyboard = new Map<number, {first: boolean, repeat: boolean, held: boolean}>();
|
||||||
|
|
||||||
@ -63,10 +63,10 @@ export const shiftMap = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const altMap = {
|
export const altMap = {
|
||||||
"w": "⬆",
|
"w": CHAR.UP,
|
||||||
"a": "⬅",
|
"a": CHAR.LEFT,
|
||||||
"s": "⬇",
|
"s": CHAR.DOWN,
|
||||||
"d": "➡",
|
"d": CHAR.RIGHT,
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener("keydown", (evt) => {
|
addEventListener("keydown", (evt) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user