<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: RichTextBox syntax highlighting</title>
	<atom:link href="http://khason.net/blog/richtextbox-syntax-highlighting/feed/" rel="self" type="application/rss+xml" />
	<link>http://khason.net/blog/richtextbox-syntax-highlighting/</link>
	<description>Take care of the sense, and the sounds will take care of themselves.</description>
	<lastBuildDate>Fri, 10 Sep 2010 03:44:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Vlad</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-3359</link>
		<dc:creator>Vlad</dc:creator>
		<pubDate>Tue, 13 Oct 2009 06:29:28 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-3359</guid>
		<description>Here is one alternative solution: http://blog.bodurov.com/Wpf-Source-Code-Editor</description>
		<content:encoded><![CDATA[<p>Here is one alternative solution: <a href="http://blog.bodurov.com/Wpf-Source-Code-Editor" rel="nofollow">http://blog.bodurov.com/Wpf-Source-Code-Editor</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: vlad</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-3346</link>
		<dc:creator>vlad</dc:creator>
		<pubDate>Sat, 10 Oct 2009 00:52:02 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-3346</guid>
		<description>By the way why are you using bitwise or &#124; instead of conditional or &#124;&#124;? For example here
Char.IsWhiteSpace(text[i]) &#124; JSSyntaxProvider.GetSpecials.Contains(text[i])

This will evaluate the second expression even if the first is true. If you use &#124;&#124; and the first is true (character is white space) it will not waste time to look at the second. Obviously character cannot be white space and special at the same time</description>
		<content:encoded><![CDATA[<p>By the way why are you using bitwise or | instead of conditional or ||? For example here<br />
Char.IsWhiteSpace(text[i]) | JSSyntaxProvider.GetSpecials.Contains(text[i])</p>
<p>This will evaluate the second expression even if the first is true. If you use || and the first is true (character is white space) it will not waste time to look at the second. Obviously character cannot be white space and special at the same time</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Smith</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-2098</link>
		<dc:creator>Alan Smith</dc:creator>
		<pubDate>Mon, 12 Jan 2009 16:26:51 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-2098</guid>
		<description>For anyone landing here looking for WPF Richtextbox syntax highlighting, I can confirm that the above is not a solution for any meaningful size of file.    I previously used ScintillaNet for this purpose but cannot get it working under 64bit Vista.   Having decided I only need some basic highlighting and not folding, block comment colouring etc I am experimenting (with some success) a more efficient version of the above concept.
Perhaps more determined and capable programmers than me might find this concept worth exploring....
1.	Concept .... Use the Paragraph.Tag flags in the document to indicate that a paragraph needs highlighting or re-highlighting... use NULL (the default) to indicate it does need highlighting that way newly pasted text is handled.
2.	In the TextChangedEventHandler use the change list (with the Event Arg e) to mark each unique paragraph mentioned as needing re-highlighting follows...
  foreach (TextChange C in e.Changes)
  {
                TextPointer P = Document.ContentStart.GetPositionAtOffset(C.Offset);
                if (P.Paragraph != null) P.Paragraph.Tag = null;   //It needs reformatting
  }
  ReformatAsNeeded() 
3.	Call reformat as needed at the end of the Text change event and when the file is first loaded (this bit is slow)
void ReformatAsNeeded()
{
    if (Document.Blocks.Count &gt; 0)
    {
        Block B = Document.Blocks.FirstBlock;
        while (B != null)
        {
            if (B is Paragraph)
            {
                Paragraph P = B as Paragraph;
                if (P.Tag == null)
                {
                    ReFormat(P);
                    P.Tag = true;   //It has been highlighted
                }
            }
            else throw new Exception(&quot;Unknown block type &quot; + B.ToString());
            B = B.NextBlock;
        }
    }

4.	Modify the &quot;navigator&quot; code in the article to only walk the Paragraph supplied via the Reformat call shown above. 
Initial highlighting a newly loaded file is still slow (it probably always will be using this technology!) but I can live with that for my files.   As said this is experimental work in progress, it may not work... is probably too early to mention, but posting now as it may trigger ideas.  Yes I know there are still bugs in it (from the original) like does not colour a word on the end of line.    

PS - Please excuse the possible poor formatting.</description>
		<content:encoded><![CDATA[<p>For anyone landing here looking for WPF Richtextbox syntax highlighting, I can confirm that the above is not a solution for any meaningful size of file.    I previously used ScintillaNet for this purpose but cannot get it working under 64bit Vista.   Having decided I only need some basic highlighting and not folding, block comment colouring etc I am experimenting (with some success) a more efficient version of the above concept.<br />
Perhaps more determined and capable programmers than me might find this concept worth exploring&#8230;.<br />
1.	Concept &#8230;. Use the Paragraph.Tag flags in the document to indicate that a paragraph needs highlighting or re-highlighting&#8230; use NULL (the default) to indicate it does need highlighting that way newly pasted text is handled.<br />
2.	In the TextChangedEventHandler use the change list (with the Event Arg e) to mark each unique paragraph mentioned as needing re-highlighting follows&#8230;<br />
  foreach (TextChange C in e.Changes)<br />
  {<br />
                TextPointer P = Document.ContentStart.GetPositionAtOffset(C.Offset);<br />
                if (P.Paragraph != null) P.Paragraph.Tag = null;   //It needs reformatting<br />
  }<br />
  ReformatAsNeeded()<br />
3.	Call reformat as needed at the end of the Text change event and when the file is first loaded (this bit is slow)<br />
void ReformatAsNeeded()<br />
{<br />
    if (Document.Blocks.Count &gt; 0)<br />
    {<br />
        Block B = Document.Blocks.FirstBlock;<br />
        while (B != null)<br />
        {<br />
            if (B is Paragraph)<br />
            {<br />
                Paragraph P = B as Paragraph;<br />
                if (P.Tag == null)<br />
                {<br />
                    ReFormat(P);<br />
                    P.Tag = true;   //It has been highlighted<br />
                }<br />
            }<br />
            else throw new Exception(&#8220;Unknown block type &#8221; + B.ToString());<br />
            B = B.NextBlock;<br />
        }<br />
    }</p>
<p>4.	Modify the &#8220;navigator&#8221; code in the article to only walk the Paragraph supplied via the Reformat call shown above.<br />
Initial highlighting a newly loaded file is still slow (it probably always will be using this technology!) but I can live with that for my files.   As said this is experimental work in progress, it may not work&#8230; is probably too early to mention, but posting now as it may trigger ideas.  Yes I know there are still bugs in it (from the original) like does not colour a word on the end of line.    </p>
<p>PS &#8211; Please excuse the possible poor formatting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tamir Khason</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-354</link>
		<dc:creator>Tamir Khason</dc:creator>
		<pubDate>Thu, 01 Jan 2009 08:03:22 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-354</guid>
		<description>&lt;p&gt;it&#039;s low what?&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>it&#8217;s low what?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bs</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-353</link>
		<dc:creator>bs</dc:creator>
		<pubDate>Thu, 01 Jan 2009 08:03:20 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-353</guid>
		<description>&lt;p&gt;great sample--just what i was looking for, thanks&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>great sample&#8211;just what i was looking for, thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 陈锋</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-352</link>
		<dc:creator>陈锋</dc:creator>
		<pubDate>Thu, 01 Jan 2009 08:03:19 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-352</guid>
		<description>&lt;p&gt;RichTextBox 中文字背景高亮方法的一些link&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>RichTextBox 中文字背景高亮方法的一些link</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rajesh Kumar</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-351</link>
		<dc:creator>Rajesh Kumar</dc:creator>
		<pubDate>Thu, 01 Jan 2009 08:03:17 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-351</guid>
		<description>&lt;p&gt;You don&#039;t need to define something called &quot;Tag&quot;. You can use TextRange instead, which serves for the same.&lt;/p&gt;
&lt;p&gt;See this sample: &lt;a rel=&quot;nofollow&quot; target=&quot;_new&quot; href=&quot;http://blogs.msdn.com/prajakta/archive/2006/11/01/navigate-words-in-richtextbox.aspx&quot; rel=&quot;nofollow&quot;&gt;blogs.msdn.com/.../navigate-words-in-richtextbox.aspx&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>You don&#39;t need to define something called &quot;Tag&quot;. You can use TextRange instead, which serves for the same.</p>
<p>See this sample: <a rel="nofollow" target="_new" href="http://blogs.msdn.com/prajakta/archive/2006/11/01/navigate-words-in-richtextbox.aspx" rel="nofollow">blogs.msdn.com/&#8230;/navigate-words-in-richtextbox.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavol</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-350</link>
		<dc:creator>Pavol</dc:creator>
		<pubDate>Thu, 01 Jan 2009 08:03:16 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-350</guid>
		<description>&lt;p&gt;Good work, but it&#039;s so horribly slow...&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Good work, but it&#39;s so horribly slow&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pavol</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-349</link>
		<dc:creator>Pavol</dc:creator>
		<pubDate>Thu, 01 Jan 2009 08:03:15 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-349</guid>
		<description>&lt;p&gt;this is the row: that slow things down:&lt;/p&gt;
&lt;p&gt;documentRange.ClearAllProperties();&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>this is the row: that slow things down:</p>
<p>documentRange.ClearAllProperties();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom</title>
		<link>http://khason.net/blog/richtextbox-syntax-highlighting/comment-page-1/#comment-348</link>
		<dc:creator>Tom</dc:creator>
		<pubDate>Thu, 01 Jan 2009 08:03:14 +0000</pubDate>
		<guid isPermaLink="false">http://khason.net/blog/richtextbox-syntax-highlighting/#comment-348</guid>
		<description>&lt;p&gt;Try instead of documentRange.ClearAllProperties();&lt;/p&gt;
&lt;p&gt;just set the background and foreground colors of the whole FlowDocument to white and black :)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Try instead of documentRange.ClearAllProperties();</p>
<p>just set the background and foreground colors of the whole FlowDocument to white and black <img src='http://khason.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>
