Documentation
¶
Overview ¶
Package codeview renders a single block of source code with optional line numbers, gutter highlights, and a small built-in tokenizer that tints keywords, strings, numbers, and comments.
The package is stateless. Callers build a Block, call Render, and place the result inside their own View(). Compose Block.Line with .Highlight, .Underline, or .Gutter to mark up specific rows (current cursor line, diff hunks, failing-test stack frame, etc.).
The tokenizer is intentionally tiny. It is a "good enough" lexer for quick reads: Go, JavaScript/TypeScript, Python, Rust, JSON, Bash, and any language that uses // or # line comments and double-quoted strings. Production-quality syntax highlighting belongs in a separate component that wraps a real lexer (chroma, tree-sitter) — codeview's bar is to make a peek-into-a-file surface readable inside an operator dashboard.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Block ¶
type Block struct {
Source string
Language Language
ShowGutter bool // render line-number gutter
StartLine int // 1-based line number for the first row; 0 means 1
Marks map[int]LineMark
MaxWidth int // 0 means no truncation; otherwise hard-wrap with ellipsis
}
Block is the input to Render. Mark a subset of lines via Marks; keys are 1-based line numbers matching the rendered gutter.
type Language ¶
type Language string
Language selects the tokenizer dialect. Unknown languages fall through to LangPlain which only highlights numbers and string literals.
