Update mautrix-go and remove duplicate function

This commit is contained in:
Tulir Asokan 2023-01-15 15:48:12 +02:00
parent c0036f391b
commit d6c08dc134
3 changed files with 8 additions and 15 deletions

4
go.mod
View File

@ -24,7 +24,8 @@ require (
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
gopkg.in/vansante/go-ffprobe.v2 v2.1.1
gopkg.in/yaml.v3 v3.0.1
maunium.net/go/mautrix v0.11.0
maunium.net/go/mauflag v1.0.0
maunium.net/go/mautrix v0.11.1
mvdan.cc/xurls/v2 v2.4.0
)
@ -44,7 +45,6 @@ require (
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
maunium.net/go/mauflag v1.0.0 // indirect
maunium.net/go/maulogger/v2 v2.3.2 // indirect
)

4
go.sum
View File

@ -123,7 +123,7 @@ maunium.net/go/mauflag v1.0.0 h1:YiaRc0tEI3toYtJMRIfjP+jklH45uDHtT80nUamyD4M=
maunium.net/go/mauflag v1.0.0/go.mod h1:nLivPOpTpHnpzEh8jEdSL9UqO9+/KBJFmNRlwKfkPeA=
maunium.net/go/maulogger/v2 v2.3.2 h1:1XmIYmMd3PoQfp9J+PaHhpt80zpfmMqaShzUTC7FwY0=
maunium.net/go/maulogger/v2 v2.3.2/go.mod h1:TYWy7wKwz/tIXTpsx8G3mZseIRiC5DoMxSZazOHy68A=
maunium.net/go/mautrix v0.11.0 h1:B1FBHcvE4Mud+AC+zgNQQOw0JxSVrt40watCejhVA7w=
maunium.net/go/mautrix v0.11.0/go.mod h1:K29EcHwsNg6r7fMfwvi0GHQ9o5wSjqB9+Q8RjCIQEjA=
maunium.net/go/mautrix v0.11.1 h1:S5TZGY3M1/bJcd6Y5SUWsNvqQAgFjgFYk5ULm/NCkqk=
maunium.net/go/mautrix v0.11.1/go.mod h1:K29EcHwsNg6r7fMfwvi0GHQ9o5wSjqB9+Q8RjCIQEjA=
mvdan.cc/xurls/v2 v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
mvdan.cc/xurls/v2 v2.4.0/go.mod h1:+GEjq9uNjqs8LQfM9nVnM8rff0OQ5Iash5rzX+N1CSg=

View File

@ -18,12 +18,12 @@ package html
import (
"fmt"
"math"
"strings"
"go.mau.fi/mauview"
"maunium.net/go/gomuks/ui/widget"
"maunium.net/go/mautrix/format"
)
type ListEntity struct {
@ -32,13 +32,6 @@ type ListEntity struct {
Start int
}
func digits(num int) int {
if num <= 0 {
return 0
}
return int(math.Floor(math.Log10(float64(num))) + 1)
}
func NewListEntity(ordered bool, start int, children []Entity) *ListEntity {
entity := &ListEntity{
ContainerEntity: &ContainerEntity{
@ -54,7 +47,7 @@ func NewListEntity(ordered bool, start int, children []Entity) *ListEntity {
}
if ordered {
entity.Tag = "ol"
entity.Indent += digits(start + len(children) - 1)
entity.Indent += format.Digits(start + len(children) - 1)
}
return entity
}
@ -81,7 +74,7 @@ func (le *ListEntity) Draw(screen mauview.Screen, ctx DrawContext) {
proxyScreen.Height = entity.Height()
if le.Ordered {
number := le.Start + i
line := fmt.Sprintf("%d. %s", number, strings.Repeat(" ", le.Indent-2-digits(number)))
line := fmt.Sprintf("%d. %s", number, strings.Repeat(" ", le.Indent-2-format.Digits(number)))
widget.WriteLine(screen, mauview.AlignLeft, line, 0, proxyScreen.OffsetY, le.Indent, le.Style)
} else {
screen.SetContent(0, proxyScreen.OffsetY, '●', nil, le.Style)
@ -101,7 +94,7 @@ func (le *ListEntity) PlainText() string {
indent := strings.Repeat(" ", le.Indent)
if le.Ordered {
number := le.Start + i
_, _ = fmt.Fprintf(&buf, "%d. %s", number, strings.Repeat(" ", le.Indent-2-digits(number)))
_, _ = fmt.Fprintf(&buf, "%d. %s", number, strings.Repeat(" ", le.Indent-2-format.Digits(number)))
} else {
buf.WriteString("● ")
}