com.intellij.openapi.editor.markup.HighlighterTargetArea Java Examples
The following examples show how to use
com.intellij.openapi.editor.markup.HighlighterTargetArea.
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: AbstractRefactoringPanel.java From IntelliJDeodorant with MIT License | 6 votes |
private static void highlightPsiElement(PsiElement psiElement, boolean openInEditor) { if (openInEditor) { EditorHelper.openInEditor(psiElement); } Editor editor = FileEditorManager.getInstance(psiElement.getProject()).getSelectedTextEditor(); if (editor == null) { return; } TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); editor.getMarkupModel().addRangeHighlighter( psiElement.getTextRange().getStartOffset(), psiElement.getTextRange().getEndOffset(), HighlighterLayer.SELECTION, attributes, HighlighterTargetArea.EXACT_RANGE ); }
Example #2
Source File: RangeMarkerTest.java From consulo with Apache License 2.0 | 6 votes |
public void testRangeHighlighterLinesInRangeForLongLinePerformance() throws Exception { final int N = 50000; Document document = EditorFactory.getInstance().createDocument(StringUtil.repeatSymbol('x', 2 * N)); final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true); for (int i=0; i<N-1;i++) { markupModel.addRangeHighlighter(2*i, 2*i+1, 0, null, HighlighterTargetArea.EXACT_RANGE); } markupModel.addRangeHighlighter(N / 2, N / 2 + 1, 0, null, HighlighterTargetArea.LINES_IN_RANGE); PlatformTestUtil.startPerformanceTest("slow highlighters lookup", (int)(N*Math.log(N)/1000), new ThrowableRunnable() { @Override public void run() { List<RangeHighlighterEx> list = new ArrayList<RangeHighlighterEx>(); CommonProcessors.CollectProcessor<RangeHighlighterEx> coll = new CommonProcessors.CollectProcessor<RangeHighlighterEx>(list); for (int i=0; i<N-1;i++) { list.clear(); markupModel.processRangeHighlightersOverlappingWith(2*i, 2*i+1, coll); assertEquals(2, list.size()); // 1 line plus one exact range marker } } }).assertTiming(); }
Example #3
Source File: PersistentRangeHighlighterImpl.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void changedUpdateImpl(@Nonnull DocumentEvent e) { // todo Denis Zhdanov DocumentEventImpl event = (DocumentEventImpl)e; final boolean shouldTranslateViaDiff = isValid() && PersistentRangeMarkerUtil.shouldTranslateViaDiff(event, getStartOffset(), getEndOffset()); boolean wasTranslatedViaDiff = shouldTranslateViaDiff; if (shouldTranslateViaDiff) { wasTranslatedViaDiff = translatedViaDiff(e, event); } if (!wasTranslatedViaDiff) { super.changedUpdateImpl(e); if (isValid()) { myLine = getDocument().getLineNumber(getStartOffset()); int endLine = getDocument().getLineNumber(getEndOffset()); if (endLine != myLine) { setIntervalEnd(getDocument().getLineEndOffset(myLine)); } } } if (isValid() && getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) { setIntervalStart(DocumentUtil.getFirstNonSpaceCharOffset(getDocument(), myLine)); setIntervalEnd(getDocument().getLineEndOffset(myLine)); } }
Example #4
Source File: ImmediatePainter.java From consulo with Apache License 2.0 | 6 votes |
private static void updateAttributes(final DesktopEditorImpl editor, final int offset, final List<? extends TextAttributes> attributes) { final List<RangeHighlighterEx> list1 = new ArrayList<>(); final List<RangeHighlighterEx> list2 = new ArrayList<>(); final Processor<RangeHighlighterEx> processor = highlighter -> { if (!highlighter.isValid()) return true; final boolean isLineHighlighter = highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE; if (isLineHighlighter || highlighter.getStartOffset() < offset) { list1.add(highlighter); } if (isLineHighlighter || highlighter.getEndOffset() > offset || (highlighter.getEndOffset() == offset && (highlighter.isGreedyToRight()))) { list2.add(highlighter); } return true; }; editor.getFilteredDocumentMarkupModel().processRangeHighlightersOverlappingWith(Math.max(0, offset - 1), offset, processor); editor.getMarkupModel().processRangeHighlightersOverlappingWith(Math.max(0, offset - 1), offset, processor); updateAttributes(editor, attributes.get(0), list1); updateAttributes(editor, attributes.get(1), list2); }
Example #5
Source File: EditorHyperlinkSupport.java From consulo with Apache License 2.0 | 6 votes |
private static void linkFollowed(Editor editor, Collection<? extends RangeHighlighter> ranges, final RangeHighlighter link) { MarkupModelEx markupModel = (MarkupModelEx)editor.getMarkupModel(); for (RangeHighlighter range : ranges) { TextAttributes oldAttr = range.getUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES); if (oldAttr != null) { markupModel.setRangeHighlighterAttributes(range, oldAttr); range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, null); } if (range == link) { range.putUserData(OLD_HYPERLINK_TEXT_ATTRIBUTES, range.getTextAttributes()); markupModel.setRangeHighlighterAttributes(range, getFollowedHyperlinkAttributes(range)); } } //refresh highlighter text attributes markupModel.addRangeHighlighter(0, 0, link.getLayer(), getHyperlinkAttributes(), HighlighterTargetArea.EXACT_RANGE).dispose(); }
Example #6
Source File: RecentLocationsDataModel.java From consulo with Apache License 2.0 | 6 votes |
private void applyHighlightingPasses(Project project, final EditorEx editor, Document document, final EditorColorsScheme colorsScheme, final TextRange rangeMarker) { final int startOffset = rangeMarker.getStartOffset(); final int endOffset = rangeMarker.getEndOffset(); DaemonCodeAnalyzerEx.processHighlights(document, project, null, startOffset, endOffset, info -> { if (info.getStartOffset() >= startOffset && info.getEndOffset() <= endOffset) { HighlightSeverity highlightSeverity = info.getSeverity(); if (highlightSeverity == HighlightSeverity.ERROR || highlightSeverity == HighlightSeverity.WARNING || highlightSeverity == HighlightSeverity.WEAK_WARNING || highlightSeverity == HighlightSeverity.GENERIC_SERVER_ERROR_OR_WARNING) { return true; } TextAttributes textAttributes = info.forcedTextAttributes != null ? info.forcedTextAttributes : colorsScheme.getAttributes(info.forcedTextAttributesKey); editor.getMarkupModel().addRangeHighlighter(info.getActualStartOffset() - rangeMarker.getStartOffset(), info.getActualEndOffset() - rangeMarker.getStartOffset(), 1000, textAttributes, HighlighterTargetArea.EXACT_RANGE); return true; } else { return true; } }); }
Example #7
Source File: RecentLocationsRenderer.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private static JComponent setupEditorComponent(@Nonnull EditorEx editor, @Nonnull String text, @Nonnull SpeedSearch speedSearch, @Nonnull EditorColorsScheme colorsScheme, boolean selected) { Iterable<TextRange> ranges = speedSearch.matchingFragments(text); if (ranges != null) { selectSearchResultsInEditor(editor, ranges.iterator()); } else { RecentLocationsAction.clearSelectionInEditor(editor); } editor.setBackgroundColor(getBackgroundColor(colorsScheme, selected)); editor.setBorder(JBUI.Borders.empty(0, 4, 6, 0)); if (EMPTY_FILE_TEXT.equals(editor.getDocument().getText())) { editor.getMarkupModel().addRangeHighlighter(0, EMPTY_FILE_TEXT.length(), HighlighterLayer.SYNTAX, createEmptyTextForegroundTextAttributes(colorsScheme), HighlighterTargetArea.EXACT_RANGE); } return editor.getComponent(); }
Example #8
Source File: ApplyPatchChange.java From consulo with Apache License 2.0 | 6 votes |
private void createStatusHighlighter() { int line1 = myPatchDeletionRange.start; int line2 = myPatchInsertionRange.end; Color color = getStatusColor(); if (isResolved()) { color = ColorUtil.mix(color, myViewer.getPatchEditor().getGutterComponentEx().getBackground(), 0.6f); } String tooltip = getStatusText(); EditorEx patchEditor = myViewer.getPatchEditor(); Document document = patchEditor.getDocument(); MarkupModelEx markupModel = patchEditor.getMarkupModel(); TextRange textRange = DiffUtil.getLinesRange(document, line1, line2); RangeHighlighter highlighter = markupModel.addRangeHighlighter(textRange.getStartOffset(), textRange.getEndOffset(), HighlighterLayer.LAST, null, HighlighterTargetArea.LINES_IN_RANGE); PairConsumer<Editor, MouseEvent> clickHandler = getResultRange() != null ? (e, event) -> myViewer.scrollToChange(this, Side.RIGHT, false) : null; highlighter.setLineMarkerRenderer(LineStatusMarkerRenderer.createRenderer(line1, line2, color, tooltip, clickHandler)); myHighlighters.add(highlighter); }
Example #9
Source File: ApplyPatchChange.java From consulo with Apache License 2.0 | 6 votes |
@Nullable private MyGutterOperation createOperation(@Nonnull OperationType type) { if (isResolved()) return null; EditorEx editor = myViewer.getPatchEditor(); Document document = editor.getDocument(); int line = getPatchRange().start; int offset = line == DiffUtil.getLineCount(document) ? document.getTextLength() : document.getLineStartOffset(line); RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE); return new MyGutterOperation(highlighter, type); }
Example #10
Source File: CtrlMouseHandler.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private HighlightersSet installHighlighterSet(@Nonnull Info info, @Nonnull EditorEx editor, boolean highlighterOnly) { editor.getContentComponent().addKeyListener(myEditorKeyListener); editor.getScrollingModel().addVisibleAreaListener(myVisibleAreaListener); if (info.isNavigatable()) { editor.setCustomCursor(CtrlMouseHandler.class, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } List<RangeHighlighter> highlighters = new ArrayList<>(); if (!highlighterOnly || info.isNavigatable()) { TextAttributes attributes = info.isNavigatable() ? EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR) : new TextAttributes(null, HintUtil.getInformationColor(), null, null, Font.PLAIN); for (TextRange range : info.getRanges()) { TextAttributes attr = NavigationUtil.patchAttributesColor(attributes, range, editor); final RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), HighlighterLayer.HYPERLINK, attr, HighlighterTargetArea.EXACT_RANGE); highlighters.add(highlighter); } } return new HighlightersSet(highlighters, editor, info); }
Example #11
Source File: NavigationUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Patches attributes to be visible under debugger active line */ @SuppressWarnings("UseJBColor") public static TextAttributes patchAttributesColor(TextAttributes attributes, @Nonnull TextRange range, @Nonnull Editor editor) { if (attributes.getForegroundColor() == null && attributes.getEffectColor() == null) return attributes; MarkupModel model = DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false); if (model != null) { if (!((MarkupModelEx)model).processRangeHighlightersOverlappingWith(range.getStartOffset(), range.getEndOffset(), highlighter -> { if (highlighter.isValid() && highlighter.getTargetArea() == HighlighterTargetArea.LINES_IN_RANGE) { TextAttributes textAttributes = highlighter.getTextAttributes(); if (textAttributes != null) { Color color = textAttributes.getBackgroundColor(); return !(color != null && color.getBlue() > 128 && color.getRed() < 128 && color.getGreen() < 128); } } return true; })) { TextAttributes clone = attributes.clone(); clone.setForegroundColor(Color.orange); clone.setEffectColor(Color.orange); return clone; } } return attributes; }
Example #12
Source File: LSPDiagnosticsToMarkers.java From intellij-quarkus with Eclipse Public License 2.0 | 6 votes |
private void createMarkers(Editor editor, Document document, List<Diagnostic> diagnostics) { RangeHighlighter[] rangeHighlighters = new RangeHighlighter[diagnostics.size()]; int index = 0; for(Diagnostic diagnostic : diagnostics) { int startOffset = LSPIJUtils.toOffset(diagnostic.getRange().getStart(), document); int endOffset = LSPIJUtils.toOffset(diagnostic.getRange().getEnd(), document); if (endOffset > document.getLineEndOffset(document.getLineCount() - 1)) { endOffset = document.getLineEndOffset(document.getLineCount() - 1); } int layer = getLayer(diagnostic.getSeverity()); EffectType effectType = getEffectType(diagnostic.getSeverity()); Color color = getColor(diagnostic.getSeverity()); RangeHighlighter rangeHighlighter = editor.getMarkupModel().addRangeHighlighter(startOffset, endOffset, layer, new TextAttributes(editor.getColorsScheme().getDefaultForeground(), editor.getColorsScheme().getDefaultBackground(), color, effectType, Font.PLAIN), HighlighterTargetArea.EXACT_RANGE); rangeHighlighter.setErrorStripeTooltip(diagnostic); rangeHighlighters[index++] = rangeHighlighter; } Map<String, RangeHighlighter[]> allMarkers = getAllMarkers(editor); allMarkers.put(languageServerId, rangeHighlighters); }
Example #13
Source File: MarkupModelWindow.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, int endOffset, int layer, TextAttributes textAttributes, @Nonnull HighlighterTargetArea targetArea, boolean isPersistent, Consumer<? super RangeHighlighterEx> changeAttributesAction) { TextRange hostRange = myDocument.injectedToHost(new ProperTextRange(startOffset, endOffset)); return myHostModel.addRangeHighlighterAndChangeAttributes(hostRange.getStartOffset(), hostRange.getEndOffset(), layer, textAttributes, targetArea, isPersistent, changeAttributesAction); }
Example #14
Source File: RangeMarkerTest.java From consulo with Apache License 2.0 | 5 votes |
public void testRangeHighlightersRecreateBug() throws Exception { Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]"); MarkupModel markupModel = DocumentMarkupModel.forDocument(document, ourProject, true); for (int i=0; i<2; i++) { RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); RangeMarker m2 = markupModel.addRangeHighlighter(2, 7, 0, null, HighlighterTargetArea.EXACT_RANGE); RangeMarker m3 = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); markupModel.removeAllHighlighters(); } }
Example #15
Source File: RangeMarkerTest.java From consulo with Apache License 2.0 | 5 votes |
public void testRangeHighlighterDisposeVsRemoveAllConflict() throws Exception { Document document = EditorFactory.getInstance().createDocument("[xxxxxxxxxxxxxx]"); MarkupModel markupModel = DocumentMarkupModel.forDocument(document, ourProject, true); RangeMarker m = markupModel.addRangeHighlighter(1, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); assertTrue(m.isValid()); markupModel.removeAllHighlighters(); assertFalse(m.isValid()); assertEmpty(markupModel.getAllHighlighters()); m.dispose(); assertFalse(m.isValid()); }
Example #16
Source File: ExtractMethodPanel.java From IntelliJDeodorant with MIT License | 5 votes |
/** * Opens definition of method and highlights statements, which should be extracted. * * @param sourceMethod method from which code is proposed to be extracted into separate method. * @param scope scope of the current project. * @param slice computation slice. */ private static void openDefinition(@Nullable PsiMethod sourceMethod, AnalysisScope scope, ASTSlice slice) { new Task.Backgroundable(scope.getProject(), "Search Definition") { @Override public void run(@NotNull ProgressIndicator indicator) { indicator.setIndeterminate(true); } @Override public void onSuccess() { if (sourceMethod != null) { Set<SmartPsiElementPointer<PsiElement>> statements = slice.getSliceStatements(); PsiStatement psiStatement = (PsiStatement) statements.iterator().next().getElement(); if (psiStatement != null && psiStatement.isValid()) { EditorHelper.openInEditor(psiStatement); Editor editor = FileEditorManager.getInstance(sourceMethod.getProject()).getSelectedTextEditor(); if (editor != null) { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); editor.getMarkupModel().removeAllHighlighters(); statements.stream() .filter(statement -> statement.getElement() != null) .forEach(statement -> editor.getMarkupModel().addRangeHighlighter(statement.getElement().getTextRange().getStartOffset(), statement.getElement().getTextRange().getEndOffset(), HighlighterLayer.SELECTION, attributes, HighlighterTargetArea.EXACT_RANGE)); } } } } }.queue(); }
Example #17
Source File: RangeMarkerTest.java From consulo with Apache License 2.0 | 5 votes |
public void testRangeHighlighterIteratorOrder() throws Exception { Document document = EditorFactory.getInstance().createDocument("1234567890"); final MarkupModelEx markupModel = (MarkupModelEx)DocumentMarkupModel.forDocument(document, ourProject, true); RangeHighlighter exact = markupModel.addRangeHighlighter(3, 6, 0, null, HighlighterTargetArea.EXACT_RANGE); RangeHighlighter line = markupModel.addRangeHighlighter(4, 5, 0, null, HighlighterTargetArea.LINES_IN_RANGE); List<RangeHighlighter> list = new ArrayList<RangeHighlighter>(); markupModel.processRangeHighlightersOverlappingWith(2, 9, new CommonProcessors.CollectProcessor<RangeHighlighter>(list)); assertEquals(Arrays.asList(line, exact), list); }
Example #18
Source File: EditorFilteringMarkupModelEx.java From consulo with Apache License 2.0 | 5 votes |
@Override @Nonnull public RangeHighlighterEx addRangeHighlighterAndChangeAttributes(int startOffset, int endOffset, int layer, TextAttributes textAttributes, @Nonnull HighlighterTargetArea targetArea, boolean isPersistent, Consumer<? super RangeHighlighterEx> changeAttributesAction) { return myDelegate.addRangeHighlighterAndChangeAttributes(startOffset, endOffset, layer, textAttributes, targetArea, isPersistent, changeAttributesAction); }
Example #19
Source File: HighlightUtils.java From CppTools with Apache License 2.0 | 5 votes |
static RangeHighlighter createRangeMarker(Editor editor, final int rangeOffset, final int rangeOffset2, final int index, TextAttributes attrs) { RangeHighlighter rangeHighlighter = editor.getMarkupModel().addRangeHighlighter( rangeOffset, rangeOffset2, index == PP_SKIPPED_INDEX ? HighlighterLayer.LAST:100, attrs, HighlighterTargetArea.EXACT_RANGE ); if (index == OVERRIDES_INDEX) { rangeHighlighter.setGutterIconRenderer( new MyGutterIconRenderer( IconLoader.getIcon("/gutter/overridingMethod.png"), true ) ); } else if (index == OVERRIDDEN_INDEX) { rangeHighlighter.setGutterIconRenderer( new MyGutterIconRenderer( IconLoader.getIcon("/gutter/overridenMethod.png"), false ) ); } return rangeHighlighter; }
Example #20
Source File: EditorHyperlinkSupport.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private RangeHighlighter createHyperlink(final int highlightStartOffset, final int highlightEndOffset, @Nullable final TextAttributes highlightAttributes, @Nonnull final HyperlinkInfo hyperlinkInfo, @Nullable TextAttributes followedHyperlinkAttributes, int layer) { TextAttributes textAttributes = highlightAttributes != null ? highlightAttributes : getHyperlinkAttributes(); final RangeHighlighter highlighter = myEditor.getMarkupModel().addRangeHighlighter(highlightStartOffset, highlightEndOffset, layer, textAttributes, HighlighterTargetArea.EXACT_RANGE); associateHyperlink(highlighter, hyperlinkInfo, followedHyperlinkAttributes); return highlighter; }
Example #21
Source File: LanguageConsoleBuilder.java From consulo with Apache License 2.0 | 5 votes |
private void addLineSeparatorPainterIfNeed() { if (lineSeparatorPainter != null) { return; } RangeHighlighter highlighter = getHistoryViewer().getMarkupModel().addRangeHighlighter(0, getDocument().getTextLength(), HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.EXACT_RANGE); highlighter.setGreedyToRight(true); highlighter.setCustomRenderer(renderer); lineSeparatorPainter = highlighter; }
Example #22
Source File: EditorTextFieldCellRenderer.java From consulo with Apache License 2.0 | 5 votes |
protected void setTextToEditor(String text) { myEditor.getMarkupModel().removeAllHighlighters(); myEditor.getDocument().setText(text); ((DesktopEditorImpl)myEditor).resetSizes(); myEditor.getHighlighter().setText(text); if (myTextAttributes != null) { myEditor.getMarkupModel().addRangeHighlighter(0, myEditor.getDocument().getTextLength(), HighlighterLayer.ADDITIONAL_SYNTAX, myTextAttributes, HighlighterTargetArea.EXACT_RANGE); } ((DesktopEditorImpl)myEditor).setPaintSelection(mySelected); SelectionModel selectionModel = myEditor.getSelectionModel(); selectionModel.setSelection(0, mySelected ? myEditor.getDocument().getTextLength() : 0); }
Example #23
Source File: RecentLocationsDataModel.java From consulo with Apache License 2.0 | 5 votes |
private void applySyntaxHighlighting(Project project, EditorEx editor, Document document, EditorColorsScheme colorsScheme, TextRange textRange, IdeDocumentHistoryImpl.PlaceInfo placeInfo) { EditorHighlighter editorHighlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(placeInfo.getFile(), colorsScheme, project); editorHighlighter.setEditor(new LightHighlighterClient(document, project)); editorHighlighter.setText(document.getText(TextRange.create(0, textRange.getEndOffset()))); int startOffset = textRange.getStartOffset(); for (HighlighterIterator iterator = editorHighlighter.createIterator(startOffset); !iterator.atEnd() && iterator.getEnd() <= textRange.getEndOffset(); iterator.advance()) { if (iterator.getStart() >= startOffset) { editor.getMarkupModel().addRangeHighlighter(iterator.getStart() - startOffset, iterator.getEnd() - startOffset, 999, iterator.getTextAttributes(), HighlighterTargetArea.EXACT_RANGE); } } }
Example #24
Source File: HighlightData.java From consulo with Apache License 2.0 | 5 votes |
public void addHighlToView(final Editor view, EditorColorsScheme scheme, final Map<TextAttributesKey,String> displayText) { // XXX: Hack if (HighlighterColors.BAD_CHARACTER.equals(myHighlightType)) { return; } final TextAttributes attr = scheme.getAttributes(myHighlightType); if (attr != null) { UIUtil.invokeAndWaitIfNeeded((Runnable)() -> { try { // IDEA-53203: add ERASE_MARKER for manually defined attributes view.getMarkupModel().addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, TextAttributes.ERASE_MARKER, HighlighterTargetArea.EXACT_RANGE); RangeHighlighter highlighter = view.getMarkupModel() .addRangeHighlighter(myStartOffset, myEndOffset, HighlighterLayer.ADDITIONAL_SYNTAX, attr, HighlighterTargetArea.EXACT_RANGE); final Color errorStripeColor = attr.getErrorStripeColor(); highlighter.setErrorStripeMarkColor(errorStripeColor); final String tooltip = displayText.get(myHighlightType); highlighter.setErrorStripeTooltip(tooltip); } catch (Exception e) { throw new RuntimeException(e); } }); } }
Example #25
Source File: TemplateState.java From consulo with Apache License 2.0 | 5 votes |
private RangeHighlighter getSegmentHighlighter(int segmentNumber, boolean isSelected, boolean isEnd) { final TextAttributes lvAttr = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.LIVE_TEMPLATE_ATTRIBUTES); TextAttributes attributes = isSelected ? lvAttr : new TextAttributes(); TextAttributes endAttributes = new TextAttributes(); int start = mySegments.getSegmentStart(segmentNumber); int end = mySegments.getSegmentEnd(segmentNumber); RangeHighlighter segmentHighlighter = myEditor.getMarkupModel() .addRangeHighlighter(start, end, HighlighterLayer.LAST + 1, isEnd ? endAttributes : attributes, HighlighterTargetArea.EXACT_RANGE); segmentHighlighter.setGreedyToLeft(true); segmentHighlighter.setGreedyToRight(true); return segmentHighlighter; }
Example #26
Source File: AbstractValueHint.java From consulo with Apache License 2.0 | 5 votes |
public void invokeHint(Runnable hideRunnable) { myHideRunnable = hideRunnable; if (!canShowHint()) { hideHint(); return; } if (myType == ValueHintType.MOUSE_ALT_OVER_HINT) { EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme(); TextAttributes attributes = scheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR); attributes = NavigationUtil.patchAttributesColor(attributes, myCurrentRange, myEditor); myHighlighter = myEditor.getMarkupModel().addRangeHighlighter(myCurrentRange.getStartOffset(), myCurrentRange.getEndOffset(), HighlighterLayer.SELECTION + 1, attributes, HighlighterTargetArea.EXACT_RANGE); Component internalComponent = myEditor.getContentComponent(); myStoredCursor = internalComponent.getCursor(); internalComponent.addKeyListener(myEditorKeyListener); internalComponent.setCursor(hintCursor()); if (LOG.isDebugEnabled()) { LOG.debug("internalComponent.setCursor(hintCursor())"); } } else { evaluateAndShowHint(); } }
Example #27
Source File: PersistentRangeHighlighterImpl.java From consulo with Apache License 2.0 | 5 votes |
static PersistentRangeHighlighterImpl create(@Nonnull MarkupModelImpl model, int offset, int layer, @Nonnull HighlighterTargetArea target, @Nullable TextAttributes textAttributes, boolean normalizeStartOffset) { int line = model.getDocument().getLineNumber(offset); int startOffset = normalizeStartOffset ? model.getDocument().getLineStartOffset(line) : offset; return new PersistentRangeHighlighterImpl(model, startOffset, line, layer, target, textAttributes); }
Example #28
Source File: FilteredIndentsHighlightingPass.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 5 votes |
@NotNull private static RangeHighlighter createHighlighter(MarkupModel mm, TextRange range) { final RangeHighlighter highlighter = mm.addRangeHighlighter(range.getStartOffset(), range.getEndOffset(), 0, null, HighlighterTargetArea.EXACT_RANGE); highlighter.setCustomRenderer(RENDERER); return highlighter; }
Example #29
Source File: TextMergeChange.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private MyGutterOperation createOperation(@Nonnull ThreeSide side, @Nonnull OperationType type) { if (isResolved(side)) return null; EditorEx editor = myViewer.getEditor(side); Document document = editor.getDocument(); int line = getStartLine(side); int offset = line == DiffUtil.getLineCount(document) ? document.getTextLength() : document.getLineStartOffset(line); RangeHighlighter highlighter = editor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE); return new MyGutterOperation(side, highlighter, type); }
Example #30
Source File: UnifiedDiffChange.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private MyGutterOperation createOperation(@Nonnull Side sourceSide) { int offset = myEditor.getDocument().getLineStartOffset(myLine1); RangeHighlighter highlighter = myEditor.getMarkupModel().addRangeHighlighter(offset, offset, HighlighterLayer.ADDITIONAL_SYNTAX, null, HighlighterTargetArea.LINES_IN_RANGE); return new MyGutterOperation(sourceSide, highlighter); }