syntax

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package syntax highlights source files for display in the TUI source pane.

A curated Chroma tokeniser is compiled in only for the default build. The `lite` build tag swaps in a small built-in highlighter (highlight_lite.go), dropping Chroma while keeping basic source colours.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HighlightLines

func HighlightLines(filename string, src []string, themeName string) []string

HighlightLines returns ANSI-styled source lines without using a cache. It uses the minimal highlighter when Chroma cannot identify or tokenise the file.

func StyleEntryToLipgloss

func StyleEntryToLipgloss(e chroma.StyleEntry, fallbackFG string) lipgloss.Style

StyleEntryToLipgloss converts the subset of Chroma style attributes exex renders. Tokens a style leaves uncoloured take fallbackFG (see theme.ForegroundFor), so a style that only highlights keywords still draws its body text in the right colour instead of the terminal default.

Both the source pane (this package) and the disassembly pane (internal/ui) need it, and each had its own byte-identical copy.

Types

type Highlighter

type Highlighter struct {
	// contains filtered or unexported fields
}

Highlighter tokenises source files and caches recent per-line ANSI output.

func NewHighlighter

func NewHighlighter(theme string) *Highlighter

NewHighlighter creates a cached source highlighter. An empty theme selects the project default.

func (*Highlighter) Highlight

func (h *Highlighter) Highlight(filename string, src []string) []string

Highlight returns ANSI-styled source lines for filename, using a per-filename cache. A nil receiver falls back to one-shot highlighting with the default theme.

Jump to

Keyboard shortcuts

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