]> gitweb.factorcode.org Git - factor.git/blob - basis/io/styles/styles-docs.factor
Merge branch 'master' into experimental (untested!)
[factor.git] / basis / io / styles / styles-docs.factor
1 USING: help.markup help.syntax io.streams.plain io strings
2 hashtables ;
3 IN: io.styles
4
5 ARTICLE: "character-styles" "Character styles"
6 "Character styles for " { $link stream-format } " and " { $link with-style } ":"
7 { $subsection foreground }
8 { $subsection background }
9 { $subsection font }
10 { $subsection font-size }
11 { $subsection font-style }
12 { $subsection presented } ;
13
14 ARTICLE: "paragraph-styles" "Paragraph styles"
15 "Paragraph styles for " { $link with-nesting } ":"
16 { $subsection page-color }
17 { $subsection border-color }
18 { $subsection border-width }
19 { $subsection wrap-margin }
20 { $subsection presented } ;
21
22 ARTICLE: "table-styles" "Table styles"
23 "Table styles for " { $link tabular-output } ":"
24 { $subsection table-gap }
25 { $subsection table-border } ;
26
27 HELP: write-object
28 { $values { "str" string } { "obj" "an object" } }
29 { $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 } "." }
30 $io-error ;
31
32 ARTICLE: "presentations" "Presentations"
33 "The " { $link presented } " style can be used to emit clickable objects. A utility word for outputting this style:"
34 { $subsection write-object } ;
35
36 ARTICLE: "styles" "Formatted output"
37 "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."
38 $nl
39 "Style hashtables are keyed by symbols from the " { $vocab-link "io.styles" } " vocabulary."
40 { $subsection "character-styles" }
41 { $subsection "paragraph-styles" }
42 { $subsection "table-styles" }
43 { $subsection "presentations" } ;
44
45 ABOUT: "styles"
46
47 HELP: plain
48 { $description "A value for the " { $link font-style } " character style denoting plain text." } ;
49
50 HELP: bold
51 { $description "A value for the " { $link font-style } " character style denoting boldface text." } ;
52
53 HELP: italic
54 { $description "A value for the " { $link font-style } " character style denoting italicized text." } ;
55
56 HELP: bold-italic
57 { $description "A value for the " { $link font-style } " character style denoting boldface italicized text." } ;
58
59 HELP: foreground
60 { $description "Character style. Text color, denoted by a sequence of four numbers between 0 and 1 (red, green, blue and alpha)." } 
61 { $examples
62     { $code
63         "10 ["
64             "    \"Hello world\" swap"
65             "    { 0.1 0.1 0.2 1 } n*v { 1 1 1 1 } vmin"
66             "    foreground associate format nl"
67         "] each"
68     }
69 } ;
70
71 HELP: background
72 { $description "Character style. Background color, denoted by a sequence of four numbers between 0 and 1 (red, green, blue and alpha)." }
73 { $examples
74     { $code
75         "10 ["
76             "    \"Hello world\" swap"
77             "    { 0.1 0.4 0.1 } n*v { 1 1 1 } vmin { 1 } append"
78             "    background associate format nl"
79         "] each"
80     }
81 } ;
82
83 HELP: font
84 { $description "Character style. Font family named by a string." }
85 { $examples
86     "This example outputs some different font sizes:"
87     { $code "{ \"monospace\" \"serif\" \"sans-serif\" }\n[ dup font associate format nl ] each" }
88 } ;
89
90 HELP: font-size
91 { $description "Character style. Font size, an integer." }
92 { $examples
93     "This example outputs some different font sizes:"
94     { $code "{ 12 18 24 72 }"
95         "[ \"Bigger\" swap font-size associate format nl ] each"
96     }
97 }  ;
98
99 HELP: font-style
100 { $description "Character style. Font style, one of " { $link plain } ", " { $link bold } ", " { $link italic } ", or " { $link bold-italic } "." }
101 { $examples
102     "This example outputs text in all three styles:"
103     { $code "{ plain bold italic bold-italic }\n[ [ name>> ] keep font-style associate format nl ] each" }
104 }  ;
105
106 HELP: presented
107 { $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." } ;
108
109 HELP: presented-path
110 { $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." } ;
111
112 HELP: presented-printer
113 { $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." } ;
114
115 HELP: page-color
116 { $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)." } 
117 { $examples
118     { $code "H{ { page-color { 1 0.8 0.5 1 } } }\n[ \"A background\" write ] with-nesting nl" }
119 } ;
120
121 HELP: border-color
122 { $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)." } 
123 { $examples
124     { $code "H{ { border-color { 1 0 0 1 } } }\n[ \"A border\" write ] with-nesting nl" }
125 } ;
126
127 HELP: border-width
128 { $description "Paragraph style. Pixels between edge of text and border color, an integer." } 
129 { $examples
130     { $code "H{ { border-width 10 } }\n[ \"Some inset text\" write ] with-nesting nl" }
131 } ;
132
133 HELP: wrap-margin
134 { $description "Paragraph style. Pixels between left margin and right margin where text is wrapped, an integer." } ;
135
136 { wrap-margin bl } related-words
137
138 HELP: table-gap
139 { $description "Table style. Horizontal and vertical gap between table cells, denoted by a pair of integers." } ;
140
141 { table-gap table-border stream-write-table tabular-output } related-words
142
143 HELP: table-border
144 { $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)." } ;
145
146 HELP: input
147 { $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> } "." }
148 { $examples
149     "This presentation class is used for the code examples you see in the online help:"
150     { $code "\"2 3 + .\" dup <input> write-object nl" }
151 } ;
152
153 HELP: <input> ( string -- input )
154 { $values { "string" string } { "input" input } }
155 { $description "Creates a new " { $link input } "." } ;
156
157 HELP: standard-table-style
158 { $values { "style" hashtable } }
159 { $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 } "." } ;