RE: Justify text in a field

2005-07-28 Thread MisterX
Al

> I agree, but the ideal could be to use
> unicode fonts, that have many spaces of different width. :-D
> 
> 
> 
> 

I didn't know that! Just learned something!

Here's my old monospace script, im sure you can adjust it for modern times
;)
Please share your improvements to it ;)

Im working on a special editor and this could make it in after all...

cheers
Xavier

on mouseUp
  put cd fld "linewidth" into lineWidth
  put cd fld "Lmargin" into Lmargin
  put cd fld "Rmargin" into Rmargin
  put cd fld "Indent" into Indent
  put hilite of cd btn "full justification" into fulljustification
  
  if indent<0 then
put Stringfill("L", Lmargin+indent ) into L
  else put Stringfill("L", Lmargin ) into L
  put Stringfill("R", Rmargin ) into R
  put Stringfill("I", abs(indent)  ) into I
  put Stringfill("-", linewidth-(Lmargin+Rmargin)-indent ) into P
  
  -- LIPR for left right indent and paragraph start
  get L & I & P & R
  put L & I & P & R into cd fld "Ruler"
  
  put setmonospacestyle(cd fld "input",selectedtext of cd btn
"alignment",lineWidth,\
  Lmargin, Rmargin, Indent,fulljustification) into cd fld "output"
  -- text you want to limitlength
end mouseUp

function setmonospacestyle
thetext,alignment,Paraglinewidth,LMargin,RMargin,Indent,fulljustification
  
  put Paraglinewidth - (LMargin + RMargin) into linewidth
  
  if LMargin<>0
  then put StringFill(" ",LMargin) into LMargintxt
  else put "" into LMargintxt
  
  if LMargin<>0
  then put StringFill(" ",RMargin) into RMargintxt
  else put "" into RMargintxt
  
  if indent>0
  then put StringFill(" ",indent) into indenttxt
  else put "" into indenttxt
  
  put 0 into thislinelen
  put "" into thisline
  put "" into output
  
  repeat with y = 1 to the number of lines in thetext
put line y of thetext into theline

put theline <> "" into isindented
if isindented then put indenttxt before thisline
put the number of words in theline into thelinewordcount
repeat with x = 1 to thelinewordcount
  
  set cursor to busy
  
  put word x of theline into thisword
  put the length of thisword into thiswordlen
  
  if (isindented and (thislinelen+thiswordlen+1 - indent) > linewidth)
or\
  (thislinelen+thiswordlen+1) > linewidth then

if char 1 of thisline = " " then delete char 1 of thisline

if isindented and indent<0 and LMargin>abs(indent)
then put StringFill(" ",LMargin+indent) before thisline
else if LMargin>0 then put LMarginTxt before thisline

if RMargin>0 then put RMarginTxt after thisline


if the number of words in thisline > 0 then
  if  alignment = "Center"  then
put AlignCenterTxtString(thisline,lineWidth) into thisline

  else if alignment = "Right"   then

put AlignRightTxtString(thisline,lineWidth) into thisline

  else if alignment = "Justify" then

if x < thelinewordcount
then put AlignJustifyTxtString(thisline,lineWidth) into thisline

  end if
end if

put return & thisline after output
put thisword into thisline
put thiswordlen into thislinelen
put false into isindented

  else

if thisline="" then
  put thisword into thisline
else put " " & thisword after thisline
put length(thisline) into thislinelen
--add thiswordlen+1 to thislinelen

  end if
end repeat

if char 1 of thisline = " " then delete char 1 of thisline

if isindented and indent<0 and LMargin>abs(indent)
then put StringFill(" ",LMargin+indent) before thisline
else if LMargin>0 then put LMarginTxt before thisline
-- if indent<0 and LMargin>indent
-- then put StringFill(" ",LMargin+indent) before thisline
-- else if LMargin>0 then put LMarginTxt before thisline
if RMargin>0 then put RMarginTxt after thisline

if the number of words in thisline > 0 then
  
  if  alignment = "Center"  then
put AlignCenterTxtString(thisline,lineWidth) into thisline

  else if alignment = "Right"   then

put AlignRightTxtString(thisline,lineWidth) into thisline

-- you don't justify last line of paragraph unless fullJustified
  else if alignment = "Justify" and fulljustification then
put AlignJustifyTxtString(thisline,lineWidth) into thisline

  end if
end if

put return & thisline after output
put "" into thisline
put 0 into thislinelen

  end repeat
  
  delete char 1 of output
  return output
  
end setmonospacestyle


function StringFill what,anum
  if anum=0 then return ""
  put "" into out
  repeat with x = 1 to anu

RE: Justify text in a field

2005-07-28 Thread Alejandro Tejada
on Thu, 28 Jul 2005 
Jonathan Lynch wrote:

> As long as a field is wide enough, and a given
> screen line contains
> enough words, manipulating expanded and condensed
> characters should make
> this possible - sounds kind of difficult to me.

Yes, That's what i thought. :-(

on Thu, 28 Jul 2005 
xavier wrote:

> Actually IT IS POSSIBLE!!!
> Jonathan flipped my mind switch back in gear ;)
> Give a field's width w and the formattedwidth of the
> text in line l...
> you might have to add each word's formattedwith (and
> get pissed off
> at the definition of a word in rev) - then divide
> the difference by 
> the number of words in the line and then insert
> "tiny" spaces in between
> the words... This should do the trick...

I agree, but the ideal could be to use
unicode fonts, that have many spaces of 
different width. :-D





Visit my site:
http://www.geocities.com/capellan2000/




Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Justify text in a field - THE SOLUTION!!!

2005-07-28 Thread MisterX
Actually IT IS POSSIBLE!!!

Jonathan flipped my mind switch back in gear ;)

Give a field's width w and the formattedwidth of the text in line l...
you might have to add each word's formattedwith (and get pissed off
at the definition of a word in rev) - then divide the difference by 
the number of words in the line and then insert "tiny" spaces in between
the words... This should do the trick...

By tiny spaces, i mean that they have to be small enough to
fit the line without over flowing it. so reducing their size 
should help... you can't simulate kerning or letter width scaling
but you can simulate variable word spacing...

hope that helps...
Xavier
http://monsieurx.com

 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Lynch, Jonathan
> Sent: Thursday, July 28, 2005 15:43
> To: How to use Revolution
> Subject: RE: Justify text in a field
> 
> 
> >Do you mean the formattedrect of a single line?
> 
> 
> Certainly - You can do formattedrect for any chunk of a 
> field, be it lines, characters, words, etc...
> 
> >if i remember well, Colin inserted spaces between words, and set the 
> >styles of words to extended and condensed, but i could not find his 
> >code now. :-(
> 
> This sounds like it would be designed not for centering, but 
> for having the line spread out evenly from right to left (I 
> forget what that is called). Is that what you need? The 
> calculations would be a bit more complex, but still quite doable.
> 
> >In scrolling fields this could take a while.
> >Did you had some timings available for this technique? In this way i 
> >could know beforehand if it is user's friendly.
> 
> Ah - you are not just talking about centering a single line, 
> you are talking about having all lines spread out evenly. The 
> would get a bit tricky. Once you did this, you would not 
> really be able to properly type in that field, without it 
> doing weird stuff.
>  
> >This idea is fine and very precise,
> >but what will happen if you had to
> >copy and paste this text elsewhere.
> 
> If you pasted it into another field in Rev, with the same 
> settings and dimensions, it should work fine. However, pasted 
> somewhere else that was not in Rev, or in a Rev field with 
> different settings, it would be a mess.
> 
> >You'll be carrying a lot of empty space with the copied text, unless 
> >you perform some cleaning up in copied text. :-(
> 
> I think perhaps I was confused by what you mean by the word 
> 'Justify' - I think of that as a word to go with left, right, 
> and center justification. I just looked it up, and the evenly 
> spread out type is called 'double justification'. In html, 
> you would do something like:
> blah blah blah to give it double 
> justification.
> 
> I think, for what it sounds like you are doing, you really 
> need something like that. Unfortunately, Rev doesn't give 
> that option - yet.
> 
> As long as a field is wide enough, and a given screen line 
> contains enough words, manipulating expanded and condensed 
> characters should make this possible - sounds kind of difficult to me.
>   
> 
> Start your day with Yahoo! - make it your home page 
> http://www.yahoo.com/r/hs 
>  
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Justify text in a field

2005-07-28 Thread Lynch, Jonathan

>Do you mean the formattedrect of a single line?


Certainly - You can do formattedrect for any chunk of a field, be it
lines, characters, words, etc...

>if i remember well, Colin inserted spaces between
>words, and set the styles of words to extended and
>condensed, but i could not find his code now. :-(

This sounds like it would be designed not for centering, but for having
the line spread out evenly from right to left (I forget what that is
called). Is that what you need? The calculations would be a bit more
complex, but still quite doable.

>In scrolling fields this could take a while.
>Did you had some timings available for this
>technique? In this way i could know beforehand if
>it is user's friendly. 

Ah - you are not just talking about centering a single line, you are
talking about having all lines spread out evenly. The would get a bit
tricky. Once you did this, you would not really be able to properly type
in that field, without it doing weird stuff.
 
>This idea is fine and very precise,
>but what will happen if you had to 
>copy and paste this text elsewhere.

If you pasted it into another field in Rev, with the same settings and
dimensions, it should work fine. However, pasted somewhere else that was
not in Rev, or in a Rev field with different settings, it would be a
mess.

>You'll be carrying a lot of empty space 
>with the copied text, unless you perform
>some cleaning up in copied text. :-(

I think perhaps I was confused by what you mean by the word 'Justify' -
I think of that as a word to go with left, right, and center
justification. I just looked it up, and the evenly spread out type is
called 'double justification'. In html, you would do something like:
blah blah blah to give it double
justification.

I think, for what it sounds like you are doing, you really need
something like that. Unfortunately, Rev doesn't give that option - yet.

As long as a field is wide enough, and a given screen line contains
enough words, manipulating expanded and condensed characters should make
this possible - sounds kind of difficult to me.


Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Justify text in a field

2005-07-27 Thread Alejandro Tejada
on Wed, 27 Jul 2005 
xavier wrote:

> only with monospace fonts...
> but it works horizontal or vertically ;)

Monospaced only! I hoped for a 
more proportional solution. ;-)

Jonathan Lynch wrote:
> You could have a script do this:
> - get the formattedrect of a block of text

Do you mean the formattedrect of a single line?

> - calculate how far from the left of the field that
> block of text needs to be
> - insert a few spaces to the left of the block of
> text

if i remember well, Colin inserted spaces between
words, and set the styles of words to extended and
condensed, but i could not find his code now. :-(

> - check the formattedrect of the block of text again
> - keep inserting (or deleting if you go too far to
> the right) spaces until item 1 of the formattedrect 
> of the block of text is close enough to be where it 
> needs to be.

In scrolling fields this could take a while.
Did you had some timings available for this
technique? In this way i could know beforehand if
it is user's friendly. 

> - if you really want to be neurotic, you can use
> spaces with a really small font size, so that the 
> width of a space is only 1 or 2 pixels!

This idea is fine and very precise,
but what will happen if you had to 
copy and paste this text elsewhere.

You'll be carrying a lot of empty space 
with the copied text, unless you perform
some cleaning up in copied text. :-(

Thanks a lot to Jonathan and Xavier for
sharing their insights!

al


Visit my site:
http://www.geocities.com/capellan2000/




Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Justify text in a field

2005-07-27 Thread Lynch, Jonathan
You could have a script do this:
- get the formattedrect of a block of text
- calculate how far from the left of the field that block of text needs
to be
- insert a few spaces to the left of the block of text
- check the formattedrect of the block of text again
- keep inserting (or deleting if you go too far to the right) spaces
until item 1 of the formattedrect of the block of text is close enough
to be where it needs to be.
- if you really want to be neurotic, you can use spaces with a really
small font size, so that the width of a space is only 1 or 2 pixels!

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of MisterX
Sent: Wednesday, July 27, 2005 3:24 PM
To: 'How to use Revolution'
Subject: RE: Justify text in a field

Hi All

only with monospace fonts...
but it works horizontal or vertically ;)

sorry
Xav 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Alejandro Tejada
> Sent: Wednesday, July 27, 2005 20:29
> To: use-revolution@lists.runrev.com
> Subject: Justify text in a field
> 
> Hi Developers,
> 
> After reading these messages about
> Mac and Win fonts issues, i remember
> about a code that Colin Holgate
> contributed in the HyperCard list,
> that used text properties named
> extended and condensed to simulate
> justification in a text field.
> 
> This code does not work in RR.
> so, i ask this question to every
> developer:
> 
> Do you have working code to create justified text, or 
> something that resemble this, within a RR field?
> 
> Thanks in advance.
> 
> al
> 
> 
> Visit my site:
> http://www.geocities.com/capellan2000/
> 
> 
>   
> 
> Start your day with Yahoo! - make it your home page 
> http://www.yahoo.com/r/hs 
>  
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


RE: Justify text in a field

2005-07-27 Thread MisterX
Hi All

only with monospace fonts...
but it works horizontal or vertically ;)

sorry
Xav 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Alejandro Tejada
> Sent: Wednesday, July 27, 2005 20:29
> To: use-revolution@lists.runrev.com
> Subject: Justify text in a field
> 
> Hi Developers,
> 
> After reading these messages about
> Mac and Win fonts issues, i remember
> about a code that Colin Holgate
> contributed in the HyperCard list,
> that used text properties named
> extended and condensed to simulate
> justification in a text field.
> 
> This code does not work in RR.
> so, i ask this question to every
> developer:
> 
> Do you have working code to create justified text, or 
> something that resemble this, within a RR field?
> 
> Thanks in advance.
> 
> al
> 
> 
> Visit my site:
> http://www.geocities.com/capellan2000/
> 
> 
>   
> 
> Start your day with Yahoo! - make it your home page 
> http://www.yahoo.com/r/hs 
>  
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage 
> your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
> 

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Justify text in a field

2005-07-27 Thread Alejandro Tejada
Hi Developers,

After reading these messages about
Mac and Win fonts issues, i remember
about a code that Colin Holgate
contributed in the HyperCard list,
that used text properties named
extended and condensed to simulate
justification in a text field.

This code does not work in RR.
so, i ask this question to every
developer:

Do you have working code to create justified
text, or something that resemble this,
within a RR field?

Thanks in advance.

al


Visit my site:
http://www.geocities.com/capellan2000/




Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution