tui
¶
LOG_FLUSH_SECONDS
module-attribute
¶
How often waiting lines are moved into the log pane. Anything that arrives in between is shown together.
LOG_LINES_PER_FLUSH
module-attribute
¶
The most lines shown per flush, so a flood can never keep the UI from handling keys and clicks.
LOG_BACKLOG
module-attribute
¶
VIEWER_CHECK_SECONDS
module-attribute
¶
How often to check that the viewer is still open, so closing its window ends the session.
LogItem
module-attribute
¶
Anything that can wait to be shown in the log pane: a logging record, a controller message, or ready made text.
-
Reference
mujoco_mojoutilslayersreloadedtuirender_log_item
LOCATION_KEY
module-attribute
¶
The key, in the style of a log line's file:line, that holds the text a click copies. That is the full path, while the line shows the shorter one.
CONTROL_ICONS
module-attribute
¶
CONTROL_ICONS: dict[str, str] = {
"gen": "↻",
"run": "â–¶",
"pause": "‖",
"step": "⇥",
"stop": "â– ",
}
The symbol on each control button, by the command it types. Each must be one cell wide in a monospace font, or the row stops lining up. Plain geometric and arrow characters are used because they exist in nearly every font, unlike the emoji style media symbols.
FieldView
dataclass
¶
How one value of the session appears in the status bar.
-
Reference
mujoco_mojoutilslayersreloadedtuistatus_fields
ControllerMessage
¶
SelectableLog
¶
Bases: RichLog
A RichLog whose lines can be selected with the mouse and copied.
Textual only selects text in widgets that say where each piece of text is, and a plain RichLog does not, so dragging across it just scrolled. This one marks every line with its position and highlights the lines a drag touched in full. A line is either selected or not, so what is highlighted is exactly what gets copied. Copying hands over the text cleaned up for pasting.
LogBuffer
dataclass
¶
LogBuffer(capacity: int = LOG_BACKLOG)
Thread safe, bounded queue between everything that writes to the log pane and the UI.
Any thread can put, and it never blocks and never grows past capacity. When it is full the oldest item is dropped and counted. The UI takes a few at a time.
-
Reference
mujoco_mojoutilslayersreloadedtui
capacity
class-attribute
instance-attribute
¶
capacity: int = LOG_BACKLOG
How many items may wait. Past this the oldest are dropped.
take
¶
Up to limit of the oldest items, and how many were dropped since the last call.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
TuiLogHandler
¶
TuiLogHandler(buffer: LogBuffer)
Bases: Handler
Sends logging records to the log pane in place of the terminal handler, which would otherwise write over the screen.
emit only stores the record. Formatting happens later on the UI side, so a runtime that logs on every physics step pays almost nothing for being watched.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
FieldEditor
¶
Bases: Input
Inline editor that replaces a field's value while it is being edited.
Cancelled
¶
Bases: Message
The user pressed Escape.
ParamField
¶
ParamField(key: str, kind: FieldKind)
Bases: Horizontal
One labeled value in the status bar.
Clicking an edit field swaps its value for an editor, and clicking a toggle field flips it. The field only reports what the user did. The app passes it on to the controller, which decides whether the change is allowed.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
Edited
¶
StatusBar
¶
StatusBar(
status: ControllerStatus,
*,
title: str,
subtitle: str = "",
id: str | None = None,
)
Bases: Horizontal
State badge and the session's parameters, with the editable ones a click away.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
ExplainButton
¶
Bases: Button
Shows and hides the short hint, on the command line, that says what the command being typed will do. It never takes focus, so typing carries on.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
ControlButton
¶
Bases: Button
One of the buttons that control a run. Pressing it types its command. It never takes focus, so typing carries on.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
ControlBar
¶
ControlBar(
shortcuts: list[Binding],
state: RunState,
has_runtime: bool,
*,
id: str | None = None,
)
Bases: Horizontal
The row of buttons that start, hold, step, and stop a run, each showing its key and lit only when it applies.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
CommandSuggester
¶
Bases: Suggester
Completes the command being typed, and also the command after explain, so explain hel becomes explain help.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
CommandInput
¶
Bases: Input
Command line with Up and Down history and Tab completion.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
action_complete
¶
Accepts the suggested completion, the same as pressing Right at the end of the line.
HelpScreen
¶
HelpScreen(
commands: list[tuple[str, str]],
keys: list[tuple[str, str]],
close_keys: list[str],
)
Bases: ModalScreen[None]
Lists the commands and key bindings.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
ReloadedApp
¶
ReloadedApp(
controller: ReloadedController,
backend: ViewerBackend,
*,
keys: ReloadedKeySettings | None = None,
subtitle: str = "",
watch_css: bool = False,
explain: bool = True,
rain_seconds: float = 1.5,
logs: LogBuffer | None = None,
)
Bases: App[None]
Terminal UI for a Reloaded session.
It owns no session logic. Everything the user types or clicks goes to the ReloadedController, and everything the controller reports comes back as events.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
shortcuts
instance-attribute
¶
shortcuts = shortcut_bindings(keys or ReloadedKeySettings())
The keys bound to actions, in the order the footer shows them.
action_help_quit
¶
Ctrl+C is left for copying text, so say how to quit rather than let Textual name Ctrl+Q, which some terminals never pass along.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
render_markup
¶
render_markup(message: str) -> Text
Rich markup to Text, falling back to the literal string if the markup is malformed (e.g. an array repr with square brackets).
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
key_label
¶
Display form of a Textual key name, e.g. ctrl+q becomes Ctrl+Q and f1 becomes F1.
shortcut_bindings
¶
shortcut_bindings(
keys: ReloadedKeySettings,
) -> list[Binding]
One binding per configured key. The first key of an action is shown in the footer, and any others only work.
-
Reference
mujoco_mojoutilslayersreloadedtuiReloadedAppshortcuts
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
status_fields
¶
status_fields(status: ControllerStatus) -> list[FieldView]
The values shown in the status bar, in order. Fields marked edit open an editor when clicked and toggle fields flip.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
control_states
¶
Which control buttons apply in state, by the command each one types. A button that does not apply is greyed out.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
run_summary
¶
run_summary(status: ControllerStatus) -> Text | None
How the most recent run ended, or None before the first one. Shown on the log's bottom border, where it has room.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
fit_title
¶
The app title for a status bar with available spare columns: with its subtitle if both fit, alone if only it fits, and nothing otherwise, so it is never cut in half.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
record_location
¶
Where a record was logged, as path:line. Pasted into an editor's quick open (Ctrl+P in VS Code) it jumps to that line.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
right_aligned
¶
right_aligned(
text: Text, tail: Text, width: int | None
) -> Text
text followed by tail flush with the right edge of a pane width cells wide: on the last row text takes up once it is wrapped if there is room, and on a row of its own if there is not. With no width to go by, tail just follows after two spaces.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
record_full_location
¶
Where a record was logged, as path:line with the file's full path. This is what a click copies, so it works from any folder, while the log shows the shorter record_location.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
format_record
¶
One logging record as a line for the log pane: time, level, the message, then where it was logged, flush right when the pane's width is known. Clicking the location copies it.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
render_log_item
¶
Turns whatever was waiting into text, on the UI side so the thread that logged never pays for it. width is how wide the log pane is, which lets a record's location sit flush right.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
selected_text
¶
The text of strip from character start to end (to the end of the line if end is -1), the way it should be pasted.
The log pads a record out so its location sits flush right. That padding is for the eye, so a selection that takes in the location gets the message and the location with two spaces between them, and trailing spaces never come along.
Source code in src/mujoco_mojo/utils/layers/reloaded/tui.py
highlighted
¶
strip with style laid over every segment. Strip.apply_style puts a style underneath what a segment already has, which would leave a line's own colors showing.