Editing the style(s) of text in a field.

Peter M. Brigham pmbrig at gmail.com
Fri Feb 28 12:51:26 EST 2014

On Feb 26, 2014, at 7:37 PM, Alex Tweedly wrote:

> I guess the code will just have to iterate through the chars and change them.
>   (oops no, just tried that and it's too slow. I guess the code will need to scan through the chars and change each sub-chunk)

There was a handler posted here not too long ago to increase or decrease the textsize of a field. It could be adapted to operate on chunks of a field.

-- Peter

Peter M. Brigham
pmbrig at gmail.com


on bumpTextSize theObject,theDirection
   -- increases the textsize of the entire text of any field,
   -- even if the field has varying textsizes already.
   --    theObject = a full object reference, eg, the long id
   --    theDirection = +1 or -1
   -- thanks to Michael Doub and Malte Brill
   if theDirection is not among the items of "1,-1" then exit bumpTextSize
   put the htmlText of theObject into theHtml
   replace "size="&quote with "size="&numtoChar(1500) in theHTML
   set the itemdel to numToChar(1500)
   if the number of items of theHTML<>1 then
      put 0 into itemCount
      repeat for each item theItem in theHTML
         add 1 to itemCount
         if itemCount=1 then
            put theItem into newHTML
            next repeat
         end if
         put 1 into counter
         put offset (">", theItem) into tClose
         put offset ("<" , theItem) into tOpen
         if tClose <> 0 then -- found it
            if tOpen <> 0 and tOpen > tClose then
               -- found "<" and after ">" this is ok
               repeat forever
                  add 1 to counter
                  if char counter of theItem=quote then exit repeat
               end repeat
               put char 1 to counter-1 of theItem into theSize
               put theSize + theDirection into theSize
               put theSize into char 1 to counter-1 of theItem
            end if
         end if
         put quote&theItem after newHTML
      end repeat
      set the htmlText of theObject to newHTML
   end if
   set the textSize of theObject to \
         the effective textSize of theObject + theDirection
end bumpTextSize

More information about the Use-livecode mailing list