Java Code Examples for org.eclipse.jface.text.TextAttribute#STRIKETHROUGH
The following examples show how to use
org.eclipse.jface.text.TextAttribute#STRIKETHROUGH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NonRuleBasedDamagerRepairer.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Adds style information to the given text presentation. * * @param presentation * the text presentation to be extended * @param offset * the offset of the range to be styled * @param length * the length of the range to be styled * @param attr * the attribute describing the style of the range to be styled */ protected void addRange( TextPresentation presentation, int offset, int length, TextAttribute attr ) { if ( attr != null ) { int style= attr.getStyle(); int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); StyleRange range = new StyleRange( offset, length, attr.getForeground( ), attr.getBackground( ), fontStyle ); range.strikeout = ( attr.getStyle( ) & TextAttribute.STRIKETHROUGH ) != 0; range.underline = ( attr.getStyle( ) & TextAttribute.UNDERLINE ) != 0; range.font= attr.getFont(); presentation.addStyleRange( range ); } }
Example 2
Source File: AbstractEditorConfigScanner.java From editorconfig-eclipse with Apache License 2.0 | 6 votes |
/** * Create a text attribute based on the given color, bold, italic, * strikethrough and underline preference keys. * * @param colorKey * the color preference key * @param boldKey * the bold preference key * @param italicKey * the italic preference key * @param strikethroughKey * the strikethrough preference key * @param underlineKey * the italic preference key * @return the created text attribute */ private TextAttribute createTextAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { Color color = null; if (colorKey != null) color = fColorManager.getColor(colorKey); int style = fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; if (fPreferenceStore.getBoolean(italicKey)) style |= SWT.ITALIC; if (fPreferenceStore.getBoolean(strikethroughKey)) style |= TextAttribute.STRIKETHROUGH; if (fPreferenceStore.getBoolean(underlineKey)) style |= TextAttribute.UNDERLINE; return new TextAttribute(color, null, style); }
Example 3
Source File: AbstractJavaScanner.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** * Create a text attribute based on the given color, bold, italic, strikethrough and underline preference keys. * * @param colorKey the color preference key * @param boldKey the bold preference key * @param italicKey the italic preference key * @param strikethroughKey the strikethrough preference key * @param underlineKey the italic preference key * @return the created text attribute * @since 3.0 */ private TextAttribute createTextAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { Color color= null; if (colorKey != null) color= fColorManager.getColor(colorKey); int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; if (fPreferenceStore.getBoolean(italicKey)) style |= SWT.ITALIC; if (fPreferenceStore.getBoolean(strikethroughKey)) style |= TextAttribute.STRIKETHROUGH; if (fPreferenceStore.getBoolean(underlineKey)) style |= TextAttribute.UNDERLINE; return new TextAttribute(color, null, style); }
Example 4
Source File: DamageRepairer.java From LogViewer with Eclipse Public License 2.0 | 6 votes |
/** * Adds style information to the given text presentation. * * @param presentation the text presentation to be extended * @param offset the offset of the range to be styled * @param length the length of the range to be styled * @param attr the attribute describing the style of the range to be styled * @param wholeLine the boolean switch to declare that the whole line should be colored */ private void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr, boolean wholeLine) { if (attr != null) { int style= attr.getStyle(); int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); if(wholeLine) { try { int line = document.getLineOfOffset(offset); int start = document.getLineOffset(line); length = document.getLineLength(line); offset = start; } catch (BadLocationException e) { } } StyleRange styleRange = new StyleRange(offset,length,attr.getForeground(),attr.getBackground(),fontStyle); styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; styleRange.underline = (style & TextAttribute.UNDERLINE) != 0; presentation.addStyleRange(styleRange); } }
Example 5
Source File: InvasiveThemeHijacker.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void setWSTToken(IEclipsePreferences prefs, Theme theme, String ourEquivalentScope, String prefKey, boolean revertToDefaults) { if (revertToDefaults) { prefs.remove(prefKey); } else { TextAttribute attr = theme.getTextAttribute(ourEquivalentScope); boolean bold = (attr.getStyle() & SWT.BOLD) != 0; boolean italic = (attr.getStyle() & SWT.ITALIC) != 0; boolean strikethrough = (attr.getStyle() & TextAttribute.STRIKETHROUGH) != 0; boolean underline = (attr.getStyle() & TextAttribute.UNDERLINE) != 0; StringBuilder value = new StringBuilder(); value.append(Theme.toHex(attr.getForeground().getRGB())); value.append('|'); value.append(Theme.toHex(attr.getBackground().getRGB())); value.append('|'); value.append(bold); value.append('|'); value.append(italic); value.append('|'); value.append(strikethrough); value.append('|'); value.append(underline); prefs.put(prefKey, value.toString()); } }
Example 6
Source File: TextStyling.java From goclipse with Eclipse Public License 1.0 | 5 votes |
public static TextAttribute createTextAttribute(Color color, boolean isBold, boolean isItalic, boolean isStrikethrough, boolean isUnderline) { int style = SWT.NORMAL; style |= isBold ? SWT.BOLD : 0; style |= isItalic ? SWT.ITALIC : 0; style |= isStrikethrough ? TextAttribute.STRIKETHROUGH : 0; style |= isUnderline ? TextAttribute.UNDERLINE : 0; return new TextAttribute(color, null, style); }
Example 7
Source File: PyDefaultDamagerRepairer.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Adds style information to the given text presentation. * * @param presentation the text presentation to be extended * @param offset the offset of the range to be styled * @param length the length of the range to be styled * @param attr the attribute describing the style of the range to be styled */ protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) { if (attr != null) { int style = attr.getStyle(); int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); StyleRange styleRange = new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), fontStyle); styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; styleRange.underline = (style & TextAttribute.UNDERLINE) != 0; styleRange.font = attr.getFont(); presentation.addStyleRange(styleRange); } }
Example 8
Source File: SemanticHighlightingManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Initialize semantic highlightings. */ private void initializeHighlightings() { fSemanticHighlightings= SemanticHighlightings.getSemanticHighlightings(); fHighlightings= new Highlighting[fSemanticHighlightings.length]; for (int i= 0, n= fSemanticHighlightings.length; i < n; i++) { SemanticHighlighting semanticHighlighting= fSemanticHighlightings[i]; String colorKey= SemanticHighlightings.getColorPreferenceKey(semanticHighlighting); addColor(colorKey); String boldKey= SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting); int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; String italicKey= SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting); if (fPreferenceStore.getBoolean(italicKey)) style |= SWT.ITALIC; String strikethroughKey= SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting); if (fPreferenceStore.getBoolean(strikethroughKey)) style |= TextAttribute.STRIKETHROUGH; String underlineKey= SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting); if (fPreferenceStore.getBoolean(underlineKey)) style |= TextAttribute.UNDERLINE; boolean isEnabled= fPreferenceStore.getBoolean(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting)); fHighlightings[i]= new Highlighting(new TextAttribute(fColorManager.getColor(PreferenceConverter.getColor(fPreferenceStore, colorKey)), null, style), isEnabled); } }
Example 9
Source File: SemanticHighlightingManager.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @return Returns a corresponding style range. */ public StyleRange createStyleRange() { int len= 0; if (fStyle.isEnabled()) len= getLength(); TextAttribute textAttribute= fStyle.getTextAttribute(); int style= textAttribute.getStyle(); int fontStyle= style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); StyleRange styleRange= new StyleRange(getOffset(), len, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle); styleRange.strikeout= (style & TextAttribute.STRIKETHROUGH) != 0; styleRange.underline= (style & TextAttribute.UNDERLINE) != 0; return styleRange; }
Example 10
Source File: ThemeingDamagerRepairer.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
private boolean matchesDefaults(TextAttribute attr) { if (attr == null) { return false; } // Make sure font is just normal int style = attr.getStyle(); int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); if (fontStyle != SWT.NORMAL) { return false; } if ((style & TextAttribute.STRIKETHROUGH) != 0) { return false; } if ((style & TextAttribute.UNDERLINE) != 0) { return false; } // Is FG different? Color fg = attr.getForeground(); if (fg != null && !fg.getRGB().equals(getCurrentTheme().getForeground())) { return false; } // Is BG different? Color bg = attr.getBackground(); if (bg != null && !bg.getRGB().equals(getCurrentTheme().getBackground())) { return false; } return true; }
Example 11
Source File: CSSTokenProvider.java From tm4e with Eclipse Public License 1.0 | 5 votes |
public CSSTokenProvider(InputStream in) { tokenMaps = new HashMap<>(); try { parser = new CSSParser(in); for (IStyle style : parser.getStyles()) { RGB color = style.getColor(); if (color != null) { int s = SWT.NORMAL; if (style.isBold()) { s = s | SWT.BOLD; } if (style.isItalic()) { s = s | SWT.ITALIC; } if (style.isUnderline()) { s = s | TextAttribute.UNDERLINE; } if (style.isStrikeThrough()) { s = s | TextAttribute.STRIKETHROUGH; } tokenMaps.put(style, new Token(new TextAttribute(ColorManager.getInstance().getColor(color), null, s))); } } } catch (Exception e) { e.printStackTrace(); } }
Example 12
Source File: TextAttributeFactory.java From LogViewer with Eclipse Public License 2.0 | 5 votes |
public static TextAttribute getTextAttribute(LogToolRuleDesc ruleDesc) { if (ruleDesc != null) { int style = SWT.NORMAL; if (ruleDesc.isItalic()) style |= SWT.ITALIC; if (ruleDesc.isBold()) style |= SWT.BOLD; if (ruleDesc.isStrikethrough()) style |= TextAttribute.STRIKETHROUGH; if (ruleDesc.isUnderline()) style |= TextAttribute.UNDERLINE; return new TextAttribute(new Color(Display.getDefault(),ruleDesc.getForegroundColor()),new Color(Display.getDefault(),ruleDesc.getBackgroundColor()), style); } return null; }
Example 13
Source File: XStyledString.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
private StyleRange mkSRange(String s, Color fgColor, int style) { //NOTE: new used attributes in StyleRange must be reconcoled in convertToStyledString() StyleRange sr = new StyleRange(); sr.start = sb.length(); sr.length = s.length(); sr.foreground = fgColor; sr.fontStyle = (style & (SWT.BOLD | SWT.ITALIC)); sr.underline = (style & TextAttribute.UNDERLINE) != 0; sr.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; usedStyles |= style; return sr; }
Example 14
Source File: AttributedPosition.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @return Returns a corresponding style range. */ public StyleRange createStyleRange() { int len = getLength(); TextAttribute textAttribute = attribute; int style = textAttribute.getStyle(); int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); StyleRange styleRange = new StyleRange(getOffset(), len, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle); styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; styleRange.underline = (style & TextAttribute.UNDERLINE) != 0; styleRange.font = textAttribute.getFont(); return styleRange; }
Example 15
Source File: StylerFactory.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public void applyStyles(TextStyle textStyle) { textStyle.strikeout = (xtextTextStyle.getStyle() & TextAttribute.STRIKETHROUGH) != 0; textStyle.underline = (xtextTextStyle.getStyle() & TextAttribute.UNDERLINE) != 0; if (xtextTextStyle.getFontData() == null && xtextTextStyle.getStyle() != org.eclipse.xtext.ui.editor.utils.TextStyle.DEFAULT_FONT_STYLE) { FontData fontData = new FontData(); fontData.setStyle(xtextTextStyle.getStyle()); xtextTextStyle.setFontData(fontData); } textStyle.font = fontFromFontData(xtextTextStyle.getFontData()); if (xtextTextStyle.getBackgroundColor() != null) textStyle.background = colorFromRGB(xtextTextStyle.getBackgroundColor()); textStyle.foreground = colorFromRGB(xtextTextStyle.getColor()); }
Example 16
Source File: FormatterPreview.java From xds-ide with Eclipse Public License 1.0 | 4 votes |
private void colorIt() { try { if (pstToTokenMap == null) { initTokenMap(); } // Parse text: Document doc = new Document(styledText.getText()); BuildSettings buildSettings = DefaultBuildSettingsHolder.DefaultBuildSettings; ParserCriticalErrorReporter errorReporter = ParserCriticalErrorReporter.getInstance(); IImportResolver defaultImportResolver = new DefaultImportResolver(buildSettings, errorReporter, null); XdsParser parser = new XdsParser(null, doc.get(), new XdsSettings(buildSettings, xdsSourceType), defaultImportResolver, errorReporter); ModulaAst ast = parser.parseModule(); leafsNodes = new ArrayList<PstLeafNode>(); // Fill Leaf array: collectLeafs(ast); Collections.sort(leafsNodes, new Comparator<PstLeafNode>() { public int compare(PstLeafNode a, PstLeafNode b) { return a.getOffset() - b.getOffset(); } }); // Search matched M2Token for elements in the leaf array and collect style ranges for them: ArrayList<StyleRange> asr = new ArrayList<StyleRange>(); for (PstLeafNode pln : leafsNodes) { ModulaTokens mt = pstToTokenMap.get(pln.getElementType()); if (mt == null) { mt = ModulaTokens.Default; } int style = mt.getToken().getStyleWhenEnabled(); StyleRange sr = new StyleRange(); sr.fontStyle = (style & (SWT.BOLD | SWT.ITALIC)); sr.underline = (style & TextAttribute.UNDERLINE) != 0; sr.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; sr.foreground = new Color(Display.getDefault(), mt.getToken().getRgbWhenEnabled()); sr.background = defBackgroundColor; sr.start = pln.getOffset(); sr.length = pln.getLength(); asr.add(sr); } if (asr.size() > 0) { styledText.setStyleRanges(asr.toArray(new StyleRange[asr.size()])); } } catch (Exception e) {} }
Example 17
Source File: ExpressionSyntaxColoringPage.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Color the text in the sample area according to the current preferences */ void applyStyles( ) { if ( fText == null || fText.isDisposed( ) ) return; try { ITypedRegion[] regions = TextUtilities.computePartitioning( fDocument, IDocumentExtension3.DEFAULT_PARTITIONING, 0, fDocument.getLength( ), true ); if ( regions.length > 0 ) { for ( int i = 0; i < regions.length; i++ ) { ITypedRegion region = regions[i]; String namedStyle = (String) fContextToStyleMap.get( region.getType( ) ); if ( namedStyle == null ) continue; TextAttribute attribute = getAttributeFor( namedStyle ); if ( attribute == null ) continue; int fontStyle = attribute.getStyle( ) & ( SWT.ITALIC | SWT.BOLD | SWT.NORMAL ); StyleRange style = new StyleRange( region.getOffset( ), region.getLength( ), attribute.getForeground( ), attribute.getBackground( ), fontStyle ); style.strikeout = ( attribute.getStyle( ) & TextAttribute.STRIKETHROUGH ) != 0; style.underline = ( attribute.getStyle( ) & TextAttribute.UNDERLINE ) != 0; style.font = attribute.getFont( ); fText.setStyleRange( style ); } } } catch ( BadLocationException e ) { ExceptionHandler.handle( e ); } }
Example 18
Source File: AbstractSyntaxColoringTest.java From dsl-devkit with Eclipse Public License 1.0 | 3 votes |
/** * Creates a {@link StyleRange} from the given parameters. * * @param offset * the offset * @param length * the length of the range * @param textAttribute * the {@link TextAttribute} * @return a {@link StyleRange} from the given parameters */ public static StyleRange createStyleRange(final int offset, final int length, final TextAttribute textAttribute) { int style = textAttribute.getStyle(); int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); StyleRange styleRange = new StyleRange(offset, length, textAttribute.getForeground(), textAttribute.getBackground(), fontStyle); styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; styleRange.underline = (style & TextAttribute.UNDERLINE) != 0; styleRange.font = textAttribute.getFont(); return styleRange; }
Example 19
Source File: TMPresentationReconciler.java From tm4e with Eclipse Public License 1.0 | 3 votes |
/** * Adds style information to the given text presentation. * * @param presentation * the text presentation to be extended * @param offset * the offset of the range to be styled * @param length * the length of the range to be styled * @param attr * the attribute describing the style of the range to be styled * @param lastLineStyleRanges */ protected void addRange(TextPresentation presentation, int offset, int length, TextAttribute attr) { if (attr != null) { int style = attr.getStyle(); int fontStyle = style & (SWT.ITALIC | SWT.BOLD | SWT.NORMAL); StyleRange styleRange = new StyleRange(offset, length, attr.getForeground(), attr.getBackground(), fontStyle); styleRange.strikeout = (style & TextAttribute.STRIKETHROUGH) != 0; styleRange.underline = (style & TextAttribute.UNDERLINE) != 0; styleRange.font = attr.getFont(); presentation.addStyleRange(styleRange); } }