codeview

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package codeview composes the egui2 CodeViewJob primitive with the project's SQL, JSON, and Go highlighters into a small set of retained- holder builders. The three highlighters share the same shape — palette intern at init → run highlighter → emit one CodeViewJob.Section per span → Keep — so they live in one package.

Naming convention: Build* re-tokenises every call (use for dynamic strings); Prepare* is a documented alias for static / global content where the retained holder is constructed once and reused across frames.

The Go view additionally exposes BuildGoLines / PrepareGoLines, which render a byte slice covering a 1-based [firstLine, lastLine] window with a right-aligned line-number gutter. The line-window machinery is internally generic; SQL/JSON equivalents can be added when a caller needs them.

Index

Constants

This section is empty.

Variables

View Source
var PackageProps = packageprops.Props{
	WASMWASI:         packageprops.WASMBlocked,
	WASMJS:           packageprops.WASMBlocked,
	WASMFreestanding: packageprops.WASMCompiles,
}

PackageProps records this package's curated properties (ADR-0080). Seeded by `wasmsurvey props generate`; curate by hand, then `wasmsurvey props verify`.

Functions

func BuildGo

BuildGo highlights Go source and returns a retained CodeViewJob. Each call re-highlights; use PrepareGo for static snippets.

func BuildGoLines

func BuildGoLines(src string, firstLine int32, lastLine int32) typed.RetainedFffiHolderTyped[c.CodeViewJobS]

BuildGoLines highlights src and renders the byte slice covering 1-based lines [firstLine, lastLine] (inclusive) with a right-aligned line-number gutter prefixed to each line. The full source is parsed so AST refinement applies — spans that cross the window boundary are clipped at the edges.

firstLine/lastLine are clamped to the source's line range. An out-of-bounds window returns an empty retained holder.

func BuildJson

BuildJson highlights JSON and returns a retained CodeViewJob. Each call re-tokenises; use PrepareJson for static documents.

func BuildMarkdown

BuildMarkdown canonicalises and highlights markdown source, returning a retained CodeViewJob. Each call re-renders; use PrepareMarkdown for static documents.

IMPORTANT: the rendered text is a *canonical* form of the input, not the source verbatim. gofmt-style: lists become `-`, emphasis becomes `*` / `**`, frontmatter keys sort alphabetically, indented code blocks lose their 4-space marker. The text displayed in the CodeView is what this function returns, not what was passed in. See package markdownhighlight for the full canonicalisation rules.

func BuildSql

BuildSql highlights SQL and returns a retained CodeViewJob. Each call re-tokenises; use PrepareSql for static SQL.

func PrepareGo

PrepareGo is identical to BuildGo — use this name for static / global Go snippets where the retained holder is built once and reused across frames.

func PrepareGoLines

func PrepareGoLines(src string, firstLine int32, lastLine int32) typed.RetainedFffiHolderTyped[c.CodeViewJobS]

PrepareGoLines is identical to BuildGoLines — use this name for static / global slices so it is clear the retained holder is built once and reused across frames.

func PrepareJson

PrepareJson is identical to BuildJson — use this name for static / global documents where the retained holder is built once and reused across frames.

func PrepareMarkdown

func PrepareMarkdown(src string) typed.RetainedFffiHolderTyped[c.CodeViewJobS]

PrepareMarkdown is identical to BuildMarkdown — use this name for static / global markdown where the retained holder is built once and reused across frames.

func PrepareSql

PrepareSql is identical to BuildSql — use this name for static / global SQL where the retained holder is built once and reused across frames.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL