Skip to content

Commit 4139212

Browse files
authored
Merge pull request #46 from bombshell-dev/proper-example-folder
move to examples folder with readme
2 parents 088eb82 + ed95c3e commit 4139212

9 files changed

Lines changed: 72 additions & 10 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ computation.
2121
will run anywhere JavaScript runs with no native dependencies, and no build step
2222
for consumers.
2323

24-
### Demo
24+
### Examples
2525

2626
The application in this demo uses Clayterm for all layout and input parsing
2727

@@ -30,14 +30,14 @@ The application in this demo uses Clayterm for all layout and input parsing
3030
The input parser decodes raw terminal bytes into structured events. Here you can
3131
see each key event as the string "hello world" is typed.
3232

33-
![Keyboard events demo](demo/keyboard-key-events.gif)
33+
![Keyboard events demo](examples/keyboard/keyboard-key-events.gif)
3434

3535
#### Pointer Events
3636

3737
Here we see hover styles applied to UI elements in response to the pointer
3838
state. Clay drives the hit testing; no manual coordinate math required.
3939

40-
![Pointer events demo](demo/keyboard-pointer-events.gif)
40+
![Pointer events demo](examples/keyboard/keyboard-pointer-events.gif)
4141

4242
## Architecture
4343

deno.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"fmt:check": "deno fmt --check && clang-format --dry-run --Werror src/*.c src/*.h",
88
"build:npm": "deno run -A tasks/build-npm.ts",
99
"build:jsr": "deno run -A tasks/build-jsr.ts",
10-
"demo": "deno run demo/keyboard.ts",
1110
"bench": "deno run -A bench/mod.ts"
1211
},
1312
"imports": {

examples/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ import {
2424
rgba,
2525
SHOWCURSOR,
2626
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";
3030

3131
const encode = (s: string) => new TextEncoder().encode(s);
3232
const write = (b: Uint8Array) => Deno.stdout.writeSync(b);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ import {
2121
type PointerEvent,
2222
rgba,
2323
text,
24-
} from "../mod.ts";
24+
} from "../../mod.ts";
2525
import {
2626
alternateBuffer,
2727
cursor,
2828
mouseTracking,
2929
progressiveInput,
3030
type Setting,
3131
settings,
32-
} from "../settings.ts";
32+
} from "../../settings.ts";
3333
import { useInput } from "./use-input.ts";
3434
import { useStdin } from "./use-stdin.ts";
3535

File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
suspend,
1212
until,
1313
} from "effection";
14-
import { createInput, type InputEvent, type InputOptions } from "../mod.ts";
14+
import { createInput, type InputEvent, type InputOptions } from "../../mod.ts";
1515

1616
function nothing() {
1717
return suspend() as unknown as Operation<

0 commit comments

Comments
 (0)