blob: ad019cdf7a7c34d7ae9f50353cea875f717f5936 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*******************************************************************************
* Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.tcf.ui.views.scriptpad;
import java.util.regex.Pattern;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.LineStyleEvent;
import org.eclipse.swt.custom.LineStyleListener;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.tcf.te.runtime.interfaces.IDisposable;
/**
* Script Pad line style listener implementation.
*/
public class ScriptPadLineStyleListener implements LineStyleListener, IDisposable {
private static final Pattern COMMENT_LINE = Pattern.compile("\\s*#.*"); //$NON-NLS-1$
private static final Pattern CONNECT_LINE = Pattern.compile("\\s*connect\\s+.*"); //$NON-NLS-1$
// private static final Pattern COMMAND_LINE = Pattern.compile("\\s*tcf\\s+(\\w+)\\s+(\\w+)(.*)"); //$NON-NLS-1$
/* (non-Javadoc)
* @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
*/
@Override
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(org.eclipse.swt.custom.LineStyleEvent)
*/
@Override
public void lineGetStyle(LineStyleEvent event) {
String text = event.lineText;
if (text != null && !"".equals(text)) { //$NON-NLS-1$
if (COMMENT_LINE.matcher(text).matches()) {
StyleRange range = new StyleRange(event.lineOffset, text.length(),
event.widget.getDisplay().getSystemColor(SWT.COLOR_DARK_GREEN),
((StyledText)event.widget).getBackground());
event.styles = new StyleRange[] { range };
}
else if (CONNECT_LINE.matcher(text).matches()) {
StyleRange range = new StyleRange(event.lineOffset, text.length(),
event.widget.getDisplay().getSystemColor(SWT.COLOR_GRAY),
((StyledText)event.widget).getBackground(),
SWT.ITALIC);
event.styles = new StyleRange[] { range };
}
}
}
}
|