Skip to content

Conversation

WebReflection
Copy link
Contributor

@WebReflection WebReflection commented Jan 22, 2024

Description

This MR fixes in a more robust and elegant way #1923 by providing a "dunder terminal" reference out of the box that points at the currently running Xterm instance and as discussed, and agreed, with both @JeffersGlass and @ntoll.

Changes

  • use polyscript.currentScript only when it's robust and reliable to set the __terminal__ reference once in workers
  • directly set __terminal__ through its reference in main
  • smoke tests both scenarios work as expected
  • added integration tests

Checklist

  • All tests pass locally
  • I have updated CHANGELOG.md
  • I have created documentation for this(if applicable)

@WebReflection WebReflection merged commit cea52b4 into pyscript:main Jan 22, 2024
Comment on lines +146 to +154

// on main, it's easy to trash and clean the current terminal
globalThis.__py_terminal__ = init({
disableStdin: true,
cursorBlink: false,
cursorStyle: "underline",
});
run("from js import __py_terminal__ as __terminal__");
delete globalThis.__py_terminal__;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still ought to be able to assign to the Python scope directly from JavaScript rather than doing this globalThis dance...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, I am not proud of that ugly dance but it worked well in both MicroPython and Pyodide ... can I do better for both "worlds"? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants