Apps
Diff
# Diff — Side-by-side diff viewer
Two-column diff viewer: original (left) vs modified (right). Synchronized scrolling with color-coded lines and line numbers.
## Usage
Launch: `[tui/launch <panel> "diff" "apps/diff/src/diff.dft"]`
### Keys
| Key | Action |
|-----|--------|
| `j` / `down` | Scroll down |
| `k` / `up` | Scroll up |
| `page_down` | Page down |
| `page_up` | Page up |
| `g` / `home` | Go to top |
| `G` / `end` | Go to bottom |
### Line colors
| Color | Meaning |
|-------|---------|
| Green | Added line (right only) |
| Red | Removed line (left only) |
| Yellow/Orange | Changed line (modified content) |
| Cyan | Hunk header |
| Default | Unchanged context |
## Public RPC methods
Call via `[rpc <runtime-name> "method-name" args...]`:
| Method | Args | Description |
|--------|------|-------------|
| `load-diff` | `left-path right-path` | Load two files and diff them |
| `load-text` | `left-text right-text left-label right-label` | Diff two text strings |
| `clear` | — | Clear the diff view |
| `goto-line` | `line` | Scroll to a specific pair (1-based) |
| `reload` | — | Reload from current file paths |
| `get-state` | — | Return state as JSON |
| `get-pairs` | `start count` | Return a slice of pairs as JSON |
## Pub/sub topics
Publish to the diff panel's ID:
| Topic | Data | Description |
|-------|------|-------------|
| `diff/load` | JSON `{left-text, right-text, left-label?, right-label?}` | Load a diff |
| `diff/clear` | — | Clear the view |
| `diff/goto-line` | `"42"` | Scroll to pair |
## Integration
From another app (e.g., git):
set diff-id [tui/find-panel "diff"] if ($diff-id == 0) { set diff-id [tui/split :vertical] [tui/launch $diff-id "diff" "apps/diff/src/diff.dft"] } [rpc "diff" "load-diff" $original-file $modified-file] [tui/focus-id $diff-id]