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

Pretty Printing

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



(pretty-display v [port width graph? struct? depth size-hook print-hook]) PROCEDURE

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



(pretty-print v [port width graph? struct? depth size-hook print-hook]) PROCEDURE

Pretty-prints the value v using the same printed form as write. All other argument are optional.



(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 display.



(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-print-hook) returns an integer size for the value.

The print hook's actual arguments are the value to print and a boolean: #t for printing like display and #f for printing like write.



(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-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's actual arguments are the value to print and a boolean: #t for printing like display and #f for printing like write. The sizing hook may be applied to the same value mulitple times during pretty-printing.


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

PLT