Fix some style nesting issues

darcs
slava 2006-06-17 19:59:44 +00:00
parent a5cc32ed15
commit 26e6ac7477
7 changed files with 20 additions and 15 deletions

View File

@ -8,7 +8,6 @@
+ help: + help:
- double 'presented' for the block & char style
- refactor style stack code so that nested styles are handled at a lower-level - refactor style stack code so that nested styles are handled at a lower-level
- with-style & with-stream-style - with-style & with-stream-style
- in HTML, we can nest div tags, etc - in HTML, we can nest div tags, etc

View File

@ -19,8 +19,8 @@ M: word article-content
] { } make ; ] { } make ;
: with-default-style ( quot -- ) : with-default-style ( quot -- )
default-char-style [ default-style [
default-para-style [ last-block on call ] with-nesting H{ } [ last-block on call ] with-nesting
] with-style ; inline ] with-style ; inline
: print-title ( article -- ) : print-title ( article -- )

View File

@ -144,7 +144,7 @@ M: link summary "Link: " swap link-name append ;
"Notes" $heading print-element ; "Notes" $heading print-element ;
: $see ( content -- ) : $see ( content -- )
code-style [ dup array? [ first ] when see ] with-nesting ; code-style [ H{ } [ first see ] with-nesting ] with-style ;
: $definition ( content -- ) : $definition ( content -- )
"Definition" $heading $see ; "Definition" $heading $see ;

View File

@ -3,14 +3,10 @@
IN: help IN: help
USING: styles ; USING: styles ;
: default-char-style : default-style
H{ H{
{ font "serif" } { font "serif" }
{ font-size 12 } { font-size 12 }
} ;
: default-para-style
H{
{ wrap-margin 500 } { wrap-margin 500 }
} ; } ;

View File

@ -30,8 +30,10 @@ M: nested-style-stream stream-write1
>r ch>string r> H{ } swap do-nested-style stream-format ; >r ch>string r> H{ } swap do-nested-style stream-format ;
: do-nested-quot ( quot style stream -- quot style stream ) : do-nested-quot ( quot style stream -- quot style stream )
do-nested-style tuck >r >r
>r [ swap \ with-style 3array >quotation ] keep r> ; nested-style-stream-style swap \ with-style
3array >quotation
r> r> do-nested-style ;
M: nested-style-stream with-nested-stream M: nested-style-stream with-nested-stream
do-nested-quot with-nested-stream ; do-nested-quot with-nested-stream ;

View File

@ -57,8 +57,8 @@ HELP: with-nesting "( style quot -- )"
{ $notes "Details are in the documentation for " { $link stream-format } "." } { $notes "Details are in the documentation for " { $link stream-format } "." }
$io-error ; $io-error ;
HELP: print "( style quot -- )" HELP: print "( style -- )"
{ $values { "style" "a hashtable" } { "quot" "a quotation" } } { $values { "style" "a hashtable" } }
{ $description "Writes a newline-terminated string to the " { $link stdio } " stream." } { $description "Writes a newline-terminated string to the " { $link stdio } " stream." }
$io-error ; $io-error ;

View File

@ -1,8 +1,6 @@
IN: temporary IN: temporary
USING: io kernel math namespaces styles test ; USING: io kernel math namespaces styles test ;
! Make sure everything here works...
[ ">> + <<" ] [ [ ">> + <<" ] [
[ [
[ [
@ -12,3 +10,13 @@ USING: io kernel math namespaces styles test ;
] string-out ] string-out
] with-scope ] with-scope
] unit-test ] unit-test
[ "+" ] [
[
[
H{ } [
H{ { highlight t } } [ "+" write ] with-nesting
] with-style
] string-out
] with-scope
] unit-test