From bdd47b99919dbf55c946349f0c206cc40d0a75ff Mon Sep 17 00:00:00 2001 From: Keith Lazuka Date: Mon, 28 Sep 2009 08:47:03 -0400 Subject: [PATCH] help.markup: word link stack effect is now clickable --- basis/colors/constants/factor-colors.txt | 1 + basis/help/markup/markup.factor | 42 +++++++++---------- basis/io/styles/styles.factor | 15 +++++-- .../prettyprint/stylesheet/stylesheet.factor | 3 +- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/basis/colors/constants/factor-colors.txt b/basis/colors/constants/factor-colors.txt index b8af9d3949..64a857a2a4 100644 --- a/basis/colors/constants/factor-colors.txt +++ b/basis/colors/constants/factor-colors.txt @@ -4,3 +4,4 @@ 172 167 147 FactorDarkTan 81 91 105 FactorLightSlateBlue 55 62 72 FactorDarkSlateBlue + 0 51 0 FactorDarkGreen diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index 0201e86b3f..2377a6753a 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -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 + +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 ; +PRIVATE> + +: ($link) ( topic -- ) >topic link-text ; : $link ( element -- ) first ($link) ; -: ($long-link) ( topic -- ) - { [ link-text ] [ link-effect ] } (($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 ; diff --git a/basis/io/styles/styles.factor b/basis/io/styles/styles.factor index b141d8d2f7..ae493be849 100644 --- a/basis/io/styles/styles.factor +++ b/basis/io/styles/styles.factor @@ -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 diff --git a/basis/prettyprint/stylesheet/stylesheet.factor b/basis/prettyprint/stylesheet/stylesheet.factor index 580049160d..42a701d60f 100644 --- a/basis/prettyprint/stylesheet/stylesheet.factor +++ b/basis/prettyprint/stylesheet/stylesheet.factor @@ -43,5 +43,4 @@ PRIVATE> dim-color colored-presentation-style ; : effect-style ( effect -- style ) - 0 0.2 0 1 colored-presentation-style - { { font-style plain } } assoc-union ; + presented associate stack-effect-style get assoc-union ;