{ $description "Variable. The prettyprinter's current character position." } ;
HELP: last-newline f
{ $description "Variable. The character position of the last newline output by the prettyprinter." } ;
HELP: recursion-check f
{ $description "Variable. The current nesting of collections being output by the prettyprinter, used to detect circularity and prevent infinite recursion." } ;
HELP: line-count f
{ $description "Variable. The number of lines output by the prettyprinter so far, used for line limiting (see " { $link line-limit } ")." } ;
HELP: end-printing f
{ $description "Variable. A continuation captured by " { $link do-pprint } " that breaks out of the printer." } ;
HELP: indent f
{ $description "Variable. The prettyprinter's current indent level." } ;
HELP: pprinter-stack f
{ $description "Variable. A stack of " { $link block } " objects currently being constructed by the prettyprinter." } ;
HELP: tab-size f
{ $description "Variable. Prettyprinter tab size. Indent nesting is always a multiple of the tab size. The default is 4." } ;
HELP: margin f
{ $description "Variable. The maximum line length, in characters. Lines longer than the margin are wrapped. The default is 64." } ;
HELP: nesting-limit f
{ $description "Variable. The maximum nesting level. Structures that nest further than this will simply print as a pound sign (#). The default is " { $link f } ", denoting unlimited nesting depth." } ;
HELP: length-limit f
{ $description "Variable. The maximum printed sequence length. Sequences longer than this are truncated, and \"...\" is output in place of remaining elements. The default is " { $link f } ", denoting unlimited sequence length." } ;
HELP: line-limit f
{ $description "Variable. The maximum number of lines output by the prettyprinter before output is truncated with \"...\". The default is " { $link f } ", denoting unlimited line count." } ;
HELP: string-limit f
{ $description "Variable. Toggles whenever printed strings are truncated to the margin." } ;
HELP: pprint-section* "( section -- )"
{ $values { "section" "a section" } }
{ $contract "Prettyprints an object delegating to an instance of " { $link section } ", performing wrapping and indentation using the formatting information in the section." } ;
HELP: section f
{ $description "A section represents a run of text with a known length and indentation level." } ;
HELP: line-limit? "( -- ? )"
{ $values { "?" "a boolean" } }
{ $description "Tests if the line number limit has been reached, and thus if prettyprinting should stop." } ;
HELP: do-indent "( -- )"
{ $description "Outputs the current indent nesting to the default stream." } ;
HELP: fresh-line "( n -- )"
{ $values { "n" "the current column position" } }
{ $description "Advances the prettyprinter by one line unless the current line is empty. If the line limit is exceeded, escapes the prettyprinter by restoring a continuation captured in " { $link do-pprint } "." } ;
HELP: <text> "( string style -- text )"
{ $values { "string" "a string" } { "style" "a hashtable" } { "text" "a new text section" } }
{ $description "Creates a text section." } ;
HELP: block f
{ $description "A block is a section consisting of whitespace-separated child sections." } ;
{ $description "Adds a section consisting of a single string to the current block. The current style on the style stack is used; see " { $link with-style } "." }
{ $notes "This word is used to end blocks in order for the prettyprinter to be forgiving in the case of mismatched begin/end pairs (this can happen when printing parsing words)." }
{ $description "Recursively output all children of the top-level block. The continuation is restored and output terminates if the line length is exceeded; this test is performed in " { $link fresh-line } "." } ;
HELP: pprint* "( obj -- )"
{ $values { "obj" "an object" } }
{ $contract "Adds sections to the current block corresponding to the prettyprinted representation of the object." }
{ $description "Adds a text section for the word. Unlike the " { $link word } " method of " { $link pprint* } ", this does not add a " { $link POSTPONE: POSTPONE: } " prefix to parsing words." }
{ $values { "ch" "a character" } { "str" "a string" } }
{ $description "Converts a character to an escape code." } ;
HELP: ch>unicode-escape "( ch -- str )"
{ $values { "ch" "a character" } { "str" "a string" } }
{ $description "Converts a character to a Unicode escape code (" { $snippet "\\u1234"} ")." } ;
HELP: unparse-ch "( ch -- )"
{ $values { "ch" "a character" } }
{ $description "Adds the character to the sequence being constructed (see " { $link "namespaces-make" } "). If the character can appear in a string literal, it is added directly, otherwise an escape code is added." } ;
HELP: do-string-limit "( str -- trimmed )"
{ $values { "str" "a string" } { "trimmed" "a possibly trimmed string" } }
{ $description "If " { $link string-limit } " is on, trims the string such that it does not exceed the margin, appending \"...\" if trimming took place." } ;
HELP: pprint-string "( str prefix -- )"
{ $values { "str" "a string" } { "prefix" "a prefix string" } }
{ $description "If the object is already being printed, that is, if the prettyprinter has encountered a cycle in the object graph, or if the maximum nesting depth has been reached, outputs a dummy string. Otherwise applies the quotation to the object." }
{ $description "If the " { $link length-limit } " is set, trims the sequence if necessary, and outputs a boolean indicating if \"...\" should be output." }
{ $description "Sets up the prettyprinter and calls the quotation in a new scope. The quotation should add sections to the top-level block. When the quotation returns, the top-level block is printed to the default stream." } ;
HELP: pprint "( obj -- )"
{ $values { "obj" "an object" } }
{ $description "Prettyprints an object to the default stream. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ;
HELP: . "( obj -- )"
{ $values { "obj" "an object" } }
{ $description "Prettyprints an object to the default stream with a trailing line break. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ;
{ $description "Outputs a prettyprinted string representation of an object. Output is influenced by many variables; see " { $link "prettyprint-variables" } "." } ;
{ $description "Prettyprints an object to the default stream. This word rebinds printer control variables to enforce ``shorter'' output. See " { $link "prettyprint-variables" } "." } ;
{ $description "Prettyprints an object to the default stream with a trailing line break. This word rebinds printer control variables to enforce ``shorter'' output." } ;
{ $description "Outputs a prettyprinted string representation of an object. This word rebinds printer control variables to enforce ``shorter'' output. See " { $link "prettyprint-variables" } "." } ;