Documentation
¶
Overview ¶
Package code provides retained, read-only syntax highlighting for MyGo text, ported from the code view of the onevra component library (MIT). Parse outside the frame builder and retain the document until the source changes. Render joins its parent's selection; call Selectable on the returned element for an independent code view. Applications own scrolling and background work.
doc := code.Parse(source, "go") doc.Render(c).Padding(12)
Index ¶
Constants ¶
const ( MaxHighlightBytes = 64 * 1024 MaxHighlightRuns = 4096 )
Highlighting limits bound lexer input and retained styling. Larger or more fragmented inputs remain readable as plain text; no source is truncated.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
Document is an immutable highlighted source, which several views can share. Its zero value is empty. It holds no UI handles and no global source cache. Both palettes are prepared once, so Render performs neither tokenization nor span allocation on theme changes.
func Parse ¶
Parse highlights source in the named language, case-insensitively, accepting the aliases Chroma does (js, ts, py, sh and so on). Empty or unknown languages, invalid UTF-8, lexer failures and inputs beyond the limits use plain text. It never guesses the language, reads files or starts goroutines. Source bytes, tabs and line endings are preserved. Parsing is safe outside the UI thread; it is synchronous and makes no promise about its time for regex-based lexers.
func (*Document) Highlighted ¶
Highlighted reports whether tokenization completed within the limits.