[READ-ONLY] Mirror of https://github.com/bombshell-dev/tty. Platform independent 2D layout engine for terminal applications based on Clay
5

Configure Feed

Select the types of activity you want to include in your feed.

move to examples folder with readme

Jacob Bolda (May 27, 2026, 4:17 PM -0500) ed95c3eb 088eb82f

+72 -10
+3 -3
README.md
··· 21 21 will run anywhere JavaScript runs with no native dependencies, and no build step 22 22 for consumers. 23 23 24 - ### Demo 24 + ### Examples 25 25 26 26 The application in this demo uses Clayterm for all layout and input parsing 27 27 ··· 30 30 The input parser decodes raw terminal bytes into structured events. Here you can 31 31 see each key event as the string "hello world" is typed. 32 32 33 - ![Keyboard events demo](demo/keyboard-key-events.gif) 33 + ![Keyboard events demo](examples/keyboard/keyboard-key-events.gif) 34 34 35 35 #### Pointer Events 36 36 37 37 Here we see hover styles applied to UI elements in response to the pointer 38 38 state. Clay drives the hit testing; no manual coordinate math required. 39 39 40 - ![Pointer events demo](demo/keyboard-pointer-events.gif) 40 + ![Pointer events demo](examples/keyboard/keyboard-pointer-events.gif) 41 41 42 42 ## Architecture 43 43
+3 -3
demo/inline-region.ts examples/inline-regions/index.ts
··· 24 24 rgba, 25 25 SHOWCURSOR, 26 26 text, 27 - } from "../mod.ts"; 28 - import { cursor, settings } from "../settings.ts"; 29 - import { validated } from "../validate.ts"; 27 + } from "../../mod.ts"; 28 + import { cursor, settings } from "../../settings.ts"; 29 + import { validated } from "../../validate.ts"; 30 30 31 31 const encode = (s: string) => new TextEncoder().encode(s); 32 32 const write = (b: Uint8Array) => Deno.stdout.writeSync(b);
demo/keyboard-key-events.gif examples/keyboard/keyboard-key-events.gif
demo/keyboard-pointer-events.gif examples/keyboard/keyboard-pointer-events.gif
+2 -2
demo/keyboard.ts examples/keyboard/index.ts
··· 21 21 type PointerEvent, 22 22 rgba, 23 23 text, 24 - } from "../mod.ts"; 24 + } from "../../mod.ts"; 25 25 import { 26 26 alternateBuffer, 27 27 cursor, ··· 29 29 progressiveInput, 30 30 type Setting, 31 31 settings, 32 - } from "../settings.ts"; 32 + } from "../../settings.ts"; 33 33 import { useInput } from "./use-input.ts"; 34 34 import { useStdin } from "./use-stdin.ts"; 35 35
+1 -1
demo/use-input.ts examples/keyboard/use-input.ts
··· 11 11 suspend, 12 12 until, 13 13 } from "effection"; 14 - import { createInput, type InputEvent, type InputOptions } from "../mod.ts"; 14 + import { createInput, type InputEvent, type InputOptions } from "../../mod.ts"; 15 15 16 16 function nothing() { 17 17 return suspend() as unknown as Operation<
demo/use-stdin.ts examples/keyboard/use-stdin.ts
-1
deno.json
··· 7 7 "fmt:check": "deno fmt --check && clang-format --dry-run --Werror src/*.c src/*.h", 8 8 "build:npm": "deno run -A tasks/build-npm.ts", 9 9 "build:jsr": "deno run -A tasks/build-jsr.ts", 10 - "demo": "deno run demo/keyboard.ts", 11 10 "bench": "deno run -A bench/mod.ts" 12 11 }, 13 12 "imports": {
+63
examples/README.md
··· 1 + # examples 2 + 3 + This directory contains runnable example applications that exercise different 4 + features of libs. If any of these examples are not working, please open an issue 5 + with information about your terminal, shell, operating system and any other 6 + information that could be pertinent to reproducing the issue. 7 + 8 + > [!NOTE] 9 + > Run the commands in this document from the repository root. 10 + 11 + ## Prerequisites 12 + 13 + Build the generated WebAssembly bundle before running the examples: 14 + 15 + ```sh 16 + make 17 + ``` 18 + 19 + ## Keyboard 20 + 21 + Path: `examples/keyboard/index.ts` 22 + 23 + Run it with: 24 + 25 + ```sh 26 + deno run examples/keyboard/index.ts 27 + ``` 28 + 29 + What it shows: 30 + 31 + - raw keyboard input decoded into structured key events 32 + - progressive keyboard protocol support 33 + - pointer tracking and hover/click-driven UI updates 34 + - terminal mode configuration such as alternate buffer, hidden cursor, and mouse 35 + reporting 36 + 37 + Related files: 38 + 39 + - `examples/keyboard/use-input.ts` wraps the input parser as a stream of decoded 40 + events 41 + - `examples/keyboard/use-stdin.ts` adapts stdin into a byte stream for the demo 42 + 43 + ## Inline Regions 44 + 45 + Path: `examples/inline-regions/index.ts` 46 + 47 + Run it with: 48 + 49 + ```sh 50 + deno run examples/inline-regions/index.ts 51 + ``` 52 + 53 + What it shows: 54 + 55 + - rendering animated regions into normal terminal scrollback 56 + - querying cursor position with DSR to place later frames correctly 57 + - updating a previously allocated region without taking over the whole screen 58 + - small animated demos including a spinner, a progress bar, and a nyan-cat-style 59 + sequence 60 + 61 + This example is useful if you want to embed transient or animated UI output into 62 + a normal command-line workflow instead of switching to a full-screen alternate 63 + buffer interface.