How to change background color of diff lines in meld?

Hi,
I’m trying to change the background color of the diff lines.
I can’t find the names of the styles needed for this change.

I copied the “classic.xml” to new name, under “Meld\share\gtksourceview-4\styles”.
When I re-load meld, it recognize the new xml file.
I’ve managed to change many styles, but cant find which are the styles that I want to change.

All built-in schemes have same “blue hues”, so it doesn’t help.

I want to change colors to “classic” (?) colors: pink for modified line and green for added line.
See desired colors below in some image from the web.
Thanks for any help,

Example:

Meld has its own set of GtkSourceView style elements for background colours (among a few other things). You can see what they all are in the main source style (data/styles/meld-base.style-scheme.xml.in · main · GNOME / meld · GitLab).

If you only want to override the Meld-specific colours, your best option is to use the style I’ve linked above as a base, changing the parent-scheme to whatever your preferred GtkSourceView colour scheme is.

Thanks, I was able to do it.
I saw in gitlab that you are the maintainer of the project, and I don’t have a gitlab-gnome account, so I just ask here:
I thought it would be a good idea to pull-request this color scheme.
But actually it also changes the “meld:” colors, not only the syntax,
and the preferences dialog refers to “Syntax highlighting color scheme”,
so it doesn’t fit there.
Do you know/have any plan to add an option to change the “meld colors”
or just rename the description from “Syntax highlighting color scheme” to " “Color scheme” ?
Thanks again for your help.

I thought it would be a good idea to pull-request this color scheme. But actually it also changes the “meld:” colors, not only the syntax,

Adding in new schemes here is fine; the background scheme just needs broadly to match the sourceview scheme it’s paired with.

Do you know/have any plan to add an option to change the “meld colors”
or just rename the description from “Syntax highlighting color scheme” to " “Color scheme” ?

The two are so closely linked that we can’t really separate them. The syntax highlighting scheme changes foreground text colours in ways that can make the Meld colours harder to read, and dark syntax schemes need different Meld colours to work. At a technical level, it would also be very difficult to separate them.

However, our colour scheme selector is very old at this point and is definitely due for a refresh. There have been suggestions to redesign this to follow something closer to the Builder UI, which would be great.

I’ve tried to create a color scheme, where a “new” line is green, and a “removed” line is red.
But I cant find the “meld:” style for it, if possible at all.
There’s one called “meld:delete”, but I dont think it is used, as both removed/added line seem to use style of “meld:replace”.
See attached image and xml.
Is it possible at all ? maybe by some arg to to tell meld to internal use other diff method/format ?
Thanks for your help.

xml cannot be uploaded, so here it as as text:

<?xml version="1.0" encoding="UTF-8"?>
<style-scheme id="classic-test-999999" _name="_ Test diff rainbow" version="1.0">
  <author>GtkSourceView team</author>
  <_description>Classic color scheme</_description>

  <!-- Palette -->
  <color name="white"      value="#FFFFFF"/>
  <color name="blue"       value="#0000FF"/>
  <color name="magenta"    value="#FF00FF"/>
  <color name="violet"     value="#6A5ACD"/>
  <color name="cyan"       value="#008A8C"/>
  <color name="gray"       value="#BEBEBE"/>
  <color name="green"      value="#2E8B57"/>
  <color name="bordeaux"   value="#A52A2A"/>
  <color name="red"        value="#FF0000"/>
  <color name="yellow"     value="#FFFF00"/>
  <color name="purple"     value="#A020F0"/>

  <!-- extra rainbow-vibrant colors for tests --> 
  <color name="lightpink"     value="#FFECEC"/>
  <color name="light-green"   value="#EBFFEA"/>
  <color name="aqua"          value="#00FFFF"/>
  <color name="deeppink"     	value="#FF1493"/>
  <color name="lime"          value="#00FF00"/>
  <color name="OrangeRed"     value="#FF4500"/>
  <color name="red2"          value="#FF0000"/>
  <color name="gold"     	value="#FFD700"/>
  <color name="copper"    	value="#B87333"/>
  <color name="black2"     	value="#000000"/>

  <!-- colored lines -->
  <style name="meld:insert" background="lime" foreground="red2" line-background="deeppink"/>
  <!-- next for line where line is identfied as same line in noth files, but with some inlines changes-->
  <style name="meld:replace" background="lightpink" foreground="copper" line-background="black2"/>
  <style name="meld:conflict" background="red2" foreground="red2" line-background="red2"/>
  <style name="meld:delete" background="aqua" foreground="aqua" line-background="aqua"/>
  <style name="meld:error" background="red2" foreground="red2" line-background="red2"/>
  <!-- bg of word(s) inside a line of style meld:replace -->	
  <style name="meld:inline" background="deeppink"/>
  <style name="meld:current-line-highlight" foreground="#eeeeee" background="#rgba(0, 255, 255, 0.5)"/>
  <!-- shades of gray (didnt touch ) -->
  <style name="meld:unknown-text" foreground="#aaaaaa"/>
  <style name="meld:syncpoint-outline" foreground="#bbbbbb"/>
  <style name="meld:current-chunk-highlight" background="#rgba(255, 255, 255, 0.06)"/>
  <style name="meld:dimmed" foreground="#999999"/>
  <style name="meld:overscroll" background="#rgba(255, 255, 255, 0.1)"/>
  <style name="map-overlay" background="#rgba(200, 200, 200, 0.4)"/>
</style-scheme>

Meld doesn’t support this, no. The reasons are mostly historical, but basically Meld has always had a model that considers changes in files without really enforcing the diff-style mental model of one file being “old” and one being “new”, and so there’s never really such a thing as a deletion… just an addition on the other side.

I absolutely understand that this is something that might be useful to support, but right now we don’t. I don’t really have a good idea of how much work it would be to add support for this either. It might be quite easy… you could try changing get_common_theme() to return meld:delete instead of meld:insert for line and fill colours.

For reference, we do use the delete colour, but only in (from memory) version control view.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.