Colouring words

Michael Doub mikedoub at gmail.com
Mon Aug 10 20:29:45 CEST 2015


I was going to suggest looking at styledText too,  but it is kind of 
tricky to insert a run within the array.

I think Richmond should look at some of the text routines in the 
masterLibrary.   There are several that might be interesting:

LineOffsets returns a list of lines that contain a string within 
container - create a list of each line that contains "only"

WordOffsets returns a list of word offsets of a string within a 
container - create a new list that has line number and  the word offsets 
within the line.

wordBounds returns the start and end character of a word specified by 
line number and work offset. -  Based on the line number and word 
offset, get the start and end character and change the color within the 
field variable with the screen locked.




On 8/10/15 1:59 PM, Mike Bonner wrote:
> It sounds like you might want to look at the styledtext.  Its a bit
> convoluted, but once you get it figured out, it should be very fast.
>
> Pseudo code for this would be..
> put the text of the field into a variable.
> repeat for each line (paragraph) and build up an array of "runs" with
> descriptive text styling for each paragraph.
> Apply the resulting array to the field.
>
> Sounds simple.. Isn't.
>
>
> On Mon, Aug 10, 2015 at 11:40 AM, Michael Doub <mikedoub at gmail.com> wrote:
>
>> Yet another approach:
>>
>>     put "this is the only  one" into fld 1
>>
>>     put empty into s1
>>     put empty into e1
>>     get MatchChunk (line 1of  fld 1,"(?i).+(only).+",s1,e1)
>> -- the regexp capture returns the start and end characters the match
>>
>>     set the textcolor of char s1 to e1 of line 1 of fld 1 to red
>>
>> On 8/10/15 12:03 PM, Mike Bonner wrote:
>>
>>> You can do this..  Still a bit ugly but it works.
>>>
>>> set the textcolor of trueword ( truewordoffset("only",line 5 of field 1))
>>> of line 5 of field 1 to red
>>>
>>>
>>> On Mon, Aug 10, 2015 at 9:13 AM, Richmond <richmondmathewson at gmail.com>
>>> wrote:
>>>
>>> On 10/08/15 16:51, dunbarx at aol.com wrote:
>>>> @Mark
>>>>>
>>>>> There is nothing wrong with setting the textColor of an entire line. Any
>>>>> valid chunk expression would do.
>>>>>
>>>>> No, there is nothing wrong with that, but that is not what I want to do.
>>>> Richmond.
>>>>
>>>>
>>>> @, Richmond:
>>>>>
>>>>> What are you seeing? Why does it not work? I am in v 6.7.
>>>>>
>>>>>
>>>>> Craig Newman
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>>
>>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>>
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>




More information about the use-livecode mailing list