python-wasm
python-wasm copied to clipboard
Add buffer for pasted stdin and inactive stdin
It took me a while to figure out what to hook into, but I believe I finally got standard input working the way I'd expect it to.
Improvements:
- When multi-line text is pasted it displays as expected and also runs as expected
- When text is typed while code is currently running, the typed text shows up only when standard input is prompt again
- Partial data (when the pasted text doesn't end in a newline or when some text is typed and then some is pasted) shows up as expected
I added a separate class because the code started to feel unwieldy after I initially added all the buffering to the existing class. Happy to refactor if desired.
This along with unicode support (there's another PR for that) make this REPL feel pretty much like a native one from my testing (just need to add support for using Ctrl+L to clear the screen). 😁
I merged the browser-ui into CPython repo a while ago. Could you please make a PR against https://github.com/python/cpython/blob/main/Tools/wasm/python.html ?
@tiran I just opened a pull request. 👍 You might want to update the README file here to note that important changes should be made to the cpython repo instead/additionally.