From 80179a8246f085473451f024dda55c512e6dac37 Mon Sep 17 00:00:00 2001 From: ayntgl <90600421+ayntgl@users.noreply.github.com> Date: Mon, 27 Sep 2021 23:24:21 +0400 Subject: [PATCH] feat: support w3c names and hex value colors in config (#60) --- config.go | 32 ++++++++++++++++++++++++++++---- main.go | 14 +++++++++++++- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index d3db44c..f84a9a5 100644 --- a/config.go +++ b/config.go @@ -3,8 +3,6 @@ package main import ( "encoding/json" "os" - - "github.com/rivo/tview" ) var conf *config @@ -23,13 +21,27 @@ type keybindings struct { MessageInputFieldFocus string } +type theme struct { + PrimitiveBackgroundColor string // Main background color for primitives. + ContrastBackgroundColor string // Background color for contrasting elements. + MoreContrastBackgroundColor string // Background color for even more contrasting elements. + BorderColor string // Box borders. + TitleColor string // Box titles. + GraphicsColor string // Graphics. + PrimaryTextColor string // Primary text. + SecondaryTextColor string // Secondary text (e.g. labels). + TertiaryTextColor string // Tertiary text (e.g. subtitles, notes). + InverseTextColor string // Text on primary-colored backgrounds. + ContrastSecondaryTextColor string // Secondary text on ContrastBackgroundColor-colored backgrounds. +} + type config struct { Token string Mouse bool Notifications bool UserAgent string GetMessagesLimit int - Theme tview.Theme + Theme theme Keybindings keybindings } @@ -60,7 +72,19 @@ func loadConfig() *config { "AppleWebKit/537.36 (KHTML, like Gecko) " + "Chrome/92.0.4515.131 Safari/537.36", GetMessagesLimit: 50, - Theme: tview.Styles, + Theme: theme{ + PrimitiveBackgroundColor: "black", + ContrastBackgroundColor: "blue", + MoreContrastBackgroundColor: "green", + BorderColor: "white", + TitleColor: "white", + GraphicsColor: "white", + PrimaryTextColor: "white", + SecondaryTextColor: "yellow", + TertiaryTextColor: "green", + InverseTextColor: "blue", + ContrastSecondaryTextColor: "darkcyan", + }, Keybindings: keybindings{ GuildsTreeViewFocus: "Alt+Rune[1]", diff --git a/main.go b/main.go index fa5081f..057a22f 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "github.com/gdamore/tcell/v2" "github.com/rivo/tview" "github.com/zalando/go-keyring" ) @@ -9,7 +10,18 @@ const service = "discordo" func main() { conf = loadConfig() - tview.Styles = conf.Theme + + tview.Styles.PrimitiveBackgroundColor = tcell.GetColor(conf.Theme.PrimitiveBackgroundColor) + tview.Styles.ContrastBackgroundColor = tcell.GetColor(conf.Theme.ContrastBackgroundColor) + tview.Styles.MoreContrastBackgroundColor = tcell.GetColor(conf.Theme.MoreContrastBackgroundColor) + tview.Styles.BorderColor = tcell.GetColor(conf.Theme.BorderColor) + tview.Styles.TitleColor = tcell.GetColor(conf.Theme.TitleColor) + tview.Styles.GraphicsColor = tcell.GetColor(conf.Theme.GraphicsColor) + tview.Styles.PrimaryTextColor = tcell.GetColor(conf.Theme.PrimaryTextColor) + tview.Styles.SecondaryTextColor = tcell.GetColor(conf.Theme.SecondaryTextColor) + tview.Styles.TertiaryTextColor = tcell.GetColor(conf.Theme.TertiaryTextColor) + tview.Styles.InverseTextColor = tcell.GetColor(conf.Theme.InverseTextColor) + tview.Styles.ContrastSecondaryTextColor = tcell.GetColor(conf.Theme.ContrastSecondaryTextColor) app = newApplication() channelsTree = newChannelsTree()