Files
Claude 32529543d6 Image boards on the terminals, with their pictures
The text BBS and 3270s have the image boards (B on the main menu, or a
menu's boards): the boards, threads by bump order, posts read as
messages with who posted, the thread, and the posts that quote them.
Callers post as the web's posters do (names, tripcodes, sage, staff's
capcodes), through the same checks: posting is now Submit, shared by
the web's form and bbs.ImageBoards. A thread's image comes by the
terminal's transfer protocol.

Pictures (view.Picture, on messages and panels) are shown as well as
the terminal can: kitty's graphics protocol (kitty, Ghostty), sixel,
iTerm2's inline images (iTerm2, mintty), or coloured half blocks in 256
colours on other UTF-8 terminals; described in words elsewhere and on
3270s. V shows the image whole; pictures on/off is on the profile. The
web terminal has xterm.js's image addon, so sixel there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
2026-10-14 02:16:21 +00:00

52 lines
1.8 KiB
JavaScript

// The web terminal: xterm.js on the BBS's /terminal/ws, the caller's bytes
// both ways in binary frames, as a telnet client's would go.
"use strict";
(function () {
const status = document.getElementById("status");
const again = document.getElementById("again");
const term = new Terminal({
cursorBlink: true,
fontFamily: '"DejaVu Sans Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace',
fontSize: 16,
scrollback: 2000,
theme: { background: "#000000", foreground: "#c0c0c0" },
});
const fit = new FitAddon.FitAddon();
term.loadAddon(fit);
// pictures: sixel and iTerm2's inline images (the image boards')
term.loadAddon(new ImageAddon.ImageAddon({ sixelSupport: true, iipSupport: true }));
term.open(document.getElementById("term"));
window.addEventListener("resize", () => fit.fit());
const encoder = new TextEncoder();
let ws = null;
const send = (bytes) => {
if (ws && ws.readyState === WebSocket.OPEN) ws.send(bytes);
};
term.onData((d) => send(encoder.encode(d)));
term.onBinary((d) => send(Uint8Array.from(d, (c) => c.charCodeAt(0) & 0xff)));
function connect() {
fit.fit();
term.reset();
again.hidden = true;
status.textContent = "Connecting…";
const scheme = location.protocol === "https:" ? "wss:" : "ws:";
const url = `${scheme}//${location.host}/terminal/ws?cols=${term.cols}&rows=${term.rows}`;
ws = new WebSocket(url, "bbs.terminal");
ws.binaryType = "arraybuffer";
ws.onopen = () => {
status.textContent = "Connected";
term.focus();
};
ws.onmessage = (e) => term.write(new Uint8Array(e.data));
ws.onclose = () => {
status.textContent = "Disconnected";
again.hidden = false;
ws = null;
};
}
again.addEventListener("click", connect);
connect();
})();