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