refactor(ui): upgrade tview to latest and adopt new API
This commit is contained in:
parent
9ec330ba38
commit
abf8a09177
8 changed files with 15 additions and 15 deletions
2
go.mod
2
go.mod
|
|
@ -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-20260315070900-cf84a0d532d9
|
||||
github.com/ayn2op/tview v0.0.0-20260315074416-50a7d9c11304
|
||||
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
4
go.sum
|
|
@ -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-20260315070900-cf84a0d532d9 h1:XcMapeKrJg1SySKwxKJIdDlzTCH2KeHBTxFR+PwT7A8=
|
||||
github.com/ayn2op/tview v0.0.0-20260315070900-cf84a0d532d9/go.mod h1:IXZrCv1VAZyWPdKDUJYs9ZYFiJ1GmCQUo9tLjQWoSnU=
|
||||
github.com/ayn2op/tview v0.0.0-20260315074416-50a7d9c11304 h1:IbClNDuGoPrJtP4WkKr/iLXIxsR1WKSSJH46wLM0azM=
|
||||
github.com/ayn2op/tview v0.0.0-20260315074416-50a7d9c11304/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=
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func (v *Model) activeKeyMap() help.KeyMap {
|
|||
return nil
|
||||
}
|
||||
|
||||
switch v.app.GetFocus() {
|
||||
switch v.app.Focused() {
|
||||
case v.guildsTree:
|
||||
return v.guildsTree
|
||||
case v.messagesList:
|
||||
|
|
|
|||
|
|
@ -536,9 +536,9 @@ func (mi *messageInput) showMentionList() {
|
|||
borders = 1
|
||||
}
|
||||
l := mi.mentionsList
|
||||
x, _, _, _ := mi.GetInnerRect()
|
||||
_, y, _, _ := mi.GetRect()
|
||||
_, _, maxW, maxH := mi.chat.messagesList.GetInnerRect()
|
||||
x, _, _, _ := mi.InnerRect()
|
||||
_, y, _, _ := mi.Rect()
|
||||
_, _, maxW, maxH := mi.chat.messagesList.InnerRect()
|
||||
if t := int(mi.cfg.Theme.MentionsList.MaxHeight); t != 0 {
|
||||
maxH = min(maxH, t)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ func (ml *messagesList) drawDateSeparator(builder *tview.LineBuilder, ts discord
|
|||
label := " " + date + " "
|
||||
fillChar := ml.cfg.DateSeparator.Character
|
||||
dimStyle := baseStyle.Dim(true)
|
||||
_, _, width, _ := ml.GetInnerRect()
|
||||
_, _, width, _ := ml.InnerRect()
|
||||
if width <= 0 {
|
||||
builder.Write(strings.Repeat(fillChar, 8)+label+strings.Repeat(fillChar, 8), dimStyle)
|
||||
return
|
||||
|
|
@ -513,7 +513,7 @@ func (ml *messagesList) drawEmbeds(builder *tview.LineBuilder, message discord.M
|
|||
defaultBarStyle := baseStyle.Dim(true)
|
||||
prefixText := " ▎ "
|
||||
prefixWidth := tview.TaggedStringWidth(prefixText)
|
||||
_, _, innerWidth, _ := ml.GetInnerRect()
|
||||
_, _, innerWidth, _ := ml.InnerRect()
|
||||
// Wrap against the current list viewport. This keeps embed wrapping stable even when sidebars/panes are resized.
|
||||
wrapWidth := max(innerWidth-prefixWidth, 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ func (v *Model) focusMessageInput() bool {
|
|||
}
|
||||
|
||||
func (v *Model) focusPrevious() {
|
||||
switch v.app.GetFocus() {
|
||||
switch v.app.Focused() {
|
||||
case v.messagesList: // Handle both a.messagesList and a.flex as well as other edge cases (if there is).
|
||||
if v.focusGuildsTree() {
|
||||
return
|
||||
|
|
@ -185,7 +185,7 @@ func (v *Model) focusPrevious() {
|
|||
}
|
||||
|
||||
func (v *Model) focusNext() {
|
||||
switch v.app.GetFocus() {
|
||||
switch v.app.Focused() {
|
||||
case v.messagesList:
|
||||
if v.focusMessageInput() {
|
||||
return
|
||||
|
|
@ -268,7 +268,7 @@ func (v *Model) HandleEvent(event tcell.Event) tview.Command {
|
|||
}
|
||||
|
||||
func (v *Model) showConfirmModal(prompt string, buttons []string, onDone func(label string)) {
|
||||
v.confirmModalPreviousFocus = v.app.GetFocus()
|
||||
v.confirmModalPreviousFocus = v.app.Focused()
|
||||
v.confirmModalDone = onDone
|
||||
|
||||
modal := tview.NewModal().
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ func (m *Model) Draw(screen tcell.Screen) {
|
|||
}
|
||||
|
||||
func (m *Model) centerLines(lines []tview.Line) []tview.Line {
|
||||
_, _, _, height := m.GetInnerRect()
|
||||
_, _, _, height := m.InnerRect()
|
||||
if height == 0 {
|
||||
height = 40
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ func (m *Model) updateHelpHeight() {
|
|||
m.rootFlex.ResizeItem(m.help, height, 0)
|
||||
}
|
||||
|
||||
func (m *Model) GetRect() (int, int, int, int) {
|
||||
return m.rootFlex.GetRect()
|
||||
func (m *Model) Rect() (int, int, int, int) {
|
||||
return m.rootFlex.Rect()
|
||||
}
|
||||
|
||||
func (m *Model) SetRect(x int, y int, width int, height int) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue