private static List<BidiRun> createFragments( @NotNull EditorView view, int lineStartOffset, int lineEndOffset, @NotNull FontRenderContext fontRenderContext) { if (lineEndOffset <= lineStartOffset) return Collections.emptyList(); EditorImpl editor = view.getEditor(); FontPreferences fontPreferences = editor.getColorsScheme().getFontPreferences(); char[] chars = CharArrayUtil.fromSequence( editor.getDocument().getImmutableCharSequence(), lineStartOffset, lineEndOffset); List<BidiRun> runs = createRuns(editor, chars, lineStartOffset); for (BidiRun run : runs) { IterationState it = new IterationState( editor, lineStartOffset + run.startOffset, lineStartOffset + run.endOffset, false, false, false, false); while (!it.atEnd()) { addFragments( run, chars, it.getStartOffset() - lineStartOffset, it.getEndOffset() - lineStartOffset, it.getMergedAttributes().getFontType(), fontPreferences, fontRenderContext, view.getTabFragment()); it.advance(); } assert !run.fragments.isEmpty(); } return runs; }
private static List<BidiRun> createFragments( @NotNull EditorView view, @NotNull CharSequence text, @JdkConstants.FontStyle int fontStyle, @NotNull FontRenderContext fontRenderContext) { if (text.length() == 0) return Collections.emptyList(); EditorImpl editor = view.getEditor(); FontPreferences fontPreferences = editor.getColorsScheme().getFontPreferences(); char[] chars = CharArrayUtil.fromSequence(text); List<BidiRun> runs = createRuns(editor, chars, -1); for (BidiRun run : runs) { addFragments( run, chars, run.startOffset, run.endOffset, fontStyle, fontPreferences, fontRenderContext, null); assert !run.fragments.isEmpty(); } return runs; }