! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays assocs classes colors.constants
+USING: accessors arrays assocs classes colors colors.constants
combinators definitions definitions.icons effects fry generic
hashtables help.stylesheet help.topics io io.styles kernel make
math namespaces parser present prettyprint
1array \ $image prefix ;
! Some links
+
+<PRIVATE
+
: write-link ( string object -- )
link-style get [ write-object ] with-style ;
: link-text ( topic -- )
[ article-name ] keep write-link ;
-: link-effect ( topic -- )
- dup word? [
- stack-effect [ effect>string ] [ effect-style ] bi
- [ write ] with-style
- ] [ drop ] if ;
+GENERIC: link-long-text ( topic -- )
-: inter-cleave ( x seq between -- )
- [ [ call( x -- ) ] with ] dip swap interleave ; inline
+M: topic link-long-text
+ [ article-title ] keep write-link ;
-: (($link)) ( topic words -- )
- [ dup topic? [ >link ] unless ] dip
- [ [ bl ] inter-cleave ] ($span) ; inline
+M: word link-long-text
+ dup presented associate [
+ [ article-name link-style get format ]
+ [ drop bl ]
+ [ stack-effect effect>string stack-effect-style get format ]
+ tri
+ ] with-nesting ;
-: ($link) ( topic -- )
- { [ link-text ] } (($link)) ;
+: >topic ( obj -- topic ) dup topic? [ >link ] unless ;
-: $link ( element -- ) first ($link) ;
+PRIVATE>
-: ($long-link) ( topic -- )
- { [ link-text ] [ link-effect ] } (($link)) ;
+: ($link) ( topic -- ) >topic link-text ;
+: $link ( element -- ) first ($link) ;
+: ($long-link) ( topic -- ) >topic link-long-text ;
: $long-link ( element -- ) first ($long-link) ;
: ($pretty-link) ( topic -- )
- { [ link-icon ] [ link-text ] } (($link)) ;
-
+ >topic [ link-icon ] [ drop bl ] [ link-text ] tri ;
: $pretty-link ( element -- ) first ($pretty-link) ;
: ($long-pretty-link) ( topic -- )
- { [ link-icon ] [ link-text ] [ link-effect ] } (($link)) ;
-
-: $long-pretty-link ( element -- ) first ($long-pretty-link) ;
+ >topic [ link-icon ] [ drop bl ] [ link-long-text ] tri ;
: <$pretty-link> ( definition -- element )
1array \ $pretty-link prefix ;
! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: hashtables io io.streams.plain io.streams.string
-colors summary make accessors splitting math.order
-kernel namespaces assocs destructors strings sequences
-present fry strings.tables delegate delegate.protocols ;
+USING: accessors assocs colors colors.constants delegate
+delegate.protocols destructors fry hashtables io
+io.streams.plain io.streams.string kernel make math.order
+namespaces present sequences splitting strings strings.tables
+summary ;
IN: io.styles
GENERIC: stream-format ( str style stream -- )
: write-object ( str obj -- ) presented associate format ;
: write-image ( image -- ) [ "" ] dip image associate format ;
+
+SYMBOL: stack-effect-style
+H{
+ { foreground COLOR: FactorDarkGreen }
+ { font-style plain }
+} stack-effect-style set-global