Re: text color part 2

2011-11-22 Thread John Brozycki
This still isn't exactly what I want.  Given search term of http: this will 
change color of the entire word http://somesite.com;.  I only want to change 
the color of what matches. Tried the following:

on mouseUp
   set the traversalOn of field Results to true
   put the text of field Results into tResults
   put the text of field SearchField into strSearch
   put the length of strSearch into tLength
   put 1 into tFramePos
   put 0 into tPreviousOffset
   repeat while tFramePos  0
  put itemOffset(strSearch,tResults,tPreviousOffset) into tFramePos
  select characters (tFramePos+tPreviousOffset) to 
(tFramePos+tPreviousOffset+tLength) of field Results
  set the textColor of the selection to red
  set the BackgroundColor of the selection to yellow
  put tFramePos + tPreviousOffset into tPreviousOffset
   end repeat
end mouseUp

I get a syntax error on the select characters line.  After consulting the 
Dictionary/User Guide/web I can't find syntax how to select characters.  Am I 
specifying this wrong or is there another command to do this?

Thx,
John


On Nov 21, 2011, at 8:31 PM, Mike Bonner wrote:

 you can set the textcolor of the selection to red
 
 Be aware though, if you just have an insertion point in the field, and set
 the textcolor of the selection to red, any typing done afterwards will be
 red.  If this isn't what you desire you'll probably want to check to see
 what is selected so you can avoid this behavior.
 
 On Mon, Nov 21, 2011 at 6:31 PM, John Brozycki jo...@hvc.rr.com wrote:
 
 Is it possible to select text in a field and change the text or highlight
 color of JUST the selected text?  I realize I could do this with HTML (
 such as
 FONT COLOR=#00) but what if you are trying to highlight and
 display HTML source, and thus the field is plaintext so that HTML commands
 display instead of being rendered in the field?
 
 find string... - only provides a highlight box around sequential searches
 for the text, and in the same color of the text.
 
 set the textColor of field x... - changes the color for the entire field.
 
 Any suggestions greatly appreciated!
 
 Thanks,
 John
 
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: text color part 2

2011-11-22 Thread Mark Wieder
John-

If you can get by without setting the background color, try using the
htmlText property of the field, something like this:

on mouseUp
  local tText
  local tStrReplace

  put the htmlText of field Original into tStrReplace
  put font color=  quote  red  quote   \
 field SearchField \
 /font into tStrReplace
  replace field SearchField with tStrReplace in tText
  set the htmlText of field Results to tText
end mouseUp

-- 
-Mark Wieder
 mwie...@ahsoftware.net


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: text color part 2

2011-11-22 Thread John Brozycki
Mark,

Thanks for the suggestion.  I've typically done just that to color text.  The 
problem is, in this case, the field contains plaintext that is actual html, and 
I need to be able to view it without it disappearing and modifying other text.  
For example, a search could be done on, say, font and I want it to find all 
of this occurrences and color them to make them stand out.  Mike's suggestion 
got me to an answer, and we both posted working solutions.

Just want to say how thankful I am for this list and everyone who has helped me 
either directly by replying to a question I asked, or indirectly by helping 
someone else and I've benefited from the answer.

Best,
John

On Nov 22, 2011, at 7:54 PM, Mark Wieder wrote:

 John-
 
 If you can get by without setting the background color, try using the
 htmlText property of the field, something like this:
 
 on mouseUp
  local tText
  local tStrReplace
 
  put the htmlText of field Original into tStrReplace
  put font color=  quote  red  quote   \
 field SearchField \
 /font into tStrReplace
  replace field SearchField with tStrReplace in tText
  set the htmlText of field Results to tText
 end mouseUp
 
 -- 
 -Mark Wieder
 mwie...@ahsoftware.net


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: text color part 2

2011-11-22 Thread Mark Wieder
John-

Tuesday, November 22, 2011, 5:22:51 PM, you wrote:

 Mark,

 Thanks for the suggestion.  I've typically done just that to
 color text.  The problem is, in this case, the field contains
 plaintext that is actual html, and I need to be able to view it
 without it disappearing and modifying other text.  For example, a
 search could be done on, say, font and I want it to find all of
 this occurrences and color them to make them stand out.  Mike's
 suggestion got me to an answer, and we both posted working solutions.

Fair enough, but I still would opt for the replace command for speed
rather than a repeat loop. A couple of extra lines allows you to have
html tags embedded in the text itself. Just a thought.

on mouseUp
local tText
local tStrReplace
local tSearchString

put the htmltext of field Original into tText
put the htmltext of field SearchField into tSearchString
-- remove the p and /p strings
delete char 1 to 3 of tSearchString
delete char -4 to -1 of tSearchString
put font color=  quote  red  quote   \
 tSearchString  \
/font into tStrReplace
replace tSearchString with tStrReplace in tText
set the htmltext of field Results to tText
end mouseUp

-- 
-Mark Wieder
 mwie...@ahsoftware.net


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode