Documentation
¶
Overview ¶
Package theme holds Omassh's colour palette and the styles derived from it.
Index ¶
Constants ¶
const DefaultName = "terminal"
DefaultName is the palette used when nothing else is chosen.
Variables ¶
var ( Text color.Color TextDim color.Color TextBrt color.Color Accent color.Color Green color.Color Yellow color.Color Red color.Color Magenta color.Color Border color.Color SelBg color.Color )
The active colours. Rendering code reads these directly.
var ( Dim lipgloss.Style Normal lipgloss.Style Selected lipgloss.Style Title lipgloss.Style Key lipgloss.Style )
Styles derived from the colours above. They are recomputed by Apply, since a style captures its colour at construction and would otherwise keep the old palette after a theme change.
var Builtin = map[string]Palette{
"terminal": {
Text: "default", TextDim: "8", TextBrt: "default", Accent: "4",
Green: "2", Yellow: "3", Red: "1", Magenta: "5",
Border: "8", Selected: "default",
},
"tokyonight": {
Text: "#c0caf5", TextDim: "#565f89", TextBrt: "#ffffff", Accent: "#7aa2f7",
Green: "#9ece6a", Yellow: "#e0af68", Red: "#f7768e", Magenta: "#bb9af7",
Border: "#3b4261", Selected: "#283457",
},
"gruvbox": {
Text: "#ebdbb2", TextDim: "#928374", TextBrt: "#fbf1c7", Accent: "#83a598",
Green: "#b8bb26", Yellow: "#fabd2f", Red: "#fb4934", Magenta: "#d3869b",
Border: "#504945", Selected: "#3c3836",
},
"nord": {
Text: "#d8dee9", TextDim: "#6c7a94", TextBrt: "#eceff4", Accent: "#88c0d0",
Green: "#a3be8c", Yellow: "#ebcb8b", Red: "#bf616a", Magenta: "#b48ead",
Border: "#434c5e", Selected: "#3b4252",
},
"mono": {
Text: "#cccccc", TextDim: "#777777", TextBrt: "#ffffff", Accent: "#ffffff",
Green: "#cccccc", Yellow: "#cccccc", Red: "#ffffff", Magenta: "#cccccc",
Border: "#555555", Selected: "#333333",
},
}
Builtin palettes, selectable by name from the config file.
Functions ¶
func Apply ¶
func Apply(p Palette)
Apply makes p the active palette. Fields left empty fall back to the built-in default, so a config file can override one colour without having to restate the rest. So does a value parse cannot read, which Validate is there to report before anything is drawn.
func BuiltinNames ¶
func BuiltinNames() []string
BuiltinNames lists the palettes, for error messages and documentation.
func PaletteKeys ¶ added in v0.10.8
func PaletteKeys() []string
PaletteKeys are the colours a palette may set, in the order the example config lists them. Read off the struct so the two cannot drift: a name added here appears in the complaint about a name that is not here.
Types ¶
type Palette ¶
type Palette struct {
Text string `yaml:"text"`
TextDim string `yaml:"text_dim"`
TextBrt string `yaml:"text_bright"`
Accent string `yaml:"accent"`
Green string `yaml:"green"`
Yellow string `yaml:"yellow"`
Red string `yaml:"red"`
Magenta string `yaml:"magenta"`
Border string `yaml:"border"`
Selected string `yaml:"selected_bg"`
}
Palette is a named set of colours, as strings so it can come from YAML. Each is a hex colour, a number from the terminal's own palette, or default; parse says what each of those draws.