Skip to main content

Module tui

Module tui 

Source
Expand description

Modern terminal UI built on ratatui + crossterm.

Design principles:

  • Dashboard layout: header bar, main panel, status line
  • Keyboard-first: arrow keys + Enter/Esc, no mouse dependency

Terminal UI rendering for NotAlterra.

Uses ratatui + crossterm to draw menu screens, picker lists, dialogs, metadata inspectors, and the animated whale separator. All rendering is stateless β€” callers pass in an AppState snapshot.

StructsΒ§

AppState
Global application state passed through every frame.
InputDialogState
State for the text-input dialog used to enter a save-folder path.

EnumsΒ§

StatusStyle

FunctionsΒ§

centered_rect πŸ”’
Create a centered rectangle for modal overlays. Return a rectangle centered in r by the given width and height percentages. Return a rectangle centered in r by the given width and height percentages.
centered_rect_size πŸ”’
Return a rectangle centered in r by the given width and height percentages. Shrink a rectangle to the given absolute width and height, centered. Return a rectangle centered in r by the given width and height percentages.
draw_confirm_popup
Draw a simple confirmation popup with [ Yes ] [ No ] buttons.
draw_disclaimer_popup
Draw the disclaimer popup with full warning text.
draw_header πŸ”’
Render the title bar with version information.
draw_info_dialog
Render a non-interactive info dialog β€” no buttons, renders once, caller is expected to return to the event loop (the dialog stays visible until the next terminal.draw() replaces it).
draw_input_dialog
Draw the text input dialog for entering a custom save-folder path.
draw_main_menu
Draw the main menu.
draw_ok_dialog
Render an informational dialog with a plain-text message and OK button. Auto-sizes to fit content. Title is displayed in cyan, message in gray, whale separator at the bottom. Press Enter or Space to dismiss.
draw_ok_dialog_styled
Render a dialog with styled content lines. Supports inline formatting (colors, bold) via [Line] slices. Use for metadata displays, help text, or any content that needs per-span styling.
draw_picker
Draw a file/folder picker list. pinned_header renders items[0] as a fixed header above the scrollable list.
draw_picker_split
Draw the file picker with a horizontal split: pip-style file list on the left, live metadata preview on the right. Used by the .bak recover flow.
draw_picker_with_info
Draw a file/folder picker list with an extra selected-item info line (e.g. showing the full filename of the highlighted .bak file). pinned_header renders items[0] as a fixed header above the scrollable list.
draw_right_pane πŸ”’
Render the right-hand metadata pane in the split file picker. Shows the filename header, a dim separator, then the provided content lines. When meta_lines is empty, shows a placeholder message.
draw_select_list πŸ”’
Render a scrollable picker list with description and prompt.
draw_select_list_pip πŸ”’
Render a compact pip-list without description line or prompt. The pip (β–Ί) replaces the full-row background highlight.
draw_select_list_with_info πŸ”’
Render a picker list with description and prompt.
draw_status_bar πŸ”’
Render the status bar at the bottom of the screen.
draw_status_dashboard πŸ”’
Render the status dashboard beneath the header.
draw_sub_menu
Draw a sub-menu (e.g. Config management).
draw_text_screen
Draw a full-screen text display with a β€œpress any key” prompt at the bottom. Used for status messages during long operations (scanning, backing up) and for displaying scan results.
draw_whale_separator
Draw the bottom status bar with an animated whale patrolling right-to-left. The whale moves one position every 180ms. After reaching the left edge, it disappears for ~5.4s (30 cooldown ticks) before reappearing on the right. Two variants alternate every 400ms.
inner πŸ”’
Shrink a rect by a margin on all sides.
standard_layout πŸ”’
truncate_path_tail πŸ”’
Truncate a filesystem path to show only the most specific directories. Walks forward to the first path separator after the truncation point to avoid splitting mid-component.