mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ignore editor background color when rendering usages (for dark themes)
This commit is contained in:
@@ -445,7 +445,7 @@ public class MigrationPanel extends JPanel implements Disposable {
|
||||
final UsagePresentation presentation = UsageInfoToUsageConverter.convert(new UsageInfoToUsageConverter.TargetElementsDescriptor(typeElement), new UsageInfo(typeElement)).getPresentation();
|
||||
boolean isPrefix = true; //skip usage position
|
||||
for (TextChunk chunk : presentation.getText()) {
|
||||
if (!isPrefix) append(chunk.getText(), patchAttrs(usageInfo, SimpleTextAttributes.fromTextAttributes(chunk.getAttributes())));
|
||||
if (!isPrefix) append(chunk.getText(), patchAttrs(usageInfo, chunk.getSimpleAttributesIgnoreBackground()));
|
||||
isPrefix = false;
|
||||
}
|
||||
setIcon(presentation.getIcon());
|
||||
|
||||
@@ -103,7 +103,7 @@ public class SliceLeafValueRootNode extends SliceNode implements MyColoredTreeCe
|
||||
false, result);
|
||||
|
||||
for (TextChunk chunk : result) {
|
||||
renderer.append(chunk.getText(), SimpleTextAttributes.fromTextAttributes(chunk.getAttributes()));
|
||||
renderer.append(chunk.getText(), chunk.getSimpleAttributesIgnoreBackground());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,10 +63,9 @@ public class SliceUsageCellRenderer extends ColoredTreeCellRenderer {
|
||||
|
||||
TextChunk[] text = sliceUsage.getPresentation().getText();
|
||||
for (TextChunk textChunk : text) {
|
||||
SimpleTextAttributes attributes = SimpleTextAttributes.fromTextAttributes(textChunk.getAttributes());
|
||||
SimpleTextAttributes attributes = textChunk.getSimpleAttributesIgnoreBackground();
|
||||
if (isForcedLeaf) {
|
||||
attributes = attributes.derive(attributes.getStyle(), Color.LIGHT_GRAY, attributes.getBgColor(), attributes.getWaveColor());
|
||||
//attributes = attributes.derive(SimpleTextAttributes.STYLE_UNDERLINE, attributes.getBgColor(), attributes.getBgColor(), attributes.getWaveColor());
|
||||
}
|
||||
append(textChunk.getText(), attributes);
|
||||
}
|
||||
|
||||
@@ -94,14 +94,14 @@ class ShowUsagesTableCellRenderer implements TableCellRenderer {
|
||||
if (text.length != 0) {
|
||||
SimpleTextAttributes attributes = isSelected ?
|
||||
new SimpleTextAttributes(bg, fg, fg, SimpleTextAttributes.STYLE_ITALIC) :
|
||||
deriveAttributesWithColor(SimpleTextAttributes.fromTextAttributes(text[0].getAttributes()), fileBgColor);
|
||||
deriveAttributesWithColor(text[0].getSimpleAttributesIgnoreBackground(), fileBgColor);
|
||||
textChunks.append(text[0].getText(), attributes);
|
||||
}
|
||||
}
|
||||
else if (column == 2) {
|
||||
for (int i = 1; i < text.length; i++) {
|
||||
TextChunk textChunk = text[i];
|
||||
final SimpleTextAttributes attrs = SimpleTextAttributes.fromTextAttributes(textChunk.getAttributes());
|
||||
final SimpleTextAttributes attrs = textChunk.getSimpleAttributesIgnoreBackground();
|
||||
SimpleTextAttributes attributes = isSelected ?
|
||||
new SimpleTextAttributes(bg, fg, fg, attrs.getStyle()) : deriveAttributesWithColor(attrs, fileBgColor);
|
||||
textChunks.append(textChunk.getText(), attributes);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
*/
|
||||
package com.intellij.find.actions;
|
||||
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiFile;
|
||||
@@ -65,7 +64,8 @@ public class UsageListCellRenderer extends ColoredListCellRenderer {
|
||||
|
||||
TextChunk[] text = presentation.getText();
|
||||
for (TextChunk textChunk : text) {
|
||||
append(textChunk.getText(), SimpleTextAttributes.fromTextAttributes(textChunk.getAttributes()));
|
||||
SimpleTextAttributes simples = textChunk.getSimpleAttributesIgnoreBackground();
|
||||
append(textChunk.getText(), simples);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,10 @@ package com.intellij.ide.favoritesTreeView;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
import com.intellij.ide.projectView.ViewSettings;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import com.intellij.usageView.UsageInfo;
|
||||
import com.intellij.usages.TextChunk;
|
||||
import com.intellij.usages.UsageInfo2UsageAdapter;
|
||||
@@ -75,9 +73,7 @@ public class UsageProjectTreeNode extends ProjectViewNodeWithChildrenList<UsageI
|
||||
|
||||
public static void updatePresentationWithTextChunks(PresentationData presentation, TextChunk[] text) {
|
||||
for (TextChunk chunk : text) {
|
||||
final TextAttributes attributes = chunk.getAttributes();
|
||||
presentation.addText(chunk.getText(), new SimpleTextAttributes(attributes.getBackgroundColor(), attributes.getForegroundColor(),
|
||||
attributes.getEffectColor(), attributes.getFontType()));
|
||||
presentation.addText(chunk.getText(), chunk.getSimpleAttributesIgnoreBackground());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.usages;
|
||||
|
||||
import com.intellij.openapi.editor.markup.AttributesFlyweight;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.ui.SimpleTextAttributes;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TextChunk {
|
||||
@@ -43,4 +44,11 @@ public class TextChunk {
|
||||
public String toString() {
|
||||
return getText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public SimpleTextAttributes getSimpleAttributesIgnoreBackground() {
|
||||
SimpleTextAttributes simples = SimpleTextAttributes.fromTextAttributes(getAttributes());
|
||||
simples = new SimpleTextAttributes(null, simples.getFgColor(), simples.getWaveColor(), simples.getStyle());
|
||||
return simples;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,8 @@ class UsageViewTreeCellRenderer extends ColoredTreeCellRenderer {
|
||||
if (node.isValid()) {
|
||||
TextChunk[] text = node.getUsage().getPresentation().getText();
|
||||
for (TextChunk textChunk : text) {
|
||||
append(textChunk.getText(), patchAttrs(node, SimpleTextAttributes.fromTextAttributes(textChunk.getAttributes())));
|
||||
SimpleTextAttributes simples = textChunk.getSimpleAttributesIgnoreBackground();
|
||||
append(textChunk.getText(), patchAttrs(node, simples));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user