[previous] [up] [next]     [index]
Next: Requiring Libraries and Files: Up: MzLib Libraries Previous: Converted Printing: pconver.ss

Pretty Printing: pretty.ss

Files: pretty.ss, prettyu.ss, prettyr.ss, prettys.ss
Signature: mzlib:pretty-print^
Unit: mzlib:pretty-print@, no imports



(pretty-display v [port]) PROCEDURE

Same as pretty-print, but v is printed like display instead of like write.



(pretty-print v [port]) PROCEDURE

Pretty-prints the value v using the same printed form as write. If port is provided, v is printed into port; otherwise, v is printed to the current output port.

In addition to the parameters defined by the pretty library, pretty-print conforms to the print-graph, print-struct, and print-vector-length parameters.



(pretty-print-columns [width]) PROCEDURE

Parameter that sets the default width for pretty printing to width and returns void. If no width argument is provided, the current value is returned instead.

If the display width is 'infinity, then pretty-printed output is never broken into lines, and a newline is not added to the end of the output.



(pretty-print-depth [depth]) PROCEDURE

Parameter that sets the default depth for recursive pretty printing to depth and returns void. If no depth argument is provided, the current value is returned instead. A depth of 0 indicates that only simple values are printed; Scheme values within other values (e.g. the elements of a list) are replaced with ``...''.



(pretty-print-display-string-handler [f]) PROCEDURE

Parameter that sets the procedure for displaying final strings to a port to output pretty-printed values. The default handler is the default port display handler (see section 11.1.9).



(pretty-print-exact-as-decimal [as-decimal?]) PROCEDURE

Parameter that determines how exact non-integers are printed. If the parameter's value is #t, then an exact non-integer with a decimal representation is printed as a decimal number instead of a fraction. The initial value is #f.



(pretty-print-handler v) PROCEDURE

Pretty-prints v if v is not void or prints nothing otherwise. Pass this procedure to current-print to install the pretty printer into the read-eval-print loop.



(pretty-print-print-hook [hook]) PROCEDURE

Parameter that sets the print hook for pretty-printing to hook. If hook is not provided, the current hook is returned.

The print hook is applied to a value for printing when the sizing hook (see pretty-print-size-hook) returns an integer size for the value.

The print hook receives three arguments. The first argument is the value to print. The second argument is a Boolean: #t for printing like display and #f for printing like write. The third argument is the destination port.



(pretty-print-print-line [liner]) PROCEDURE

Parameter that sets a procedure for printing the newline separator between lines of a pretty-printed value. The liner procedure is called with four arguments: a new line number, an output port, the old line's length, and the number of destination columns. The return value from liner is the number of extra characters it printed at the beginning of the new line.

The liner procedure is called before any characters are printed with 0 as the line number and 0 as the old line length; liner is called after the last character for a value is printed with #f as the line number and with the length of the last line. Whenever the pretty-printer starts a new line, liner is called with the new line's number (where the first new line is numbered 1) and the just-finished line's length. The destination columns argument to liner is always the total width of the destination printing area, or 'infinity if pretty-printed values are not broken into lines.

The default liner procedure prints a newline whenever the line number is not 0 and the column count is not 'infinity, always returning 0. A custom liner procedure can be used to print extra text before each line of pretty-printed output; the number of characters printed before each line should be returned by liner so that the next line break can be chosen correctly.



(pretty-print-show-inexactness [explicit?]) PROCEDURE

Parameter that determines how inexact numbers are printed. If the parameter's value is #t, then inexact numbers are always printed with a leading #i. The initial value is #f.



(pretty-print-post-print-hook [hook]) PROCEDURE

Parameter that sets a procedure to be called just after an object is printed. The hook receives two arguments: the object and the output port.



(pretty-print-pre-print-hook [hook]) PROCEDURE

Parameter that sets a procedure to be called just before an object is printed. The hook receives two arguments: the object and the output port.



(pretty-print-size-hook [hook]) PROCEDURE

Parameter that sets the sizing hook for pretty-printing to hook. If hook is not provided, the current hook is returned.

The sizing hook is applied to each value to be printed. If the hook returns #f, then printing is handled internally by the pretty-printer. Otherwise, the value should be an integer specifying the length of the printed value in characters; the print hook will be called to actually print the value (see pretty-print-print-hook).

The sizing hook receives three arguments. The first argument is the value to print. The second argument is a Boolean: #t for printing like display and #f for printing like write. The third argument is the destination port. The sizing hook may be applied to a single value multiple times during pretty-printing.


[previous] [up] [next]     [index]
Next: Requiring Libraries and Files: Up: MzLib Libraries Previous: Converted Printing: pconver.ss

PLT