30.4. Generic functions for character input

Generic functions for character input

(GRAY:STREAM-READ-CHAR stream)

If a character was pushed back using GRAY:STREAM-UNREAD-CHAR, returns and consumes it. Otherwise returns and consumes the next character from the stream. Returns :EOF if the end-of-stream is reached.

You must define a method for this function.

(GRAY:STREAM-UNREAD-CHAR stream char)

Pushes char, which must be the last character read from the stream, back onto the front of the stream.

You must define a method for this function.

(GRAY:STREAM-READ-CHAR-NO-HANG stream)

Returns a character or :EOF, like GRAY:STREAM-READ-CHAR, if that would return immediately. If GRAY:STREAM-READ-CHAR's value is not available immediately, returns NIL instead of waiting.

The default method simply calls GRAY:STREAM-READ-CHAR; this is sufficient for streams whose GRAY:STREAM-READ-CHAR method never blocks.

(GRAY:STREAM-PEEK-CHAR stream)

If a character was pushed back using GRAY:STREAM-UNREAD-CHAR, returns it. Otherwise returns the next character from the stream, avoiding any side effects GRAY:STREAM-READ-CHAR would do. Returns :EOF if the end-of-stream is reached.

The default method calls GRAY:STREAM-READ-CHAR and GRAY:STREAM-UNREAD-CHAR; this is sufficient for streams whose GRAY:STREAM-READ-CHAR method has no side-effects.

(GRAY:STREAM-LISTEN stream)

If a character was pushed back using GRAY:STREAM-UNREAD-CHAR, returns it. Otherwise returns the next character from the stream, if already available. If no character is available immediately, or if end-of-stream is reached, returns NIL.

The default method calls GRAY:STREAM-READ-CHAR-NO-HANG and GRAY:STREAM-UNREAD-CHAR; this is sufficient for streams whose GRAY:STREAM-READ-CHAR method has no side-effects.

(GRAY:STREAM-READ-CHAR-WILL-HANG-P stream)

Returns NIL if GRAY:STREAM-READ-CHAR will return immediately. Otherwise it returns true.

The default method calls GRAY:STREAM-READ-CHAR-NO-HANG and GRAY:STREAM-UNREAD-CHAR; this is sufficient for streams whose GRAY:STREAM-READ-CHAR method has no side-effects.

This function is a CLISP extension (see EXT:READ-CHAR-WILL-HANG-P).

(GRAY:STREAM-READ-CHAR-SEQUENCE stream sequence &OPTIONAL [start [end]])

Fills the subsequence of sequence specified by :START and :END with characters consecutively read from stream. Returns the index of the first element of sequence that was not updated (= end, or < end if the stream reached its end).

sequence is an ARRAY of CHARACTERs, i.e. a STRING. start is a nonnegative INTEGER and defaults to 0. end is a nonnegative INTEGER or NIL and defaults to NIL, which stands for (LENGTH sequence).

The default method repeatedly calls GRAY:STREAM-READ-CHAR; this is always sufficient if speed does not matter.

This function is a CLISP extension (see EXT:READ-CHAR-SEQUENCE).

(GRAY:STREAM-READ-LINE stream)

Reads a line of characters, and return two values: the line (a STRING, without the terminating #\Newline character), and a BOOLEAN value which is true if the line was terminated by end-of-stream instead of #\Newline.

The default method repeatedly calls GRAY:STREAM-READ-CHAR; this is always sufficient.

(GRAY:STREAM-CLEAR-INPUT stream)

Clears all pending interactive input from the stream, and returns true if some pending input was removed.

The default method does nothing and returns NIL; this is sufficient for non-interactive streams.


These notes document CLISP version 2.49.60+Last modified: 2017-11-21