Setting hidden of lines very slow

hh hh at hyperhh.de
Fri Nov 30 10:32:11 EST 2018


If showing *only* lines with colored text means that all others
are hidden then you could use:

...
set hidden of line i of fld "text" to \
    (the textcolor of line i of fld "text" is empty)
...

Trevor's script would then read:
...
put (tTextA[i]["runs"][1]["style"]["textcolor"] is empty) \
     into tTextA[i]["style"]["hidden"] 
...

Here yet another fast method:

on mouseUp
  put the millisecs into m1
  lock screen; lock messages
  put the htmltext of fld 1 into ht
  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


> > Kaveh wrote:
> > But here is a follow-up: Now I want to hide all lines that
> > have no text style and only show lines with colored text. 
> > I use:
> >
> > repeat with i = 1 to the number of lines of fld 1
> >   if the textcolor of line i of fld "text" is not empty then
> >     set the hidden of line i of fld "text" to false
> >   end if
> > end repeat
> >
> > This is taking time too. Any suggestions how to speed this up?
> >
> 
> Trevor wrote:
> Try working with the styledText property.
> 
> 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
>   if tTextA[i]["runs"][1]["style"]["textcolor"] is not empty then
>     # hide paragraph
>     put true 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