PyModel/pythinker-code / .agents/skills/opentui
opentui
VerifiedBuild terminal UIs with OpenTUI. Covers core, components, audio, keymaps, React, Solid, plugins, testing, standalone executables, QR encoding, SSH, and Three.js WebGPU.
docs/components/line-number.mdx
View on GitHub---
title: Line numbers
description: Line number gutter for code and text renderables
order: 12
---
# Line numbers
Add a line number gutter to renderables that provide line info, such as `CodeRenderable` and text editor components.
## Basic usage
### Renderable API
```typescript
import {
CodeRenderable,
LineNumberRenderable,
ScrollBoxRenderable,
SyntaxStyle,
RGBA,
createCliRenderer,
} from "@opentui/core"
const renderer = await createCliRenderer()
const syntaxStyle = SyntaxStyle.fromStyles({
default: { fg: RGBA.fromHex("#E6EDF3") },
})
const code = new CodeRenderable(renderer, {
id: "code",
content: "const x = 1\nconst y = 2\n",
filetype: "typescript",
syntaxStyle,
width: "100%",
})
const lineNumbers = new LineNumberRenderable(renderer, {
id: "code-lines",
target: code,
minWidth: 3,
paddingRight: 1,
fg: "#6b7280",
bg: "#161b22",
})
const scrollbox = new ScrollBoxRenderable(renderer, {
id: "scrollbox",
width: 70,
height: 18,
})
scrollbox.add(lineNumbers)
renderer.root.add(scrollbox)
```
## Line signs and colors
Set a single background for a line, or split gutter and content colors separately with a `LineColorConfig` object:
```typescript
// Shorthand: applies to both gutter and content
lineNumbers.setLineColor(3, "#2b6cb0")
// Split config: different gutter vs content background
lineNumbers.setLineColor(3, {
gutter: "#2b6cb0",
content: "#1f2937",
})
lineNumbers.setLineSign(3, { before: ">", beforeColor: "#2b6cb0" })
// Clear
lineNumbers.clearLineColor(3)
lineNumbers.clearLineSign(3)
```
## Theming the gutter
Gutter text and background colors accept assignments after construction:
```typescript
lineNumbers.fg = "#6b7280"
lineNumbers.bg = "#161b22"
```
Assign `undefined` to reset to the defaults (`#888888` foreground, transparent background).
## Construct API
> Not available yet. Use `LineNumberRenderable` for now.
## Properties
| Property | Type | Default | Description |
| ------------------ | ------------------------------------------------ | ----------- | ------------------------------ |
| `target` | `Renderable & LineInfoProvider` | - | Target renderable to number |
| `fg` | `string` or `RGBA` | `#888888` | Gutter text color |
| `bg` | `string` or `RGBA` | transparent | Gutter background color |
| `minWidth` | `number` | `3` | Minimum gutter width |
| `paddingRight` | `number` | `1` | Right padding for gutter |
| `lineColors` | `Map<number, string \| RGBA \| LineColorConfig>` | - | Per-line background colors |
| `lineSigns` | `Map<number, LineSign>` | - | Per-line signs (before/after) |
| `lineNumberOffset` | `number` | `0` | Offset for line numbering |
| `hideLineNumbers` | `Set<number>` | - | Lines to hide numbers for |
| `lineNumbers` | `Map<number, number>` | - | Override line numbers per line |
| `showLineNumbers` | `boolean` | `true` | Toggle gutter visibility |
## Methods
| Method | Description |
| ---------------------- | ------------------------------------- |
| `setLineColor()` | Set a background color for a line |
| `clearLineColor()` | Clear a line background color |
| `setLineSign()` | Set a sign before/after a line number |
| `clearLineSign()` | Clear a line sign |
| `setLineNumbers()` | Override multiple line numbers |
| `setHideLineNumbers()` | Hide line numbers for specific lines |
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |