64 lines
2.5 KiB
HTML
64 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>micro text editor with vi and SKK plugins</title>
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@xterm/xterm@5.5.0/css/xterm.css">
|
|
<style>
|
|
html, body { height:100%; margin:0; background:#000; }
|
|
header { height:44px; line-height:44px; padding:0 12px; color:#9ae6b4; background:#111; border-bottom:1px solid #222; font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }
|
|
#term { height:calc(100vh - 44px); }
|
|
a { color: #c88; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<header><a href="https://micro-editor.github.io/">micro</a> text editor with <a href="https://github.com/micro-garden/vi-plugin">vi</a> and <a href="https://github.com/micro-garden/skk-plugin">SKK</a> plugins</header>
|
|
<div id="term"></div>
|
|
|
|
<script src="libv86.js"></script>
|
|
<script type="module">
|
|
import { Terminal } from 'https://cdn.jsdelivr.net/npm/@xterm/xterm@5.5.0/+esm';
|
|
import { FitAddon } from 'https://cdn.jsdelivr.net/npm/@xterm/addon-fit@0.10.0/+esm';
|
|
|
|
const term = new Terminal({ cursorBlink:true, convertEol:true });
|
|
const fitAddon = new FitAddon();
|
|
term.loadAddon(fitAddon);
|
|
term.open(document.getElementById('term'));
|
|
fitAddon.fit();
|
|
addEventListener('resize', () => fitAddon.fit());
|
|
term.writeln('Booting Buildroot on v86 via serial... (ttyS0 @ 115200)');
|
|
term.writeln('');
|
|
|
|
const diskBuf = await fetch(new URL("rootfs.ext2", location.href)).then(r => r.arrayBuffer());
|
|
|
|
const emu = new V86({
|
|
memory_size: 256 * 1024 * 1024,
|
|
bios: { url: "bios/seabios.bin" },
|
|
vga_bios: { url: "bios/vgabios.bin" },
|
|
bzimage: { url: "bzImage" },
|
|
hda: { buffer: diskBuf, async: true, use_persistent_storage: true },
|
|
network_relay_url: "wss://relay.widgetry.org/",
|
|
cmdline: "root=/dev/sda rw console=ttyS0,115200",
|
|
disable_keyboard: true,
|
|
autostart: true,
|
|
});
|
|
|
|
const decoder = new TextDecoder("utf-8");
|
|
let haveByteEvent = false, byteBuffer = [];
|
|
function flushBytes(){
|
|
if(byteBuffer.length){
|
|
term.write(decoder.decode(new Uint8Array(byteBuffer)));
|
|
byteBuffer = [];
|
|
}
|
|
requestAnimationFrame(flushBytes);
|
|
}
|
|
flushBytes();
|
|
|
|
emu.add_listener("serial0-output-byte", b => { haveByteEvent = true; byteBuffer.push(b & 0xFF); });
|
|
emu.add_listener("serial0-output-char", ch => { if(!haveByteEvent) term.write(ch); });
|
|
|
|
term.onData(data => emu.serial0_send(data));
|
|
</script>
|
|
</body>
|
|
</html>
|