diff options
author | Tulir Asokan <tulir@maunium.net> | 2019-06-16 15:18:25 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2019-06-16 15:18:25 +0300 |
commit | 8b87809ac1cae1263d3591a1b9b5b88c944034d8 (patch) | |
tree | 25c6421dc5da1b96d2d7804eccad94ed8a2ee1a1 /ui/messages/htmlmessage.go | |
parent | d3c18788dda5c2205a858c99afc75acc46c7ed33 (diff) | |
parent | 1ea6ba026aab8b9d3e66681c97043b5806ef4971 (diff) |
Merge branch 'break-things-again'
Diffstat (limited to 'ui/messages/htmlmessage.go')
-rw-r--r-- | ui/messages/htmlmessage.go | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/ui/messages/htmlmessage.go b/ui/messages/htmlmessage.go index 30b1588..5b95a82 100644 --- a/ui/messages/htmlmessage.go +++ b/ui/messages/htmlmessage.go @@ -17,9 +17,7 @@ package messages import ( - "fmt" - "strings" - + ifc "maunium.net/go/gomuks/interface" "maunium.net/go/mautrix" "maunium.net/go/mauview" "maunium.net/go/tcell" @@ -29,30 +27,27 @@ import ( ) type HTMLMessage struct { - BaseMessage - Root html.Entity FocusedBg tcell.Color focused bool } -func NewHTMLMessage(event *mautrix.Event, displayname string, root html.Entity) UIMessage { - return &HTMLMessage{ - BaseMessage: newBaseMessage(event, displayname), - Root: root, - } +func NewHTMLMessage(event *mautrix.Event, displayname string, root html.Entity) *UIMessage { + return newUIMessage(event, displayname, &HTMLMessage{ + Root: root, + }) } -func (hw *HTMLMessage) Clone() UIMessage { +func (hw *HTMLMessage) RegisterMatrix(matrix ifc.MatrixContainer) {} + +func (hw *HTMLMessage) Clone() MessageRenderer { return &HTMLMessage{ - BaseMessage: hw.BaseMessage.clone(), - Root: hw.Root.Clone(), - FocusedBg: hw.FocusedBg, + Root: hw.Root.Clone(), + FocusedBg: hw.FocusedBg, } } func (hw *HTMLMessage) Draw(screen mauview.Screen) { - screen = hw.DrawReply(screen) if hw.focused { screen.SetStyle(tcell.StyleDefault.Background(hw.FocusedBg)) } @@ -80,18 +75,17 @@ func (hw *HTMLMessage) OnPasteEvent(event mauview.PasteEvent) bool { return false } -func (hw *HTMLMessage) CalculateBuffer(preferences config.UserPreferences, width int) { +func (hw *HTMLMessage) CalculateBuffer(preferences config.UserPreferences, width int, msg *UIMessage) { if width < 2 { return } - hw.CalculateReplyBuffer(preferences, width) // TODO account for bare messages in initial startX startX := 0 hw.Root.CalculateBuffer(width, startX, preferences.BareMessageView) } func (hw *HTMLMessage) Height() int { - return hw.ReplyHeight() + hw.Root.Height() + return hw.Root.Height() } func (hw *HTMLMessage) PlainText() string { @@ -103,8 +97,5 @@ func (hw *HTMLMessage) NotificationContent() string { } func (hw *HTMLMessage) String() string { - return fmt.Sprintf("&messages.HTMLMessage{\n" + - " Base=%s,\n" + - " Root=||\n%s\n" + - "}", strings.Replace(hw.BaseMessage.String(), "\n", "\n ", -1), hw.Root.String()) + return hw.Root.String() } |