~chrisppy/beagles

950d286853fe78a0ded92212f512ad1f24732496 — Chris Palmer 24 days ago 2c64c92
theme cleanup in config
M config/config.go => config/config.go +100 -89
@@ 30,22 30,8 @@ import (
// Config contains all relevant configuration data for the application
type Config struct {
	Browser        *Browser
	Theme          Theme
	Podcast        Podcast
	ErrColor       tcell.Color
	SeparatorColor tcell.Color
	ReadColor      tcell.Color
	CMDBGColor     tcell.Color
	CMDFGColor     tcell.Color
	StatusBGColor  tcell.Color
	StatusFGColor  tcell.Color
	TitleBGColor   tcell.Color
	TitleFGColor   tcell.Color
	ListBGColor    tcell.Color
	ListFGColor    tcell.Color
	TreeBGColor    tcell.Color
	TreeFGColor    tcell.Color
	ContentBGColor tcell.Color
	ContentFGColor tcell.Color
	CMDMode        KeyCMD
	Enter          KeyCMD
	Escape         KeyCMD


@@ 72,6 58,25 @@ type Config struct {
	Help           KeyCMD
}

// Theme config
type Theme struct {
	ErrColor       tcell.Color
	SeparatorColor tcell.Color
	ReadColor      tcell.Color
	CMDBGColor     tcell.Color
	CMDFGColor     tcell.Color
	StatusBGColor  tcell.Color
	StatusFGColor  tcell.Color
	TitleBGColor   tcell.Color
	TitleFGColor   tcell.Color
	ListBGColor    tcell.Color
	ListFGColor    tcell.Color
	TreeBGColor    tcell.Color
	TreeFGColor    tcell.Color
	ContentBGColor tcell.Color
	ContentFGColor tcell.Color
}

// KeyCMD contains everything needs to set the KeyBinding
type KeyCMD struct {
	Text  string


@@ 80,21 85,25 @@ type KeyCMD struct {
	Key   tcell.Key
}

type theme struct {
	BackgroundColor string            `toml:"background_color"`
	ForegroundColor string            `toml:"foreground_color"`
	ErrorColor      string            `toml:"error_color"`
	Separator       string            `toml:"separator_color"`
	ReadColor       string            `toml:"read_color"`
	CommandLine     *commandLineTheme `toml:"command_line, omitempty"`
	StatusLine      *statusLineTheme  `toml:"status_line, omitempty"`
	TitleLine       *titleLineTheme   `toml:"title_line, omitempty"`
	List            *listTheme        `toml:"list, omitempty"`
	Content         *contentTheme     `toml:"content, omitempty"`
	Tree            *treeTheme        `toml:"tree, omitempty"`
}

type config struct {
	BackgroundColor string       `toml:"background_color"`
	ForegroundColor string       `toml:"foreground_color"`
	ErrorColor      string       `toml:"error_color"`
	Separator       string       `toml:"separator_color"`
	ReadColor       string       `toml:"read_color"`
	KeyCommands     keyCommands  `toml:"key_commands"`
	Podcast         Podcast      `toml:"podcast"`
	Browser         *Browser     `toml:"browser, omitempty"`
	CommandLine     *commandLine `toml:"command_line, omitempty"`
	StatusLine      *statusLine  `toml:"status_line, omitempty"`
	TitleLine       *titleLine   `toml:"title_line, omitempty"`
	List            *list        `toml:"list, omitempty"`
	Content         *content     `toml:"content, omitempty"`
	Tree            *tree        `toml:"tree, omitempty"`
	Theme       theme       `toml:"theme"`
	KeyCommands keyCommands `toml:"key_commands"`
	Podcast     Podcast     `toml:"podcast"`
	Browser     *Browser    `toml:"browser, omitempty"`
}

// KeyCommands config


@@ 137,38 146,32 @@ type Browser struct {
	} `toml:"http, omitempty"`
}

// StatusLine config
type statusLine struct {
type statusLineTheme struct {
	BackgroundColor string `toml:"background_color"`
	ForegroundColor string `toml:"foreground_color"`
}

// TitleLine config
type titleLine struct {
type titleLineTheme struct {
	BackgroundColor string `toml:"background_color"`
	ForegroundColor string `toml:"foreground_color"`
}

// CommandLine config
type commandLine struct {
type commandLineTheme struct {
	BackgroundColor string `toml:"background_color"`
	ForegroundColor string `toml:"foreground_color"`
}

// Tree config
type tree struct {
type treeTheme struct {
	BackgroundColor string `toml:"background_color"`
	ForegroundColor string `toml:"foreground_color"`
}

// List config
type list struct {
type listTheme struct {
	BackgroundColor string `toml:"background_color"`
	ForegroundColor string `toml:"foreground_color"`
}

// Content config
type content struct {
type contentTheme struct {
	BackgroundColor string `toml:"background_color"`
	ForegroundColor string `toml:"foreground_color"`
}


@@ 208,12 211,16 @@ func Load(configDir string) *Config {

	cmds := make(map[string]bool)

	theme := Theme{
		ErrColor:       tcell.GetColor(cfg.Theme.ErrorColor),
		SeparatorColor: tcell.GetColor(cfg.Theme.Separator),
		ReadColor:      tcell.GetColor(cfg.Theme.ReadColor),
	}

	c := &Config{
		Podcast:        cfg.Podcast,
		Browser:        cfg.Browser,
		ErrColor:       tcell.GetColor(cfg.ErrorColor),
		SeparatorColor: tcell.GetColor(cfg.Separator),
		ReadColor:      tcell.GetColor(cfg.ReadColor),
		Theme:          theme,
		CMDMode:        createKeyCMD(":", cmds),
		Enter:          createKeyCMD("Enter", cmds),
		Escape:         createKeyCMD("Esc", cmds),


@@ 240,61 247,61 @@ func Load(configDir string) *Config {
		MarkUnfavorite: createKeyCMD(cfg.KeyCommands.MarkUnfavorite, cmds),
	}

	bg := tcell.GetColor(cfg.BackgroundColor)
	fg := tcell.GetColor(cfg.ForegroundColor)
	bg := tcell.GetColor(cfg.Theme.BackgroundColor)
	fg := tcell.GetColor(cfg.Theme.ForegroundColor)

	if cfg.CommandLine != nil {
		w := cfg.CommandLine
		c.CMDBGColor = tcell.GetColor(w.BackgroundColor)
		c.CMDFGColor = tcell.GetColor(w.ForegroundColor)
	if cfg.Theme.CommandLine != nil {
		w := cfg.Theme.CommandLine
		c.Theme.CMDBGColor = tcell.GetColor(w.BackgroundColor)
		c.Theme.CMDFGColor = tcell.GetColor(w.ForegroundColor)
	} else {
		c.CMDBGColor = bg
		c.CMDFGColor = fg
		c.Theme.CMDBGColor = bg
		c.Theme.CMDFGColor = fg
	}

	if cfg.StatusLine != nil {
		w := cfg.StatusLine
		c.StatusBGColor = tcell.GetColor(w.BackgroundColor)
		c.StatusFGColor = tcell.GetColor(w.ForegroundColor)
	if cfg.Theme.StatusLine != nil {
		w := cfg.Theme.StatusLine
		c.Theme.StatusBGColor = tcell.GetColor(w.BackgroundColor)
		c.Theme.StatusFGColor = tcell.GetColor(w.ForegroundColor)
	} else {
		c.StatusBGColor = bg
		c.StatusFGColor = fg
		c.Theme.StatusBGColor = bg
		c.Theme.StatusFGColor = fg
	}

	if cfg.TitleLine != nil {
		w := cfg.TitleLine
		c.TitleBGColor = tcell.GetColor(w.BackgroundColor)
		c.TitleFGColor = tcell.GetColor(w.ForegroundColor)
	if cfg.Theme.TitleLine != nil {
		w := cfg.Theme.TitleLine
		c.Theme.TitleBGColor = tcell.GetColor(w.BackgroundColor)
		c.Theme.TitleFGColor = tcell.GetColor(w.ForegroundColor)
	} else {
		c.TitleBGColor = bg
		c.TitleFGColor = fg
		c.Theme.TitleBGColor = bg
		c.Theme.TitleFGColor = fg
	}

	if cfg.List != nil {
		w := cfg.List
		c.ListBGColor = tcell.GetColor(w.BackgroundColor)
		c.ListFGColor = tcell.GetColor(w.ForegroundColor)
	if cfg.Theme.List != nil {
		w := cfg.Theme.List
		c.Theme.ListBGColor = tcell.GetColor(w.BackgroundColor)
		c.Theme.ListFGColor = tcell.GetColor(w.ForegroundColor)
	} else {
		c.ListBGColor = bg
		c.ListFGColor = fg
		c.Theme.ListBGColor = bg
		c.Theme.ListFGColor = fg
	}

	if cfg.Tree != nil {
		w := cfg.Tree
		c.TreeBGColor = tcell.GetColor(w.BackgroundColor)
		c.TreeFGColor = tcell.GetColor(w.ForegroundColor)
	if cfg.Theme.Tree != nil {
		w := cfg.Theme.Tree
		c.Theme.TreeBGColor = tcell.GetColor(w.BackgroundColor)
		c.Theme.TreeFGColor = tcell.GetColor(w.ForegroundColor)
	} else {
		c.TreeBGColor = bg
		c.TreeFGColor = fg
		c.Theme.TreeBGColor = bg
		c.Theme.TreeFGColor = fg
	}

	if cfg.Content != nil {
		w := cfg.Content
		c.ContentBGColor = tcell.GetColor(w.BackgroundColor)
		c.ContentFGColor = tcell.GetColor(w.ForegroundColor)
	if cfg.Theme.Content != nil {
		w := cfg.Theme.Content
		c.Theme.ContentBGColor = tcell.GetColor(w.BackgroundColor)
		c.Theme.ContentFGColor = tcell.GetColor(w.ForegroundColor)
	} else {
		c.ContentBGColor = bg
		c.ContentFGColor = fg
		c.Theme.ContentBGColor = bg
		c.Theme.ContentFGColor = fg
	}

	return c


@@ 328,22 335,22 @@ func load(configDir string) *config {
}

func defaultConfig() *config {
	cltheme := &commandLine{
	cltheme := &commandLineTheme{
		BackgroundColor: "#2e3440",
		ForegroundColor: "#d8dee9",
	}

	cnttheme := &content{
	cnttheme := &contentTheme{
		BackgroundColor: "#2e3440",
		ForegroundColor: "#e5e9f0",
	}

	ltheme := &list{
	ltheme := &listTheme{
		BackgroundColor: "#2e3440",
		ForegroundColor: "#e5e9f0",
	}

	ttheme := &tree{
	ttheme := &treeTheme{
		BackgroundColor: "#2e3440",
		ForegroundColor: "#e5e9f0",
	}


@@ 377,7 384,7 @@ func defaultConfig() *config {
		ExternalPlayer: extPlay,
	}

	return &config{
	theme := theme{
		BackgroundColor: "#88c0d0",
		ForegroundColor: "#2e3440",
		ErrorColor:      "#bf616a",


@@ 387,7 394,11 @@ func defaultConfig() *config {
		Content:         cnttheme,
		List:            ltheme,
		Tree:            ttheme,
		KeyCommands:     keys,
		Podcast:         pod,
	}

	return &config{
		Theme:       theme,
		KeyCommands: keys,
		Podcast:     pod,
	}
}

M doc/beagles-config.5.scd => doc/beagles-config.5.scd +60 -57
@@ 20,20 20,70 @@ inherit the colors from *background_color* and *foreground_color*.
Keys can be either a single character or defined by the KeyNames in the tcell
library (e.g. PgUp).

*background_color* - string
	The main background color of the application
*theme* - object

*foreground_color* - string
	The main foreground color of the application
	*background_color* - string
		The main background color of the application

	*foreground_color* - string
		The main foreground color of the application

	*error_color* - string
		The color of error messages

	*separator_color* - string
		The color of separator objects

	*read_color* - string
		The color of items marked as read

	*command_line* - object, optional

		*background_color* - string
			The background color of the command line

		*foreground_color* - string
			The foreground color of the command line

	*status_line* - object, optional

		*background_color* - string
			The background color of the status line

		*foreground_color* - string
			The foreground color of the status line

	*title_line* - object, optional

*error_color* - string
	The color of error messages
		*background_color* - string
			The background color of the title line

*separator_color* - string
	The color of separator objects
		*foreground_color* - string
			The foreground color of the title line

*read_color* - string
	The color of items marked as read
	*list* - object, optional

		*background_color* - string
			The background color of the list pane

		*foreground_color* - string
			The foreground color of the list pane

	*tree* - object, optional

		*background_color* - string
			The background color of the tree pane

		*foreground_color* - string
			The foreground color of the tree pane

	*content* - object, optional

		*background_color* - string
			The background color of the content pane

		*foreground_color* - string
			The foreground color of the content pane

*key_commands* - object



@@ 116,53 166,6 @@ library (e.g. PgUp).
			as one of the arguments as that will substitute the
			podcast file to play

*command_line* - object, optional

	*background_color* - string
		The background color of the command line

	*foreground_color* - string
		The foreground color of the command line

*status_line* - object, optional

	*background_color* - string
		The background color of the status line

	*foreground_color* - string
		The foreground color of the status line

*title_line* - object, optional

	*background_color* - string
		The background color of the title line

	*foreground_color* - string
		The foreground color of the title line

*list* - object, optional

	*background_color* - string
		The background color of the list pane

	*foreground_color* - string
		The foreground color of the list pane

*tree* - object, optional

	*background_color* - string
		The background color of the tree pane

	*foreground_color* - string
		The foreground color of the tree pane

*content* - object, optional

	*background_color* - string
		The background color of the content pane

	*foreground_color* - string
		The foreground color of the content pane

# SEE ALSO
	*beagles*(1)

M ui/commandline.go => ui/commandline.go +4 -4
@@ 34,13 34,13 @@ type commandLine struct {
func newCommandLine(config *config.Config) *commandLine {
	line := tui.NewInputField()

	line.SetFieldBackgroundColor(config.CMDBGColor)
	line.SetFieldTextColor(config.CMDFGColor)
	line.SetFieldBackgroundColor(config.Theme.CMDBGColor)
	line.SetFieldTextColor(config.Theme.CMDFGColor)

	return &commandLine{
		Widget:   line,
		TxtColor: config.CMDFGColor,
		ErrColor: config.ErrColor,
		TxtColor: config.Theme.CMDFGColor,
		ErrColor: config.Theme.ErrColor,
	}
}


M ui/content.go => ui/content.go +4 -4
@@ 38,13 38,13 @@ func newContent(config *config.Config) *content {
	view.SetTextAlign(tui.AlignLeft)
	view.SetScrollable(true)

	view.SetBackgroundColor(config.ContentBGColor)
	view.SetTextColor(config.ContentFGColor)
	view.SetBackgroundColor(config.Theme.ContentBGColor)
	view.SetTextColor(config.Theme.ContentFGColor)

	return &content{
		Widget:   view,
		TxtColor: config.ContentFGColor,
		ErrColor: config.ErrColor,
		TxtColor: config.Theme.ContentFGColor,
		ErrColor: config.Theme.ErrColor,
	}
}


M ui/list.go => ui/list.go +2 -2
@@ 35,8 35,8 @@ func newList(config *config.Config) *list {
	view := tui.NewList()
	view.ShowSecondaryText(false)

	view.SetBackgroundColor(config.ListBGColor)
	view.SetMainTextColor(config.ListFGColor)
	view.SetBackgroundColor(config.Theme.ListBGColor)
	view.SetMainTextColor(config.Theme.ListFGColor)

	return &list{Widget: view}
}

M ui/separator.go => ui/separator.go +2 -2
@@ 26,9 26,9 @@ import (
func newSeparator(config *config.Config, isVertical bool) *tui.Box {
	line := tui.NewBox()

	line.SetBackgroundColor(config.SeparatorColor)
	line.SetBackgroundColor(config.Theme.SeparatorColor)

	style := tcell.StyleDefault.Foreground(config.SeparatorColor)
	style := tcell.StyleDefault.Foreground(config.Theme.SeparatorColor)
	line.SetDrawFunc(func(screen tcell.Screen, x, y, w, h int) (int, int, int, int) {
		if isVertical {
			fh := y + h

M ui/statusline.go => ui/statusline.go +2 -2
@@ 31,8 31,8 @@ func newStatusLine(config *config.Config) *statusLine {
	line.SetTextAlign(tui.AlignLeft)
	line.SetText("-- LIST --")

	line.SetBackgroundColor(config.StatusBGColor)
	line.SetTextColor(config.StatusFGColor)
	line.SetBackgroundColor(config.Theme.StatusBGColor)
	line.SetTextColor(config.Theme.StatusFGColor)

	return &statusLine{Widget: line}
}

M ui/titleline.go => ui/titleline.go +2 -2
@@ 31,8 31,8 @@ func newTitleLine(config *config.Config) *tui.TextView {
	line.SetTextAlign(tui.AlignCenter)
	line.SetText("beagles")

	line.SetBackgroundColor(config.TitleBGColor)
	line.SetTextColor(config.TitleFGColor)
	line.SetBackgroundColor(config.Theme.TitleBGColor)
	line.SetTextColor(config.Theme.TitleFGColor)

	return line
}

M ui/tree.go => ui/tree.go +5 -5
@@ 45,11 45,11 @@ func newTree(config *config.Config) *tree {
	view := tui.NewTreeView()
	view.SetGraphics(true)

	view.SetBackgroundColor(config.TreeBGColor)
	view.SetGraphicsColor(config.TreeFGColor)
	view.SetBackgroundColor(config.Theme.TreeBGColor)
	view.SetGraphicsColor(config.Theme.TreeFGColor)

	node := tui.NewTreeNode("subscriptions")
	node.SetColor(config.TreeFGColor)
	node.SetColor(config.Theme.TreeFGColor)

	childNodes := make([]*tui.TreeNode, 0)
	node.SetChildren(childNodes)


@@ 61,8 61,8 @@ func newTree(config *config.Config) *tree {
		Widget:      view,
		Node:        node,
		ChildNodes:  childNodes,
		TextColor:   config.TreeFGColor,
		ReadColor:   config.ReadColor,
		TextColor:   config.Theme.TreeFGColor,
		ReadColor:   config.Theme.ReadColor,
		Dates:       make(map[string]time.Time),
		ChildParent: make(map[string]*tui.TreeNode),
	}