Fix rendering formatted m.emotes

This commit is contained in:
Tulir Asokan 2020-02-19 21:54:53 +02:00
parent af99c76d46
commit 15e1d3f87c
6 changed files with 37 additions and 1 deletions

View File

@ -92,4 +92,6 @@ func (be *BaseEntity) CalculateBuffer(width, startX int, bare bool) int {
return be.startX return be.startX
} }
func (be *BaseEntity) Draw(screen mauview.Screen) {} func (be *BaseEntity) Draw(screen mauview.Screen) {
panic("Called Draw() of BaseEntity")
}

View File

@ -40,6 +40,11 @@ func NewBlockquoteEntity(children []Entity) *BlockquoteEntity {
}} }}
} }
func (be *BlockquoteEntity) AdjustStyle(fn AdjustStyleFunc) Entity {
be.BaseEntity = be.BaseEntity.AdjustStyle(fn).(*BaseEntity)
return be
}
func (be *BlockquoteEntity) Clone() Entity { func (be *BlockquoteEntity) Clone() Entity {
return &BlockquoteEntity{ContainerEntity: be.ContainerEntity.Clone().(*ContainerEntity)} return &BlockquoteEntity{ContainerEntity: be.ContainerEntity.Clone().(*ContainerEntity)}
} }

View File

@ -16,6 +16,10 @@
package html package html
import (
"maunium.net/go/mauview"
)
type BreakEntity struct { type BreakEntity struct {
*BaseEntity *BaseEntity
} }
@ -27,6 +31,12 @@ func NewBreakEntity() *BreakEntity {
}} }}
} }
// AdjustStyle changes the style of this text entity.
func (be *BreakEntity) AdjustStyle(fn AdjustStyleFunc) Entity {
be.BaseEntity = be.BaseEntity.AdjustStyle(fn).(*BaseEntity)
return be
}
func (be *BreakEntity) Clone() Entity { func (be *BreakEntity) Clone() Entity {
return NewBreakEntity() return NewBreakEntity()
} }
@ -38,3 +48,7 @@ func (be *BreakEntity) PlainText() string {
func (be *BreakEntity) String() string { func (be *BreakEntity) String() string {
return "&html.BreakEntity{},\n" return "&html.BreakEntity{},\n"
} }
func (be *BreakEntity) Draw(screen mauview.Screen) {
// No-op, the logic happens in containers
}

View File

@ -36,6 +36,11 @@ func NewHorizontalLineEntity() *HorizontalLineEntity {
}} }}
} }
func (he *HorizontalLineEntity) AdjustStyle(fn AdjustStyleFunc) Entity {
he.BaseEntity = he.BaseEntity.AdjustStyle(fn).(*BaseEntity)
return he
}
func (he *HorizontalLineEntity) Clone() Entity { func (he *HorizontalLineEntity) Clone() Entity {
return NewHorizontalLineEntity() return NewHorizontalLineEntity()
} }

View File

@ -58,6 +58,11 @@ func NewListEntity(ordered bool, start int, children []Entity) *ListEntity {
return entity return entity
} }
func (le *ListEntity) AdjustStyle(fn AdjustStyleFunc) Entity {
le.BaseEntity = le.BaseEntity.AdjustStyle(fn).(*BaseEntity)
return le
}
func (le *ListEntity) Clone() Entity { func (le *ListEntity) Clone() Entity {
return &ListEntity{ return &ListEntity{
ContainerEntity: le.ContainerEntity.Clone().(*ContainerEntity), ContainerEntity: le.ContainerEntity.Clone().(*ContainerEntity),

View File

@ -44,6 +44,11 @@ func NewTextEntity(text string) *TextEntity {
} }
} }
func (te *TextEntity) AdjustStyle(fn AdjustStyleFunc) Entity {
te.BaseEntity = te.BaseEntity.AdjustStyle(fn).(*BaseEntity)
return te
}
func (te *TextEntity) Clone() Entity { func (te *TextEntity) Clone() Entity {
return &TextEntity{ return &TextEntity{
BaseEntity: te.BaseEntity.Clone().(*BaseEntity), BaseEntity: te.BaseEntity.Clone().(*BaseEntity),