本文整理汇总了Java中com.intellij.openapi.editor.markup.MarkupModel.addLineHighlighter方法的典型用法代码示例。如果您正苦于以下问题:Java MarkupModel.addLineHighlighter方法的具体用法?Java MarkupModel.addLineHighlighter怎么用?Java MarkupModel.addLineHighlighter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.editor.markup.MarkupModel
的用法示例。
在下文中一共展示了MarkupModel.addLineHighlighter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMarkerAtOffset
import com.intellij.openapi.editor.markup.MarkupModel; //导入方法依赖的package包/类
private RangeHighlighter addMarkerAtOffset(int offset, SearchMark mark) {
ApplicationManager.getApplication().assertIsDispatchThread();
final Document document = editor.getDocument();
if (0 <= offset && offset < document.getTextLength()) {
editor.getSettings().setLineMarkerAreaShown(true);
final int line = document.getLineNumber(offset);
final MarkupModel markupModel = editor.getMarkupModel();
RangeHighlighter highlighter;
highlighter = markupModel.addLineHighlighter(line, HighlighterLayer.ADDITIONAL_SYNTAX, null);
highlighter.setGutterIconRenderer(mark);
return highlighter;
} else {
return null;
}
}
示例2: showInEditor
import com.intellij.openapi.editor.markup.MarkupModel; //导入方法依赖的package包/类
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
TextAttributes attributes =
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);
if (state.equals(panel.getEditorState())) {
return;
}
panel.navigateInPreviewEditor(state);
TextAttributes softerAttributes = attributes.clone();
Color backgroundColor = softerAttributes.getBackgroundColor();
if (backgroundColor != null) {
softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor));
}
final Editor editor = panel.getEditor();
if (editor != null) {
final MarkupModel editorModel = editor.getMarkupModel();
final MarkupModel documentModel =
DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
if (line1 != line) {
editorModel.addLineHighlighter(line1,
DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
}
}
}
}
}
示例3: updateHighLights
import com.intellij.openapi.editor.markup.MarkupModel; //导入方法依赖的package包/类
private void updateHighLights(Editor editor) {
MarkupModel markup = editor.getMarkupModel();
for (RangeHighlighter customRangeHighlighter : newCommentHighlighters) {
markup.removeHighlighter(customRangeHighlighter);
}
newCommentHighlighters.clear();
int lineCount = markup.getDocument().getLineCount();
Map<Integer, List<Comment>> lineComments = lineComments(comments);
for (Map.Entry<Integer, List<Comment>> entry : lineComments.entrySet()) {
if (entry.getKey() > lineCount) continue;
boolean hasNewComments = false;
for (Comment comment : entry.getValue()) {
if (comment.id == null) {
hasNewComments = true;
break;
}
}
TextAttributes attributes = new TextAttributes();
if (hasNewComments) attributes.setBackgroundColor(JBColor.PINK);
else attributes.setBackgroundColor(JBColor.YELLOW);
RangeHighlighter rangeHighlighter = markup
.addLineHighlighter(entry.getKey() - 1, HighlighterLayer.SELECTION + (hasNewComments ? 2 : 1), attributes);
rangeHighlighter.setGutterIconRenderer(new CommentGutterIconRenderer());
newCommentHighlighters.add(rangeHighlighter);
}
}
示例4: showInEditor
import com.intellij.openapi.editor.markup.MarkupModel; //导入方法依赖的package包/类
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
TextAttributes attributes =
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);
if (state.equals(panel.getEditorState())) {
return;
}
panel.navigateInPreviewEditor(state);
TextAttributes softerAttributes = attributes.clone();
Color backgroundColor = softerAttributes.getBackgroundColor();
if (backgroundColor != null) {
softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor));
}
final Editor editor = panel.getEditor();
final MarkupModel editorModel = editor.getMarkupModel();
final MarkupModel documentModel =
DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
if (line1 != line) {
editorModel.addLineHighlighter(line1,
DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
}
}
}
}
示例5: showInEditor
import com.intellij.openapi.editor.markup.MarkupModel; //导入方法依赖的package包/类
protected static void showInEditor(DetailView panel, VirtualFile virtualFile, int line) {
TextAttributes attributes =
EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
DetailView.PreviewEditorState state = DetailView.PreviewEditorState.create(virtualFile, line, attributes);
if (state.equals(panel.getEditorState())) {
return;
}
panel.navigateInPreviewEditor(state);
TextAttributes softerAttributes = attributes.clone();
Color backgroundColor = softerAttributes.getBackgroundColor();
if (backgroundColor != null) {
softerAttributes.setBackgroundColor(ColorUtil.softer(backgroundColor));
}
final Editor editor = panel.getEditor();
final MarkupModel editorModel = editor.getMarkupModel();
final MarkupModel documentModel =
DocumentMarkupModel.forDocument(editor.getDocument(), editor.getProject(), false);
for (RangeHighlighter highlighter : documentModel.getAllHighlighters()) {
if (highlighter.getUserData(DebuggerColors.BREAKPOINT_HIGHLIGHTER_KEY) == Boolean.TRUE) {
final int line1 = editor.offsetToLogicalPosition(highlighter.getStartOffset()).line;
if (line1 != line) {
editorModel.addLineHighlighter(line1,
DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER + 1, softerAttributes);
}
}
}
}