syntax

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package syntax turns Chroma tokens into Scry-owned terminal styling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectLexer

func DetectLexer(path, oldPath, sample string) chroma.Lexer

DetectLexer selects a lexer by path, old path, content sample, then fallback.

func HighlightLine

func HighlightLine(path, oldPath, sample, body string) string

HighlightLine highlights one diff body without using a cache.

func Highlightable

func Highlightable(kind model.LineKind) bool

Highlightable reports whether syntax highlighting should apply to a diff line.

Types

type Cache

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

Cache owns memoized syntax rendering for loaded patches.

func NewCache

func NewCache(profiles ...terminal.ColorProfile) *Cache

NewCache creates an empty syntax cache.

func (*Cache) ForPatch

func (c *Cache) ForPatch(patch model.FilePatch, contentHash string) *LineCache

ForPatch returns the line cache keyed by path and PatchLoadState content hash.

type CacheKey

type CacheKey struct {
	Path        string
	ContentHash string
}

CacheKey identifies the highlighted line cache for one loaded patch.

type Highlighter

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

Highlighter wraps a coalesced Chroma lexer.

func NewHighlighter

func NewHighlighter(path, oldPath, sample string, profiles ...terminal.ColorProfile) *Highlighter

NewHighlighter creates a highlighter using Scry's lexer detection order.

func (*Highlighter) Highlight

func (h *Highlighter) Highlight(body string) string

Highlight renders body text with Scry-owned styles.

func (*Highlighter) HighlightSpan

func (h *Highlighter) HighlightSpan(body string, start, end int) string

HighlightSpan renders body text and reverses the provided raw byte span.

type LineCache

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

LineCache memoizes highlighted bodies by logical diff-line index.

func NewLineCache

func NewLineCache(path, oldPath, sample string, profiles ...terminal.ColorProfile) *LineCache

NewLineCache creates a per-patch line highlighter.

func (*LineCache) HighlightLine

func (lc *LineCache) HighlightLine(line int, body string) string

HighlightLine returns the cached highlighted body for a diff line.

func (*LineCache) HighlightLineSpan

func (lc *LineCache) HighlightLineSpan(line int, body string, start, end int) string

HighlightLineSpan highlights a transient search span without caching it.

Jump to

Keyboard shortcuts

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