From 98a8b528624c9f497c213afe66fb738cf15f2c82 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sat, 13 Apr 2019 17:04:52 +0300 Subject: Minor UI changes --- ui/member-list.go | 20 +++++++++----------- ui/messages/base.go | 12 ++++++------ 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/ui/member-list.go b/ui/member-list.go index 82a6125..633470e 100644 --- a/ui/member-list.go +++ b/ui/member-list.go @@ -22,11 +22,12 @@ import ( "github.com/mattn/go-runewidth" - "maunium.net/go/gomuks/debug" - "maunium.net/go/gomuks/ui/widget" "maunium.net/go/mautrix" "maunium.net/go/mauview" "maunium.net/go/tcell" + + "maunium.net/go/gomuks/debug" + "maunium.net/go/gomuks/ui/widget" ) type MemberList struct { @@ -50,14 +51,11 @@ func (rml roomMemberList) Len() int { return len(rml) } -func (rml roomMemberList) lessMembership(i, j int) bool { - return rml[j].Membership == "invite" && rml[i].Membership == "join" -} - func (rml roomMemberList) Less(i, j int) bool { - return rml.lessMembership(i, j) || - rml[i].PowerLevel > rml[j].PowerLevel || - strings.Compare(rml[i].Displayname, rml[j].Displayname) < 0 + if rml[i].PowerLevel != rml[j].PowerLevel { + return rml[i].PowerLevel > rml[j].PowerLevel + } + return strings.Compare(strings.ToLower(rml[i].Displayname), strings.ToLower(rml[j].Displayname)) < 0 } func (rml roomMemberList) Swap(i, j int) { @@ -67,7 +65,6 @@ func (rml roomMemberList) Swap(i, j int) { func (ml *MemberList) Update(data map[string]*mautrix.Member, levels *mautrix.PowerLevels) *MemberList { ml.list = make(roomMemberList, len(data)) i := 0 - debug.Print(levels) for userID, member := range data { ml.list[i] = &memberListItem{ Member: *member, @@ -84,10 +81,11 @@ func (ml *MemberList) Update(data map[string]*mautrix.Member, levels *mautrix.Po func (ml *MemberList) Draw(screen mauview.Screen) { width, _ := screen.Size() for y, member := range ml.list { + debug.Print(member.UserID, member.Displayname, member.Membership, member.PowerLevel) if member.Membership == "invite" { widget.WriteLineSimpleColor(screen, member.Displayname, 1, y, member.Color) screen.SetCell(0, y, tcell.StyleDefault, '(') - if sw := runewidth.StringWidth(member.Displayname); sw < width { + if sw := runewidth.StringWidth(member.Displayname); sw < width-1 { screen.SetCell(sw+1, y, tcell.StyleDefault, ')') } else { screen.SetCell(width-1, y, tcell.StyleDefault, ')') diff --git a/ui/messages/base.go b/ui/messages/base.go index cb9b371..05df72b 100644 --- a/ui/messages/base.go +++ b/ui/messages/base.go @@ -178,7 +178,7 @@ func (msg *BaseMessage) TimestampColor() tcell.Color { func (msg *BaseMessage) ReplyHeight() int { if msg.ReplyTo != nil { - return 2 + msg.ReplyTo.Height() + return 1 + msg.ReplyTo.Height() } return 0 } @@ -278,14 +278,14 @@ func (msg *BaseMessage) DrawReply(screen mauview.Screen) mauview.Screen { } width, height := screen.Size() replyHeight := msg.ReplyTo.Height() - widget.WriteLineSimpleColor(screen, "In reply to", 0, 0, tcell.ColorGreen) - widget.WriteLineSimpleColor(screen, msg.ReplyTo.RealSender(), len("In reply to "), 0, msg.ReplyTo.SenderColor()) - for y := 1; y < 1+replyHeight; y++ { - screen.SetCell(0, y, tcell.StyleDefault, '▋') + widget.WriteLineSimpleColor(screen, "In reply to", 1, 0, tcell.ColorGreen) + widget.WriteLineSimpleColor(screen, msg.ReplyTo.RealSender(), 13, 0, msg.ReplyTo.SenderColor()) + for y := 0; y < 1+replyHeight; y++ { + screen.SetCell(0, y, tcell.StyleDefault, '▊') } replyScreen := mauview.NewProxyScreen(screen, 1, 1, width-1, replyHeight) msg.ReplyTo.Draw(replyScreen) - return mauview.NewProxyScreen(screen, 0, replyHeight+2, width, height-replyHeight-2) + return mauview.NewProxyScreen(screen, 0, replyHeight+1, width, height-replyHeight-1) } func (msg *BaseMessage) String() string { -- cgit v1.2.3