[REBOL] Re: Text-view question - part II
From: gjones05:mail:orion at: 9-May-2001 7:26
From: "Júlio César Santana"
> Hi,
>
> I'm sorry, think I need to clarify my question! I can call the
text-view.r
> using tho "do" function or even include that piece of code into my
script
> and changing it a little bit to become a new layout definition, just
like:
> lo: layout [
> h2 "Text File Viewer..."
> ...
> f1: field ; file name
> ...
> the code in the text-view.r
> ]
>
> But, I' m trying to call that piece of the code with the following:
>
> f1/text: %test.r
> view lo
>
> The layout shows up but only the f1 field is correctly filled, the
other
> faces (area, size, date) are still empty! Shouldn't they have been
filled too?
> I hope my question have been better explained.
> TIA,
>
> Julio Cesar
Hi, Julio,
Now I see what you mean. And thanks to Graham for pointing out where the
text-viewer.r code is located. I modified the code to do what I think
you want.
REBOL []
size: 0x0
fix-slider: func [faces [object! block!]] [
foreach list to-block faces [
list/sld/redrag list/lc / max 1 length? head list/lines
]
]
get-file: func [a-file] [
a-file: to-file a-file
if all [not dir? a-file file? a-file] [
t0/text: a-file show t0
t1/text: sz: size? a-file show t1
t2/text: modified? a-file show t2
t3/para/origin: 4x4
t3/lines: copy []
t3/lines: either sz [read/lines a-file][none]
fix-slider t3
show t3
size: size-text t3
]
]
lo: layout [
h2 "Text File Viewer..."
box 656x4 effect [gradient 1x0 200.0.0]
across space 6
style txt text 40x24 font [valign: 'center]
txt bold "File:" t0: text 300x24
txt bold "Size:" t1: txt 60
txt bold "Date:" t2: txt 160
return space 0
t3: text-list 640x480 with [color: 0.0.200]
]
get-file %user.r
view lo
Hope this helps.
--Scott Jones