diff --git a/TODO.FACTOR.txt b/TODO.FACTOR.txt index eba67129a5..8c1a439ff7 100644 --- a/TODO.FACTOR.txt +++ b/TODO.FACTOR.txt @@ -5,6 +5,8 @@ + httpd: - outliners don't work - browser responder doesn't work + - fix remaining HTML stream issues + - update for file style prop becoming presented - fix this: @@ -28,13 +30,10 @@ - constant branch folding - cocoa: starting the UI with +foo switches opens them as files + refactor style stack code so that nested styles are handled at a lower-level - - in HTML, we can nest div tags, etc - - fix prettyprinter's highlighting of non-leaves looks bad - - maybe even go from markup to HTML? - - fix remaining HTML stream issues - - need to present $list in a useful way + - with-style & with-stream-style + - in HTML, we can nest div tags, etc + - prettyprinter's highlighting of non-leaves looks bad - better line spacing in ui and html - related issue - - get rid of style stack + fix compiled gc check - there was a performance hit, investigate diff --git a/library/io/files.factor b/library/io/files.factor index 3926f3ac49..782f7bacba 100644 --- a/library/io/files.factor +++ b/library/io/files.factor @@ -29,15 +29,15 @@ strings styles ; : ( path -- stream ) resource-path ; -TUPLE: file path ; +TUPLE: pathname string ; : (file.) ( name path -- ) - file associate format ; + write-object ; DEFER: directory. : (directory.) ( name path -- ) - >r "/" append r> dup swap [ directory. ] curry + >r "/" append r> dup swap [ directory. ] curry write-outliner terpri ; : file. ( dir name -- ) diff --git a/library/io/nested-style.factor b/library/io/nested-style.factor index d09dd3c991..b54608ea52 100644 --- a/library/io/nested-style.factor +++ b/library/io/nested-style.factor @@ -1,10 +1,13 @@ ! Copyright (C) 2006 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. IN: io -USING: generic hashtables kernel namespaces strings ; +USING: arrays generic hashtables kernel namespaces strings ; TUPLE: nested-style-stream style ; +: with-style ( style quot -- ) + >r stdio get r> with-stream* ; inline + : do-nested-style ( style stream -- style delegate ) [ nested-style-stream-style hash-union ] keep delegate ; @@ -25,11 +28,12 @@ M: nested-style-stream stream-write M: nested-style-stream stream-write1 >r ch>string r> H{ } swap do-nested-style stream-format ; +: do-nested-quot ( quot style stream -- quot style stream ) + do-nested-style + >r [ swap \ with-style 3array >quotation ] keep r> ; + M: nested-style-stream with-nested-stream - do-nested-style with-nested-stream ; + do-nested-quot with-nested-stream ; M: nested-style-stream with-stream-table - do-nested-style with-stream-table ; - -: with-style ( style quot -- ) - >r stdio get r> with-stream* ; inline + do-nested-quot with-stream-table ; diff --git a/library/io/stream.factor b/library/io/stream.factor index 0009dbf5aa..b45b29cb99 100644 --- a/library/io/stream.factor +++ b/library/io/stream.factor @@ -15,7 +15,7 @@ GENERIC: stream-flush ( stream -- ) GENERIC: stream-terpri ( stream -- ) GENERIC: stream-format ( string style stream -- ) GENERIC: with-nested-stream ( quot style stream -- ) -GENERIC: with-stream-table ( quot grid style stream -- ) +GENERIC: with-stream-table ( grid quot style stream -- ) : stream-print ( string stream -- ) [ stream-write ] keep stream-terpri ; diff --git a/library/io/string-streams.factor b/library/io/string-streams.factor index f1b9b1cd9d..a5218e586a 100644 --- a/library/io/string-streams.factor +++ b/library/io/string-streams.factor @@ -26,11 +26,14 @@ M: sbuf stream-flush drop ; swap dup length [ zero? rot [ call ] keep swap ] 2map nip ; inline -M: plain-writer with-stream-table ( quot grid style stream -- ) - nip -rot [ [ swap string-out ] map-with ] map-with - flip [ format-column ] map-last - flip [ " " join ] map - [ swap stream-print ] each-with ; +M: plain-writer with-stream-table ( grid quot style stream -- ) + [ + nip swap + [ [ swap string-out ] map-with ] map-with + flip [ format-column ] map-last + flip [ " " join ] map + [ print ] each + ] with-stream* ; ! Reversed string buffers support the stream input protocol. M: sbuf stream-read1 ( sbuf -- char/f ) diff --git a/library/test/io/nested-style.factor b/library/test/io/nested-style.factor new file mode 100644 index 0000000000..e3f4bdfe00 --- /dev/null +++ b/library/test/io/nested-style.factor @@ -0,0 +1,14 @@ +IN: temporary +USING: io kernel math namespaces styles test ; + +! Make sure everything here works... + +[ ">> + <<" ] [ + [ + [ + H{ { highlight t } } [ + H{ } [ "+" write ] with-nesting + ] with-style + ] string-out + ] with-scope +] unit-test diff --git a/library/test/test.factor b/library/test/test.factor index 7fef108654..ffbfac4e0d 100644 --- a/library/test/test.factor +++ b/library/test/test.factor @@ -74,7 +74,7 @@ SYMBOL: failures "collections/strings" "collections/namespaces" "collections/vectors" "collections/sequences" "collections/queues" "generic" "tuple" "parser" - "parse-number" "init" "io/io" + "parse-number" "init" "io/io" "io/nested-style" "words" "prettyprint" "random" "stream" "math/bitops" "math/math-combinators" "math/rational" "math/float" "math/complex" "math/irrational" diff --git a/library/ui/gadgets/presentations.factor b/library/ui/gadgets/presentations.factor index c9e20023a5..297bb89c1b 100644 --- a/library/ui/gadgets/presentations.factor +++ b/library/ui/gadgets/presentations.factor @@ -94,8 +94,8 @@ M: object-button gadget-help ( button -- string ) [ pick pick >r >r -rot styled-pane r> r> rot ] map ] map 2nip 5 over set-grid-gap ; -M: pane with-stream-table ( quot grid style pane -- ) - >r swap r> print-gadget ; +M: pane with-stream-table ( grid quot style pane -- ) + >r rot r> print-gadget ; M: pane with-nested-stream ( quot style stream -- ) >r styled-pane r> write-gadget ;