Problem of wraping in layout
[1/10] from: info::id-net::ch at: 12-Jan-2002 16:38
I designed an application in rebol but i got the problem
of having text that is wraped when its approched the border of the layout.
I thought that with the code "space 0x0" that problem will end, but...
What is the solution of this problem ?
Philippe
[2/10] from: brett:codeconscious at: 13-Jan-2002 10:13
Hi Philippe,
> I designed an application in rebol but i got the problem
> of having text that is wraped when its approched the border of the layout.
I'm not sure if this will help but you can display text
with line-breaks using "as-is". This shows the difference:
example-text: {Here is some text.
It is made up of three lines.
This is the last line.}
view layout [
text as-is example-text
text example-text
]
Making this example, I've learnt something myself - AS-IS stops the TRIM
function from being applied to your string. That is, if you do not use as-is
your string will be modified. Try this after you have run the example above:
probe example-text
This demonstrates the issue another way. Here I swapped the order of when
as-is used:
example-text: {Here is some text.
It is made up of three lines.
This is the last line.}
view layout [
text example-text
text as-is example-text
]
Philippe, make a small example of your problem if this post has not helped.
Small focussed code snippets are a good way to discuss an issue.
Cheers,
Brett.
[3/10] from: info:id-net:ch at: 14-Jan-2002 10:03
Here's the example
The "hello world" is wrapped because of the 20x20 margin. All the space 0x0
and offset to 0x0 can't resolve the problem.
rebol []
win: [space 0x0
at 0x50 text "hello" across
screen-left: box 212.212.212 300x400
screen-right: box 212.212.212 300x400
at 760x200 text as-is "Hello world!"
]
lt-left: [
backdrop: 212.212.212
space 0x0
box 212.212.212 300x400]
lt-right: [
backdrop: 212.212.212
space 0x0
box 212.212.212 300x400
at 230x20 text font-size 20 "Philippe"]
lt-left-lt: layout/offset lt-left 0x0
lt-right-lt: layout/offset lt-right 0x0
win: layout/offset/size win 0x0 800x600
screen-left/pane: lt-left-lt
screen-right/pane: lt-right-lt
view win
[4/10] from: brett:codeconscious at: 14-Jan-2002 23:12
Hm...
Well I've focussed Philippe's issue down to this code:
system/view/vid/verbose: true
spec: copy [origin 0x0 space 0x0]
repeat i 5 [
append spec compose [
at (probe to-pair reduce [645 + i 20 * i])
text "Hello world!"
]
]
win: layout/offset/size spec 0x0 800x600
view win
Notice how the text sizing suddenly goes haywire.
As far as I can tell, the text style tries to determine if it will fit
inside the pane that it is being placed in. The problem is it makes this
determination by considering only 90% (less offset and paragraph margin) of
theavailable pane size. You can see the 90% ratio by using this code:
print mold get in get-style 'text 'init
All I can guess is that someone had a problem with text layout and text
sizing...
Any thoughts or a message to feedback?
So a workaround is to initally position the text nowhere near the right had
side - and then to move it to the correct position afterwards like this:
spec: copy [
origin 0x0 space 0x0
t: text "Hello world!"
do [t/offset: 729x200]
]
win: layout/offset/size spec 0x0 800x600
HTH
Brett.
[5/10] from: rotenca:telvia:it at: 14-Jan-2002 14:35
Hi Brett and Philippe
> Well I've focussed Philippe's issue down to this code:
> system/view/vid/verbose: true
<<quoted lines omitted: 7>>
> win: layout/offset/size spec 0x0 800x600
> view win
Try with
text no-wrap "Hello world!"
---
Ciao
Romano
[6/10] from: greggirwin:mindspring at: 14-Jan-2002 13:13
Hi Philippe,
ORIGIN is what you're after, but it doesn't seem to do what you want when
you specify the /size refinement for VIEW. If you specify the width for your
TEXT item, you can override the wrapping.
--Gregg
[7/10] from: brett:codeconscious at: 15-Jan-2002 8:10
Hi Romano,
You're solution is somewhat more to the point than mine :)
I could have saved myself a lot of time...
Thanks!
Brett.
[8/10] from: g:santilli:tiscalinet:it at: 14-Jan-2002 22:32
Hello Brett!
On 14-Gen-02, you wrote:
BH> Notice how the text sizing suddenly goes haywire.
That's because VID tries to keep the text inside the screen (i.e.
if you don't provide a size, it wraps the text as soon as it comes
close to the right of the screen, approximately).
BH> So a workaround is to initally position the text nowhere near
BH> the right had side - and then to move it to the correct
BH> position afterwards like this:
Or, simply provide a size for it:
t: text 400 "Hello world"
Regards,
Gabriele.
--
Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer
Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/
[9/10] from: info:id-net:ch at: 14-Jan-2002 23:09
Thanks to all for the problem of wrapping. The 'width solution and the
no-wrap
are good.
The first solution of Brett is a little bit too complicated for me. I'm just
a 2 months beginner in Rebol, but i
already wrote an application of 92k.
How can I explore more about all the system/pane and other stuff like that ?
Philippe
[10/10] from: info:id-net:ch at: 15-Jan-2002 15:25
I combined the size of the text with the no-wrap solution to
provide a good solution when you want to limit a size of a text without
wrap.
For example :
text 80 no-wrap "Hello world"
If you type text 80 "Hello world!", and if the text exceed that 80' size,
the text beyond 80 will be wrapped to the second line.
If you type no-wrap, all your text will be screened.
But with text 80 no-wrap. The text won't be wrapped and will not exceed 80.
It's very useful for long "First Name" or "Second Name" for example, that
must be displayed within a limit.
Philippe Oehler
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted