Add background color for reactions
This commit is contained in:
parent
db1424a06d
commit
fa8147f07a
2
go.mod
2
go.mod
@ -20,6 +20,6 @@ require (
|
||||
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2
|
||||
gopkg.in/yaml.v2 v2.2.8
|
||||
maunium.net/go/mautrix v0.1.0-alpha.3.0.20200220001222-8dc3dd5d538d
|
||||
maunium.net/go/mauview v0.0.0-20200219222453-b984e20438e6
|
||||
maunium.net/go/mauview v0.0.0-20200220201003-92b19f8819b4
|
||||
maunium.net/go/tcell v1.1.2-0.20200218183045-87c4a25c5b09
|
||||
)
|
||||
|
2
go.sum
2
go.sum
@ -90,5 +90,7 @@ maunium.net/go/mauview v0.0.0-20200219201346-81706f13fc83 h1:KdMJGXJw9Z/uBzg+19h
|
||||
maunium.net/go/mauview v0.0.0-20200219201346-81706f13fc83/go.mod h1:jwg3Ow7akzsCX3q38pZAfmEC5gGN8gXwMyyjy/yZVMg=
|
||||
maunium.net/go/mauview v0.0.0-20200219222453-b984e20438e6 h1:yYs5rsnDQrZie4eeWlcgdw4QSO0eFCiAoA8aiiE+yok=
|
||||
maunium.net/go/mauview v0.0.0-20200219222453-b984e20438e6/go.mod h1:jwg3Ow7akzsCX3q38pZAfmEC5gGN8gXwMyyjy/yZVMg=
|
||||
maunium.net/go/mauview v0.0.0-20200220201003-92b19f8819b4 h1:60G4iPYhO5Z4qkcniM+xPBeXNmuyD1tqXzj8ryeEdWY=
|
||||
maunium.net/go/mauview v0.0.0-20200220201003-92b19f8819b4/go.mod h1:jwg3Ow7akzsCX3q38pZAfmEC5gGN8gXwMyyjy/yZVMg=
|
||||
maunium.net/go/tcell v1.1.2-0.20200218183045-87c4a25c5b09 h1:hu+R+0nodoZPS19WGyYiw/d63+/NQS/R3Duw3d9HqAU=
|
||||
maunium.net/go/tcell v1.1.2-0.20200218183045-87c4a25c5b09/go.mod h1:Ru7KmI5AU7xHUx6hGltgJvknrS+8jlGGMKK15pZuc9k=
|
||||
|
@ -49,7 +49,7 @@ type ReactionItem struct {
|
||||
}
|
||||
|
||||
func (ri ReactionItem) String() string {
|
||||
return fmt.Sprintf("%d %s", ri.Count, ri.Key)
|
||||
return fmt.Sprintf("%d×%s", ri.Count, ri.Key)
|
||||
}
|
||||
|
||||
type ReactionSlice []ReactionItem
|
||||
@ -83,8 +83,6 @@ type UIMessage struct {
|
||||
ReplyTo *UIMessage
|
||||
Reactions ReactionSlice
|
||||
Renderer MessageRenderer
|
||||
|
||||
reactionBuffer string
|
||||
}
|
||||
|
||||
const DateFormat = "January _2, 2006"
|
||||
@ -305,7 +303,15 @@ func (msg *UIMessage) DrawReactions(screen mauview.Screen) {
|
||||
}
|
||||
width, height := screen.Size()
|
||||
screen = mauview.NewProxyScreen(screen, 0, height-1, width, 1)
|
||||
mauview.Print(screen, msg.reactionBuffer, 0, 0, width, mauview.AlignLeft, mauview.Styles.PrimaryTextColor)
|
||||
|
||||
x := 0
|
||||
for _, reaction := range msg.Reactions {
|
||||
_, drawn := mauview.PrintWithStyle(screen, reaction.String(), x, 0, width - x, mauview.AlignLeft, tcell.StyleDefault.Foreground(mauview.Styles.PrimaryTextColor).Background(tcell.ColorDarkGreen))
|
||||
x += drawn + 1
|
||||
if x >= width {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (msg *UIMessage) Draw(screen mauview.Screen) {
|
||||
@ -329,19 +335,9 @@ func (msg *UIMessage) CalculateReplyBuffer(preferences config.UserPreferences, w
|
||||
msg.ReplyTo.CalculateBuffer(preferences, width-1)
|
||||
}
|
||||
|
||||
func (msg *UIMessage) CalculateReactionBuffer() {
|
||||
var text strings.Builder
|
||||
for _, reaction := range msg.Reactions {
|
||||
text.WriteString(reaction.String())
|
||||
text.WriteRune(' ')
|
||||
}
|
||||
msg.reactionBuffer = text.String()
|
||||
}
|
||||
|
||||
func (msg *UIMessage) CalculateBuffer(preferences config.UserPreferences, width int) {
|
||||
msg.Renderer.CalculateBuffer(preferences, width, msg)
|
||||
msg.CalculateReplyBuffer(preferences, width)
|
||||
msg.CalculateReactionBuffer()
|
||||
}
|
||||
|
||||
func (msg *UIMessage) DrawReply(screen mauview.Screen) mauview.Screen {
|
||||
|
Loading…
Reference in New Issue
Block a user