Multicolumn Printing (Text Flow)
Cubist at aol.com
Cubist at aol.com
Tue Nov 16 16:36:19 EST 2004
In a message dated 11/16/04 12:35:15 PM,
use-revolution-request at lists.runrev.com writes:
sez depstein at att.net:
>Here's another approach to the text overflow calculation:
Nice idea, but do you really need to test every character in sequence? I
was under the impression that Rev doesn't believe in hyphenation, so you could
speed up this handler by testing words rather than characters; a further
speedup could be gained by starting with the entire field (what if the text doesn't
actually overflow?) and doing a binary search. With that in mind, here's my
modified version of your handler ('ware the line wraps!)...
function ExtraText2 FldName
-- removes from fld FldName, and returns, the htmlText that overflows size of
fld FldName
put (the number of words in fld FldName) into WordKount
put max (WordKount div 2, 1) into DerDelta
put the height of fld FldName into DerHeight
put the formattedHeight of word 1 to WordKount of fld FldName into
CurrentHeight
if CurrentHeight <= DerHeight then return "" -- no overflow, right?
-- now comes the binary search
put WordKount into HiEnd
put CurrentHeight into MaxH
put DerDelta into LoEnd
put the formattedHeight of word 1 to LoEnd of fld Fldname into MinH
repeat
put max (DerDelta div 2, 1) into DerDelta
if MinH > DerHeight then -- even the minimum is too long
put LoEnd into HiEnd
put MinH into MaxH
subtract DerDelta from LoEnd
put the formattedHeight of word 1 to LoEnd of fld Fldname into MinH
else if MinH = DerHeight then -- *just* right!
return the htmlText of word (LoEnd + 1) to -1 of fld FldName
else -- the minimum is too small
if MaxH - MinH = 1 then -- we've discovered the overflow point
return the htmlText of word (LoEnd + 1) to -1 of fld FldName
end if
add DerDelta to LoEnd
end if
put the formattedHeight of word 1 to LoEnd of fld Fldname into MinH
end repeat
end extraText2
Comments, people?
More information about the use-livecode
mailing list