.net c# - 完美的语法高亮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1383574/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
c# - perfect syntax highlighting
提问by zee
I'm looking for a RichTextBox with syntax highlighting! Sounds easy but I'm searching since months and didn't find that what I need.
我正在寻找一个带有语法高亮的 RichTextBox!听起来很简单,但我几个月以来一直在寻找,但没有找到我需要的东西。
First I started to do it by myself... No good idea...
一开始我自己开始做...没有什么好主意...
I tried to use this: http://blogs.microsoft.co.il/blogs/tamir/archive/2006/12/14/RichTextBox-syntax-highlighting.aspx
我试着用这个:http: //blogs.microsoft.co.il/blogs/tamir/archive/2006/12/14/RichTextBox-syntax-highlighting.aspx
but that code don't handle loading files or pasting so i started to write a highlight function for inserting text-blocks. That tutorial and my code worked fine first, but then I saw a lot of tiny bugs and loading large files took too much time.
但该代码不处理加载文件或粘贴,所以我开始编写用于插入文本块的突出显示功能。该教程和我的代码首先运行良好,但后来我看到了很多小错误并且加载大文件花费了太多时间。
Then a found a lot of similar tutorials/codes at codeproject.com like this: http://www.codeproject.com/KB/edit/SyntaxHighlighting.aspx
然后在 codeproject.com 上找到了很多类似的教程/代码,如下所示:http: //www.codeproject.com/KB/edit/SyntaxHighlighting.aspx
But there I get problems if the file becomes large, too. Pasting and loading files will take a while...
但是如果文件变大,我也会遇到问题。粘贴和加载文件需要一段时间...
I think I'm searching for something like this: http://www.aqistar.com/
我想我正在寻找这样的东西:http: //www.aqistar.com/
But I don't can spent money and I want to sell my program maybe so the code/control should be free.
但是我不能花钱,我想出售我的程序,所以代码/控件应该是免费的。
Can anybody help me?
有谁能够帮助我?
回答by Daniel
AvalonEditis the WPF-based text editor used in SharpDevelop4.0. It has built-in support for syntax highlighting for several languages and you can add new highlighting definitions using an XML-based file format.
AvalonEdit是SharpDevelop4.0 中使用的基于 WPF 的文本编辑器。它内置支持多种语言的语法突出显示,您可以使用基于 XML 的文件格式添加新的突出显示定义。
AvalonEdit is open-source, but can also be used in commercial applications (MIT licensed since AvalonEdit 5.0).
AvalonEdit 是开源的,但也可用于商业应用程序(自 AvalonEdit 5.0 起获得 MIT 许可)。
If you don't want to use WPF, you could also use ICSharpCode.TextEditor, the old Windows Forms text editor from SharpDevelop 3.x.
如果您不想使用 WPF,您还可以使用 ICSharpCode.TextEditor,SharpDevelop 3.x 中的旧 Windows 窗体文本编辑器。

