]> gitweb.factorcode.org Git - factor.git/commitdiff
Merge branch 'link' of git://github.com/klazuka/factor
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 30 Sep 2009 10:11:21 +0000 (05:11 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Wed, 30 Sep 2009 10:11:21 +0000 (05:11 -0500)
basis/colors/constants/factor-colors.txt
basis/help/markup/markup.factor
basis/io/styles/styles.factor
basis/prettyprint/stylesheet/stylesheet.factor

index b8af9d394914455c7eb138b1758d7245ff7a5696..64a857a2a40dd69815265c0f782541e8104ef06d 100644 (file)
@@ -4,3 +4,4 @@
 172 167 147            FactorDarkTan
  81  91 105            FactorLightSlateBlue
  55  62  72            FactorDarkSlateBlue
+  0  51   0     FactorDarkGreen
index 0201e86b3fe018f78038860b71f1b88f5fe758c9..2377a6753a8e39d9984040dc72a3153e15bfe121 100644 (file)
@@ -1,6 +1,6 @@
 ! 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
@@ -154,6 +154,9 @@ ALIAS: $slot $snippet
     1array \ $image prefix ;
 
 ! Some links
+
+<PRIVATE
+
 : write-link ( string object -- )
     link-style get [ write-object ] with-style ;
 
@@ -163,38 +166,35 @@ ALIAS: $slot $snippet
 : 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 ;
index b141d8d2f713e0299ba23db3749c919c82bf3894..ae493be8490c26f97c741246ece4a79625d30663 100644 (file)
@@ -1,9 +1,10 @@
 ! 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 -- )
@@ -162,3 +163,9 @@ M: input summary
 : 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
index 580049160db93c136d0ca3789c8a940004dd506b..42a701d60f6639ad5e5068433a2b20fe70efaf85 100644 (file)
@@ -43,5 +43,4 @@ PRIVATE>
     dim-color colored-presentation-style ;
 
 : effect-style ( effect -- style )
-    0 0.2 0 1 <rgba> colored-presentation-style
-    { { font-style plain } } assoc-union ;
+    presented associate stack-effect-style get assoc-union ;