mirror of
https://github.com/pyscript/pyscript.git
synced 2026-04-05 05:00:30 -04:00
Improve offline dist content (#1836)
This commit is contained in:
committed by
GitHub
parent
e81830a2ea
commit
c8ec29a3d8
@@ -1,37 +0,0 @@
|
||||
<!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>
|
||||
@@ -1,14 +0,0 @@
|
||||
###### magic monkey patching ######
|
||||
import builtins
|
||||
import sys
|
||||
|
||||
from pyodide.code import eval_code
|
||||
from pyscript import sync
|
||||
|
||||
sys.stdout = sync
|
||||
builtins.input = sync.readline
|
||||
|
||||
####### main code ######
|
||||
import code
|
||||
|
||||
code.interact()
|
||||
Reference in New Issue
Block a user