theme.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package config
  2. import (
  3. "github.com/rivo/tview"
  4. )
  5. type BorderPreset struct {
  6. Horizontal rune
  7. Vertical rune
  8. TopLeft rune
  9. TopRight rune
  10. BottomLeft rune
  11. BottomRight rune
  12. }
  13. func (p *BorderPreset) UnmarshalTOML(v any) error {
  14. switch v.(string) {
  15. case "double":
  16. *p = BorderPreset{
  17. Horizontal: tview.BoxDrawingsDoubleHorizontal,
  18. Vertical: tview.BoxDrawingsDoubleVertical,
  19. TopLeft: tview.BoxDrawingsDoubleDownAndRight,
  20. TopRight: tview.BoxDrawingsDoubleDownAndLeft,
  21. BottomLeft: tview.BoxDrawingsDoubleUpAndRight,
  22. BottomRight: tview.BoxDrawingsDoubleUpAndLeft,
  23. }
  24. case "thick":
  25. *p = BorderPreset{
  26. Horizontal: tview.BoxDrawingsHeavyHorizontal,
  27. Vertical: tview.BoxDrawingsHeavyVertical,
  28. TopLeft: tview.BoxDrawingsHeavyDownAndRight,
  29. TopRight: tview.BoxDrawingsHeavyDownAndLeft,
  30. BottomLeft: tview.BoxDrawingsHeavyUpAndRight,
  31. BottomRight: tview.BoxDrawingsHeavyUpAndLeft,
  32. }
  33. case "round":
  34. *p = BorderPreset{
  35. Horizontal: tview.BoxDrawingsLightHorizontal,
  36. Vertical: tview.BoxDrawingsLightVertical,
  37. TopLeft: tview.BoxDrawingsLightArcDownAndRight,
  38. TopRight: tview.BoxDrawingsLightArcDownAndLeft,
  39. BottomLeft: tview.BoxDrawingsLightArcUpAndRight,
  40. BottomRight: tview.BoxDrawingsLightArcUpAndLeft,
  41. }
  42. case "hidden":
  43. *p = BorderPreset{
  44. Horizontal: ' ',
  45. Vertical: ' ',
  46. TopLeft: ' ',
  47. TopRight: ' ',
  48. BottomLeft: ' ',
  49. BottomRight: ' ',
  50. }
  51. }
  52. return nil
  53. }
  54. type (
  55. BorderTheme struct {
  56. Enabled bool `toml:"enabled"`
  57. Padding [4]int `toml:"padding"`
  58. Color string `toml:"color"`
  59. ActiveColor string `toml:"active_color"`
  60. Preset BorderPreset `toml:"preset"`
  61. }
  62. Theme struct {
  63. TitleColor string `toml:"title_color"`
  64. BackgroundColor string `toml:"background_color"`
  65. Border BorderTheme `toml:"border"`
  66. GuildsTree GuildsTreeTheme `toml:"guilds_tree"`
  67. MessagesText MessagesTextTheme `toml:"messages_text"`
  68. }
  69. GuildsTreeTheme struct {
  70. AutoExpandFolders bool `toml:"auto_expand_folders"`
  71. Graphics bool `toml:"graphics"`
  72. PrivateChannelColor string `toml:"private_channel_color"`
  73. GuildColor string `toml:"guild_color"`
  74. ChannelColor string `toml:"channel_color"`
  75. }
  76. MessagesTextTheme struct {
  77. ReplyIndicator string `toml:"reply_indicator"`
  78. AuthorColor string `toml:"author_color"`
  79. ContentColor string `toml:"content_color"`
  80. EmojiColor string `toml:"emoji_color"`
  81. LinkColor string `toml:"link_color"`
  82. AttachmentColor string `toml:"attachment_color"`
  83. }
  84. )
  85. func defaultTheme() Theme {
  86. return Theme{
  87. Border: BorderTheme{
  88. Enabled: true,
  89. Padding: [...]int{0, 0, 1, 1},
  90. Color: "default",
  91. ActiveColor: "green",
  92. Preset: BorderPreset{
  93. Horizontal: tview.Borders.Horizontal,
  94. Vertical: tview.Borders.Vertical,
  95. TopLeft: tview.Borders.TopLeft,
  96. TopRight: tview.Borders.TopRight,
  97. BottomLeft: tview.Borders.BottomLeft,
  98. BottomRight: tview.Borders.BottomRight,
  99. },
  100. },
  101. BackgroundColor: "default",
  102. TitleColor: "default",
  103. GuildsTree: GuildsTreeTheme{
  104. AutoExpandFolders: true,
  105. ChannelColor: tview.Styles.PrimaryTextColor.String(),
  106. Graphics: true,
  107. GuildColor: tview.Styles.PrimaryTextColor.String(),
  108. PrivateChannelColor: tview.Styles.PrimaryTextColor.String(),
  109. },
  110. MessagesText: MessagesTextTheme{
  111. ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ",
  112. AuthorColor: "aqua",
  113. ContentColor: tview.Styles.PrimaryTextColor.String(),
  114. EmojiColor: "green",
  115. LinkColor: "blue",
  116. AttachmentColor: "yellow",
  117. },
  118. }
  119. }