On 6 April 2016 at 21:49, Henrik Nergaard <[email protected]> wrote:

> The only thing required for styling is to specify the attributes for the
> runs associated with the text.
>
> A simple example:
>
>
>
> | text attributes oldRuns clr|
>
>
>
> text := (String loremIpsum: 1234) asText.
>
>
>
> attributes := Array new: text size.
>
>
>
> clr := TextColor color: Color random.
>
>
>
> 1 to: text size do: [ :index |
>
>                attributes at: index put: {
>
>                               clr.
>
>                               TextFontChange font2
>
>                }.
>
>
>
>                (text at: index) isSeparator ifTrue: [ clr := TextColor
> color: Color random ]
>
> ].
>
>
>
> text runs: (RunArray newFrom: attributes).
>
>
>
> text
>
>
>

Same for TxText:

| text selection |
text :=  (String loremIpsum: 1234) asTxModel.

selection := text newSelection.
"set font to whole text"
selection applyAttribute: (TxFontAttribute with: MyFont).

selection end moveToStart.
[ selection end isAtEnd ] whileFalse: [

selection end moveDown.

selection applyAttribute: (TxForeColorAttribute with: Color random).

selection start: selection end.
].

text editInWindow



>
> Best regards,
>
> Henrik
>
>
>
> *From:* Pharo-dev [mailto:[email protected]] *On Behalf
> Of *Nicolai Hess
> *Sent:* Wednesday, April 6, 2016 8:23 PM
> *To:* Pharo Development List <[email protected]>
> *Subject:* Re: [Pharo-dev] TxText model
>
>
>
>
>
>
>
> 2016-04-06 18:11 GMT+02:00 [email protected] <[email protected]>:
>
> Ok. Call me stupid but in Pharo I don't see how to do that easily.
>
>
>
> Phil
>
>
>
> At least for Rubric, it can not be that difficult. I saw a GT-Inspector
> with a XML-styer
>
>
>
>
>
> On Wed, Apr 6, 2016 at 5:41 PM, Stephan Eggermont <[email protected]>
> wrote:
>
> On 06-04-16 11:13, [email protected] wrote:
>
> Another pain is the styling of text where the only styler we have is the
> SHSt80Styler (class name out of my mind, need to check) and that's a huge
> pain to support other stylings.
>
>
> Styling with different stylers worked in TextMorph. In Squeak it is easy
> to add styling for a different language in the class browser. Levente did
> that for PostgreSQLv3.
>
> Stephan
>
>
>
>
>



-- 
Best regards,
Igor Stasenko.

Reply via email to