If you are not happy with what you have, I can tell you how I did it, but I must warn you, it has been a big effort. I did it as part of a larger project; relevant steps include: - text lines stored in memory basically in an ArrayList, one item per line; - each line also holds two flags to indicate comment status; these get set when the line is input/changed; - text drawn in a Panel, using OnPaint handler, and Graphics.DrawString; - all coloring/syntax highlighting handled inside OnPaint, based on a simple parser that knows the list of keywords (and their color) for each of the supported programming languages. Steps taken to get maximum performance: - only the visible lines are parsed, colored and painted; lines scrolled outside the panel are skipped (except for the comment flags). A typical Panel shows up to 60 lines, a very small number with respect to an entire source file. - the comment flags help in starting the first visible line either as continued comment (green background) or not. - the simple parsers are not full fledged parsers, they dont understand expressions, dont return a parse tree, etc. They must only process a single line and know about comments, string literals, and keywords. - the parsers return tokens (identifiers, constants, operators, etc) as a string plus Color; Graphics.DrawString paints these tokens individually. - as a result of all this, nearly linear behavior, and no delay whatsoever. All in all a couple thousand lines of C# code (and based on a growing library of low-level classes that I use in all my apps and that is not included in the estimate). Hope this clarifies things. :)
Luc Pattyn [My Articles] [Forum Guidelines]