build: switch to tcell/v3 (#655)

This commit is contained in:
Ayyan 2025-12-08 22:35:40 -08:00 • committed by GitHub
parent 7e8af16e72
commit d29de744fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 36 additions and 33 deletions

View file

@ -6,7 +6,7 @@ import (
"github.com/ayn2op/discordo/internal/config"
"github.com/ayn2op/discordo/internal/login"
"github.com/ayn2op/tview"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v3"
"golang.design/x/clipboard"
)
@ -71,7 +71,7 @@ func (a *application) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
return nil
case "Ctrl+C":
// https://github.com/ayn2op/tview/blob/a64fc48d7654432f71922c8b908280cdb525805c/application.go#L153
return tcell.NewEventKey(tcell.KeyCtrlC, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyCtrlC, "", tcell.ModNone)
}
return event

View file

@ -8,7 +8,7 @@ import (
"github.com/ayn2op/discordo/internal/ui"
"github.com/ayn2op/tview"
"github.com/diamondburned/arikawa/v3/discord"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v3"
)
const (

View file

@ -12,7 +12,7 @@ import (
"github.com/diamondburned/arikawa/v3/discord"
"github.com/diamondburned/arikawa/v3/gateway"
"github.com/diamondburned/ningen/v3"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v3"
"golang.design/x/clipboard"
)
@ -242,12 +242,12 @@ func (gt *guildsTree) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
gt.collapseParentNode(gt.GetCurrentNode())
return nil
case gt.cfg.Keys.GuildsTree.MoveToParentNode:
return tcell.NewEventKey(tcell.KeyRune, 'K', tcell.ModNone)
return tcell.NewEventKey(tcell.KeyRune, "K", tcell.ModNone)
case gt.cfg.Keys.GuildsTree.SelectPrevious:
return tcell.NewEventKey(tcell.KeyUp, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone)
case gt.cfg.Keys.GuildsTree.SelectNext:
return tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyDown, "", tcell.ModNone)
case gt.cfg.Keys.GuildsTree.SelectFirst:
gt.Move(gt.GetRowCount() * -1)
// return tcell.NewEventKey(tcell.KeyHome, 0, tcell.ModNone)
@ -256,7 +256,7 @@ func (gt *guildsTree) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
// return tcell.NewEventKey(tcell.KeyEnd, 0, tcell.ModNone)
case gt.cfg.Keys.GuildsTree.SelectCurrent:
return tcell.NewEventKey(tcell.KeyEnter, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyEnter, "", tcell.ModNone)
case gt.cfg.Keys.GuildsTree.YankID:
gt.yankID()

View file

@ -25,7 +25,7 @@ import (
"github.com/diamondburned/arikawa/v3/utils/json/option"
"github.com/diamondburned/arikawa/v3/utils/sendpart"
"github.com/diamondburned/ningen/v3/discordmd"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v3"
"github.com/ncruces/zenity"
"github.com/sahilm/fuzzy"
"github.com/yuin/goldmark/ast"
@ -90,7 +90,7 @@ func (mi *messageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
switch event.Name() {
case mi.cfg.Keys.MessageInput.Paste:
mi.paste()
return tcell.NewEventKey(tcell.KeyCtrlV, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyCtrlV, "", tcell.ModNone)
case mi.cfg.Keys.MessageInput.Send:
if app.chatView.GetVisibile(mentionsListPageName) {
@ -125,10 +125,10 @@ func (mi *messageInput) onInputCapture(event *tcell.EventKey) *tcell.EventKey {
if app.chatView.GetVisibile(mentionsListPageName) {
switch event.Name() {
case mi.cfg.Keys.MentionsList.Up:
mi.mentionsList.InputHandler()(tcell.NewEventKey(tcell.KeyUp, 0, tcell.ModNone), nil)
mi.mentionsList.InputHandler()(tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone), nil)
return nil
case mi.cfg.Keys.MentionsList.Down:
mi.mentionsList.InputHandler()(tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone), nil)
mi.mentionsList.InputHandler()(tcell.NewEventKey(tcell.KeyDown, "", tcell.ModNone), nil)
return nil
}
}

View file

@ -25,7 +25,7 @@ import (
"github.com/diamondburned/arikawa/v3/state"
"github.com/diamondburned/arikawa/v3/utils/json/option"
"github.com/diamondburned/ningen/v3/discordmd"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v3"
"github.com/skratchdot/open-golang/open"
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/parser"
@ -198,7 +198,8 @@ func (ml *messagesList) drawDefaultMessage(w io.Writer, message discord.Message)
for _, a := range message.Attachments {
fmt.Fprintln(w)
fg, bg, _ := ml.cfg.Theme.MessagesList.AttachmentStyle.Decompose()
fg := ml.cfg.Theme.MessagesList.AttachmentStyle.GetForeground()
bg := ml.cfg.Theme.MessagesList.AttachmentStyle.GetBackground()
if ml.cfg.ShowAttachmentLinks {
fmt.Fprintf(w, "[%s:%s]%s:\n%s[-:-]", fg, bg, a.Filename, a.URL)
} else {
@ -458,13 +459,13 @@ func (ml *messagesList) showAttachmentsList(urls []string, attachments []discord
SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Name() {
case ml.cfg.Keys.MessagesList.SelectPrevious:
return tcell.NewEventKey(tcell.KeyUp, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyUp, "", tcell.ModNone)
case ml.cfg.Keys.MessagesList.SelectNext:
return tcell.NewEventKey(tcell.KeyDown, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyDown, "", tcell.ModNone)
case ml.cfg.Keys.MessagesList.SelectFirst:
return tcell.NewEventKey(tcell.KeyHome, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyHome, "", tcell.ModNone)
case ml.cfg.Keys.MessagesList.SelectLast:
return tcell.NewEventKey(tcell.KeyEnd, 0, tcell.ModNone)
return tcell.NewEventKey(tcell.KeyEnd, "", tcell.ModNone)
}
return event

4
go.mod
View file

@ -5,11 +5,11 @@ go 1.25.3
require (
github.com/BurntSushi/toml v1.5.0
github.com/andybalholm/brotli v1.2.0
github.com/ayn2op/tview v0.0.0-20251208201522-07345f151518
github.com/ayn2op/tview v0.0.0-20251208234354-304b7f6e9e9d
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb
github.com/diamondburned/arikawa/v3 v3.6.1-0.20250928004212-a891a653eb26
github.com/diamondburned/ningen/v3 v3.0.1-0.20250920191746-98fbd92e134d
github.com/gdamore/tcell/v2 v2.13.2
github.com/gdamore/tcell/v3 v3.0.2
github.com/gen2brain/beeep v0.11.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3

8
go.sum
View file

@ -27,8 +27,8 @@ github.com/akavel/rsrc v0.10.2 h1:Zxm8V5eI1hW4gGaYsJQUhxpjkENuG91ki8B4zCrvEsw=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/ayn2op/tview v0.0.0-20251208201522-07345f151518 h1:Dp4n/gjX7kjDeuu8fC3mF0/F7WqRi9qZ9TXurWePWqs=
github.com/ayn2op/tview v0.0.0-20251208201522-07345f151518/go.mod h1:+W5L37Sfwa+fucRkCHTHjthH+zoWXoAr3LwmFHy+8G4=
github.com/ayn2op/tview v0.0.0-20251208234354-304b7f6e9e9d h1:KajT53WJzVV3CKfxkphJiwsVChXHOVeBHwMQffjawRM=
github.com/ayn2op/tview v0.0.0-20251208234354-304b7f6e9e9d/go.mod h1:w/5UGxmYFBWxiIFw1FEw6myjGhDiahp8J8pUfCUEmlw=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
@ -54,8 +54,8 @@ github.com/esiqveland/notify v0.13.3 h1:QCMw6o1n+6rl+oLUfg8P1IIDSFsDEb2WlXvVvIJb
github.com/esiqveland/notify v0.13.3/go.mod h1:hesw/IRYTO0x99u1JPweAl4+5mwXJibQVUcP0Iu5ORE=
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
github.com/gdamore/tcell/v2 v2.13.2 h1:5j4srfF8ow3HICOv/61/sOhQtA25qxEB2XR3Q/Bhx2g=
github.com/gdamore/tcell/v2 v2.13.2/go.mod h1:+Wfe208WDdB7INEtCsNrAN6O2m+wsTPk1RAovjaILlo=
github.com/gdamore/tcell/v3 v3.0.2 h1:1sM7T9uc/iqQiJCliTBuqGcWAWksI355ejAfkPYHmVs=
github.com/gdamore/tcell/v3 v3.0.2/go.mod h1:OoJxRXVKR7ROCFzAIUkHHy/7mWTkz9sNfWLhdEsNHVM=
github.com/gen2brain/beeep v0.11.1 h1:EbSIhrQZFDj1K2fzlMpAYlFOzV8YuNe721A58XcCTYI=
github.com/gen2brain/beeep v0.11.1/go.mod h1:jQVvuwnLuwOcdctHn/uyh8horSBNJ8uGb9Cn2W4tvoc=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=

View file

@ -4,7 +4,7 @@ import (
"errors"
"github.com/ayn2op/tview"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v3"
)
var errInvalidType = errors.New("invalid type")
@ -165,8 +165,6 @@ func stringToAttrMask(s string) tcell.AttrMask {
return tcell.AttrBlink
case "reverse":
return tcell.AttrReverse
case "underline":
return tcell.AttrUnderline
case "dim":
return tcell.AttrDim
case "italic":

View file

@ -22,7 +22,7 @@ import (
"github.com/ayn2op/discordo/internal/ui"
"github.com/ayn2op/tview"
"github.com/diamondburned/arikawa/v3/api"
"github.com/gdamore/tcell/v2"
"github.com/gdamore/tcell/v3"
"github.com/gorilla/websocket"
"github.com/skip2/go-qrcode"
)

View file

@ -92,7 +92,8 @@ func (r *Renderer) renderAutoLink(w io.Writer, node *ast.AutoLink, entering bool
urlStyle := r.theme.URLStyle
if entering {
fg, bg, _ := urlStyle.Decompose()
fg := urlStyle.GetForeground()
bg := urlStyle.GetBackground()
fmt.Fprintf(w, "[%s:%s]", fg, bg)
w.Write(node.URL(source))
} else {
@ -103,7 +104,8 @@ func (r *Renderer) renderAutoLink(w io.Writer, node *ast.AutoLink, entering bool
func (r *Renderer) renderLink(w io.Writer, node *ast.Link, entering bool) {
urlStyle := r.theme.URLStyle
if entering {
fg, bg, _ := urlStyle.Decompose()
fg := urlStyle.GetForeground()
bg := urlStyle.GetBackground()
fmt.Fprintf(w, "[%s:%s::%s]", fg, bg, node.Destination)
} else {
io.WriteString(w, "[-:-::-]")
@ -163,7 +165,8 @@ func (r *Renderer) renderInline(w io.Writer, node *discordmd.Inline, entering bo
func (r *Renderer) renderMention(w io.Writer, node *discordmd.Mention, entering bool) {
mentionStyle := r.theme.MentionStyle
if entering {
fg, bg, _ := mentionStyle.Decompose()
fg := mentionStyle.GetForeground()
bg := mentionStyle.GetBackground()
fmt.Fprintf(w, "[%s:%s:b]", fg, bg)
switch {
@ -185,9 +188,10 @@ func (r *Renderer) renderMention(w io.Writer, node *discordmd.Mention, entering
}
func (r *Renderer) renderEmoji(w io.Writer, node *discordmd.Emoji, entering bool) {
emojiStyle := r.theme.EmojiStyle
if entering {
fg, bg, _ := emojiStyle.Decompose()
emojiStyle := r.theme.EmojiStyle
fg := emojiStyle.GetForeground()
bg := emojiStyle.GetBackground()
fmt.Fprintf(w, "[%s:%s]", fg, bg)
io.WriteString(w, ":"+node.Name+":")
} else {