Răsfoiți Sursa

Color-coded attachements & link toggling (#438)

Co-authored-by: Ayyan <119342035+ayn2op@users.noreply.github.com>
Retropaint 1 an în urmă
părinte
comite
a6e6388322
3 a modificat fișierele cu 19 adăugiri și 9 ștergeri
  1. 5 1
      cmd/messages_text.go
  2. 4 0
      internal/config/config.go
  3. 10 8
      internal/config/theme.go

+ 5 - 1
cmd/messages_text.go

@@ -160,7 +160,11 @@ func (mt *MessagesText) createBody(w io.Writer, m discord.Message, isReply bool)
 func (mt *MessagesText) createFooter(w io.Writer, m discord.Message) {
 	for _, a := range m.Attachments {
 		fmt.Fprintln(w)
-		fmt.Fprintf(w, "[%s]: %s", a.Filename, a.URL)
+		if cfg.ShowAttachmentLinks { 
+			fmt.Fprintf(w, "[%s][%s]:\n%s[-]", cfg.Theme.MessagesText.AttachmentColor, a.Filename, a.URL)
+		} else {
+			fmt.Fprintf(w, "[%s][%s][-]", cfg.Theme.MessagesText.AttachmentColor, a.Filename)
+		}
 	}
 }
 

+ 4 - 0
internal/config/config.go

@@ -20,6 +20,8 @@ type Config struct {
 	TimestampsBeforeAuthor bool   `toml:"timestamps_before_author"`
 	TimestampsFormat       string `toml:"timestamps_format"`
 
+	ShowAttachmentLinks bool `toml:"show_attachment_links"`
+
 	Keys  Keys  `toml:"keys"`
 	Theme Theme `toml:"theme"`
 }
@@ -34,6 +36,8 @@ func defaultConfig() *Config {
 		Timestamps:             false,
 		TimestampsBeforeAuthor: false,
 		TimestampsFormat:       time.Kitchen,
+	
+		ShowAttachmentLinks: true,
 
 		Keys:  defaultKeys(),
 		Theme: defaultTheme(),

+ 10 - 8
internal/config/theme.go

@@ -26,10 +26,11 @@ type (
 	MessagesTextTheme struct {
 		ReplyIndicator string `toml:"reply_indicator"`
 
-		AuthorColor  string `toml:"author_color"`
-		ContentColor string `toml:"content_color"`
-		EmojiColor   string `toml:"emoji_color"`
-		LinkColor    string `toml:"link_color"`
+		AuthorColor     string `toml:"author_color"`
+		ContentColor    string `toml:"content_color"`
+		EmojiColor      string `toml:"emoji_color"`
+		LinkColor       string `toml:"link_color"`
+		AttachmentColor string `toml:"attachment_color"`
 	}
 )
 
@@ -52,10 +53,11 @@ func defaultTheme() Theme {
 		MessagesText: MessagesTextTheme{
 			ReplyIndicator: string(tview.BoxDrawingsLightArcDownAndRight) + " ",
 
-			AuthorColor:  "aqua",
-			ContentColor: tview.Styles.PrimaryTextColor.String(),
-			EmojiColor:   "green",
-			LinkColor:    "blue",
+			AuthorColor:     "aqua",
+			ContentColor:    tview.Styles.PrimaryTextColor.String(),
+			EmojiColor:      "green",
+			LinkColor:       "blue",
+			AttachmentColor: "yellow",
 		},
 	}
 }