Labels support printing multiple lines of text, but they don't relayout and
word-wrap.

Paragraphs are used by the ui.gadgets.panes for this, and basically the way
they work is you can add any gadget (but in this case a label-per-word) to
them and "word break gadgets" to represent the whitespace, so it word-wraps
properly:

    500 <paragraph> 100 iota
    [ " " <word-break-gadget> add-gadget ]
    [ number>text <label> add-gadget ] interleave

Perhaps we should wrap this logic into a multiline-label that does the word
splitting and word wrapping for you for convenience.





On Fri, Sep 18, 2015 at 5:09 AM, Georg Simon <georg.si...@auge.de> wrote:

> What is the preferred way to write some text to a gadget?
> By trial and error I found this to work :
> -----------------------------------------------------
> IN: scratchpad USING: io.styles ui.gadgets.panes ;
>
> CONSTANT: character-style
> { { font-name "sans-serif" } { font-size 22 } }
> CONSTANT: paragraph-style
> { { wrap-margin 300 } }
>
> <pane>
> "sans-serif minimum space for each letter"
> over <pane-stream>
> [
>     paragraph-style
>     [ character-style [ print ] with-style ]
>     with-nesting
>     ]
> with-output-stream
> gadget.
> -----------------------------------------------------
> Is there a better way?
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to