use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.text by eclipse.
the class TextPresentationTest method testMergeStyleRange6.
/**
* Merge range at start of existing non-default range.
*/
@Test
public void testMergeStyleRange6() {
StyleRange range = createStyleRange(47, 49, 1, -1, NORMAL);
fTextPresentation.mergeStyleRange(range);
StyleRange[] expectedAllRanges = new StyleRange[] { createStyleRange(0, 4, NORMAL), createStyleRange(4, 20, BOLD), createStyleRange(20, 47, NORMAL), createStyleRange(47, 49, 1, -1, BOLD), createStyleRange(49, 54, BOLD), createStyleRange(54, 96, NORMAL), createStyleRange(96, 102, BOLD), createStyleRange(102, 140, NORMAL) };
StyleRange[] expectedNonDefaultRanges = new StyleRange[] { createStyleRange(4, 20, BOLD), createStyleRange(47, 49, 1, -1, BOLD), createStyleRange(49, 54, BOLD), createStyleRange(96, 102, BOLD) };
checkRegions(expectedAllRanges, expectedNonDefaultRanges);
}
use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.text by eclipse.
the class TextPresentationTest method testMergeStyleRange4.
/**
* Merge range within existing default range.
*/
@Test
public void testMergeStyleRange4() {
StyleRange range = createStyleRange(22, 24, 1, -1, NORMAL);
fTextPresentation.mergeStyleRange(range);
StyleRange[] expectedAllRanges = new StyleRange[] { createStyleRange(0, 4, NORMAL), createStyleRange(4, 20, BOLD), createStyleRange(20, 22, NORMAL), createStyleRange(22, 24, 1, -1, NORMAL), createStyleRange(24, 47, NORMAL), createStyleRange(47, 54, BOLD), createStyleRange(54, 96, NORMAL), createStyleRange(96, 102, BOLD), createStyleRange(102, 140, NORMAL) };
StyleRange[] expectedNonDefaultRanges = new StyleRange[] { createStyleRange(4, 20, BOLD), createStyleRange(22, 24, 1, -1, NORMAL), createStyleRange(47, 54, BOLD), createStyleRange(96, 102, BOLD) };
checkRegions(expectedAllRanges, expectedNonDefaultRanges);
}
use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.text by eclipse.
the class TextPresentationTest method testClippedRegions2.
@Test
public void testClippedRegions2() {
fTextPresentation.setResultWindow(new Region(30, 70));
StyleRange[] expectedAllRanges = new StyleRange[] { createStyleRange(0, 17, NORMAL), createStyleRange(17, 24, BOLD), createStyleRange(24, 66, NORMAL), createStyleRange(66, 70, BOLD) };
StyleRange[] expectedNonDefaultRanges = new StyleRange[] { createStyleRange(17, 24, BOLD), createStyleRange(66, 70, BOLD) };
checkRegions(expectedAllRanges, expectedNonDefaultRanges);
}
use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.text by eclipse.
the class TextPresentationTest method testMergeStyleRange7.
/**
* Merge range within existing non-default range.
*/
@Test
public void testMergeStyleRange7() {
StyleRange range = createStyleRange(49, 51, 1, -1, NORMAL);
fTextPresentation.mergeStyleRange(range);
StyleRange[] expectedAllRanges = new StyleRange[] { createStyleRange(0, 4, NORMAL), createStyleRange(4, 20, BOLD), createStyleRange(20, 47, NORMAL), createStyleRange(47, 49, BOLD), createStyleRange(49, 51, 1, -1, BOLD), createStyleRange(51, 54, BOLD), createStyleRange(54, 96, NORMAL), createStyleRange(96, 102, BOLD), createStyleRange(102, 140, NORMAL) };
StyleRange[] expectedNonDefaultRanges = new StyleRange[] { createStyleRange(4, 20, BOLD), createStyleRange(47, 49, BOLD), createStyleRange(49, 51, 1, -1, BOLD), createStyleRange(51, 54, BOLD), createStyleRange(96, 102, BOLD) };
checkRegions(expectedAllRanges, expectedNonDefaultRanges);
}
use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.text by eclipse.
the class TextPresentation method getFirstIndexInWindow.
/**
* Returns the index of the first range which overlaps with the
* specified window.
*
* @param window the window to be used for searching
* @return the index of the first range overlapping with the window
*/
private int getFirstIndexInWindow(IRegion window) {
if (window != null) {
int start = window.getOffset();
int i = -1, j = fRanges.size();
while (j - i > 1) {
int k = (i + j) >> 1;
StyleRange r = fRanges.get(k);
if (r.start + r.length > start)
j = k;
else
i = k;
}
return j;
}
return 0;
}
Aggregations