From ca652dc1573acfbfaeb8244d1cb0791ac6a36516 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 4 Apr 2008 08:44:32 -0500 Subject: [PATCH] Fix UI panes --- core/io/streams/nested/nested.factor | 4 +- core/io/streams/plain/plain.factor | 2 +- extra/ui/gadgets/panes/panes-tests.factor | 73 ++++++++++++++++++++--- extra/ui/gadgets/panes/panes.factor | 2 +- 4 files changed, 71 insertions(+), 10 deletions(-) diff --git a/core/io/streams/nested/nested.factor b/core/io/streams/nested/nested.factor index 2a522d8e36..6b8953f86e 100755 --- a/core/io/streams/nested/nested.factor +++ b/core/io/streams/nested/nested.factor @@ -34,10 +34,12 @@ M: filter-writer stream-write-table stream>> stream-write-table ; M: filter-writer dispose - drop ; + stream>> dispose ; TUPLE: ignore-close-stream < filter-writer ; +M: ignore-close-stream dispose drop ; + C: ignore-close-stream TUPLE: style-stream < filter-writer style ; diff --git a/core/io/streams/plain/plain.factor b/core/io/streams/plain/plain.factor index 8d8a0a8810..47bff681cd 100644 --- a/core/io/streams/plain/plain.factor +++ b/core/io/streams/plain/plain.factor @@ -12,7 +12,7 @@ M: plain-writer stream-format nip stream-write ; M: plain-writer make-span-stream - swap ; + swap ; M: plain-writer make-block-stream nip ; diff --git a/extra/ui/gadgets/panes/panes-tests.factor b/extra/ui/gadgets/panes/panes-tests.factor index e3f6e36050..0263b15d71 100755 --- a/extra/ui/gadgets/panes/panes-tests.factor +++ b/extra/ui/gadgets/panes/panes-tests.factor @@ -1,8 +1,8 @@ IN: ui.gadgets.panes.tests USING: alien ui.gadgets.panes ui.gadgets namespaces -kernel sequences io io.streams.string tools.test prettyprint -definitions help help.syntax help.markup splitting -tools.test.ui models ; +kernel sequences io io.styles io.streams.string tools.test +prettyprint definitions help help.syntax help.markup +help.stylesheet splitting tools.test.ui models math inspector ; : #children "pane" get gadget-children length ; @@ -17,20 +17,79 @@ tools.test.ui models ; [ t ] [ #children "num-children" get = ] unit-test : test-gadget-text - dup make-pane gadget-text - swap with-string-writer "\n" ?tail drop "\n" ?tail drop = ; + dup make-pane gadget-text dup print "======" print + swap with-string-writer dup print "\n" ?tail drop "\n" ?tail drop = ; [ t ] [ [ "hello" write ] test-gadget-text ] unit-test [ t ] [ [ "hello" pprint ] test-gadget-text ] unit-test +[ t ] [ + [ + H{ { wrap-margin 100 } } [ "hello" pprint ] with-nesting + ] test-gadget-text +] unit-test +[ t ] [ + [ + H{ { wrap-margin 100 } } [ + H{ } [ + "hello" pprint + ] with-style + ] with-nesting + ] test-gadget-text +] unit-test [ t ] [ [ [ 1 2 3 ] pprint ] test-gadget-text ] unit-test +[ t ] [ [ \ + describe ] test-gadget-text ] unit-test [ t ] [ [ \ = see ] test-gadget-text ] unit-test [ t ] [ [ \ = help ] test-gadget-text ] unit-test -ARTICLE: "test-article" "This is a test article" +[ t ] [ + [ + title-style get [ + "Hello world" write + ] with-style + ] test-gadget-text +] unit-test + + +[ t ] [ + [ + title-style get [ + "Hello world" write + ] with-nesting + ] test-gadget-text +] unit-test + +[ t ] [ + [ + title-style get [ + title-style get [ + "Hello world" write + ] with-nesting + ] with-style + ] test-gadget-text +] unit-test + +[ t ] [ + [ + title-style get [ + title-style get [ + [ "Hello world" write ] ($block) + ] with-nesting + ] with-style + ] test-gadget-text +] unit-test + +ARTICLE: "test-article-1" "This is a test article" +"Hello world, how are you today." ; + +[ t ] [ [ "test-article-1" $title ] test-gadget-text ] unit-test + +[ t ] [ [ "test-article-1" help ] test-gadget-text ] unit-test + +ARTICLE: "test-article-2" "This is a test article" "Hello world, how are you today." { $table { "a" "b" } { "c" "d" } } ; -[ t ] [ [ "test-article" help ] test-gadget-text ] unit-test +[ t ] [ [ "test-article-2" help ] test-gadget-text ] unit-test [ \ = see ] with-pane [ \ = help ] with-pane diff --git a/extra/ui/gadgets/panes/panes.factor b/extra/ui/gadgets/panes/panes.factor index 94ff427961..fedacbd2af 100755 --- a/extra/ui/gadgets/panes/panes.factor +++ b/extra/ui/gadgets/panes/panes.factor @@ -166,7 +166,7 @@ M: pane-stream dispose drop ; M: pane-stream stream-flush drop ; M: pane-stream make-span-stream - swap ; + swap ; ! Character styles