0
현재 줄의 시작 부분에있는 텍스트를 마우스 커서로 가져 오려고합니다.이클립스 편집기에서 이전 줄을 접었을 때 현재 줄의 텍스트를 가져옵니다.
ITextSelection textSelection= (ITextSelection) textEditor.getSelectionProvider().getSelection();
IRegion lineInfo = null;
int offsetCurrentCursor = textSelection.getOffset();
int offsetLine; // THIS IS THE VALUE THAT I WANT
try {
int lineNumber = document.getLineOfOffset(offsetCurrentCursor);
lineInfo = document.getLineInformation(lineNumber);
offsetLine = lineInfo.getOffset();
} catch (BadLocationException e) {
}
StyledText styledText = (StyledText) textEditor.getAdapter(Control.class);
String currentText = "";
if (offsetLine <= offsetCurrentCursor - 1) {
currentText = styledText.getText(offsetLine, offsetCurrentCursor - 1);
}
그러나 일부 이전 선이 붕괴 될 때 방법은 StyledText
의 getText
이 작동하지 않습니다.
또 다른 문제점은 StyledText.setCaretOffset(int offset)
을 사용하여 커서를 이동하려고하고 일부 이전 줄이 접힐 때도 작동하지 않는다는 것입니다.
작동하지만 이제는 StyledText에 또 다른 문제가 있습니다. StyledText.setCaretOffset (int offset)을 사용하여 커서를 움직였습니다. 이제 커서가 올바른 위치로 이동하지 않습니다. IDocument로 할 수 있습니까? 고마워. 나는 IDocument의 문서 api를 보았지만 아무 것도 발견하지 못했습니다. – computered
전환 코드를 제어하는 모델이 추가되었습니다. –