refactor!: move indents config to sidebar table (#793)

This commit is contained in:
ayn2op 2026-04-19 20:14:35 -04:00 • committed by GitHub
parent 3d03359078
commit 01fc26612a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 28 deletions

View file

@ -80,8 +80,18 @@ type (
Leaf string `toml:"leaf"`
}
SidebarIndentsConfig struct {
Guild int `toml:"guild"`
Category int `toml:"category"`
Channel int `toml:"channel"`
Forum int `toml:"forum"`
GroupDM int `toml:"group_dm"`
DM int `toml:"dm"`
}
SidebarConfig struct {
Markers SidebarMarkersConfig `toml:"markers"`
Indents SidebarIndentsConfig `toml:"indents"`
}
Config struct {

View file

@ -68,6 +68,15 @@ expanded = "▾ "
collapsed = "▸ "
leaf = ""
# Indentation for different item types.
[sidebar.indents]
dm = 2
group_dm = 1
guild = 2
category = 1
channel = 2
forum = 2
[icons]
guild_category = ""
guild_text = "#"
@ -203,15 +212,6 @@ idle_style = { foreground = "yellow" }
dnd_style = { foreground = "red" }
offline_style = { foreground = "gray" }
# Guilds tree indentation for different item types
[theme.guilds_tree.indents]
dm = 2
group_dm = 1
guild = 2 # server inside a folder
category = 1
channel = 2
forum = 2
[theme.scroll_bar]
visibility = "auto"
# "minimal", "box_drawing", or "unicode"

View file

@ -208,7 +208,6 @@ type (
AutoExpandFolders bool `toml:"auto_expand_folders"`
Graphics bool `toml:"graphics"`
GraphicsColor string `toml:"graphics_color"`
Indents GuildsTreeIndents `toml:"indents"`
OnlineStyle StyleWrapper `toml:"online_style"`
IdleStyle StyleWrapper `toml:"idle_style"`
@ -216,15 +215,6 @@ type (
OfflineStyle StyleWrapper `toml:"offline_style"`
}
GuildsTreeIndents struct {
Guild int `toml:"guild"`
Category int `toml:"category"`
Channel int `toml:"channel"`
Forum int `toml:"forum"`
GroupDM int `toml:"group_dm"`
DM int `toml:"dm"`
}
MessagesListTheme struct {
ReplyIndicator string `toml:"reply_indicator"`
ForwardedIndicator string `toml:"forwarded_indicator"`

View file

@ -220,7 +220,7 @@ func (gt *guildsTree) createGuildNode(n *tview.TreeNode, guild discord.Guild) {
SetReference(guild.ID).
SetExpandable(true).
SetExpanded(false).
SetIndent(gt.cfg.Theme.GuildsTree.Indents.Guild)
SetIndent(gt.cfg.Sidebar.Indents.Guild)
gt.setNodeLineStyle(guildNode, gt.guildNodeStyle(guild.ID))
n.AddChild(guildNode)
gt.guildNodeByID[guild.ID] = guildNode
@ -231,21 +231,22 @@ func (gt *guildsTree) createChannelNode(node *tview.TreeNode, channel discord.Ch
return
}
indents := gt.cfg.Sidebar.Indents
channelNode := tview.NewTreeNode(ui.ChannelToString(channel, gt.cfg.Icons, gt.chat.state)).SetReference(channel.ID)
gt.setNodeLineStyle(channelNode, gt.channelNodeStyle(channel))
switch channel.Type {
case discord.DirectMessage:
channelNode.SetIndent(gt.cfg.Theme.GuildsTree.Indents.DM)
channelNode.SetIndent(indents.DM)
case discord.GroupDM:
channelNode.SetIndent(gt.cfg.Theme.GuildsTree.Indents.GroupDM)
channelNode.SetIndent(indents.GroupDM)
case discord.GuildCategory:
channelNode.SetIndent(gt.cfg.Theme.GuildsTree.Indents.Category)
channelNode.SetIndent(indents.Category)
channelNode.SetExpandable(true).SetExpanded(true)
case discord.GuildForum:
channelNode.SetIndent(gt.cfg.Theme.GuildsTree.Indents.Forum)
channelNode.SetIndent(indents.Forum)
channelNode.SetExpandable(true).SetExpanded(false)
default:
channelNode.SetIndent(gt.cfg.Theme.GuildsTree.Indents.Channel)
channelNode.SetIndent(indents.Channel)
}
node.AddChild(channelNode)
gt.channelNodeByID[channel.ID] = channelNode