33 lines
589 B
Swift
33 lines
589 B
Swift
@preconcurrency import Rainbow
|
|
|
|
public struct Text: NodeRepresentable {
|
|
@usableFromInline
|
|
let text: String
|
|
|
|
@inlinable
|
|
public init(_ text: String) {
|
|
self.text = text
|
|
}
|
|
|
|
@inlinable
|
|
public func render() -> String {
|
|
text
|
|
}
|
|
}
|
|
|
|
public extension NodeRepresentable {
|
|
|
|
static func empty() -> Self where Self == Text {
|
|
Text("")
|
|
}
|
|
|
|
static func newLine(count: Int = 1) -> Self where Self == AnyNode {
|
|
"\n".repeating(count).eraseToAnyNode()
|
|
}
|
|
|
|
static func space(count: Int = 1) -> Self where Self == AnyNode {
|
|
" ".repeating(count).eraseToAnyNode()
|
|
}
|
|
|
|
}
|