Examples of StyleRange


Examples of org.eclipse.swt.custom.StyleRange

        for( int i = 0; i < reservedWords.size(); i++ ) {
            String reservedWord = reservedWords.get(i);

            int index = 0;
            while( (index = text.indexOf(reservedWord, index)) != -1 ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = index;
                int length = reservedWord.length();
                styleRange.length = length;
                styleRange.foreground = darkRedColor;
                styleRange.fontStyle = SWT.BOLD | SWT.ITALIC;
                functionAreaText.setStyleRange(styleRange);
                index = index + length;
            }
        }

        // color important words
        for( int i = 0; i < operationsWords.size(); i++ ) {
            String opWord = operationsWords.get(i);

            int index = 0;
            while( (index = text.indexOf(opWord, index)) != -1 ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = index;
                int length = opWord.length();
                styleRange.length = length;
                styleRange.foreground = darkCyanColor;
                styleRange.fontStyle = SWT.BOLD | SWT.ITALIC;
                functionAreaText.setStyleRange(styleRange);
                index = index + length;
            }
        }

        // brackets
        String[] textSplit = text.split("\\(|\\)|\\{|\\}"); //$NON-NLS-1$
        if (textSplit.length > 1) {
            List<Integer> bracketPositions = new ArrayList<Integer>();
            int position = 0;
            for( int i = 0; i < textSplit.length - 1; i++ ) {
                position = position + textSplit[i].length() + 1;
                bracketPositions.add(position - 1);
            }

            for( Integer pos : bracketPositions ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = pos;
                styleRange.length = 1;
                styleRange.foreground = darkBlueColor;
                styleRange.fontStyle = SWT.BOLD;
                functionAreaText.setStyleRange(styleRange);
            }
        }

        // ;
        textSplit = text.split(";"); //$NON-NLS-1$
        if (textSplit.length > 1) {

            List<Integer> bracketPositions = new ArrayList<Integer>();
            int position = 0;
            for( int i = 0; i < textSplit.length - 1; i++ ) {
                position = position + textSplit[i].length() + 1;
                bracketPositions.add(position - 1);
            }

            for( Integer pos : bracketPositions ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = pos;
                styleRange.length = 1;
                styleRange.foreground = darkGreenColor;
                styleRange.fontStyle = SWT.BOLD;
                functionAreaText.setStyleRange(styleRange);
            }
        }

        textSplit = text.split("\\?"); //$NON-NLS-1$
        if (textSplit.length > 1) {
            List<Integer> bracketPositions = new ArrayList<Integer>();
            int position = 0;
            for( int i = 0; i < textSplit.length - 1; i++ ) {
                position = position + textSplit[i].length() + 1;
                bracketPositions.add(position - 1);
            }

            for( Integer pos : bracketPositions ) {
                StyleRange styleRange = new StyleRange();
                styleRange.start = pos;
                styleRange.length = 1;
                styleRange.foreground = redColor;
                styleRange.fontStyle = SWT.BOLD;
                functionAreaText.setStyleRange(styleRange);
View Full Code Here

Examples of org.eclipse.swt.custom.StyleRange

        while (converterPropertiesKeys.hasMoreElements()) {
            Object key = converterPropertiesKeys.nextElement();
            Object value = converterProperties.get(key);
 
            StyleRange styleRange = new StyleRange();
            styleRange.start = detailPane.getText().length();
            detailPane.append(key + ":\n");
            styleRange.length = key.toString().length() + 1;
            styleRange.fontStyle = SWT.BOLD;
            detailPane.setStyleRange(styleRange);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.