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
ShouldPrint
Whether anything printed now would be shown: false for Noop and inside an aborted speculation.
public bool ShouldPrint { get; }
Property Value
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
BeginGroup(string)
Open a group with open, indented by its width.
public void BeginGroup(string open)
Parameters
openstring
Breakable(string)
A place the line may break; separator is printed when it does not.
public void Breakable(string separator)
Parameters
separatorstring
Comment(string)
A trailing comment on the current line.
public void Comment(string text)
Parameters
textstring
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
EndGroup(string)
Close the innermost group with close.
public void EndGroup(string close)
Parameters
closestring
Group(int, string, string, Action)
Print body inside a group.
public void Group(int indent, string open, string close, Action body)
Parameters
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
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
textstring
Reflow(string)
Print representation, letting the engine break it at its brackets and commas.
public void Reflow(string representation)
Parameters
representationstring
Repr(object?)
Print value as the code that builds it, in the current Dialect.
public void Repr(object? value)
Parameters
valueobject
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
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
openstringclosestringitemsIEnumerable<TItem>printAction<TItem>
Type Parameters
TItem
ShiftIndent(int)
Change the indentation of the following lines by delta.
public void ShiftIndent(int delta)
Parameters
deltaint
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
Text(string)
Print text; each newline in it is a hard break.
public void Text(string text)
Parameters
textstring