feat(config): add keys.guilds_tree.yank (#508)

Co-authored-by: ayn2op <ayn2op@mac.local>
This commit is contained in:
Ayyan 2025-02-25 19:42:17 -05:00 • committed by GitHub
parent 70df24ae39
commit bad44a4490
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import (
"sort"
"strings"
"github.com/atotto/clipboard"
"github.com/ayn2op/discordo/internal/config"
"github.com/diamondburned/arikawa/v3/discord"
"github.com/diamondburned/arikawa/v3/gateway"
@ -237,6 +238,18 @@ func (gt *GuildsTree) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
case gt.cfg.Keys.GuildsTree.SelectCurrent:
return tcell.NewEventKey(tcell.KeyEnter, 0, tcell.ModNone)
case gt.cfg.Keys.GuildsTree.YankID:
node := gt.GetCurrentNode()
if node == nil {
return nil
}
// Reference of a tree node in the guilds tree is its ID.
// discord.Snowflake (discord.GuildID and discord.ChannelID) have the String method.
if id, ok := node.GetReference().(fmt.Stringer); ok {
go clipboard.WriteAll(id.String())
}
}
return nil

View file

@ -25,6 +25,7 @@ type (
GuildsTreeKeys struct {
NavigationKeys
SelectCurrent string `toml:"select_current"`
YankID string `toml:"yank_id"`
}
MessagesTextKeys struct {
@ -64,6 +65,7 @@ func defaultKeys() Keys {
SelectLast: "Rune[G]",
},
SelectCurrent: "Enter",
YankID: "Rune[y]",
},
MessagesText: MessagesTextKeys{