Terminal

Monospace terminal emulator display with ANSI color support.

python 9 params

Preview

show_line_numbers
shell
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 its script on the page: <script src="{% static 'djust_components/terminal.js' %}"></script>. djust ships it; without it the markup renders but does not update in the browser.

Parameters

NameTypeDefaultDescription
outputlist | NoneNonelist of text lines to display
titlestr''optional title bar text
stream_eventstr — the event your server pushes to it''djust event for streaming new lines
show_line_numbersboolFalseshow line numbers (default False)
wrapboolFalsewrap long lines (default False)
custom_classstr''additional CSS classes
max_linesint0keep at most this many lines when streaming (0 = unlimited)
auto_scrollboolTruefollow the newest line while streaming (default True; False leaves the scroll position alone; the follow also stops by itself when the reader scrolls up)
**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
FilePathNotes
moduledjust.components.components.terminalSubclass it, or pass custom_class, to change how it renders.
cssdjust_components/components.cssDefines 12 of this component's classes at line 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135. Override those rules, or the custom properties they read, in a stylesheet loaded after it.