builder.jamo (built in)

builder: builds big text quickly. use "builder.jamo"

Joining text with + copies all of it each time, so building a big text piece by piece gets slow. A TextBuilder keeps the pieces in one buffer that doubles when it's full, and makes the text once at the end.

structTextBuilder

struct TextBuilder
    buffer: int
    capacity: int
    used: int
end

funcnew_builder

func new_builder(): TextBuilder

funcTextBuilder.room

func TextBuilder.room(extra: int)

funcTextBuilder.add

func TextBuilder.add(text: string)

funcTextBuilder.line

func TextBuilder.line(text: string)

Adds the text, then a new line

funcTextBuilder.add_int

func TextBuilder.add_int(value: int)

funcTextBuilder.length

func TextBuilder.length(): int

How many bytes it holds so far

funcTextBuilder.text

func TextBuilder.text(): string

Everything added, as one text

funcTextBuilder.clear

func TextBuilder.clear()

Starts over, keeping its buffer