hi
I need to determine if a given selection is in between a start line and an end line.
I have an ILineRange
and a given offset within the viewport of eclipse. (I need to know, if the selection (from a remote party) was made within the current viewport of the local user. Unfortunately, I cannot get an ILineRange
from the selection. I must rely on getOffset() and getLength()...
Anyone has an idea?
I think there is not a clean solution for this, as the offset (or the characters per line vary (new line lines or a big block of comment).
views:
101answers:
2
+1
A:
Maybe you can check if that org.eclipse.linuxtools.dataviewers.annotatedsourceeditor.STOverviewRuler
class deals with the same kind of problem you have.
Something along the lines of:
if (ANNOTATION_HEIGHT_SCALABLE) {
int numbersOfLines= document.getNumberOfLines(annotationOffset, annotationLength);
// don't count empty trailing lines
IRegion lastLine= document.getLineInformationOfOffset(annotationOffset + annotationLength);
if (lastLine.getOffset() == annotationOffset + annotationLength) {
numbersOfLines -= 2;
hh= (numbersOfLines * size.y) / maxLines + ANNOTATION_HEIGHT;
if (hh < ANNOTATION_HEIGHT)
hh= ANNOTATION_HEIGHT;
} else
hh= ANNOTATION_HEIGHT;
}
fAnnotationHeight= hh;
int startLine= textWidget.getLineAtOffset(annotationOffset - visible.getOffset());
yy= Math.min((startLine * size.y) / maxLines, size.y - hh);
VonC
2010-03-19 16:31:32
+1
A:
The conversion between positions and offsets can be done with IDocument's API (methods around getLine*()). (I'm not sure I fully understood your question, but I do hope that this is helpful information.)
thSoft
2010-03-20 22:49:56