English 中文(简体)
How do I highlight syntax errors using ICSharpCode.TextEditor.TextEditorControl?
原标题:

I m using ICSharpCode.TextEditor.TextEditorControl as my DSL editor. When I get DSL compilation errors, I would like to highlight the offending text to provide a better user experience. However, I m having difficulty finding how to do this.

So far, I ve found that there is a ShowInvalidLines property but I don t see a way to mark any lines as invalid. I also see HighlightSpanStack property of LineSegment and HighlightingStrategy but not sure how they are supposed to be used.

Any help would be appreciated. Thanks!

最佳回答

To highlight a piece of text use a TextMarker. The following code underlines the word Error with a red wavy line.

TextEditorControl textEditor = new TextEditorControl();
textEditor.Text = "Mark Error";

int offset = 5;
int length = 5;
TextMarker marker = new TextMarker(offset, length, TextMarkerType.WaveLine, Color.Red);
textEditor.Document.MarkerStrategy.AddMarker(marker);

You can highlight the text with any background and foreground colour and the TextMarkerType supports underlining, wavy lines or a solid block of colour.

问题回答

暂无回答




相关问题
Good IDE for Mono on Windows

I would like to develop Mono application for Win/Linux/Mac in C# on Windows. Is there any really good (Visual Studio comparable) IDE for that? The best would be if I could manage Visual C# Express to ...

sharpdevelop, asp.net and run/debug it?

i created an asp.net project in sharpdevelop. i wanted to get started to see how debugging is and i am stuck already. How do i run the ASP.NET project? It just says its configured as a DLL. How do i ...

Developing the mono application on Sharp Develop 3.1

Im testing the Sharp Develop 3.1 to find out that can i use sharp develop on windows for building mono application. building process works find, while i m debugging ,execution is not stopping at break ...

Convert SharpDevelop 3.1 solution to VS2005

Is there a way to open a solution created in SharpDevelop 3.1 in Visual Studio 2005? Here is the header of the solution file: Microsoft Visual Studio Solution File, Format Version 10.00 # Visual ...

热门标签