diff options
author | nyamatongwe <devnull@localhost> | 2011-04-07 21:11:27 +1000 |
---|---|---|
committer | nyamatongwe <devnull@localhost> | 2011-04-07 21:11:27 +1000 |
commit | 2320136b7c8ade644fbdbc9fe0151373132006cf (patch) | |
tree | e77a7574be855c71fcfdf690e044d0ecfee5b802 /src/Editor.cxx | |
parent | 5e80410bb388d5a73c647b80d308e97c73a22972 (diff) | |
download | scintilla-mirror-2320136b7c8ade644fbdbc9fe0151373132006cf.tar.gz |
Bug #3265401 changes to fold markers.
Hide folding markers and indicator lines when a fold header does not have
any subordinate lines to fold away.
Do not contract an empty fold header when clicked on.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r-- | src/Editor.cxx | 51 |
1 files changed, 28 insertions, 23 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx index 92d172a8a..3aab72682 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -1735,17 +1735,21 @@ void Editor::PaintSelMargin(Surface *surfWindow, PRectangle &rc) { int levelNextNum = levelNext & SC_FOLDLEVELNUMBERMASK; if (level & SC_FOLDLEVELHEADERFLAG) { if (firstSubLine) { - if (cs.GetExpanded(lineDoc)) { - if (levelNum == SC_FOLDLEVELBASE) - marks |= 1 << SC_MARKNUM_FOLDEROPEN; - else - marks |= 1 << folderOpenMid; - } else { - if (levelNum == SC_FOLDLEVELBASE) - marks |= 1 << SC_MARKNUM_FOLDER; - else - marks |= 1 << folderEnd; - } + if (levelNum < levelNextNum) { + if (cs.GetExpanded(lineDoc)) { + if (levelNum == SC_FOLDLEVELBASE) + marks |= 1 << SC_MARKNUM_FOLDEROPEN; + else + marks |= 1 << folderOpenMid; + } else { + if (levelNum == SC_FOLDLEVELBASE) + marks |= 1 << SC_MARKNUM_FOLDER; + else + marks |= 1 << folderEnd; + } + } else if (levelNum > SC_FOLDLEVELBASE){ + marks |= 1 << SC_MARKNUM_FOLDERSUB; + } } else { marks |= 1 << SC_MARKNUM_FOLDERSUB; } @@ -3443,21 +3447,22 @@ void Editor::Paint(Surface *surfaceWindow, PRectangle rcArea) { ll->RestoreBracesHighlight(rangeLine, braces); bool expanded = cs.GetExpanded(lineDoc); - // Paint the line above the fold - if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { - if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { + const int level = pdoc->GetLevel(lineDoc); + const int levelNext = pdoc->GetLevel(lineDoc + 1); + if ((level & SC_FOLDLEVELHEADERFLAG) && + ((level & SC_FOLDLEVELNUMBERMASK) < (levelNext & SC_FOLDLEVELNUMBERMASK))) { + // Paint the line above the fold + if ((expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_EXPANDED)) + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEBEFORE_CONTRACTED))) { PRectangle rcFoldLine = rcLine; rcFoldLine.bottom = rcFoldLine.top + 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); } - } - // Paint the line below the fold - if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) - || - (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { - if (pdoc->GetLevel(lineDoc) & SC_FOLDLEVELHEADERFLAG) { + // Paint the line below the fold + if ((expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_EXPANDED)) + || + (!expanded && (foldFlags & SC_FOLDFLAG_LINEAFTER_CONTRACTED))) { PRectangle rcFoldLine = rcLine; rcFoldLine.top = rcFoldLine.bottom - 1; surface->FillRectangle(rcFoldLine, vs.styles[STYLE_DEFAULT].fore.allocated); @@ -6558,8 +6563,8 @@ void Editor::ToggleContraction(int line) { if (cs.GetExpanded(line)) { int lineMaxSubord = pdoc->GetLastChild(line); - cs.SetExpanded(line, 0); if (lineMaxSubord > line) { + cs.SetExpanded(line, 0); cs.SetVisible(line + 1, lineMaxSubord, false); int lineCurrent = pdoc->LineFromPosition(sel.MainCaret()); |