Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Newline = &newlineType{}
Newline is a text Component that inserts a new line.
Functions ¶
This section is empty.
Types ¶
type BasicComponent ¶
type BasicComponent interface {
Component
// Render renders the component to string buffer.
Render(*Renderer)
// contains filtered or unexported methods
}
BasicComponent is either a [newlineType] or a Text.
type Component ¶
type Component interface {
// Simplify returns a flattened and and simplified the component in an inside-out order.
// This is similar to how a AST optimizer would do it.
Simplify(*Renderer) []BasicComponent
}
Component is an abstract representation of some unit of printable text.
type LinePrefix ¶
LinePrefix adds a prefix to each line.
func (*LinePrefix) Simplify ¶
func (c *LinePrefix) Simplify(r *Renderer) []BasicComponent
Simplify implements Component
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is responsible for rendering Component into strings. To prevent unnecessary computation, this is caches simplification steps.
func NewRenderer ¶
func NewRenderer() *Renderer
func (*Renderer) Simplify ¶
func (r *Renderer) Simplify(c Component) []BasicComponent
Simplify should be used by [Component]s to render their contents.
func (*Renderer) WriteString ¶
WriteString should be used by [Component]s to render their contents.
type Sequence ¶
type Sequence struct {
Children []Component
}
Sequence contains zero or more child [Component]s in an ordered sequence.
Click to show internal directories.
Click to hide internal directories.