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);