120 lines
5.9 KiB
Plaintext
120 lines
5.9 KiB
Plaintext
USING: help io quotations strings ;
|
|
|
|
HELP: stdio
|
|
{ $var-description "Holds a stream, used for various implicit stream operations. Rebound using " { $link with-stream } " and " { $link with-stream* } "." } ;
|
|
|
|
HELP: close
|
|
{ $contract "Closes the " { $link stdio } " stream." }
|
|
$io-error ;
|
|
|
|
HELP: readln
|
|
{ $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 ;
|
|
|
|
HELP: read1
|
|
{ $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 ;
|
|
|
|
HELP: read
|
|
{ $values { "n" "a non-negative integer" } { "str/f" "a string or " { $link f } } }
|
|
{ $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 ;
|
|
|
|
HELP: write1
|
|
{ $values { "ch" "a character" } }
|
|
{ $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." }
|
|
$io-error ;
|
|
|
|
HELP: write
|
|
{ $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 ;
|
|
|
|
HELP: flush
|
|
{ $contract "Waits for any pending output to the " { $link stdio } " stream to complete." }
|
|
$io-error ;
|
|
|
|
HELP: nl
|
|
{ $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 ;
|
|
|
|
HELP: format
|
|
{ $values { "str" "a string" } { "style" "a hashtable" } }
|
|
{ $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." }
|
|
{ $notes "Details are in the documentation for " { $link stream-format } "." }
|
|
$io-error ;
|
|
|
|
HELP: with-nesting
|
|
{ $values { "style" "a hashtable" } { "quot" "a quotation" } }
|
|
{ $contract "Calls the quotation in a new dynamic scope with the " { $link stdio } " stream rebound to a nested paragraph stream, with formatting information applied." }
|
|
{ $notes "Details are in the documentation for " { $link stream-format } "." }
|
|
$io-error ;
|
|
|
|
HELP: tabular-output
|
|
{ $values { "style" "a hashtable" } { "quot" quotation } }
|
|
{ $description "Calls a quotation which emits a series of equal-length table rows using " { $link with-row } ". The results are laid out in a tabular fashion on the " { $link stdio } " stream."
|
|
$nl
|
|
"The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
|
|
{ $examples
|
|
{ $code
|
|
"{ { 1 2 } { 3 4 } }"
|
|
"H{ { table-gap { 10 10 } } } ["
|
|
" [ [ [ [ . ] with-cell ] each ] with-row ] each"
|
|
"] tabular-output"
|
|
}
|
|
}
|
|
$io-error ;
|
|
|
|
HELP: with-row
|
|
{ $values { "quot" quotation } }
|
|
{ $description "Calls a quotation which emits a series of table cells using " { $link with-cell } ". This word can only be called inside the quotation given to " { $link tabular-output } "." }
|
|
$io-error ;
|
|
|
|
HELP: with-cell
|
|
{ $values { "quot" quotation } }
|
|
{ $description "Calls a quotation in a new scope with the " { $link stdio } " stream rebound. Output performed by the quotation is displayed in a table cell. This word can only be called inside the quotation given to " { $link with-row } "." }
|
|
$io-error ;
|
|
|
|
HELP: write-cell
|
|
{ $values { "str" string } }
|
|
{ $description "Outputs a table cell containing a single string. This word can only be called inside the quotation given to " { $link with-row } "." }
|
|
$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" } }
|
|
{ $description "Writes a newline-terminated string to the " { $link stdio } " stream." }
|
|
$io-error ;
|
|
|
|
HELP: with-stream
|
|
{ $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." } ;
|
|
|
|
{ with-stream with-stream* } related-words
|
|
|
|
HELP: with-stream*
|
|
{ $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 does not close the stream. Compare with " { $link with-stream } "." } ;
|
|
|
|
HELP: bl
|
|
{ $description "Outputs a space character (" { $snippet "\" \"" } ")." }
|
|
$io-error ;
|
|
|
|
HELP: write-object
|
|
{ $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 ;
|