Skip to content

Examples

rizukirr edited this page Jun 4, 2026 · 6 revisions

Examples

The examples/ directory builds into build/examples/. Each is a small, self-contained program.

Example Demonstrates
hello the minimal init → draw → event loop → shutdown cycle
print lt_print / lt_printf, UTF-8, wide (CJK) characters, multi-line text
colors the 8 named colors as fg/bg and the attribute flags
truecolor 24-bit RGB gradients, LT_RGB, the LT_HI_BLACK sentinel, runtime color-depth detection
keyboard termbox2's classic on-screen keyboard demo, ported by prefix swap (tb_lt_, TB_LT_) plus LT_INPUT_COMPAT — proof the API is drop-in
mouse SGR (1006) mouse events — buttons, position, drag
kbd on-screen keyboard + live event inspector — keys, modifiers, ev.action (press/repeat/release), and bare-modifier keys under the modern input model, plus an input-model indicator (kitty / legacy / Win32)
theme color querying — lt_query_color + lt_is_dark_background pick a light or dark theme for the panel, with the assume-dark fallback when the terminal doesn't answer; press q to exit

Run them after building:

cmake -B build && cmake --build build
./build/examples/hello
./build/examples/colors
./build/examples/mouse

Most quit on q or Esc (the keyboard demo quits with Ctrl+X then Ctrl+Q). The mouse demo prints event details to stderr while running, so redirect if you want to inspect them:

./build/examples/mouse 2> events.log

Clone this wiki locally