2016-08-23 8 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; 
    } 

예를 들어, 내가 컨트롤에 점 입력; 따라서 Text 값은 '.'입니다.

그러나 나는 세계의 어느 부분에 위치해 있는지 알아야합니까? test.

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. 
} 
} 

그럼, 어떻게 얻을 수있는 좌표 : 예를 들어

, 나는이 같은 코드가? 내가 코드 완성하기 위해 Caret.Offset를 사용 TextSpan (로슬린 클래스)를해야한다, 그런

var caret = tbTextEditor.TextArea.Caret; 

:

+0

, [AvalonEdit 홈페이지 ] (http://avalonedit.net/documentation/html/47c58b63-f30c-4290-a2f2-881d21227446.htm) 및 [SharpDevelop repo]의 예 (https://github.com/icsharpcode/SharpDevelop/blob/ b0838faf2d4b0c19003039cd48ae8cc49768f30f/src/AddIns/BackendBindings/TypeS cript/Project/Src/TypeScriptCompletionItemProvider.cs) 시작해야합니다. – m0sa

답변

1

내가 Caret 속성을 발견 매우 복잡한 작업이다

TextSpan span = new TextSpan(caret.Offset, 1);