Add Option to make Py-Terminal and Xterm.js (#1317)

* Add 'xterm' attribute in py-config using new validation

* Use screen reader mode

* Add `xtermReady` promise to allow users to away xterm.js init

* Guard against initializing a tag twice

* Add tests and doc
This commit is contained in:
Jeff Glass
2023-05-29 10:00:20 -05:00
committed by GitHub
parent 538aac9a28
commit 932756c7a0
7 changed files with 361 additions and 35 deletions

View File

@@ -211,6 +211,35 @@ class TestDocsSnippets(PyScriptTest):
assert "0\n1\n2\n" in py_terminal.inner_text()
@skip_worker("FIXME: js.document")
def test_reference_pyterminal_xterm(self):
self.pyscript_run(
"""
<py-config>
xterm = true
</py-config>
<py-script>
print("HELLO!")
import js
import asyncio
async def adjust_term_size(columns, rows):
xterm = await js.document.querySelector('py-terminal').xtermReady
xterm.resize(columns, rows)
print("test-done")
asyncio.ensure_future(adjust_term_size(40, 10))
</py-script>
"""
)
self.page.get_by_text("test-done").wait_for()
py_terminal = self.page.locator("py-terminal")
print(dir(py_terminal))
print(type(py_terminal))
assert py_terminal.evaluate("el => el.xterm.cols") == 40
assert py_terminal.evaluate("el => el.xterm.rows") == 10
@skip_worker(reason="FIXME: js.document (@when decorator)")
def test_reference_when_simple(self):
self.pyscript_run(