[ bold bold-italic ] member?
[ "font-weight: bold; " % ] when ;
-: underline-css, ( flag -- )
- [ "text-decoration: underline; " % ] when ;
-
: size-css, ( size -- )
"font-size: " % # "; " % ;
{ font [ font-css, ] }
{ font-style [ style-css, ] }
{ font-size [ size-css, ] }
- { underline [ underline-css, ] }
} hash-apply
] "" make ;
#! font
#! font-style
#! font-size
- #! underline
#! file
#! word
#! vocab
--- /dev/null
+USING: help io ;
+
+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."
+{ $subsection "stream-protocol" }
+{ $subsection "stream-utilities" }
+{ $subsection "stdio" }
+;
+
+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" } ;
+
+ARTICLE: "stream-protocol" "Stream protocol"
+"The stream protocol consits of a large number of generic words, many of which are optional."
+$terpri
+"A word required to be implemented for all streams:"
+{ $subsection stream-close }
+"Three words are required for input streams:"
+{ $subsection stream-read1 }
+{ $subsection stream-read }
+{ $subsection stream-readln }
+"If your stream supports the first two but not the last one, wrap it in a " { $link <line-reader> } " to get a default implementation."
+$terpri
+"Seven words are required for output streams:"
+{ $subsection stream-flush }
+{ $subsection stream-write1 }
+{ $subsection stream-write }
+{ $subsection stream-terpri }
+{ $subsection stream-terpri* }
+{ $subsection stream-format }
+{ $subsection with-nested-stream }
+"If your stream supports the first three but not the rest, wrap it in a " { $link <plain-writer> } ", which provides plain text implementations of the stream formatting words (the so called " { $emphasis "extended stream output protocol" } ")." ;
+
+ARTICLE: "stream-utils" "Stream utilities"
+"There are a few useful stream-related words which are not generic, but merely built up from the stream protocol."
+$terpri
+"First, a simple composition of " { $link stream-write } " and " { $link stream-terpri } ":"
+{ $subsection stream-print }
+"Next up, a pair of words for reading the entire contents of a stream as an array of lines, or a single string:"
+{ $subsection lines }
+{ $subsection contents }
+"Finally, a word to copy the contents of one stream to another:"
+{ $subsection stream-copy } ;
+
+GLOSSARY: "default stream" "see " { $link stdio } ;
+
+ARTICLE: "stdio" "The default stream"
+"Various words take an implicit stream parameter from the " { $link stdio } " variable to reduce stack shuffling. Unless rebound in a child namespace, this variable will be set to a console stream for interacting with the user."
+{ $link close }
+{ $subsection read1 }
+{ $subsection read }
+{ $subsection readln }
+{ $subsection flush }
+{ $subsection write1 }
+{ $subsection write }
+{ $subsection print }
+{ $subsection terpri }
+{ $subsection terpri* }
+{ $subsection format }
+{ $subsection with-nesting }
+"A pair of combinators support rebinding the " { $link stdio } " variable:"
+{ $subsection with-stream }
+{ $subsection with-stream* } ;
+
+
: draw-ground
GL_DEPTH_TEST glDisable
- black gl-color
+ { 0.0 0.0 0.0 1.0 } gl-color
GL_QUADS [
{ -1000 0 -1000 } gl-vertex
{ -1000 0 1000 } gl-vertex
] do-matrix ;
: draw-grid ( w h -- )
- white gl-color [ swap [ grid-square ] each-with ] each-with ;
+ { 1.0 1.0 1.0 1.0 } gl-color [ swap [ grid-square ] each-with ] each-with ;
: make-ground-list ( -- id )
GL_COMPILE [ draw-ground 50 50 draw-grid ] make-dlist ;
--- /dev/null
+! Copyright (C) 2005, 2006 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+IN: styles
+
+SYMBOL: plain
+SYMBOL: bold
+SYMBOL: italic
+SYMBOL: bold-italic
+
+! Character styles
+SYMBOL: foreground
+SYMBOL: background
+SYMBOL: font
+SYMBOL: font-size
+SYMBOL: font-style
+SYMBOL: presented
+SYMBOL: file
+SYMBOL: word-break
+
+! Paragraph styles
+SYMBOL: page-color
+SYMBOL: border-color
+SYMBOL: border-width
+SYMBOL: wrap-margin
+SYMBOL: outline
+
+! Input history
+TUPLE: input string ;
"The following two lines are equivalent:"
{ $code "X [ Y ] [ Z ] if*" "X dup [ Y ] [ drop Z ] if" } } ;
-HELP: when* "( cond true false -- )"
+HELP: when* "( cond true -- )"
{ $values { "cond" "a generalized boolean" } { "true" "a quotation with stack effect " { $snippet "( cond -- )" } } }
{ $description "Variant of " { $link if* } " with no false quotation."
$terpri
"The following two lines are equivalent:"
{ $code "X [ Y ] when*" "X dup [ Y ] [ drop ] if" } } ;
-HELP: unless* "( cond true false -- )"
+HELP: unless* "( cond false -- )"
{ $values { "cond" "a generalized boolean" } { "false" "a quotation " } }
{ $description "Variant of " { $link if* } " with no true quotation."
$terpri
+++ /dev/null
-! Copyright (C) 2005, 2006 Slava Pestov.
-! See http://factor.sf.net/license.txt for BSD license.
-IN: styles
-
-! Colors are RGBA quadruples
-: black { 0.0 0.0 0.0 1.0 } ;
-: dark-gray { 0.25 0.25 0.25 1.0 } ;
-: gray { 0.5 0.5 0.5 1.0 } ;
-: light-gray { 0.75 0.75 0.75 1.0 } ;
-: white { 1.0 1.0 1.0 1.0 } ;
-: red { 1.0 0.0 0.0 1.0 } ;
-: green { 0.0 1.0 0.0 1.0 } ;
-: blue { 0.0 0.0 1.0 1.0 } ;
-
-! Character styles
-
-SYMBOL: foreground ! Used for text and outline shapes.
-SYMBOL: background ! Used for filled shapes.
-
-SYMBOL: font
-SYMBOL: font-size
-SYMBOL: font-style
-
-SYMBOL: plain
-SYMBOL: bold
-SYMBOL: italic
-SYMBOL: bold-italic
-
-SYMBOL: underline
-
-SYMBOL: presented
-SYMBOL: file
-
-! A quotation that writes an outline expansion to stdio
-SYMBOL: outline
-
-! A word break inside a pragraph with wrap-margin set
-SYMBOL: word-break
-
-! Paragraph styles
-SYMBOL: page-color
-SYMBOL: border-color
-SYMBOL: border-width
-SYMBOL: wrap-margin
-
-! Input history
-TUPLE: input string ;
[ outliner? ] find-parent ;
: <expand-arrow> ( ? -- gadget )
- arrow-right arrow-down ? gray swap
+ arrow-right arrow-down ? { 0.5 0.5 0.5 1.0 } swap
<polygon-gadget> <default-border> ;
: <expand-button> ( ? -- gadget )
: slider-vertical? gadget-orientation { 0 1 0 } = ;
: <slide-button> ( orientation polygon amount -- )
- >r gray swap <polygon-gadget> r>
+ >r { 0.5 0.5 0.5 1.0 } swap <polygon-gadget> r>
[ swap slide-by-line ] curry <repeat-button>
[ set-gadget-orientation ] keep ;