Calculate block width from BlockStack & RenderContext

This commit is contained in:
Christian Muehlhaeuser
2019-12-07 19:49:24 +01:00
parent 7404a91eb4
commit 71e84251b3
8 changed files with 41 additions and 37 deletions
+7
View File
@@ -51,6 +51,13 @@ func (s BlockStack) Margin() uint {
return i
}
func (s BlockStack) Width(ctx RenderContext) uint {
if s.Indent()+s.Margin()*2 > uint(ctx.options.WordWrap) {
return 0
}
return uint(ctx.options.WordWrap) - s.Indent() - s.Margin()*2
}
func (s BlockStack) Parent() BlockElement {
if len(s) < 2 {
return s.Current()