This section describes the standard operations on output ports. Following that, some useful custom operations are described.
Most output ports are able to tell whether or not they are at the beginning of a line of output. If output-port is such a port, end-of-line is written to the port only if the port is not already at the beginning of a line. If output-port is not such a port, an end-of-line is unconditionally written to the port. Returns an unspecified value.
If output-port is buffered, this causes its buffer to be written out. Otherwise it has no effect. Returns an unspecified value.
Normally, this operation does nothing. However, ports that support discretionary output flushing implement this operation identically to
Each of these procedures invokes the respective operation on output-port. For example, the following are equivalent:(output-port/write-char output-port char) ((port/operation output-port 'write-char) output-port char)
Writes string to output-port. Equivalent to(output-port/write-substring output-port string 0 (string-length string))
The following custom operations are generally useful.
Returns the number of unwritten characters that are stored in output-port's buffer. This will always be less than or equal to the buffer's size.
Returns the maximum number of characters that output-port's buffer can hold.
Resizes output-port's buffer so that it can hold at most size characters. Characters in the buffer are discarded. Size must be an exact non-negative integer.
Returns an exact positive integer that is the width of output-port in characters. If output-port has no natural width, e.g. if it is a file port,
Returns an exact positive integer that is the height of output-port in characters. If output-port has no natural height, e.g. if it is a file port,
This procedure invokes the custom operation whose name is the symbol
x-size, if it exists. If the
x-sizeoperation is both defined and returns a value other than
#f, that value is returned as the result of this procedure. Otherwise,
output-port/x-sizereturns a default value (currently
output-port/x-sizeis useful for programs that tailor their output to the width of the display (a fairly common practice). If the output device is not a display, such programs normally want some reasonable default width to work with, and this procedure provides exactly that.