@dealdeploy/skl 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/opentui/SKILL.md +198 -0
- package/.agents/skills/opentui/references/animation/REFERENCE.md +431 -0
- package/.agents/skills/opentui/references/components/REFERENCE.md +143 -0
- package/.agents/skills/opentui/references/components/code-diff.md +496 -0
- package/.agents/skills/opentui/references/components/containers.md +412 -0
- package/.agents/skills/opentui/references/components/inputs.md +531 -0
- package/.agents/skills/opentui/references/components/text-display.md +384 -0
- package/.agents/skills/opentui/references/core/REFERENCE.md +145 -0
- package/.agents/skills/opentui/references/core/api.md +506 -0
- package/.agents/skills/opentui/references/core/configuration.md +166 -0
- package/.agents/skills/opentui/references/core/gotchas.md +393 -0
- package/.agents/skills/opentui/references/core/patterns.md +448 -0
- package/.agents/skills/opentui/references/keyboard/REFERENCE.md +511 -0
- package/.agents/skills/opentui/references/layout/REFERENCE.md +337 -0
- package/.agents/skills/opentui/references/layout/patterns.md +444 -0
- package/.agents/skills/opentui/references/react/REFERENCE.md +174 -0
- package/.agents/skills/opentui/references/react/api.md +435 -0
- package/.agents/skills/opentui/references/react/configuration.md +301 -0
- package/.agents/skills/opentui/references/react/gotchas.md +443 -0
- package/.agents/skills/opentui/references/react/patterns.md +501 -0
- package/.agents/skills/opentui/references/solid/REFERENCE.md +201 -0
- package/.agents/skills/opentui/references/solid/api.md +543 -0
- package/.agents/skills/opentui/references/solid/configuration.md +315 -0
- package/.agents/skills/opentui/references/solid/gotchas.md +415 -0
- package/.agents/skills/opentui/references/solid/patterns.md +558 -0
- package/.agents/skills/opentui/references/testing/REFERENCE.md +614 -0
- package/.claude/settings.local.json +11 -0
- package/.claude/skills/opentui/SKILL.md +198 -0
- package/.claude/skills/opentui/references/animation/REFERENCE.md +431 -0
- package/.claude/skills/opentui/references/components/REFERENCE.md +143 -0
- package/.claude/skills/opentui/references/components/code-diff.md +496 -0
- package/.claude/skills/opentui/references/components/containers.md +412 -0
- package/.claude/skills/opentui/references/components/inputs.md +531 -0
- package/.claude/skills/opentui/references/components/text-display.md +384 -0
- package/.claude/skills/opentui/references/core/REFERENCE.md +145 -0
- package/.claude/skills/opentui/references/core/api.md +506 -0
- package/.claude/skills/opentui/references/core/configuration.md +166 -0
- package/.claude/skills/opentui/references/core/gotchas.md +393 -0
- package/.claude/skills/opentui/references/core/patterns.md +448 -0
- package/.claude/skills/opentui/references/keyboard/REFERENCE.md +511 -0
- package/.claude/skills/opentui/references/layout/REFERENCE.md +337 -0
- package/.claude/skills/opentui/references/layout/patterns.md +444 -0
- package/.claude/skills/opentui/references/react/REFERENCE.md +174 -0
- package/.claude/skills/opentui/references/react/api.md +435 -0
- package/.claude/skills/opentui/references/react/configuration.md +301 -0
- package/.claude/skills/opentui/references/react/gotchas.md +443 -0
- package/.claude/skills/opentui/references/react/patterns.md +501 -0
- package/.claude/skills/opentui/references/solid/REFERENCE.md +201 -0
- package/.claude/skills/opentui/references/solid/api.md +543 -0
- package/.claude/skills/opentui/references/solid/configuration.md +315 -0
- package/.claude/skills/opentui/references/solid/gotchas.md +415 -0
- package/.claude/skills/opentui/references/solid/patterns.md +558 -0
- package/.claude/skills/opentui/references/testing/REFERENCE.md +614 -0
- package/index.ts +429 -86
- package/package.json +2 -1
- package/update.ts +87 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
# Text & Display Components
|
|
2
|
+
|
|
3
|
+
Components for displaying text content in OpenTUI.
|
|
4
|
+
|
|
5
|
+
## Text Component
|
|
6
|
+
|
|
7
|
+
The primary component for displaying styled text.
|
|
8
|
+
|
|
9
|
+
### Basic Usage
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// React/Solid
|
|
13
|
+
<text>Hello, World!</text>
|
|
14
|
+
|
|
15
|
+
// With content prop
|
|
16
|
+
<text content="Hello, World!" />
|
|
17
|
+
|
|
18
|
+
// Core
|
|
19
|
+
const text = new TextRenderable(renderer, {
|
|
20
|
+
id: "greeting",
|
|
21
|
+
content: "Hello, World!",
|
|
22
|
+
})
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Styling (React/Solid)
|
|
26
|
+
|
|
27
|
+
For React and Solid, use **nested modifier tags** for text styling:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
<text fg="#FFFFFF" bg="#000000">
|
|
31
|
+
<strong>Bold</strong>, <em>italic</em>, and <u>underlined</u>
|
|
32
|
+
</text>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> **Important**: Do NOT use `bold`, `italic`, `underline`, `dim`, `strikethrough` as props on `<text>` — they don't work. Always use nested tags like `<strong>`, `<em>`, `<u>`, or `<span>` with styling.
|
|
36
|
+
|
|
37
|
+
### Styling (Core) - Text Attributes
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { TextRenderable, TextAttributes } from "@opentui/core"
|
|
41
|
+
|
|
42
|
+
const text = new TextRenderable(renderer, {
|
|
43
|
+
content: "Styled",
|
|
44
|
+
attributes: TextAttributes.BOLD | TextAttributes.UNDERLINE,
|
|
45
|
+
})
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Available attributes:**
|
|
49
|
+
- `TextAttributes.BOLD`
|
|
50
|
+
- `TextAttributes.DIM`
|
|
51
|
+
- `TextAttributes.ITALIC`
|
|
52
|
+
- `TextAttributes.UNDERLINE`
|
|
53
|
+
- `TextAttributes.BLINK`
|
|
54
|
+
- `TextAttributes.INVERSE`
|
|
55
|
+
- `TextAttributes.HIDDEN`
|
|
56
|
+
- `TextAttributes.STRIKETHROUGH`
|
|
57
|
+
|
|
58
|
+
### Text Selection
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<text selectable>
|
|
62
|
+
This text can be selected by the user
|
|
63
|
+
</text>
|
|
64
|
+
|
|
65
|
+
<text selectable={false}>
|
|
66
|
+
This text cannot be selected
|
|
67
|
+
</text>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Text Modifiers
|
|
71
|
+
|
|
72
|
+
Inline styling elements that must be used inside `<text>`:
|
|
73
|
+
|
|
74
|
+
### Span
|
|
75
|
+
|
|
76
|
+
Inline styled text:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<text>
|
|
80
|
+
Normal text with <span fg="red">red text</span> inline
|
|
81
|
+
</text>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Bold/Strong
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
<text>
|
|
88
|
+
<strong>Bold text</strong>
|
|
89
|
+
<b>Also bold</b>
|
|
90
|
+
</text>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Italic/Emphasis
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
<text>
|
|
97
|
+
<em>Italic text</em>
|
|
98
|
+
<i>Also italic</i>
|
|
99
|
+
</text>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Underline
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
<text>
|
|
106
|
+
<u>Underlined text</u>
|
|
107
|
+
</text>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Line Break
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
<text>
|
|
114
|
+
Line one
|
|
115
|
+
<br />
|
|
116
|
+
Line two
|
|
117
|
+
</text>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Link
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
<text>
|
|
124
|
+
Visit <a href="https://example.com">our website</a>
|
|
125
|
+
</text>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Combined Modifiers
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
<text>
|
|
132
|
+
<span fg="#00FF00">
|
|
133
|
+
<strong>Bold green</strong>
|
|
134
|
+
</span>
|
|
135
|
+
and
|
|
136
|
+
<span fg="#FF0000">
|
|
137
|
+
<em><u>italic underlined red</u></em>
|
|
138
|
+
</span>
|
|
139
|
+
</text>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Styled Text Template (Core)
|
|
143
|
+
|
|
144
|
+
The `t` template literal for complex styling:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import { t, bold, italic, underline, fg, bg, dim } from "@opentui/core"
|
|
148
|
+
|
|
149
|
+
const styled = t`
|
|
150
|
+
${bold("Bold")} and ${italic("italic")} text.
|
|
151
|
+
${fg("#FF0000")("Red text")} with ${bg("#0000FF")("blue background")}.
|
|
152
|
+
${dim("Dimmed")} and ${underline("underlined")}.
|
|
153
|
+
`
|
|
154
|
+
|
|
155
|
+
const text = new TextRenderable(renderer, {
|
|
156
|
+
content: styled,
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Style Functions
|
|
161
|
+
|
|
162
|
+
| Function | Description |
|
|
163
|
+
|----------|-------------|
|
|
164
|
+
| `bold(text)` | Bold text |
|
|
165
|
+
| `italic(text)` | Italic text |
|
|
166
|
+
| `underline(text)` | Underlined text |
|
|
167
|
+
| `dim(text)` | Dimmed text |
|
|
168
|
+
| `strikethrough(text)` | Strikethrough text |
|
|
169
|
+
| `fg(color)(text)` | Set foreground color |
|
|
170
|
+
| `bg(color)(text)` | Set background color |
|
|
171
|
+
|
|
172
|
+
## ASCII Font Component
|
|
173
|
+
|
|
174
|
+
Display large ASCII art text banners.
|
|
175
|
+
|
|
176
|
+
### Basic Usage
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
// React
|
|
180
|
+
<ascii-font text="TITLE" font="tiny" />
|
|
181
|
+
|
|
182
|
+
// Solid
|
|
183
|
+
<ascii_font text="TITLE" font="tiny" />
|
|
184
|
+
|
|
185
|
+
// Core
|
|
186
|
+
const title = new ASCIIFontRenderable(renderer, {
|
|
187
|
+
id: "title",
|
|
188
|
+
text: "TITLE",
|
|
189
|
+
font: "tiny",
|
|
190
|
+
})
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Available Fonts
|
|
194
|
+
|
|
195
|
+
| Font | Description |
|
|
196
|
+
|------|-------------|
|
|
197
|
+
| `tiny` | Compact ASCII font |
|
|
198
|
+
| `block` | Block-style letters |
|
|
199
|
+
| `slick` | Sleek modern style |
|
|
200
|
+
| `shade` | Shaded 3D effect |
|
|
201
|
+
|
|
202
|
+
### Styling
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
// React
|
|
206
|
+
<ascii-font
|
|
207
|
+
text="HELLO"
|
|
208
|
+
font="block"
|
|
209
|
+
color="#00FF00"
|
|
210
|
+
/>
|
|
211
|
+
|
|
212
|
+
// Core
|
|
213
|
+
import { RGBA } from "@opentui/core"
|
|
214
|
+
|
|
215
|
+
const title = new ASCIIFontRenderable(renderer, {
|
|
216
|
+
text: "HELLO",
|
|
217
|
+
font: "block",
|
|
218
|
+
color: RGBA.fromHex("#00FF00"),
|
|
219
|
+
})
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Example Output
|
|
223
|
+
|
|
224
|
+
```
|
|
225
|
+
Font: tiny
|
|
226
|
+
╭─╮╭─╮╭─╮╭╮╭╮╭─╮╶╮╶ ╶╮
|
|
227
|
+
│ ││─┘├┤ │╰╯││ │ │
|
|
228
|
+
╰─╯╵ ╰─╯╵ ╵╰─╯╶╯╶╰─╯
|
|
229
|
+
|
|
230
|
+
Font: block
|
|
231
|
+
█▀▀█ █▀▀█ █▀▀ █▀▀▄
|
|
232
|
+
█ █ █▀▀▀ █▀▀ █ █
|
|
233
|
+
▀▀▀▀ ▀ ▀▀▀ ▀ ▀
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Colors
|
|
237
|
+
|
|
238
|
+
### Color Formats
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
// Hex colors
|
|
242
|
+
<text fg="#FF0000">Red</text>
|
|
243
|
+
<text fg="#F00">Short hex</text>
|
|
244
|
+
|
|
245
|
+
// Named colors
|
|
246
|
+
<text fg="red">Red</text>
|
|
247
|
+
<text fg="blue">Blue</text>
|
|
248
|
+
|
|
249
|
+
// Transparent
|
|
250
|
+
<text bg="transparent">No background</text>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### RGBA Class
|
|
254
|
+
|
|
255
|
+
The `RGBA` class from `@opentui/core` can be used in **all frameworks** (Core, React, Solid) for programmatic color manipulation:
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { RGBA } from "@opentui/core"
|
|
259
|
+
|
|
260
|
+
// From hex string (most common)
|
|
261
|
+
const red = RGBA.fromHex("#FF0000")
|
|
262
|
+
const shortHex = RGBA.fromHex("#F00") // Short form supported
|
|
263
|
+
|
|
264
|
+
// From integers (0-255 range for each channel)
|
|
265
|
+
const green = RGBA.fromInts(0, 255, 0, 255) // r, g, b, a
|
|
266
|
+
const semiGreen = RGBA.fromInts(0, 255, 0, 128) // 50% transparent
|
|
267
|
+
|
|
268
|
+
// From normalized floats (0.0-1.0 range)
|
|
269
|
+
const blue = RGBA.fromValues(0.0, 0.0, 1.0, 1.0) // r, g, b, a
|
|
270
|
+
const overlay = RGBA.fromValues(0.1, 0.1, 0.1, 0.7) // Dark semi-transparent
|
|
271
|
+
|
|
272
|
+
// Common use cases
|
|
273
|
+
const backgroundColor = RGBA.fromHex("#1a1a2e")
|
|
274
|
+
const textColor = RGBA.fromHex("#FFFFFF")
|
|
275
|
+
const borderColor = RGBA.fromInts(122, 162, 247, 255) // Tokyo Night blue
|
|
276
|
+
const shadowColor = RGBA.fromValues(0.0, 0.0, 0.0, 0.5) // 50% black
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**When to use each method:**
|
|
280
|
+
- `fromHex()` - When working with design specs or CSS colors
|
|
281
|
+
- `fromInts()` - When you have 8-bit color values (0-255)
|
|
282
|
+
- `fromValues()` - When doing color math or interpolation (normalized 0.0-1.0)
|
|
283
|
+
|
|
284
|
+
### Using RGBA in React/Solid
|
|
285
|
+
|
|
286
|
+
```tsx
|
|
287
|
+
// React or Solid - RGBA works with color props
|
|
288
|
+
import { RGBA } from "@opentui/core"
|
|
289
|
+
|
|
290
|
+
const primaryColor = RGBA.fromHex("#7aa2f7")
|
|
291
|
+
|
|
292
|
+
function MyComponent() {
|
|
293
|
+
return (
|
|
294
|
+
<box backgroundColor={primaryColor} borderColor={primaryColor}>
|
|
295
|
+
<text fg={RGBA.fromHex("#c0caf5")}>Styled with RGBA</text>
|
|
296
|
+
</box>
|
|
297
|
+
)
|
|
298
|
+
}
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Most props that accept color strings (`"#FF0000"`, `"red"`) also accept `RGBA` objects directly.
|
|
302
|
+
|
|
303
|
+
## Text Wrapping
|
|
304
|
+
|
|
305
|
+
Text wraps based on parent container:
|
|
306
|
+
|
|
307
|
+
```tsx
|
|
308
|
+
<box width={40}>
|
|
309
|
+
<text>
|
|
310
|
+
This long text will wrap when it reaches the edge of the
|
|
311
|
+
40-character wide parent container.
|
|
312
|
+
</text>
|
|
313
|
+
</box>
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Dynamic Content
|
|
317
|
+
|
|
318
|
+
### React
|
|
319
|
+
|
|
320
|
+
```tsx
|
|
321
|
+
function Counter() {
|
|
322
|
+
const [count, setCount] = useState(0)
|
|
323
|
+
return <text>Count: {count}</text>
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### Solid
|
|
328
|
+
|
|
329
|
+
```tsx
|
|
330
|
+
function Counter() {
|
|
331
|
+
const [count, setCount] = createSignal(0)
|
|
332
|
+
return <text>Count: {count()}</text>
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### Core
|
|
337
|
+
|
|
338
|
+
```typescript
|
|
339
|
+
const text = new TextRenderable(renderer, {
|
|
340
|
+
id: "counter",
|
|
341
|
+
content: "Count: 0",
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
// Update later
|
|
345
|
+
text.setContent("Count: 1")
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
## Gotchas
|
|
349
|
+
|
|
350
|
+
### Text Modifiers Outside Text
|
|
351
|
+
|
|
352
|
+
```tsx
|
|
353
|
+
// WRONG - modifiers only work inside <text>
|
|
354
|
+
<box>
|
|
355
|
+
<strong>Won't work</strong>
|
|
356
|
+
</box>
|
|
357
|
+
|
|
358
|
+
// CORRECT
|
|
359
|
+
<box>
|
|
360
|
+
<text>
|
|
361
|
+
<strong>This works</strong>
|
|
362
|
+
</text>
|
|
363
|
+
</box>
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### Empty Text
|
|
367
|
+
|
|
368
|
+
```tsx
|
|
369
|
+
// May cause layout issues
|
|
370
|
+
<text></text>
|
|
371
|
+
|
|
372
|
+
// Better - use space or conditional
|
|
373
|
+
<text>{content || " "}</text>
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Color Format
|
|
377
|
+
|
|
378
|
+
```tsx
|
|
379
|
+
// WRONG
|
|
380
|
+
<text fg="FF0000">Missing #</text>
|
|
381
|
+
|
|
382
|
+
// CORRECT
|
|
383
|
+
<text fg="#FF0000">With #</text>
|
|
384
|
+
```
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# OpenTUI Core (@opentui/core)
|
|
2
|
+
|
|
3
|
+
The foundational library for building terminal user interfaces. Provides an imperative API with all primitives, giving you maximum control over rendering, state, and behavior.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
OpenTUI Core runs on Bun with native Zig bindings for performance-critical operations:
|
|
8
|
+
- **Renderer**: Manages terminal output, input events, and the rendering loop
|
|
9
|
+
- **Renderables**: Hierarchical UI building blocks with Yoga layout
|
|
10
|
+
- **Constructs**: Declarative wrappers for composing Renderables
|
|
11
|
+
- **FrameBuffer**: Low-level 2D rendering surface for custom graphics
|
|
12
|
+
|
|
13
|
+
## When to Use Core
|
|
14
|
+
|
|
15
|
+
Use the core imperative API when:
|
|
16
|
+
- Building a library or framework on top of OpenTUI
|
|
17
|
+
- Need maximum control over rendering and state
|
|
18
|
+
- Want smallest possible bundle size (no React/Solid runtime)
|
|
19
|
+
- Building performance-critical applications
|
|
20
|
+
- Integrating with existing imperative codebases
|
|
21
|
+
|
|
22
|
+
## When NOT to Use Core
|
|
23
|
+
|
|
24
|
+
| Scenario | Use Instead |
|
|
25
|
+
|----------|-------------|
|
|
26
|
+
| Familiar with React patterns | `@opentui/react` |
|
|
27
|
+
| Want fine-grained reactivity | `@opentui/solid` |
|
|
28
|
+
| Building typical applications | React or Solid reconciler |
|
|
29
|
+
| Rapid prototyping | React or Solid reconciler |
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
### Using create-tui (Recommended)
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bunx create-tui@latest -t core my-app
|
|
37
|
+
cd my-app
|
|
38
|
+
bun run src/index.ts
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The CLI creates the `my-app` directory for you - it must **not already exist**.
|
|
42
|
+
|
|
43
|
+
**Agent guidance**: Always use autonomous mode with `-t <template>` flag. Never use interactive mode (`bunx create-tui@latest my-app` without `-t`) as it requires user prompts that agents cannot respond to.
|
|
44
|
+
|
|
45
|
+
### Manual Setup
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
mkdir my-tui && cd my-tui
|
|
49
|
+
bun init
|
|
50
|
+
bun install @opentui/core
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
import { createCliRenderer, TextRenderable, BoxRenderable } from "@opentui/core"
|
|
55
|
+
|
|
56
|
+
const renderer = await createCliRenderer()
|
|
57
|
+
|
|
58
|
+
// Create a box container
|
|
59
|
+
const container = new BoxRenderable(renderer, {
|
|
60
|
+
id: "container",
|
|
61
|
+
width: 40,
|
|
62
|
+
height: 10,
|
|
63
|
+
border: true,
|
|
64
|
+
borderStyle: "rounded",
|
|
65
|
+
padding: 1,
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
// Create text inside the box
|
|
69
|
+
const greeting = new TextRenderable(renderer, {
|
|
70
|
+
id: "greeting",
|
|
71
|
+
content: "Hello, OpenTUI!",
|
|
72
|
+
fg: "#00FF00",
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
// Compose the tree
|
|
76
|
+
container.add(greeting)
|
|
77
|
+
renderer.root.add(container)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Core Concepts
|
|
81
|
+
|
|
82
|
+
### Renderer
|
|
83
|
+
|
|
84
|
+
The `CliRenderer` orchestrates everything:
|
|
85
|
+
- Manages the terminal viewport and alternate screen
|
|
86
|
+
- Handles input events (keyboard, mouse, paste)
|
|
87
|
+
- Runs the rendering loop (configurable FPS)
|
|
88
|
+
- Provides the root node for the renderable tree
|
|
89
|
+
|
|
90
|
+
### Renderables vs Constructs
|
|
91
|
+
|
|
92
|
+
| Renderables (Imperative) | Constructs (Declarative) |
|
|
93
|
+
|--------------------------|--------------------------|
|
|
94
|
+
| `new TextRenderable(renderer, {...})` | `Text({...})` |
|
|
95
|
+
| Requires renderer at creation | Creates VNode, instantiated later |
|
|
96
|
+
| Direct mutation via methods | Chained calls recorded, replayed on instantiation |
|
|
97
|
+
| Full control | Cleaner composition |
|
|
98
|
+
|
|
99
|
+
### Storage Options
|
|
100
|
+
|
|
101
|
+
Renderables can be composed in two ways:
|
|
102
|
+
1. **Imperative**: Create instances, call `.add()` to compose
|
|
103
|
+
2. **Declarative (Constructs)**: Create VNodes, pass children as arguments
|
|
104
|
+
|
|
105
|
+
## Essential Commands
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
bun install @opentui/core # Install
|
|
109
|
+
bun run src/index.ts # Run directly (no build needed)
|
|
110
|
+
bun test # Run tests
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Runtime Requirements
|
|
114
|
+
|
|
115
|
+
OpenTUI runs on Bun and uses Zig for native builds.
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# Package management
|
|
119
|
+
bun install @opentui/core
|
|
120
|
+
|
|
121
|
+
# Running
|
|
122
|
+
bun run src/index.ts
|
|
123
|
+
bun test
|
|
124
|
+
|
|
125
|
+
# Building (only needed for native code changes)
|
|
126
|
+
bun run build
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Zig** is required for building native components.
|
|
130
|
+
|
|
131
|
+
## In This Reference
|
|
132
|
+
|
|
133
|
+
- [Configuration](./configuration.md) - Renderer options, environment variables
|
|
134
|
+
- [API](./api.md) - Renderer, Renderables, types, utilities
|
|
135
|
+
- [Patterns](./patterns.md) - Composition, events, state management
|
|
136
|
+
- [Gotchas](./gotchas.md) - Common issues, debugging, limitations
|
|
137
|
+
|
|
138
|
+
## See Also
|
|
139
|
+
|
|
140
|
+
- [React](../react/REFERENCE.md) - React reconciler for declarative TUI
|
|
141
|
+
- [Solid](../solid/REFERENCE.md) - Solid reconciler for declarative TUI
|
|
142
|
+
- [Layout](../layout/REFERENCE.md) - Yoga/Flexbox layout system
|
|
143
|
+
- [Components](../components/REFERENCE.md) - Component reference by category
|
|
144
|
+
- [Keyboard](../keyboard/REFERENCE.md) - Input handling and shortcuts
|
|
145
|
+
- [Testing](../testing/REFERENCE.md) - Test renderer and snapshots
|