build(deps): upgrade tview to latest

This commit is contained in:
ayn2op 2026-03-15 02:35:53 -04:00
parent 74d485c96d
commit 9ec330ba38
9 changed files with 44 additions and 35 deletions

2
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/alecthomas/chroma/v2 v2.23.1
github.com/andybalholm/brotli v1.2.0
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97
github.com/ayn2op/tview v0.0.0-20260315010736-d2153f13054e
github.com/ayn2op/tview v0.0.0-20260315070900-cf84a0d532d9
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb
github.com/diamondburned/arikawa/v3 v3.6.1-0.20260311205148-176ad9b9440f
github.com/diamondburned/ningen/v3 v3.0.1-0.20260306213430-5a08d3a709b4

4
go.sum
View file

@ -16,8 +16,8 @@ github.com/andybalholm/brotli v1.2.0 h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwTo
github.com/andybalholm/brotli v1.2.0/go.mod h1:rzTDkvFWvIrjDXZHkuS16NPggd91W3kUSvPlQ1pLaKY=
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97 h1:WujETUV+v0DEJyZgjeLzQvihWyL80c0Tg4qf0dDo+Io=
github.com/ayn2op/clipboard v0.0.0-20260308203959-c5ad7df3fc97/go.mod h1:3kFnpNCa3dF6WryzOMCDao7PfZ7DTCh+pievlfuwV80=
github.com/ayn2op/tview v0.0.0-20260315010736-d2153f13054e h1:BRXzZGLUR+zTZ2Dg4/FF1vMNTsZ+6ftmazbUFUIwgJ8=
github.com/ayn2op/tview v0.0.0-20260315010736-d2153f13054e/go.mod h1:lZ8RdOegQWBQafTOasGE7Ps1/Ymy4jmXoPt5vz2QsS0=
github.com/ayn2op/tview v0.0.0-20260315070900-cf84a0d532d9 h1:XcMapeKrJg1SySKwxKJIdDlzTCH2KeHBTxFR+PwT7A8=
github.com/ayn2op/tview v0.0.0-20260315070900-cf84a0d532d9/go.mod h1:IXZrCv1VAZyWPdKDUJYs9ZYFiJ1GmCQUo9tLjQWoSnU=
github.com/danieljoos/wincred v1.2.3 h1:v7dZC2x32Ut3nEfRH+vhoZGvN72+dQ/snVXo/vMFLdQ=
github.com/danieljoos/wincred v1.2.3/go.mod h1:6qqX0WNrS4RzPZ1tnroDzq9kY3fu1KwE7MRLQK4X0bs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

View file

@ -4,6 +4,7 @@ import (
"errors"
"github.com/ayn2op/tview"
"github.com/ayn2op/tview/list"
"github.com/gdamore/tcell/v3"
)
@ -151,7 +152,7 @@ func (gw *GlyphSetWrapper) UnmarshalTOML(val any) error {
return nil
}
type ScrollBarVisibilityWrapper struct{ tview.ScrollBarVisibility }
type ScrollBarVisibilityWrapper struct{ list.ScrollBarVisibility }
func (vw *ScrollBarVisibilityWrapper) UnmarshalTOML(val any) error {
s, ok := val.(string)
@ -161,11 +162,11 @@ func (vw *ScrollBarVisibilityWrapper) UnmarshalTOML(val any) error {
switch s {
case "automatic", "auto":
vw.ScrollBarVisibility = tview.ScrollBarVisibilityAutomatic
vw.ScrollBarVisibility = list.ScrollBarVisibilityAutomatic
case "always":
vw.ScrollBarVisibility = tview.ScrollBarVisibilityAlways
vw.ScrollBarVisibility = list.ScrollBarVisibilityAlways
case "never", "hidden", "off":
vw.ScrollBarVisibility = tview.ScrollBarVisibilityNever
vw.ScrollBarVisibility = list.ScrollBarVisibilityNever
}
return nil

View file

@ -23,7 +23,9 @@ var _ help.KeyMap = (*channelsPicker)(nil)
func newChannelsPicker(cfg *config.Config, chatView *Model) *channelsPicker {
cp := &channelsPicker{picker.New(), chatView}
cp.Box = ui.ConfigureBox(tview.NewBox(), &cfg.Theme)
// When a child of tview.Flex is focused, tview.Flex itself is not reported as focused. Instead, the focused child (picker) is considered focused. Therefore, we manually set the active border style on the picker to ensure it displays the correct focused appearance.
// When a child of the parent flex is focused, the parent layout itself is not reported as focused.
// Instead, the focused child (picker) is considered focused.
// Therefore, we manually set the active border style on the picker to ensure it displays the correct focused appearance.
cp.
SetBlurFunc(nil).
SetFocusFunc(nil).

View file

@ -4,6 +4,7 @@ import (
"github.com/ayn2op/discordo/internal/config"
"github.com/ayn2op/discordo/internal/ui"
"github.com/ayn2op/tview"
"github.com/ayn2op/tview/list"
"github.com/gdamore/tcell/v3"
)
@ -14,13 +15,13 @@ type mentionsListItem struct {
}
type mentionsList struct {
*tview.List
*list.Model
items []mentionsListItem
}
func newMentionsList(cfg *config.Config) *mentionsList {
m := &mentionsList{
List: tview.NewList(),
Model: list.NewModel(),
}
m.Box = ui.ConfigureBox(m.Box, &cfg.Theme)
@ -43,7 +44,7 @@ func (m *mentionsList) clear() {
}
func (m *mentionsList) rebuild() {
m.SetBuilder(func(index int, cursor int) tview.ListItem {
m.SetBuilder(func(index int, cursor int) list.Item {
if index < 0 || index >= len(m.items) {
return nil
}

View file

@ -25,6 +25,7 @@ import (
"github.com/ayn2op/tview"
"github.com/ayn2op/tview/help"
"github.com/ayn2op/tview/keybind"
"github.com/ayn2op/tview/list"
"github.com/diamondburned/arikawa/v3/api"
"github.com/diamondburned/arikawa/v3/discord"
"github.com/diamondburned/arikawa/v3/gateway"
@ -41,7 +42,7 @@ import (
)
type messagesList struct {
*tview.List
*list.Model
cfg *config.Config
chatView *Model
messages []discord.Message
@ -81,7 +82,7 @@ type messagesListRow struct {
func newMessagesList(cfg *config.Config, chatView *Model) *messagesList {
ml := &messagesList{
List: tview.NewList(),
Model: list.NewModel(),
cfg: cfg,
chatView: chatView,
renderer: markdown.NewRenderer(cfg),
@ -162,7 +163,7 @@ func (ml *messagesList) clearSelection() {
ml.SetCursor(-1)
}
func (ml *messagesList) buildItem(index int, cursor int) tview.ListItem {
func (ml *messagesList) buildItem(index int, cursor int) list.Item {
ml.ensureRows()
if index < 0 || index >= len(ml.rows) {
@ -277,7 +278,7 @@ func sameLocalDate(a discord.Timestamp, b discord.Timestamp) bool {
// Cursor returns the selected message index, skipping separator rows.
func (ml *messagesList) Cursor() int {
ml.ensureRows()
rowIndex := ml.List.Cursor()
rowIndex := ml.Model.Cursor()
if rowIndex < 0 || rowIndex >= len(ml.rows) {
return -1
}
@ -291,7 +292,7 @@ func (ml *messagesList) Cursor() int {
// SetCursor selects a message index and maps it to the corresponding row.
func (ml *messagesList) SetCursor(index int) {
ml.List.SetCursor(ml.messageToRowIndex(index))
ml.Model.SetCursor(ml.messageToRowIndex(index))
}
func (ml *messagesList) messageToRowIndex(messageIndex int) int {
@ -316,7 +317,7 @@ func (ml *messagesList) onRowCursorChanged(rowIndex int) {
}
target := ml.nearestMessageRowIndex(rowIndex)
ml.List.SetCursor(target)
ml.Model.SetCursor(target)
}
// nearestMessageRowIndex expects rowIndex to be within bounds.
@ -898,7 +899,7 @@ func (ml *messagesList) HandleEvent(event tcell.Event) tview.Command {
// Do not fall through to List defaults for unmatched keys.
return nil
}
return ml.List.HandleEvent(event)
return ml.Model.HandleEvent(event)
}
func (ml *messagesList) selectUp() {

View file

@ -9,6 +9,7 @@ import (
"github.com/ayn2op/discordo/internal/config"
"github.com/ayn2op/discordo/internal/ui"
"github.com/ayn2op/tview"
"github.com/ayn2op/tview/flex"
"github.com/ayn2op/tview/keybind"
"github.com/ayn2op/tview/layers"
"github.com/diamondburned/arikawa/v3/discord"
@ -31,9 +32,9 @@ type Model struct {
*layers.Layers
// guildsTree (sidebar) + rightFlex
mainFlex *tview.Flex
mainFlex *flex.Model
// messagesList + messageInput
rightFlex *tview.Flex
rightFlex *flex.Model
guildsTree *guildsTree
messagesList *messagesList
@ -59,8 +60,8 @@ func NewView(app *tview.Application, cfg *config.Config, token string) *Model {
v := &Model{
Layers: layers.New(),
mainFlex: tview.NewFlex(),
rightFlex: tview.NewFlex(),
mainFlex: flex.NewModel(),
rightFlex: flex.NewModel(),
typers: make(map[discord.UserID]*time.Timer),
@ -98,7 +99,7 @@ func (v *Model) buildLayout() {
v.mainFlex.Clear()
v.rightFlex.
SetDirection(tview.FlexRow).
SetDirection(flex.DirectionRow).
AddItem(v.messagesList, 0, 1, false).
AddItem(v.messageInput, 3, 1, false)
// The guilds tree is always focused first at start-up.

View file

@ -10,6 +10,7 @@ import (
"github.com/ayn2op/discordo/internal/ui/login/qr"
"github.com/ayn2op/discordo/internal/ui/login/token"
"github.com/ayn2op/tview"
"github.com/ayn2op/tview/flex"
"github.com/ayn2op/tview/help"
"github.com/ayn2op/tview/keybind"
"github.com/gdamore/tcell/v3"
@ -19,7 +20,7 @@ const tokenEnvVarKey = "DISCORDO_TOKEN"
type Model struct {
app *tview.Application
rootFlex *tview.Flex // inner + help
rootFlex *flex.Model // inner + help
inner tview.Primitive
help *help.Help
@ -29,13 +30,13 @@ type Model struct {
func NewModel(cfg *config.Config, app *tview.Application) *Model {
m := &Model{
app: app,
rootFlex: tview.NewFlex(),
rootFlex: flex.NewModel(),
help: help.New(),
cfg: cfg,
}
m.rootFlex.SetDirection(tview.FlexRow)
m.rootFlex.SetDirection(flex.DirectionRow)
styles := help.DefaultStyles()
styles.ShortKeyStyle = cfg.Theme.Help.ShortKeyStyle.Style

View file

@ -2,7 +2,9 @@ package picker
import (
"github.com/ayn2op/tview"
"github.com/ayn2op/tview/flex"
"github.com/ayn2op/tview/keybind"
"github.com/ayn2op/tview/list"
"github.com/gdamore/tcell/v3"
"github.com/sahilm/fuzzy"
)
@ -13,9 +15,9 @@ type (
)
type Picker struct {
*tview.Flex
*flex.Model
input *tview.InputField
list *tview.List
list *list.Model
onSelected SelectedFunc
onCancel CancelFunc
@ -27,9 +29,9 @@ type Picker struct {
func New() *Picker {
p := &Picker{
Flex: tview.NewFlex(),
Model: flex.NewModel(),
input: tview.NewInputField(),
list: tview.NewList(),
list: list.NewModel(),
}
// Show a horizontal bottom border to visually separate input from list.
@ -46,7 +48,7 @@ func New() *Picker {
SetBorderStyle(tcell.StyleDefault.Dim(true))
p.
SetDirection(tview.FlexRow).
SetDirection(flex.DirectionRow).
// bottom border + value
AddItem(p.input, 2, 0, true).
AddItem(p.list, 0, 1, false)
@ -58,7 +60,7 @@ func New() *Picker {
func (p *Picker) setFilteredItems(filtered Items) {
p.filtered = filtered
p.list.SetBuilder(func(index int, cursor int) tview.ListItem {
p.list.SetBuilder(func(index int, cursor int) list.Item {
if index < 0 || index >= len(p.filtered) {
return nil
}
@ -86,7 +88,7 @@ func (p *Picker) SetKeyMap(keyMap *KeyMap) {
}
// SetScrollBarVisibility sets when the picker's list scrollBar is rendered.
func (p *Picker) SetScrollBarVisibility(visibility tview.ScrollBarVisibility) {
func (p *Picker) SetScrollBarVisibility(visibility list.ScrollBarVisibility) {
p.list.SetScrollBarVisibility(visibility)
}
@ -176,7 +178,7 @@ func (p *Picker) HandleEvent(event tcell.Event) tview.Command {
}
}
return p.Flex.HandleEvent(event)
return p.Model.HandleEvent(event)
}
return p.Flex.HandleEvent(event)
return p.Model.HandleEvent(event)
}