| 124 | } |
| 125 | |
| 126 | async function readPrompts() { |
| 127 | let continuing = ''; |
| 128 | |
| 129 | while (true) { |
| 130 | let input = await readline.read(getPrompt(continuing ? 'ps2' : 'ps1')); |
| 131 | if (input.endsWith('\n')) input = input.slice(0, -1); |
| 132 | if (continuing) { |
| 133 | input = continuing += '\n' + input; |
| 134 | if (!continuing.endsWith('\n')) continue; |
| 135 | } |
| 136 | try { |
| 137 | console.log([input]); |
| 138 | terminalVM.execSingle(input); |
| 139 | } catch (err) { |
| 140 | if (err.canContinue) { |
| 141 | continuing = input; |
| 142 | continue; |
| 143 | } else if (err instanceof WebAssembly.RuntimeError) { |
| 144 | err = window.__RUSTPYTHON_ERROR || err; |
| 145 | } |
| 146 | readline.print('' + err); |
| 147 | } |
| 148 | continuing = ''; |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | function onReady() { |
| 153 | snippets.addEventListener('change', updateSnippetAndRun); |