From bc257b0df89ab40d8c9c19b9af06fc6f9d536a13 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Wed, 18 Jan 2006 23:50:52 +0000 Subject: [PATCH] minor style cleanup --- contrib/httpd/html.factor | 5 -- doc/handbook/streams.facts | 70 +++++++++++++++++++++++++++ examples/factoroids/factoroids.factor | 4 +- library/io/styles.factor | 28 +++++++++++ library/kernel.facts | 4 +- library/styles.factor | 47 ------------------ library/ui/outliner.factor | 2 +- library/ui/sliders.factor | 2 +- 8 files changed, 104 insertions(+), 58 deletions(-) create mode 100644 doc/handbook/streams.facts create mode 100644 library/io/styles.factor delete mode 100644 library/styles.factor diff --git a/contrib/httpd/html.factor b/contrib/httpd/html.factor index 6fb97cb766..3a137f81a2 100644 --- a/contrib/httpd/html.factor +++ b/contrib/httpd/html.factor @@ -31,9 +31,6 @@ sequences strings styles words ; [ bold bold-italic ] member? [ "font-weight: bold; " % ] when ; -: underline-css, ( flag -- ) - [ "text-decoration: underline; " % ] when ; - : size-css, ( size -- ) "font-size: " % # "; " % ; @@ -57,7 +54,6 @@ sequences strings styles words ; { font [ font-css, ] } { font-style [ style-css, ] } { font-size [ size-css, ] } - { underline [ underline-css, ] } } hash-apply ] "" make ; @@ -138,7 +134,6 @@ C: html-stream ( stream -- stream ) #! font #! font-style #! font-size - #! underline #! file #! word #! vocab diff --git a/doc/handbook/streams.facts b/doc/handbook/streams.facts new file mode 100644 index 0000000000..4dba28d226 --- /dev/null +++ b/doc/handbook/streams.facts @@ -0,0 +1,70 @@ +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 } " 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 } ", 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* } ; + + diff --git a/examples/factoroids/factoroids.factor b/examples/factoroids/factoroids.factor index 04fb203853..41e3411ebc 100644 --- a/examples/factoroids/factoroids.factor +++ b/examples/factoroids/factoroids.factor @@ -11,7 +11,7 @@ IN: factoroids : 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 @@ -33,7 +33,7 @@ IN: factoroids ] 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 ; diff --git a/library/io/styles.factor b/library/io/styles.factor new file mode 100644 index 0000000000..d3df55707d --- /dev/null +++ b/library/io/styles.factor @@ -0,0 +1,28 @@ +! 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 ; diff --git a/library/kernel.facts b/library/kernel.facts index 5599993894..51995e6e9a 100644 --- a/library/kernel.facts +++ b/library/kernel.facts @@ -203,14 +203,14 @@ $terpri "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 diff --git a/library/styles.factor b/library/styles.factor deleted file mode 100644 index e42f7357b7..0000000000 --- a/library/styles.factor +++ /dev/null @@ -1,47 +0,0 @@ -! 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 ; diff --git a/library/ui/outliner.factor b/library/ui/outliner.factor index 8defdda316..3cbf16c303 100644 --- a/library/ui/outliner.factor +++ b/library/ui/outliner.factor @@ -24,7 +24,7 @@ DEFER: [ outliner? ] find-parent ; : ( ? -- gadget ) - arrow-right arrow-down ? gray swap + arrow-right arrow-down ? { 0.5 0.5 0.5 1.0 } swap ; : ( ? -- gadget ) diff --git a/library/ui/sliders.factor b/library/ui/sliders.factor index 88e961362a..150efa318c 100644 --- a/library/ui/sliders.factor +++ b/library/ui/sliders.factor @@ -106,7 +106,7 @@ M: elevator layout* ( elevator -- ) : slider-vertical? gadget-orientation { 0 1 0 } = ; : ( orientation polygon amount -- ) - >r gray swap r> + >r { 0.5 0.5 0.5 1.0 } swap r> [ swap slide-by-line ] curry [ set-gadget-orientation ] keep ;