theme.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package config
  2. import (
  3. "github.com/rivo/tview"
  4. )
  5. type TitleAlign int
  6. func (ta *TitleAlign) UnmarshalTOML(v any) error {
  7. switch v.(string) {
  8. case "left":
  9. *ta = tview.AlignLeft
  10. case "center":
  11. *ta = tview.AlignCenter
  12. case "right":
  13. *ta = tview.AlignRight
  14. }
  15. return nil
  16. }
  17. type (
  18. BorderTheme struct {
  19. Enabled bool `toml:"enabled"`
  20. Padding [4]int `toml:"padding"`
  21. Color string `toml:"color"`
  22. ActiveColor string `toml:"active_color"`
  23. Preset BorderPreset `toml:"preset"`
  24. }
  25. TitleTheme struct {
  26. Color string `toml:"color"`
  27. ActiveColor string `toml:"active_color"`
  28. Align TitleAlign `toml:"align"`
  29. }
  30. Theme struct {
  31. BackgroundColor string `toml:"background_color"`
  32. Title TitleTheme `toml:"title"`
  33. Border BorderTheme `toml:"border"`
  34. GuildsTree GuildsTreeTheme `toml:"guilds_tree"`
  35. MessagesText MessagesTextTheme `toml:"messages_text"`
  36. }
  37. GuildsTreeTheme struct {
  38. AutoExpandFolders bool `toml:"auto_expand_folders"`
  39. Graphics bool `toml:"graphics"`
  40. PrivateChannelColor string `toml:"private_channel_color"`
  41. GuildColor string `toml:"guild_color"`
  42. ChannelColor string `toml:"channel_color"`
  43. }
  44. MessagesTextTheme struct {
  45. ReplyIndicator string `toml:"reply_indicator"`
  46. AuthorColor string `toml:"author_color"`
  47. ContentColor string `toml:"content_color"`
  48. EmojiColor string `toml:"emoji_color"`
  49. LinkColor string `toml:"link_color"`
  50. AttachmentColor string `toml:"attachment_color"`
  51. }
  52. )
  53. func defaultTheme() Theme {
  54. return Theme{
  55. BackgroundColor: "default",
  56. Border: BorderTheme{
  57. Enabled: true,
  58. Padding: [...]int{0, 0, 1, 1},
  59. Color: "default",
  60. ActiveColor: "green",
  61. Preset: borderPresetRound(),
  62. },
  63. Title: TitleTheme{
  64. Color: "default",
  65. ActiveColor: "green",
  66. Align: tview.AlignLeft,
  67. },
  68. GuildsTree: GuildsTreeTheme{
  69. AutoExpandFolders: true,
  70. ChannelColor: tview.Styles.PrimaryTextColor.String(),
  71. Graphics: true,
  72. GuildColor: tview.Styles.PrimaryTextColor.String(),
  73. PrivateChannelColor: tview.Styles.PrimaryTextColor.String(),
  74. },
  75. MessagesText: MessagesTextTheme{
  76. ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ",
  77. AuthorColor: "aqua",
  78. ContentColor: tview.Styles.PrimaryTextColor.String(),
  79. EmojiColor: "green",
  80. LinkColor: "blue",
  81. AttachmentColor: "yellow",
  82. },
  83. }
  84. }