Search in sources :

Example 66 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project xtext-eclipse by eclipse.

the class TextAttributeProvider method createTextAttribute.

protected TextAttribute createTextAttribute(String id, TextStyle defaultTextStyle) {
    TextStyle textStyle = new TextStyle();
    preferencesAccessor.populateTextStyle(id, textStyle, defaultTextStyle);
    int style = textStyle.getStyle();
    Font fontFromFontData = EditorUtils.fontFromFontData(textStyle.getFontData());
    return new TextAttribute(EditorUtils.colorFromRGB(textStyle.getColor()), EditorUtils.colorFromRGB(textStyle.getBackgroundColor()), style, fontFromFontData);
}
Also used : TextStyle(org.eclipse.xtext.ui.editor.utils.TextStyle) TextAttribute(org.eclipse.jface.text.TextAttribute) Font(org.eclipse.swt.graphics.Font)

Example 67 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project erlide_eclipse by erlang.

the class ErlTokenScanner method getTextAttribute.

// private static final List<String> RESERVED = Arrays.asList(new String[] {
// "after", "begin", "case", "try", "cond", "catch", "andalso",
// "orelse", "end", "fun", "if", "let", "of", "query", "receive",
// "when", "bnot", "not", "div", "rem", "band", "and", "bor", "bxor",
// "bsl", "bsr", "or", "xor", "spec", });
protected TextAttribute getTextAttribute(final TokenHighlight th) {
    final IPreferenceStore store = ErlideUIPlugin.getDefault().getPreferenceStore();
    final HighlightStyle data = th.getStyle(store);
    // load from prefsstore
    return new TextAttribute(fColorManager.getColor(data.getColor()), null, data.getStyles());
}
Also used : HighlightStyle(org.erlide.ui.prefs.HighlightStyle) TextAttribute(org.eclipse.jface.text.TextAttribute) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 68 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project erlide_eclipse by erlang.

the class ErlTokenScanner method fixTokenData.

private void fixTokenData(final Token token, final RGB color, final int style) {
    final TextAttribute attr = (TextAttribute) token.getData();
    final int newStyle = style == -1 ? attr.getStyle() : style;
    final Color newColor = color == null ? attr.getForeground() : fColorManager.getColor(color);
    token.setData(new TextAttribute(newColor, attr.getBackground(), newStyle));
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Color(org.eclipse.swt.graphics.Color)

Example 69 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.

the class XMLConfiguration method getPresentationReconciler.

@Override
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
    PresentationReconciler reconciler = new PresentationReconciler();
    reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getXMLTagScanner());
    reconciler.setDamager(dr, XMLPartitionScanner.XML_TAG);
    reconciler.setRepairer(dr, XMLPartitionScanner.XML_TAG);
    dr = new DefaultDamagerRepairer(getXMLScanner());
    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
    NonRuleBasedDamagerRepairer ndr = new NonRuleBasedDamagerRepairer(new TextAttribute(colorManager.getColor(COLOR_XML_COMMENT)));
    reconciler.setDamager(ndr, XMLPartitionScanner.XML_COMMENT);
    reconciler.setRepairer(ndr, XMLPartitionScanner.XML_COMMENT);
    return reconciler;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) DefaultDamagerRepairer(org.eclipse.jface.text.rules.DefaultDamagerRepairer) PresentationReconciler(org.eclipse.jface.text.presentation.PresentationReconciler) IPresentationReconciler(org.eclipse.jface.text.presentation.IPresentationReconciler)

Example 70 with TextAttribute

use of org.eclipse.jface.text.TextAttribute in project dbeaver by serge-rider.

the class XMLConfiguration method getXMLTagScanner.

XMLTagScanner getXMLTagScanner() {
    XMLTagScanner tagScanner = new XMLTagScanner(colorManager);
    tagScanner.setDefaultReturnToken(new Token(new TextAttribute(colorManager.getColor(COLOR_TAG))));
    return tagScanner;
}
Also used : TextAttribute(org.eclipse.jface.text.TextAttribute) Token(org.eclipse.jface.text.rules.Token)

Aggregations

TextAttribute (org.eclipse.jface.text.TextAttribute)142 Token (org.eclipse.jface.text.rules.Token)45 RGB (org.eclipse.swt.graphics.RGB)37 Color (org.eclipse.swt.graphics.Color)36 IToken (org.eclipse.jface.text.rules.IToken)23 StyleRange (org.eclipse.swt.custom.StyleRange)20 IPresentationReconciler (org.eclipse.jface.text.presentation.IPresentationReconciler)16 PresentationReconciler (org.eclipse.jface.text.presentation.PresentationReconciler)16 DefaultDamagerRepairer (org.eclipse.jface.text.rules.DefaultDamagerRepairer)14 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)12 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)12 IRule (org.eclipse.jface.text.rules.IRule)10 RuleBasedScanner (org.eclipse.jface.text.rules.RuleBasedScanner)9 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)8 ArrayList (java.util.ArrayList)7 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)6 ColorRegistry (org.eclipse.jface.resource.ColorRegistry)5 Document (org.eclipse.jface.text.Document)4 IDocument (org.eclipse.jface.text.IDocument)4 MultiLineRule (org.eclipse.jface.text.rules.MultiLineRule)4