Did you know ... Search Documentation:
pprint.pl -- Pretty Print Prolog terms
PublicShow source

This module is a first start of what should become a full-featured pretty printer for Prolog terms with many options and parameters. Eventually, it should replace portray_clause/1 and various other special-purpose predicates.

To be done
- This is just a quicky. We need proper handling of portray/1, avoid printing very long terms multiple times, spacing (around operators), etc.
- Use a record for the option-processing.
- The current approach is far too simple, often resulting in illegal terms.
Source print_term(+Term, +Options) is det
Pretty print a Prolog term. The following options are processed:
Define the output stream. Default is user_output
Width of a line. If the output is a tty and tty_size/2 can produce a size the default is the number of columns minus 8. Otherwise the default is 72 characters. If the Column is unbound it is unified with the computed value.
Left margin for continuation lines. Default is the current line position or 0 if that is not available.
Distance between tab-stops. Default is 8 characters.
Defines how arguments of compound terms are placed. Defined values are:
Simply place them left to right (no line-breaks)
Place them vertically, aligned with the open bracket (not implemented)
auto (default)
As horizontal if line-width is not exceeded, vertical otherwise. See also auto_indent_arguments(Int)
An integer
Place them vertically aligned, <N> spaces to the right of the beginning of the head.
Used by indent_arguments(auto) to decide whether to introduce a newline after the `(` or not. If specified and > 0, this provides the default integer for indent_arguments(Int). The "hanging" mode is used if otherwise the indentation increment is twice this value.
This is the inverse of the write_term/3 option ignore_ops. Default is to respect them.
List of options passed to write_term/3 for terms that are not further processed. Default:
    [ numbervars(true),
If true (default false), add a full stop (.) to the output.
If true (default false), add a newline to the output.
Source prepare_term(+Term, -Template, -Cycles, -Constraints)[private]
Prepare a term, possibly holding cycles and constraints for printing.
Source infix_list(+Term, ?Op, -List) is semidet[private]
True when List is a list of subterms of Term that are the result of the nested infix operator Op. Deals both with xfy and yfx operators.
Source pp_list_elements(+List, +Ctx, +Options) is det[private]
Print the elements of a possibly open list as a vertical list.
Source indent(+Out, +Indent, +Options)[private]
Newline and indent to the indicated column. Respects the option tab_width. Default is 8. If the tab-width equals zero, indentation is emitted using spaces.
Source print_width(+Term, -W, +Options) is det[private]
Width required when printing `normally' left-to-right.
Source pprint(+Term, +Context, +Options)[private]
The bottom-line print-routine.
Source is_op1(+Name, -Type, -Priority, -ArgPriority, +Options) is semidet[private]
True if Name is an operator taking one argument of Type.
Source is_op2(+Name, -LeftPri, -Pri, -RightPri, +Options) is semidet[private]
True if Name is an operator taking two arguments of Type.
Source need_space(@Term1, @Term2, +LeftOptions, +RightOptions)[private]
True if a space is needed between Term1 and Term2 if they are printed using the given option lists.
Source end_code_type(+Term, -Code, Options)[private]
True when code is the first/last character code that is emitted by printing Term using Options.
Source primitive(+Term, -Class) is semidet[private]
True if Term is a primitive term, rendered using the CSS class Class.
Source operator_module(-Module, +Options) is det[private]
Find the module for evaluating operators.
Source arg_options(+Options, -OptionsOut) is det[private]
Increment depth in Options.