Table of Contents

Class Printer

Namespace
Hegel
Assembly
Hegel.dll

Prints a drawn value as the engine lays it out: text, groups that break across lines when they run past the width, and comments. A PrintableGenerator<T> prints through one as it draws; outside a draw, Document gives you one.

public sealed class Printer
Inheritance
Printer
Inherited Members

Properties

Noop

A printer that discards everything: what a silent draw prints to.

public static Printer Noop { get; }

Property Value

Printer

ShouldPrint

Whether anything printed now would be shown: false for Noop and inside an aborted speculation.

public bool ShouldPrint { get; }

Property Value

bool

Methods

BeginGroup(int, string)

Open a group with open, indenting its contents by indent when it breaks.

public void BeginGroup(int indent, string open)

Parameters

indent int
open string

BeginGroup(string)

Open a group with open, indented by its width.

public void BeginGroup(string open)

Parameters

open string

Breakable(string)

A place the line may break; separator is printed when it does not.

public void Breakable(string separator)

Parameters

separator string

Comment(string)

A trailing comment on the current line.

public void Comment(string text)

Parameters

text string

Deferred()

A printer for a region of the output that is filled in later (printed to after this printer has moved on), as a filter's attempt count is.

public Printer Deferred()

Returns

Printer

EndGroup(string)

Close the innermost group with close.

public void EndGroup(string close)

Parameters

close string

Group(int, string, string, Action)

Print body inside a group.

public void Group(int indent, string open, string close, Action body)

Parameters

indent int
open string
close string
body Action

Group<TResult>(int, string, string, Func<TResult>)

Print body inside a group and return its result.

public TResult Group<TResult>(int indent, string open, string close, Func<TResult> body)

Parameters

indent int
open string
close string
body Func<TResult>

Returns

TResult

Type Parameters

TResult

HardBreak()

End the line.

public void HardBreak()

IfBreak(string)

Print text only when the enclosing group breaks.

public void IfBreak(string text)

Parameters

text string

Reflow(string)

Print representation, letting the engine break it at its brackets and commas.

public void Reflow(string representation)

Parameters

representation string

Repr(object?)

Print value as the code that builds it, in the current Dialect.

public void Repr(object? value)

Parameters

value object

Repr(object?, Type)

Print value, drawn with the static type staticType, as the code that builds it, in the current Dialect. The static type tells a dialect what a null stands for.

public void Repr(object? value, Type staticType)

Parameters

value object
staticType Type

Separator()

A comma and a breakable space.

public void Separator()

Seq<TItem>(string, string, IEnumerable<TItem>, Action<TItem>)

Print items with print, separated, inside a group.

public void Seq<TItem>(string open, string close, IEnumerable<TItem> items, Action<TItem> print)

Parameters

open string
close string
items IEnumerable<TItem>
print Action<TItem>

Type Parameters

TItem

ShiftIndent(int)

Change the indentation of the following lines by delta.

public void ShiftIndent(int delta)

Parameters

delta int

Speculate()

Start printing speculatively: what follows is kept by Commit() and discarded by Abort() or by disposing the speculation first.

public Printer.Speculation Speculate()

Returns

Printer.Speculation

Text(string)

Print text; each newline in it is a hard break.

public void Text(string text)

Parameters

text string