Wax_utils.PrinterSourceThe state of the pretty-printer, managing indentation, pending spaces/newlines, and attached comments/blank lines.
Prints a string to the formatter, flushing any pending items first.
Prints a string with a specified display length to the formatter.
Queues a space to be printed, if no newlines are pending and a non-blank string has been emitted.
Queues a newline to be printed, if no non-blank string has been emitted.
defer_eol pp emit records a trailing line comment to be emitted at the end of the current line. It is flushed before the next ordinary token or box (or at end of output), but a separator printed within with_held_eol stays on the comment's line, before the comment. Emitting it ends the line.
with_held_eol pp f runs f without flushing a pending end-of-line comment first, so a list separator (e.g. a comma) printed by f appears on the comment's line, ahead of the deferred comment.
Whether a trailing end-of-line comment is currently deferred (set by defer_eol, not yet flushed). Lets a caller suppress a trailing comma when the last element already carries a trailing comment — adding the comma would push the comment off that element and shift where it re-attaches on a reparse.
if_broken pp f emits the content produced by f only when the enclosing box is laid out broken (multi-line); in a flat (single-line) box it produces nothing. Used for a trailing comma after the last element of a list that wraps. It never counts toward the box's fit decision.
box pp ?skip_space ?indent f creates a "box" for pretty-printing. The content generated by f will be formatted within this box. If it fits on a single line, it will be printed on one line. Otherwise, it will be broken into multiple lines. ?indent specifies an additional indentation level for lines broken within the box. If ?skip_space is true, no space will be added before the box if it starts on the same line as previous content.
hvbox pp ?skip_space ?indent f creates a "horizontal-vertical" box. The content generated by f will be formatted horizontally if it fits on the current line; otherwise, it will be formatted vertically, breaking lines where appropriate. ?indent specifies an additional indentation level for lines broken within the box. If ?skip_space is true, no space will be added before the box.
hbox pp ?skip_space f creates a "horizontal" box: breaks within never wrap, so the content always stays on one line. If ?skip_space is true, no space is added before the box.
hovbox pp ?skip_space ?indent f creates a "packing" box: as much content as fits is placed on each line, wrapping greedily, breaking only where needed.
vbox pp ?skip_space ?indent f creates a "vertical" box. The content generated by f will always be formatted vertically, breaking lines where appropriate. ?indent specifies an additional indentation level for lines broken within the box. If ?skip_space is true, no space will be added before the box.
run ?width fmt f creates a new printer on the given formatter, runs f, and renders the result. width is the target line width (default 78).