public void printToHistory(@NotNull final List<Pair<String, TextAttributes>> attributedText) { ApplicationManager.getApplication().assertIsDispatchThread(); if (LOG.isDebugEnabled()) { LOG.debug("printToHistory(): " + attributedText.size()); } final boolean scrollToEnd = shouldScrollHistoryToEnd(); final int[] offsets = new int[attributedText.size() + 1]; int i = 0; offsets[i] = 0; final StringBuilder sb = new StringBuilder(); for (final Pair<String, TextAttributes> pair : attributedText) { sb.append(StringUtil.convertLineSeparators(pair.getFirst())); offsets[++i] = sb.length(); } final DocumentEx history = myHistoryViewer.getDocument(); final int oldHistoryLength = history.getTextLength(); appendToHistoryDocument(history, sb.toString()); assert oldHistoryLength + offsets[i] == history.getTextLength() : "unexpected history length " + oldHistoryLength + " " + offsets[i] + " " + history.getTextLength(); LOG.debug("printToHistory(): text processed"); final MarkupModel markupModel = DocumentMarkupModel.forDocument(history, myProject, true); i = 0; for (final Pair<String, TextAttributes> pair : attributedText) { markupModel.addRangeHighlighter( oldHistoryLength + offsets[i], oldHistoryLength + offsets[i + 1], HighlighterLayer.SYNTAX, pair.getSecond(), HighlighterTargetArea.EXACT_RANGE); ++i; } LOG.debug("printToHistory(): markup added"); if (scrollToEnd) { scrollHistoryToEnd(); } queueUiUpdate(scrollToEnd); LOG.debug("printToHistory(): completed"); }
private void highlightTodo(boolean left, List<Pair<TextRange, TextAttributes>> todoRanges) { FragmentedDiffPanelState panelState = (FragmentedDiffPanelState) ((DiffPanelImpl) myHorizontal).getDiffPanelState(); FragmentedDiffPanelState panelState2 = (FragmentedDiffPanelState) ((DiffPanelImpl) myVertical).getDiffPanelState(); for (Pair<TextRange, TextAttributes> range : todoRanges) { TextAttributes second = range.getSecond().clone(); panelState.addRangeHighlighter( left, range.getFirst().getStartOffset(), range.getFirst().getEndOffset(), second); panelState2.addRangeHighlighter( left, range.getFirst().getStartOffset(), range.getFirst().getEndOffset(), second); } }