fix: highlight messages using mouse (#441)
This commit is contained in:
parent
431c40f220
commit
54c55eb69b
1 changed files with 14 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"io"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/atotto/clipboard"
|
||||
|
|
@ -55,6 +56,8 @@ func newMessagesText() *MessagesText {
|
|||
renderer.WithOption("linkColor", cfg.Theme.MessagesText.LinkColor),
|
||||
)
|
||||
|
||||
mt.SetHighlightedFunc(mt.onHighlighted)
|
||||
|
||||
return mt
|
||||
}
|
||||
|
||||
|
|
@ -280,6 +283,17 @@ func (mt *MessagesText) _select(name string) {
|
|||
mt.ScrollToHighlight()
|
||||
}
|
||||
|
||||
func (mt *MessagesText) onHighlighted(added, removed, remaining []string) {
|
||||
if (len(added) > 0) {
|
||||
mID, err := strconv.ParseInt(added[0], 10, 64)
|
||||
if err != nil {
|
||||
slog.Error("Failed to parse region id as int to use as message id.","err",err)
|
||||
return
|
||||
}
|
||||
mt.selectedMessageID = discord.MessageID(mID)
|
||||
}
|
||||
}
|
||||
|
||||
func (mt *MessagesText) yank() {
|
||||
msg, err := mt.getSelectedMessage()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue