Patch #1726 2006-12-16 13:56
mcdave
Fold all of the procedures at the same line- Download
- 1726-Fold_all_of_th.patch (3.1 KB)
- Category
- Status
- Rejected
- Close date
- 2007-04-12 12:51
- Assigned to
- killerbot
Index: src/sdk/wxscintilla/src/scintilla/src/LexCPP.cxx
===================================================================
--- src/sdk/wxscintilla/src/scintilla/src/LexCPP.cxx (revision 3455)
+++ src/sdk/wxscintilla/src/scintilla/src/LexCPP.cxx (working copy)
@@ -97,7 +97,7 @@
if (sc.atLineStart) {
if (sc.state == SCE_C_STRING) {
- // Prevent SCE_C_STRINGEOL from leaking back to previous line which
+ // Prevent SCE_C_STRINGEOL from leaking back to previous line which
// ends with a line continuation by locking in the state upto this position.
sc.SetState(SCE_C_STRING);
}
@@ -399,16 +399,61 @@
}
}
if (style == SCE_C_OPERATOR) {
- if (ch == '{') {
- // Measure the minimum before a '{' to allow
- // folding on "} else {"
- if (levelMinCurrent > levelNext) {
- levelMinCurrent = levelNext;
- }
- levelNext++;
- } else if (ch == '}') {
- levelNext--;
- }
+ if (ch == '{')
+ {
+ // Measure the minimum before a '{' to allow
+ // folding on "} else {"
+ if(visibleChars == 0)
+ {
+ bool foundBracket = false;
+ int thisCharPosition = i - 1;
+ int thisLinePosition = lineCurrent;
+ char thisChar = '{';
+ while(foundBracket == false && thisCharPosition > startPos)
+ {
+ thisChar = styler.SafeGetCharAt(thisCharPosition);
+ if(!isspacechar(thisChar) == true)
+ {
+ foundBracket = true;
+ thisLinePosition = styler.GetLine(thisCharPosition);
+ }
+ thisCharPosition--;
+ }
+ if(foundBracket == true)
+ {
+ if (levelMinCurrent > levelNext)
+ {
+ levelMinCurrent = levelNext;
+ }
+ levelNext++;
+ while(thisLinePosition != lineCurrent)
+ {
+ int levelUse = levelCurrent;
+ int lev = levelUse | levelNext << 16;
+ if (visibleChars == 0 && foldCompact)
+ lev |= SC_FOLDLEVELWHITEFLAG;
+ if (levelUse < levelNext)
+ lev |= SC_FOLDLEVELHEADERFLAG;
+ styler.SetLevel(thisLinePosition, lev);
+ thisLinePosition++;
+ levelCurrent = levelNext;
+ levelMinCurrent = levelCurrent;
+ }
+ }
+ }
+ else
+ {
+ if (levelMinCurrent > levelNext)
+ {
+ levelMinCurrent = levelNext;
+ }
+ levelNext++;
+ }
+ }
+ else if (ch == '}')
+ {
+ levelNext--;
+ }
}
if (atEOL) {
int levelUse = levelCurrent;
History
could you explain a bit more what is changing, and why it is needed.
By the way have a look at this (wrt previous applied patches) : http://forums.codeblocks.org/index.php?topic=4724.msg37157#msg37157
Well it is only a cosmetic feature. When you fold a block of code, the fold line will always be where the '{' character is. I added the feature that if the '{' is the character in the line, it will find the first valid character to make that line its fold line. So far it works great... I hope...
What is it with me and the AStyle patches... it changes the whole file without determining the changes... Sorry about that... here is the changes without the AStyle.
Sorry for responding so late, but this patch cannot be applied. Folding the line where { exists, is a strong scintilla's feature which this patch almost invalidates.
The reasoning is simple: you can manually add folding points anywhere in your code just by adding a { in a comment (like //{ and //}). With this patch, everyone using this feature will be upset because they would then have to update their *code* so that it behaves like they are used to.
If that's not enough reason, here's a more strong point: we do not accept patches for scintilla/wxScintilla/wxPropGrid/wxFlatNotebook. We update these components using their source releases, when we have tested them well enough.
Meaning that if you insist on changing this scintilla functionality, you would have to submit the patch to the scintilla team.
Thanks for your effort though.