Separate colors for "Highlight occurrences of selected text" (IJPL-45173)

GitOrigin-RevId: c8ae757fb9ceb3db0a628e68bee990223e29a800
This commit is contained in:
Bas Leijdekkers
2024-06-17 18:11:30 +02:00
committed by intellij-monorepo-bot
parent 18f41b07cb
commit a197326674
5 changed files with 25 additions and 3 deletions

View File

@@ -2181,6 +2181,7 @@ com.intellij.openapi.editor.colors.EditorColors
- sf:FOLDED_TEXT_ATTRIBUTES:com.intellij.openapi.editor.colors.TextAttributesKey
- sf:FOLDED_TEXT_BORDER_COLOR:com.intellij.openapi.editor.colors.ColorKey
- sf:GUTTER_BACKGROUND:com.intellij.openapi.editor.colors.ColorKey
- sf:HIGHLIGHT_SELECTED_TEXT_ATTRIBUTES:com.intellij.openapi.editor.colors.TextAttributesKey
- sf:IDENTIFIER_UNDER_CARET_ATTRIBUTES:com.intellij.openapi.editor.colors.TextAttributesKey
- sf:IGNORED_ADDED_LINES_BORDER_COLOR:com.intellij.openapi.editor.colors.ColorKey
- sf:IGNORED_DELETED_LINES_BORDER_COLOR:com.intellij.openapi.editor.colors.ColorKey

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.openapi.editor.colors;
import com.intellij.lang.Language;
@@ -56,6 +56,7 @@ public interface EditorColors {
TextAttributesKey WRITE_IDENTIFIER_UNDER_CARET_ATTRIBUTES =
TextAttributesKey.createTextAttributesKey("WRITE_IDENTIFIER_UNDER_CARET_ATTRIBUTES");
TextAttributesKey TEXT_SEARCH_RESULT_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("TEXT_SEARCH_RESULT_ATTRIBUTES");
TextAttributesKey HIGHLIGHT_SELECTED_TEXT_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("HIGHLIGHT_SELECTED_TEXT_ATTRIBUTES");
TextAttributesKey FOLDED_TEXT_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("FOLDED_TEXT_ATTRIBUTES");
ColorKey FOLDED_TEXT_BORDER_COLOR = ColorKey.createColorKey("FOLDED_TEXT_BORDER_COLOR");

View File

@@ -19,6 +19,7 @@ options.general.attribute.descriptor.deleted.text=Text//Deleted text
options.general.attribute.descriptor.search.result=Search Results//Search result
options.general.attribute.descriptor.search.result.write.access=Search Results//Search result (write access)
options.general.attribute.descriptor.text.search.result=Search Results//Text search result
options.general.attribute.descriptor.highlight.selected.text=Search Results//Selected text highlighting
options.general.attribute.descriptor.template.variable=Live Templates//Template Variable
options.java.attribute.descriptor.keyword=Keyword

View File

@@ -216,7 +216,7 @@ final class BackgroundHighlighter {
count++;
results.add(result);
offset = result.getEndOffset();
result = findManager.findString(sequence, offset, findModel, null);
result = findManager.findString(sequence, offset, findModel);
}
return results;
})
@@ -230,7 +230,10 @@ final class BackgroundHighlighter {
List<RangeHighlighter> highlighters = new ArrayList<>();
MarkupModel markupModel = editor.getMarkupModel();
for (FindResult result : results) {
highlighters.add(markupModel.addRangeHighlighter(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES, result.getStartOffset(), result.getEndOffset(),
int startOffset = result.getStartOffset();
int endOffset = result.getEndOffset();
if (startOffset == start && endOffset == end) continue;
highlighters.add(markupModel.addRangeHighlighter(EditorColors.HIGHLIGHT_SELECTED_TEXT_ATTRIBUTES, startOffset, endOffset,
HighlightManagerImpl.OCCURRENCE_LAYER, HighlighterTargetArea.EXACT_RANGE));
}
editor.putUserData(SELECTION_HIGHLIGHTS, highlighters);
@@ -349,3 +352,4 @@ final class BackgroundHighlighter {
private static final class HighlightSelectionKey {}
}

View File

@@ -713,6 +713,14 @@
</value>
</option>
<option name="HIGHLIGHT_SELECTED_TEXT_ATTRIBUTES">
<value>
<option name="EFFECT_COLOR" value="808080"/>
<option name="EFFECT_TYPE" value="0"/>
<option name="ERROR_STRIPE_COLOR" value="808080"/>
</value>
</option>
<option name="INJECTED_LANGUAGE_FRAGMENT">
<value>
<option name="BACKGROUND" value="edfced" deuteranopia="ebebeb" protanopia="ebebeb"/>
@@ -2702,6 +2710,13 @@
<option name="ERROR_STRIPE_COLOR" value="61936f" deuteranopia="65a878" protanopia="65a878"/>
</value>
</option>
<option name="HIGHLIGHT_SELECTED_TEXT_ATTRIBUTES">
<value>
<option name="EFFECT_COLOR" value="6F737A"/>
<option name="EFFECT_TYPE" value="0"/>
<option name="ERROR_STRIPE_COLOR" value="6F737A"/>
</value>
</option>
<option name="TODO_DEFAULT_ATTRIBUTES">
<value>
<option name="FOREGROUND" value="A8C023" deuteranopia="bfa222" protanopia="bfa222"/>