You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Option to make Py-Terminal and Xterm.js (pyscript#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
Copy file name to clipboardExpand all lines: docs/changelog.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
Features
8
8
--------
9
9
10
+
- Added the `xterm` attribute to `py-config`. When set to `True` or `xterm`, an (output-only) [xterm.js](http://xtermjs.org/) terminal will be used in place of the default py-terminal.
10
11
- The default version of Pyodide is now `0.23.2`. See the [Pyodide Changelog](https://pyodide.org/en/stable/project/changelog.html#version-0-23-2) for a detailed list of changes.
11
12
- Added the `@when` decorator for attaching Python functions as event handlers
12
13
- The `py-mount` attribute on HTML elements has been deprecated, and will be removed in a future release.
Copy file name to clipboardExpand all lines: docs/reference/plugins/py-terminal.md
+26-1Lines changed: 26 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This is one of the core plugins in PyScript, which is active by default. With it
4
4
5
5
## Configuration
6
6
7
-
You can control how `<py-terminal>` behaves by setting the value of the `terminal`configuration in your `<py-config>`, together with the `docked` one.
7
+
You can control how `<py-terminal>` behaves by setting the values of the `terminal`, `docked`, and `xterm` fields in your configuration in your `<py-config>`.
8
8
9
9
For the **terminal** field, these are the values:
10
10
@@ -26,6 +26,31 @@ Please note that **docked** mode is currently used as default only when `termina
26
26
27
27
In all other cases it's up to the user decide if a terminal should be docked or not.
28
28
29
+
For the **xterm** field, these are the values:
30
+
31
+
| value | description |
32
+
|-------|-------------|
33
+
|`false`| This is the default. The `<py-terminal>` is a simple `<pre>` tag with some CSS styling. |
34
+
|`true` or `xterm`| The [xtermjs](http://xtermjs.org/) library is loaded and its Terminal object is used as the `<py-terminal>`. It's visibility and position are determined by the `docked` and `auto` keys in the same way as the default `<py-terminal>`|
35
+
36
+
The xterm.js [Terminal object](http://xtermjs.org/docs/api/terminal/classes/terminal/) can be accessed directly if you want to adjust its properties, add [custom parser hooks](http://xtermjs.org/docs/guides/hooks/), introduce [xterm.js addons](http://xtermjs.org/docs/guides/using-addons/), etc. Access is best achieved by awaiting the `xtermReady` attribute of the `<py-terminal>` HTML element itself:
Some terminal-formatting packages read from specific environment variables to determine whether they should emit formatted output; PyScript does not set these variables explicitly - you may need to set them yourself, or force your terminal-formatting package into a state where it outputs correctly formatted output.
50
+
51
+
A couple of specific examples:
52
+
- the [rich](https://github.com/Textualize/rich) will not, by default, output colorful text, but passing `256` or `truecolor` as an argument as the `color_system` parameter to the [Console constructor](https://rich.readthedocs.io/en/stable/reference/console.html#rich.console.Console) will force it to do so. (As of rich v13)
53
+
-[termcolor](https://github.com/termcolor/termcolor) will not, by default, output colorful text, but setting `os.environ["FORCE_COLOR"] = "True"` or by passing `force_color=True` to the `colored()` function will force it to do so. (As of termcolor v2.3)
0 commit comments