From 903a6fbbc53bdda0a6dae9ede44cb0cfb4ac1850 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 26 Mar 2009 21:28:09 -0500 Subject: [PATCH] help.tips: use write-object to write heading so that right-clicking on "Tip of the day" and picking Edit works --- basis/help/tips/tips.factor | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/basis/help/tips/tips.factor b/basis/help/tips/tips.factor index 311ab46a20..4685b6c517 100644 --- a/basis/help/tips/tips.factor +++ b/basis/help/tips/tips.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2009 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: parser arrays namespaces sequences random help.markup kernel io -io.styles colors.constants definitions accessors ; +USING: parser arrays namespaces sequences random help.markup help.stylesheet +kernel io io.styles colors.constants definitions accessors ; IN: help.tips SYMBOL: tips @@ -24,7 +24,7 @@ SYNTAX: TIP: parse-definition >array [ save-location ] [ add-tip ] bi ; -: a-tip ( -- tip ) tips get random content>> ; +: a-tip ( -- tip ) tips get random ; SYMBOL: tip-of-the-day-style @@ -34,13 +34,20 @@ H{ { wrap-margin 500 } } tip-of-the-day-style set-global +: $tip-title ( tip -- ) + [ + heading-style get [ + [ "Tip of the day" ] dip write-object + ] with-style + ] ($block) ; + : $tip-of-the-day ( element -- ) drop [ tip-of-the-day-style get [ last-element off - "Tip of the day" $heading a-tip print-element nl + a-tip [ $tip-title ] [ content>> print-element nl ] bi "— " print-element "all-tips-of-the-day" ($link) ] with-nesting @@ -49,4 +56,6 @@ H{ : tip-of-the-day. ( -- ) { $tip-of-the-day } print-content nl ; : $tips-of-the-day ( element -- ) - drop tips get [ nl nl ] [ content>> print-element ] interleave ; \ No newline at end of file + drop tips get [ nl nl ] [ content>> print-element ] interleave ; + +INSTANCE: tip definition \ No newline at end of file