2019-10-18 09:05:06 -04:00
|
|
|
! Copyright (C) 2006, 2007 Slava Pestov.
|
2006-06-14 01:47:28 -04:00
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
|
IN: io
|
2019-10-18 09:05:08 -04:00
|
|
|
USING: arrays generic assocs kernel namespaces strings
|
|
|
|
|
quotations ;
|
2006-06-14 01:47:28 -04:00
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
TUPLE: style-stream style ;
|
2006-06-14 02:16:53 -04:00
|
|
|
|
2006-06-14 01:47:28 -04:00
|
|
|
: do-nested-style ( style stream -- style delegate )
|
2019-10-18 09:05:08 -04:00
|
|
|
[ style-stream-style swap union ] keep
|
2006-06-16 23:12:40 -04:00
|
|
|
delegate ;
|
2006-06-14 01:47:28 -04:00
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
: collapse-nested-style ( style stream -- style steam )
|
|
|
|
|
dup style-stream? [ do-nested-style ] when ;
|
|
|
|
|
|
|
|
|
|
: (with-stream-style) ( quot style stream -- )
|
|
|
|
|
collapse-nested-style <style-stream> swap with-stream* ;
|
|
|
|
|
inline
|
|
|
|
|
|
|
|
|
|
C: style-stream ( style delegate -- stream )
|
2006-06-14 01:47:28 -04:00
|
|
|
[ set-delegate ] keep
|
2019-10-18 09:05:06 -04:00
|
|
|
[ set-style-stream-style ] keep ;
|
2006-06-14 01:47:28 -04:00
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
M: style-stream stream-format
|
2006-06-14 01:47:28 -04:00
|
|
|
do-nested-style stream-format ;
|
|
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
M: style-stream stream-write
|
|
|
|
|
H{ } swap stream-format ;
|
2006-06-14 01:47:28 -04:00
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
M: style-stream stream-write1
|
|
|
|
|
>r 1string H{ } r> stream-format ;
|
|
|
|
|
|
|
|
|
|
M: style-stream with-stream-style
|
|
|
|
|
do-nested-style with-stream-style ;
|
2006-06-14 01:47:28 -04:00
|
|
|
|
2006-06-14 02:16:53 -04:00
|
|
|
: do-nested-quot ( quot style stream -- quot style stream )
|
2006-06-17 15:59:44 -04:00
|
|
|
tuck >r >r
|
2019-10-18 09:05:06 -04:00
|
|
|
style-stream-style swap \ with-style
|
2006-06-17 15:59:44 -04:00
|
|
|
3array >quotation
|
|
|
|
|
r> r> do-nested-style ;
|
2006-06-14 02:16:53 -04:00
|
|
|
|
2019-10-18 09:05:06 -04:00
|
|
|
M: style-stream with-nested-stream
|
2006-06-14 02:16:53 -04:00
|
|
|
do-nested-quot with-nested-stream ;
|
2006-06-14 01:47:28 -04:00
|
|
|
|
2019-10-18 09:05:08 -04:00
|
|
|
M: style-stream make-table-cell
|
|
|
|
|
do-nested-quot make-table-cell ;
|