text_screens
text_screens
¶
Native text editor / viewer modals.
The web-compatible replacement for the $EDITOR-subprocess and
"print to a suspended terminal" instruction workflows (issue #473).
Both are plain in-process modals — no child process, no terminal:
TextEditorScreen— an editableTextArea; dismisses with the edited text on Save,Noneon Cancel.TextViewScreen— the same widget in read-only mode for display-only content.
TextEditorScreen(text, *, title)
¶
Bases: ModalScreen[str | None]
Modal TextArea editor.
Dismisses with the (possibly edited) text on Save, or None on
Cancel / Escape — the caller decides whether to persist.
Create the editor over text with title on the dialog border.
Source code in src/terok/tui/text_screens.py
BINDINGS = [Binding('escape', 'cancel', 'Cancel')]
class-attribute
instance-attribute
¶
CSS = '\n TextEditorScreen {\n align: center middle;\n }\n\n #text-editor-dialog {\n width: 90%;\n height: 85%;\n border: heavy $primary;\n border-title-align: right;\n background: $surface;\n padding: 1 2;\n }\n\n #text-editor-area {\n height: 1fr;\n margin-bottom: 1;\n }\n\n #text-editor-buttons {\n height: 3;\n align-horizontal: right;\n }\n\n #text-editor-buttons Button {\n margin-left: 1;\n }\n '
class-attribute
instance-attribute
¶
compose()
¶
Lay out the editable text area and the Cancel / Save buttons.
Source code in src/terok/tui/text_screens.py
on_mount()
¶
TextViewScreen(text, *, title)
¶
Bases: ModalScreen[None]
Read-only modal text viewer — scrollable, selectable, no terminal.
Create the viewer over text with title on the dialog border.
Source code in src/terok/tui/text_screens.py
BINDINGS = [Binding('escape', 'dismiss', 'Close')]
class-attribute
instance-attribute
¶
CSS = '\n TextViewScreen {\n align: center middle;\n }\n\n #text-view-dialog {\n width: 90%;\n height: 85%;\n border: heavy $primary;\n border-title-align: right;\n background: $surface;\n padding: 1 2;\n }\n\n #text-view-area {\n height: 1fr;\n margin-bottom: 1;\n }\n\n #text-view-buttons {\n height: 3;\n align-horizontal: right;\n }\n '
class-attribute
instance-attribute
¶
compose()
¶
Lay out the read-only text area and a Close button.