Skip to content

Quick Start

This page shows the smallest useful lazy-cuh app: a focused list, relative line numbers, vim-style movement, and a typed selection message.

from rich.text import Text
from textual.app import App, ComposeResult
from lazy_cuh import LineNumberMode, LineNumberSpec, ListViewModel, ListViewSpec, NavigableItem
from lazy_cuh.styles import LAZY_CUH_CSS
from lazy_cuh.widgets import ItemSelectedMessage, ListViewWidget
class Demo(App):
CSS = LAZY_CUH_CSS + """
ListViewWidget {
height: 1fr;
border: round ansi_default;
border-title-color: ansi_default;
padding: 0 1;
}
ListViewWidget:focus {
border: round ansi_green;
border-title-color: ansi_green;
}
"""
BINDINGS = [("q", "quit", "Quit")]
def compose(self) -> ComposeResult:
model = ListViewModel(
items=(
NavigableItem(id="panels", label=Text("Composable panels")),
NavigableItem(id="lists", label=Text("Item-oriented lists")),
NavigableItem(id="keybars", label=Text("Context-aware keybars")),
),
spec=ListViewSpec(
width=60,
line_numbers=LineNumberSpec(LineNumberMode.RELATIVE),
),
)
widget = ListViewWidget(model, id="items")
widget.border_title = "[1]-Items"
yield widget
def on_mount(self) -> None:
self.query_one("#items", ListViewWidget).focus()
def on_item_selected_message(self, message: ItemSelectedMessage) -> None:
self.notify(f"Selected {message.item_id}")
if __name__ == "__main__":
Demo(ansi_color=True).run()

Run it with:

Terminal window
uv run python app.py

Use j and k to move, enter or space to select, and q to quit.

The example separates the reusable framework pieces from Textual runtime code:

  • NavigableItem is semantic item data.
  • ListViewModel renders items, line numbers, wrapping, and cursor highlight.
  • ListViewWidget adapts the model to Textual and emits typed messages.
  • LAZY_CUH_CSS provides the transparent lazygit-style defaults.

The app still owns the actual behavior: selecting an item shows a notification, but a real app could translate that event into a command, modal, or domain action.