Documentation
¶
Overview ¶
Package themes stores user-imported color themes and exposes them to the UI.
Index ¶
- Constants
- func Schema() ([]byte, error)
- type BrokenTheme
- type GitInstallResult
- type ImportResult
- type Manifest
- type SelectOptions
- type Selection
- type Service
- func (s *Service) Import(_ context.Context, opts api.ImportThemeOptions) (ImportResult, error)
- func (s *Service) InstallFromGit(_ context.Context, opts api.InstallThemesOptions) (GitInstallResult, error)
- func (s *Service) List(_ context.Context, _ api.None) ([]Theme, error)
- func (s *Service) ListBroken(_ context.Context, _ api.None) ([]BrokenTheme, error)
- func (s *Service) Remove(_ context.Context, opts api.RemoveThemeOptions) (api.None, error)
- func (s *Service) SaveTemplate(_ context.Context, opts api.SaveThemeTemplateOptions) (api.None, error)
- func (s *Service) Select(ctx context.Context, opts SelectOptions) (api.None, error)
- func (s *Service) Selection(ctx context.Context, _ api.None) (Selection, error)
- func (s *Service) SetFollowSystem(_ context.Context, opts api.FollowSystemOptions) (api.None, error)
- func (s *Service) UpdateFromGit(_ context.Context, opts api.UpdateThemeOptions) (GitInstallResult, error)
- type Settings
- type Source
- type Syntax
- type SyntaxStyle
- type Theme
Constants ¶
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.
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 )
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 ¶
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 ¶
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 (*Service) Import ¶
func (s *Service) Import(_ context.Context, opts api.ImportThemeOptions) (ImportResult, error)
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) ListBroken ¶
ListBroken returns the stored custom themes List leaves out, sorted by id.
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) 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 SyntaxStyle ¶
type SyntaxStyle = api.SyntaxStyle