theme.go 2.6 KB

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