theme.go 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. BackgroundColor string `toml:"background_color"`
  64. TitleColor string `toml:"title_color"`
  65. ActiveTitleColor string `toml:"active_title_color"`
  66. Border BorderTheme `toml:"border"`
  67. GuildsTree GuildsTreeTheme `toml:"guilds_tree"`
  68. MessagesText MessagesTextTheme `toml:"messages_text"`
  69. }
  70. GuildsTreeTheme struct {
  71. AutoExpandFolders bool `toml:"auto_expand_folders"`
  72. Graphics bool `toml:"graphics"`
  73. PrivateChannelColor string `toml:"private_channel_color"`
  74. GuildColor string `toml:"guild_color"`
  75. ChannelColor string `toml:"channel_color"`
  76. }
  77. MessagesTextTheme struct {
  78. ReplyIndicator string `toml:"reply_indicator"`
  79. AuthorColor string `toml:"author_color"`
  80. ContentColor string `toml:"content_color"`
  81. EmojiColor string `toml:"emoji_color"`
  82. LinkColor string `toml:"link_color"`
  83. AttachmentColor string `toml:"attachment_color"`
  84. }
  85. )
  86. func defaultTheme() Theme {
  87. return Theme{
  88. Border: BorderTheme{
  89. Enabled: true,
  90. Padding: [...]int{0, 0, 1, 1},
  91. Color: "default",
  92. ActiveColor: "green",
  93. Preset: BorderPreset{
  94. Horizontal: tview.Borders.Horizontal,
  95. Vertical: tview.Borders.Vertical,
  96. TopLeft: tview.Borders.TopLeft,
  97. TopRight: tview.Borders.TopRight,
  98. BottomLeft: tview.Borders.BottomLeft,
  99. BottomRight: tview.Borders.BottomRight,
  100. },
  101. },
  102. BackgroundColor: "default",
  103. TitleColor: "default",
  104. ActiveTitleColor: "green",
  105. GuildsTree: GuildsTreeTheme{
  106. AutoExpandFolders: true,
  107. ChannelColor: tview.Styles.PrimaryTextColor.String(),
  108. Graphics: true,
  109. GuildColor: tview.Styles.PrimaryTextColor.String(),
  110. PrivateChannelColor: tview.Styles.PrimaryTextColor.String(),
  111. },
  112. MessagesText: MessagesTextTheme{
  113. ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ",
  114. AuthorColor: "aqua",
  115. ContentColor: tview.Styles.PrimaryTextColor.String(),
  116. EmojiColor: "green",
  117. LinkColor: "blue",
  118. AttachmentColor: "yellow",
  119. },
  120. }
  121. }