Example usage for org.eclipse.jface.viewers StyledString insert

List of usage examples for org.eclipse.jface.viewers StyledString insert

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StyledString insert.

Prototype

public StyledString insert(char ch, int offset) throws StringIndexOutOfBoundsException 

Source Link

Document

Inserts the character at the given offset.

Usage

From source file:com.google.dart.tools.ui.internal.util.Strings.java

License:Open Source License

/**
 * Inserts the marks into the given styled string.
 * /*from   w  ww  .j  a v a 2 s . c o m*/
 * @param styledString the styled string
 * @param originalString the original string
 * @param processedString the processed string
 */
private static void insertMarks(StyledString styledString, String originalString, String processedString) {
    int originalLength = originalString.length();
    int processedStringLength = processedString.length();
    char orig = originalLength > 0 ? originalString.charAt(0) : '\0';
    for (int o = 0, p = 0; p < processedStringLength; p++) {
        char processed = processedString.charAt(p);
        if (o < originalLength) {
            if (orig == processed) {
                o++;
                if (o < originalLength) {
                    orig = originalString.charAt(o);
                }
                continue;
            }
        }
        styledString.insert(processed, p);
    }
}

From source file:descent.internal.corext.util.Strings.java

License:Open Source License

/**
 * Inserts the marks into the given styled string.
 * //ww  w. j a  v a 2s . c o m
 * @param styledString the styled string
 * @param originalString the original string
 * @param processedString the processed string
 * @since 3.5
 */
private static void insertMarks(StyledString styledString, String originalString, String processedString) {
    int i = 0;
    char orig = originalString.charAt(0);
    int processedStringLength = originalString.length();
    for (int processedIndex = 0; processedIndex < processedStringLength; processedIndex++) {
        char processed = processedString.charAt(processedIndex);
        if (orig == processed)
            orig = originalString.charAt(++i);
        else
            styledString.insert(processed, processedIndex);
    }
}

From source file:eclipse.spellchecker.etc.Strings.java

License:Open Source License

/**
 * Inserts the marks into the given styled string.
 *
 * @param styledString the styled string
 * @param originalString the original string
 * @param processedString the processed string
 * @since 3.5//www .  ja va  2 s  .c om
 */
private static void insertMarks(StyledString styledString, String originalString, String processedString) {
    int originalLength = originalString.length();
    int processedStringLength = processedString.length();
    char orig = originalLength > 0 ? originalString.charAt(0) : '\0';
    for (int o = 0, p = 0; p < processedStringLength; p++) {
        char processed = processedString.charAt(p);
        if (o < originalLength) {
            if (orig == processed) {
                o++;
                if (o < originalLength)
                    orig = originalString.charAt(o);
                continue;
            }
        }
        styledString.insert(processed, p);
    }
}

From source file:org.eclipse.cdt.internal.ui.callhierarchy.CHLabelProvider.java

License:Open Source License

private StyledString addInitializerDecoration(StyledString label) {
    int i = 0;//from   w  w  w . j  a  v a2s  .  co m
    char[] content = label.toString().toCharArray();
    for (i = 0; i < content.length; i++) {
        char c = content[i];
        if (c == '-' || Character.isWhitespace(c)) {
            break;
        }
    }
    StyledString label2 = new StyledString();
    label2.append("{init "); //$NON-NLS-1$
    i += label2.length();
    label2.append(label);
    label2.insert('}', i++);
    label2.insert('(', i++);
    label2.insert(')', i++);
    label2.setStyle(0, i, null);
    return label2;
}