Stop replacing text of event links

This commit is contained in:
Tulir Asokan 2019-04-15 00:34:48 +03:00
parent 98a8b52862
commit 60e3fe3927
2 changed files with 13 additions and 15 deletions

View File

@ -26,7 +26,6 @@ import (
"maunium.net/go/mauview" "maunium.net/go/mauview"
"maunium.net/go/tcell" "maunium.net/go/tcell"
"maunium.net/go/gomuks/debug"
"maunium.net/go/gomuks/ui/widget" "maunium.net/go/gomuks/ui/widget"
) )
@ -81,7 +80,6 @@ func (ml *MemberList) Update(data map[string]*mautrix.Member, levels *mautrix.Po
func (ml *MemberList) Draw(screen mauview.Screen) { func (ml *MemberList) Draw(screen mauview.Screen) {
width, _ := screen.Size() width, _ := screen.Size()
for y, member := range ml.list { for y, member := range ml.list {
debug.Print(member.UserID, member.Displayname, member.Membership, member.PowerLevel)
if member.Membership == "invite" { if member.Membership == "invite" {
widget.WriteLineSimpleColor(screen, member.Displayname, 1, y, member.Color) widget.WriteLineSimpleColor(screen, member.Displayname, 1, y, member.Color)
screen.SetCell(0, y, tcell.StyleDefault, '(') screen.SetCell(0, y, tcell.StyleDefault, '(')

View File

@ -168,8 +168,8 @@ func (parser *htmlParser) blockquoteToEntity(node *html.Node) Entity {
return NewBlockquoteEntity(parser.nodeToEntities(node.FirstChild)) return NewBlockquoteEntity(parser.nodeToEntities(node.FirstChild))
} }
func (parser *htmlParser) linkToEntity(node *html.Node) (entity Entity) { func (parser *htmlParser) linkToEntity(node *html.Node) Entity {
entity = &ContainerEntity{ entity := &ContainerEntity{
BaseEntity: &BaseEntity{ BaseEntity: &BaseEntity{
Tag: "a", Tag: "a",
}, },
@ -177,27 +177,27 @@ func (parser *htmlParser) linkToEntity(node *html.Node) (entity Entity) {
} }
href := parser.getAttribute(node, "href") href := parser.getAttribute(node, "href")
if len(href) == 0 { if len(href) == 0 {
return return entity
} }
match := matrixToURL.FindStringSubmatch(href) match := matrixToURL.FindStringSubmatch(href)
if len(match) == 2 { if len(match) == 2 {
pillTarget := match[1] pillTarget := match[1]
textEntity := &TextEntity{ text := NewTextEntity(pillTarget)
BaseEntity: &BaseEntity{
Tag: "a",
},
Text: pillTarget,
}
if pillTarget[0] == '@' { if pillTarget[0] == '@' {
if member := parser.room.GetMember(pillTarget); member != nil { if member := parser.room.GetMember(pillTarget); member != nil {
textEntity.Text = member.Displayname text.Text = member.Displayname
textEntity.Style = textEntity.Style.Foreground(widget.GetHashColor(pillTarget)) text.Style = text.Style.Foreground(widget.GetHashColor(pillTarget))
} }
entity.Children = []Entity{text}
/*} else if slash := strings.IndexRune(pillTarget, '/'); slash != -1 {
room := pillTarget[:slash]
event := pillTarget[slash+1:]*/
} else if pillTarget[0] == '#' {
entity.Children = []Entity{text}
} }
entity = textEntity
} }
// TODO add click action and underline on hover for links // TODO add click action and underline on hover for links
return return entity
} }
func (parser *htmlParser) imageToEntity(node *html.Node) Entity { func (parser *htmlParser) imageToEntity(node *html.Node) Entity {