Search in sources :

Example 66 with StyleRange

use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.swt by eclipse.

the class TextEditor method handleMouseUp.

void handleMouseUp(Event event) {
    if (link != null) {
        int offset = styledText.getCaretOffset();
        StyleRange range = offset > 0 ? styledText.getStyleRangeAtOffset(offset - 1) : null;
        if (range != null) {
            if (link == range.data) {
                Shell dialog = new Shell(shell);
                dialog.setLayout(new FillLayout());
                // $NON-NLS-1$
                dialog.setText(getResourceString("Browser"));
                Browser browser = new Browser(dialog, SWT.NONE);
                browser.setUrl(link);
                dialog.open();
            }
        }
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) StyleRange(org.eclipse.swt.custom.StyleRange) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) Browser(org.eclipse.swt.browser.Browser)

Example 67 with StyleRange

use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.swt by eclipse.

the class TextEditor method disposeResource.

void disposeResource(Resource resource) {
    if (resource == null)
        return;
    StyleRange[] styles = styledText.getStyleRanges(0, styledText.getCharCount(), false);
    int index = 0;
    while (index < styles.length) {
        if (styles[index].font == resource)
            break;
        if (styles[index].foreground == resource)
            break;
        if (styles[index].background == resource)
            break;
        if (styles[index].strikeoutColor == resource)
            break;
        if (styles[index].underlineColor == resource)
            break;
        if (styles[index].borderColor == resource)
            break;
        index++;
    }
    if (index == styles.length)
        resource.dispose();
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange) Point(org.eclipse.swt.graphics.Point)

Example 68 with StyleRange

use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_custom_StyledText method test_setStyleRangeLorg_eclipse_swt_custom_StyleRange.

@Test
public void test_setStyleRangeLorg_eclipse_swt_custom_StyleRange() {
    StyleRange[] styles;
    String textString = textString();
    /*
		defaultStyles

			(0,48,RED,YELLOW),
			(58,10,BLUE,CYAN),
			(68,10,GREEN,PURPLE)
	*/
    text.setText(textString);
    // No overlap with existing styles
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(48, 5, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 4);
    assertTrue(":1:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":1:", styles[1].equals(getStyle(48, 5, YELLOW, RED)));
    assertTrue(":1:", styles[2].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":1:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap middle of one style - partial
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(10, 10, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 5);
    assertTrue(":2:", styles[0].equals(getStyle(0, 10, RED, YELLOW)));
    assertTrue(":2:", styles[1].equals(getStyle(10, 10, YELLOW, RED)));
    assertTrue(":2:", styles[2].equals(getStyle(20, 28, RED, YELLOW)));
    assertTrue(":2:", styles[3].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":2:", styles[4].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setStyleRange(null);
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 0);
    // Overlap middle of one style - full
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(58, 10, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 3);
    assertTrue(":3:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":3:", styles[1].equals(getStyle(58, 10, YELLOW, RED)));
    assertTrue(":3:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap end of one style
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(38, 15, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 4);
    assertTrue(":4:", styles[0].equals(getStyle(0, 38, RED, YELLOW)));
    assertTrue(":4:", styles[1].equals(getStyle(38, 15, YELLOW, RED)));
    assertTrue(":4:", styles[2].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":4:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap beginning of one style
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(50, 10, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":5:", styles.length == 4);
    assertTrue(":5:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":5:", styles[1].equals(getStyle(50, 10, YELLOW, RED)));
    assertTrue(":5:", styles[2].equals(getStyle(60, 8, BLUE, CYAN)));
    assertTrue(":5:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap complete style
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(48, 20, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":6:", styles.length == 3);
    assertTrue(":6:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":6:", styles[1].equals(getStyle(48, 20, YELLOW, RED)));
    assertTrue(":6:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    text.setText(textString);
    text.setStyleRange(getStyle(0, 48, RED, YELLOW));
    text.setStyleRange(getStyle(48, 20, BLUE, CYAN));
    text.setStyleRange(getStyle(68, 10, GREEN, PURPLE));
    // should be merged with style before it
    text.setStyleRange(getStyle(48, 10, RED, YELLOW));
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 3);
    assertTrue(":1:", styles[0].equals(getStyle(0, 58, RED, YELLOW)));
    assertTrue(":1:", styles[1].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":1:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setText(textString);
    text.setStyleRange(getStyle(0, 10, RED, YELLOW));
    text.setStyleRange(getStyle(15, 10, BLUE, CYAN));
    text.setStyleRange(getStyle(25, 10, GREEN, PURPLE));
    // should be merged with style after it
    text.setStyleRange(getStyle(11, 4, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 3);
    assertTrue(":2:", styles[0].equals(getStyle(0, 10, RED, YELLOW)));
    assertTrue(":2:", styles[1].equals(getStyle(11, 14, BLUE, CYAN)));
    assertTrue(":2:", styles[2].equals(getStyle(25, 10, GREEN, PURPLE)));
    text.setText(textString);
    text.setStyleRange(getStyle(0, 10, RED, YELLOW));
    text.setStyleRange(getStyle(15, 10, BLUE, CYAN));
    text.setStyleRange(getStyle(25, 10, GREEN, PURPLE));
    // should be merged with style after it
    text.setStyleRange(getStyle(5, 15, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 3);
    assertTrue(":3:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":3:", styles[1].equals(getStyle(5, 20, BLUE, CYAN)));
    assertTrue(":3:", styles[2].equals(getStyle(25, 10, GREEN, PURPLE)));
    text.setText("01234567890123456789");
    text.setStyleRange(getStyle(0, 10, RED, YELLOW));
    text.setStyleRange(getStyle(10, 10, BLUE, CYAN));
    text.setStyleRange(getStyle(5, 3, RED, YELLOW));
    text.setStyleRange(getStyle(12, 5, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 2);
    assertTrue(":4:", styles[0].equals(getStyle(0, 10, RED, YELLOW)));
    assertTrue(":4:", styles[1].equals(getStyle(10, 10, BLUE, CYAN)));
    text.setText("0123456789012345");
    text.setStyleRange(getStyle(0, 5, RED, YELLOW));
    text.setStyleRange(getStyle(5, 5, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 5, GREEN, PURPLE));
    text.setStyleRange(getStyle(5, 5, RED, YELLOW));
    text.setStyleRange(getStyle(10, 5, RED, YELLOW));
    styles = text.getStyleRanges();
    assertTrue(":5:", styles.length == 1);
    assertTrue(":5:", styles[0].equals(getStyle(0, 15, RED, YELLOW)));
    text.setText("012345678901234");
    text.setStyleRange(getStyle(0, 5, RED, YELLOW));
    text.setStyleRange(getStyle(10, 5, BLUE, CYAN));
    // should be merged
    text.setStyleRange(getStyle(5, 7, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":6:", styles.length == 2);
    assertTrue(":6:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":6:", styles[1].equals(getStyle(5, 10, BLUE, CYAN)));
    text.setText("123 456 789");
    text.setStyleRange(getStyle(4, 3, BLUE, null));
    text.setStyleRange(getStyle(8, 3, RED, null));
    text.setStyleRange(getStyle(5, 2, BLUE, null));
    styles = text.getStyleRanges();
    assertTrue(":7:", styles.length == 2);
    assertTrue(":7:", styles[0].equals(getStyle(4, 3, BLUE, null)));
    assertTrue(":7:", styles[1].equals(getStyle(8, 3, RED, null)));
    text.setText("123 456 789");
    text.setStyleRange(getStyle(4, 3, BLUE, null));
    text.setStyleRange(getStyle(8, 3, RED, null));
    text.setStyleRange(getStyle(7, 4, BLUE, null));
    styles = text.getStyleRanges();
    assertTrue(":8:", styles.length == 1);
    assertTrue(":8:", styles[0].equals(getStyle(4, 7, BLUE, null)));
    text.setText("123 456 789 ABC DEF");
    text.setStyleRange(getStyle(0, 4, BLUE, null));
    text.setStyleRange(getStyle(4, 4, RED, null));
    text.setStyleRange(getStyle(8, 4, BLUE, null));
    text.setStyleRange(getStyle(12, 4, RED, null));
    text.setStyleRange(getStyle(16, 3, BLUE, null));
    text.setStyleRange(getStyle(5, 14, RED, null));
    styles = text.getStyleRanges();
    assertTrue(":9:", styles.length == 2);
    assertTrue(":9:", styles[0].equals(getStyle(0, 4, BLUE, null)));
    assertTrue(":9:", styles[1].equals(getStyle(4, 15, RED, null)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    text.setText(textString);
    text.setStyleRange(getStyle(0, 48, RED, YELLOW));
    text.setStyleRange(getStyle(48, 20, BLUE, CYAN));
    text.setStyleRange(getStyle(68, 10, GREEN, PURPLE));
    text.setStyleRange(getStyle(38, 20, null, null));
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 3);
    assertTrue(":1:", styles[0].equals(getStyle(0, 38, RED, YELLOW)));
    assertTrue(":1:", styles[1].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":1:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setText(textString);
    int length = textString.length();
    text.setStyleRange(getStyle(0, 48, RED, YELLOW));
    text.setStyleRange(getStyle(48, 20, BLUE, CYAN));
    text.setStyleRange(getStyle(68, 10, GREEN, PURPLE));
    text.setStyleRange(getStyle(0, length, null, null));
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 0);
    text.setText("01234567890123456789");
    text.setStyleRange(getStyle(0, 3, RED, YELLOW));
    text.setStyleRange(getStyle(5, 3, BLUE, CYAN));
    text.setStyleRange(getStyle(9, 8, GREEN, PURPLE));
    text.setStyleRange(getStyle(0, 10, GREEN, PURPLE));
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 1);
    assertTrue(":3:", styles[0].equals(getStyle(0, 17, GREEN, PURPLE)));
    text.setText("0123456789012345");
    text.setStyleRange(getStyle(0, 5, RED, YELLOW));
    text.setStyleRange(getStyle(5, 5, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 5, GREEN, PURPLE));
    text.setStyleRange(getStyle(7, 9, RED, YELLOW));
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 3);
    assertTrue(":4:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":4:", styles[1].equals(getStyle(5, 2, BLUE, CYAN)));
    assertTrue(":4:", styles[2].equals(getStyle(7, 9, RED, YELLOW)));
    text.setText("012345678901234");
    text.setStyleRange(getStyle(0, 5, RED, YELLOW));
    text.setStyleRange(getStyle(10, 5, BLUE, CYAN));
    text.setStyleRange(getStyle(3, 10, GREEN, PURPLE));
    styles = text.getStyleRanges();
    assertTrue(":5:", styles.length == 3);
    assertTrue(":5:", styles[0].equals(getStyle(0, 3, RED, YELLOW)));
    assertTrue(":5:", styles[1].equals(getStyle(3, 10, GREEN, PURPLE)));
    assertTrue(":5:", styles[2].equals(getStyle(13, 2, BLUE, CYAN)));
    text.setText("redgreenblueyellowcyanpurple");
    text.setStyleRange(getStyle(0, 3, RED, null));
    text.setStyleRange(getStyle(3, 5, GREEN, null));
    text.setStyleRange(getStyle(8, 4, BLUE, null));
    text.setStyleRange(getStyle(12, 6, YELLOW, null));
    text.setStyleRange(getStyle(18, 4, CYAN, null));
    text.setStyleRange(getStyle(22, 6, PURPLE, null));
    text.setStyleRange(getStyle(8, 14, null, RED));
    styles = text.getStyleRanges();
    assertTrue(":6:", styles.length == 4);
    assertTrue(":6:", styles[0].equals(getStyle(0, 3, RED, null)));
    assertTrue(":6:", styles[1].equals(getStyle(3, 5, GREEN, null)));
    assertTrue(":6:", styles[2].equals(getStyle(8, 14, null, RED)));
    assertTrue(":6:", styles[3].equals(getStyle(22, 6, PURPLE, null)));
    text.setText("redgreenblueyellowcyanpurple");
    text.setStyleRange(getStyle(0, 3, RED, null));
    text.setStyleRange(getStyle(3, 5, GREEN, null));
    text.setStyleRange(getStyle(8, 4, BLUE, null));
    text.setStyleRange(getStyle(12, 6, YELLOW, null));
    text.setStyleRange(getStyle(18, 4, CYAN, null));
    text.setStyleRange(getStyle(22, 6, PURPLE, null));
    text.setStyleRange(getStyle(0, 28, null, null));
    styles = text.getStyleRanges();
    assertTrue(":7:", styles.length == 0);
    /*
	text.setText("This\r\na\tAnother line.");
	text.setStyleRange(getStyle(3,3,BLUE,null));
	text.setStyleRange(getStyle(7,8,BLUE,null));
	text.setStyleRange(getStyle(6,1,BLUE,null));
	StyledTextEvent event = new StyledTextEvent();
	event.detail = 6;
	event.text = "a\tAnother line.";
	text.notifyListener(ST.LineGetStyle, event);
	assertTrue(":8:", event.styles[0].equals(getStyle(3,4,BLUE,null)));
*/
    text.setText("123 456 789");
    text.setStyleRange(getStyle(4, 3, BLUE, null));
    text.setStyleRange(getStyle(8, 3, RED, null));
    text.setStyleRange(getStyle(5, 5, BLUE, null));
    styles = text.getStyleRanges();
    assertTrue(":9:", styles.length == 2);
    assertTrue(":9:", styles[0].equals(getStyle(4, 6, BLUE, null)));
    assertTrue(":9:", styles[1].equals(getStyle(10, 1, RED, null)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    textString = textString();
    text.setText(textString);
    text.setStyleRange(getStyle(0, 48, RED, YELLOW));
    text.setStyleRange(getStyle(48, 20, BLUE, CYAN));
    text.setStyleRange(getStyle(68, 10, GREEN, PURPLE));
    // should be merged with style before it
    text.setStyleRange(getStyle(48, 10, RED, YELLOW));
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 3);
    assertTrue(":1:", styles[0].equals(getStyle(0, 58, RED, YELLOW)));
    assertTrue(":1:", styles[1].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":1:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setText(textString);
    text.setStyleRange(getStyle(0, 10, RED, YELLOW));
    text.setStyleRange(getStyle(15, 10, BLUE, CYAN));
    text.setStyleRange(getStyle(25, 10, GREEN, PURPLE));
    // should be merged with style after it
    text.setStyleRange(getStyle(11, 4, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 3);
    assertTrue(":2:", styles[0].equals(getStyle(0, 10, RED, YELLOW)));
    assertTrue(":2:", styles[1].equals(getStyle(11, 14, BLUE, CYAN)));
    assertTrue(":2:", styles[2].equals(getStyle(25, 10, GREEN, PURPLE)));
    text.setText(textString);
    text.setStyleRange(getStyle(0, 10, RED, YELLOW));
    text.setStyleRange(getStyle(15, 10, BLUE, CYAN));
    text.setStyleRange(getStyle(25, 10, GREEN, PURPLE));
    // should be merged with style after it
    text.setStyleRange(getStyle(5, 15, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 3);
    assertTrue(":3:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":3:", styles[1].equals(getStyle(5, 20, BLUE, CYAN)));
    assertTrue(":3:", styles[2].equals(getStyle(25, 10, GREEN, PURPLE)));
    text.setText("01234567890123456789");
    text.setStyleRange(getStyle(0, 10, RED, YELLOW));
    text.setStyleRange(getStyle(10, 10, BLUE, CYAN));
    text.setStyleRange(getStyle(5, 3, RED, YELLOW));
    text.setStyleRange(getStyle(12, 5, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 2);
    assertTrue(":4:", styles[0].equals(getStyle(0, 10, RED, YELLOW)));
    assertTrue(":4:", styles[1].equals(getStyle(10, 10, BLUE, CYAN)));
    text.setText("0123456789012345");
    text.setStyleRange(getStyle(0, 5, RED, YELLOW));
    text.setStyleRange(getStyle(5, 5, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 5, GREEN, PURPLE));
    text.setStyleRange(getStyle(5, 5, RED, YELLOW));
    text.setStyleRange(getStyle(10, 5, RED, YELLOW));
    styles = text.getStyleRanges();
    assertTrue(":5:", styles.length == 1);
    assertTrue(":5:", styles[0].equals(getStyle(0, 15, RED, YELLOW)));
    text.setText("012345678901234");
    text.setStyleRange(getStyle(0, 5, RED, YELLOW));
    text.setStyleRange(getStyle(10, 5, BLUE, CYAN));
    // should be merged
    text.setStyleRange(getStyle(5, 7, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":6:", styles.length == 2);
    assertTrue(":6:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":6:", styles[1].equals(getStyle(5, 10, BLUE, CYAN)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    textString = textString();
    /*
		defaultStyles

			(0,48,RED,YELLOW),
			(58,10,BLUE,CYAN),
			(68,10,GREEN,PURPLE)
	*/
    text.setText(textString);
    // End/Beginning overlap
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(38, 25, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 4);
    assertTrue(":1:", styles[0].equals(getStyle(0, 38, RED, YELLOW)));
    assertTrue(":1:", styles[1].equals(getStyle(38, 25, YELLOW, RED)));
    assertTrue(":1:", styles[2].equals(getStyle(63, 5, BLUE, CYAN)));
    assertTrue(":1:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(63, 10, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 4);
    assertTrue(":1:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":1:", styles[1].equals(getStyle(58, 5, BLUE, CYAN)));
    assertTrue(":1:", styles[2].equals(getStyle(63, 10, YELLOW, RED)));
    assertTrue(":1:", styles[3].equals(getStyle(73, 5, GREEN, PURPLE)));
    // Complete overlap
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(0, 78, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 1);
    assertTrue(":2:", styles[0].equals(getStyle(0, 78, YELLOW, RED)));
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(0, 68, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 2);
    assertTrue(":2:", styles[0].equals(getStyle(0, 68, YELLOW, RED)));
    assertTrue(":2:", styles[1].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setStyleRanges(defaultStyles());
    text.setStyleRange(getStyle(58, 20, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 2);
    assertTrue(":2:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":2:", styles[1].equals(getStyle(58, 20, YELLOW, RED)));
    // 1-N complete, beginning
    text.setText("012345678901234567890123456789");
    text.setStyleRanges(new StyleRange[] { getStyle(0, 5, RED, RED), getStyle(5, 5, YELLOW, YELLOW), getStyle(10, 5, CYAN, CYAN), getStyle(15, 5, BLUE, BLUE), getStyle(20, 5, GREEN, GREEN), getStyle(25, 5, PURPLE, PURPLE) });
    text.setStyleRange(getStyle(5, 23, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 3);
    assertTrue(":3:", styles[0].equals(getStyle(0, 5, RED, RED)));
    assertTrue(":3:", styles[1].equals(getStyle(5, 23, YELLOW, RED)));
    assertTrue(":3:", styles[2].equals(getStyle(28, 2, PURPLE, PURPLE)));
    // end, 1-N complete, beginning
    text.setStyleRanges(new StyleRange[] { getStyle(0, 5, RED, RED), getStyle(5, 5, YELLOW, YELLOW), getStyle(10, 5, CYAN, CYAN), getStyle(15, 5, BLUE, BLUE), getStyle(20, 5, GREEN, GREEN), getStyle(25, 5, PURPLE, PURPLE) });
    text.setStyleRange(getStyle(13, 12, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 5);
    assertTrue(":3:", styles[0].equals(getStyle(0, 5, RED, RED)));
    assertTrue(":3:", styles[1].equals(getStyle(5, 5, YELLOW, YELLOW)));
    assertTrue(":3:", styles[2].equals(getStyle(10, 3, CYAN, CYAN)));
    assertTrue(":3:", styles[3].equals(getStyle(13, 12, YELLOW, RED)));
    assertTrue(":3:", styles[4].equals(getStyle(25, 5, PURPLE, PURPLE)));
    text.setText("x/");
    text.setStyleRange(getStyle(0, 2, YELLOW, null));
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 1);
    assertTrue(":4:", styles[0].equals(getStyle(0, 2, YELLOW, null)));
    text.replaceTextRange(2, 0, "/");
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 1);
    assertTrue(":4:", styles[0].equals(getStyle(0, 2, YELLOW, null)));
    text.setStyleRange(getStyle(0, 1, YELLOW, null));
    assertTrue(":4:", styles.length == 1);
    assertTrue(":4:", styles[0].equals(getStyle(0, 2, YELLOW, null)));
    text.setStyleRange(getStyle(1, 2, RED, null));
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 2);
    assertTrue(":4:", styles[0].equals(getStyle(0, 1, YELLOW, null)));
    assertTrue(":4:", styles[1].equals(getStyle(1, 2, RED, null)));
    text.setText("xxx/");
    text.setStyleRange(getStyle(0, 2, RED, null));
    text.setStyleRange(getStyle(2, 2, YELLOW, null));
    styles = text.getStyleRanges();
    assertTrue(":4a:", styles.length == 2);
    assertTrue(":4a:", styles[0].equals(getStyle(0, 2, RED, null)));
    assertTrue(":4a:", styles[1].equals(getStyle(2, 2, YELLOW, null)));
    text.replaceTextRange(4, 0, "/");
    styles = text.getStyleRanges();
    assertTrue(":4a:", styles.length == 2);
    assertTrue(":4a:", styles[0].equals(getStyle(0, 2, RED, null)));
    assertTrue(":4a:", styles[1].equals(getStyle(2, 2, YELLOW, null)));
    text.setStyleRange(getStyle(2, 1, YELLOW, null));
    assertTrue(":4a:", styles.length == 2);
    assertTrue(":4a:", styles[0].equals(getStyle(0, 2, RED, null)));
    assertTrue(":4a:", styles[1].equals(getStyle(2, 2, YELLOW, null)));
    text.setStyleRange(getStyle(3, 2, RED, null));
    styles = text.getStyleRanges();
    assertTrue(":4a:", styles.length == 3);
    assertTrue(":4a:", styles[0].equals(getStyle(0, 2, RED, null)));
    assertTrue(":4a:", styles[1].equals(getStyle(2, 1, YELLOW, null)));
    assertTrue(":4a:", styles[2].equals(getStyle(3, 2, RED, null)));
    text.setText("xxx/");
    text.setStyleRange(getStyle(0, 2, RED, null));
    text.setStyleRange(getStyle(2, 2, YELLOW, null));
    text.replaceTextRange(4, 0, "/");
    styles = text.getStyleRanges();
    text.setStyleRange(getStyle(2, 1, YELLOW, null));
    text.setStyleRange(getStyle(2, 3, RED, null));
    styles = text.getStyleRanges();
    assertTrue(":4b:", styles.length == 1);
    assertTrue(":4b:", styles[0].equals(getStyle(0, 5, RED, null)));
    text.setText("xxx/");
    text.setStyleRange(getStyle(0, 2, RED, null));
    text.setStyleRange(getStyle(2, 2, YELLOW, null));
    text.replaceTextRange(4, 0, "/");
    styles = text.getStyleRanges();
    text.setStyleRange(getStyle(2, 1, YELLOW, null));
    text.setStyleRange(getStyle(1, 4, YELLOW, null));
    styles = text.getStyleRanges();
    assertTrue(":4c:", styles.length == 2);
    assertTrue(":4c:", styles[0].equals(getStyle(0, 1, RED, null)));
    assertTrue(":4c:", styles[1].equals(getStyle(1, 4, YELLOW, null)));
    text.setText("New\r\n");
    StyleRange style = getStyle(0, 5, null, null);
    style.fontStyle = SWT.BOLD;
    text.setStyleRange(style);
    // styles (0,5,BOLD)
    // "Newa\r\n"
    text.replaceTextRange(3, 0, "a");
    // styles (0,3,BOLD), (4,2,BOLD)
    style = text.getStyleRangeAtOffset(4);
    style.start = 3;
    style.length = 1;
    text.setStyleRange(style);
    // styles (0,6,BOLD)
    // "aNewa\r\n"
    text.replaceTextRange(0, 0, "a");
    // styles (1,6,BOLD)
    style = text.getStyleRangeAtOffset(1);
    style.start = 0;
    style.length = 1;
    text.setStyleRange(style);
    // styles (0,7,BOLD)
    // "Newa\r\n"
    text.replaceTextRange(0, 1, "");
    // styles (0,6,BOLD)
    for (int i = 0; i < 6; i++) {
        style = text.getStyleRangeAtOffset(i);
        assertTrue(":5:", style.fontStyle == SWT.BOLD);
    }
    text.setText("New L 1\r\nNew L 2\r\n");
    style = getStyle(0, 9, null, null);
    style.fontStyle = SWT.BOLD;
    text.setStyleRange(style);
    // styles (0,9,BOLD)
    text.replaceTextRange(7, 0, "a");
    // styles (0,7,BOLD), (8,2,BOLD)
    style = text.getStyleRangeAtOffset(8);
    if (style != null) {
        style.start = 7;
        style.length = 1;
        text.setStyleRange(style);
    }
    // styles (0,10,BOLD)
    text.replaceTextRange(4, 0, "a");
    // styles (0,4,BOLD), (5,6,BOLD)
    style = text.getStyleRangeAtOffset(5);
    if (style != null) {
        style.start = 4;
        style.length = 1;
        text.setStyleRange(style);
    }
    // styles (0,11,BOLD)
    text.replaceTextRange(2, 3, "");
    // styles (0,8,BOLD)
    for (int i = 0; i < 8; i++) {
        style = text.getStyleRangeAtOffset(i);
        assertTrue(":5a:", style.fontStyle == SWT.BOLD);
    }
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    // "01234567890123"
    textString = "1234 1234 1234";
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(5, 2, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":1a:", styles.length == 1);
    assertTrue(":1a:", styles[0].equals(getStyle(5, 4, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(7, 2, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":2a:", styles.length == 1);
    assertTrue(":2a:", styles[0].equals(getStyle(5, 4, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(6, 2, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":3a:", styles.length == 1);
    assertTrue(":3a:", styles[0].equals(getStyle(5, 4, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(3, 4, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":4a:", styles.length == 1);
    assertTrue(":4a:", styles[0].equals(getStyle(3, 6, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(7, 4, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":5a:", styles.length == 1);
    assertTrue(":5a:", styles[0].equals(getStyle(5, 6, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":6a:", styles.length == 1);
    assertTrue(":6a:", styles[0].equals(getStyle(5, 4, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(3, 10, YELLOW, RED));
    styles = text.getStyleRanges();
    assertTrue(":7a:", styles.length == 1);
    assertTrue(":7a:", styles[0].equals(getStyle(3, 10, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(5, 2, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":1b:", styles.length == 2);
    assertTrue(":1b:", styles[0].equals(getStyle(5, 2, BLUE, CYAN)));
    assertTrue(":1b:", styles[1].equals(getStyle(7, 2, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(7, 2, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":2b:", styles.length == 2);
    assertTrue(":2b:", styles[0].equals(getStyle(5, 2, YELLOW, RED)));
    assertTrue(":2b:", styles[1].equals(getStyle(7, 2, BLUE, CYAN)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(6, 2, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":3b:", styles.length == 3);
    assertTrue(":3b:", styles[0].equals(getStyle(5, 1, YELLOW, RED)));
    assertTrue(":3b:", styles[1].equals(getStyle(6, 2, BLUE, CYAN)));
    assertTrue(":3b:", styles[2].equals(getStyle(8, 1, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(3, 4, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":4b:", styles.length == 2);
    assertTrue(":4b:", styles[0].equals(getStyle(3, 4, BLUE, CYAN)));
    assertTrue(":4b:", styles[1].equals(getStyle(7, 2, YELLOW, RED)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(7, 4, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":5b:", styles.length == 2);
    assertTrue(":5b:", styles[0].equals(getStyle(5, 2, YELLOW, RED)));
    assertTrue(":5b:", styles[1].equals(getStyle(7, 4, BLUE, CYAN)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":6b:", styles.length == 1);
    assertTrue(":6b:", styles[0].equals(getStyle(5, 4, BLUE, CYAN)));
    text.setText("1234 1234 1234");
    text.setStyleRange(getStyle(5, 4, YELLOW, RED));
    text.setStyleRange(getStyle(3, 10, BLUE, CYAN));
    styles = text.getStyleRanges();
    assertTrue(":7b:", styles.length == 1);
    assertTrue(":7b:", styles[0].equals(getStyle(3, 10, BLUE, CYAN)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    // "012345678901234567890123"
    String testString = "1234 1234 1234 1234 1234";
    text.setText(testString);
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(12, 2, "");
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 1);
    assertTrue(":1:", styles[0].equals(getStyle(10, 2, YELLOW, RED)));
    text.setText(testString);
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(10, 2, "");
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 1);
    assertTrue(":2:", styles[0].equals(getStyle(10, 2, YELLOW, RED)));
    text.setText(testString);
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(12, 4, "");
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 1);
    assertTrue(":3:", styles[0].equals(getStyle(10, 2, YELLOW, RED)));
    text.setText(testString);
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(8, 4, "");
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 1);
    assertTrue(":4:", styles[0].equals(getStyle(8, 2, YELLOW, RED)));
    text.setText(testString);
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(8, 6, "");
    styles = text.getStyleRanges();
    assertTrue(":5:", styles.length == 0);
    text.setText(testString);
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(10, 6, "");
    styles = text.getStyleRanges();
    assertTrue(":6:", styles.length == 0);
    text.setText(testString);
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(8, 12, "");
    styles = text.getStyleRanges();
    assertTrue(":7:", styles.length == 0);
    // "012345678901234567890123"
    // String testString=	"1234 1234 1234 1234 1234";
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(5, 7, "");
    styles = text.getStyleRanges();
    assertTrue(":8:", styles.length == 1);
    assertTrue(":8:", styles[0].equals(getStyle(5, 2, YELLOW, RED)));
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(7, 7, "");
    styles = text.getStyleRanges();
    assertTrue(":9:", styles.length == 1);
    assertTrue(":9:", styles[0].equals(getStyle(5, 2, BLUE, CYAN)));
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(2, 10, "");
    styles = text.getStyleRanges();
    assertTrue(":10:", styles.length == 1);
    assertTrue(":10:", styles[0].equals(getStyle(2, 2, YELLOW, RED)));
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(7, 9, "");
    styles = text.getStyleRanges();
    assertTrue(":11:", styles.length == 1);
    assertTrue(":11:", styles[0].equals(getStyle(5, 2, BLUE, CYAN)));
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(5, 9, "");
    styles = text.getStyleRanges();
    assertTrue(":12:", styles.length == 0);
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.replaceTextRange(3, 13, "");
    styles = text.getStyleRanges();
    assertTrue(":11:", styles.length == 0);
    // "012345678901234567890123"
    // String testString=	"1234 1234 1234 1234 1234";
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.setStyleRange(getStyle(15, 4, GREEN, PURPLE));
    text.replaceTextRange(7, 12, "");
    styles = text.getStyleRanges();
    assertTrue(":14:", styles.length == 1);
    assertTrue(":14:", styles[0].equals(getStyle(5, 2, BLUE, CYAN)));
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.setStyleRange(getStyle(15, 4, GREEN, PURPLE));
    text.replaceTextRange(5, 12, "");
    styles = text.getStyleRanges();
    assertTrue(":15:", styles.length == 1);
    assertTrue(":15:", styles[0].equals(getStyle(5, 2, GREEN, PURPLE)));
    text.setText(testString);
    text.setStyleRange(getStyle(5, 4, BLUE, CYAN));
    text.setStyleRange(getStyle(10, 4, YELLOW, RED));
    text.setStyleRange(getStyle(15, 4, GREEN, PURPLE));
    text.replaceTextRange(9, 10, "");
    styles = text.getStyleRanges();
    assertTrue(":16:", styles.length == 1);
    assertTrue(":16:", styles[0].equals(getStyle(5, 4, BLUE, CYAN)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    StyleRange style1 = getStyle(0, 0, null, null);
    StyleRange style2 = getStyle(0, 0, RED, YELLOW);
    assertTrue(":1:", !style1.equals(style2));
    assertTrue(":1:", !style1.similarTo(style2));
    assertTrue(":1:", !style2.equals(style1));
    assertTrue(":1:", !style2.similarTo(style1));
    style1 = getStyle(0, 10, RED, YELLOW);
    style2 = getStyle(11, 5, RED, YELLOW);
    assertTrue(":2:", !style1.equals(style2));
    assertTrue(":2:", !style2.equals(style1));
    assertTrue(":2:", style1.similarTo(style2));
    assertTrue(":2:", style2.similarTo(style1));
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) StyleRange(org.eclipse.swt.custom.StyleRange) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 69 with StyleRange

use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_custom_StyledText method getStyle.

// this method must not be public so that the auto-gen tool keeps it
private StyleRange getStyle(int start, int length, RGB fg, RGB bg) {
    StyleRange style = new StyleRange();
    style.start = start;
    style.length = length;
    if (fg != null)
        style.foreground = getColor(fg);
    else
        style.foreground = null;
    if (bg != null)
        style.background = getColor(bg);
    else
        style.background = null;
    return style;
}
Also used : StyleRange(org.eclipse.swt.custom.StyleRange)

Example 70 with StyleRange

use of org.eclipse.swt.custom.StyleRange in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_custom_StyledText method test_replaceStyleRangesII$Lorg_eclipse_swt_custom_StyleRange.

@Test
public void test_replaceStyleRangesII$Lorg_eclipse_swt_custom_StyleRange() {
    StyleRange[] styles;
    String textString = textString();
    /*
		defaultStyles

			(0,48,RED,YELLOW),
			(58,10,BLUE,CYAN),
			(68,10,GREEN,PURPLE)
	*/
    text.setText(textString);
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    text.replaceStyleRanges(0, 78, new StyleRange[] {});
    styles = text.getStyleRanges();
    assertTrue(":0:", styles.length == 0);
    text.setText(textString);
    styles = text.getStyleRanges();
    assertTrue(":0:", styles.length == 0);
    text.replaceStyleRanges(0, 78, new StyleRange[] {});
    styles = text.getStyleRanges();
    assertTrue(":0:", styles.length == 0);
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    styles = text.getStyleRanges();
    assertTrue(":0:", styles.length == 3);
    assertTrue(":0:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":0:", styles[1].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":0:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    // No overlap with existing styles
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    text.replaceStyleRanges(48, 5, new StyleRange[] { getStyle(48, 5, YELLOW, RED) });
    styles = text.getStyleRanges();
    assertTrue(":1:", styles.length == 4);
    assertTrue(":1:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":1:", styles[1].equals(getStyle(48, 5, YELLOW, RED)));
    assertTrue(":1:", styles[2].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":1:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap middle of one style - partial
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    text.replaceStyleRanges(10, 10, new StyleRange[] { getStyle(10, 10, YELLOW, RED) });
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 5);
    assertTrue(":2:", styles[0].equals(getStyle(0, 10, RED, YELLOW)));
    assertTrue(":2:", styles[1].equals(getStyle(10, 10, YELLOW, RED)));
    assertTrue(":2:", styles[2].equals(getStyle(20, 28, RED, YELLOW)));
    assertTrue(":2:", styles[3].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":2:", styles[4].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.replaceStyleRanges(0, text.getCharCount(), new StyleRange[] {});
    styles = text.getStyleRanges();
    assertTrue(":2:", styles.length == 0);
    // Overlap middle of one style - full
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    text.replaceStyleRanges(58, 10, new StyleRange[] { getStyle(58, 10, YELLOW, RED) });
    styles = text.getStyleRanges();
    assertTrue(":3:", styles.length == 3);
    assertTrue(":3:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":3:", styles[1].equals(getStyle(58, 10, YELLOW, RED)));
    assertTrue(":3:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap end of one style
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    text.replaceStyleRanges(38, 15, new StyleRange[] { getStyle(38, 15, YELLOW, RED) });
    styles = text.getStyleRanges();
    assertTrue(":4:", styles.length == 4);
    assertTrue(":4:", styles[0].equals(getStyle(0, 38, RED, YELLOW)));
    assertTrue(":4:", styles[1].equals(getStyle(38, 15, YELLOW, RED)));
    assertTrue(":4:", styles[2].equals(getStyle(58, 10, BLUE, CYAN)));
    assertTrue(":4:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap beginning of one style
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    text.replaceStyleRanges(50, 10, new StyleRange[] { getStyle(50, 10, YELLOW, RED) });
    styles = text.getStyleRanges();
    assertTrue(":5:", styles.length == 4);
    assertTrue(":5:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":5:", styles[1].equals(getStyle(50, 10, YELLOW, RED)));
    assertTrue(":5:", styles[2].equals(getStyle(60, 8, BLUE, CYAN)));
    assertTrue(":5:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    // Overlap complete style
    text.replaceStyleRanges(0, text.getCharCount(), defaultStyles());
    text.replaceStyleRanges(48, 20, new StyleRange[] { getStyle(48, 20, YELLOW, RED) });
    styles = text.getStyleRanges();
    assertTrue(":6:", styles.length == 3);
    assertTrue(":6:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":6:", styles[1].equals(getStyle(48, 20, YELLOW, RED)));
    assertTrue(":6:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    text.setText(textString);
    StyleRange[] ranges = new StyleRange[3];
    ranges[0] = getStyle(0, 48, RED, YELLOW);
    ranges[1] = getStyle(48, 20, BLUE, CYAN);
    ranges[2] = getStyle(68, 10, GREEN, PURPLE);
    text.replaceStyleRanges(0, 78, ranges);
    styles = text.getStyleRanges();
    assertTrue(":7:", styles.length == 3);
    assertTrue(":7:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":7:", styles[1].equals(getStyle(48, 20, BLUE, CYAN)));
    assertTrue(":7:", styles[2].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setText("012345678901234");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 5, RED, YELLOW);
    ranges[1] = getStyle(10, 5, BLUE, CYAN);
    text.replaceStyleRanges(0, 15, ranges);
    styles = text.getStyleRanges();
    assertTrue(":8:", styles.length == 2);
    assertTrue(":8:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":8:", styles[1].equals(getStyle(10, 5, BLUE, CYAN)));
    text.setText("redgreenblueyellowcyanpurple");
    ranges = new StyleRange[4];
    ranges[0] = getStyle(0, 3, RED, null);
    ranges[1] = getStyle(3, 5, GREEN, null);
    ranges[2] = getStyle(8, 4, BLUE, null);
    ranges[3] = getStyle(12, 6, YELLOW, null);
    text.replaceStyleRanges(0, 18, ranges);
    styles = text.getStyleRanges();
    assertTrue(":9:", styles.length == 4);
    assertTrue(":9:", styles[0].equals(getStyle(0, 3, RED, null)));
    assertTrue(":9:", styles[1].equals(getStyle(3, 5, GREEN, null)));
    assertTrue(":9:", styles[2].equals(getStyle(8, 4, BLUE, null)));
    assertTrue(":9:", styles[3].equals(getStyle(12, 6, YELLOW, null)));
    ranges = new StyleRange[2];
    ranges[0] = getStyle(18, 4, CYAN, null);
    ranges[1] = getStyle(22, 6, PURPLE, null);
    text.replaceStyleRanges(18, 10, ranges);
    styles = text.getStyleRanges();
    assertTrue(":9:", styles.length == 6);
    assertTrue(":9:", styles[4].equals(getStyle(18, 4, CYAN, null)));
    assertTrue(":9:", styles[5].equals(getStyle(22, 6, PURPLE, null)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    textString = textString();
    text.setText(textString);
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 10, RED, YELLOW);
    ranges[1] = getStyle(25, 10, GREEN, PURPLE);
    text.replaceStyleRanges(0, 35, ranges);
    ranges = new StyleRange[2];
    ranges[0] = getStyle(5, 15, BLUE, CYAN);
    ranges[1] = getStyle(20, 10, GREEN, PURPLE);
    text.replaceStyleRanges(5, 25, ranges);
    styles = text.getStyleRanges();
    assertTrue(":10:", styles.length == 3);
    assertTrue(":10:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":10:", styles[1].equals(getStyle(5, 15, BLUE, CYAN)));
    assertTrue(":10:", styles[2].equals(getStyle(20, 15, GREEN, PURPLE)));
    text.setText("01234567890123456789");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 10, RED, YELLOW);
    ranges[1] = getStyle(10, 10, BLUE, CYAN);
    text.replaceStyleRanges(0, 20, ranges);
    ranges = new StyleRange[2];
    ranges[0] = getStyle(5, 3, RED, YELLOW);
    ranges[1] = getStyle(12, 5, BLUE, CYAN);
    text.replaceStyleRanges(5, 12, ranges);
    styles = text.getStyleRanges();
    assertTrue(":11:", styles.length == 2);
    assertTrue(":11:", styles[0].equals(getStyle(0, 8, RED, YELLOW)));
    assertTrue(":11:", styles[1].equals(getStyle(12, 8, BLUE, CYAN)));
    text.setText("0123456789012345");
    ranges = new StyleRange[3];
    ranges[0] = getStyle(0, 5, RED, YELLOW);
    ranges[1] = getStyle(5, 5, BLUE, CYAN);
    ranges[2] = getStyle(10, 5, GREEN, PURPLE);
    text.replaceStyleRanges(0, 15, ranges);
    ranges = new StyleRange[2];
    ranges[0] = getStyle(5, 5, RED, YELLOW);
    ranges[1] = getStyle(10, 5, RED, YELLOW);
    text.replaceStyleRanges(5, 10, ranges);
    styles = text.getStyleRanges();
    assertTrue(":12:", styles.length == 1);
    assertTrue(":12:", styles[0].equals(getStyle(0, 15, RED, YELLOW)));
    text.setText("0123456789012345");
    ranges = new StyleRange[1];
    ranges[0] = getStyle(10, 5, GREEN, PURPLE);
    text.replaceStyleRanges(0, 15, ranges);
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 5, RED, YELLOW);
    ranges[1] = getStyle(5, 5, BLUE, CYAN);
    text.replaceStyleRanges(0, 10, ranges);
    styles = text.getStyleRanges();
    assertTrue(":13:", styles.length == 3);
    assertTrue(":13:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":13:", styles[1].equals(getStyle(5, 5, BLUE, CYAN)));
    assertTrue(":13:", styles[2].equals(getStyle(10, 5, GREEN, PURPLE)));
    text.setText("012345678901234");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 5, RED, YELLOW);
    ranges[1] = getStyle(10, 5, BLUE, CYAN);
    text.replaceStyleRanges(0, 15, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(5, 7, BLUE, CYAN);
    text.replaceStyleRanges(5, 7, ranges);
    styles = text.getStyleRanges();
    assertTrue(":14:", styles.length == 2);
    assertTrue(":14:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    assertTrue(":14:", styles[1].equals(getStyle(5, 10, BLUE, CYAN)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    textString = textString();
    /*
		defaultStyles

			(0,48,RED,YELLOW),
			(58,10,BLUE,CYAN),
			(68,10,GREEN,PURPLE)
	*/
    // End/Beginning overlap
    text.setText(textString);
    text.setStyleRanges(defaultStyles());
    ranges = new StyleRange[1];
    ranges[0] = getStyle(38, 25, YELLOW, RED);
    text.replaceStyleRanges(38, 25, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1a:", styles.length == 4);
    assertTrue(":1a:", styles[0].equals(getStyle(0, 38, RED, YELLOW)));
    assertTrue(":1a:", styles[1].equals(getStyle(38, 25, YELLOW, RED)));
    assertTrue(":1a:", styles[2].equals(getStyle(63, 5, BLUE, CYAN)));
    assertTrue(":1a:", styles[3].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setStyleRanges(defaultStyles());
    ranges = new StyleRange[1];
    ranges[0] = getStyle(63, 10, YELLOW, RED);
    text.replaceStyleRanges(63, 10, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1a:", styles.length == 4);
    assertTrue(":1a:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":1a:", styles[1].equals(getStyle(58, 5, BLUE, CYAN)));
    assertTrue(":1a:", styles[2].equals(getStyle(63, 10, YELLOW, RED)));
    assertTrue(":1a:", styles[3].equals(getStyle(73, 5, GREEN, PURPLE)));
    // Complete overlap
    text.setStyleRanges(defaultStyles());
    ranges = new StyleRange[1];
    ranges[0] = getStyle(0, 78, YELLOW, RED);
    text.replaceStyleRanges(0, 78, ranges);
    styles = text.getStyleRanges();
    styles = text.getStyleRanges();
    assertTrue(":2a:", styles.length == 1);
    assertTrue(":2a:", styles[0].equals(getStyle(0, 78, YELLOW, RED)));
    text.setStyleRanges(defaultStyles());
    ranges = new StyleRange[1];
    ranges[0] = getStyle(0, 68, YELLOW, RED);
    text.replaceStyleRanges(0, 68, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2a:", styles.length == 2);
    assertTrue(":2a:", styles[0].equals(getStyle(0, 68, YELLOW, RED)));
    assertTrue(":2a:", styles[1].equals(getStyle(68, 10, GREEN, PURPLE)));
    text.setStyleRanges(defaultStyles());
    ranges = new StyleRange[1];
    ranges[0] = getStyle(58, 20, YELLOW, RED);
    text.replaceStyleRanges(58, 20, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2a:", styles.length == 2);
    assertTrue(":2a:", styles[0].equals(getStyle(0, 48, RED, YELLOW)));
    assertTrue(":2a:", styles[1].equals(getStyle(58, 20, YELLOW, RED)));
    // 1-N complete, beginning
    text.setText("012345678901234567890123456789");
    text.setStyleRanges(new StyleRange[] { getStyle(0, 5, RED, RED), getStyle(5, 5, YELLOW, YELLOW), getStyle(10, 5, CYAN, CYAN), getStyle(15, 5, BLUE, BLUE), getStyle(20, 5, GREEN, GREEN), getStyle(25, 5, PURPLE, PURPLE) });
    ranges = new StyleRange[1];
    ranges[0] = getStyle(5, 23, YELLOW, RED);
    text.replaceStyleRanges(5, 23, ranges);
    styles = text.getStyleRanges();
    assertTrue(":3a:", styles.length == 3);
    assertTrue(":3a:", styles[0].equals(getStyle(0, 5, RED, RED)));
    assertTrue(":3a:", styles[1].equals(getStyle(5, 23, YELLOW, RED)));
    assertTrue(":3a:", styles[2].equals(getStyle(28, 2, PURPLE, PURPLE)));
    // end, 1-N complete, beginning
    text.setStyleRanges(new StyleRange[] { getStyle(0, 5, RED, RED), getStyle(5, 5, YELLOW, YELLOW), getStyle(10, 5, CYAN, CYAN), getStyle(15, 5, BLUE, BLUE), getStyle(20, 5, GREEN, GREEN), getStyle(25, 5, PURPLE, PURPLE) });
    ranges = new StyleRange[1];
    ranges[0] = getStyle(13, 12, YELLOW, RED);
    text.replaceStyleRanges(13, 12, ranges);
    styles = text.getStyleRanges();
    assertTrue(":3a:", styles.length == 5);
    assertTrue(":3a:", styles[0].equals(getStyle(0, 5, RED, RED)));
    assertTrue(":3a:", styles[1].equals(getStyle(5, 5, YELLOW, YELLOW)));
    assertTrue(":3a:", styles[2].equals(getStyle(10, 3, CYAN, CYAN)));
    assertTrue(":3a:", styles[3].equals(getStyle(13, 12, YELLOW, RED)));
    assertTrue(":3a:", styles[4].equals(getStyle(25, 5, PURPLE, PURPLE)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    // insert with no styles
    text.setText("01234567890123456789");
    ranges = new StyleRange[1];
    ranges[0] = getStyle(0, 5, RED, YELLOW);
    text.replaceStyleRanges(0, 10, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1xa:", styles.length == 1);
    assertTrue(":1xa:", styles[0].equals(getStyle(0, 5, RED, YELLOW)));
    // insert before 1 style
    text.setText("01234567890123456789");
    ranges = new StyleRange[1];
    ranges[0] = getStyle(5, 3, RED, YELLOW);
    text.replaceStyleRanges(0, 10, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(0, 3, PURPLE, PURPLE);
    text.replaceStyleRanges(0, 3, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1xb:", styles.length == 2);
    assertTrue(":1xb:", styles[0].equals(getStyle(0, 3, PURPLE, PURPLE)));
    assertTrue(":1xb:", styles[1].equals(getStyle(5, 3, RED, YELLOW)));
    // insert after 1 style
    text.setText("01234567890123456789");
    ranges = new StyleRange[1];
    ranges[0] = getStyle(5, 3, RED, YELLOW);
    text.replaceStyleRanges(0, 10, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(8, 1, PURPLE, PURPLE);
    text.replaceStyleRanges(8, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1xc:", styles.length == 2);
    assertTrue(":1xc:", styles[0].equals(getStyle(5, 3, RED, YELLOW)));
    assertTrue(":1xc:", styles[1].equals(getStyle(8, 1, PURPLE, PURPLE)));
    // insert before 2 styles
    text.setText("01234567890123456789");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(5, 2, RED, YELLOW);
    ranges[1] = getStyle(10, 2, RED, YELLOW);
    text.replaceStyleRanges(0, 20, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(2, 1, PURPLE, PURPLE);
    text.replaceStyleRanges(2, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1xe:", styles.length == 3);
    assertTrue(":1xe:", styles[0].equals(getStyle(2, 1, PURPLE, PURPLE)));
    assertTrue(":1xe:", styles[1].equals(getStyle(5, 2, RED, YELLOW)));
    assertTrue(":1xe:", styles[2].equals(getStyle(10, 2, RED, YELLOW)));
    // insert after 2 styles
    text.setText("01234567890123456789");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(5, 2, RED, YELLOW);
    ranges[1] = getStyle(10, 2, RED, YELLOW);
    text.replaceStyleRanges(0, 20, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(12, 1, PURPLE, PURPLE);
    text.replaceStyleRanges(12, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1xf:", styles.length == 3);
    assertTrue(":1xf:", styles[0].equals(getStyle(5, 2, RED, YELLOW)));
    assertTrue(":1xf:", styles[1].equals(getStyle(10, 2, RED, YELLOW)));
    assertTrue(":1xf:", styles[2].equals(getStyle(12, 1, PURPLE, PURPLE)));
    // insert middle 2 styles
    text.setText("01234567890123456789");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(1, 2, RED, YELLOW);
    ranges[1] = getStyle(12, 2, RED, YELLOW);
    text.replaceStyleRanges(0, 20, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(5, 3, PURPLE, PURPLE);
    text.replaceStyleRanges(5, 3, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1xg:", styles.length == 3);
    assertTrue(":1xg:", styles[0].equals(getStyle(1, 2, RED, YELLOW)));
    assertTrue(":1xg:", styles[1].equals(getStyle(5, 3, PURPLE, PURPLE)));
    assertTrue(":1xg:", styles[2].equals(getStyle(12, 2, RED, YELLOW)));
    // insert middle 3 styles
    text.setText("01234567890123456789");
    ranges = new StyleRange[3];
    ranges[0] = getStyle(1, 3, RED, PURPLE);
    ranges[1] = getStyle(6, 3, PURPLE, YELLOW);
    ranges[2] = getStyle(12, 3, RED, YELLOW);
    text.replaceStyleRanges(0, 20, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(4, 2, PURPLE, PURPLE);
    text.replaceStyleRanges(4, 2, ranges);
    styles = text.getStyleRanges();
    assertTrue(":1xh:", styles.length == 4);
    assertTrue(":1xh:", styles[0].equals(getStyle(1, 3, RED, PURPLE)));
    assertTrue(":1xh:", styles[1].equals(getStyle(4, 2, PURPLE, PURPLE)));
    assertTrue(":1xh:", styles[2].equals(getStyle(6, 3, PURPLE, YELLOW)));
    assertTrue(":1xh:", styles[3].equals(getStyle(12, 3, RED, YELLOW)));
    // reset the environment
    text.dispose();
    text = new StyledText(shell, SWT.NULL);
    setWidget(text);
    text.setText("0");
    ranges = new StyleRange[1];
    ranges[0] = getStyle(0, 1, PURPLE, PURPLE);
    text.replaceStyleRanges(0, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2xa:", styles.length == 1);
    text.setText("01");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 1, PURPLE, PURPLE);
    ranges[1] = getStyle(1, 1, RED, RED);
    text.replaceStyleRanges(0, 2, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(0, 1, YELLOW, YELLOW);
    text.replaceStyleRanges(0, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2xb:", styles.length == 2);
    assertTrue(":2xb:", styles[0].equals(getStyle(0, 1, YELLOW, YELLOW)));
    assertTrue(":2xb:", styles[1].equals(getStyle(1, 1, RED, RED)));
    text.setText("01");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 1, PURPLE, PURPLE);
    ranges[1] = getStyle(1, 1, RED, RED);
    text.replaceStyleRanges(0, 2, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(1, 1, YELLOW, YELLOW);
    text.replaceStyleRanges(1, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2xc:", styles.length == 2);
    assertTrue(":2xc:", styles[0].equals(getStyle(0, 1, PURPLE, PURPLE)));
    assertTrue(":2xc:", styles[1].equals(getStyle(1, 1, YELLOW, YELLOW)));
    text.setText("012");
    ranges = new StyleRange[2];
    ranges[0] = getStyle(0, 1, PURPLE, PURPLE);
    ranges[1] = getStyle(1, 1, RED, RED);
    text.replaceStyleRanges(0, 2, ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(2, 1, YELLOW, YELLOW);
    text.replaceStyleRanges(2, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2xd:", styles.length == 3);
    assertTrue(":2xd:", styles[0].equals(getStyle(0, 1, PURPLE, PURPLE)));
    assertTrue(":2xd:", styles[1].equals(getStyle(1, 1, RED, RED)));
    assertTrue(":2xd:", styles[2].equals(getStyle(2, 1, YELLOW, YELLOW)));
    text.setText("01234");
    ranges = new StyleRange[3];
    ranges[0] = getStyle(1, 1, PURPLE, PURPLE);
    ranges[1] = getStyle(2, 1, RED, RED);
    ranges[2] = getStyle(3, 1, PURPLE, PURPLE);
    text.setStyleRanges(ranges);
    ranges = new StyleRange[1];
    ranges[0] = getStyle(4, 1, YELLOW, YELLOW);
    text.replaceStyleRanges(4, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2xe:", styles.length == 4);
    assertTrue(":2xe:", styles[3].equals(getStyle(4, 1, YELLOW, YELLOW)));
    text.setText("01234");
    ranges = new StyleRange[1];
    ranges[0] = getStyle(4, 1, YELLOW, YELLOW);
    text.replaceStyleRanges(4, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2xf:", styles.length == 1);
    assertTrue(":2xf:", styles[0].equals(getStyle(4, 1, YELLOW, YELLOW)));
    text.setText("01234");
    ranges = new StyleRange[1];
    ranges[0] = getStyle(4, 1, YELLOW, YELLOW);
    text.replaceStyleRanges(4, 1, ranges);
    ranges = new StyleRange[0];
    text.replaceStyleRanges(4, 1, ranges);
    styles = text.getStyleRanges();
    assertTrue(":2xg:", styles.length == 0);
}
Also used : StyledText(org.eclipse.swt.custom.StyledText) StyleRange(org.eclipse.swt.custom.StyleRange) Test(org.junit.Test)

Aggregations

StyleRange (org.eclipse.swt.custom.StyleRange)145 Point (org.eclipse.swt.graphics.Point)52 Test (org.junit.Test)39 ArrayList (java.util.ArrayList)25 Color (org.eclipse.swt.graphics.Color)22 StyledText (org.eclipse.swt.custom.StyledText)13 Font (org.eclipse.swt.graphics.Font)10 GlyphMetrics (org.eclipse.swt.graphics.GlyphMetrics)10 Matcher (java.util.regex.Matcher)9 FontData (org.eclipse.swt.graphics.FontData)8 RGB (org.eclipse.swt.graphics.RGB)8 Rectangle (org.eclipse.swt.graphics.Rectangle)7 IOException (java.io.IOException)5 TextPresentation (org.eclipse.jface.text.TextPresentation)5 Image (org.eclipse.swt.graphics.Image)5 Control (org.eclipse.swt.widgets.Control)5 Position (org.eclipse.jface.text.Position)4 TextStyle (org.eclipse.swt.graphics.TextStyle)4 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3