Terminal
Monospace terminal emulator display with ANSI color support.
Preview
1$ djust new myapp
2Creating project…
3Done in 1.2s
python
terminal(output=['$ djust new myapp', 'Creating project…', 'Done in 1.2s'], title='shell', show_line_numbers=True)Usage
views.py
python
from djust import LiveView
from djust.components import Terminal
class MyView(LiveView):
template_name = "my_template.html"
def mount(self, request, **kwargs):
self.component = Terminal(output=['$ djust new myapp', 'Creating project…', 'Done in 1.2s'], title='shell', show_line_numbers=True)my_template.html
django
{{ component }}Needs a client hook djust does not ship: dj-hook="Terminal". The markup renders, but the interaction described above is yours to add — register window.djust.hooks.Terminal = { mounted() { … } } before client.js loads (see the hooks guide).
Parameters
| Name | Type | Default |
|---|---|---|
| output | list | None | None |
| title | str | '' |
| stream_event | str — the event your server pushes to it | '' |
| show_line_numbers | bool | False |
| wrap | bool | False |
| custom_class | str | '' |
| **kwargs | — passed to `Component.__init__`: `name=` identifies the instance in the events it sends, `id=` sets `component.id`, and any other keyword is kept as state | — |
Source & styles
| File | Path | Notes |
|---|---|---|
| module | djust.components.components.terminal | Subclass it, or pass custom_class, to change how it renders. |
| css | djust_components/components.css | Defines 12 of this component's classes at line 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081. Override those rules, or the custom properties they read, in a stylesheet loaded after it. |