Terminal Addons
The xtermjs console that powers the PyScript terminal can make use of a variety of addons to add specific functionality. The fit and web links addons are included out-of-the-box. To add an addon, grab the terminal object using the __terminal__
global name and add a newly instatiated addon object to it. You can instantiate the addon via JavaScript, or using the ESM Module Loaderfunctionality included with PyScript:
<py-config>
[js_modules.main]
"https://cdn.jsdelivr.net/npm/@xterm/addon-web-links@0.11.0/+esm" = "weblinks"
</py-config>
<script type="py" terminal>
from pyscript import js_modules
addon = js_modules.weblinks.WebLinksAddon.new()
__terminal__.loadAddon(addon)
print("Check out https://google.com")
</script>