all repos — hex @ d2773f50bc14f0b32c287a6e496f151ae84f01f9

A tiny, minimalist, slightly-esoteric concatenative programming lannguage.

web/assets/hex-playground.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
let stdinBuffer = [];
const inputBox = document.querySelector("article input")
inputBox.addEventListener("keydown", (event) => {
    if (event.key === "Enter" && !event.shiftKey) {
        event.preventDefault();
        const input = inputBox.value;
        inputBox.value = ""; // Clear the textarea
        stdinBuffer.push(...input + "\n"); // Add input to the buffer
      }
});

Module.print = (text) => {
    document.querySelector("article section").textContent += text + "\n";
};
Module.printErr = (text) => {
    document.querySelector("article section").textContent += text + "\n";
};
Module.stdin = () => {
    return stdinBuffer.length > 0 ? stdinBuffer.shift().charCodeAt(0) : null;
};