Changeset 91 for trunk/Forms/UFormTargetCode.pas
- Timestamp:
- Jul 20, 2018, 9:41:37 AM (6 years ago)
- Location:
- trunk/Forms
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms
-
Property svn:ignore
set to
*.lrj
-
Property svn:ignore
set to
-
trunk/Forms/UFormTargetCode.pas
r46 r91 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 Menus ;9 Menus, ActnList, strutils; 10 10 11 11 type … … 14 14 15 15 TFormTargetCode = class(TForm) 16 AShrinkCode: TAction; 17 AFormatCode: TAction; 18 ActionList1: TActionList; 16 19 MemoTarget: TMemo; 20 MenuItem1: TMenuItem; 17 21 MenuItem20: TMenuItem; 18 22 PopupMenuTarget: TPopupMenu; 23 procedure AFormatCodeExecute(Sender: TObject); 24 procedure AShrinkCodeExecute(Sender: TObject); 19 25 private 20 26 { private declarations } … … 30 36 {$R *.lfm} 31 37 38 { TFormTargetCode } 39 40 procedure TFormTargetCode.AFormatCodeExecute(Sender: TObject); 41 var 42 Source: string; 43 NewSource: string; 44 Indent: Integer; 45 I: Integer; 46 const 47 IndentText = ' '; 48 begin 49 Source := MemoTarget.Text; 50 NewSource := ''; 51 Indent := 0; 52 for I := 1 to Length(Source) do begin 53 if Source[I] = '[' then begin 54 NewSource := NewSource + LineEnding + DupeString(IndentText, Indent) + Source[I] + LineEnding ; 55 Inc(Indent); 56 NewSource := NewSource + DupeString(IndentText, Indent); 57 end 58 else if Source[I] = ']' then begin 59 Dec(Indent); 60 NewSource := NewSource + LineEnding + DupeString(IndentText, Indent) + Source[I] + LineEnding + DupeString(IndentText, Indent); 61 end 62 else if Ord(Source[I]) > $20 then 63 NewSource := NewSource + Source[I]; 64 end; 65 MemoTarget.Text := NewSource; 66 end; 67 68 procedure TFormTargetCode.AShrinkCodeExecute(Sender: TObject); 69 var 70 Source: string; 71 Pos: Integer; 72 I: Integer; 73 begin 74 Source := MemoTarget.Text; 75 Pos := 1; 76 for I := 1 to Length(Source) do begin 77 if Source[I] > ' ' then begin 78 Source[Pos] := Source[I]; 79 Inc(Pos); 80 end; 81 end; 82 SetLength(Source, Pos - 1); 83 MemoTarget.Text := Source; 84 end; 85 32 86 end. 33 87
Note:
See TracChangeset
for help on using the changeset viewer.