1 USING: help.markup help.syntax io.streams.plain io strings
2 hashtables kernel quotations ;
6 { $values { "str" string } { "style" "a hashtable" } { "stream" "an output stream" } }
7 { $contract "Writes formatted text to the stream. If the stream does buffering, output may not be performed immediately; use " { $link stream-flush } " to force output."
9 "The " { $snippet "style" } " hashtable holds character style information. See " { $link "character-styles" } "." }
10 { $notes "Most code only works on one stream at a time and should instead use " { $link format } "; see " { $link "stdio" } "." }
13 HELP: make-block-stream
14 { $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } }
15 { $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "."
17 "Unlike " { $link make-span-stream } ", this creates a new paragraph block in the output."
19 "The " { $snippet "style" } " hashtable holds paragraph style information. See " { $link "paragraph-styles" } "." }
20 { $notes "Most code only works on one stream at a time and should instead use " { $link with-nesting } "; see " { $link "stdio" } "." }
23 HELP: stream-write-table
24 { $values { "table-cells" "a sequence of sequences of table cells" } { "style" "a hashtable" } { "stream" "an output stream" } }
25 { $contract "Prints a table of cells produced by " { $link with-cell } "."
27 "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
28 { $notes "Most code only works on one stream at a time and should instead use " { $link tabular-output } "; see " { $link "stdio" } "." }
31 HELP: make-cell-stream
32 { $values { "style" hashtable } { "stream" "an output stream" } { "stream'" object } }
33 { $contract "Creates an output stream which writes to a table cell object." }
34 { $notes "Most code only works on one stream at a time and should instead use " { $link with-cell } "; see " { $link "stdio" } "." }
37 HELP: make-span-stream
38 { $values { "style" "a hashtable" } { "stream" "an output stream" } { "stream'" "an output stream" } }
39 { $contract "Creates an output stream which wraps " { $snippet "stream" } " and adds " { $snippet "style" } " on calls to " { $link stream-write } " and " { $link stream-format } "."
41 "Unlike " { $link make-block-stream } ", the stream output is inline, and not nested in a paragraph block." }
42 { $notes "Most code only works on one stream at a time and should instead use " { $link with-style } "; see " { $link "stdio" } "." }
46 { $values { "str" string } { "style" "a hashtable" } }
47 { $description "Writes formatted text to " { $link output-stream } ". If the stream does buffering, output may not be performed immediately; use " { $link flush } " to force output." }
48 { $notes "Details are in the documentation for " { $link stream-format } "." }
52 { $values { "style" "a hashtable" } { "quot" quotation } }
53 { $description "Calls the quotation in a new dynamic scope with " { $link output-stream } " rebound to a nested paragraph stream, with formatting information applied." }
54 { $notes "Details are in the documentation for " { $link make-block-stream } "." }
58 { $values { "style" "a hashtable" } { "quot" quotation } }
59 { $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 " { $link output-stream } "."
61 "The " { $snippet "style" } " hashtable holds table style information. See " { $link "table-styles" } "." }
65 "H{ { table-gap { 10 10 } } } ["
66 " [ [ [ [ . ] with-cell ] each ] with-row ] each"
73 { $values { "quot" quotation } }
74 { $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 } "." }
78 { $values { "quot" quotation } }
79 { $description "Calls a quotation in a new scope with " { $link output-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 } "." }
83 { $values { "str" string } }
84 { $description "Outputs a table cell containing a single string. This word can only be called inside the quotation given to " { $link with-row } "." }
88 { $values { "style" "a hashtable" } { "quot" quotation } }
89 { $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" } "." }
90 { $notes "Details are in the documentation for " { $link make-span-stream } "." }
93 ARTICLE: "formatted-stream-protocol" "Formatted stream protocol"
94 "The " { $vocab-link "io.styles" } " vocabulary defines a protocol for output streams that support rich text."
95 { $subsection stream-format }
96 { $subsection make-span-stream }
97 { $subsection make-block-stream }
98 { $subsection make-cell-stream }
99 { $subsection stream-write-table } ;
101 ARTICLE: "formatted-stdout" "Formatted output on the default stream"
102 "The below words perform formatted output on " { $link output-stream } "."
105 { $subsection format }
106 { $subsection with-style }
107 { $subsection with-nesting }
109 { $subsection tabular-output }
110 { $subsection with-row }
111 { $subsection with-cell }
112 { $subsection write-cell } ;
114 ARTICLE: "character-styles" "Character styles"
115 "Character styles for " { $link stream-format } " and " { $link with-style } ":"
116 { $subsection foreground }
117 { $subsection background }
119 { $subsection font-size }
120 { $subsection font-style }
121 { $subsection presented } ;
123 ARTICLE: "paragraph-styles" "Paragraph styles"
124 "Paragraph styles for " { $link with-nesting } ":"
125 { $subsection page-color }
126 { $subsection border-color }
127 { $subsection border-width }
128 { $subsection wrap-margin }
129 { $subsection presented } ;
131 ARTICLE: "table-styles" "Table styles"
132 "Table styles for " { $link tabular-output } ":"
133 { $subsection table-gap }
134 { $subsection table-border } ;
137 { $values { "str" string } { "obj" "an object" } }
138 { $description "Writes a string to " { $link output-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 } "." }
141 ARTICLE: "presentations" "Presentations"
142 "The " { $link presented } " style can be used to emit clickable objects. A utility word for outputting this style:"
143 { $subsection write-object } ;
145 ARTICLE: "styles" "Styled text"
146 "The " { $link stream-format } ", " { $link with-style } ", " { $link with-nesting } " and " { $link tabular-output } " words take a hashtable of style attributes. Output stream implementations are free to ignore style information."
148 "Style hashtables are keyed by symbols from the " { $vocab-link "io.styles" } " vocabulary."
149 { $subsection "character-styles" }
150 { $subsection "paragraph-styles" }
151 { $subsection "table-styles" }
152 { $subsection "presentations" } ;
154 ARTICLE: "io.styles" "Formatted output"
155 "The " { $vocab-link "io.styles" } " vocabulary defines a protocol for formatted output. This is used by the prettyprinter, help system, and various developer tools. Implementations include " { $vocab-link "ui.gadgets.panes" } ", " { $vocab-link "html.streams" } ", and " { $vocab-link "io.streams.plain" } "."
156 { $subsection "formatted-stream-protocol" }
157 { $subsection "formatted-stdout" }
158 { $subsection "styles" } ;
163 { $description "A value for the " { $link font-style } " character style denoting plain text." } ;
166 { $description "A value for the " { $link font-style } " character style denoting boldface text." } ;
169 { $description "A value for the " { $link font-style } " character style denoting italicized text." } ;
172 { $description "A value for the " { $link font-style } " character style denoting boldface italicized text." } ;
175 { $description "Character style. Text color, denoted by a sequence of four numbers between 0 and 1 (red, green, blue and alpha)." }
179 " \"Hello world\" swap"
180 " { 0.1 0.1 0.2 1 } n*v { 1 1 1 1 } vmin"
181 " foreground associate format nl"
187 { $description "Character style. Background color, denoted by a sequence of four numbers between 0 and 1 (red, green, blue and alpha)." }
191 " \"Hello world\" swap"
192 " { 0.1 0.4 0.1 } n*v { 1 1 1 } vmin { 1 } append"
193 " background associate format nl"
199 { $description "Character style. Font family named by a string." }
201 "This example outputs some different font sizes:"
202 { $code "{ \"monospace\" \"serif\" \"sans-serif\" }\n[ dup font associate format nl ] each" }
206 { $description "Character style. Font size, an integer." }
208 "This example outputs some different font sizes:"
209 { $code "{ 12 18 24 72 }"
210 "[ \"Bigger\" swap font-size associate format nl ] each"
215 { $description "Character style. Font style, one of " { $link plain } ", " { $link bold } ", " { $link italic } ", or " { $link bold-italic } "." }
217 "This example outputs text in all three styles:"
218 { $code "{ plain bold italic bold-italic }\n[ [ name>> ] keep font-style associate format nl ] each" }
222 { $description "Character and paragraph style. An object associated with the text. In the Factor UI, this is shown as a clickable presentation of the object; left-clicking invokes a default command, and right-clicking shows a menu of commands." } ;
225 { $description "Character and paragraph style. An editable object associated with the text. In the Factor UI, this is shown as a clickable presentation of the object path together with an expander button which displays an object editor; left-clicking invokes a default command, and right-clicking shows a menu of commands." } ;
227 HELP: presented-printer
228 { $description "Character and paragraph style. A quotation with stack effect " { $snippet "( obj -- )" } " which is applied to the value at the " { $link presented-path } " if the presentation needs to be re-displayed after the object has been edited." } ;
231 { $description "Paragraph style. Background color of the paragraph block, denoted by a sequence of four numbers between 0 and 1 (red, green, blue and alpha)." }
233 { $code "H{ { page-color { 1 0.8 0.5 1 } } }\n[ \"A background\" write ] with-nesting nl" }
237 { $description "Paragraph style. Border color of the paragraph block, denoted by a sequence of four numbers between 0 and 1 (red, green, blue and alpha)." }
239 { $code "H{ { border-color { 1 0 0 1 } } }\n[ \"A border\" write ] with-nesting nl" }
243 { $description "Paragraph style. Pixels between edge of text and border color, an integer." }
245 { $code "H{ { border-width 10 } }\n[ \"Some inset text\" write ] with-nesting nl" }
249 { $description "Paragraph style. Pixels between left margin and right margin where text is wrapped, an integer." } ;
251 { wrap-margin bl } related-words
254 { $description "Table style. Horizontal and vertical gap between table cells, denoted by a pair of integers." } ;
256 { table-gap table-border stream-write-table tabular-output } related-words
259 { $description "Table style. Color of the border drawn between cells, denoted by a sequence of four numbers between 0 and 1 (red, green, blue and alpha)." } ;
262 { $class-description "Class of input text presentations. Instances can be used passed to " { $link write-object } " to output a clickable piece of input. Input text presentations are created by calling " { $link <input> } "." }
264 "This presentation class is used for the code examples you see in the online help:"
265 { $code "\"2 3 + .\" dup <input> write-object nl" }
269 { $values { "string" string } { "input" input } }
270 { $description "Creates a new " { $link input } "." } ;
272 HELP: standard-table-style
273 { $values { "style" hashtable } }
274 { $description "Outputs a table style where cells are separated by 5-pixel gaps and framed by a light gray border. This style can be passed to " { $link tabular-output } "." } ;
276 ARTICLE: "io.streams.plain" "Plain writer streams"
277 "Plain writer streams wrap an underlying stream and provide a default implementation of "
278 { $link stream-nl } ", "
279 { $link stream-format } ", "
280 { $link make-span-stream } ", "
281 { $link make-block-stream } " and "
282 { $link make-cell-stream } "."
283 { $subsection plain-writer } ;