View Issue Details

IDProjectCategoryView StatusLast Update
0012561PatchesIDEpublic2008-11-09 18:36
ReporterBrad Campbell Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.9.27 (SVN) 
Target Version0.9.28Fixed in Version0.9.27 (SVN) 
Summary0012561: Add a FoldAll method to TSynEdit
DescriptionSynEdit already has an UnfoldAll method, and I needed a FoldAll.
TagsNo tags attached.
Fixed in Revision17279
LazTarget0.9.28
Widgetset
Attached Files

Activities

2008-11-04 08:05

 

synedit-fold.patch (1,510 bytes)   
--- components/synedit/synedit.pp	2008-11-03 20:03:53.000000000 +0400
+++ Projects/Pascal/High/synedit.pp	2008-11-04 11:00:48.000000000 +0400
@@ -749,6 +749,7 @@
     procedure CodeFoldAction(iLine: integer);
     function FindNextUnfoldedLine(iLine: integer; Down: boolean): Integer;
     procedure UnfoldAll;
+    procedure FoldAll;
     {$ENDIF}
 
     procedure AddKey(Command: TSynEditorCommand; Key1: word; SS1: TShiftState;
@@ -2908,6 +2909,12 @@
     if Down then inc(Result) else dec(Result);
 end;
 
+procedure TCustomSynEdit.FoldAll;
+begin
+  TSynEditStringList(Lines).FoldAll;
+  Invalidate;
+end;
+
 procedure TCustomSynEdit.UnfoldAll;
 begin
   TSynEditStringList(Lines).UnfoldAll;

--- components/synedit/synedittextbuffer.pp	2008-10-21 14:48:25.000000000 +0400
+++ Projects/Pascal/High/synedittextbuffer.pp	2008-11-04 11:06:12.000000000 +0400
@@ -186,6 +186,7 @@
     procedure FoldLines(AStartIndex: Integer);
     procedure UnFoldLines(AStartIndex: Integer);
     procedure UnfoldAll;
+    procedure FoldAll;
     procedure FixFolding(AStartIndex: Integer; AMinEndIndex: Integer = 0);
     {$ENDIF}
   public
@@ -1123,6 +1124,18 @@
   end;
 end;
 
+procedure TSynEditStringList.FoldAll;
+var
+  i: Integer;
+begin
+  for i:=0 to Count-1 do begin
+    if (FoldType[i] = cfExpanded) and Not Folded[I] then
+      Begin
+      FoldLines(I);
+      End;
+  end;
+end;
+
 procedure TSynEditStringList.FixFolding(AStartIndex: integer; AMinEndIndex : Integer = 0);
 var
   Level, CoLevel: LongInt;
synedit-fold.patch (1,510 bytes)   

Martin Friebe

2008-11-04 23:19

manager   ~0023176

It seems to me that your patch only folds the "top-level" folds? It skips any nested folds?
Is that intended?

I will merge it into the refactored folding code. (So don't worry if your patch does not match the new code any more.)
To include the folding of nested folds would allow extending it, for fold/unfold to level x.

Brad Campbell

2008-11-05 00:01

reporter   ~0023177

It was an unintentional side effect actually, but in my case a desirable outcome.
The idea of being able to specify the nested fold level sounds worthwhile however.

Martin Friebe

2008-11-08 15:56

manager   ~0023232

@Brad: Please close if ok for you

Brad Campbell

2008-11-09 18:36

reporter   ~0023264

Works for me. Thanks :)

Issue History

Date Modified Username Field Change
2008-11-04 08:05 Brad Campbell New Issue
2008-11-04 08:05 Brad Campbell File Added: synedit-fold.patch
2008-11-04 08:46 Vincent Snijders LazTarget => 0.9.28
2008-11-04 08:46 Vincent Snijders Assigned To => Martin Friebe
2008-11-04 08:46 Vincent Snijders Status new => assigned
2008-11-04 08:46 Vincent Snijders Target Version => 0.9.28
2008-11-04 08:47 Vincent Snijders Category Patch => IDE
2008-11-04 08:47 Vincent Snijders Project Lazarus => Patches
2008-11-04 23:19 Martin Friebe Note Added: 0023176
2008-11-04 23:20 Martin Friebe Status assigned => feedback
2008-11-05 00:01 Brad Campbell Note Added: 0023177
2008-11-05 22:22 Martin Friebe Status feedback => assigned
2008-11-08 15:56 Martin Friebe Fixed in Revision => 17279
2008-11-08 15:56 Martin Friebe Status assigned => resolved
2008-11-08 15:56 Martin Friebe Fixed in Version => 0.9.27 (SVN)
2008-11-08 15:56 Martin Friebe Resolution open => fixed
2008-11-08 15:56 Martin Friebe Note Added: 0023232
2008-11-09 18:36 Brad Campbell Status resolved => closed
2008-11-09 18:36 Brad Campbell Note Added: 0023264