Setting hidden of lines very slow

hh hh at
Sat Dec 1 09:40:11 EST 2018

> Kaveh wrote:
> I can confirm that the htmltext method works beautifully and blindingly fast.

So we have here two methods:
The htmlText-method and the styledText-method.

There is an interesting result in the speed comparison of the two methods.

Here the htmlText-method is significantly faster with less than at about
1500 short lines, between 1500 and 2500 short lines speed is at about the
same, for more than at about 2500 short lines the styledText-method becomes
significantly faster.

As LC flattens any nested arrays the styledText-method is probably adjustable
and worth the loop through the runs: styledText experts please come in.

## HtmlText-method for any colored text chunk in the line.
on mouseUp
  put the millisecs into m1
  lock screen; lock messages
  set linedelimiter to "<p"
  put the htmltext of fld 1 into ht
  replace " hidden" with empty in ht
  repeat for each line L in ht
    if offset("color=",L)>0 then put "<p" & L after s
    else put "<p hidden" & L after s
 end repeat
 set htmltext of fld 1 to s
 put the millisecs-m1 into fld "timing"
end mouseUp

## StyledText-method for a whole colorized line.
put the styledText of field "text" into tTextA
# loop through paragraphs
repeat with i = 1 to the number of elements of tTextA
  # Check if first run has textcolor set
  put (tTextA[i]["runs"][1]["style"]["textcolor"] is empty) \
      into tTextA[i]["style"]["hidden"] 
  end if
end repeat
set the styledText of fld "text" to tTextA```

More information about the Use-livecode mailing list