From c22a64cc5d39c864dfd8953b5feb7c079a447d00 Mon Sep 17 00:00:00 2001 From: rigormorrtiss Date: Wed, 18 Aug 2021 21:02:21 +0400 Subject: [PATCH] util: add theme.borders option to config (#32) --- discordo.go | 36 +++++++++++++++++++++++------------- util/config.go | 13 ++++++++----- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/discordo.go b/discordo.go index ff54dcf..839a96a 100644 --- a/discordo.go +++ b/discordo.go @@ -32,22 +32,32 @@ var ( ) func main() { - tview.Borders.HorizontalFocus = tview.Borders.Horizontal - tview.Borders.VerticalFocus = tview.Borders.Vertical - tview.Borders.TopLeftFocus = tview.Borders.TopLeft - tview.Borders.TopRightFocus = tview.Borders.TopRight - tview.Borders.BottomLeftFocus = tview.Borders.BottomLeft - tview.Borders.BottomRightFocus = tview.Borders.BottomRight - tview.Borders.Horizontal = ' ' - tview.Borders.Vertical = ' ' - tview.Borders.TopLeft = ' ' - tview.Borders.TopRight = ' ' - tview.Borders.BottomLeft = ' ' - tview.Borders.BottomRight = ' ' - conf = util.NewConfig() + tview.Styles.PrimitiveBackgroundColor = tcell.GetColor(conf.Theme.Background) + if !conf.Theme.Borders { + tview.Borders = struct { + Horizontal rune + Vertical rune + TopLeft rune + TopRight rune + BottomLeft rune + BottomRight rune + LeftT rune + RightT rune + TopT rune + BottomT rune + Cross rune + HorizontalFocus rune + VerticalFocus rune + TopLeftFocus rune + TopRightFocus rune + BottomLeftFocus rune + BottomRightFocus rune + }{} + } + app = ui.NewApp(onAppInputCapture) guildsTreeView = ui.NewGuildsTreeView(onGuildsTreeViewSelected) messagesTextView = ui.NewMessagesTextView(app) diff --git a/util/config.go b/util/config.go index ff9488f..18288ca 100644 --- a/util/config.go +++ b/util/config.go @@ -6,13 +6,14 @@ import ( ) type Theme struct { - Background string `json:"background"` - Foreground string `json:"foreground"` + Background string `json:"background,omitempty"` + Foreground string `json:"foreground,omitempty"` + Borders bool `json:"borders,omitempty"` } type Config struct { - GetMessagesLimit uint `json:"getMessagesLimit"` - Theme *Theme `json:"theme"` + GetMessagesLimit uint `json:"getMessagesLimit,omitempty"` + Theme *Theme `json:"theme,omitempty"` } func NewConfig() *Config { @@ -23,7 +24,9 @@ func NewConfig() *Config { var c Config = Config{ GetMessagesLimit: 50, - Theme: &Theme{}, + Theme: &Theme{ + Borders: true, + }, } configPath := userHomeDir + "/.config/discordo/config.json" if _, err := os.Stat(configPath); os.IsNotExist(err) {