Bug 468206 - [Search] C/C++ Search - unable to change search match background color
Summary: [Search] C/C++ Search - unable to change search match background color
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-editor (show other bugs)
Version: 8.6.0   Edit
Hardware: PC Linux
: P3 normal with 5 votes (vote)
Target Milestone: 9.8.0   Edit
Assignee: Marco Stornelli CLA
QA Contact: Doug Schaefer CLA
URL:
Whiteboard:
Keywords:
Depends on: 537988 546210
Blocks:
  Show dependency tree
 
Reported: 2015-05-25 14:09 EDT by Tomasz Kalicki CLA
Modified: 2019-10-09 01:08 EDT (History)
12 users (show)

See Also:


Attachments
C/C++ Search match background color issue (66.63 KB, image/png)
2015-05-25 14:09 EDT, Tomasz Kalicki CLA
no flags Details
2018-12 (146.19 KB, image/png)
2019-02-13 00:17 EST, Will Korbe CLA
no flags Details
CCS CDT 9.2 (19.62 KB, image/png)
2019-04-18 03:44 EDT, Amitai Weil CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomasz Kalicki CLA 2015-05-25 14:09:32 EDT
Created attachment 253736 [details]
C/C++ Search match background color issue

I'm running dark theme and I've a problem with background color for search match in C/C++ search window (see attached screenshot).

Match background color can be adjusted in: Preferences > General > Appearance > Color and Fonts > Match highlight background color.

This option works for regular "File Search", but for "C/C++ Search" this color hardcoded (RGB:206,204,247). Unreadable when text font is white.

Issue exist in Luna SR2 and Mars RC1. Both Windows & Linux.
Comment 1 Jonah Graham CLA 2015-11-17 14:43:03 EST
Someone on SO ran into this, while investigating I tried out a quick fix solution as I am not very familiar with themes, but in the absence of inheriting the colours fully so they work in the dark theme, simply making them editable may be a short term workaround: http://stackoverflow.com/questions/33765133/how-to-change-highlight-color-of-references-in-search-view-in-eclipse-cdt/33765612#33765612
Comment 2 Jonah Graham CLA 2015-11-17 14:45:04 EST
Extra notes (for me or anyone else who comes to fix this), the colour is eventually used in org.eclipse.cdt.internal.ui.search.CSearchLabelProvider.getStyledText(Object) and the style is created here org.eclipse.cdt.internal.ui.viewsupport.ColoringLabelProvider.HIGHLIGHT_STYLE
Comment 3 Jonah Graham CLA 2016-02-09 14:29:46 EST
GARCIN David on SO provided a useful workaround for this issue (http://stackoverflow.com/a/34996869/2796832), reproduced here: 


I found out two easy solutions to this problem:

1) Create a new file and add those lines:

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 -> Preferences

Browse to the newly created file and clic the Finish button

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

Edit org.eclipse.ui.workbench.prefs file and add the line

org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128
Comment 4 Axel Mueller CLA 2017-02-15 04:16:32 EST
I just wanted to give the Dark Theme a new try with Eclipse Neon. However, the problem described here still exists so Dark Theme is - for me - not usable with CDT.
Comment 5 Rasmus Pedersen CLA 2017-05-07 08:49:13 EDT
(In reply to Jonah Graham from comment #3)
> GARCIN David on SO provided a useful workaround for this issue
> (http://stackoverflow.com/a/34996869/2796832), reproduced here: 
> 
> 
> I found out two easy solutions to this problem:
> 
> 1) Create a new file and add those lines:
> 
> 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 -> Preferences
> 
> Browse to the newly created file and clic the Finish button
> 
> 2) Go to
> [workspace-location]/.metadata/.plugins/org.eclipse.core.runtime/.settings
> 
> Edit org.eclipse.ui.workbench.prefs file and add the line
> 
> org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128

This doesn't work for me. I'm running Eclipse Neon 4.6.3 (CDT 9.2.1.201704050430), should the workaround be applicable to that version too?
Comment 6 Dmitry Nezhevenko CLA 2017-10-13 08:39:37 EDT
It works for me with latest CDT. Just added two lines to org.eclipse.ui.workbench.prefs:

org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128
org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight=128,0,64
Comment 7 Viorel Florian CLA 2018-01-11 11:44:52 EST
@Rasmus Pedersen
I have Neon and this a non-issue for me because you can fix it like so:

Windows > Preferences > General > Appearance > Colors and Fonts > Colored labels - match highlight ...

I found it here:
https://stackoverflow.com/questions/10922934/how-to-change-search-background-color-in-eclipse/10955355 

Hope this helps
Comment 8 Gregory Kramida CLA 2018-01-11 11:56:50 EST
@Viorel Florian,

Are you speaking of the search background color or general match background color? Does one translate to the other now (I don't know, I haven't tested)?

See differences between these issues here.

Unrelated issue: https://stackoverflow.com/questions/18635149/changing-highlighting-color-in-a-theme-from-eclipse-color-theme

Current issue: https://stackoverflow.com/questions/33765133/how-to-change-highlight-color-of-references-in-search-view-in-eclipse-cdt
Comment 9 Geobert Quach CLA 2018-04-23 07:02:11 EDT
I confirm that Viorel's comment is for the match in the editor, not the search panel. This issue is still relevant. Oxygen and CDT 9.4.3.
Comment 10 Geobert Quach CLA 2018-04-23 07:53:47 EDT
Just tried all the workaround listed and none work for me :(
Comment 11 Geobert Quach CLA 2018-04-23 08:11:10 EDT

Found a workaround that works for me. With eclipse closed:

    - unpack <eclipse installation folder>\plugins\org.eclipse.cdt.ui_6.3.0.201802261533.jar
    - edit plugin.xml and change the color to your taste
    - put this file back into the jar
    - delete <eclipse installation folder>\configuration\org.eclipse.core.runtime\.mainData.1
    - start eclipse
Comment 12 raner bingmeiyou CLA 2018-12-17 02:15:39 EST
(In reply to Geobert Quach from comment #11)
> 
> Found a workaround that works for me. With eclipse closed:
> 
>     - unpack <eclipse installation
> folder>\plugins\org.eclipse.cdt.ui_6.3.0.201802261533.jar
>     - edit plugin.xml and change the color to your taste
>     - put this file back into the jar
>     - delete <eclipse installation
> folder>\configuration\org.eclipse.core.runtime\.mainData.1
>     - start eclipse

I confirm that this is last effective solution for eclipse-cpp-2018-09-win32-x86_64.zip(org.eclipse.cdt.ui_6.3.1.201811180605.jar).

Import preferences file (from https://stackoverflow.com/questions/33765133/how-to-change-highlight-color-of-references-in-search-view-in-eclipse-cdt) only work the first time import and brfore restart eclipse.
Once eclipse restarted, `org.eclipse.cdt.ui.ColoredLabels.match_highlight=128,0,128` is exist in org.eclipse.ui.workbench.prefs, and that color will become (RGB:206,204,247) again ignoring content in org.eclipse.ui.workbench.prefs.
But after I edit plugin.xml in org.eclipse.cdt.ui_6.3.1.201811180605.jar and delete configuration\org.eclipse.core.runtime\, IT WORKS!

NOTE:
Import preferences file still works for eclipse-cpp-oxygen-3a-win32-x86_64.zip(org.eclipse.cdt.ui_6.3.0.201802261533.jar) to me.
Comment 13 Will Korbe CLA 2019-02-13 00:11:40 EST
upgraded from cpp-oxygen to cpp-2018-12 and none of the workarounds are working for me anymore. On Linux or MacOS. 

I have the C/C++ version installed but can find the CDT plug-in jar, so I can't try that one.

~/eclipse/cpp-2018-12$ find . -name "*plugins*"
./Eclipse.app/Contents/Eclipse/plugins

MacOS
~/eclipse/cpp-2018-12/Eclipse.app/Contents/Eclipse/plugins$ ls -al
total 112
drwxr-xr-x  3 user  600     96 Feb 12 19:37 .
drwxr-xr-x  9 user  600    288 Feb 12 19:19 ..
-rw-r--r--  1 user  600  54580 Feb 12 17:37 org.eclipse.equinox.launcher_1.5.200.v20180922-1751.jar

Linux:
~/eclipse$ find . -name "*plugins*"
./plugins
~/eclipse$ ls -al plugins/
total 64
drwxr-xr-x 2 user staff  4096 Feb 12 17:14 .
drwxr-xr-x 6 user staff  4096 Feb 12 20:17 ..
-rw-r--r-- 1 user staff 54580 Feb 12 17:14 org.eclipse.equinox.launcher_1.5.200.v20180922-1751.jar
Comment 14 Will Korbe CLA 2019-02-13 00:17:48 EST
Created attachment 277548 [details]
2018-12
Comment 15 Eclipse Genie CLA 2019-03-29 13:47:13 EDT
New Gerrit change created: https://git.eclipse.org/r/139784
Comment 16 Eclipse Genie CLA 2019-04-03 15:15:40 EDT
New Gerrit change created: https://git.eclipse.org/r/139982
Comment 18 Jonah Graham CLA 2019-04-08 13:51:27 EDT
The two fixes together give the users the best experience here. So I don't know who to assign to. Thanks to both Marco and Tomasz for providing fixes.

To summarize, Marco exposes the search colours in the preferences UI, and Tomasz changes the default to be the same as the platform's search result.
Comment 19 Marco Stornelli CLA 2019-04-08 13:53:36 EDT
Yep, however I'd like to keep the write access feature, using the same color and without any UI will loose this feature.
Comment 20 Jonah Graham CLA 2019-04-08 14:02:54 EDT
(In reply to Marco Stornelli from comment #19)
> Yep, however I'd like to keep the write access feature, using the same color
> and without any UI will loose this feature.

Marco, I have approved and merged your fix for adding these colours to the UI. Regardless of anything else that means going forward users will be able to customize. 

I am now trying to understand if we can achieve sensible defaults for both normal and write access having different colours.
Comment 21 Jonah Graham CLA 2019-04-08 14:11:48 EDT
I have looked into how to do this properly with themeing. As a result I will take Marco's patch (https://git.eclipse.org/r/#/c/139784/) so that user's can fine tune these colours, but for the defaults I will try to use themeing as not to lose out on having different defaults for "Match background highlight" and "Write match background highlight"
Comment 23 Jonah Graham CLA 2019-04-08 15:57:33 EDT
Turns out that themeing does not work for this. I examined whether JDT supported this to learn from them, but unfortunately JDT has basically the same bug (see Bug 546210). Hopefully someone can solve this problem here on in JDT and the fix be copied across to the other one.

In the meantime I have set the non-write highlight to the same as normal highlight from org.eclipse.ui.search, this is what JDT does and what Tomasz provided, so I have accepted his patch for the main highlight change, but not the write highlight.
Comment 24 Tomasz Rojek CLA 2019-04-09 05:29:12 EDT
For those who are waiting for next release - as a temporary workaround you can just edit file:
plugins/org.eclipse.ui.themes_1.2.400.v20190223-1254/css/dark/e4-dark_preferencestyle.css

and add those two lines before last closing brace:
'org.eclipse.cdt.ui.ColoredLabels.match_highlight=206,92,0'
'org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight=128,0,128'

BTW - what is the difference between write highlights and normal ones?
Comment 25 Jonah Graham CLA 2019-04-09 11:08:24 EDT
(In reply to Tomasz Rojek from comment #24)
> For those who are waiting for next release - as a temporary workaround you
> can just edit file:
> plugins/org.eclipse.ui.themes_1.2.400.v20190223-1254/css/dark/e4-
> dark_preferencestyle.css
> 
> and add those two lines before last closing brace:
> 'org.eclipse.cdt.ui.ColoredLabels.match_highlight=206,92,0'
> 'org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight=128,0,128'

Tomasz, thanks for this. Have you tried this in a dev environment. I had tried that approach, but it didn't work. If it does work, can you submit a patch with that change?


> BTW - what is the difference between write highlights and normal ones?

If the identifier is a variable and being assigned, then the write highlight is used.
Comment 26 Marco Stornelli CLA 2019-04-14 05:16:04 EDT
@Jonah Do we need to close this bug as fixed? Or is it better to keep it open until bug 537988 is closed?
Comment 27 Jonah Graham CLA 2019-04-14 07:26:25 EDT
(In reply to Marco Stornelli from comment #26)
> @Jonah Do we need to close this bug as fixed? Or is it better to keep it
> open until bug 537988 is closed?

I think we should either create a new bug to track the remaining issue (default colour in dark theme for highlight of write occurrences) or just leave this one open. 

However it is assigned to you, so please decide what you prefer.
Comment 28 Amitai Weil CLA 2019-04-17 08:38:51 EDT
In the bottom line - what should be done
for the solution from 
http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/ ?

What is needed to be done after downloading the .zip?
should it be copied somewhere?
Please help
Comment 29 Jonah Graham CLA 2019-04-17 08:55:53 EDT
(In reply to Amitai Weil from comment #28)
> In the bottom line - what should be done
> for the solution from 
> http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/ ?
> 
> What is needed to be done after downloading the .zip?
> should it be copied somewhere?
> Please help

Hi Amatai,

The workaround is described in Comment 24. The workaround does not require you to download anything, simply edit a file in your Eclipse installation you already have.

Use the Git repository is if you are able to develop and test a fix so that the workaround isn't needed. The next version of CDT (9.8.0) will be significantly improved, but there is still one of the search colours that has a bad default.
Comment 30 Amitai Weil CLA 2019-04-18 03:07:20 EDT
(In reply to Tomasz Rojek from comment #24)
> For those who are waiting for next release - as a temporary workaround you
> can just edit file:
> plugins/org.eclipse.ui.themes_1.2.400.v20190223-1254/css/dark/e4-
> dark_preferencestyle.css
> 
> and add those two lines before last closing brace:
> 'org.eclipse.cdt.ui.ColoredLabels.match_highlight=206,92,0'
> 'org.eclipse.cdt.ui.ColoredLabels.writeaccess_highlight=128,0,128'
> 
> BTW - what is the difference between write highlights and normal ones?

I have no such file in my workspace (under [workspaceName]\.metadata\.plugins\
Searching all folder mentioned didn't show any appropriate result of 'themes'/'dark' or any *.css file.
My this be because I'm using the Code Composer studio software?
(Texas Instruments MCU IDE).
Comment 31 Amitai Weil CLA 2019-04-18 03:44:53 EDT
Created attachment 278328 [details]
CCS CDT 9.2
Comment 32 Amitai Weil CLA 2019-04-18 03:48:09 EDT
(In reply to Amitai Weil from comment #31)
> Created attachment 278328 [details]
> CCS CDT 9.2


After some search I've found the file, which appeared (for CCS 9) in:
C:\TI\ccs900\ccs\eclipse\plugins\org.eclipse.ui.themes_1.2.100.v20180514-1547\css\dark

None the less - the editing of file still didn't change the color, as appears 
in the figure, maybe there's some configuration overriding these dark setting?
Comment 33 Amitai Weil CLA 2019-04-18 03:59:07 EDT
After playing with some settings (don't remember all) 
and rechosing dark Linux theme all is OK new, thanks
Comment 34 Marco Stornelli CLA 2019-04-21 03:11:14 EDT
New bug report bug 546610 opened.