From bf4cac32235c75f1379f439797e89508abd43f73 Mon Sep 17 00:00:00 2001 From: PascalCorpsman Date: Thu, 31 Oct 2024 15:16:27 +0100 Subject: [PATCH] ADD: Review feature --- src/FPC_Understand.lpi | 8 + src/FPC_Understand.lpr | 102 ++-- src/ucommentframe.lfm | 33 ++ src/ucommentframe.pas | 52 ++ src/ufpc_understand.pas | 263 ++++++++- src/unit1.lfm | 102 ++-- src/unit1.pas | 38 +- src/unit11.lfm | 331 ++++++----- src/unit11.pas | 14 +- src/unit13.lfm | 1174 +++++++++++++++++++++------------------ src/unit13.pas | 268 ++++++++- src/unit3.lfm | 45 +- src/unit3.pas | 10 +- src/unit4.pas | 20 +- src/unit5.lfm | 59 +- src/unit5.pas | 15 +- src/unit6.lfm | 33 +- src/unit6.pas | 4 +- 18 files changed, 1643 insertions(+), 928 deletions(-) create mode 100644 src/ucommentframe.lfm create mode 100644 src/ucommentframe.pas diff --git a/src/FPC_Understand.lpi b/src/FPC_Understand.lpi index d082c52..3998214 100644 --- a/src/FPC_Understand.lpi +++ b/src/FPC_Understand.lpi @@ -266,6 +266,14 @@ + + + + + + + + diff --git a/src/FPC_Understand.lpr b/src/FPC_Understand.lpr index 7ad0a43..61862d0 100644 --- a/src/FPC_Understand.lpr +++ b/src/FPC_Understand.lpr @@ -1,51 +1,51 @@ -(******************************************************************************) -(* *) -(* Author : Uwe Schächterle (Corpsman) *) -(* *) -(* This file is part of FPC understand *) -(* *) -(* See the file license.md, located under: *) -(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *) -(* for details about the license. *) -(* *) -(* It is not allowed to change or remove this text from any *) -(* source file of the project. *) -(* *) -(******************************************************************************) -Program FPC_Understand; - -{$MODE objfpc}{$H+} - -Uses -{$IFDEF UNIX} - cthreads, -{$ENDIF} -{$IFDEF HASAMIGA} - athreads, -{$ENDIF} - Interfaces, // this includes the LCL widgetset - Forms, tachartlazaruspkg, Unit1, Unit2, Unit3, Unit4, Unit5, Unit6, Unit7, - Unit8, Unit9, Unit10, Unit11, Unit12, unit13; - -{$R *.res} - -Begin - RequireDerivedFormResource := True; - Application.Scaled := True; - Application.Initialize; - Application.CreateForm(TForm1, Form1); - Application.CreateForm(TForm2, Form2); - Application.CreateForm(TForm3, Form3); - Application.CreateForm(TForm4, Form4); - Application.CreateForm(TForm5, Form5); - Application.CreateForm(TForm6, Form6); - Application.CreateForm(TForm7, Form7); - Application.CreateForm(TForm8, Form8); - Application.CreateForm(TForm9, Form9); - Application.CreateForm(TForm10, Form10); - Application.CreateForm(TForm11, Form11); - Application.CreateForm(TForm12, Form12); - Application.CreateForm(TForm13, Form13); - Application.Run; -End. - +(******************************************************************************) +(* *) +(* Author : Uwe Schächterle (Corpsman) *) +(* *) +(* This file is part of FPC understand *) +(* *) +(* See the file license.md, located under: *) +(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *) +(* for details about the license. *) +(* *) +(* It is not allowed to change or remove this text from any *) +(* source file of the project. *) +(* *) +(******************************************************************************) +Program FPC_Understand; + +{$MODE objfpc}{$H+} + +Uses +{$IFDEF UNIX} + cthreads, +{$ENDIF} +{$IFDEF HASAMIGA} + athreads, +{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, tachartlazaruspkg, Unit1, Unit2, Unit3, Unit4, Unit5, Unit6, Unit7, + Unit8, Unit9, Unit10, Unit11, Unit12, unit13; + +{$R *.res} + +Begin + RequireDerivedFormResource := True; + Application.Scaled := True; + Application.Initialize; + Application.CreateForm(TForm1, Form1); + Application.CreateForm(TForm2, Form2); + Application.CreateForm(TForm3, Form3); + Application.CreateForm(TForm4, Form4); + Application.CreateForm(TForm5, Form5); + Application.CreateForm(TForm6, Form6); + Application.CreateForm(TForm7, Form7); + Application.CreateForm(TForm8, Form8); + Application.CreateForm(TForm9, Form9); + Application.CreateForm(TForm10, Form10); + Application.CreateForm(TForm11, Form11); + Application.CreateForm(TForm12, Form12); + Application.CreateForm(TForm13, Form13); + Application.Run; +End. + diff --git a/src/ucommentframe.lfm b/src/ucommentframe.lfm new file mode 100644 index 0000000..53206c1 --- /dev/null +++ b/src/ucommentframe.lfm @@ -0,0 +1,33 @@ +object CommentFrame: TCommentFrame + Left = 0 + Height = 136 + Top = 0 + Width = 224 + ClientHeight = 136 + ClientWidth = 224 + TabOrder = 0 + DesignLeft = 338 + DesignTop = 115 + object Memo1: TMemo + Left = 8 + Height = 98 + Top = 8 + Width = 208 + Anchors = [akTop, akLeft, akRight, akBottom] + Lines.Strings = ( + 'Memo1' + ) + ScrollBars = ssAutoBoth + TabOrder = 0 + WordWrap = False + end + object Button1: TButton + Left = 8 + Height = 25 + Top = 111 + Width = 208 + Anchors = [akLeft, akRight, akBottom] + Caption = 'Remove' + TabOrder = 1 + end +end diff --git a/src/ucommentframe.pas b/src/ucommentframe.pas new file mode 100644 index 0000000..433ad91 --- /dev/null +++ b/src/ucommentframe.pas @@ -0,0 +1,52 @@ +(******************************************************************************) +(* *) +(* Author : Uwe Schächterle (Corpsman) *) +(* *) +(* This file is part of FPC understand *) +(* *) +(* See the file license.md, located under: *) +(* https://github.com/PascalCorpsman/Software_Licenses/blob/main/license.md *) +(* for details about the license. *) +(* *) +(* It is not allowed to change or remove this text from any *) +(* source file of the project. *) +(* *) +(******************************************************************************) +Unit uCommentFrame; + +{$MODE ObjFPC}{$H+} + +Interface + +Uses + Classes, SysUtils, Forms, Controls, StdCtrls; + +Type + + { TCommentFrame } + + TCommentFrame = Class(TFrame) + Button1: TButton; + Memo1: TMemo; + private + + public + Line: integer; + Order: integer; // Die Sortierte Reihenfolge + Constructor Create(TheOwner: TComponent); override; + End; + +Implementation + +{$R *.lfm} + +{ TCommentFrame } + +Constructor TCommentFrame.Create(TheOwner: TComponent); +Begin + Inherited Create(TheOwner); + memo1.clear; +End; + +End. + diff --git a/src/ufpc_understand.pas b/src/ufpc_understand.pas index 08067b6..f71b0ab 100644 --- a/src/ufpc_understand.pas +++ b/src/ufpc_understand.pas @@ -88,10 +88,20 @@ BoarderForAverageMostComplexFiles: integer; // Der Durchschnitt aller Methoden in einer Datei muss größer diesem Wert liegen um Berücksichtigt zu werden End; + TLineComment = Record + Line: integer; + Filename: String; + Comment: String; + End; + + TLineComments = Array Of TLineComment; + { TProject } TProject = Class private + fLineComments: TLineComments; + fGeneral: TGeneral; fFiles: TFiles; FSearchPaths: TPathList; @@ -133,6 +143,10 @@ Procedure Clear; + Procedure RemoveLineComment(aFilename: String; line: Integer); + Procedure SetLineComment(aFilename: String; line: Integer; Comment: String); + Function GetLineComments(): TLineComments; + Function LoadFromFile(aFilename: String): boolean; Procedure SaveToFile(aFilename: String); Procedure Change(); // Setzen des Changed Flags @@ -205,15 +219,101 @@ *) Function GetPathDelimFromLPIFile(Const LPIFile: TDOMXML): String; +Function ExportCommentsAsCSV(Comments: TLineComments; Filename: String): Boolean; + Implementation -Uses IniFiles, Dialogs, LazFileUtils, LCLType, forms; +Uses IniFiles, Dialogs, LazFileUtils, LCLType, forms, Math; Procedure Nop; Begin End; +Function DeSerialize(Value: String): String; +Var + i, j: integer; +Begin + // Optionales Entfernen der Anführenden " + If length(Value) > 0 Then Begin + If Value[1] = '"' Then Begin + delete(Value, 1, 1); + delete(Value, length(Value), 1); + End; + End; + setlength(result, length(Value) * 2); + j := 1; + i := 1; + While i <= length(value) Do Begin + If value[i] = '#' Then Begin + inc(i); + If i > length(value) Then Begin + Raise exception.create('Error invalid deserialize String "' + value + '"'); + End; + Case Value[i] Of + '#': Begin + result[j] := '#'; + inc(j); + End; + '-': Begin + result[j] := '"'; + inc(j); + End; + '+': Begin +{$IFDEF Windows} + result[j] := LineEnding[1]; + result[j + 1] := LineEnding[2]; + inc(j, 2); +{$ELSE} + result[j] := LineEnding; + inc(j); +{$ENDIF} + End + Else Begin + Raise exception.Create('Error "' + value[i] + '" Not known as deserialize param.'); + End; + End; + inc(i); + End + Else Begin + result[j] := value[i]; + inc(i); + inc(j); + End; + End; + setlength(result, j - 1); +End; + +Function Serialize(Const Value: String): String; +Var + i: Integer; +Begin + result := '"'; + For i := 1 To length(value) Do Begin + Case value[i] Of +{$IFDEF Windows} + #10: Begin // Das Muss Geschluckt werden + End; + #13: Begin +{$ELSE} + LineEnding: Begin +{$ENDIF} + result := result + '#+'; + End; + '#': Begin + result := result + '##'; + End; + '"': Begin + result := result + '#-'; + End + Else Begin + result := result + value[i]; + End; + End; + End; + result := result + '"'; +End; + Function GetOSIdentiferString(): String; Begin Result := ''; @@ -504,6 +604,111 @@ If assigned(PDelim) Then result := PDelim.AttributeValue['Value']; End; +Function ExportCommentsAsCSV(Comments: TLineComments; Filename: String + ): Boolean; + Procedure QuickFilename(li, re: integer); + Var + l, r: Integer; + p: String; + h: TLineComment; + Begin + If Li < Re Then Begin + // Achtung, das Pivotelement darf nur einam vor den While schleifen ausgelesen werden, danach nicht mehr !! + p := Comments[Trunc((li + re) / 2)].Filename; // Auslesen des Pivo Elementes + l := Li; + r := re; + While l < r Do Begin + While CompareStr(Comments[l].Filename, p) < 0 Do + inc(l); + While CompareStr(Comments[r].Filename, p) > 0 Do + dec(r); + If L <= R Then Begin + h := Comments[l]; + Comments[l] := Comments[r]; + Comments[r] := h; + inc(l); + dec(r); + End; + End; + QuickFilename(li, r); + QuickFilename(l, re); + End; + End; + + Procedure QuickLines(li, re: integer); + Var + l, r, p: Integer; + h: TLineComment; + Begin + If Li < Re Then Begin + // Achtung, das Pivotelement darf nur einam vor den While schleifen ausgelesen werden, danach nicht mehr !! + p := Comments[Trunc((li + re) / 2)].Line; // Auslesen des Pivo Elementes + l := Li; + r := re; + While l < r Do Begin + While Comments[l].Line < p Do + inc(l); + While Comments[r].Line > p Do + dec(r); + If L <= R Then Begin + h := Comments[l]; + Comments[l] := Comments[r]; + Comments[r] := h; + inc(l); + dec(r); + End; + End; + QuickLines(li, r); + QuickLines(l, re); + End; + End; + +Var + sl: TStringList; + + Procedure Export(aFrom, aTo: integer); + Var + i: Integer; + s: String; + Begin + QuickLines(aFrom, aTo); + (* + A1;B1;"C1 + 2. Zeile";"D1;Bl""ub" + A2;B2;C2;D1 + + *) + For i := aFrom To aTo Do Begin + s := Comments[i].Filename + ';' + inttostr(Comments[i].Line) + ';"' + StringReplace(Comments[i].Comment, '"', '""', [rfReplaceAll]) + '"'; + sl.add(s); + End; + End; + +Var + startindex, Endindex: Integer; +Begin + result := false; + sl := TStringList.Create; + sl.add('Filename;Line;Comment'); + // 1. Sortieren nach Dateinamen + QuickFilename(0, high(Comments)); + startindex := 0; + Endindex := 1; + While Endindex <= high(Comments) Do Begin + If Comments[startindex].Filename <> Comments[Endindex].Filename Then Begin + Export(startindex, Endindex); + startindex := Endindex + 1; + End; + Endindex := Endindex + 1; + End; + Endindex := min(Endindex, high(Comments)); + Export(startindex, Endindex); + // 2. Exportieren Nach Dateinamen + sl.SaveToFile(Filename); + sl.free; + result := true; +End; + Function FilenameIsPascalUnit(Filename: String): Boolean; (* * gibt den Index von Value in Values wieder, -1 wenn nicht enthalten @@ -739,6 +944,7 @@ Constructor TProject.Create; Begin Inherited Create; + fLineComments := Nil; Clear; End; @@ -769,6 +975,44 @@ ChartStatisticSettings.BoarderForMostComplexFunction := fCCColors.LevelGood; ChartStatisticSettings.BoarderForAverageMostComplexFiles := Default_BoarderForAverageMostComplexFiles; FSearchPaths := Nil; + setlength(fLineComments, 0); +End; + +Procedure TProject.RemoveLineComment(aFilename: String; line: Integer); +Var + i, j: Integer; +Begin + For i := 0 To high(fLineComments) Do Begin + If (fLineComments[i].Line = line) And (fLineComments[i].Filename = aFilename) Then Begin + For j := i To high(fLineComments) - 1 Do Begin + fLineComments[j] := fLineComments[j + 1]; + End; + setlength(fLineComments, high(fLineComments)); + fChanged := true; + exit; + End; + End; +End; + +Procedure TProject.SetLineComment(aFilename: String; line: Integer; + Comment: String); +Begin + RemoveLineComment(aFilename, line); + setlength(fLineComments, high(fLineComments) + 2); + fLineComments[high(fLineComments)].Line := line; + fLineComments[high(fLineComments)].Filename := aFilename; + fLineComments[high(fLineComments)].Comment := Comment; + fChanged := true; +End; + +Function TProject.GetLineComments(): TLineComments; +Var + i: Integer; +Begin + setlength(result, length(fLineComments)); + For i := 0 To high(Result) Do Begin + result[i] := fLineComments[i]; + End; End; Procedure TProject.SetName(AValue: String); @@ -891,6 +1135,15 @@ FSearchPaths[i].FromLPI := false; End; + // LineComments + cnt := ini.readInteger('LineComments', 'Count', 0); + setlength(fLineComments, cnt); + For i := 0 To high(fLineComments) Do Begin + fLineComments[i].Line := ini.ReadInteger('LineComments', 'Comment' + inttostr(i) + 'Line', -1); + fLineComments[i].Filename := ini.ReadString('LineComments', 'Comment' + inttostr(i) + 'File', ''); + fLineComments[i].Comment := DeSerialize(ini.ReadString('LineComments', 'Comment' + inttostr(i) + 'Comment', '')); + End; + // Weiter fFilename := aFilename; @@ -953,6 +1206,14 @@ End; ini.WriteInteger('Files', 'SearchpathCount', cnt); + // LineComments + ini.WriteInteger('LineComments', 'Count', length(fLineComments)); + For i := 0 To high(fLineComments) Do Begin + ini.WriteInteger('LineComments', 'Comment' + inttostr(i) + 'Line', fLineComments[i].Line); + ini.WriteString('LineComments', 'Comment' + inttostr(i) + 'File', fLineComments[i].Filename); + ini.WriteString('LineComments', 'Comment' + inttostr(i) + 'Comment', Serialize(fLineComments[i].Comment)); + End; + // weiter ini.UpdateFile; diff --git a/src/unit1.lfm b/src/unit1.lfm index 3b70825..966dd07 100644 --- a/src/unit1.lfm +++ b/src/unit1.lfm @@ -1,13 +1,12 @@ object Form1: TForm1 Left = 324 - Height = 994 + Height = 497 Top = 107 - Width = 1520 + Width = 760 AllowDropFiles = True Caption = 'Form1' - ClientHeight = 994 - ClientWidth = 1520 - DesignTimePPI = 192 + ClientHeight = 497 + ClientWidth = 760 Menu = MainMenu1 Position = poScreenCenter LCLVersion = '3.99.0.0' @@ -18,20 +17,20 @@ object Form1: TForm1 OnMouseWheelUp = FormMouseWheelUp OnResize = FormResize object ScrollBar1: TScrollBar - Left = 16 - Height = 28 - Top = 960 - Width = 1456 + Left = 8 + Height = 14 + Top = 480 + Width = 728 Anchors = [akLeft, akRight, akBottom] PageSize = 0 TabOrder = 0 OnChange = ScrollBar1Change end object ScrollBar2: TScrollBar - Left = 1488 - Height = 928 - Top = 16 - Width = 28 + Left = 744 + Height = 464 + Top = 8 + Width = 14 Anchors = [akTop, akRight, akBottom] Kind = sbVertical PageSize = 0 @@ -39,40 +38,40 @@ object Form1: TForm1 OnChange = ScrollBar2Change end object Label1: TLabel - Left = 608 - Height = 32 - Top = 320 - Width = 248 + Left = 304 + Height = 16 + Top = 160 + Width = 140 Caption = 'Nothing loaded, please' end object Button1: TButton - Left = 624 - Height = 50 - Top = 448 - Width = 274 + Left = 312 + Height = 25 + Top = 224 + Width = 137 Caption = 'click to import *.lpi' TabOrder = 2 OnClick = Button1Click end object Button2: TButton - Left = 624 - Height = 50 - Top = 368 - Width = 274 + Left = 312 + Height = 25 + Top = 184 + Width = 137 Caption = 'load a FPU project' TabOrder = 3 OnClick = Button2Click end object Label2: TLabel - Left = 736 - Height = 32 - Top = 416 - Width = 22 + Left = 368 + Height = 16 + Top = 208 + Width = 13 Caption = 'or' end object MainMenu1: TMainMenu - Left = 80 - Top = 32 + Left = 40 + Top = 16 object MenuItem1: TMenuItem Caption = 'File' object MenuItem2: TMenuItem @@ -114,6 +113,13 @@ object Form1: TForm1 Caption = 'Reload dependencies' OnClick = MenuItem16Click end + object Separator10: TMenuItem + Caption = '-' + end + object MenuItem53: TMenuItem + Caption = 'Export line comments' + OnClick = MenuItem53Click + end end object MenuItem50: TMenuItem Caption = 'Analyze' @@ -190,24 +196,24 @@ object Form1: TForm1 end object IniPropStorage1: TIniPropStorage StoredValues = <> - Left = 288 - Top = 32 + Left = 144 + Top = 16 end object OpenDialog1: TOpenDialog DefaultExt = '.fpu' Filter = 'FPC-Understand file|*.fpu|All|*.*' - Left = 480 - Top = 32 + Left = 240 + Top = 16 end object SaveDialog1: TSaveDialog DefaultExt = '.fpu' Filter = 'FPC-Understand file|*.fpu|All|*.*' - Left = 624 - Top = 32 + Left = 312 + Top = 16 end object PopupMenu1: TPopupMenu - Left = 80 - Top = 176 + Left = 40 + Top = 88 object MenuItem9: TMenuItem Caption = 'Center out of range nodes' OnClick = MenuItem9Click @@ -296,8 +302,8 @@ object Form1: TForm1 end end object PopupMenu2: TPopupMenu - Left = 80 - Top = 320 + Left = 40 + Top = 160 object MenuItem52: TMenuItem Caption = 'Open Code' OnClick = MenuItem52Click @@ -332,13 +338,19 @@ object Form1: TForm1 object OpenDialog2: TOpenDialog DefaultExt = '.pas;.pp;.lpr' Filter = 'Pascal File|*.pas; *.pp; *.lpr|All|*.*' - Left = 480 - Top = 176 + Left = 240 + Top = 88 end object SaveDialog2: TSaveDialog DefaultExt = '.png' Filter = 'Portable network graphic|*.png|All|*.*' - Left = 80 - Top = 448 + Left = 40 + Top = 224 + end + object SaveDialog3: TSaveDialog + DefaultExt = '.csv' + Filter = 'Comma separated file|*.csv|All|*.*' + Left = 312 + Top = 88 end end diff --git a/src/unit1.pas b/src/unit1.pas index dcef351..0c69073 100644 --- a/src/unit1.pas +++ b/src/unit1.pas @@ -63,7 +63,7 @@ (* 0.23 - Reorder MainMenu *) (* 0.24 - FIX: graphical glitches in chart statistics *) (* ADD: more infos to chart statistics *) -(* 0.25 - ADD: Code preview *) +(* 0.25 - ADD: Code preview / review feature *) (* *) (* Known Bugs : - if a project holds 2 units with the same name *) (* the dependency graph will merge them to one *) @@ -75,7 +75,17 @@ (* über Units ..) *) (* *) (******************************************************************************) +(* Silk icon set 1.3 used *) +(* ---------------------- *) +(* Mark James *) +(* https://peacocksoftware.com/silk *) +(******************************************************************************) +(* This work is licensed under a *) +(* Creative Commons Attribution 2.5 License. *) +(* [ http://creativecommons.org/licenses/by/2.5/ ] *) +(******************************************************************************) Unit Unit1; + {$MODE objfpc}{$H+} Interface @@ -148,6 +158,7 @@ MenuItem50: TMenuItem; MenuItem51: TMenuItem; MenuItem52: TMenuItem; + MenuItem53: TMenuItem; MenuItem6: TMenuItem; MenuItem7: TMenuItem; MenuItem8: TMenuItem; @@ -158,9 +169,11 @@ PopupMenu2: TPopupMenu; SaveDialog1: TSaveDialog; SaveDialog2: TSaveDialog; + SaveDialog3: TSaveDialog; ScrollBar1: TScrollBar; ScrollBar2: TScrollBar; Separator1: TMenuItem; + Separator10: TMenuItem; Separator2: TMenuItem; Separator3: TMenuItem; Separator4: TMenuItem; @@ -209,6 +222,7 @@ Procedure MenuItem4Click(Sender: TObject); Procedure MenuItem51Click(Sender: TObject); Procedure MenuItem52Click(Sender: TObject); + Procedure MenuItem53Click(Sender: TObject); Procedure MenuItem5Click(Sender: TObject); Procedure MenuItem6Click(Sender: TObject); Procedure MenuItem8Click(Sender: TObject); @@ -432,7 +446,7 @@ Procedure TForm1.MenuItem13Click(Sender: TObject); Begin // Show Statistiks - If form4.CountFiles(GetSelectedFileList(), fProject.CCColors, fProject.RootFolder) Then Begin + If form4.CountFiles(GetSelectedFileList(), fProject) Then Begin form4.ShowModal; End Else Begin @@ -443,7 +457,7 @@ Procedure TForm1.MenuItem14Click(Sender: TObject); Begin // Show Classes - If form3.LoadClasses(GetSelectedFileList(), fProject.RootFolder) Then Begin + If form3.LoadClasses(GetSelectedFileList(), fProject) Then Begin form3.ShowModal; End Else Begin @@ -593,7 +607,7 @@ Procedure TForm1.MenuItem25Click(Sender: TObject); Begin // Show CC - If form5.LoadFunctions(GetSelectedFileList(), fProject.CCColors, fProject.RootFolder) Then Begin + If form5.LoadFunctions(GetSelectedFileList(), fProject) Then Begin form5.ShowModal; End Else Begin @@ -953,7 +967,21 @@ // Open Code list := GetSelectedFileList(); If length(list) > 0 Then Begin - form13.OpenFile(fProject.RootFolder, list[0].Filename); + form13.OpenFile(fProject, list[0].Filename); + End; +End; + +Procedure TForm1.MenuItem53Click(Sender: TObject); +Var + c: TLineComments; +Begin + c := fProject.GetLineComments(); + If high(c) = -1 Then Begin + showmessage('Nothing to export.'); + exit; + End; + If SaveDialog3.Execute Then Begin + ExportCommentsAsCSV(c, SaveDialog3.FileName); End; End; diff --git a/src/unit11.lfm b/src/unit11.lfm index 0261821..135fcd0 100644 --- a/src/unit11.lfm +++ b/src/unit11.lfm @@ -1,196 +1,195 @@ object Form11: TForm11 Left = 353 - Height = 1564 + Height = 710 Top = 124 - Width = 2258 + Width = 1129 Caption = 'Form11' ChildSizing.EnlargeHorizontal = crsHomogenousChildResize ChildSizing.EnlargeVertical = crsHomogenousChildResize ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.ControlsPerLine = 3 - ClientHeight = 1564 - ClientWidth = 2258 - DesignTimePPI = 192 + ClientHeight = 710 + ClientWidth = 1129 Position = poScreenCenter LCLVersion = '3.99.0.0' OnCreate = FormCreate object GroupBox1: TGroupBox Left = 0 - Height = 830 + Height = 379 Top = 0 - Width = 658 - ClientHeight = 793 - ClientWidth = 654 + Width = 328 + ClientHeight = 359 + ClientWidth = 324 TabOrder = 0 object Label1: TLabel Left = 0 - Height = 57 + Height = 30 Top = 0 - Width = 654 + Width = 324 Align = alTop Alignment = taCenter Caption = 'Line breakdown' - Font.Height = -42 + Font.Height = -21 ParentFont = False end object Shape1: TShape - Left = 16 - Height = 40 - Top = 80 - Width = 100 + Left = 8 + Height = 20 + Top = 40 + Width = 50 Brush.Color = 16744448 end object Shape2: TShape - Left = 16 - Height = 40 - Top = 128 - Width = 100 + Left = 8 + Height = 20 + Top = 64 + Width = 50 Brush.Color = clGreen end object Shape3: TShape - Left = 16 - Height = 40 - Top = 176 - Width = 100 + Left = 8 + Height = 20 + Top = 88 + Width = 50 Brush.Color = clMaroon end object Label3: TLabel - Left = 144 - Height = 32 - Top = 90 - Width = 56 + Left = 72 + Height = 15 + Top = 45 + Width = 28 Caption = 'Code' end object Label4: TLabel - Left = 144 - Height = 32 - Top = 138 - Width = 106 + Left = 72 + Height = 15 + Top = 69 + Width = 54 Caption = 'Comment' end object Label5: TLabel - Left = 144 - Height = 32 - Top = 186 - Width = 58 + Left = 72 + Height = 15 + Top = 93 + Width = 29 Caption = 'Blank' end object Label6: TLabel - Left = 304 - Height = 32 - Top = 90 - Width = 69 + Left = 152 + Height = 15 + Top = 45 + Width = 34 Caption = 'Label6' end object Label7: TLabel - Left = 304 - Height = 32 - Top = 138 - Width = 69 + Left = 152 + Height = 15 + Top = 69 + Width = 34 Caption = 'Label7' end object Label8: TLabel - Left = 304 - Height = 32 - Top = 186 - Width = 69 + Left = 152 + Height = 15 + Top = 93 + Width = 34 Caption = 'Label8' end object ToggleBox1: TToggleBox - Left = 16 - Height = 70 - Top = -16 - Width = 70 + Left = 8 + Height = 35 + Top = -8 + Width = 35 Caption = '<->' TabOrder = 0 OnClick = ToggleBox1Click end end object GroupBox2: TGroupBox - Left = 658 - Height = 830 + Left = 328 + Height = 379 Top = 0 - Width = 800 - ClientHeight = 793 - ClientWidth = 796 + Width = 401 + ClientHeight = 359 + ClientWidth = 397 TabOrder = 1 object Label2: TLabel Left = 0 - Height = 57 + Height = 30 Top = 0 - Width = 796 + Width = 397 Align = alTop Alignment = taCenter Caption = 'Directory structure' - Font.Height = -42 + Font.Height = -21 ParentFont = False end object Label9: TLabel - Left = 32 - Height = 32 - Top = 90 - Width = 320 + Left = 16 + Height = 15 + Top = 45 + Width = 155 Caption = 'Segment size by lines of code' end object ToggleBox2: TToggleBox - Left = 16 - Height = 70 - Top = -16 - Width = 70 + Left = 8 + Height = 35 + Top = -8 + Width = 35 Caption = '<->' TabOrder = 0 OnClick = ToggleBox2Click end object Label19: TLabel - Left = 684 - Height = 32 - Top = 90 - Width = 82 + Left = 342 + Height = 15 + Top = 45 + Width = 40 Alignment = taRightJustify Anchors = [akTop, akRight] Caption = 'Label19' end end object GroupBox3: TGroupBox - Left = 1458 - Height = 830 + Left = 729 + Height = 379 Top = 0 - Width = 800 - ClientHeight = 793 - ClientWidth = 796 + Width = 400 + ClientHeight = 359 + ClientWidth = 396 TabOrder = 2 object Label10: TLabel Left = 0 - Height = 57 + Height = 30 Top = 0 - Width = 796 + Width = 396 Align = alTop Alignment = taCenter Caption = ' Most complex functions' - Font.Height = -42 + Font.Height = -21 ParentFont = False end object ToggleBox3: TToggleBox - Left = 16 - Height = 70 - Top = -16 - Width = 70 + Left = 8 + Height = 35 + Top = -8 + Width = 35 Caption = '<->' TabOrder = 0 OnClick = ToggleBox3Click end object Label11: TLabel - Left = 32 - Height = 32 - Top = 90 - Width = 483 + Left = 16 + Height = 15 + Top = 45 + Width = 242 Caption = 'Complexity by the McCabe cyclomatic Metric' end object Label20: TLabel - Left = 690 - Height = 32 - Top = 90 - Width = 82 + Left = 344 + Height = 15 + Top = 45 + Width = 40 Alignment = taRightJustify Anchors = [akTop, akRight] Caption = 'Label20' @@ -198,44 +197,44 @@ object Form11: TForm11 end object GroupBox4: TGroupBox Left = 0 - Height = 734 - Top = 830 - Width = 658 - ClientHeight = 697 - ClientWidth = 654 + Height = 331 + Top = 379 + Width = 328 + ClientHeight = 311 + ClientWidth = 324 TabOrder = 3 object Label12: TLabel Left = 0 - Height = 57 + Height = 30 Top = 0 - Width = 654 + Width = 324 Align = alTop Alignment = taCenter Caption = 'Largest functions' - Font.Height = -42 + Font.Height = -21 ParentFont = False end object ToggleBox4: TToggleBox - Left = 16 - Height = 70 - Top = -16 - Width = 70 + Left = 8 + Height = 35 + Top = -8 + Width = 35 Caption = '<->' TabOrder = 0 OnChange = ToggleBox4Change end object Label15: TLabel - Left = 32 - Height = 32 - Top = 90 - Width = 216 + Left = 16 + Height = 15 + Top = 45 + Width = 106 Caption = 'Height by total lines' end object Chart1: TChart Left = 0 - Height = 559 - Top = 138 - Width = 654 + Height = 242 + Top = 69 + Width = 324 AxisList = < item Marks.LabelBrush.Style = bsClear @@ -263,104 +262,104 @@ object Form11: TForm11 end end object Label21: TLabel - Left = 548 - Height = 32 - Top = 90 - Width = 82 + Left = 272 + Height = 15 + Top = 45 + Width = 40 Anchors = [akTop, akRight] Caption = 'Label21' end end object GroupBox5: TGroupBox - Left = 658 - Height = 734 - Top = 830 - Width = 800 - ClientHeight = 697 - ClientWidth = 796 + Left = 328 + Height = 331 + Top = 379 + Width = 401 + ClientHeight = 311 + ClientWidth = 397 TabOrder = 4 object Label13: TLabel Left = 0 - Height = 57 + Height = 30 Top = 0 - Width = 796 + Width = 397 Align = alTop Alignment = taCenter Caption = 'Most complex files' - Font.Height = -42 + Font.Height = -21 ParentFont = False end object ToggleBox5: TToggleBox - Left = 16 - Height = 70 - Top = -16 - Width = 70 + Left = 8 + Height = 35 + Top = -8 + Width = 35 Caption = '<->' TabOrder = 0 OnChange = ToggleBox5Change end object Label16: TLabel - Left = 32 + Left = 16 Height = 1 - Top = 90 + Top = 45 Width = 1 end object Label18: TLabel - Left = 32 - Height = 32 - Top = 90 - Width = 483 + Left = 16 + Height = 15 + Top = 45 + Width = 242 Caption = 'Complexity by the McCabe cyclomatic Metric' end object Label22: TLabel - Left = 684 - Height = 32 - Top = 90 - Width = 82 + Left = 342 + Height = 15 + Top = 45 + Width = 40 Anchors = [akTop, akRight] Caption = 'Label22' end end object GroupBox6: TGroupBox - Left = 1458 - Height = 734 - Top = 830 - Width = 800 - ClientHeight = 697 - ClientWidth = 796 + Left = 729 + Height = 331 + Top = 379 + Width = 400 + ClientHeight = 311 + ClientWidth = 396 TabOrder = 5 object Label14: TLabel Left = 0 - Height = 57 + Height = 30 Top = 0 - Width = 796 + Width = 396 Align = alTop Alignment = taCenter Caption = 'Largest files' - Font.Height = -42 + Font.Height = -21 ParentFont = False end object ToggleBox6: TToggleBox - Left = 16 - Height = 70 - Top = -16 - Width = 70 + Left = 8 + Height = 35 + Top = -8 + Width = 35 Caption = '<->' TabOrder = 0 OnChange = ToggleBox6Change end object Label17: TLabel - Left = 32 - Height = 32 - Top = 90 - Width = 216 + Left = 16 + Height = 15 + Top = 45 + Width = 106 Caption = 'Height by total lines' end object Chart2: TChart Left = 0 - Height = 559 - Top = 138 - Width = 796 + Height = 242 + Top = 69 + Width = 396 AxisList = < item Marks.LabelBrush.Style = bsClear @@ -386,24 +385,24 @@ object Form11: TForm11 end end object Label23: TLabel - Left = 690 - Height = 32 - Top = 90 - Width = 82 + Left = 344 + Height = 15 + Top = 45 + Width = 40 Anchors = [akTop, akRight] Caption = 'Label23' end end object ChartToolset1: TChartToolset - Left = 176 - Top = 1072 + Left = 88 + Top = 536 object ChartToolset1DataPointHintTool1: TDataPointHintTool OnHint = ChartToolset1DataPointHintTool1Hint end end object ChartToolset2: TChartToolset - Left = 1648 - Top = 1056 + Left = 824 + Top = 528 object ChartToolset1DataPointHintTool2: TDataPointHintTool OnHint = ChartToolset1DataPointHintTool2Hint end diff --git a/src/unit11.pas b/src/unit11.pas index a54f7ac..c8bf545 100644 --- a/src/unit11.pas +++ b/src/unit11.pas @@ -159,7 +159,7 @@ fmcfuCursorElement: PCircle; fmcfiMousePos: TPoint; fmcfiCursorElement: PCircle; - fRootFolder: String; + fProject: TProject; fLargestFunctionsInfo: Array Of TLargestFunctionsInfo; fLargestFunctionsInfoIndex: Integer; fLargestFilesInfo: Array Of TLargestFilesInfo; @@ -274,7 +274,7 @@ If (fLargestFunctionsInfoIndex >= 0) And (fLargestFunctionsInfoIndex < length(fLargestFunctionsInfo)) Then Begin form13.OpenFile( - fRootFolder, fLargestFunctionsInfo[fLargestFunctionsInfoIndex].Filename, + fProject, fLargestFunctionsInfo[fLargestFunctionsInfoIndex].Filename, fLargestFunctionsInfo[fLargestFunctionsInfoIndex].Line ); End; @@ -286,7 +286,7 @@ If (fLargestFilesIndex >= 0) And (fLargestFilesIndex < length(fLargestFilesInfo)) Then Begin form13.OpenFile( - fRootFolder, fLargestFilesInfo[fLargestFilesIndex].Filename + fProject, fLargestFilesInfo[fLargestFilesIndex].Filename ); End; End; @@ -301,7 +301,7 @@ Procedure TForm11.InitCharts(aList: TProjectFilesInfo; Const aProject: TProject ); Begin - fRootFolder := aProject.RootFolder; + fProject := aProject; InitLineBreakdown(alist, aProject); InitDirectoryStructure(alist, aProject); InitMostComplexFunctions(alist, aProject); @@ -565,7 +565,7 @@ If assigned(fdsCursorElement) Then Begin If assigned(fdsCursorElement^.UserData) Then Begin If Not PDirInfo(fdsCursorElement^.UserData)^.isDir Then Begin - form13.OpenFile(fRootFolder, PDirInfo(fdsCursorElement^.UserData)^.Filename); + form13.OpenFile(fProject, PDirInfo(fdsCursorElement^.UserData)^.Filename); End; End; End; @@ -578,7 +578,7 @@ If assigned(fmcfuCursorElement) Then Begin If assigned(fmcfuCursorElement^.UserData) Then Begin p := PMCFunctionsInfo(fmcfuCursorElement^.UserData); - Form13.OpenFile(fRootFolder, p^.Filename, p^.Line); + Form13.OpenFile(fProject, p^.Filename, p^.Line); End; End; End; @@ -590,7 +590,7 @@ If assigned(fmcfiCursorElement) Then Begin If assigned(fmcfiCursorElement^.UserData) Then Begin p := PMCFilessInfo(fmcfiCursorElement^.UserData); - Form13.OpenFile(fRootFolder, p^.Filename); + Form13.OpenFile(fProject, p^.Filename); End; End; End; diff --git a/src/unit13.lfm b/src/unit13.lfm index f398601..0779a4d 100644 --- a/src/unit13.lfm +++ b/src/unit13.lfm @@ -1,567 +1,600 @@ object Form13: TForm13 Left = 335 - Height = 1200 + Height = 600 Top = 115 - Width = 1600 + Width = 800 Caption = 'Form13' - ClientHeight = 1200 - ClientWidth = 1600 - DesignTimePPI = 192 + ClientHeight = 600 + ClientWidth = 800 Position = poScreenCenter LCLVersion = '3.99.0.0' - inline SynEdit1: TSynEdit - Left = 16 - Height = 1104 - Top = 16 - Width = 1568 - Anchors = [akTop, akLeft, akRight, akBottom] - Color = clSilver - Font.Height = -26 - Font.Name = 'Courier New' - Font.Pitch = fpFixed - Font.Quality = fqNonAntialiased - ParentColor = False - ParentFont = False - TabOrder = 0 - Gutter.Width = 113 - Gutter.MouseActions = <> - RightGutter.Width = 0 - RightGutter.MouseActions = <> - Highlighter = SynPasSyn1 - Keystrokes = < - item - Command = ecUp - ShortCut = 38 - end - item - Command = ecSelUp - ShortCut = 8230 - end - item - Command = ecScrollUp - ShortCut = 16422 - end - item - Command = ecDown - ShortCut = 40 - end - item - Command = ecSelDown - ShortCut = 8232 - end - item - Command = ecScrollDown - ShortCut = 16424 - end - item - Command = ecLeft - ShortCut = 37 - end - item - Command = ecSelLeft - ShortCut = 8229 - end - item - Command = ecWordLeft - ShortCut = 16421 - end - item - Command = ecSelWordLeft - ShortCut = 24613 - end - item - Command = ecRight - ShortCut = 39 - end - item - Command = ecSelRight - ShortCut = 8231 - end - item - Command = ecWordRight - ShortCut = 16423 - end - item - Command = ecSelWordRight - ShortCut = 24615 - end - item - Command = ecPageDown - ShortCut = 34 - end - item - Command = ecSelPageDown - ShortCut = 8226 - end - item - Command = ecPageBottom - ShortCut = 16418 - end - item - Command = ecSelPageBottom - ShortCut = 24610 - end - item - Command = ecPageUp - ShortCut = 33 - end - item - Command = ecSelPageUp - ShortCut = 8225 - end - item - Command = ecPageTop - ShortCut = 16417 - end - item - Command = ecSelPageTop - ShortCut = 24609 - end - item - Command = ecLineStart - ShortCut = 36 - end - item - Command = ecSelLineStart - ShortCut = 8228 - end - item - Command = ecEditorTop - ShortCut = 16420 - end - item - Command = ecSelEditorTop - ShortCut = 24612 - end - item - Command = ecLineEnd - ShortCut = 35 - end - item - Command = ecSelLineEnd - ShortCut = 8227 - end - item - Command = ecEditorBottom - ShortCut = 16419 - end - item - Command = ecSelEditorBottom - ShortCut = 24611 - end - item - Command = ecToggleMode - ShortCut = 45 - end - item - Command = ecCopy - ShortCut = 16429 - end - item - Command = ecPaste - ShortCut = 8237 - end - item - Command = ecDeleteChar - ShortCut = 46 - end - item - Command = ecCut - ShortCut = 8238 - end - item - Command = ecDeleteLastChar - ShortCut = 8 - end - item - Command = ecDeleteLastChar - ShortCut = 8200 - end - item - Command = ecDeleteLastWord - ShortCut = 16392 - end - item - Command = ecUndo - ShortCut = 32776 - end - item - Command = ecRedo - ShortCut = 40968 - end - item - Command = ecLineBreak - ShortCut = 13 - end - item - Command = ecSelectAll - ShortCut = 16449 - end - item - Command = ecCopy - ShortCut = 16451 - end - item - Command = ecBlockIndent - ShortCut = 16457 - end - item - Command = ecLineBreak - ShortCut = 16461 - end - item - Command = ecInsertLine - ShortCut = 16462 - end - item - Command = ecDeleteWord - ShortCut = 16468 - end - item - Command = ecBlockUnindent - ShortCut = 16469 - end - item - Command = ecPaste - ShortCut = 16470 - end - item - Command = ecCut - ShortCut = 16472 - end - item - Command = ecDeleteLine - ShortCut = 16473 - end - item - Command = ecDeleteEOL - ShortCut = 24665 - end - item - Command = ecUndo - ShortCut = 16474 - end - item - Command = ecRedo - ShortCut = 24666 - end - item - Command = ecGotoMarker0 - ShortCut = 16432 - end - item - Command = ecGotoMarker1 - ShortCut = 16433 - end - item - Command = ecGotoMarker2 - ShortCut = 16434 - end - item - Command = ecGotoMarker3 - ShortCut = 16435 - end - item - Command = ecGotoMarker4 - ShortCut = 16436 - end - item - Command = ecGotoMarker5 - ShortCut = 16437 - end - item - Command = ecGotoMarker6 - ShortCut = 16438 - end - item - Command = ecGotoMarker7 - ShortCut = 16439 - end - item - Command = ecGotoMarker8 - ShortCut = 16440 - end - item - Command = ecGotoMarker9 - ShortCut = 16441 - end - item - Command = ecSetMarker0 - ShortCut = 24624 - end - item - Command = ecSetMarker1 - ShortCut = 24625 - end - item - Command = ecSetMarker2 - ShortCut = 24626 - end - item - Command = ecSetMarker3 - ShortCut = 24627 - end - item - Command = ecSetMarker4 - ShortCut = 24628 - end - item - Command = ecSetMarker5 - ShortCut = 24629 - end - item - Command = ecSetMarker6 - ShortCut = 24630 - end - item - Command = ecSetMarker7 - ShortCut = 24631 - end - item - Command = ecSetMarker8 - ShortCut = 24632 - end - item - Command = ecSetMarker9 - ShortCut = 24633 - end - item - Command = EcFoldLevel1 - ShortCut = 41009 - end - item - Command = EcFoldLevel2 - ShortCut = 41010 - end - item - Command = EcFoldLevel3 - ShortCut = 41011 - end - item - Command = EcFoldLevel4 - ShortCut = 41012 - end - item - Command = EcFoldLevel5 - ShortCut = 41013 - end - item - Command = EcFoldLevel6 - ShortCut = 41014 - end - item - Command = EcFoldLevel7 - ShortCut = 41015 - end - item - Command = EcFoldLevel8 - ShortCut = 41016 - end - item - Command = EcFoldLevel9 - ShortCut = 41017 - end - item - Command = EcFoldLevel0 - ShortCut = 41008 - end - item - Command = EcFoldCurrent - ShortCut = 41005 - end - item - Command = EcUnFoldCurrent - ShortCut = 41003 - end - item - Command = EcToggleMarkupWord - ShortCut = 32845 - end - item - Command = ecNormalSelect - ShortCut = 24654 - end - item - Command = ecColumnSelect - ShortCut = 24643 - end - item - Command = ecLineSelect - ShortCut = 24652 - end - item - Command = ecTab - ShortCut = 9 - end - item - Command = ecShiftTab - ShortCut = 8201 - end - item - Command = ecMatchBracket - ShortCut = 24642 - end - item - Command = ecColSelUp - ShortCut = 40998 - end - item - Command = ecColSelDown - ShortCut = 41000 - end - item - Command = ecColSelLeft - ShortCut = 40997 - end - item - Command = ecColSelRight - ShortCut = 40999 - end - item - Command = ecColSelPageDown - ShortCut = 40994 - end - item - Command = ecColSelPageBottom - ShortCut = 57378 - end - item - Command = ecColSelPageUp - ShortCut = 40993 - end - item - Command = ecColSelPageTop - ShortCut = 57377 - end - item - Command = ecColSelLineStart - ShortCut = 40996 - end - item - Command = ecColSelLineEnd - ShortCut = 40995 - end - item - Command = ecColSelEditorTop - ShortCut = 57380 - end - item - Command = ecColSelEditorBottom - ShortCut = 57379 - end> - MouseActions = <> - MouseTextActions = <> - MouseSelActions = <> - Lines.Strings = ( - '' - 'Var' - ' defcaption: String;' - '' - 'Implementation' - '' - '{$R *.lfm} ' - '' - 'Uses' - ' Forms, Dialogs, LCLType, math, Clipbrd, LCLIntf, IntfGraphics, fileutil // LCL- Units' - ' , dglOpenGL // OpenGL Header' - ' , unit7 // Rotate' - ' ;' - '' - '{ TPixelEditor }' - '' - 'Procedure TPixelEditor.OnNewButtonClick(Sender: TObject);' - 'Var' - ' s: String;' - 'Begin' - ' form3.Edit1.Text := inttostr(fImage.Width);' - ' form3.Edit2.Text := inttostr(fImage.Height);' - ' s := NewButton.hint;' - ' NewButton.hint := '''';' - ' If form3.ShowModal = mrOK Then Begin' - ' NewImage(strtointdef(form3.Edit1.Text, fImage.Width), strtointdef(form3.Edit2.Text, fImage.Height));' - ' End;' - ' NewButton.hint := s;' - 'End;' - ' ' - ) - VisibleSpecialChars = [vscSpace, vscTabAtLast] - SelectedColor.BackPriority = 50 - SelectedColor.ForePriority = 50 - SelectedColor.FramePriority = 50 - SelectedColor.BoldPriority = 50 - SelectedColor.ItalicPriority = 50 - SelectedColor.UnderlinePriority = 50 - SelectedColor.StrikeOutPriority = 50 - BracketHighlightStyle = sbhsBoth - BracketMatchColor.Background = clNone - BracketMatchColor.Foreground = clNone - BracketMatchColor.Style = [fsBold] - FoldedCodeColor.Background = clNone - FoldedCodeColor.Foreground = clGray - FoldedCodeColor.FrameColor = clGray - MouseLinkColor.Background = clNone - MouseLinkColor.Foreground = clBlue - LineHighlightColor.Background = clNone - LineHighlightColor.Foreground = clNone - inline SynLeftGutterPartList1: TSynGutterPartList - object SynGutterMarks1: TSynGutterMarks - Width = 48 - MouseActions = <> - MaxExtraMarksColums = 0 - Options = [sgmoDeDuplicateMarksOnOverflow] - end - object SynGutterLineNumber1: TSynGutterLineNumber - Width = 33 - MouseActions = <> - MarkupInfo.Background = clBtnFace - MarkupInfo.Foreground = clNone - DigitCount = 2 - ShowOnlyLineNumbersMultiplesOf = 1 - ZeroStart = False - LeadingZeros = False - end - object SynGutterChanges1: TSynGutterChanges - Width = 8 - MouseActions = <> - ModifiedColor = 59900 - SavedColor = clGreen - end - object SynGutterSeparator1: TSynGutterSeparator - Width = 4 - MouseActions = <> - MarkupInfo.Background = clWhite - MarkupInfo.Foreground = clGray - end - object SynGutterCodeFolding1: TSynGutterCodeFolding - Width = 20 - MouseActions = <> - MarkupInfo.Background = clNone - MarkupInfo.Foreground = clGray - MouseActionsExpanded = <> - MouseActionsCollapsed = <> - end - end - end + OnCloseQuery = FormCloseQuery + OnCreate = FormCreate object Button1: TButton - Left = 1434 - Height = 50 - Top = 1136 - Width = 150 + Left = 717 + Height = 25 + Top = 568 + Width = 75 Anchors = [akRight, akBottom] Caption = 'Close' ModalResult = 3 - TabOrder = 1 + TabOrder = 0 end object Button2: TButton - Left = 16 - Height = 50 - Top = 1136 - Width = 300 + Left = 8 + Height = 25 + Top = 568 + Width = 150 Anchors = [akLeft, akBottom] Caption = 'Editor options' - TabOrder = 2 + TabOrder = 1 OnClick = Button2Click end + object Panel1: TPanel + Left = 8 + Height = 554 + Top = 8 + Width = 784 + Anchors = [akTop, akLeft, akRight, akBottom] + Caption = 'Panel1' + ClientHeight = 554 + ClientWidth = 784 + TabOrder = 2 + inline SynEdit1: TSynEdit + Left = 8 + Height = 496 + Top = 16 + Width = 432 + Color = clSilver + Font.Height = -13 + Font.Name = 'Courier New' + Font.Pitch = fpFixed + Font.Quality = fqNonAntialiased + ParentColor = False + ParentFont = False + PopupMenu = PopupMenu1 + TabOrder = 0 + BookMarkOptions.BookmarkImages = ImageList1 + Gutter.Width = 57 + Gutter.MouseActions = <> + RightGutter.Width = 0 + RightGutter.MouseActions = <> + Highlighter = SynPasSyn1 + Keystrokes = < + item + Command = ecUp + ShortCut = 38 + end + item + Command = ecSelUp + ShortCut = 8230 + end + item + Command = ecScrollUp + ShortCut = 16422 + end + item + Command = ecDown + ShortCut = 40 + end + item + Command = ecSelDown + ShortCut = 8232 + end + item + Command = ecScrollDown + ShortCut = 16424 + end + item + Command = ecLeft + ShortCut = 37 + end + item + Command = ecSelLeft + ShortCut = 8229 + end + item + Command = ecWordLeft + ShortCut = 16421 + end + item + Command = ecSelWordLeft + ShortCut = 24613 + end + item + Command = ecRight + ShortCut = 39 + end + item + Command = ecSelRight + ShortCut = 8231 + end + item + Command = ecWordRight + ShortCut = 16423 + end + item + Command = ecSelWordRight + ShortCut = 24615 + end + item + Command = ecPageDown + ShortCut = 34 + end + item + Command = ecSelPageDown + ShortCut = 8226 + end + item + Command = ecPageBottom + ShortCut = 16418 + end + item + Command = ecSelPageBottom + ShortCut = 24610 + end + item + Command = ecPageUp + ShortCut = 33 + end + item + Command = ecSelPageUp + ShortCut = 8225 + end + item + Command = ecPageTop + ShortCut = 16417 + end + item + Command = ecSelPageTop + ShortCut = 24609 + end + item + Command = ecLineStart + ShortCut = 36 + end + item + Command = ecSelLineStart + ShortCut = 8228 + end + item + Command = ecEditorTop + ShortCut = 16420 + end + item + Command = ecSelEditorTop + ShortCut = 24612 + end + item + Command = ecLineEnd + ShortCut = 35 + end + item + Command = ecSelLineEnd + ShortCut = 8227 + end + item + Command = ecEditorBottom + ShortCut = 16419 + end + item + Command = ecSelEditorBottom + ShortCut = 24611 + end + item + Command = ecToggleMode + ShortCut = 45 + end + item + Command = ecCopy + ShortCut = 16429 + end + item + Command = ecPaste + ShortCut = 8237 + end + item + Command = ecDeleteChar + ShortCut = 46 + end + item + Command = ecCut + ShortCut = 8238 + end + item + Command = ecDeleteLastChar + ShortCut = 8 + end + item + Command = ecDeleteLastChar + ShortCut = 8200 + end + item + Command = ecDeleteLastWord + ShortCut = 16392 + end + item + Command = ecUndo + ShortCut = 32776 + end + item + Command = ecRedo + ShortCut = 40968 + end + item + Command = ecLineBreak + ShortCut = 13 + end + item + Command = ecSelectAll + ShortCut = 16449 + end + item + Command = ecCopy + ShortCut = 16451 + end + item + Command = ecBlockIndent + ShortCut = 16457 + end + item + Command = ecLineBreak + ShortCut = 16461 + end + item + Command = ecInsertLine + ShortCut = 16462 + end + item + Command = ecDeleteWord + ShortCut = 16468 + end + item + Command = ecBlockUnindent + ShortCut = 16469 + end + item + Command = ecPaste + ShortCut = 16470 + end + item + Command = ecCut + ShortCut = 16472 + end + item + Command = ecDeleteLine + ShortCut = 16473 + end + item + Command = ecDeleteEOL + ShortCut = 24665 + end + item + Command = ecUndo + ShortCut = 16474 + end + item + Command = ecRedo + ShortCut = 24666 + end + item + Command = ecGotoMarker0 + ShortCut = 16432 + end + item + Command = ecGotoMarker1 + ShortCut = 16433 + end + item + Command = ecGotoMarker2 + ShortCut = 16434 + end + item + Command = ecGotoMarker3 + ShortCut = 16435 + end + item + Command = ecGotoMarker4 + ShortCut = 16436 + end + item + Command = ecGotoMarker5 + ShortCut = 16437 + end + item + Command = ecGotoMarker6 + ShortCut = 16438 + end + item + Command = ecGotoMarker7 + ShortCut = 16439 + end + item + Command = ecGotoMarker8 + ShortCut = 16440 + end + item + Command = ecGotoMarker9 + ShortCut = 16441 + end + item + Command = ecSetMarker0 + ShortCut = 24624 + end + item + Command = ecSetMarker1 + ShortCut = 24625 + end + item + Command = ecSetMarker2 + ShortCut = 24626 + end + item + Command = ecSetMarker3 + ShortCut = 24627 + end + item + Command = ecSetMarker4 + ShortCut = 24628 + end + item + Command = ecSetMarker5 + ShortCut = 24629 + end + item + Command = ecSetMarker6 + ShortCut = 24630 + end + item + Command = ecSetMarker7 + ShortCut = 24631 + end + item + Command = ecSetMarker8 + ShortCut = 24632 + end + item + Command = ecSetMarker9 + ShortCut = 24633 + end + item + Command = EcFoldLevel1 + ShortCut = 41009 + end + item + Command = EcFoldLevel2 + ShortCut = 41010 + end + item + Command = EcFoldLevel3 + ShortCut = 41011 + end + item + Command = EcFoldLevel4 + ShortCut = 41012 + end + item + Command = EcFoldLevel5 + ShortCut = 41013 + end + item + Command = EcFoldLevel6 + ShortCut = 41014 + end + item + Command = EcFoldLevel7 + ShortCut = 41015 + end + item + Command = EcFoldLevel8 + ShortCut = 41016 + end + item + Command = EcFoldLevel9 + ShortCut = 41017 + end + item + Command = EcFoldLevel0 + ShortCut = 41008 + end + item + Command = EcFoldCurrent + ShortCut = 41005 + end + item + Command = EcUnFoldCurrent + ShortCut = 41003 + end + item + Command = EcToggleMarkupWord + ShortCut = 32845 + end + item + Command = ecNormalSelect + ShortCut = 24654 + end + item + Command = ecColumnSelect + ShortCut = 24643 + end + item + Command = ecLineSelect + ShortCut = 24652 + end + item + Command = ecTab + ShortCut = 9 + end + item + Command = ecShiftTab + ShortCut = 8201 + end + item + Command = ecMatchBracket + ShortCut = 24642 + end + item + Command = ecColSelUp + ShortCut = 40998 + end + item + Command = ecColSelDown + ShortCut = 41000 + end + item + Command = ecColSelLeft + ShortCut = 40997 + end + item + Command = ecColSelRight + ShortCut = 40999 + end + item + Command = ecColSelPageDown + ShortCut = 40994 + end + item + Command = ecColSelPageBottom + ShortCut = 57378 + end + item + Command = ecColSelPageUp + ShortCut = 40993 + end + item + Command = ecColSelPageTop + ShortCut = 57377 + end + item + Command = ecColSelLineStart + ShortCut = 40996 + end + item + Command = ecColSelLineEnd + ShortCut = 40995 + end + item + Command = ecColSelEditorTop + ShortCut = 57380 + end + item + Command = ecColSelEditorBottom + ShortCut = 57379 + end> + MouseActions = <> + MouseTextActions = <> + MouseSelActions = <> + Lines.Strings = ( + '' + 'Var' + ' defcaption: String;' + '' + 'Implementation' + '' + '{$R *.lfm} ' + '' + 'Uses' + ' Forms, Dialogs, LCLType, math, Clipbrd, LCLIntf, IntfGraphics, fileutil // LCL- Units' + ' , dglOpenGL // OpenGL Header' + ' , unit7 // Rotate' + ' ;' + '' + '{ TPixelEditor }' + '' + 'Procedure TPixelEditor.OnNewButtonClick(Sender: TObject);' + 'Var' + ' s: String;' + 'Begin' + ' form3.Edit1.Text := inttostr(fImage.Width);' + ' form3.Edit2.Text := inttostr(fImage.Height);' + ' s := NewButton.hint;' + ' NewButton.hint := '''';' + ' If form3.ShowModal = mrOK Then Begin' + ' NewImage(strtointdef(form3.Edit1.Text, fImage.Width), strtointdef(form3.Edit2.Text, fImage.Height));' + ' End;' + ' NewButton.hint := s;' + 'End;' + ' ' + ) + VisibleSpecialChars = [vscSpace, vscTabAtLast] + SelectedColor.BackPriority = 50 + SelectedColor.ForePriority = 50 + SelectedColor.FramePriority = 50 + SelectedColor.BoldPriority = 50 + SelectedColor.ItalicPriority = 50 + SelectedColor.UnderlinePriority = 50 + SelectedColor.StrikeOutPriority = 50 + BracketHighlightStyle = sbhsBoth + BracketMatchColor.Background = clNone + BracketMatchColor.Foreground = clNone + BracketMatchColor.Style = [fsBold] + FoldedCodeColor.Background = clNone + FoldedCodeColor.Foreground = clGray + FoldedCodeColor.FrameColor = clGray + MouseLinkColor.Background = clNone + MouseLinkColor.Foreground = clBlue + LineHighlightColor.Background = clNone + LineHighlightColor.Foreground = clNone + OnChange = SynEdit1Change + OnGutterClick = SynEdit1GutterClick + inline SynLeftGutterPartList1: TSynGutterPartList + object SynGutterMarks1: TSynGutterMarks + Width = 24 + MouseActions = <> + MaxExtraMarksColums = 0 + Options = [sgmoDeDuplicateMarksOnOverflow] + end + object SynGutterLineNumber1: TSynGutterLineNumber + Width = 17 + MouseActions = <> + MarkupInfo.Background = clBtnFace + MarkupInfo.Foreground = clNone + DigitCount = 2 + ShowOnlyLineNumbersMultiplesOf = 1 + ZeroStart = False + LeadingZeros = False + end + object SynGutterChanges1: TSynGutterChanges + Width = 4 + MouseActions = <> + ModifiedColor = 59900 + SavedColor = clGreen + end + object SynGutterSeparator1: TSynGutterSeparator + Width = 2 + MouseActions = <> + MarkupInfo.Background = clWhite + MarkupInfo.Foreground = clGray + end + object SynGutterCodeFolding1: TSynGutterCodeFolding + MouseActions = <> + MarkupInfo.Background = clNone + MarkupInfo.Foreground = clGray + MouseActionsExpanded = <> + MouseActionsCollapsed = <> + end + end + end + object ScrollBox1: TScrollBox + Left = 600 + Height = 296 + Top = 16 + Width = 176 + HorzScrollBar.Page = 1 + VertScrollBar.Page = 1 + PopupMenu = PopupMenu2 + TabOrder = 1 + OnResize = ScrollBox1Resize + end + object Splitter1: TSplitter + Left = 456 + Height = 336 + Top = 16 + Width = 5 + Align = alNone + MinSize = 128 + end + end object SynPasSyn1: TSynPasSyn Enabled = False CommentAttri.Foreground = clGray @@ -573,7 +606,48 @@ object Form13: TForm13 NestedComments = False TypeHelpers = True StringMultilineMode = [] - Left = 816 - Top = 96 + Left = 408 + Top = 48 + end + object PopupMenu1: TPopupMenu + Left = 304 + Top = 48 + object MenuItem1: TMenuItem + Caption = 'Save' + ShortCut = 16467 + OnClick = MenuItem1Click + end + end + object ImageList1: TImageList + Left = 496 + Top = 48 + Bitmap = { + 4C7A010000001000000010000000530100000000000078DAFBCFF07F50405E2E + F6FF151196FFB7B484FDDFD11E8113B7273BFE9712E1FD8FAEBF21CEEEFFAD83 + 2BFFFFFDF3FB3F3E70FFE496FFF34B7CFEB3B230C3CDE06467FDBFAD2DFCFFBF + 7F7FFFFFFBF6E1FFBF4F2FFFFFFBF8ECFFBFF74FFEFF7BF7F0FFBF37F7FEFF7D + 751B88EF80CD38BEA0FABFBAAC305CBF9800F7FF035373C072FF3EBEF8FFEF03 + 48EFE3FFFFDE3E00EABD0BD1FBE2FAFFBFCFAE82D59C5DD5F9DF5C430ABBFE0F + 4F81763E82E87D0DD4FBF21654EF95FF7F9F5CC4AA1FC5FD20B7BFB9FFFFEFEB + 3B40BD37FFFF7D7E0DA8F73250EF85FF7FA0FA4F2CAAFDAF252FF21F5BF881CC + 400620B7FC7D7C016C2E72F8B1B3B2FCC7167F2077C0E2EAEA8EB970737E7C7E + 0FE6CF2CF0C41A7FD8E0FC529FFF5FDF3D07EBDBDC1CF63FDA59E73FB1E929CD + DBF0FF956D33FF6F6C0AFD1F64A3FE9F94B42829C4F37F6199EF7F4F53E5FFFF + 1986370400FCEF7B5C + } + end + object SaveDialog3: TSaveDialog + DefaultExt = '.csv' + Filter = 'Comma separated file|*.csv|All|*.*' + Left = 672 + Top = 120 + end + object PopupMenu2: TPopupMenu + Left = 672 + Top = 48 + object MenuItem2: TMenuItem + Caption = 'Export comments' + OnClick = MenuItem2Click + end end end diff --git a/src/unit13.pas b/src/unit13.pas index 3a55ba1..0cae389 100644 --- a/src/unit13.pas +++ b/src/unit13.pas @@ -19,8 +19,9 @@ Interface Uses - Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, SynEdit, - SynHighlighterPas, SynPopupMenu; + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus, + ExtCtrls, SynEdit, SynHighlighterPas, SynEditMarks, uCommentFrame, + ufpc_understand; Type @@ -29,15 +30,38 @@ TForm13 = Class(TForm) Button1: TButton; Button2: TButton; + ImageList1: TImageList; + MenuItem1: TMenuItem; + MenuItem2: TMenuItem; + Panel1: TPanel; + PopupMenu1: TPopupMenu; + PopupMenu2: TPopupMenu; + SaveDialog3: TSaveDialog; + ScrollBox1: TScrollBox; + Splitter1: TSplitter; SynEdit1: TSynEdit; SynPasSyn1: TSynPasSyn; Procedure Button2Click(Sender: TObject); + Procedure FormCloseQuery(Sender: TObject; Var CanClose: Boolean); + Procedure FormCreate(Sender: TObject); + Procedure MenuItem1Click(Sender: TObject); + Procedure MenuItem2Click(Sender: TObject); + Procedure ScrollBox1Resize(Sender: TObject); + Procedure SynEdit1Change(Sender: TObject); + Procedure SynEdit1GutterClick(Sender: TObject; X, Y, Line: integer; + mark: TSynEditMark); private + fProject: TProject; frelativeFilename: String; fAbsoluteFilename: String; + fFrameNameCounter: integer; + Procedure RepositionAllComments; + Function AddLineMark(Line: Integer): TCommentFrame; + Procedure RemoveLineMark(Line: integer); + Procedure OnRemoveCommentClick(Sender: TObject); + Procedure OnSelectLineComment(Sender: TObject); public - Procedure OpenFile(Const Rootfolder, Filename: String; aLine: integer = -1); - + Procedure OpenFile(Project: TProject; Const Filename: String; aLine: integer = -1); End; Var @@ -47,8 +71,6 @@ {$R *.lfm} -Uses ufpc_understand; - { TForm13 } Procedure TForm13.Button2Click(Sender: TObject); @@ -56,13 +78,243 @@ showmessage('Todo.'); End; -Procedure TForm13.OpenFile(Const Rootfolder, Filename: String; aLine: integer); +Procedure TForm13.FormCloseQuery(Sender: TObject; Var CanClose: Boolean); +Var + i: Integer; + f: TCommentFrame; +Begin + // Speichern aller Unit Kommentare + For i := 0 To ScrollBox1.ComponentCount - 1 Do Begin + f := ScrollBox1.Components[i] As TCommentFrame; + fProject.SetLineComment(frelativeFilename, f.Line, f.Memo1.Text); + End; +End; + +Procedure TForm13.FormCreate(Sender: TObject); +Begin + ScrollBox1.Align := alRight; + Splitter1.Align := alRight; + SynEdit1.Align := alClient; + fFrameNameCounter := 0; +End; + +Procedure TForm13.MenuItem1Click(Sender: TObject); Begin + SynEdit1.Lines.SaveToFile(fAbsoluteFilename); + caption := 'File preview: ' + ExtractFileName(frelativeFilename); +End; + +Procedure TForm13.MenuItem2Click(Sender: TObject); +Var + c: TLineComments; + i: Integer; +Begin + // Export Comments + If ScrollBox1.ComponentCount = 0 Then Begin + showmessage('Error, nothing to export.'); + exit; + End; + setlength(c, ScrollBox1.ComponentCount); + For i := 0 To high(c) Do Begin + c[i].Line := (ScrollBox1.Components[i] As TCommentFrame).Line; + c[i].Filename := frelativeFilename; + c[i].Comment := (ScrollBox1.Components[i] As TCommentFrame).Memo1.Text; + End; + If SaveDialog3.Execute Then Begin + ExportCommentsAsCSV(c, SaveDialog3.FileName); + End; +End; + +Procedure TForm13.ScrollBox1Resize(Sender: TObject); +Var + i: Integer; +Begin + // Ändert sich die Breite der Scrollbox muss das noch mal "Händisch" Korrigiert werden + For i := 0 To ScrollBox1.ComponentCount - 1 Do Begin + (ScrollBox1.Components[i] As TCommentFrame).Width := ScrollBox1.ClientWidth; + End; +End; + +Procedure TForm13.SynEdit1Change(Sender: TObject); +Var + s: String; +Begin + s := caption; + If (s <> '') And (s[length(s)] <> '*') Then Begin + caption := caption + '*'; + End; +End; + +Procedure TForm13.SynEdit1GutterClick(Sender: TObject; X, Y, Line: integer; + mark: TSynEditMark); +Begin + AddLineMark(Line); +End; + +Procedure TForm13.RepositionAllComments; +Var + a: Array Of TCommentFrame; // Scrollbox1.Components läst kein reorder zu :( also muss über diesen Zwischenschritt sortiert werden + + Procedure Quick(li, re: integer); + Var + l, r, p: Integer; + h: TCommentFrame; + Begin + If Li < Re Then Begin + p := a[Trunc((li + re) / 2)].Line; // Auslesen des Pivo Elementes + l := Li; + r := re; + While l < r Do Begin + While a[l].Line < p Do + inc(l); + While a[r].Line > p Do + dec(r); + If L <= R Then Begin + h := a[l]; + a[l] := a[r]; + a[r] := h; + inc(l); + dec(r); + End; + End; + quick(li, r); + quick(l, re); + End; + End; + +Var + i: Integer; +Begin + // 1. Sortieren der Components nach Line Aufsteigend + setlength(a, ScrollBox1.ComponentCount); + For i := 0 To high(a) Do Begin + a[i] := ScrollBox1.Components[i] As TCommentFrame; + End; + Quick(0, ScrollBox1.ComponentCount - 1); + For i := 0 To high(a) Do Begin + a[i].Order := i; + End; + // 2. Top eigenschaften anpassen + For i := 0 To ScrollBox1.ComponentCount - 1 Do Begin + (ScrollBox1.Components[i] As TCommentFrame).Top := (ScrollBox1.Components[0] As TCommentFrame).Height * (ScrollBox1.Components[i] As TCommentFrame).Order; + End; +End; + +Function TForm13.AddLineMark(Line: Integer): TCommentFrame; + Procedure SelectLine; + Var + i: integer; + Begin + // Scrollt die Scrollbox so hin, das das "Line" Element ausgewählt wird + // Und setzt den Fokus ins Memo + For i := 0 To ScrollBox1.ControlCount - 1 Do Begin + If (ScrollBox1.Components[i] As TCommentFrame).Line = Line Then Begin + ScrollBox1.ScrollInView(ScrollBox1.Components[i] As TControl); + If visible Then (ScrollBox1.Components[i] As TCommentFrame).Memo1.SetFocus; + result := ScrollBox1.Components[i] As TCommentFrame; + break; + End; + End; + // Scrollt das Synedit falls dieses die Zeile nicht anzeigt + If (line < SynEdit1.TopLine) Or (line >= SynEdit1.TopLine + SynEdit1.Height Div SynEdit1.LineHeight) Then Begin + SynEdit1.TopLine := SynEdit1.Lines.Count - 1; + SynEdit1.TopLine := Line; + End; + End; +Var + m: TSynEditMark; + f: TCommentFrame; + i: Integer; +Begin + result := Nil; + // 1. Suchen ob es die Markierung bereits gibt + For i := 0 To SynEdit1.Marks.Count - 1 Do Begin + If SynEdit1.Marks[i].Line = Line Then Begin + // Wenn Ja wählen wir sie Seitlich an ... + SelectLine; + exit; + End; + End; + // Wenn Nein wird sie erstellt ;) + m := TSynEditMark.Create(SynEdit1); + m.BookmarkNumber := 0; + m.Line := Line; + m.ImageList := ImageList1; + m.ImageIndex := 0; + m.Visible := true; + SynEdit1.Marks.Add(m); + f := TCommentFrame.Create(ScrollBox1); + fFrameNameCounter := fFrameNameCounter + 1; + f.name := 'Comment' + inttostr(fFrameNameCounter); + f.Parent := ScrollBox1; + f.Line := Line; + f.Width := ScrollBox1.ClientWidth; + f.Anchors := [akLeft, akTop]; // akRight funktioniert hier nicht, deswegen wird das im OnResize korrigiert + f.Button1.OnClick := @OnRemoveCommentClick; + f.Memo1.OnClick := @OnSelectLineComment; + f.PopupMenu := PopupMenu2; + f.Memo1.PopupMenu := PopupMenu2; + RepositionAllComments; + SelectLine; +End; + +Procedure TForm13.RemoveLineMark(Line: integer); +Var + i: Integer; +Begin + For i := 0 To SynEdit1.Marks.Count - 1 Do Begin + If SynEdit1.Marks[i].Line = Line Then Begin + SynEdit1.Marks[i].Free; + break; + End; + End; + For i := 0 To ScrollBox1.ComponentCount - 1 Do Begin + If (ScrollBox1.Components[i] As TCommentFrame).Line = Line Then Begin + ScrollBox1.Components[i].Free; + break; + End; + End; + fProject.RemoveLineComment(frelativeFilename, line); + RepositionAllComments; +End; + +Procedure TForm13.OnRemoveCommentClick(Sender: TObject); +Begin + RemoveLineMark(((sender As TButton).Parent As TCommentFrame).Line); +End; + +Procedure TForm13.OnSelectLineComment(Sender: TObject); +Begin + // Add ist hier eigentlich falsch, aber der Add code selectiert auch, wenn Line bereits existiert, also stimmts doch wieder ;) + AddLineMark(((sender As TMemo).Parent As TCommentFrame).Line); +End; + +Procedure TForm13.OpenFile(Project: TProject; Const Filename: String; + aLine: integer); +Var + i: Integer; + c: TLineComments; + f: TCommentFrame; +Begin + fProject := Project; frelativeFilename := Filename; - fAbsoluteFilename := ConcatRelativePath(Rootfolder, Filename); + fAbsoluteFilename := ConcatRelativePath(fProject.Rootfolder, Filename); If FileExists(fAbsoluteFilename) Then Begin SynEdit1.Lines.LoadFromFile(fAbsoluteFilename); + For i := SynEdit1.Marks.Count - 1 Downto 0 Do Begin + SynEdit1.Marks[i].free; + End; + For i := ScrollBox1.ComponentCount - 1 Downto 0 Do Begin + ScrollBox1.Components[i].free; + End; + c := fProject.GetLineComments(); + For i := 0 To high(c) Do Begin + If c[i].Filename = frelativeFilename Then Begin + f := AddLineMark(c[i].Line); + f.Memo1.Text := c[i].Comment; + End; + End; SynEdit1.TopLine := 0; If aLine <> -1 Then Begin SynEdit1.TopLine := SynEdit1.Lines.Count - 1; diff --git a/src/unit3.lfm b/src/unit3.lfm index 4234215..0288cc1 100644 --- a/src/unit3.lfm +++ b/src/unit3.lfm @@ -1,20 +1,19 @@ object Form3: TForm3 Left = 335 - Height = 1226 + Height = 613 Top = 112 - Width = 1952 + Width = 976 Caption = 'Form3' - ClientHeight = 1226 - ClientWidth = 1952 - DesignTimePPI = 192 + ClientHeight = 613 + ClientWidth = 976 Position = poScreenCenter LCLVersion = '3.99.0.0' OnCreate = FormCreate OnDestroy = FormDestroy object LazVirtualStringTree1: TLazVirtualStringTree - Left = 16 + Left = 8 Height = 608 - Top = 16 + Top = 8 Width = 1536 DefaultText = 'Node' Header.AutoSizeIndex = 0 @@ -22,18 +21,18 @@ object Form3: TForm3 item Position = 0 Text = 'Class' - Width = 600 + Width = 300 end item Position = 1 Text = 'File' - Width = 600 + Width = 300 end item Position = 2 Text = 'Line' end> - Header.Height = 82 + Header.Height = 41 Header.Options = [hoColumnResize, hoShowSortGlyphs, hoVisible, hoAutoSpring] PopupMenu = PopupMenu1 TabOrder = 0 @@ -43,31 +42,31 @@ object Form3: TForm3 OnGetNodeDataSize = LazVirtualStringTree1GetNodeDataSize end object Button1: TButton - Left = 48 - Height = 50 - Top = 720 - Width = 150 + Left = 24 + Height = 25 + Top = 360 + Width = 75 Caption = 'OK' TabOrder = 1 OnClick = Button1Click end object StatusBar1: TStatusBar Left = 0 - Height = 44 - Top = 1182 - Width = 1952 + Height = 23 + Top = 590 + Width = 976 Panels = < item - Width = 500 + Width = 250 end item - Width = 100 + Width = 50 end> SimplePanel = False end object PopupMenu1: TPopupMenu - Left = 406 - Top = 230 + Left = 203 + Top = 115 object MenuItem2: TMenuItem Caption = 'Open code' OnClick = LazVirtualStringTree1DblClick @@ -80,7 +79,7 @@ object Form3: TForm3 object SaveDialog1: TSaveDialog DefaultExt = '.csv' Filter = 'CSV-File|*.csv|All|*.*' - Left = 400 - Top = 352 + Left = 200 + Top = 176 end end diff --git a/src/unit3.pas b/src/unit3.pas index 0d15b29..418c0a8 100644 --- a/src/unit3.pas +++ b/src/unit3.pas @@ -64,9 +64,9 @@ private CSV_export: TStringList; fList: TProjectFilesInfo; // Das wird aktuell noch nicht verwendet, könnte aber - fRootFolder: String; + fProject: TProject; public - Function LoadClasses(aList: TProjectFilesInfo; RootFolder: String): Boolean; + Function LoadClasses(aList: TProjectFilesInfo; Project: TProject): Boolean; End; Var @@ -283,7 +283,7 @@ //adata^.Columns[0] := Root^.RootElement.Name; //adata^.Columns[1] := Root^.RootElement.FileName; //adata^.Columns[2] := Root^.RootElement.Line; - Form13.OpenFile(fRootFolder, adata^.Columns[1], strtointdef(adata^.Columns[2], -1)); + Form13.OpenFile(fProject, adata^.Columns[1], strtointdef(adata^.Columns[2], -1)); End; End; End; @@ -327,7 +327,7 @@ End; End; -Function TForm3.LoadClasses(aList: TProjectFilesInfo; RootFolder: String +Function TForm3.LoadClasses(aList: TProjectFilesInfo; Project: TProject ): Boolean; Var ClassCount: integer; @@ -360,7 +360,7 @@ aRoot: PVirtualNode; it: TItem; Begin - fRootFolder := RootFolder; + fProject := Project; result := false; If high(aList) = -1 Then exit; fList := aList; diff --git a/src/unit4.pas b/src/unit4.pas index ef16d92..dec06c9 100644 --- a/src/unit4.pas +++ b/src/unit4.pas @@ -35,9 +35,9 @@ Procedure FormCreate(Sender: TObject); private fColors: TCCColors; - fRootFolder: String; + fProject: TProject; public - Function CountFiles(aList: TProjectFilesInfo; Colors: TCCColors; RootFolder: String): Boolean; + Function CountFiles(aList: TProjectFilesInfo; Project: TProject): Boolean; End; Var @@ -51,12 +51,12 @@ { TForm4 } -Procedure TForm4.Button1Click(Sender: TObject); +procedure TForm4.Button1Click(Sender: TObject); Begin close; End; -Procedure TForm4.Button2Click(Sender: TObject); +procedure TForm4.Button2Click(Sender: TObject); Begin // Details form6.SetColors(fColors); @@ -64,7 +64,7 @@ form6.ShowModal; End; -Procedure TForm4.FormCreate(Sender: TObject); +procedure TForm4.FormCreate(Sender: TObject); Begin caption := 'Code Statistics'; button1.Align := alBottom; @@ -72,8 +72,8 @@ Memo1.Align := alClient; End; -Function TForm4.CountFiles(aList: TProjectFilesInfo; Colors: TCCColors; - RootFolder: String): Boolean; +function TForm4.CountFiles(aList: TProjectFilesInfo; Project: TProject + ): Boolean; Var j, minCC, i, MethodeCount, CCSum, maxCC: Integer; minCCName, maxCCName, minCCFileName, maxCCFileName: String; @@ -82,11 +82,11 @@ NumberOfCodeLines, NumberofCommentLines, TotalLines, EmptyLines: integer; lmaxCC, lCCSum: Integer; Begin - fRootFolder := RootFolder; - form6.RootFolder := RootFolder; + fProject := Project; + form6.fProject := Project; result := false; If high(aList) = -1 Then exit; - fColors := Colors; + fColors := Project.CCColors; MethodeCount := 0; CCSum := 0; minCC := high(Integer); diff --git a/src/unit5.lfm b/src/unit5.lfm index 309a77b..14c6f90 100644 --- a/src/unit5.lfm +++ b/src/unit5.lfm @@ -1,40 +1,39 @@ object Form5: TForm5 Left = 347 - Height = 1290 + Height = 645 Top = 107 - Width = 1886 + Width = 943 Caption = 'Form5' - ClientHeight = 1290 - ClientWidth = 1886 - DesignTimePPI = 192 + ClientHeight = 645 + ClientWidth = 943 Position = poScreenCenter LCLVersion = '3.99.0.0' OnCreate = FormCreate object Panel1: TPanel Left = 0 - Height = 1200 + Height = 600 Top = 0 - Width = 1886 + Width = 943 Align = alClient Caption = 'Panel1' - ClientHeight = 1200 - ClientWidth = 1886 + ClientHeight = 600 + ClientWidth = 943 TabOrder = 0 object ListBox1: TListBox Left = 1 - Height = 1198 + Height = 598 Top = 1 - Width = 432 + Width = 216 Align = alLeft ItemHeight = 0 TabOrder = 0 OnClick = ListBox1Click end object StringGrid1: TStringGrid - Left = 443 - Height = 1198 + Left = 222 + Height = 598 Top = 1 - Width = 1442 + Width = 720 Align = alClient ColCount = 8 Columns = < @@ -73,27 +72,27 @@ object Form5: TForm5 OnPrepareCanvas = StringGrid1PrepareCanvas end object Splitter1: TSplitter - Left = 433 - Height = 1198 + Left = 217 + Height = 598 Top = 1 - Width = 10 + Width = 5 end end object Panel2: TPanel Left = 0 - Height = 90 - Top = 1200 - Width = 1886 + Height = 45 + Top = 600 + Width = 943 Align = alBottom Caption = 'Panel2' - ClientHeight = 90 - ClientWidth = 1886 + ClientHeight = 45 + ClientWidth = 943 TabOrder = 1 object Button1: TButton - Left = 16 - Height = 50 - Top = 16 - Width = 1852 + Left = 8 + Height = 25 + Top = 8 + Width = 926 Anchors = [akTop, akLeft, akRight, akBottom] Caption = 'Close' TabOrder = 0 @@ -101,8 +100,8 @@ object Form5: TForm5 end end object PopupMenu1: TPopupMenu - Left = 1044 - Top = 526 + Left = 522 + Top = 263 object MenuItem3: TMenuItem Caption = 'Open code' OnClick = StringGrid1DblClick @@ -119,7 +118,7 @@ object Form5: TForm5 object SaveDialog1: TSaveDialog DefaultExt = '.csv' Filter = 'CSV-File|*.csv|All|*.*' - Left = 512 - Top = 464 + Left = 256 + Top = 232 end end diff --git a/src/unit5.pas b/src/unit5.pas index 3003a96..b786100 100644 --- a/src/unit5.pas +++ b/src/unit5.pas @@ -54,9 +54,9 @@ fCCColors: TCCColors; fFileInfos: Array Of TProcInfos; fStringGridSortDirection: Boolean; - fRootfolder: String; + fProject: TProject; public - Function LoadFunctions(aList: TProjectFilesInfo; Colors: TCCColors; Rootfolder: String): Boolean; + Function LoadFunctions(aList: TProjectFilesInfo; Project: TProject): Boolean; End; Var @@ -170,12 +170,12 @@ // Open Code If StringGrid1.Selection.Top <> -1 Then Begin // Es gibt etwas zum Anspringen - form13.OpenFile(fRootfolder, ListBox1.Items[ListBox1.ItemIndex], strtointdef(StringGrid1.Cells[IndexLine, StringGrid1.Selection.Top], -1)); + form13.OpenFile(fProject, ListBox1.Items[ListBox1.ItemIndex], strtointdef(StringGrid1.Cells[IndexLine, StringGrid1.Selection.Top], -1)); End Else Begin // Die Datei hat gar keine Erkannten Funktionen If ListBox1.ItemIndex <> -1 Then Begin - form13.OpenFile(fRootfolder, ListBox1.Items[ListBox1.ItemIndex]); + form13.OpenFile(fProject, ListBox1.Items[ListBox1.ItemIndex]); End; End; End; @@ -236,13 +236,12 @@ End; End; -Function TForm5.LoadFunctions(aList: TProjectFilesInfo; Colors: TCCColors; - Rootfolder: String): Boolean; +Function TForm5.LoadFunctions(aList: TProjectFilesInfo; Project: TProject): Boolean; Var i: Integer; Begin - fRootfolder := Rootfolder; - fCCColors := Colors; + fProject := Project; + fCCColors := Project.CCColors; result := false; ListBox1.Clear; setlength(fFileInfos, length(aList)); diff --git a/src/unit6.lfm b/src/unit6.lfm index 1ffb726..dd270da 100644 --- a/src/unit6.lfm +++ b/src/unit6.lfm @@ -1,29 +1,28 @@ object Form6: TForm6 Left = 424 - Height = 1112 + Height = 556 Top = 573 - Width = 1542 + Width = 771 Caption = 'Form6' - ClientHeight = 1112 - ClientWidth = 1542 - DesignTimePPI = 192 + ClientHeight = 556 + ClientWidth = 771 Position = poScreenCenter LCLVersion = '3.99.0.0' OnCreate = FormCreate object Button1: TButton - Left = 192 - Height = 50 - Top = 1024 - Width = 150 + Left = 96 + Height = 25 + Top = 512 + Width = 75 Caption = 'OK' TabOrder = 0 OnClick = Button1Click end object StringGrid1: TStringGrid - Left = 32 - Height = 704 - Top = 16 - Width = 912 + Left = 16 + Height = 352 + Top = 8 + Width = 456 ColCount = 7 Columns = < item @@ -57,8 +56,8 @@ object Form6: TForm6 OnPrepareCanvas = StringGrid1PrepareCanvas end object PopupMenu1: TPopupMenu - Left = 268 - Top = 278 + Left = 134 + Top = 139 object MenuItem2: TMenuItem Caption = 'Open code' OnClick = StringGrid1DblClick @@ -71,7 +70,7 @@ object Form6: TForm6 object SaveDialog1: TSaveDialog DefaultExt = '.csv' Filter = 'CSV-File|*.csv|All|*.*' - Left = 456 - Top = 408 + Left = 228 + Top = 204 end end diff --git a/src/unit6.pas b/src/unit6.pas index c8177d8..587670a 100644 --- a/src/unit6.pas +++ b/src/unit6.pas @@ -47,7 +47,7 @@ fStringGridSortDirection: Boolean; fCCColors: TCCColors; public - RootFolder: String; + fProject: TProject; Procedure ClearGrid; Procedure AddDataset(Filename: String; Const AData: TFileInfo; MethodCount: integer; AvgCC: Single; MaxCC: Integer); @@ -122,7 +122,7 @@ Begin // Open Code If StringGrid1.Selection.Top <> -1 Then Begin - form13.OpenFile(RootFolder, StringGrid1.Cells[0, StringGrid1.Selection.Top]); + form13.OpenFile(fProject, StringGrid1.Cells[0, StringGrid1.Selection.Top]); End; End;