-USING: help io ;
+USING:
+help
+io
+styles ;
GLOSSARY: "stream" "an endpoint for input/output operations, supporting the " { $link "stream-protocol" } ;
ARTICLE: "streams" "Streams"
"Input and output centers on the concept of a " { $emphasis "stream" } ", which is a source or sink of characters. Streams also support formatted output, which may be used to present styled text in a manner independent of output medium."
+$terpri
+"Stream words are in the " { $snippet "io" } " vocabulary."
{ $subsection "stream-protocol" }
-{ $subsection "stream-utilities" }
+{ $subsection "stream-utils" }
{ $subsection "stdio" }
+{ $subsection "styles" }
+{ $subsection "stream-binary" }
+{ $subsection "stream-impls" }
;
GLOSSARY: "input stream" "an object responding to the input words of the " { $link "stream-protocol" } ;
GLOSSARY: "output stream" "an object responding to the output words of the " { $link "stream-protocol" } ;
-GLOSSARY: "bidirectional stream" "an object that is both an input and output stream" } ;
+GLOSSARY: "bidirectional stream" "an object that is both an input and output stream" ;
ARTICLE: "stream-protocol" "Stream protocol"
"The stream protocol consits of a large number of generic words, many of which are optional."
{ $subsection with-stream }
{ $subsection with-stream* } ;
+ARTICLE: "styles" "Formatted output"
+"The " { $link stream-format } " and " { $link with-nested-stream } " words take a hashtable of style attributes. The former acts on character styles, and the latter acts on paragraph styles. Output stream implementations are free to ignore style information."
+$terpri
+"Style hashtables are keyed by symbols from the " { $snippet "styles" } " vocabulary."
+{ $subsection "character-styles" }
+{ $subsection "paragraph-styles" }
+{ $subsection "style-stack" }
+{ $subsection "presentations" } ;
+
+ARTICLE: "character-styles" "Character styles"
+"Character styles for " { $link stream-format } ":"
+{ $subsection foreground }
+{ $subsection background }
+{ $subsection foreground }
+{ $subsection background }
+{ $subsection font }
+{ $subsection font-size }
+{ $subsection font-style }
+{ $subsection presented }
+{ $subsection file }
+{ $subsection word-break } ;
+
+ARTICLE: "paragraph-styles" "Paragraph styles"
+"Paragraph styles for " { $link with-nested-stream } ":"
+{ $subsection page-color }
+{ $subsection border-color }
+{ $subsection border-width }
+{ $subsection wrap-margin }
+{ $subsection outline }
+{ $subsection presented } ;
+
+ARTICLE: "style-stack" "The style stack"
+"The style stack provides a convenient facility for implementing logical nesting of character and paragraph styles."
+$terpri
+"A combinator pushes a style onto the style stack and calls a quotaiton:"
+{ $subsection with-style }
+"The contents of the style stack can be combined to form one style hashtable:"
+{ $subsection current-style }
+"A pair of words corresponding to " { $link format } " and " { $link with-nesting } ", but taking the current style from the style stack:"
+{ $subsection format* }
+{ $subsection with-nesting* } ;
+
+ARTICLE: "presentations" "Presentations and outliners"
+"The " { $link presented } " and " { $link outline } " styles can be used to build sophisticated user interfaces in the Factor UI."
+$terpri
+"Associating the " { $link presented } " character style with a run of text displayed in a pane makes it a clickable presentation of an object. Two useful utility words wrap presentation output:"
+{ $subsection write-object }
+{ $subsection simple-object }
+"Associating the " { $link outline } " paragraph style with a nested block displays it as an expandable outliner gadget, whose contents are lazily generated by a quotation. Two useful utility words wrap outliner output:"
+{ $subsection write-outliner }
+{ $subsection simple-outliner } ;
+
+GLOSSARY: "big endian" "a representation of an integer as a sequence of bytes, ordered from most significant to least significant. This is the native byte ordering for PowerPC processors" ;
+
+GLOSSARY: "little endian" "a representation of an integer as a sequence of bytes, ordered from least significant to most significant. This is the native byte ordering for x86 and AMD64 processors" ;
+
+ARTICLE: "stream-binary" "Working with binary data"
+"The core stream words read and write strings. Packed binary integers can be read and written by converting to and from sequences of bytes. Floating point numbers can be read and written by converting them into a their bitwise integer representation (" { $link "floats" } ")."
+$terpri
+"There are two ways to order the bytes making up an integer; " { $emphasis "little endian" } " byte order outputs the least significant byte first, and the most significant byte last, whereas " { $emphasis "big endian" } " is the other way around."
+$terpri
+"Consider the hexadecimal integer "{ $snippet "HEX: cafebabe" } ". Big endian byte order yields the following sequence of bytes:"
+{ $code
+ "Byte: 1 2 3 4"
+ "Value: be ba fe ca"
+}
+"Compare this with little endian byte order:"
+{ $code
+ "Byte: 1 2 3 4"
+ "Value: ca fe ba be"
+}
+"Two words convert a sequence of bytes into an integer:"
+{ $subsection be> }
+{ $subsection le> }
+"Two words convert an integer into a sequence of bytes:"
+{ $subsection >be }
+{ $subsection >le } ;
+
+ARTICLE: "stream-impls" "Stream implementations"
+"External resource streams communicate with the outside world:"
+{ $subsection "file-streams" }
+{ $subsection "network-streams" }
+"Virtual streams serve as glue:"
+{ $subsection "string-streams" }
+"Wrapper streams convert partial implementations of the stream protocol into full-fledged streams:"
+{ $subsection <line-reader> }
+{ $subsection <plain-writer> }
+"A utility to combine a complementary input and output stream pair into a single stream:"
+{ $subsection <duplex-stream> }
+"As a final note, the " { $link f } " object implements the stream protocol, by yielding end-of-file on input and discarding all output." ;
+
+ARTICLE: "file-streams" "Reading and writing files"
+{ $subsection <file-reader> }
+{ $subsection <file-writer> }
+"File system meta-data:"
+{ $subsection exists? }
+{ $subsection directory? }
+{ $subsection file-length }
+{ $subsection stat } ;
+
+GLOSSARY: "server stream" "a stream listening on a TCP/IP socket" ;
+
+GLOSSARY: "client stream" "a bidirectional stream for an to end-point of a TCP/IP connection" ;
+
+ARTICLE: "network-streams" "TCP/IP networking"
+"Client connections are bidirectional streams opened with this word:"
+{ $subsection <client> }
+"Network servers are implemented by first opening a server socket, then waiting for connections:"
+{ $subsection <server> }
+{ $subsection accept }
+"Some information can be obtained about incoming client connections:"
+{ $subsection client-stream-host }
+{ $subsection client-stream-port } ;
+ARTICLE: "string-streams" "String streams"
+"Streams:"
+{ $subsection <string-reader> }
+{ $subsection <string-writer> }
+"Utility combinators:"
+{ $subsection string-in }
+{ $subsection string-out } ;