text-list faces
[1/5] from: carl::cybercraft::co::nz at: 11-May-2004 11:18
What's the path to the faces of the text in a text-list? I assume they're a block of
faces somewhere in the text-list object?
Thanks,
-- Carl Read
[2/5] from: didec:tiscali at: 12-May-2004 0:10
> What's the path to the faces of the text in a text-list? I assume they're a block
of faces somewhere in the text-list object?
>
No, sorry, there is no block of face in a text-list.
The text-list is one type of face called iterated-face : there is only one subface.
The pane is not a face or a block, but a function that is called to display each data
with the subface.
the secret of text-list is in its 'init block and its 'text-pane function.
So to modify the text, just change the data in the block of texts (face/data).
> Thanks,
>
> -- Carl Read
>
Bye
DideC
[3/5] from: carl:cybercraft at: 12-May-2004 20:02
>> What's the path to the faces of the text in a text-list? I assume they're
>a block of faces somewhere in the text-list object?
<<quoted lines omitted: 5>>
>each data with the subface.
>the secret of text-list is in its 'init block and its 'text-pane function.
Ah - finally! Never noticed text-pane before. (Which is most strange...) What I was
wanting to do was to have different colored lines of text. Can now...
view layout [
t: text-list "aaa" "bbb" "ccc"
button "Change" [
repeat line 3 [
face: t/text-pane t/iter line
insert face/text join line " "
face/font/color: pick reduce [red green blue] line
show face
]
]
]
Many thanks.
-- Carl Read
[4/5] from: didec:tiscali at: 12-May-2004 11:13
[...]
> Ah - finally! Never noticed text-pane before. (Which is most strange...) What I
was wanting to do was to have different colored lines of text. Can now...
> view layout [
<<quoted lines omitted: 8>>
> ]
> ]
Not a perfect solution, because as soon as you click a line, all lines are redisplayed
with the last color.
It can be done by changing the text-pane func itself to let it change the font color
or something else. Just take care of that : text-pane must return the iter face or none
:
view layout [
t: text-list "aaa" "bbb" "ccc" with [
text-pane: func [face id][
if pair? id [return 1 + second id / iter/size]
iter/offset: iter/old-offset: id - 1 * iter/size * 0x1
if iter/offset/y + iter/size/y > size/y [return none]
cnt: id: id + sn
;***** HERE IS THE ADDON : ALTERNATE COLOR EVEN/ODD
iter/font/color: pick [255.0.0 0.0.255] odd? id
;**** END
if iter/text: pick data id [
lines: at data id
iter
]
]
]
]
> Many thanks.
>
> -- Carl Read
>
DideC
[5/5] from: carl:cybercraft at: 13-May-2004 10:49
>Not a perfect solution, because as soon as you click a line, all lines are
>redisplayed with the last color.
As I found out...
>It can be done by changing the text-pane func itself to let it change the
>font color or something else. Just take care of that : text-pane must return
<<quoted lines omitted: 16>>
> ]
>]
Yes - much better. Though if you're deciding on the color based on iter/text at that
point, it gets it a line out. Moving it to the following if block gets it right though.
ie...
view layout [
t: text-list "aaa" "bbb" "ccc" with [
text-pane: func [face id][
if pair? id [return 1 + second id / iter/size]
iter/offset: iter/old-offset: id - 1 * iter/size * 0x1
if iter/offset/y + iter/size/y > size/y [return none]
cnt: id: id + sn
if iter/text: pick data id [
;**** EXTRA CODE
iter/font/color: either iter/text = "bbb" [255.0.0][0.0.255]
;****
lines: at data id
iter
]
]
]
]
Thanks once again,
-- Carl Read
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted