Selected server will now be marked blue
MODIFY
internal/ui/window.go
internal/ui/window.go
@@ -68,20 +68,29 @@ func NewWindow(discord *discordgo.Session) (*Window, error) {
channelTree.SetBorder(true)
channelTree.SetTopLevel(1)
- guildList := tview.NewList()
+ guildList := tview.NewTreeView()
+ guildRootNode := tview.NewTreeNode("")
+ guildList.SetRoot(guildRootNode)
guildList.SetBorder(true)
- guildList.ShowSecondaryText(false)
- for _, guild := range guilds {
- guildList.AddItem(guild.Name, "", 0, nil)
- }
-
- guildList.SetSelectedFunc(func(index int, primary, secondary string, shortcut rune) {
- for _, guild := range guilds {
- if guild.Name == primary {
+ guildList.SetTopLevel(1)
+
+ var selectedGuildNode *tview.TreeNode
+ for _, tempGuild := range guilds {
+ guild := tempGuild
+ guildNode := tview.NewTreeNode(guild.Name)
+ guildRootNode.AddChild(guildNode)
+ guildNode.SetSelectable(true)
+ guildNode.SetSelectedFunc(func() {
if window.killCurrentGuildUpdateThread != nil {
*window.killCurrentGuildUpdateThread <- true
}
+ if selectedGuildNode != nil {
+ selectedGuildNode.SetColor(tcell.ColorWhite)
+ }
+ selectedGuildNode = guildNode
+ selectedGuildNode.SetColor(tcell.ColorTeal)
+
window.selectedGuild = guild
channelRootNode.ClearChildren()
@@ -154,10 +163,9 @@ func NewWindow(discord *discordgo.Session) (*Window, error) {
}
}
}()
- break
- }
- }
})
+ }
+ guildList.SetCurrentNode(guildRootNode)
guildPage.AddItem(guildList, 0, 1, true)
guildPage.AddItem(channelTree, 0, 2, true)

Selected server will now be marked blue