Syntax highlighting in .net richtextbox, how do I deal with newlines? -


i trying highlight syntax in richtextcontrol (quoted text, xml tags, xml comments). apart obvious problem created own stupidity (for example, run through text highlight syntax takes on second , cannot check syntax whenever character typed) ran issue caused newlines in text.

this feeble attempt syntaxhighlight:

    while < l          ssrelevanttext = t.text.substring(i)          ssselectedtext = regex.match(ssrelevanttext, pattern, regexoptions.singleline).value         idxselectionstart = t.find(ssselectedtext, i, richtextboxfinds.none)         idxselectionlength = ssselectedtext.length         t.selectionstart = idxselectionstart         t.selectionlength = idxselectionlength         t.selectioncolor = color          = idxselectionstart + idxselectionlength         t.selectionstart = idxcursorbeforeselection         t.selectionlength = 0         t.selectioncolor = color.black      end while 

(i removed comments because, ironically, vb comments break so's syntax-highlighting.)

i tried other regexoptions problem remains while, example

"hello"

is found , accurately coloured,

"

hello

"

is not found. (the colouring fails below such incident, not always.)

if replace newlines other symbol, above works , highlighted correctly. why newlines interfering?

alternatively, how 1 syntax-highlighting in richtextbox? examples can find refer syntax-highlighting of reserved words , not terms based on patterns.

edit: far figured out richtextbox method find() not find strings containing newlines. since triggers exception (easily avoided) no further highlighting done after that. how can find string in richtextbox contains newlines?

you might want here: http://blogs.microsoft.co.il/blogs/tamir/archive/2006/12/14/richtextbox-syntax-highlighting.aspx

it provides nice example of how syntax higlight in c# using richtextbox.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -