Add custom theming
This commit is contained in:
56
config.go
56
config.go
@@ -25,18 +25,44 @@ func (d *configDuration) UnmarshalText(text []byte) error {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Theme string `toml:"theme"`
|
||||
RefreshInterval configDuration `toml:"refresh_interval"`
|
||||
Repository string `toml:"repository"`
|
||||
ShowAll bool `toml:"show_all"`
|
||||
Limit int `toml:"limit"`
|
||||
Endpoint string `toml:"endpoint"`
|
||||
Display DisplayConfig `toml:"display"`
|
||||
Paths PathConfig `toml:"paths"`
|
||||
Threads ThreadConfig `toml:"threads"`
|
||||
Cache CacheConfig `toml:"cache"`
|
||||
Editing EditingConfig `toml:"editing"`
|
||||
KeyBindings KeyBindings `toml:"keybindings"`
|
||||
Theme string `toml:"theme"`
|
||||
RefreshInterval configDuration `toml:"refresh_interval"`
|
||||
Repository string `toml:"repository"`
|
||||
ShowAll bool `toml:"show_all"`
|
||||
Limit int `toml:"limit"`
|
||||
Endpoint string `toml:"endpoint"`
|
||||
Display DisplayConfig `toml:"display"`
|
||||
Paths PathConfig `toml:"paths"`
|
||||
Threads ThreadConfig `toml:"threads"`
|
||||
Cache CacheConfig `toml:"cache"`
|
||||
Editing EditingConfig `toml:"editing"`
|
||||
CustomTheme CustomThemeConfig `toml:"custom_theme"`
|
||||
KeyBindings KeyBindings `toml:"keybindings"`
|
||||
}
|
||||
|
||||
type CustomThemeConfig struct {
|
||||
Base string `toml:"base"`
|
||||
Mode string `toml:"mode"`
|
||||
Title string `toml:"title"`
|
||||
Dim string `toml:"dim"`
|
||||
Text string `toml:"text"`
|
||||
ActiveForeground string `toml:"active_foreground"`
|
||||
ActiveBackground string `toml:"active_background"`
|
||||
Success string `toml:"success"`
|
||||
Warning string `toml:"warning"`
|
||||
Error string `toml:"error"`
|
||||
EditorForeground string `toml:"editor_foreground"`
|
||||
EditorBackground string `toml:"editor_background"`
|
||||
PaneInactive string `toml:"pane_inactive"`
|
||||
PaneActive string `toml:"pane_active"`
|
||||
Quote string `toml:"quote"`
|
||||
SelectionBackground string `toml:"selection_background"`
|
||||
SuggestionRemoveBackground string `toml:"suggestion_remove_background"`
|
||||
SuggestionAddBackground string `toml:"suggestion_add_background"`
|
||||
ChangedRemoveBackground string `toml:"changed_remove_background"`
|
||||
ChangedAddBackground string `toml:"changed_add_background"`
|
||||
AuthorPalette []string `toml:"author_palette"`
|
||||
SyntaxTheme string `toml:"syntax_theme"`
|
||||
}
|
||||
|
||||
type DisplayConfig struct {
|
||||
@@ -160,10 +186,8 @@ func loadConfig(path string, required bool) (Config, error) {
|
||||
}
|
||||
|
||||
func validateConfig(config Config) error {
|
||||
switch config.Theme {
|
||||
case "dark", "light", "no-color", "high-contrast":
|
||||
default:
|
||||
return fmt.Errorf("theme must be dark or light")
|
||||
if _, err := resolveThemePalette(config.Theme, config.CustomTheme); err != nil {
|
||||
return err
|
||||
}
|
||||
if config.RefreshInterval.Duration < 2*time.Second {
|
||||
return fmt.Errorf("refresh_interval must be at least 2s")
|
||||
|
||||
Reference in New Issue
Block a user