Yeah, I think that's true. I've only begun digging deeper into the scintilla code today so haven't really got a feel yet of how to do that. I guess I should start by diff'ing against 1.7.7 to get a feel for how invasive the changebar patch actually is.
You can either do that or download the patch from my server, it's a patch against 1.7.7 (used for C::B's new-scintilla-branch).
Your patch is against trunk and the scintilla used there is an 1.6.x-version as far as I know, so there are many, many differences, for example to the lexers, that should not be needed for the change bar.
You can download C::B with scintilla 1.7.7, which is not (yet) in trunk with svn from svn://svn.berlios.de/codeblocks/branches/scintilla
it should work on linux and windows and will soon (?) be merged with trunk. The scintilla-branch is uptodate, and contains some smal improvements, due to newer (better) indicatiors (used for "Highlight occurrences" and "Incremental Search").
One cause I worked with the newer scintilla is because it will most likely be committed to trunk the next time (no exact timeline, but no problems so far).
@Jens: I uploaded a patch against the scintilla branch here:
https://developer.berlios.de/patch/index.php?func=detailpatch&patch_id=2597&group_id=5358
I am not putting this forward as a patch similar to yours - I only uploaded it so you could see a change I made to scintilla that allows any margin to have the folding background. I noticed when I used the newer version of scintilla with the changebar in a separate margin it used the normal margin colour. I guess 1.7.5 had a bug in it which meant the margin colour matched the folding margin even when it shouldn't have.
I wanted it to look the same as the folding margin so made this patch quickly to try out the idea. I thought you may find that aspect of the patch useful and worth incorporating into your own patch.
gryphon
If I see it right (after a short look over your patch without replying it), the main difference to my patch is, apart from making it easy to swap the folding- and changebar-margin at compile-time, that you set the margins background explicitely and created a function and an event for this purpose.
This makes the background-chosing more flexible, but it is not needed if we use scintillas standard-behaviour.
You need to do that, because you did not change "SC_MASK_FOLDERS" and "wxSCI_MASK_FOLDERS" to "0xFF800000". The unpatched scintilla uses this mask to decide which background colour is chosen:
If (mask & wxSCI_MASK_FOLDERS)==0, the margin background colour is controlled by style 33 (wxSCI_STYLE_LINENUMBER).
Quote from the scintilla api-reference (you find it in "src/sdk/wxscintilla/website/reference.html" inside the C::B source-tree).
That's the cause, why I have to explicitely change the mask for the folder-margin, to make it not show the changebar.
The main problem with the whole changebar-patch, is that it seems not to be easy to switch it on and off (not only to make the changebar-visible or not).
try http://apt.jenslody.de/patches/scintilla_changebar_new.patch (http://apt.jenslody.de/patches/scintilla_changebar_new.patch), that should work.
It does. Nice! :-)
BTW: I believe the patch of gryphon concerning cbeditor.cpp is slightly better in certain areas. In addition I think you missed one point in cbeditor.cpp concerning calculation of the margin, namely this part of gryphons patch:
@@ -2269,7 +2286,8 @@
wxPoint clientpos(ScreenToClient(position));
const int margin = m_pControl->GetMarginWidth(0) + // numbers, if present
m_pControl->GetMarginWidth(1) + // breakpoints, bookmarks... if present
- m_pControl->GetMarginWidth(2); // folding, if present
+ m_pControl->GetMarginWidth(changebarMargin) +
+ m_pControl->GetMarginWidth(foldingMargin); // folding, if present
wxRect r = m_pControl->GetRect();
bool inside1 = r.Contains(clientpos);
Was there a special reason *not* to apply this section?
What I like especially is that there are static constants named "changebarMargin" and "foldingMargin" which makes reading the code a lot easier to understand. What do you think?!
I did not (yet) test it under windows.
I'll do it.
BTW: I believe you still missed that part (unless you have a reason not to apply it):
const int margin = m_pControl->GetMarginWidth(lineMargin) + // numbers, if present
m_pControl->GetMarginWidth(markerMargin) + // breakpoints, bookmarks... if present
m_pControl->GetMarginWidth(foldingMargin) + // folding, if present
m_pControl->GetMarginWidth(changebarMargin); // changebar