diff --git a/internal/config/config.go b/internal/config/config.go index b65f95e..666835c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -36,6 +36,21 @@ type ( Receive bool `toml:"receive"` } + Icons struct { + GuildCategory string `toml:"guild_category"` + GuildText string `toml:"guild_text"` + GuildVoice string `toml:"guild_voice"` + GuildStageVoice string `toml:"guild_stage_voice"` + + GuildAnnouncementThread string `toml:"guild_announcement_thread"` + GuildPublicThread string `toml:"guild_public_thread"` + GuildPrivateThread string `toml:"guild_private_thread"` + + GuildAnnouncement string `toml:"guild_announcement"` + GuildForum string `toml:"guild_forum"` + GuildStore string `toml:"guild_store"` + } + Config struct { AutoFocus bool `toml:"auto_focus"` Mouse bool `toml:"mouse"` @@ -55,6 +70,8 @@ type ( Notifications Notifications `toml:"notifications"` TypingIndicator TypingIndicator `toml:"typing_indicator"` + Icons Icons `toml:"icons"` + Keys Keys `toml:"keys"` Theme Theme `toml:"theme"` } diff --git a/internal/config/config.toml b/internal/config/config.toml index c92582b..f6cf1f7 100644 --- a/internal/config/config.toml +++ b/internal/config/config.toml @@ -41,6 +41,18 @@ send = true # Whether to receive typing status or not. receive = true +[icons] +guild_category = "" +guild_text = "#" +guild_voice = "♪ " +guild_stage_voice = "♪ " +guild_announcement_thread = "a-" +guild_public_thread = "› " +guild_private_thread = "› " +guild_announcement = "a-" +guild_forum = "≡ " +guild_store = "s-" + # Global shortcuts # Esc: Reset message selection or close the channel selection popup. [keys] diff --git a/internal/ui/chat/guilds_tree.go b/internal/ui/chat/guilds_tree.go index 9ad8420..0f2727f 100644 --- a/internal/ui/chat/guilds_tree.go +++ b/internal/ui/chat/guilds_tree.go @@ -99,7 +99,7 @@ func (gt *guildsTree) createChannelNode(node *tview.TreeNode, channel discord.Ch return } - channelNode := tview.NewTreeNode(ui.ChannelToString(channel)). + channelNode := tview.NewTreeNode(ui.ChannelToString(channel, gt.cfg.Icons)). SetReference(channel.ID). SetTextStyle(gt.getChannelNodeStyle(channel.ID)) node.AddChild(channelNode) diff --git a/internal/ui/chat/messages_list.go b/internal/ui/chat/messages_list.go index 4a64ee2..d6a6080 100644 --- a/internal/ui/chat/messages_list.go +++ b/internal/ui/chat/messages_list.go @@ -74,7 +74,7 @@ func (ml *messagesList) reset() { } func (ml *messagesList) setTitle(channel discord.Channel) { - title := ui.ChannelToString(channel) + title := ui.ChannelToString(channel, ml.cfg.Icons) if topic := channel.Topic; topic != "" { title += " - " + topic } diff --git a/internal/ui/util.go b/internal/ui/util.go index aeca96c..88f0865 100644 --- a/internal/ui/util.go +++ b/internal/ui/util.go @@ -58,7 +58,8 @@ func Centered(p tview.Primitive, width, height int) tview.Primitive { AddItem(p, 1, 1, 1, 1, 0, 0, true) } -func ChannelToString(channel discord.Channel) string { +func ChannelToString(channel discord.Channel, icons config.Icons) string { + var icon string switch channel.Type { case discord.DirectMessage, discord.GroupDM: if channel.Name != "" { @@ -71,19 +72,30 @@ func ChannelToString(channel discord.Channel) string { } return strings.Join(recipients, ", ") + + case discord.GuildCategory: + icon = icons.GuildCategory case discord.GuildText: - return "#" + channel.Name - case discord.GuildVoice, discord.GuildStageVoice: - return "v-" + channel.Name + icon = icons.GuildText + case discord.GuildVoice: + icon = icons.GuildVoice + case discord.GuildStageVoice: + icon = icons.GuildStageVoice + + case discord.GuildAnnouncementThread: + icon = icons.GuildAnnouncementThread + case discord.GuildPublicThread: + icon = icons.GuildPublicThread + case discord.GuildPrivateThread: + icon = icons.GuildPrivateThread + case discord.GuildAnnouncement: - return "a-" + channel.Name - case discord.GuildStore: - return "s-" + channel.Name + icon = icons.GuildAnnouncement case discord.GuildForum: - return "f-" + channel.Name - case discord.GuildPublicThread, discord.GuildPrivateThread, discord.GuildAnnouncementThread: - return "t-" + channel.Name - default: - return channel.Name + icon = icons.GuildForum + case discord.GuildStore: + icon = icons.GuildStore } + + return icon + channel.Name }