2016-08-23 123 views
1

如何知道在AvalonEdit控件上更改文本的座標? 它需要使用Roslyn來完成代碼。如何獲取在AvalonEdit控件上更改文本的座標?

我有AvalonEdit控制和訂閱上TextEntering:

tbTextEditor.TextArea.TextEntering += TextEditor_exTtArea_TextEntering; 
tbTextEditor.TextArea.TextEntered += TextEditor_TextArea_TextEntered; 

private void TextEditor_TextArea_TextEntered(object sender, TextCompositionEventArgs e) 
    { 
    var textChanging=e.Text; 
    } 

例如,I型點到控制; 所以,Text的值是'。';

但是我必須知道它位於世界的哪個部分?

例如,我有這樣的代碼:

using System; 
class Test 
{ 
public int I=0; 
public void Completion() 
{ 
var test=new Test(); 
test. // here is my dot. 

test.I=10; // here is dot too. 
} 
} 

test.那麼,如何讓座標?

+0

這是一個非常複雜的任務,[在AvalonEdit主頁](http://avalonedit.net/documentation/html/47c58b63-f30c-4290-a2f2-881d21227446.htm)以及[SharpDevelop repo]中的示例(https://github.com/icsharpcode/SharpDevelop/blob/ b0838faf2d4b0c19003039cd48ae8cc49768f30f/src目錄/加載項/ BackendBindings /類型cript/Project/Src/TypeScriptCompletionItemProvider.cs)應該讓你開始 – m0sa

回答

1

我發現Caret屬性:

var caret = tbTextEditor.TextArea.Caret; 

然後,我應該使用Caret.OffsetTextSpan(羅斯林類),使代碼完成:

TextSpan span = new TextSpan(caret.Offset, 1); 
相關問題