factor/core/io/stdio.facts

101 lines
5.6 KiB
Plaintext
Raw Normal View History

2006-01-17 01:02:23 -05:00
USING: help io ;
2006-08-16 21:55:53 -04:00
HELP: stdio
{ $var-description "Holds a stream, used for various implicit stream operations. Rebound using " { $link with-stream } " and " { $link with-stream* } "." } ;
2006-01-16 02:48:15 -05:00
2006-08-16 21:55:53 -04:00
HELP: close
2006-01-16 02:48:15 -05:00
{ $contract "Closes the " { $link stdio } " stream." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: readln
2006-01-16 02:48:15 -05:00
{ $values { "str/f" "a string or " { $link f } } }
{ $contract "Reads a line of input from the " { $link stdio } " stream. Outputs " { $link f } " on stream exhaustion." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: read1
2006-01-16 02:48:15 -05:00
{ $values { "ch/f" "a character or " { $link f } } }
{ $contract "Reads a character of input from the " { $link stdio } " stream. Outputs " { $link f } " on stream exhaustion." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: read
{ $values { "n" "a non-negative integer" } { "str/f" "a string or " { $link f } } }
2006-01-16 02:48:15 -05:00
{ $contract "Reads " { $snippet "n" } " characters of input from the " { $link stdio } " stream. Outputs a truncated string or " { $link f } " on stream exhaustion." }
$io-error ;
HELP: read-until
{ $values { "seps" "a string" } { "str/f" "a string or " { $link f } } { "sep/f" "a character or " { $link f } } }
{ $contract "Reads characters from the " { $link stdio } " stream. until the first occurrence of a separator character, or stream exhaustion. In the former case, the separator character is pushed on the stack, and is not part of the output string. In the latter case, the entire stream contents are output, along with " { $link f } "." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: write1
2006-01-16 02:48:15 -05:00
{ $values { "ch" "a character" } }
2006-01-17 02:43:38 -05:00
{ $contract "Writes a character of output to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
2006-01-16 02:48:15 -05:00
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: write
2006-01-16 02:48:15 -05:00
{ $values { "str" "a string" } }
{ $contract "Writes a string of output to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: flush
2006-01-16 02:48:15 -05:00
{ $contract "Waits for any pending output to the " { $link stdio } " stream to complete." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: terpri
2006-01-16 02:48:15 -05:00
{ $contract "Writes a line terminator to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: format
2006-01-16 02:48:15 -05:00
{ $values { "str" "a string" } { "style" "a hashtable" } }
2006-01-17 02:43:38 -05:00
{ $contract "Writes formatted text to the " { $link stdio } " stream. If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
2006-01-16 02:48:15 -05:00
{ $notes "Details are in the documentation for " { $link stream-format } "." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: with-nesting
2006-01-16 02:48:15 -05:00
{ $values { "style" "a hashtable" } { "quot" "a quotation" } }
2006-01-17 01:02:23 -05:00
{ $contract "Calls the quotation in a new dynamic scope with the " { $link stdio } " stream rebound to a nested paragraph stream, with formatting information applied." }
2006-01-16 02:48:15 -05:00
{ $notes "Details are in the documentation for " { $link stream-format } "." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: tabular-output
{ $values { "grid" "a sequence of equal-length sequences" } { "style" "a hashtable" } { "quot" "a quotation" } }
{ $description "Calls the quotation with each element of the grid in turn, each time in a new dynamic scope with " { $link stdio } " rebound to a new stream. The results are laid out in a tabular fashion on the " { $link stdio } " stream." }
{ $notes "Details are in the documentation for " { $link with-stream-table } "." }
$io-error ;
HELP: with-style
{ $values { "style" "a hashtable" } { "quot" "a quotation" } }
{ $description "Calls the quotation in a new dynamic scope where calls to " { $link write } ", " { $link format } " and other stream output words automatically inherit style settings from " { $snippet "style" } "." }
{ $notes "Details are in the documentation for " { $link with-stream-style } "." }
$io-error ;
HELP: print
{ $values { "string" "a string" } }
2006-01-17 02:43:38 -05:00
{ $description "Writes a newline-terminated string to the " { $link stdio } " stream." }
2006-01-16 02:48:15 -05:00
$io-error ;
2006-01-17 01:02:23 -05:00
2006-08-16 21:55:53 -04:00
HELP: with-stream
2006-01-17 01:02:23 -05:00
{ $values { "stream" "an input or output stream" } { "quot" "a quotation" } }
{ $description "Calls the quotation in a new dynamic scope, with the " { $link stdio } " variable rebound to " { $snippet "stream" } ". The stream is closed if the quotation returns or throws an error." }
{ $see-also with-stream* } ;
2006-08-16 21:55:53 -04:00
HELP: with-stream*
2006-01-17 01:02:23 -05:00
{ $values { "stream" "an input or output stream" } { "quot" "a quotation" } }
{ $description "Calls the quotation in a new dynamic scope, with the " { $link stdio } " variable rebound to " { $snippet "stream" } "." }
{ $notes "This word differs from " { $link with-stream } " in that if an error is thrown while the quotation is executing, the stream is " { $emphasis "not" } " closed." }
2006-01-17 01:02:23 -05:00
{ $see-also with-stream } ;
2006-08-16 21:55:53 -04:00
HELP: bl
{ $description "Outputs a space character (" { $snippet "\" \"" } ")." }
2006-01-17 01:02:23 -05:00
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: write-object
2006-01-17 01:02:23 -05:00
{ $values { "str" "a string" } { "obj" "an object" } }
{ $description "Writes a string to the " { $link stdio } " stream, associating it with the object. If formatted output is supported, the string will become a clickable presentation of the object, otherwise this word behaves like a call to " { $link write } "." }
$io-error ;
2006-08-16 21:55:53 -04:00
HELP: write-outliner
2006-01-17 01:02:23 -05:00
{ $values { "str" "a string" } { "obj" "an object" } { "content" "a quotation" } }
{ $description "Writes an outliner to the " { $link stdio } " stream. The outliner's caption is a the string " { $snippet "str" } " with an associated presentation of " { $snippet "obj" } ". Expanding the outliner calls " { $snippet "content" } " in a new dynamic scope with " { $link stdio } " rebound to the body of the outliner. If the stream does not support formatted output, this simply writes " { $snippet "str" } " and ignores everything else." }
$io-error ;