Starting with root v6.09.02 the ColorFromName function (in core/textinput/src/Getline_color.cxx) has been changed so that the format of an rgb colour string starts with a percent sign instead of a hash (which doesn’t seem to be mentioned in the release notes).
How can a program test for this to set the color string to the correct format? Is there a way to get the correct prefix-character or would I need to get the version number of root and set it based on that?
Oh I see, if it is this one it has nothing to do with TColor. May be @axel can comment but I think the reason of the change was clear as “#” is for comments.
Yes, you are correct, this was changed in commit b3abe789. And while I understand the reasoning (though having poshash point to the position of a percent sign is somewhat confusing), I don’t understand the reason why this was introduced without any kind of release note, as it breaks any program using it.
My question isn’t so much about why this was changed, but how you see a program using it switch between using a hash or a percent sign, depending on the root version. Is there any functionality to query the required format, or would the program have to use the version of root it is compiled against?
Just found that the reason I was getting an error (Getline_color/ColorFromName: cannot parse color #rrggbb!) was because the .rootrc had the prompt color set to “#rrggbb” and not because the program was using it to set the prompt color. Sorry for not checking that earlier!
So we just need to use different .rootrc’s for the different root versions to avoid that error.
I think I changed that because even in older version, #rgb would have been parsed as a comment… As such it’s a simply bug fix: despite the doc, #rgb never worked, and %rgb works since the commit you mention. That’s at least what I remember… Let me know if I should dig into this more thoroughly!
#rgb definitely works for earlier root 6 versions, as well as root 5.34.36. I remember it also working with older versions of root 5, but I’m not a hundred percent certain of that.