简体   繁体   English

如何在 Eclipse CDT 的搜索视图中更改引用的突出显示颜色?

[英]How to change highlight color of references in Search View in Eclipse CDT?

I want to change the highlight color of references showing in Eclipse's Search View after CDT find reference operation (right click on code -> References -> any).我想在 CDT 查找引用操作后更改 Eclipse 搜索视图中显示的引用的突出显示颜色(右键单击代码 -> 引用 -> 任何)。 How can I do this?我怎样才能做到这一点?

Note: this is different from standard match highlight color .注意:这与标准匹配高亮颜色不同

Illustration:插图: 在此处输入图片说明

I found out two easy solutions to this problem:我找到了解决这个问题的两个简单方法:

1) Create a new file and add those lines (extension of the file needs to be .epf): 1) 创建一个新文件并添加这些行(文件的扩展名必须是 .epf):

file_export_version=3.0
/instance/org.eclipse.ui.workbench/org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128 

You might change the color value to match your theme您可以更改颜色值以匹配您的主题

Then go to File -> Import -> General -> Preferences然后转到文件 -> 导入 -> 常规 -> 首选项

Browse to the newly created file and click the Finish button浏览到新创建的文件并单击“完成”按钮

2) Go to [workspace-location]/.metadata/.plugins/org.eclipse.core.runtime/.settings 2) 转到 [workspace-location]/.metadata/.plugins/org.eclipse.core.runtime/.settings

Edit org.eclipse.ui.workbench.prefs file and add the line编辑 org.eclipse.ui.workbench.prefs 文件并添加行

org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128

It seems that these colours are not editable and are therefore hard coded in a way that (clearly!) does not work well with a dark theme.似乎这些颜色是不可编辑的,因此硬编码的方式(显然!)不适用于深色主题。

This is the relevant part from the org.eclipse.cdt.ui/plugin.xml :这是来自org.eclipse.cdt.ui/plugin.xml的相关部分:

  <colorDefinition
        id="org.eclipse.cdt.ui.ColoredLabels.match_highlight"
        isEditable="false"
        label="%Dummy.label"
        value="206, 204, 247">
  </colorDefinition>

A small change to the plugin.xml allows the colour to be editable:对 plugin.xml 的一个小改动允许颜色是可编辑的:

  <colorDefinition
        categoryId="org.eclipse.cdt.ui.presentation"
        id="org.eclipse.cdt.ui.ColoredLabels.match_highlight"
        isEditable="true"
        label="Match Highlight"
        value="206, 204, 247">
  </colorDefinition>

And then you can edit the background colour and fix your problem.然后您可以编辑背景颜色并解决您的问题。

This is a known issue in CDT ( Bug 468206 ), contributions welcome.这是 CDT 中的一个已知问题(错误 468206 ),欢迎贡献。

Found a workaround that works for me.找到了对我有用的解决方法。 With eclipse closed:日食关闭:

  • unpack <eclipse installation folder>\\plugins\\org.eclipse.cdt.ui_6.3.0.201802261533.jar解压<eclipse installation folder>\\plugins\\org.eclipse.cdt.ui_6.3.0.201802261533.jar
  • edit plugin.xml and change the color to your taste编辑plugin.xml并根据您的喜好更改颜色
  • put this file back into the jar把这个文件放回jar
  • delete <eclipse installation folder>\\configuration\\org.eclipse.core.runtime\\.mainData.1删除<eclipse installation folder>\\configuration\\org.eclipse.core.runtime\\.mainData.1
  • start eclipse开始日食

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM