Next: , Previous: Character input stream methods, Up: Gray Streams


10.3.7 Character output stream methods

These generic functions are used to implement subclasses of fundamental-character-output-stream:

— Generic Function: sb-gray:stream-advance-to-column stream column

Write enough blank space so that the next character will be written at the specified column. Returns true if the operation is successful, or nil if it is not supported for this stream. This is intended for use by by pprint and format ~T. The default method uses stream-line-column and repeated calls to stream-write-char with a #space character; it returns nil if stream-line-column returns nil.

— Generic Function: sb-gray:stream-fresh-line stream

Outputs a new line to the Stream if it is not positioned at the begining of a line. Returns t if it output a new line, nil otherwise. Used by fresh-line. The default method uses stream-start-line-p and stream-terpri.

— Generic Function: sb-gray:stream-line-column stream

Return the column number where the next character will be written, or nil if that is not meaningful for this stream. The first column on a line is numbered 0. This function is used in the implementation of pprint and the format ~T directive. For every character output stream class that is defined, a method must be defined for this function, although it is permissible for it to always return nil.

— Generic Function: sb-gray:stream-line-length stream

Return the stream line length or nil.

— Generic Function: sb-gray:stream-start-line-p stream

Is stream known to be positioned at the beginning of a line? It is permissible for an implementation to always return nil. This is used in the implementation of fresh-line. Note that while a value of 0 from stream-line-column also indicates the beginning of a line, there are cases where stream-start-line-p can be meaningfully implemented although stream-line-column can't be. For example, for a window using variable-width characters, the column number isn't very meaningful, but the beginning of the line does have a clear meaning. The default method for stream-start-line-p on class fundamental-character-output-stream uses stream-line-column, so if that is defined to return nil, then a method should be provided for either stream-start-line-p or stream-fresh-line.

— Generic Function: sb-gray:stream-terpri stream

Writes an end of line, as for terpri. Returns nil. The default method does (STREAM-WRITE-CHAR stream #NEWLINE).

— Generic Function: sb-gray:stream-write-char stream character

Write character to stream and return character. Every subclass of fundamental-character-output-stream must have a method defined for this function.

— Generic Function: sb-gray:stream-write-string stream string &optional start end

This is used by write-string. It writes the string to the stream, optionally delimited by start and end, which default to 0 and nil. The string argument is returned. The default method provided by fundamental-character-output-stream uses repeated calls to stream-write-char.