Merge branch 'link' of git://github.com/klazuka/factor

db4
Slava Pestov 2009-09-30 05:11:21 -05:00
commit da623ba29a
4 changed files with 34 additions and 27 deletions

View File

@ -4,3 +4,4 @@
172 167 147 FactorDarkTan 172 167 147 FactorDarkTan
81 91 105 FactorLightSlateBlue 81 91 105 FactorLightSlateBlue
55 62 72 FactorDarkSlateBlue 55 62 72 FactorDarkSlateBlue
0 51 0 FactorDarkGreen

View File

@ -1,6 +1,6 @@
! Copyright (C) 2005, 2009 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! 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 combinators definitions definitions.icons effects fry generic
hashtables help.stylesheet help.topics io io.styles kernel make hashtables help.stylesheet help.topics io io.styles kernel make
math namespaces parser present prettyprint math namespaces parser present prettyprint
@ -154,6 +154,9 @@ ALIAS: $slot $snippet
1array \ $image prefix ; 1array \ $image prefix ;
! Some links ! Some links
<PRIVATE
: write-link ( string object -- ) : write-link ( string object -- )
link-style get [ write-object ] with-style ; link-style get [ write-object ] with-style ;
@ -163,38 +166,35 @@ ALIAS: $slot $snippet
: link-text ( topic -- ) : link-text ( topic -- )
[ article-name ] keep write-link ; [ article-name ] keep write-link ;
: link-effect ( topic -- ) GENERIC: link-long-text ( topic -- )
dup word? [
stack-effect [ effect>string ] [ effect-style ] bi
[ write ] with-style
] [ drop ] if ;
: inter-cleave ( x seq between -- ) M: topic link-long-text
[ [ call( x -- ) ] with ] dip swap interleave ; inline [ article-title ] keep write-link ;
: (($link)) ( topic words -- ) M: word link-long-text
[ dup topic? [ >link ] unless ] dip dup presented associate [
[ [ bl ] inter-cleave ] ($span) ; inline [ article-name link-style get format ]
[ drop bl ]
[ stack-effect effect>string stack-effect-style get format ]
tri
] with-nesting ;
: ($link) ( topic -- ) : >topic ( obj -- topic ) dup topic? [ >link ] unless ;
{ [ link-text ] } (($link)) ;
PRIVATE>
: ($link) ( topic -- ) >topic link-text ;
: $link ( element -- ) first ($link) ; : $link ( element -- ) first ($link) ;
: ($long-link) ( topic -- ) : ($long-link) ( topic -- ) >topic link-long-text ;
{ [ link-text ] [ link-effect ] } (($link)) ;
: $long-link ( element -- ) first ($long-link) ; : $long-link ( element -- ) first ($long-link) ;
: ($pretty-link) ( topic -- ) : ($pretty-link) ( topic -- )
{ [ link-icon ] [ link-text ] } (($link)) ; >topic [ link-icon ] [ drop bl ] [ link-text ] tri ;
: $pretty-link ( element -- ) first ($pretty-link) ; : $pretty-link ( element -- ) first ($pretty-link) ;
: ($long-pretty-link) ( topic -- ) : ($long-pretty-link) ( topic -- )
{ [ link-icon ] [ link-text ] [ link-effect ] } (($link)) ; >topic [ link-icon ] [ drop bl ] [ link-long-text ] tri ;
: $long-pretty-link ( element -- ) first ($long-pretty-link) ;
: <$pretty-link> ( definition -- element ) : <$pretty-link> ( definition -- element )
1array \ $pretty-link prefix ; 1array \ $pretty-link prefix ;

View File

@ -1,9 +1,10 @@
! Copyright (C) 2005, 2009 Slava Pestov. ! Copyright (C) 2005, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
USING: hashtables io io.streams.plain io.streams.string USING: accessors assocs colors colors.constants delegate
colors summary make accessors splitting math.order delegate.protocols destructors fry hashtables io
kernel namespaces assocs destructors strings sequences io.streams.plain io.streams.string kernel make math.order
present fry strings.tables delegate delegate.protocols ; namespaces present sequences splitting strings strings.tables
summary ;
IN: io.styles IN: io.styles
GENERIC: stream-format ( str style stream -- ) GENERIC: stream-format ( str style stream -- )
@ -162,3 +163,9 @@ M: input summary
: write-object ( str obj -- ) presented associate format ; : write-object ( str obj -- ) presented associate format ;
: write-image ( image -- ) [ "" ] dip image 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

View File

@ -43,5 +43,4 @@ PRIVATE>
dim-color colored-presentation-style ; dim-color colored-presentation-style ;
: effect-style ( effect -- style ) : effect-style ( effect -- style )
0 0.2 0 1 <rgba> colored-presentation-style presented associate stack-effect-style get assoc-union ;
{ { font-style plain } } assoc-union ;