mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-20 10:47:35 -05:00
38 lines
1.1 KiB
HTML
38 lines
1.1 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>PyScript Next - Terminal</title>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@latest/css/xterm.min.css">
|
|
<script type="module">
|
|
import { Readline } from "https://cdn.jsdelivr.net/npm/xterm-readline@latest/+esm";
|
|
const rl = new Readline;
|
|
rl.setCheckHandler(text => !text.trimEnd().endsWith("&&"));
|
|
|
|
import { Terminal } from "https://cdn.jsdelivr.net/npm/xterm@latest/+esm";
|
|
const term = new Terminal({
|
|
theme: {
|
|
background: "#191A19",
|
|
foreground: "#F5F2E7",
|
|
},
|
|
cursorBlink: true,
|
|
cursorStyle: "block",
|
|
});
|
|
term.loadAddon(rl);
|
|
term.open(terminal);
|
|
term.focus();
|
|
|
|
import { PyWorker } from "../dist/core.js";
|
|
const { sync } = new PyWorker("terminal.py");
|
|
Object.assign(sync, {
|
|
readline: prompt => rl.read(prompt),
|
|
write: line => term.write(line),
|
|
});
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="terminal"></div>
|
|
</body>
|
|
</html>
|