@NotNull public static RangeHighlighter highlightMatch(@NotNull Editor editor, int start, int end) { TextAttributes color = editor.getColorsScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); return editor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.ADDITIONAL_SYNTAX + 1, color, HighlighterTargetArea.EXACT_RANGE); }
@NotNull private RangeHighlighter highlightConfirm(@NotNull Editor editor, int start, int end) { TextAttributes color = new TextAttributes( editor.getColorsScheme().getColor(EditorColors.SELECTION_FOREGROUND_COLOR), editor.getColorsScheme().getColor(EditorColors.SELECTION_BACKGROUND_COLOR), null, null, 0 ); return editor.getMarkupModel().addRangeHighlighter(start, end, HighlighterLayer.ADDITIONAL_SYNTAX + 2, color, HighlighterTargetArea.EXACT_RANGE); }
private MyFontMetrics getFontMetrics(Editor editor) { String familyName = UIManager.getFont("Label.font").getFamily(); int size = (int)(Math.max(1, editor.getColorsScheme().getEditorFontSize() - 1) * factor); MyFontMetrics metrics = editor.getUserData(HINT_FONT_METRICS); if (metrics != null && !metrics.isActual(editor, familyName, size)) { metrics = null; } if (metrics == null) { metrics = new MyFontMetrics(editor, familyName, size); editor.putUserData(HINT_FONT_METRICS, metrics); } return metrics; }
private static void highlightSearchLines(@NotNull Editor editor, @NotNull String pattern, int startLine, int endLine, boolean ignoreCase) { final TextAttributes color = editor.getColorsScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); Collection<RangeHighlighter> highlighters = EditorData.getLastHighlights(editor); if (highlighters == null) { highlighters = new ArrayList<>(); EditorData.setLastHighlights(editor, highlighters); } for (TextRange range : findAll(editor, pattern, startLine, endLine, ignoreCase)) { final RangeHighlighter highlighter = highlightMatch(editor, range.getStartOffset(), range.getEndOffset()); highlighter.setErrorStripeMarkColor(color.getBackgroundColor()); highlighter.setErrorStripeTooltip(pattern); highlighters.add(highlighter); } }
@Override protected void textChanged(DocumentEvent e) { final Editor editor = entry.getEditor(); final boolean forwards = !label.getText().equals("?"); if (incHighlighter != null) { editor.getMarkupModel().removeHighlighter(incHighlighter); } final String pattern = entry.getText(); final TextRange range = SearchGroup.findNext(editor, pattern, editor.getCaretModel().getOffset(), true, forwards); if (range != null) { final TextAttributes color = editor.getColorsScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES); incHighlighter = SearchGroup.highlightMatch(editor, range.getStartOffset(), range.getEndOffset()); incHighlighter.setErrorStripeMarkColor(color.getBackgroundColor()); incHighlighter.setErrorStripeTooltip(pattern); MotionGroup.scrollPositionIntoView(editor, editor.offsetToVisualPosition(range.getStartOffset()), true); } } };
textAttributesKey = HighlightBracketPairSettingsPage.getTextAttributesKeyByText(leftBraceText); final TextAttributes textAttributes = editor.getColorsScheme().getAttributes(textAttributesKey);
private void createUIComponents() { final EditorFactory editorFactory = EditorFactory.getInstance(); jsonDocument = editorFactory.createDocument(EMPTY_TEXT); jsonEditor = editorFactory.createEditor(jsonDocument, project, JsonFileType.INSTANCE, false); final EditorSettings settings = jsonEditor.getSettings(); settings.setWhitespacesShown(true); settings.setLineMarkerAreaShown(false); settings.setIndentGuidesShown(false); settings.setLineNumbersShown(true); settings.setFoldingOutlineShown(false); settings.setRightMarginShown(false); settings.setVirtualSpace(false); settings.setWheelFontChangeEnabled(false); settings.setUseSoftWraps(false); settings.setAdditionalColumnsCount(0); settings.setAdditionalLinesCount(1); final EditorColorsScheme colorsScheme = jsonEditor.getColorsScheme(); colorsScheme.setColor(EditorColors.CARET_ROW_COLOR, null); jsonEditor.getContentComponent().setFocusable(true); jsonPanel = (JPanel) jsonEditor.getComponent(); }