aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/member-list.go20
-rw-r--r--ui/messages/base.go12
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 {