aboutsummaryrefslogtreecommitdiff
path: root/ui/messages/html/blockquote.go
diff options
context:
space:
mode:
Diffstat (limited to 'ui/messages/html/blockquote.go')
-rw-r--r--ui/messages/html/blockquote.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/ui/messages/html/blockquote.go b/ui/messages/html/blockquote.go
index 30ce52e..17799a2 100644
--- a/ui/messages/html/blockquote.go
+++ b/ui/messages/html/blockquote.go
@@ -18,6 +18,7 @@ package html
import (
"fmt"
+ "strings"
"maunium.net/go/mauview"
)
@@ -37,6 +38,10 @@ func NewBlockquoteEntity(children []Entity) *BlockquoteEntity {
}}
}
+func (be *BlockquoteEntity) Clone() Entity {
+ return &BlockquoteEntity{BaseEntity: be.BaseEntity.Clone().(*BaseEntity)}
+}
+
func (be *BlockquoteEntity) Draw(screen mauview.Screen) {
be.BaseEntity.Draw(screen)
for y := 0; y < be.height; y++ {
@@ -44,6 +49,33 @@ func (be *BlockquoteEntity) Draw(screen mauview.Screen) {
}
}
+func (be *BlockquoteEntity) PlainText() string {
+ if len(be.Children) == 0 {
+ return ""
+ }
+ var buf strings.Builder
+ newlined := false
+ for i, child := range be.Children {
+ if i != 0 && child.IsBlock() && !newlined {
+ buf.WriteRune('\n')
+ }
+ newlined = false
+ for i, row := range strings.Split(child.PlainText(), "\n") {
+ if i != 0 {
+ buf.WriteRune('\n')
+ }
+ buf.WriteRune('>')
+ buf.WriteRune(' ')
+ buf.WriteString(row)
+ }
+ if child.IsBlock() {
+ buf.WriteRune('\n')
+ newlined = true
+ }
+ }
+ return strings.TrimSpace(buf.String())
+}
+
func (be *BlockquoteEntity) String() string {
return fmt.Sprintf("&html.BlockquoteEntity{%s},\n", be.BaseEntity)
}