Skip to content

Examples

The repository ships 39 runnable examples under examples/. They are not decoration: building them all is how the crate checks that its public API still works from outside, so any change that breaks a downstream program breaks the example build first.

cargo run --example showcase     # run one
cargo build --examples           # build all 39

Quit with Alt+X

These are full-screen terminal applications. Leave through the application, not by closing the terminal window, or you will be left in raw mode.

Start here

Example Lines What it shows
quick_start_00 .. quick_start_05 10-130 The application shell, assembled one piece at a time. Walked through in the quick start tutorial.
minimal_app 80 A status line and a window, no menu bar. The equivalent of deriving from TProgram instead of TApplication.
dialogs 64 The three standard library dialogs.
showcase 1785 The broad demo: calculator, calendar, ASCII table and puzzle windows, overlapping with shadows and z-order.

Three windows open at once in the showcase demo, overlapping with shadows

By subject

Application shell

  • menu_status — a menu bar with submenus, a right-click context menu, and a status line with hot spots and hints.
  • command_set — buttons that enable and disable themselves as application state changes, driven by the global command set.
  • function_keys — F1 through F10, and what actually arrives from the terminal.
  • dynamic_title — changing a window title while the application runs.

The File menu open over the desktop, its items showing their key chords

Windows and layout

  • window_resize — dragging, resizing and the growth modes that decide how children follow.
  • test_window_overlap — modal against non-modal, and what a modal window blocks.
  • broadcast — a standalone group distributing a broadcast to its children.
  • wrong_owner — a deliberate mistake: a button that reports the wrong owner type and picks up the wrong palette. Useful when your colours look off.

Controls

  • new_controls — the widgets added beyond the Borland set, on two tabbed pages.
  • table_frozen — a Table with frozen panes: a Region column and a totals row stay put while thirty regions by twelve months scroll both ways. The table grows with its window, and Enter on a cell shows its details through the table's on_select command and an AppHandler.
  • cluster_tooltip — multi-item check box and radio clusters, tooltips, and the frame zoom triangle.
  • list_components — the list viewer family end to end.
  • sorted_listbox — a sorted list with binary search and type-ahead.
  • tree_view — a hierarchical outline view.
  • progress_bar — determinate and marquee bars, animated as overlay widgets.
  • gallery — the component gallery: a list of components grouped by kind and, for the one under the focus, the live component, how it works with its parameters, links to related components, and the code that built it (the demo's own source file). Arrows browse, F6 switches to the component to try it.
  • label_link — labels that focus the input field they are linked to.
  • validator — every validator type in one dialog: filter, range and picture.

Check box and radio clusters side by side, over a window with a zoom icon

A list box of items beside the instructions pane of the list components demo

Files and the editor

  • file_dialog — the open and save dialogs.
  • file_browser — a directory tree beside a file list.

The Open File dialog listing a directory, with Open and Cancel buttons - pascal_ide — the editor from the Bruto-Pascal project, with a breakpoint gutter and Pascal syntax highlighting. The most complex example in the tree.

The Pascal IDE example with a highlighted source file and a breakpoint gutter

Colour and text

  • palette_themes — replacing the application palette at runtime.
  • text_styling — a table of every text style the terminal layer can emit.

Real images in the terminal through the Kitty graphics protocol, and ANSI-art backgrounds, moved to tv-extensions' examples/ (feature graphics).

The palette themes demo after switching to the Solarized theme, every control recoloured

Terminal and plumbing

  • suspend_resume — handing the terminal back to the shell and taking it again.
  • screenshot — the built-in screen capture shortcuts.
  • beep — audio feedback.
  • test_events, test_mouse — diagnostic tools that print every event, for when a key or a click is not arriving.

A scrolling output viewer fed by a simulated build log, tracing output routed into a scrollable window, and serving the application over SSH all moved to tv-extensions' examples/ (features log and ssh).

Whole applications

  • biorhythm — the calculator built in the tutorial: a validated date form and a custom chart view.
  • ui_features — beeps, dynamic titles and message boxes together.

The biorhythm calculator showing three coloured sine curves and a marker for today

Reading an example

Four of them are picked apart in the walkthroughs.