# Code & Diff Components Components for displaying code with syntax highlighting and diffs in OpenTUI. ## Code Component Display syntax-highlighted code blocks. ### Basic Usage ```tsx // React // Solid // Core const codeBlock = new CodeRenderable(renderer, { id: "code", code: sourceCode, language: "typescript", }) ``` ### Supported Languages OpenTUI uses Tree-sitter for syntax highlighting. Common languages: - `typescript`, `javascript` - `python` - `rust` - `go` - `json` - `html`, `css` - `markdown` - `bash`, `shell` ### Styling ```tsx ``` ## Line Number Component Code display with line numbers, highlighting, and diagnostics. ### Basic Usage ```tsx // React // Solid (note underscore) // Core const codeView = new LineNumberRenderable(renderer, { id: "code-view", code: sourceCode, language: "typescript", }) ``` ### Line Number Options ```tsx // React // Solid ``` ### Line Highlighting Highlight specific lines: ```tsx // React // Solid ``` ### Diagnostics Show errors, warnings, and info on specific lines: ```tsx // React // Solid ``` **Diagnostic severity levels:** - `error` - Red indicator - `warning` - Yellow indicator - `info` - Blue indicator - `hint` - Gray indicator ### Diff Highlighting Show added/removed lines: ```tsx ``` ## Diff Component Unified or split diff viewer with syntax highlighting. ### Basic Usage ```tsx // React // Solid // Core const diffView = new DiffRenderable(renderer, { id: "diff", oldCode: originalCode, newCode: modifiedCode, language: "typescript", }) ``` ### Display Modes ```tsx // Unified diff (default) // Split/side-by-side diff ``` ### Options ```tsx ``` ### Styling ```tsx ``` ## Use Cases ### Code Editor ```tsx function CodeEditor() { const [code, setCode] = useState(`function hello() { console.log("Hello!"); }`) return ( editor.ts