- Timestamp:
- Feb 22, 2022, 11:07:27 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormCompare.lfm
r120 r121 1 1 object FormCompare: TFormCompare 2 Left = 5 462 Left = 574 3 3 Height = 925 4 Top = 1594 Top = 322 5 5 Width = 1241 6 6 Caption = 'Compare' 7 ClientHeight = 9257 ClientHeight = 890 8 8 ClientWidth = 1241 9 9 DesignTimePPI = 150 10 Menu = MainMenu1 11 OnActivate = FormActivate 10 12 OnClose = FormClose 11 13 OnCreate = FormCreate 12 14 OnDestroy = FormDestroy 15 OnResize = FormResize 13 16 OnShow = FormShow 14 17 LCLVersion = '2.2.0.4' 15 18 object PanelLeft: TPanel 16 19 Left = 0 17 Height = 92520 Height = 890 18 21 Top = 0 19 22 Width = 608 20 23 Align = alLeft 21 24 BevelOuter = bvNone 22 ClientHeight = 92525 ClientHeight = 890 23 26 ClientWidth = 608 24 27 TabOrder = 0 25 28 object EditLeftFileName: TEdit 26 Left = 1 229 Left = 16 27 30 Height = 43 28 31 Top = 11 29 Width = 5 8932 Width = 544 30 33 Anchors = [akTop, akLeft, akRight] 31 34 ReadOnly = True 32 35 TabOrder = 0 33 36 end 34 inline SynEdit 1: TSynEdit37 inline SynEditLeft: TSynEditEx 35 38 Left = 16 36 Height = 8 4839 Height = 813 37 40 Top = 64 38 41 Width = 585 … … 492 495 LineHighlightColor.Background = clNone 493 496 LineHighlightColor.Foreground = clNone 497 OnChange = SynEditLeftChange 498 OnScroll = SynEditLeftScroll 494 499 inline SynLeftGutterPartList1: TSynGutterPartList 495 500 object SynGutterMarks1: TSynGutterMarks … … 529 534 end 530 535 end 536 object SpeedButtonOpenLeft: TSpeedButton 537 Left = 565 538 Height = 34 539 Top = 15 540 Width = 36 541 Action = AFileOpenLeft 542 Anchors = [akTop, akRight] 543 Images = Core.ImageList1 544 ImageIndex = 5 545 ShowCaption = False 546 end 531 547 end 532 548 object Splitter1: TSplitter 533 549 Left = 608 534 Height = 925550 Height = 890 535 551 Top = 0 536 552 Width = 8 … … 538 554 object PanelRight: TPanel 539 555 Left = 616 540 Height = 925556 Height = 890 541 557 Top = 0 542 558 Width = 625 543 559 Align = alClient 544 560 BevelOuter = bvNone 545 ClientHeight = 925561 ClientHeight = 890 546 562 ClientWidth = 625 547 563 TabOrder = 2 … … 550 566 Height = 43 551 567 Top = 11 552 Width = 5 99568 Width = 551 553 569 Anchors = [akTop, akLeft, akRight] 554 570 ReadOnly = True 555 571 TabOrder = 0 556 572 end 557 inline SynEdit 2: TSynEdit573 inline SynEditRight: TSynEditEx 558 574 Left = 16 559 Height = 8 48575 Height = 813 560 576 Top = 64 561 577 Width = 595 … … 1015 1031 LineHighlightColor.Background = clNone 1016 1032 LineHighlightColor.Foreground = clNone 1033 OnChange = SynEditRightChange 1034 OnScroll = SynEditRightScroll 1017 1035 inline SynLeftGutterPartList1: TSynGutterPartList 1018 1036 object SynGutterMarks1: TSynGutterMarks … … 1052 1070 end 1053 1071 end 1072 object SpeedButtonOpenRight: TSpeedButton 1073 Left = 575 1074 Height = 34 1075 Top = 16 1076 Width = 36 1077 Action = AFileOpenRight 1078 Anchors = [akTop, akRight] 1079 Images = Core.ImageList1 1080 ImageIndex = 2 1081 ShowCaption = False 1082 end 1083 end 1084 object OpenDialogSide: TOpenDialog 1085 Left = 344 1086 Top = 362 1087 end 1088 object MainMenu1: TMainMenu 1089 Images = Core.ImageList1 1090 Left = 344 1091 Top = 496 1092 object MenuItem1: TMenuItem 1093 Caption = 'File' 1094 object MenuItem2: TMenuItem 1095 Action = AFileOpenLeft 1096 end 1097 object MenuItem3: TMenuItem 1098 Action = AFileOpenRight 1099 end 1100 object MenuItem4: TMenuItem 1101 Action = AReloadFiles 1102 end 1103 object MenuItem5: TMenuItem 1104 Action = ASwitchSides 1105 end 1106 object MenuItemClose: TMenuItem 1107 Caption = 'Close' 1108 OnClick = MenuItemCloseClick 1109 end 1110 end 1111 end 1112 object ActionList1: TActionList 1113 Images = Core.ImageList1 1114 Left = 764 1115 Top = 360 1116 object AFileOpenLeft: TAction 1117 Caption = 'Open left file' 1118 ImageIndex = 5 1119 OnExecute = AFileOpenLeftExecute 1120 end 1121 object AFileOpenRight: TAction 1122 Caption = 'Open right file' 1123 ImageIndex = 2 1124 OnExecute = AFileOpenRightExecute 1125 end 1126 object AReloadFiles: TAction 1127 Caption = 'Reload files' 1128 OnExecute = AReloadFilesExecute 1129 end 1130 object ASwitchSides: TAction 1131 Caption = 'Switch sides' 1132 OnExecute = ASwitchSidesExecute 1133 end 1054 1134 end 1055 1135 end -
trunk/Forms/UFormCompare.lrj
r120 r121 1 1 {"version":1,"strings":[ 2 {"hash":174352581,"name":"tformcompare.caption","sourcebytes":[67,111,109,112,97,114,101],"value":"Compare"} 2 {"hash":174352581,"name":"tformcompare.caption","sourcebytes":[67,111,109,112,97,114,101],"value":"Compare"}, 3 {"hash":315429,"name":"tformcompare.menuitem1.caption","sourcebytes":[70,105,108,101],"value":"File"}, 4 {"hash":4863637,"name":"tformcompare.menuitemclose.caption","sourcebytes":[67,108,111,115,101],"value":"Close"}, 5 {"hash":195475957,"name":"tformcompare.afileopenleft.caption","sourcebytes":[79,112,101,110,32,108,101,102,116,32,102,105,108,101],"value":"Open left file"}, 6 {"hash":56694677,"name":"tformcompare.afileopenright.caption","sourcebytes":[79,112,101,110,32,114,105,103,104,116,32,102,105,108,101],"value":"Open right file"}, 7 {"hash":65066931,"name":"tformcompare.areloadfiles.caption","sourcebytes":[82,101,108,111,97,100,32,102,105,108,101,115],"value":"Reload files"}, 8 {"hash":265810003,"name":"tformcompare.aswitchsides.caption","sourcebytes":[83,119,105,116,99,104,32,115,105,100,101,115],"value":"Switch sides"} 3 9 ]} -
trunk/Forms/UFormCompare.pas
r120 r121 7 7 uses 8 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls, 9 UContact, Diff, LCLType, LCLIntf, ComCtrls, SynEdit; 9 UContact, Diff, LCLType, LCLIntf, ComCtrls, Buttons, Menus, ActnList, SynEdit, 10 SynEditMiscClasses, SynHighlighterPosition, 11 SynEditHighlighter, UCommon, USynEditEx; 10 12 11 13 type … … 14 16 15 17 TFormCompare = class(TForm) 18 ASwitchSides: TAction; 19 AReloadFiles: TAction; 20 AFileOpenLeft: TAction; 21 AFileOpenRight: TAction; 22 ActionList1: TActionList; 16 23 EditLeftFileName: TEdit; 17 24 EditRightFileName: TEdit; 25 MainMenu1: TMainMenu; 26 MenuItem1: TMenuItem; 27 MenuItem2: TMenuItem; 28 MenuItem3: TMenuItem; 29 MenuItem4: TMenuItem; 30 MenuItem5: TMenuItem; 31 MenuItemClose: TMenuItem; 32 OpenDialogSide: TOpenDialog; 18 33 PanelLeft: TPanel; 19 34 PanelRight: TPanel; 35 SpeedButtonOpenLeft: TSpeedButton; 36 SpeedButtonOpenRight: TSpeedButton; 20 37 Splitter1: TSplitter; 21 SynEdit1: TSynEdit; 22 SynEdit2: TSynEdit; 38 SynEditLeft: TSynEditEx; 39 SynEditRight: TSynEditEx; 40 procedure AFileOpenLeftExecute(Sender: TObject); 41 procedure AFileOpenRightExecute(Sender: TObject); 42 procedure AReloadFilesExecute(Sender: TObject); 43 procedure ASwitchSidesExecute(Sender: TObject); 44 procedure FormActivate(Sender: TObject); 23 45 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 24 46 procedure FormCreate(Sender: TObject); 25 47 procedure FormDestroy(Sender: TObject); 48 procedure FormResize(Sender: TObject); 26 49 procedure FormShow(Sender: TObject); 27 procedure PaintBoxLeftPaint(Sender: TObject); 50 procedure MenuItemCloseClick(Sender: TObject); 51 procedure SynEditLeftChange(Sender: TObject); 52 procedure SynEditLeftScroll(Sender: TObject); 53 procedure SynEditRightChange(Sender: TObject); 54 procedure SynEditRightScroll(Sender: TObject); 28 55 private 29 FLeftSide: TContactsFile; 30 FRightSide: TContactsFile; 31 S1, S2: string; 56 FLeftSide: string; 57 FRightSide: string; 32 58 Diff: TDiff; 33 procedure SetLeftSide(AValue: TContactsFile); 34 procedure SetRightSide(AValue: TContactsFile); 59 HighlighterLeft: TSynPositionHighlighter; 60 HighlighterRight: TSynPositionHighlighter; 61 AttrAdded: TtkTokenKind; 62 AttrDeleted: TtkTokenKind; 63 AttrModified: TtkTokenKind; 64 LastWidth: Integer; 65 procedure SetLeftSide(AValue: string); 66 procedure SetRightSide(AValue: string); 35 67 procedure ReloadContent; 36 68 procedure UpdateInterface; 69 procedure UpdateHighlight; 70 function LoadFile(AFileName: string): string; 37 71 public 38 property LeftSide: TContactsFile read FLeftSide write SetLeftSide; 39 property RightSide: TContactsFile read FRightSide write SetRightSide; 72 procedure LoadFileLeft(FileName: string); 73 procedure LoadFileRight(FileName: string); 74 property LeftSide: string read FLeftSide write SetLeftSide; 75 property RightSide: string read FRightSide write SetRightSide; 40 76 end; 41 77 … … 56 92 begin 57 93 Core.PersistentForm1.Save(Self); 94 end; 95 96 procedure TFormCompare.ASwitchSidesExecute(Sender: TObject); 97 var 98 TempFileName: string; 99 TempContent: string; 100 begin 101 TempContent := SynEditLeft.Text; 102 SynEditLeft.Text := SynEditRight.Text; 103 SynEditRight.Text := TempContent; 104 105 TempFileName := EditLeftFileName.Text; 106 EditLeftFileName.Text := EditRightFileName.Text; 107 EditRightFileName.Text := TempFileName; 108 109 UpdateInterface; 110 UpdateHighlight; 111 end; 112 113 procedure TFormCompare.FormActivate(Sender: TObject); 114 begin 115 if LastWidth = -1 then LastWidth := Width; 116 end; 117 118 procedure TFormCompare.AReloadFilesExecute(Sender: TObject); 119 begin 120 LoadFileLeft(EditLeftFileName.Text); 121 LoadFileRight(EditRightFileName.Text); 122 UpdateHighlight; 123 UpdateInterface; 124 end; 125 126 procedure TFormCompare.AFileOpenLeftExecute(Sender: TObject); 127 begin 128 OpenDialogSide.InitialDir := ExtractFileDir(EditLeftFileName.Text); 129 OpenDialogSide.FileName := ExtractFileName(EditLeftFileName.Text); 130 if OpenDialogSide.Execute then begin 131 EditLeftFileName.Text := OpenDialogSide.FileName; 132 SynEditLeft.Text := LoadFileToStr(OpenDialogSide.FileName); 133 end; 134 end; 135 136 procedure TFormCompare.AFileOpenRightExecute(Sender: TObject); 137 begin 138 OpenDialogSide.InitialDir := ExtractFileDir(EditRightFileName.Text); 139 OpenDialogSide.FileName := ExtractFileName(EditRightFileName.Text); 140 if OpenDialogSide.Execute then begin 141 EditRightFileName.Text := OpenDialogSide.FileName; 142 SynEditRight.Text := LoadFileToStr(OpenDialogSide.FileName); 143 end; 144 UpdateHighlight; 58 145 end; 59 146 … … 63 150 Core.ThemeManager1.UseTheme(Self); 64 151 Diff := TDiff.Create(Self); 152 153 HighlighterLeft := TSynPositionHighlighter.Create(Self); 154 with HighlighterLeft do begin 155 AttrAdded := CreateTokenID('Added', clNone, clLightGreen, []); 156 AttrDeleted := CreateTokenID('Deleted', clNone, clLightBlue, []); 157 AttrModified := CreateTokenID('Modified', clNone, clLightRed, []); 158 end; 159 SynEditLeft.Highlighter := HighlighterLeft; 160 161 HighlighterRight := TSynPositionHighlighter.Create(Self); 162 with HighlighterRight do begin 163 AttrAdded := CreateTokenID('Added', clNone, clLightGreen, []); 164 AttrDeleted := CreateTokenID('Deleted', clNone, clLightBlue, []); 165 AttrModified := CreateTokenID('Modified', clNone, clLightRed, []); 166 end; 167 SynEditRight.Highlighter := HighlighterRight; 168 169 LastWidth := -1; 65 170 end; 66 171 67 172 procedure TFormCompare.FormDestroy(Sender: TObject); 68 173 begin 174 FreeAndNil(HighlighterLeft); 175 FreeAndNil(HighlighterRight); 69 176 FreeAndNil(Diff); 177 end; 178 179 procedure TFormCompare.FormResize(Sender: TObject); 180 var 181 LastHandler: TNotifyEvent; 182 NewPanelWidth: Integer; 183 const 184 MaxRatio = 0.8; 185 begin 186 if LastWidth <> -1 then begin 187 LastHandler := PanelLeft.OnResize; 188 try 189 PanelLeft.OnResize := nil; 190 NewPanelWidth := Round((PanelLeft.Width / LastWidth) * Width); 191 if NewPanelWidth > Round(Width * MaxRatio) then NewPanelWidth := Round(Width * MaxRatio); 192 PanelLeft.Width := NewPanelWidth; 193 finally 194 PanelLeft.OnResize := LastHandler; 195 end; 196 LastWidth := Width; 197 end; 70 198 end; 71 199 … … 77 205 end; 78 206 79 procedure MarkupTextOut(Canvas: TCanvas; X, Y: Integer; Text: string); 80 var 81 I: Integer; 82 Len: Integer; 83 Clr: Integer; 84 SavedTextAlign: Cardinal; 85 SavedBkColor: Cardinal; 86 SavedTextColor: Cardinal; 87 SavedPt: TPoint; 88 begin 89 I := Pos('<', Text); 90 if I = 0 then begin 91 Canvas.TextOut(X, Y, Text); 92 Exit; 93 end; 94 95 SavedTextColor := GetTextColor(Canvas.Handle); 96 SavedBkColor := GetBkColor(Canvas.Handle); 97 //SavedTextAlign := GetTextAlign(Canvas.Handle); 98 //SetTextAlign(Canvas.Handle, SavedTextAlign or TA_UPDATECP); 99 MoveToEx(Canvas.Handle, X, Y, @SavedPt); 100 101 repeat 102 if I > 1 then TextOut(Canvas.Handle, 0, 0, PChar(Text), I - 1); 103 Delete(Text, 1, I); 104 Len := Length(Text); 105 if Len < 3 then Break 106 else if (Text[1] = 'F') and (Text[2] = 'C') and (Text[3] = ':') and 107 (Len > 9) and (Text[10] = '>') then begin 108 Clr := StrToIntDef('$' + Copy(Text, 4, 6), 0); 109 SetTextColor(Canvas.Handle, Clr); 110 Delete(Text, 1, 10); 111 Dec(Len, 10); 112 end 113 else if (Text[1] = 'B') and (Text[2] = 'C') and (Text[3] = ':') and 114 (Len > 9) and (Text[10] = '>') then 115 begin 116 Clr := StrToIntDef('$' + Copy(Text, 4, 6), $1FFFFFF); 117 if Clr > $FFFFFF then 118 SetBkColor(Canvas.Handle, SavedBkColor) else 119 SetBkColor(Canvas.Handle, Clr); 120 Delete(Text, 1, 10); 121 Dec(Len, 10); 122 end 123 else Break; 124 I := Pos('<', Text); 125 until (I = 0); 126 TextOut(Canvas.Handle, 0, 0, PChar(Text), Len); 127 128 SetTextColor(Canvas.Handle, SavedTextColor); 129 SetBkColor(Canvas.Handle, SavedBkColor); 130 //SetTextAlign(Canvas.Handle, SavedTextAlign); 131 with SavedPt do MoveToEx(Canvas.Handle, X, Y, nil); 132 end; 133 134 procedure TFormCompare.PaintBoxLeftPaint(Sender: TObject); 135 begin 136 with TPaintBox(Sender) do begin 137 MarkupTextOut(Canvas, 0, 5, S1); 138 MarkupTextOut(Canvas, 0, 25, S2); 139 Canvas.TextOut(0, 55, 'Compare Statistics ...'); 140 with Diff.DiffStats do begin 141 MarkupTextOut(Canvas, 0, 75, ' Matches : ' + IntToStr(Matches)); 142 MarkupTextOut(Canvas, 0, 95, ' <BC:AAFFAA>Modifies:<BC:------> ' + IntToStr(Modifies)); 143 MarkupTextOut(Canvas, 0, 115, ' <BC:FFAAAA>Adds :<BC:------> ' + IntToStr(Adds)); 144 MarkupTextOut(Canvas, 0, 135, ' <BC:AAAAFF>Deletes :<BC:------> ' + IntToStr(Deletes)); 145 end; 146 end; 147 end; 148 149 procedure TFormCompare.SetLeftSide(AValue: TContactsFile); 207 procedure TFormCompare.MenuItemCloseClick(Sender: TObject); 208 begin 209 Close; 210 end; 211 212 procedure TFormCompare.SynEditLeftChange(Sender: TObject); 213 begin 214 UpdateHighlight; 215 end; 216 217 procedure TFormCompare.SynEditLeftScroll(Sender: TObject); 218 begin 219 SynEditRight.TopLine := SynEditLeft.TopLine; 220 end; 221 222 procedure TFormCompare.SynEditRightChange(Sender: TObject); 223 begin 224 UpdateHighlight; 225 end; 226 227 procedure TFormCompare.SynEditRightScroll(Sender: TObject); 228 begin 229 SynEditLeft.TopLine := SynEditRight.TopLine; 230 end; 231 232 procedure TFormCompare.SetLeftSide(AValue: string); 150 233 begin 151 234 if FLeftSide = AValue then Exit; 152 235 FLeftSide := AValue; 153 ReloadContent; 154 UpdateInterface; 155 end; 156 157 procedure TFormCompare.SetRightSide(AValue: TContactsFile); 236 end; 237 238 procedure TFormCompare.SetRightSide(AValue: string); 158 239 begin 159 240 if FRightSide = AValue then Exit; 160 241 FRightSide := AValue; 161 ReloadContent;162 UpdateInterface;163 242 end; 164 243 165 244 procedure TFormCompare.ReloadContent; 245 begin 246 UpdateHighlight; 247 end; 248 249 procedure TFormCompare.UpdateInterface; 250 begin 251 end; 252 253 procedure TFormCompare.UpdateHighlight; 166 254 var 167 255 LeftText: string; … … 169 257 I: Integer; 170 258 LastKind: TChangeKind; 171 172 //AddCharToStr() adds color markup to strings which will be parsed later by 173 //my MarkupTextOut() function where diffs (additions, modifications and 174 //deletions) will be displayed in Paintbox1 with different colors ... 175 //<BC:------> change background color to original (transparent) color 176 //<BC:AAFFAA> change background color to pale green 177 //<BC:AAAAFF> change background color to pale red 178 //<BC:FFAAAA> change background color to pale blue 179 procedure AddCharToStr(var s: string; c: char; Kind, LastKind: TChangeKind); 180 begin 181 if (Kind = LastKind) then 182 s := s + c //no need to change colors 183 else 184 case Kind of 185 ckNone: s := s + '<BC:------>' + c; 186 ckAdd: s := s + '<BC:FFAAAA>' + c; 187 ckDelete: s := s + '<BC:AAAAFF>' + c; 188 ckModify: s := s + '<BC:AAFFAA>' + c; 189 end; 190 end; 191 192 begin 193 if Assigned(FLeftSide) then begin 194 FLeftSide.Sort; 195 LeftText := FLeftSide.AsString; 196 end else LeftText := ''; 197 if Assigned(FRightSide) then begin 198 FRightSide.Sort; 199 RightText := FRightSide.AsString; 200 end else RightText := ''; 259 P1: TPoint; 260 P2: TPoint; 261 Rec: TCompareRec; 262 NextToken1: TtkTokenKind; 263 NextToken2: TtkTokenKind; 264 begin 265 LeftText := SynEditLeft.Lines.Text; 266 RightText := SynEditRight.Lines.Text; 201 267 202 268 Diff.Execute(PChar(LeftText), PChar(RightText), Length(LeftText), Length(RightText)); 203 269 204 //now, display the diffs ... 270 HighlighterLeft.ClearAllTokens; 271 HighlighterRight.ClearAllTokens; 272 LeftText := ''; 273 RightText := ''; 205 274 LastKind := ckNone; 206 S1 := ''; 207 S2 := ''; 275 P1 := Point(1, 0); 276 P2 := Point(1, 0); 277 NextToken1 := tkText; 278 NextToken2 := tkText; 208 279 for I := 0 to Diff.Count - 1 do 209 280 with Diff.Compares[I] do begin 210 //show changes to first string (with spaces for adds to align with second string) 211 if Kind = ckAdd then AddCharToStr(S1, ' ', Kind, LastKind) 212 else AddCharToStr(S1, Chr1, Kind, LastKind); 213 214 //show changes to second string (with spaces for deletes to align with first string) 215 if Kind = ckDelete then AddCharToStr(S2, ' ', Kind, LastKind) 216 else AddCharToStr(S2, Chr2, Kind, LastKind); 281 Rec := Diff.Compares[I]; 282 if Rec.Chr1 = LineEnding then begin 283 if NextToken1 <> tkText then begin 284 HighlighterLeft.AddToken(P1.Y, 0, NextToken1); 285 NextToken1 := tkText; 286 end; 287 Inc(P1.Y); 288 P1.X := 0; 289 LeftText := LeftText + Rec.Chr1; 290 end else begin 291 if Kind = ckAdd then LeftText := LeftText + ' ' 292 else LeftText := LeftText + Rec.chr1; 293 if Kind <> LastKind then begin 294 HighlighterLeft.AddToken(P1.Y, P1.X, NextToken1); 295 if Kind = ckNone then NextToken1 := tkText 296 //else if Kind = ckAdd then NextToken1 := AttrAdded 297 else if Kind = ckDelete then NextToken1 := AttrDeleted 298 else if Kind = ckModify then NextToken1 := AttrModified; 299 end; 300 Inc(P1.X); 301 end; 302 303 if Rec.Chr2 = LineEnding then begin 304 if NextToken2 <> tkText then begin 305 HighlighterRight.AddToken(P2.Y, 0, NextToken2); 306 NextToken2 := tkText; 307 end; 308 Inc(P2.Y); 309 P2.X := 0; 310 RightText := RightText + Rec.Chr2; 311 end else begin 312 if Kind = ckDelete then RightText := RightText + ' ' 313 else RightText := RightText + Rec.Chr2; 314 if Kind <> LastKind then begin 315 HighlighterRight.AddToken(P2.Y, P2.X, NextToken2); 316 if Kind = ckNone then NextToken2 := tkText 317 else if Kind = ckAdd then NextToken2 := AttrAdded 318 //else if Kind = ckDelete then NextToken2 := AttrDeleted 319 else if Kind = ckModify then NextToken2 := AttrModified; 320 end; 321 Inc(P2.X); 322 end; 217 323 218 324 LastKind := Kind; 219 325 end; 220 end; 221 222 procedure TFormCompare.UpdateInterface; 223 begin 224 if Assigned(FLeftSide) then EditLeftFileName.Text := FLeftSide.FileName 225 else EditLeftFileName.Text := ''; 226 if Assigned(FRightSide) then EditRightFileName.Text := FRightSide.FileName 227 else EditRightFileName.Text := ''; 326 327 //SynEditLeft.Lines.Text := LeftText; 328 //SynEditRight.Lines.Text := RightText; 329 end; 330 331 function TFormCompare.LoadFile(AFileName: string): string; 332 var 333 Ext: string; 334 begin 335 Ext := ExtractFileExt(AFileName); 336 if Ext = VCardFileExt then begin 337 with TContactsFile.Create do 338 try 339 LoadFromFile(AFileName); 340 Result := AsString; 341 finally 342 Free; 343 end; 344 end else Result := LoadFileToStr(AFileName); 345 end; 346 347 procedure TFormCompare.LoadFileLeft(FileName: string); 348 begin 349 EditLeftFileName.Text := FileName; 350 LeftSide := LoadFile(FileName); 351 SynEditLeft.Text := LeftSide; 352 end; 353 354 procedure TFormCompare.LoadFileRight(FileName: string); 355 begin 356 EditRightFileName.Text := FileName; 357 RightSide := LoadFile(FileName); 358 SynEditRight.Text := RightSide; 228 359 end; 229 360 -
trunk/Forms/UFormSource.pas
r115 r121 7 7 uses 8 8 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ActnList, Menus, 9 StdCtrls, SynEdit, SynHighlighterAny, UVCardHighlighter ;9 StdCtrls, SynEdit, SynHighlighterAny, UVCardHighlighter, UCommon; 10 10 11 11 type … … 120 120 121 121 procedure TFormSource.UpdateTheme; 122 const123 clLightBlue = TColor($FF8080);124 clLightGreen = TColor($80FF80);125 clLightRed = TColor($8080FF);126 122 var 127 123 C: TColor; -
trunk/Languages/vCardStudio.cs.po
r120 r121 21 21 22 22 #: tcore.afileclose.caption 23 msgctxt "tcore.afileclose.caption" 23 24 msgid "Close" 24 25 msgstr "Zavřít" … … 108 109 msgstr "Vybrat adresář" 109 110 111 #: tformcompare.afileopenleft.caption 112 msgid "Open left file" 113 msgstr "Otevřít levý soubor" 114 115 #: tformcompare.afileopenright.caption 116 msgid "Open right file" 117 msgstr "Otevřít pravý soubor" 118 119 #: tformcompare.areloadfiles.caption 120 msgid "Reload files" 121 msgstr "Znovu načíst soubory" 122 123 #: tformcompare.aswitchsides.caption 124 msgid "Switch sides" 125 msgstr "Prohodit strany" 126 110 127 #: tformcompare.caption 111 128 msgid "Compare" 112 129 msgstr "Porovnání" 130 131 #: tformcompare.menuitem1.caption 132 msgctxt "tformcompare.menuitem1.caption" 133 msgid "File" 134 msgstr "Soubor" 135 136 #: tformcompare.menuitemclose.caption 137 msgctxt "tformcompare.menuitemclose.caption" 138 msgid "Close" 139 msgstr "Zavřít" 113 140 114 141 #: tformcontact.aphotoclear.caption -
trunk/Languages/vCardStudio.pot
r120 r121 11 11 12 12 #: tcore.afileclose.caption 13 msgctxt "tcore.afileclose.caption" 13 14 msgid "Close" 14 15 msgstr "" … … 98 99 msgstr "" 99 100 101 #: tformcompare.afileopenleft.caption 102 msgid "Open left file" 103 msgstr "" 104 105 #: tformcompare.afileopenright.caption 106 msgid "Open right file" 107 msgstr "" 108 109 #: tformcompare.areloadfiles.caption 110 msgid "Reload files" 111 msgstr "" 112 113 #: tformcompare.aswitchsides.caption 114 msgid "Switch sides" 115 msgstr "" 116 100 117 #: tformcompare.caption 101 118 msgid "Compare" 119 msgstr "" 120 121 #: tformcompare.menuitem1.caption 122 msgctxt "tformcompare.menuitem1.caption" 123 msgid "File" 124 msgstr "" 125 126 #: tformcompare.menuitemclose.caption 127 msgctxt "tformcompare.menuitemclose.caption" 128 msgid "Close" 102 129 msgstr "" 103 130 -
trunk/Packages/Common/UCommon.pas
r112 r121 8 8 {$IFDEF WINDOWS}Windows,{$ENDIF} 9 9 {$IFDEF UNIX}baseunix,{$ENDIF} 10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, 10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, Graphics, 11 11 FileUtil; //, ShFolder, ShellAPI; 12 12 … … 33 33 ExceptionHandler: TExceptionEvent; 34 34 DLLHandle1: HModule; 35 36 const 37 clLightBlue = TColor($FF8080); 38 clLightGreen = TColor($80FF80); 39 clLightRed = TColor($8080FF); 35 40 36 41 {$IFDEF WINDOWS} -
trunk/UCore.pas
r120 r121 88 88 LastContactTabIndex: Integer; 89 89 LastContactFileName: string; 90 LastCompareFileName: string; 90 91 LastPhotoFileName: string; 91 92 LastPropertyValueFileName: string; … … 171 172 var 172 173 TempFile: TDataFile; 173 LeftContacts: TContactsFile; 174 RightContacts: TContactsFile; 174 TempFileName: string; 175 175 begin 176 176 TempFile := DefaultDataFileClass.Create; … … 181 181 end; 182 182 OpenDialog1.DefaultExt := ''; 183 if Assigned(DataFile) then begin 184 OpenDialog1.InitialDir := ExtractFileDir(DataFile.FileName); 185 OpenDialog1.FileName := ExtractFileName(DataFile.FileName); 186 end; 183 OpenDialog1.InitialDir := ExtractFileDir(Core.LastCompareFileName); 184 OpenDialog1.FileName := ExtractFileName(Core.LastCompareFileName); 187 185 OpenDialog1.Options := OpenDialog1.Options - [ofAllowMultiSelect]; 188 186 if OpenDialog1.Execute then begin 189 187 with TFormCompare.Create(nil) do 190 188 try 191 LeftContacts := TContactsFile(DefaultDataFileClass.Create); 192 RightContacts := TContactsFile(DefaultDataFileClass.Create); 193 try 194 LeftContacts.Assign(TContactsFile(DataFile)); 195 LeftSide := LeftContacts; 196 RightContacts.LoadFromFile(OpenDialog1.FileName); 197 RightSide := RightContacts; 198 ShowModal; 199 finally 200 LeftContacts.Free; 201 RightContacts.Free; 202 end; 189 TempFileName := GetTempDir + DirectorySeparator + Application.Title + 190 DirectorySeparator + 'Compare' + VCardFileExt; 191 ForceDirectories(ExtractFileDir(TempFileName)); 192 TContactsFile(DataFile).SaveToFile(TempFileName); 193 LoadFileLeft(TempFileName); 194 LoadFileRight(OpenDialog1.FileName); 195 ShowModal; 203 196 finally 204 197 Free; 205 198 end; 199 Core.LastCompareFileName := OpenDialog1.FileName; 206 200 end; 207 201 end; … … 532 526 MapUrl := ReadStringWithDefault('MapUrl', 'https://www.openstreetmap.org/search?query='); 533 527 LastPhotoFileName := ReadStringWithDefault('LastPhotoFileName', ''); 528 LastCompareFileName := ReadStringWithDefault('LastCompareFileName', ''); 534 529 finally 535 530 Free; … … 558 553 WriteString('MapUrl', MapUrl); 559 554 WriteString('LastPhotoFileName', LastPhotoFileName); 555 WriteString('LastCompareFileName', LastCompareFileName); 560 556 finally 561 557 Free; -
trunk/vCardStudio.lpi
r120 r121 95 95 </Modes> 96 96 </RunParams> 97 <RequiredPackages Count=" 3">97 <RequiredPackages Count="4"> 98 98 <Item1> 99 <PackageName Value="SynEdit"/> 99 <PackageName Value="SynEditEx"/> 100 <DefaultFilename Value="Packages\SynEditEx\SynEditEx.lpk" Prefer="True"/> 100 101 </Item1> 101 102 <Item2> 103 <PackageName Value="SynEdit"/> 104 </Item2> 105 <Item3> 102 106 <PackageName Value="Common"/> 103 107 <DefaultFilename Value="Packages\Common\Common.lpk" Prefer="True"/> 104 </Item 2>105 <Item 3>108 </Item3> 109 <Item4> 106 110 <PackageName Value="LCL"/> 107 </Item 3>111 </Item4> 108 112 </RequiredPackages> 109 113 <Units Count="25">
Note:
See TracChangeset
for help on using the changeset viewer.