Build(ctx, req) never opens FIFOs, sockets or devices (Kind=Special; U-P1-10), reads at most MaxBytes, keeps at most DirLimit directory entries and MaxLines text lines, and honours ctx in reads, tools and highlighting. pdftotext/pdfinfo/ffprobe run in their own process group with a 3 s timeout and are killed with their children. A chroma formatter writes foreground SGR only (no background, no regexp post-processing); the first HighlightLines (400) lines are highlighted, so 64 KiB of Go takes ~20 ms (was 190). Remote images are downloaded to an LRU cache only up to max_remote_image_bytes (N-P1-16); a 32-entry result cache avoids rebuilds. theme.ChromaStyle maps every built-in theme (U-P2); KindLabel fixes the inverted label (U-P2). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.2 KiB
Go
36 lines
1.2 KiB
Go
package theme
|
|
|
|
import "strings"
|
|
|
|
// chromaStyles maps every built-in theme to the closest chroma style
|
|
// (U-P2: the old table knew 7 of the themes and fell back to catppuccin).
|
|
var chromaStyles = map[string]string{
|
|
"catppuccin-mocha": "catppuccin-mocha",
|
|
"catppuccin-macchiato": "catppuccin-macchiato",
|
|
"catppuccin-lavender": "catppuccin-mocha",
|
|
"tokyo-night": "tokyonight-night",
|
|
"gruvbox-dark": "gruvbox",
|
|
"nord": "nord",
|
|
"one-dark": "onedark",
|
|
"everforest": "evergarden",
|
|
"github-dark": "github-dark",
|
|
"ayu-dark": "doom-one",
|
|
"breeze": "nordic",
|
|
"cyberpunk": "aura-theme-dark",
|
|
"dracula": "dracula",
|
|
"eldritch": "aura-theme-dark-soft",
|
|
"kanagawa": "tokyonight-storm",
|
|
"kanagawa-paper": "tokyonight-moon",
|
|
"rose-pine": "rose-pine",
|
|
"solarized-dark": "solarized-dark",
|
|
"vesper": "monokai",
|
|
}
|
|
|
|
// ChromaStyle returns the chroma style name for a theme (unknown themes get
|
|
// the default theme's style).
|
|
func ChromaStyle(theme string) string {
|
|
if s, ok := chromaStyles[strings.ToLower(strings.TrimSpace(theme))]; ok {
|
|
return s
|
|
}
|
|
return chromaStyles[builtInThemes[0]]
|
|
}
|