From d6c08dc1348d8ce4ae3c62279ccefceaac0ebc39 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 15 Jan 2023 15:48:12 +0200 Subject: [PATCH] Update mautrix-go and remove duplicate function --- go.mod | 4 ++-- go.sum | 4 ++-- ui/messages/html/list.go | 15 ++++----------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 0d2274e..9254172 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 44d6f53..bd684f4 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/ui/messages/html/list.go b/ui/messages/html/list.go index f5ddc83..b4bfe64 100644 --- a/ui/messages/html/list.go +++ b/ui/messages/html/list.go @@ -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("● ") }