Patch #1740 2006-12-19 08:01
mcdave
Code Fold at Marked Line Bug Fix- Download
- 1740-Code_Fold_at_M.patch (3.3 KB)
Index: src/sdk/cbeditor.cpp
===================================================================
--- src/sdk/cbeditor.cpp (revision 3455)
+++ src/sdk/cbeditor.cpp (working copy)
@@ -1467,13 +1467,37 @@
void cbEditor::DoFoldBlockFromLine(int line, int fold)
{
- m_pControl->Colourise(0, -1); // the *most* important part!
+ /*m_pControl->Colourise(0, -1); // the *most* important part!
int i = line;
while (i != 0)
{
if (DoFoldLine(i, fold))
return;
--i;
+ }*/
+
+ ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
+ if (mgr->ReadBool(_T("/folding/show_folds"), true)) //Only unfold the marked line if the folds are enabled ... duh
+ {
+ m_pControl->Colourise(0, -1); // the *most* important part!
+ int level = m_pControl->GetFoldLevel(line);
+ int parent = m_pControl->GetFoldParent(line);
+
+ //Check for fold headers
+ if ((level & wxSCI_FOLDLEVELHEADERFLAG) && (wxSCI_FOLDLEVELBASE <= (level & wxSCI_FOLDLEVELNUMBERMASK)))
+ parent = line;
+ if (parent != -1)
+ {
+ if (m_pControl->GetFoldExpanded(parent) == false && fold == 0)
+ m_pControl->ToggleFold(parent);
+ else
+ {
+ if (m_pControl->GetFoldExpanded(parent) == true && fold == 1)
+ m_pControl->ToggleFold(parent);
+ else if (fold == 2)
+ m_pControl->ToggleFold(parent);
+ }
+ }
}
}
@@ -1569,8 +1593,23 @@
control->GotoLine(line - onScreen);
control->GotoLine(line + onScreen);
}
+
+ ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
+ if (mgr->ReadBool(_T("/folding/show_folds"), true)) //Only unfold the marked line if the folds are enabled ... duh
+ {
+ m_pControl->Colourise(0, -1); // the *most* important part!
+
+ int parent = m_pControl->GetFoldParent(line);
+ while (parent != -1) //Unfold all the parent folds to ensure that the line is visible correctly
+ {
+ if (m_pControl->GetFoldExpanded(parent) == false)
+ m_pControl->ToggleFold(parent);
+
+ parent = m_pControl->GetFoldParent(parent);
+ }
+ }
+
control->GotoLine(line);
- UnfoldBlockFromLine(line); // make sure it's visible (not folded)
}
bool cbEditor::AddBreakpoint(int line, bool notifyDebugger)
@@ -1804,7 +1843,23 @@
if (line == -1)
m_pControl->MarkerDeleteAll(marker);
else
+ {
+ ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor"));
+ if (mgr->ReadBool(_T("/folding/show_folds"), true)) //Only unfold the marked line if the folds are enabled ... duh
+ {
+ m_pControl->Colourise(0, -1); // the *most* important part!
+ int parent = m_pControl->GetFoldParent(line);
+ while (parent != -1) //Unfold all the parent folds to ensure that the line is visible correctly
+ {
+ if (m_pControl->GetFoldExpanded(parent) == false)
+ m_pControl->ToggleFold(parent);
+
+ parent = m_pControl->GetFoldParent(parent);
+ }
+ }
+
m_pControl->MarkerAdd(line, marker);
+ }
}
void cbEditor::GotoMatchingBrace()
History
This patch ensures the when the compiler marks a line as error/warning, or when it searches for something, that it will first unfold all of the parent fold then mark the line.
A nasty search and goto bug occured, this new patch fixes that issue. This patch also fixes the issue mentioned in that forum post killerbot. The issue was regarding the fold and unfold of blocks. This currently works correctly.
Hey killerbot... what do you think about that request that a user should be able to select which levels should be folded and which ones not (The depth part of it)
Makes sense... but hell... will you ever satisfy everybody?
We all have different coding styles...
Here's the patch before astyle was used. Index: cbeditor.cpp =================================================================== --- cbeditor.cpp (revision 3434) +++ cbeditor.cpp (working copy) @@ -1467,13 +1467,37 @@ void cbEditor::DoFoldBlockFromLine(int line, int fold) { - m_pControl->Colourise(0, -1); // the *most* important part! + /*m_pControl->Colourise(0, -1); // the *most* important part! int i = line; while (i != 0) { if (DoFoldLine(i, fold)) return; --i; + }*/ + + ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor")); + if (mgr->ReadBool(_T("/folding/show_folds"), true)) //Only unfold the marked line if the folds are enabled ... duh + { + m_pControl->Colourise(0, -1); // the *most* important part! + int level = m_pControl->GetFoldLevel(line); + int parent = m_pControl->GetFoldParent(line); + + //Check for fold headers + if ((level & wxSCI_FOLDLEVELHEADERFLAG) && (wxSCI_FOLDLEVELBASE <= (level & wxSCI_FOLDLEVELNUMBERMASK))) + parent = line; + if (parent != -1) + { + if (m_pControl->GetFoldExpanded(parent) == false && fold == 0) + m_pControl->ToggleFold(parent); + else + { + if (m_pControl->GetFoldExpanded(parent) == true && fold == 1) + m_pControl->ToggleFold(parent); + else if (fold == 2) + m_pControl->ToggleFold(parent); + } + } } } @@ -1569,8 +1593,23 @@ control->GotoLine(line - onScreen); control->GotoLine(line + onScreen); } + + ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor")); + if (mgr->ReadBool(_T("/folding/show_folds"), true)) //Only unfold the marked line if the folds are enabled ... duh + { + m_pControl->Colourise(0, -1); // the *most* important part! + + int parent = m_pControl->GetFoldParent(line); + while (parent != -1) //Unfold all the parent folds to ensure that the line is visible correctly + { + if (m_pControl->GetFoldExpanded(parent) == false) + m_pControl->ToggleFold(parent); + + parent = m_pControl->GetFoldParent(parent); + } + } + control->GotoLine(line); - UnfoldBlockFromLine(line); // make sure it's visible (not folded) } bool cbEditor::AddBreakpoint(int line, bool notifyDebugger) @@ -1804,7 +1843,23 @@ if (line == -1) m_pControl->MarkerDeleteAll(marker); else + { + ConfigManager* mgr = Manager::Get()->GetConfigManager(_T("editor")); + if (mgr->ReadBool(_T("/folding/show_folds"), true)) //Only unfold the marked line if the folds are enabled ... duh + { + m_pControl->Colourise(0, -1); // the *most* important part! + int parent = m_pControl->GetFoldParent(line); + while (parent != -1) //Unfold all the parent folds to ensure that the line is visible correctly + { + if (m_pControl->GetFoldExpanded(parent) == false) + m_pControl->ToggleFold(parent); + + parent = m_pControl->GetFoldParent(parent); + } + } + m_pControl->MarkerAdd(line, marker); + } } void cbEditor::GotoMatchingBrace()
MMM. Better this way: http://www.winapizone.net/recursive_unfold_on_error.patch
kkez's Version uploaded. Thanks
Testing?
First 2/3 of patch has been applied in modified form.
I could not understand the third part [bool cbEditor::AddBreakpoint(int line, bool notifyDebugger)]. In which situation it's useful?
@killerbot
I wrote previously that this patch has been reworked and applied. Thus I'm closing this patch report.