MCPcopy Index your code
hub / github.com/RustPython/RustPython / runCodeFromTextarea

Function runCodeFromTextarea

wasm/demo/src/index.js:56–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

54const errorElement = document.getElementById('error');
55
56function runCodeFromTextarea() {
57 // Clean the console and errors
58 consoleElement.value = '';
59 errorElement.textContent = '';
60
61 const code = editor.state.doc.toString();
62 try {
63 rp.pyExec(code, {
64 stdout: (output) => {
65 const shouldScroll =
66 consoleElement.scrollHeight - consoleElement.scrollTop ===
67 consoleElement.clientHeight;
68 consoleElement.value += output;
69 if (shouldScroll) {
70 consoleElement.scrollTop = consoleElement.scrollHeight;
71 }
72 },
73 });
74 } catch (err) {
75 if (err instanceof WebAssembly.RuntimeError) {
76 err = window.__RUSTPYTHON_ERROR || err;
77 }
78 errorElement.textContent = err;
79 console.error(err);
80 }
81}
82
83const snippets = document.getElementById('snippets');
84

Callers 1

onReadyFunction · 0.85

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected