Răsfoiți Sursa

util: add theme.borders option to config (#32)

rigormorrtiss 4 ani în urmă
părinte
comite
c22a64cc5d
2 a modificat fișierele cu 31 adăugiri și 18 ștergeri
  1. 23 13
      discordo.go
  2. 8 5
      util/config.go

+ 23 - 13
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)

+ 8 - 5
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) {