themes

package
v0.88.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package themes stores user-imported color themes and exposes them to the UI.

Index

Constants

View Source
const (
	ThemeSettingKey        = "appearance.theme"
	FollowSystemSettingKey = "appearance.followSystem"
	// SystemID selects the bundled theme of the scheme the OS asks for.
	SystemID = "system"
)

The settings the windows read the selection from, global ones. A theme key never written reads "", which is System.

View Source
const (
	OriginBundled = "bundled"
	OriginCustom  = "custom"
	SchemeLight   = "light"
	SchemeDark    = "dark"

	// FormatVersion is the newest theme file format this lich reads. A file
	// that omits it is format 1; bump it only for a change an older lich would
	// misread, so that lich refuses the file by name instead of by a token.
	FormatVersion = 1
)
View Source
const SchemaPath = "themes/lich-theme.schema.json"

SchemaPath is where the generated schema lives in this repository, and the tail of the raw URL a theme author points "$schema" at.

Variables

This section is empty.

Functions

func Schema

func Schema() ([]byte, error)

Schema renders the JSON Schema a theme file is checked against in an editor. It is generated from the same token sets and patterns validateTheme reads, so a token added to the bundled theme cannot leave the schema behind; the test beside this file fails when the checked-in copy has drifted.

Types

type BrokenTheme

type BrokenTheme = api.BrokenTheme

The wire shapes live in api, the one definition the window and the CLI read too.

type GitInstallResult

type GitInstallResult = api.ThemeGitResult

type ImportResult

type ImportResult = api.ThemeImportResult

The wire shapes live in api, the one definition the window and the CLI read too.

type Manifest

type Manifest struct {
	FormatVersion int    `json:"formatVersion,omitempty"`
	Name          string `json:"name"`
	Version       string `json:"version"`
	// MinLichVersion is the oldest lich release the pack's themes are written
	// for, so an older lich refuses the pack by name before it trips on a token.
	MinLichVersion string `json:"minLichVersion,omitempty"`
}

Manifest is the versioning stamp of a theme repository. It deliberately does not list the themes: id and name already live inside each theme file, and a second copy here would be a list to keep in sync for no gain.

type SelectOptions

type SelectOptions = api.SelectThemeOptions

type Selection

type Selection = api.ThemeSelection

type Service

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

Service reads bundled themes plus user-imported themes.

func New

func New(lichVersion string, settings Settings, emit func(name string, data any)) *Service

New returns a theme service rooted under lich's config directory, checking theme packs against lichVersion, the running build's version. It stores the selection in settings and reports a change to it through emit.

func NewInDir

func NewInDir(dir string) *Service

NewInDir returns a theme service rooted at dir. It is used by tests.

func (*Service) Import

Import reads a picked JSON file and installs it as a custom theme. An existing id is reported without changing it unless opts.Overwrite is true.

func (*Service) InstallFromGit

func (s *Service) InstallFromGit(_ context.Context, opts api.InstallThemesOptions) (GitInstallResult, error)

InstallFromGit clones a theme repository and installs every theme in it. The pack is validated as a whole before anything is written, so one unreadable or invalid theme fails the whole repository. The writing is per file, though: a disk error partway through leaves the themes already written in place.

func (*Service) List

func (s *Service) List(_ context.Context, _ api.None) ([]Theme, error)

List returns bundled themes followed by custom themes sorted by name.

func (*Service) ListBroken

func (s *Service) ListBroken(_ context.Context, _ api.None) ([]BrokenTheme, error)

ListBroken returns the stored custom themes List leaves out, sorted by id.

func (*Service) Remove

func (s *Service) Remove(_ context.Context, opts api.RemoveThemeOptions) (api.None, error)

Remove deletes a custom theme. Bundled and reserved ids cannot be removed.

func (*Service) SaveTemplate

func (s *Service) SaveTemplate(_ context.Context, opts api.SaveThemeTemplateOptions) (api.None, error)

SaveTemplate writes the bundled starter theme to a destination the user picked. The save dialog already confirmed replacing an existing file.

func (*Service) Select

func (s *Service) Select(ctx context.Context, opts SelectOptions) (api.None, error)

Select stores opts.ID, System or a theme List returns, as the selection.

func (*Service) Selection

func (s *Service) Selection(ctx context.Context, _ api.None) (Selection, error)

Selection reads the stored selection.

func (*Service) SetFollowSystem

func (s *Service) SetFollowSystem(_ context.Context, opts api.FollowSystemOptions) (api.None, error)

SetFollowSystem stores whether the window follows the OS to the selected theme's pair.

func (*Service) UpdateFromGit

func (s *Service) UpdateFromGit(_ context.Context, opts api.UpdateThemeOptions) (GitInstallResult, error)

UpdateFromGit re-clones the repository a theme came from and installs it again when the manifest carries a newer version. The whole pack moves together — the repository, not the single theme, is what is versioned.

type Settings

type Settings interface {
	GetSetting(_ context.Context, opts api.GetSettingOptions) (string, error)
	SetSetting(_ context.Context, opts api.SetSettingOptions) (api.None, error)
}

Settings is where the selection is stored: the store's global settings.

type Source

type Source = api.ThemeSource

The wire shapes live in api, the one definition the window and the CLI read too.

type Syntax

type Syntax = api.Syntax

type SyntaxStyle

type SyntaxStyle = api.SyntaxStyle

type Theme

type Theme = api.Theme

The wire shapes live in api, the one definition the window and the CLI read too.

Jump to

Keyboard shortcuts

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