theme.go 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package config
  2. import (
  3. "github.com/ayn2op/tview"
  4. )
  5. type BorderSetWrapper struct{ tview.BorderSet }
  6. func (bw *BorderSetWrapper) UnmarshalTOML(v any) error {
  7. switch v.(string) {
  8. case "plain":
  9. bw.BorderSet = tview.BorderSetPlain()
  10. case "round":
  11. bw.BorderSet = tview.BorderSetRound()
  12. case "thick":
  13. bw.BorderSet = tview.BorderSetThick()
  14. case "double":
  15. bw.BorderSet = tview.BorderSetDouble()
  16. }
  17. return nil
  18. }
  19. type AlignmentWrapper struct{ tview.Alignment }
  20. func (aw *AlignmentWrapper) UnmarshalTOML(v any) error {
  21. switch v.(string) {
  22. case "left":
  23. aw.Alignment = tview.AlignmentLeft
  24. case "center":
  25. aw.Alignment = tview.AlignmentCenter
  26. case "right":
  27. aw.Alignment = tview.AlignmentRight
  28. }
  29. return nil
  30. }
  31. type (
  32. BorderTheme struct {
  33. Enabled bool `toml:"enabled"`
  34. Padding [4]int `toml:"padding"`
  35. Set BorderSetWrapper `toml:"set"`
  36. Color string `toml:"color"`
  37. ActiveColor string `toml:"active_color"`
  38. }
  39. TitleTheme struct {
  40. Color string `toml:"color"`
  41. ActiveColor string `toml:"active_color"`
  42. Alignment AlignmentWrapper `toml:"alignment"`
  43. }
  44. Theme struct {
  45. BackgroundColor string `toml:"background_color"`
  46. Title TitleTheme `toml:"title"`
  47. Border BorderTheme `toml:"border"`
  48. GuildsTree GuildsTreeTheme `toml:"guilds_tree"`
  49. MessagesText MessagesTextTheme `toml:"messages_text"`
  50. }
  51. GuildsTreeTheme struct {
  52. AutoExpandFolders bool `toml:"auto_expand_folders"`
  53. Graphics bool `toml:"graphics"`
  54. PrivateChannelColor string `toml:"private_channel_color"`
  55. GuildColor string `toml:"guild_color"`
  56. ChannelColor string `toml:"channel_color"`
  57. }
  58. MessagesTextTheme struct {
  59. ShowNicknames bool `toml:"show_user_nicks"`
  60. ShowUsernameColors bool `toml:"show_user_colors"`
  61. ReplyIndicator string `toml:"reply_indicator"`
  62. ForwardedIndicator string `toml:"forwarded_indicator"`
  63. AuthorColor string `toml:"author_color"`
  64. ContentColor string `toml:"content_color"`
  65. EmojiColor string `toml:"emoji_color"`
  66. LinkColor string `toml:"link_color"`
  67. AttachmentColor string `toml:"attachment_color"`
  68. }
  69. )