private void addTextIfPossible(int endOffset) { if (endOffset <= myStartOffset) { return; } for (int i = myStartOffset; i < endOffset; i++) { char c = myText.charAt(i); switch (c) { case '\n': myIndentSymbolsToStripAtCurrentLine = myIndentSymbolsToStrip; builder.addText(myStartOffset + myOffsetShift, i + myOffsetShift + 1); myStartOffset = i + 1; break; // Intended fall-through. case ' ': case '\t': if (myIndentSymbolsToStripAtCurrentLine > 0) { myIndentSymbolsToStripAtCurrentLine--; myStartOffset++; continue; } default: myIndentSymbolsToStripAtCurrentLine = 0; } } if (myStartOffset < endOffset) { builder.addText(myStartOffset + myOffsetShift, endOffset + myOffsetShift); myStartOffset = endOffset; } }
private void processBackground(int startOffset, Color background) { if (myBackground == null && background != null && !myDefaultBackground.equals(background)) { addTextIfPossible(startOffset); myBackground = background; builder.addBackground(background); } else if (myBackground != null) { Color c = background == null ? myDefaultBackground : background; if (!myBackground.equals(c)) { addTextIfPossible(startOffset); builder.addBackground(c); myBackground = c; } } }
private void processForeground(int startOffset, Color foreground) { if (myForeground == null && foreground != null) { addTextIfPossible(startOffset); myForeground = foreground; builder.addForeground(foreground); } else if (myForeground != null) { Color c = foreground == null ? myDefaultForeground : foreground; if (!myForeground.equals(c)) { addTextIfPossible(startOffset); builder.addForeground(c); myForeground = c; } } }
private void processFontStyle(int startOffset, int fontStyle) { if (fontStyle != myFontStyle) { addTextIfPossible(startOffset); builder.addFontStyle(fontStyle); myFontStyle = fontStyle; } }
private void processFontFamilyName(int startOffset, String fontName) { String fontFamilyName = FontMapper.getPhysicalFontName(fontName); if (!fontFamilyName.equals(myFontFamilyName)) { addTextIfPossible(startOffset); builder.addFontFamilyName(fontFamilyName); myFontFamilyName = fontFamilyName; } }
@NotNull public SyntaxInfo finish() { return builder.build(); }