theme.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. ShowNicknames bool `toml:"show_user_nicks"`
  46. ShowUsernameColors bool `toml:"show_user_colors"`
  47. ReplyIndicator string `toml:"reply_indicator"`
  48. AuthorColor string `toml:"author_color"`
  49. ContentColor string `toml:"content_color"`
  50. EmojiColor string `toml:"emoji_color"`
  51. LinkColor string `toml:"link_color"`
  52. AttachmentColor string `toml:"attachment_color"`
  53. }
  54. )
  55. func defaultTheme() Theme {
  56. return Theme{
  57. BackgroundColor: "default",
  58. Border: BorderTheme{
  59. Enabled: true,
  60. Padding: [...]int{0, 0, 1, 1},
  61. Color: "default",
  62. ActiveColor: "green",
  63. Preset: borderPresetRound(),
  64. },
  65. Title: TitleTheme{
  66. Color: "default",
  67. ActiveColor: "green",
  68. Align: tview.AlignLeft,
  69. },
  70. GuildsTree: GuildsTreeTheme{
  71. AutoExpandFolders: true,
  72. ChannelColor: tview.Styles.PrimaryTextColor.String(),
  73. Graphics: true,
  74. GuildColor: tview.Styles.PrimaryTextColor.String(),
  75. PrivateChannelColor: tview.Styles.PrimaryTextColor.String(),
  76. },
  77. MessagesText: MessagesTextTheme{
  78. ShowNicknames: true,
  79. ShowUsernameColors: true,
  80. ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ",
  81. AuthorColor: "aqua",
  82. ContentColor: tview.Styles.PrimaryTextColor.String(),
  83. EmojiColor: "green",
  84. LinkColor: "blue",
  85. AttachmentColor: "yellow",
  86. },
  87. }
  88. }