Ejemplo n.º 1
0
        protected string KeywordColor(string line, string color)
        {
            int    i;
            string newstr;

            string[]       keywords = GetKeywords();
            IStringMatcher matcher  = GetMatcher();
            StringBuilder  sb       = new StringBuilder(line);

            foreach (string key in keywords)
            {
                i = 0;
                while (0 <= (i = matcher.IndexOf(key, sb, i, sb.Length - i)))
                {
                    if ((i == 0 || IsKosher(sb[i - 1])) &&
                        (key.Length + i == sb.Length || IsKosher(sb[key.Length + i])))
                    {
                        newstr =
                            "<b><font color=\"" + color + "\">" + key + "</font></b>";
                        sb = sb.Replace(key, newstr, i, key.Length);
                        i += newstr.Length - 1;
                    }
                    else
                    {
                        i += key.Length;
                    }
                }
            }
            return(sb.ToString());
        }