theme

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FontStyle

type FontStyle int8

FontStyle is a bitmask representing text decoration styles.

const (
	FontStyleNotSet        FontStyle = -1
	FontStyleNone          FontStyle = 0
	FontStyleItalic        FontStyle = 1
	FontStyleBold          FontStyle = 2
	FontStyleUnderline     FontStyle = 4
	FontStyleStrikethrough FontStyle = 8
)

func (FontStyle) Has

func (fs FontStyle) Has(flag FontStyle) bool

func (FontStyle) String

func (fs FontStyle) String() string

type Store

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

Store manages loading, caching, and retrieval of themes.

func NewStore

func NewStore(fsys fs.FS) *Store

NewStore creates a Store backed by the given filesystem. Pass nil for a registry-only store with no filesystem.

func (*Store) Get

func (s *Store) Get(name string) (*Theme, error)

Get returns a parsed theme by name, loading and caching it on first access.

func (*Store) LoadedThemes

func (s *Store) LoadedThemes() []string

LoadedThemes returns the names of all currently cached themes, sorted.

func (*Store) Register

func (s *Store) Register(name string, data []byte) error

Register adds raw theme JSON under the given name. Overwrites any previously registered or cached theme with the same name.

type Theme

type Theme struct {
	Name              string
	DisplayName       string
	Type              string // "dark" or "light"
	Colors            map[string]string
	TokenColors       []TokenColor
	DefaultForeground string
	DefaultBackground string
}

Theme represents a parsed VS Code color theme.

func Parse

func Parse(data []byte) (*Theme, error)

Parse parses a VS Code theme JSON file.

func (*Theme) Base

func (t *Theme) Base() TokenSettings

Base returns the default foreground/background as a TokenSettings.

func (*Theme) Match

func (t *Theme) Match(scopes []string) TokenSettings

Match resolves the style for a token with the given scope stack. scopes[0] is the root scope, scopes[len-1] is the most specific. Each property (foreground, background, fontStyle) is taken from the highest-scoring matching rule that defines it.

type TokenColor

type TokenColor struct {
	Scopes   []string
	Settings TokenSettings
	// contains filtered or unexported fields
}

TokenColor is a single rule mapping scope selectors to style settings.

type TokenSettings

type TokenSettings struct {
	Foreground string
	Background string
	FontStyle  FontStyle
}

TokenSettings holds style properties for a scope match.

Jump to

Keyboard shortcuts

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