2014-10-14 6 views
0

내 이클립스 플러그인에는 StyledText 개체와 IEditorReference 개체가 있습니다. 적용 접기 더 라인이없는 경우StyledText에서 모든 접힌 선을 얻는 방법

 int lineIndex = styledText.getLineIndex(yCoordinate); 

이 잘 작동 : 나는 또한이 좌표 아래에있는 라인 수를 확인하기 위해 사용하려는 y 좌표가 있습니다. 따라서 나는 줄 접기를 고려하는 방법을 찾고 있는데, 접힌 줄을 다시 돌려서 수동으로 lineIndex을 조정할 수 있습니다. 내 옵션은 무엇입니까? 일부는 당신이 할 수있는 ITextEditor 인 경우 IEditorReference에서

답변

2

당신은 IEditorPart

IEditorPart part = ref.getEditor(false); 

를 얻을 수 있습니다 다음

ITextEditor editor = (ITextEditor)part; 

IDocumentProvider provider = editor.getDocumentProvider(); 

IEditorInput input = editor.getEditorInput(); 

IDocument document = provider.getDocument(input); 

int line = document.getLineOfOffset(offset in text); 

'텍스트의 오프셋 (offset)'로부터 문자의 수 문서의 시작. StyledText에는이 값을 얻기위한 여러 가지 메소드가 있습니다 (예 : getOffsetAtLocation(Point)).

+0

흠, 좋아 보이지만 "텍스트 오프셋"이란 무엇입니까? –

+0

오프셋에 대한 일부 정보를 추가했습니다. –