diff --git a/discordo.go b/discordo.go index f191e64..82516cc 100644 --- a/discordo.go +++ b/discordo.go @@ -29,29 +29,7 @@ var ( func main() { 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 - }{} - } + tview.Styles = conf.Theme app = tview.NewApplication(). EnableMouse(conf.Mouse). @@ -59,7 +37,7 @@ func main() { guildsTreeView = ui.NewGuildsTreeView(onGuildsTreeViewSelected) channelsTreeView = ui.NewChannelsTreeView(onChannelsTreeViewSelected) messagesTextView = ui.NewMessagesTextView(app) - messageInputField = ui.NewMessageInputField(onMessageInputFieldInputCapture, conf.Theme) + messageInputField = ui.NewMessageInputField(onMessageInputFieldInputCapture) mainFlex = ui.NewMainFlex(guildsTreeView, channelsTreeView, messagesTextView, messageInputField) token := conf.Token diff --git a/ui/flex.go b/ui/flex.go index 1bbe096..14ed005 100644 --- a/ui/flex.go +++ b/ui/flex.go @@ -16,7 +16,7 @@ func NewMainFlex(gTreeV *tview.TreeView, cTreeV *tview.TreeView, textV *tview.Te AddItem(i, 3, 1, false) mf := tview.NewFlex(). AddItem(lf, 0, 1, false). - AddItem(rf, 0, 4, false) + AddItem(rf, 0, 5, false) return mf } diff --git a/ui/forms.go b/ui/forms.go index 4798dcb..5edb29f 100644 --- a/ui/forms.go +++ b/ui/forms.go @@ -1,7 +1,6 @@ package ui import ( - "github.com/gdamore/tcell/v2" "github.com/rivo/tview" ) @@ -9,7 +8,6 @@ func newBaseLoginForm() *tview.Form { f := tview.NewForm() f. SetButtonsAlign(tview.AlignCenter). - SetButtonBackgroundColor(tcell.GetColor("#5865F2")). SetBorder(true). SetBorderPadding(0, 0, 1, 0) diff --git a/ui/inputfields.go b/ui/inputfields.go index 5c76139..439a1ad 100644 --- a/ui/inputfields.go +++ b/ui/inputfields.go @@ -2,18 +2,16 @@ package ui import ( "github.com/gdamore/tcell/v2" - "github.com/rigormorrtiss/discordo/util" "github.com/rivo/tview" ) // NewMessageInputField creates and returns a new message inputfield. -func NewMessageInputField(onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey, t *util.Theme) *tview.InputField { +func NewMessageInputField(onMessageInputFieldInputCapture func(*tcell.EventKey) *tcell.EventKey) *tview.InputField { i := tview.NewInputField() i. SetPlaceholder("Message..."). SetPlaceholderTextColor(tcell.ColorWhite). - SetFieldBackgroundColor(tcell.GetColor(t.Background)). - SetBackgroundColor(tcell.GetColor(t.Background)). + SetFieldBackgroundColor(tview.Styles.PrimitiveBackgroundColor). SetInputCapture(onMessageInputFieldInputCapture). SetBorder(true). SetBorderPadding(0, 0, 1, 0) diff --git a/util/config.go b/util/config.go index be73d8c..4af6cda 100644 --- a/util/config.go +++ b/util/config.go @@ -3,21 +3,16 @@ package util import ( "encoding/json" "os" -) -// Theme defines the theme for the application. -type Theme struct { - Background string `json:"background,omitempty"` - Foreground string `json:"foreground,omitempty"` - Borders bool `json:"borders,omitempty"` -} + "github.com/rivo/tview" +) // Config consists of fields, such as theme, mouse, so on, that may be customized by the user. type Config struct { - Token string `json:"token,omitempty"` - Mouse bool `json:"mouse,omitempty"` - GetMessagesLimit int `json:"getMessagesLimit,omitempty"` - Theme *Theme `json:"theme,omitempty"` + Token string `json:"token,omitempty"` + Mouse bool `json:"mouse,omitempty"` + GetMessagesLimit int `json:"getMessagesLimit,omitempty"` + Theme tview.Theme `json:"theme,omitempty"` } // NewConfig reads the configuration file (if exists) and returns a new config. @@ -30,9 +25,6 @@ func NewConfig() *Config { var c Config = Config{ Mouse: true, GetMessagesLimit: 50, - Theme: &Theme{ - Borders: true, - }, } configPath := userHomeDir + "/.config/discordo/config.json" if _, err := os.Stat(configPath); os.IsNotExist(err) {