scripting challenge: Large/Smaller text size
Buster
wouter.abraham at scarlet.be
Sat Jul 2 21:06:11 EDT 2005
One last remark, if you change a font face then the code breaks for
that part as the font face tag precedes the size tag.
for example: <font face="Courier" size="11">
But you'll find a solution :-)
Greetings,
Wouter
On 03 Jul 2005, at 02:43, Mark Smith wrote:
> Good points. I knew a check for limits would be necessary, but I
> hadn't considered the implications of the sizeList being unsorted.
>
> Mark
>
> On 3 Jul 2005, at 00:50, Buster wrote:
>
>
>> Also the sizeList returned by the getHSizes function should be
>> sorted numeric descending for enlarging textsize and ascending
>> for reducing textsize, lest not to lose some initial size
>> differences of 1
>>
>> greetings,
>> Wouter
>>
>>
>>>
>>>
>>>> on changeTextSize inc
>>>> -- make the tags that will set text to the effective textSize
>>>> in force
>>>> put "<font size=" & quote & the effective textSize of fld 1 &
>>>> quote & ">" into openTag
>>>> put "</font>" into closeTag
>>>> -- get the html
>>>> put the htmltext of fld 1 into ttext
>>>> --this next block sets size tags for all the unsized text
>>>> replace "</font>" with "</font>" & openTag in ttext
>>>> replace "<font size=" with closeTag & "<font size=" in ttext
>>>> replace closeTag & closeTag with closeTag in ttext
>>>> --ugly, i know, but I could'nt see a better way
>>>> put openTag after char 3 of ttext
>>>> -- puts openTag after the intial <p> tag
>>>> --now get all the size values from the size tags
>>>> --via the getHSizes function
>>>> put getHSizes(ttext) into sizeList
>>>>
>>
>> if inc < 0 then sort sizeList numeric ascending #####
>> else sort sizeList numeric descending #####
>>
>>
>>>> if sizeList is not empty then
>>>>
>> if "8" is among the lines of sizeList and inc > 0 then
>> beep
>> exit to top
>> end if
>>
>>>> repeat for each line L in sizeList
>>>> put quote & L & quote into pSize
>>>> put quote & L+inc & quote into nSize
>>>> replace "<font size=" & pSize with "<font size=" & nSize
>>>> in ttext
>>>> end repeat
>>>> end if
>>>> set the htmltext of fld 1 to ttext
>>>> end changeTextSize
>>>>
>>
>>
>>
>>
>>>> function getHSizes tt
>>>> put empty into sizeList
>>>> -- turn each tag into an item
>>>> replace "<" with numToChar(28) in tt
>>>> replace ">" with numToChar(28) in tt
>>>> set the itemDelimiter to numToChar(28)
>>>> repeat for each item i in tt
>>>> if "font size=" is in i then
>>>> --if the item is a font size tag then
>>>> --get the value inside the quotes ie font size="14"
>>>> put offset(quote,i) +1 into startChar
>>>> put offset(quote,i,startchar) into endChar
>>>> put char startChar to (startChar + endChar -1) of i into
>>>> fSize
>>>> if fSize is not among the lines of sizeList then put fSize
>>>> & cr after sizeList
>>>> end if
>>>> end repeat
>>>> return char 1 to -2 of sizeList
>>>> end getHSizes
>>>> Cheers,
>>>> Mark
>>>>
>>
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at 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 at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list