diff --git a/README.md b/README.md index 22cd113..3c80d66 100644 --- a/README.md +++ b/README.md @@ -405,8 +405,11 @@ Then link to it with `/portfolio#skills` - the page will scroll to that section src/lib/components/ ├── TerminalTUI.svelte # Main terminal container └── tui/ - ├── types.ts # TypeScript types + ├── types.ts # TypeScript types (TerminalLine, TerminalAPI, etc.) ├── utils.ts # Parsing & styling utilities + ├── terminal-api.ts # Terminal API factory for reactive control + ├── terminal-typing.ts # Typing animation engine + ├── terminal-keyboard.ts# Keyboard navigation handler ├── TuiHeader.svelte # Top status bar ├── TuiBody.svelte # Scrollable content area ├── TuiFooter.svelte # Bottom status bar @@ -419,6 +422,115 @@ src/lib/components/ └── TuiTooltip.svelte # Hover tooltip ``` +## Terminal API + +The `TerminalTUI` component exposes a reactive API for programmatic control via the `terminal` bindable prop. + +### Setup + +```svelte + + + +``` + +### API Methods + +#### Writing Lines +| Method | Description | +|--------|-------------| +| `terminal.write(line)` | Append a single line | +| `terminal.writeLines(lines)` | Append multiple lines | +| `terminal.clear()` | Remove all lines | +| `terminal.setLines(lines)` | Replace all lines | + +#### Updating Lines +| Method | Description | +|--------|-------------| +| `terminal.update(index, updates)` | Update line by index with partial changes | +| `terminal.updateContent(index, content)` | Update just the content of a line | +| `terminal.updateById(id, updates)` | Update line by its `id` property | + +#### Removing Lines +| Method | Description | +|--------|-------------| +| `terminal.remove(index)` | Remove line at index | +| `terminal.removeRange(start, count)` | Remove a range of lines | +| `terminal.removeById(id)` | Remove line by its `id` property | + +#### Inserting Lines +| Method | Description | +|--------|-------------| +| `terminal.insert(index, line)` | Insert line at a specific index | + +#### Reading State +| Method | Description | +|--------|-------------| +| `terminal.getLine(index)` | Get line at index | +| `terminal.getLines()` | Get all lines (copy) | +| `terminal.getLineCount()` | Get number of lines | +| `terminal.findById(id)` | Find index of line by id | +| `terminal.isAnimating()` | Check if typing animation is active | + +#### Navigation & Control +| Method | Description | +|--------|-------------| +| `terminal.scrollToBottom()` | Scroll to bottom of terminal | +| `terminal.scrollToLine(index)` | Scroll to specific line | +| `terminal.skip()` | Skip current typing animation | +| `terminal.restart()` | Restart typing animation from beginning | + +### Example: Dynamic Updates + +```svelte + + + + +``` + ## 3D Model Viewer The `ModelViewer` component provides an interactive Three.js viewer for `.glb` models. diff --git a/src/lib/components/TerminalTUI.svelte b/src/lib/components/TerminalTUI.svelte index 4047da4..8acd06a 100644 --- a/src/lib/components/TerminalTUI.svelte +++ b/src/lib/components/TerminalTUI.svelte @@ -1,17 +1,18 @@ - Components | {user.name} + Components | {user.displayname} diff --git a/src/routes/models/+page.svelte b/src/routes/models/+page.svelte index b752520..2bb7fd3 100644 --- a/src/routes/models/+page.svelte +++ b/src/routes/models/+page.svelte @@ -61,7 +61,7 @@ - 3D Models | {user.name} + 3D Models | {user.displayname} diff --git a/src/routes/projects/+page.svelte b/src/routes/projects/+page.svelte index 419821b..0343289 100644 --- a/src/routes/projects/+page.svelte +++ b/src/routes/projects/+page.svelte @@ -9,7 +9,7 @@ - Projects | {user.name} + Projects | {user.displayname}