Created
February 28, 2018 23:50
-
-
Save AndyG/12455f2d30a28897b87c33a9d0e08e12 to your computer and use it in GitHub Desktop.
SimpleAST StyleNode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StyleNode(val styles: List<CharacterStyle>) : SpannableRenderableNode() { | |
override fun render(builder: SpannableStringBuilder, context: Context?) { | |
// No matter what happens in this world, never forget where you came from. | |
val startIndex = builder.length | |
// First render all child nodes, as these are the nodes we want to apply the styles to. | |
getChildren()?.forEach { (it as SpannableRenderableNode).render(builder, context) } | |
styles.forEach { builder.setSpan(it, startIndex, builder.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment