View Issue Details

IDProjectCategoryView StatusLast Update
0038526LazarusIDEpublic2021-02-24 00:03
ReporterDomingo Galmés Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Summary0038526: [Patch] Better file compare tool.
DescriptionThis patch is a rewrite of the File Compare Tool.
Features
  Side by side file comparation.
  Patch in unified format.
  Faster algortihm for diff,

Although the patch compiles and links without errors, it is not finished yet.
The problem is that it depends on the unit diff.pas located in (lazarus\components\jcf2\ReadWrite\diff.pas) Jedi
This unit would need to be either in lazutils or in a new package. and incorporate the new package as dependency to the ide and JCF.
I need feedback in order to make more changes.

Note: See the license of diff.pas maybe it can be a problem to incorporate the patch to the IDE.


TagsNo tags attached.
Fixed in Revision
LazTarget
Widgetset
Attached Files

Activities

Domingo Galmés

2021-02-21 22:31

reporter  

lazarus_ERMyayxXj8.png (118,015 bytes)   
lazarus_ERMyayxXj8.png (118,015 bytes)   
BetterFileCompareTool.patch (134,115 bytes)   
From 9ca647f289bbdd4ea64fb9a1e6cc7c6c51e77bb3 Mon Sep 17 00:00:00 2001
From: DomingoGP <dgalmesp@gmail.com>
Date: Sun, 21 Feb 2021 22:02:15 +0100
Subject: [PATCH] Better file compare tool

---
 ide/diffdialog.lfm          | 2854 ++++++++++++++++++++++++++---------
 ide/diffdialog.pas          | 1272 ++++++++++++++--
 ide/lazarusidestrconsts.pas |   10 +
 3 files changed, 3289 insertions(+), 847 deletions(-)

diff --git a/ide/diffdialog.lfm b/ide/diffdialog.lfm
index 21ef3d1f12..ce131b849d 100644
--- a/ide/diffdialog.lfm
+++ b/ide/diffdialog.lfm
@@ -1,730 +1,40 @@
 object DiffDlg: TDiffDlg
-  Left = 873
+  Left = 364
   Height = 576
-  Top = 301
-  Width = 598
+  Top = 238
+  Width = 872
   HelpType = htKeyword
   BorderIcons = [biSystemMenu]
   Caption = 'Compare files'
   ClientHeight = 576
-  ClientWidth = 598
+  ClientWidth = 872
   OnCreate = FormCreate
   Position = poScreenCenter
   LCLVersion = '2.1.0.0'
-  object Text1GroupBox: TGroupBox
-    AnchorSideLeft.Control = Owner
-    AnchorSideTop.Control = Owner
-    Left = 6
-    Height = 54
-    Top = 6
-    Width = 586
-    Align = alTop
-    Anchors = [akRight]
-    AutoSize = True
-    BorderSpacing.Around = 6
-    Caption = 'Text1GroupBox'
-    ClientHeight = 36
-    ClientWidth = 582
-    TabOrder = 0
-    object Text1Combobox: TComboBox
-      AnchorSideLeft.Control = Text1GroupBox
-      AnchorSideTop.Control = Text1GroupBox
-      AnchorSideRight.Control = Text1FileOpenButton
-      Left = 6
-      Height = 23
-      Top = 6
-      Width = 342
-      Anchors = [akTop, akLeft, akRight]
-      BorderSpacing.Left = 6
-      BorderSpacing.Top = 6
-      BorderSpacing.Right = 6
-      ItemHeight = 14
-      OnChange = Text1ComboboxChange
-      TabOrder = 0
-      Text = 'Text1Combobox'
-    end
-    object Text1OnlySelectionCheckBox: TCheckBox
-      AnchorSideTop.Control = Text1FileOpenButton
-      AnchorSideTop.Side = asrCenter
-      AnchorSideRight.Control = Text1GroupBox
-      AnchorSideRight.Side = asrBottom
-      Left = 398
-      Height = 18
-      Top = 8
-      Width = 178
-      Anchors = [akTop, akRight]
-      BorderSpacing.Top = 6
-      BorderSpacing.Right = 6
-      BorderSpacing.Bottom = 6
-      Caption = 'Text1OnlySelectionCheckBox'
-      OnChange = OnChangeFlag
-      TabOrder = 1
-    end
-    object Text1FileOpenButton: TButton
-      AnchorSideTop.Control = Text1Combobox
-      AnchorSideRight.Control = Text1OnlySelectionCheckBox
-      AnchorSideBottom.Control = Text1Combobox
-      AnchorSideBottom.Side = asrBottom
-      Left = 354
-      Height = 23
-      Top = 6
-      Width = 32
-      Anchors = [akTop, akRight, akBottom]
-      BorderSpacing.Right = 12
-      Caption = 'Text1FileOpenButton'
-      OnClick = FileOpenClick
-      TabOrder = 2
-    end
-  end
-  object Text2GroupBox: TGroupBox
-    AnchorSideTop.Control = Text1GroupBox
-    Left = 6
-    Height = 54
-    Top = 66
-    Width = 586
-    Align = alTop
-    AutoSize = True
-    BorderSpacing.Around = 6
-    Caption = 'Text2GroupBox'
-    ClientHeight = 36
-    ClientWidth = 582
-    TabOrder = 1
-    object Text2Combobox: TComboBox
-      AnchorSideLeft.Control = Text2GroupBox
-      AnchorSideTop.Control = Text2GroupBox
-      AnchorSideRight.Control = Text2FileOpenButton
-      Left = 6
-      Height = 23
-      Top = 6
-      Width = 342
-      Anchors = [akTop, akLeft, akRight]
-      BorderSpacing.Left = 6
-      BorderSpacing.Top = 6
-      BorderSpacing.Right = 6
-      ItemHeight = 14
-      OnChange = Text2ComboboxChange
-      TabOrder = 0
-      Text = 'Text2Combobox'
-    end
-    object Text2OnlySelectionCheckBox: TCheckBox
-      AnchorSideTop.Control = Text2FileOpenButton
-      AnchorSideTop.Side = asrCenter
-      AnchorSideRight.Control = Text2GroupBox
-      AnchorSideRight.Side = asrBottom
-      Left = 398
-      Height = 18
-      Top = 8
-      Width = 178
-      Anchors = [akTop, akRight]
-      BorderSpacing.Top = 6
-      BorderSpacing.Right = 6
-      BorderSpacing.Bottom = 6
-      Caption = 'Text2OnlySelectionCheckBox'
-      OnChange = OnChangeFlag
-      TabOrder = 1
-    end
-    object Text2FileOpenButton: TButton
-      AnchorSideTop.Control = Text2Combobox
-      AnchorSideRight.Control = Text2OnlySelectionCheckBox
-      AnchorSideBottom.Control = Text2Combobox
-      AnchorSideBottom.Side = asrBottom
-      Left = 354
-      Height = 23
-      Top = 6
-      Width = 32
-      Anchors = [akTop, akRight, akBottom]
-      BorderSpacing.Right = 12
-      Caption = 'Text2FileOpenButton'
-      OnClick = FileOpenClick
-      TabOrder = 2
-    end
-  end
-  object OptionsGroupBox: TCheckGroup
-    AnchorSideLeft.Control = Owner
-    AnchorSideTop.Control = DiffSynEdit
-    AnchorSideTop.Side = asrBottom
-    AnchorSideRight.Control = Owner
-    AnchorSideRight.Side = asrBottom
-    AnchorSideBottom.Control = ProgressBar1
-    Left = 6
-    Height = 197
-    Top = 311
-    Width = 586
-    Anchors = [akLeft, akRight, akBottom]
-    AutoFill = True
-    BorderSpacing.Around = 6
-    Caption = 'OptionsGroupBox'
-    ChildSizing.LeftRightSpacing = 6
-    ChildSizing.TopBottomSpacing = 6
-    ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
-    ChildSizing.EnlargeVertical = crsHomogenousChildResize
-    ChildSizing.ShrinkHorizontal = crsScaleChilds
-    ChildSizing.ShrinkVertical = crsScaleChilds
-    ChildSizing.Layout = cclLeftToRightThenTopToBottom
-    ChildSizing.ControlsPerLine = 1
-    TabOrder = 2
-  end
-  inline DiffSynEdit: TSynEdit
-    AnchorSideLeft.Control = Owner
-    AnchorSideTop.Control = Text2GroupBox
-    AnchorSideRight.Control = Owner
-    AnchorSideBottom.Control = OptionsGroupBox
-    Left = 6
-    Height = 179
-    Top = 126
-    Width = 586
-    Align = alTop
-    BorderSpacing.Around = 6
-    Anchors = [akTop, akLeft, akRight, akBottom]
-    Font.Color = clBlack
-    Font.Height = -12
-    Font.Name = 'courier'
-    Font.Pitch = fpFixed
-    Font.Quality = fqNonAntialiased
-    ParentColor = False
-    ParentFont = False
-    TabOrder = 3
-    BookMarkOptions.Xoffset = -18
-    Gutter.Visible = False
-    Gutter.Width = 55
-    Gutter.MouseActions = <    
-      item
-        ClickCount = ccAny
-        ClickDir = cdDown
-        Command = emcOnMainGutterClick
-      end    
-      item
-        Button = mbRight
-        Command = emcContextMenu
-      end>
-    RightGutter.Width = 0
-    RightGutter.MouseActions = <    
-      item
-        ClickCount = ccAny
-        ClickDir = cdDown
-        Command = emcOnMainGutterClick
-      end    
-      item
-        Button = mbRight
-        Command = emcContextMenu
-      end>
-    Highlighter = SynDiffSyn1
-    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 = 24649
-      end    
-      item
-        Command = ecLineBreak
-        ShortCut = 16461
-      end    
-      item
-        Command = ecInsertLine
-        ShortCut = 16462
-      end    
-      item
-        Command = ecDeleteWord
-        ShortCut = 16468
-      end    
-      item
-        Command = ecBlockUnindent
-        ShortCut = 24661
-      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 = 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>
-    MouseActions = <    
-      item
-        ShiftMask = [ssShift, ssAlt]
-        ClickDir = cdDown
-        Command = emcStartSelections
-        MoveCaret = True
-      end    
-      item
-        Shift = [ssShift]
-        ShiftMask = [ssShift, ssAlt]
-        ClickDir = cdDown
-        Command = emcStartSelections
-        MoveCaret = True
-        Option = 1
-      end    
-      item
-        Shift = [ssAlt]
-        ShiftMask = [ssShift, ssAlt]
-        ClickDir = cdDown
-        Command = emcStartColumnSelections
-        MoveCaret = True
-      end    
-      item
-        Shift = [ssShift, ssAlt]
-        ShiftMask = [ssShift, ssAlt]
-        ClickDir = cdDown
-        Command = emcStartColumnSelections
-        MoveCaret = True
-        Option = 1
-      end    
-      item
-        Button = mbRight
-        Command = emcContextMenu
-      end    
-      item
-        ClickCount = ccDouble
-        ClickDir = cdDown
-        Command = emcSelectWord
-        MoveCaret = True
-      end    
-      item
-        ClickCount = ccTriple
-        ClickDir = cdDown
-        Command = emcSelectLine
-        MoveCaret = True
-      end    
-      item
-        ClickCount = ccQuad
-        ClickDir = cdDown
-        Command = emcSelectPara
-        MoveCaret = True
-      end    
-      item
-        Button = mbMiddle
-        ClickDir = cdDown
-        Command = emcPasteSelection
-        MoveCaret = True
-      end    
-      item
-        Shift = [ssCtrl]
-        ShiftMask = [ssShift, ssAlt, ssCtrl]
-        Command = emcMouseLink
-      end>
-    MouseTextActions = <>
-    MouseSelActions = <    
-      item
-        ClickDir = cdDown
-        Command = emcStartDragMove
-      end>
-    Lines.Strings = (
-      'DiffSynEdit'
-    )
-    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 TSynGutterPartList
-      object TSynGutterMarks
-        Width = 24
-        MouseActions = <>
-      end
-      object TSynGutterLineNumber
-        Width = 15
-        MouseActions = <>
-        MarkupInfo.Background = clBtnFace
-        MarkupInfo.Foreground = clNone
-        DigitCount = 2
-        ShowOnlyLineNumbersMultiplesOf = 1
-        ZeroStart = False
-        LeadingZeros = False
-      end
-      object TSynGutterChanges
-        Width = 4
-        MouseActions = <>
-        ModifiedColor = 59900
-        SavedColor = clGreen
-      end
-      object TSynGutterSeparator
-        Width = 2
-        MouseActions = <>
-        MarkupInfo.Background = clWhite
-        MarkupInfo.Foreground = clGray
-      end
-      object TSynGutterCodeFolding
-        MouseActions = <        
-          item
-            Button = mbRight
-            Command = emcCodeFoldContextMenu
-          end        
-          item
-            ShiftMask = [ssShift]
-            Button = mbMiddle
-            ClickCount = ccAny
-            ClickDir = cdDown
-            Command = emcCodeFoldCollaps
-          end        
-          item
-            Shift = [ssShift]
-            ShiftMask = [ssShift]
-            Button = mbMiddle
-            ClickCount = ccAny
-            ClickDir = cdDown
-            Command = emcCodeFoldCollaps
-            Option = 1
-          end        
-          item
-            ClickCount = ccAny
-            ClickDir = cdDown
-            Command = emcNone
-          end>
-        MarkupInfo.Background = clNone
-        MarkupInfo.Foreground = clGray
-        MouseActionsExpanded = <        
-          item
-            ClickCount = ccAny
-            ClickDir = cdDown
-            Command = emcCodeFoldCollaps
-          end>
-        MouseActionsCollapsed = <        
-          item
-            Shift = [ssCtrl]
-            ShiftMask = [ssCtrl]
-            ClickCount = ccAny
-            ClickDir = cdDown
-            Command = emcCodeFoldExpand
-          end        
-          item
-            ShiftMask = [ssCtrl]
-            ClickCount = ccAny
-            ClickDir = cdDown
-            Command = emcCodeFoldExpand
-            Option = 1
-          end>
-      end
-    end
-  end
   object OpenInEditorButton: TBitBtn
     AnchorSideRight.Control = CloseButton
     AnchorSideBottom.Control = Owner
     AnchorSideBottom.Side = asrBottom
-    Left = 402
-    Height = 24
-    Top = 546
-    Width = 116
+    Left = 653
+    Height = 25
+    Top = 545
+    Width = 132
     Anchors = [akRight, akBottom]
     AutoSize = True
     BorderSpacing.Around = 6
     Caption = 'OpenInEditorButton'
     ModalResult = 6
-    TabOrder = 4
+    TabOrder = 0
   end
   object CloseButton: TBitBtn
     AnchorSideRight.Control = Owner
     AnchorSideRight.Side = asrBottom
     AnchorSideBottom.Control = Owner
     AnchorSideBottom.Side = asrBottom
-    Left = 524
+    Left = 791
     Height = 26
     Top = 544
-    Width = 68
+    Width = 75
     Anchors = [akRight, akBottom]
     AutoSize = True
     BorderSpacing.Around = 6
@@ -732,7 +42,7 @@ object DiffDlg: TDiffDlg
     Caption = '&Close'
     Kind = bkClose
     ModalResult = 2
-    TabOrder = 5
+    TabOrder = 1
   end
   object HelpButton: TBitBtn
     AnchorSideLeft.Control = Owner
@@ -741,58 +51,2106 @@ object DiffDlg: TDiffDlg
     Left = 6
     Height = 26
     Top = 544
-    Width = 62
+    Width = 71
     Anchors = [akLeft, akBottom]
     AutoSize = True
     BorderSpacing.Around = 6
     Caption = '&Help'
     Kind = bkHelp
     OnClick = HelpButtonClick
-    TabOrder = 6
-  end
-  object ProgressBar1: TProgressBar
-    AnchorSideLeft.Control = Owner
-    AnchorSideTop.Side = asrBottom
-    AnchorSideRight.Control = CancelScanningButton
-    AnchorSideBottom.Control = CloseButton
-    Left = 6
-    Height = 24
-    Top = 514
-    Width = 479
-    Anchors = [akLeft, akRight, akBottom]
-    BorderSpacing.Around = 6
-    Step = 0
-    TabOrder = 7
-  end
-  object CancelScanningButton: TBitBtn
-    AnchorSideTop.Control = ProgressBar1
-    AnchorSideTop.Side = asrCenter
-    AnchorSideRight.Control = Owner
-    AnchorSideRight.Side = asrBottom
-    Left = 491
-    Height = 24
-    Top = 514
-    Width = 101
-    Anchors = [akTop, akRight]
-    AutoSize = True
-    BorderSpacing.Around = 6
-    Caption = 'Cancel Scanning'
-    Enabled = False
-    OnClick = CancelScanningButtonClick
-    TabOrder = 8
-    Visible = False
-  end
-  object dlgOpen: TOpenDialog
-    DefaultExt = '.pas'
-    Filter = 'pascal files|*.pas;*.pp|any file|*.*'
-    FilterIndex = 0
-    Options = [ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail]
-    Left = 176
-    Top = 48
+    TabOrder = 2
   end
-  object SynDiffSyn1: TSynDiffSyn
-    Enabled = False
-    Left = 104
-    Top = 240
+  object PageControl1: TPageControl
+    Left = 8
+    Height = 528
+    Top = 8
+    Width = 856
+    ActivePage = tbsOptions
+    Anchors = [akTop, akLeft, akRight, akBottom]
+    TabIndex = 0
+    TabOrder = 3
+    object tbsOptions: TTabSheet
+      Caption = 'Options'
+      ClientHeight = 500
+      ClientWidth = 848
+      object OptionsGroupBox: TCheckGroup
+        AnchorSideLeft.Control = tbsOptions
+        AnchorSideTop.Side = asrBottom
+        AnchorSideRight.Control = tbsOptions
+        AnchorSideRight.Side = asrBottom
+        Left = 6
+        Height = 136
+        Top = 120
+        Width = 836
+        Anchors = [akTop, akLeft, akRight]
+        AutoFill = True
+        BorderSpacing.Around = 6
+        Caption = 'OptionsGroupBox'
+        ChildSizing.LeftRightSpacing = 6
+        ChildSizing.TopBottomSpacing = 6
+        ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
+        ChildSizing.EnlargeVertical = crsHomogenousChildResize
+        ChildSizing.ShrinkHorizontal = crsScaleChilds
+        ChildSizing.ShrinkVertical = crsScaleChilds
+        ChildSizing.Layout = cclLeftToRightThenTopToBottom
+        ChildSizing.ControlsPerLine = 2
+        Columns = 2
+        TabOrder = 0
+      end
+      object Text2GroupBox: TGroupBox
+        AnchorSideLeft.Control = tbsOptions
+        AnchorSideRight.Control = tbsOptions
+        AnchorSideRight.Side = asrBottom
+        Left = 6
+        Height = 53
+        Top = 64
+        Width = 836
+        Anchors = [akTop, akLeft, akRight]
+        AutoSize = True
+        BorderSpacing.Around = 6
+        Caption = 'Text2GroupBox'
+        ClientHeight = 33
+        ClientWidth = 832
+        TabOrder = 1
+        object Text2Combobox: TComboBox
+          AnchorSideLeft.Control = Text2GroupBox
+          AnchorSideTop.Control = Text2GroupBox
+          AnchorSideRight.Control = Text2FileOpenButton
+          Left = 6
+          Height = 23
+          Top = 6
+          Width = 597
+          Anchors = [akTop, akLeft, akRight]
+          BorderSpacing.Left = 6
+          BorderSpacing.Top = 6
+          BorderSpacing.Right = 6
+          ItemHeight = 15
+          OnChange = Text2ComboboxChange
+          TabOrder = 0
+          Text = 'Text2Combobox'
+        end
+        object Text2OnlySelectionCheckBox: TCheckBox
+          AnchorSideTop.Control = Text2FileOpenButton
+          AnchorSideTop.Side = asrCenter
+          AnchorSideRight.Control = Text2GroupBox
+          AnchorSideRight.Side = asrBottom
+          Left = 653
+          Height = 19
+          Top = 8
+          Width = 173
+          Anchors = [akTop, akRight]
+          BorderSpacing.Top = 6
+          BorderSpacing.Right = 6
+          BorderSpacing.Bottom = 6
+          Caption = 'Text2OnlySelectionCheckBox'
+          OnChange = OnChangeFlag
+          TabOrder = 1
+        end
+        object Text2FileOpenButton: TButton
+          AnchorSideTop.Control = Text2Combobox
+          AnchorSideRight.Control = Text2OnlySelectionCheckBox
+          AnchorSideBottom.Control = Text2Combobox
+          AnchorSideBottom.Side = asrBottom
+          Left = 609
+          Height = 23
+          Top = 6
+          Width = 32
+          Anchors = [akTop, akRight, akBottom]
+          BorderSpacing.Right = 12
+          Caption = 'Text2FileOpenButton'
+          OnClick = FileOpenClick
+          TabOrder = 2
+        end
+      end
+      object Text1GroupBox: TGroupBox
+        Left = 6
+        Height = 53
+        Top = 6
+        Width = 836
+        Align = alTop
+        AutoSize = True
+        BorderSpacing.Around = 6
+        Caption = 'Text1GroupBox'
+        ClientHeight = 33
+        ClientWidth = 832
+        TabOrder = 2
+        object Text1Combobox: TComboBox
+          AnchorSideLeft.Control = Text1GroupBox
+          AnchorSideTop.Control = Text1GroupBox
+          AnchorSideRight.Control = Text1FileOpenButton
+          Left = 6
+          Height = 23
+          Top = 6
+          Width = 597
+          Anchors = [akTop, akLeft, akRight]
+          BorderSpacing.Left = 6
+          BorderSpacing.Top = 6
+          BorderSpacing.Right = 6
+          ItemHeight = 15
+          OnChange = Text1ComboboxChange
+          TabOrder = 0
+          Text = 'Text1Combobox'
+        end
+        object Text1OnlySelectionCheckBox: TCheckBox
+          AnchorSideTop.Control = Text1FileOpenButton
+          AnchorSideTop.Side = asrCenter
+          AnchorSideRight.Control = Text1GroupBox
+          AnchorSideRight.Side = asrBottom
+          Left = 653
+          Height = 19
+          Top = 8
+          Width = 173
+          Anchors = [akTop, akRight]
+          BorderSpacing.Top = 6
+          BorderSpacing.Right = 6
+          BorderSpacing.Bottom = 6
+          Caption = 'Text1OnlySelectionCheckBox'
+          OnChange = OnChangeFlag
+          TabOrder = 1
+        end
+        object Text1FileOpenButton: TButton
+          AnchorSideTop.Control = Text1Combobox
+          AnchorSideRight.Control = Text1OnlySelectionCheckBox
+          AnchorSideBottom.Control = Text1Combobox
+          AnchorSideBottom.Side = asrBottom
+          Left = 609
+          Height = 23
+          Top = 6
+          Width = 32
+          Anchors = [akTop, akRight, akBottom]
+          BorderSpacing.Right = 12
+          Caption = 'Text1FileOpenButton'
+          OnClick = FileOpenClick
+          TabOrder = 2
+        end
+      end
+      object btnCompare: TButton
+        Left = 440
+        Height = 25
+        Top = 304
+        Width = 75
+        Caption = 'Compare'
+        OnClick = btnCompareClick
+        TabOrder = 3
+      end
+      object ProgressBar1: TProgressBar
+        AnchorSideLeft.Control = Owner
+        AnchorSideTop.Side = asrBottom
+        AnchorSideBottom.Control = CloseButton
+        Left = 6
+        Height = 24
+        Top = 473
+        Width = 706
+        Anchors = [akLeft, akRight, akBottom]
+        BorderSpacing.Around = 6
+        Step = 0
+        TabOrder = 4
+      end
+      object CancelScanningButton: TBitBtn
+        AnchorSideTop.Side = asrCenter
+        AnchorSideRight.Control = Owner
+        AnchorSideRight.Side = asrBottom
+        Left = 728
+        Height = 25
+        Top = 472
+        Width = 114
+        Anchors = [akRight, akBottom]
+        AutoSize = True
+        BorderSpacing.Around = 6
+        Caption = 'Cancel Scanning'
+        Enabled = False
+        OnClick = CancelScanningButtonClick
+        TabOrder = 5
+        Visible = False
+      end
+    end
+    object tbsCompare: TTabSheet
+      Caption = 'Compare'
+      ClientHeight = 500
+      ClientWidth = 848
+      OnResize = tbsCompareResize
+      inline edLeft: TSynEdit
+        Left = 5
+        Height = 456
+        Top = 40
+        Width = 400
+        Anchors = [akTop, akLeft, akBottom]
+        Font.Height = -13
+        Font.Name = 'Courier New'
+        Font.Pitch = fpFixed
+        Font.Quality = fqNonAntialiased
+        ParentColor = False
+        ParentFont = False
+        TabOrder = 0
+        Gutter.Width = 47
+        Gutter.MouseActions = <>
+        RightGutter.Width = 0
+        RightGutter.MouseActions = <>
+        Highlighter = SynFreePascalSyn1
+        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 = 24649
+          end        
+          item
+            Command = ecLineBreak
+            ShortCut = 16461
+          end        
+          item
+            Command = ecInsertLine
+            ShortCut = 16462
+          end        
+          item
+            Command = ecDeleteWord
+            ShortCut = 16468
+          end        
+          item
+            Command = ecBlockUnindent
+            ShortCut = 24661
+          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 = <>
+        VisibleSpecialChars = [vscSpace, vscTabAtLast]
+        ReadOnly = True
+        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
+        OnSpecialLineColors = edSpecialLineColors
+        OnStatusChange = edLeftStatusChange
+        inline SynLeftGutterPartList1: TSynGutterPartList
+          object SynGutterMarks1: TSynGutterMarks
+            Width = 24
+            MouseActions = <>
+          end
+          object SynGutterLineNumber1: TSynGutterLineNumber
+            Width = 17
+            MouseActions = <>
+            MarkupInfo.Background = clBtnFace
+            MarkupInfo.Foreground = clNone
+            DigitCount = 2
+            ShowOnlyLineNumbersMultiplesOf = 1
+            ZeroStart = False
+            LeadingZeros = False
+            OnFormatLineNumber = LeftSynGutterLineNumber1FormatLineNumber
+          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
+            Visible = False
+            MouseActions = <>
+            MarkupInfo.Background = clNone
+            MarkupInfo.Foreground = clGray
+            MouseActionsExpanded = <>
+            MouseActionsCollapsed = <>
+          end
+        end
+      end
+      inline edRight: TSynEdit
+        Left = 424
+        Height = 456
+        Top = 40
+        Width = 414
+        Anchors = [akTop, akLeft, akBottom]
+        Font.Height = -13
+        Font.Name = 'Courier New'
+        Font.Pitch = fpFixed
+        Font.Quality = fqNonAntialiased
+        ParentColor = False
+        ParentFont = False
+        TabOrder = 1
+        Gutter.Width = 47
+        Gutter.MouseActions = <>
+        RightGutter.Width = 0
+        RightGutter.MouseActions = <>
+        Highlighter = SynFreePascalSyn1
+        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 = 24649
+          end        
+          item
+            Command = ecLineBreak
+            ShortCut = 16461
+          end        
+          item
+            Command = ecInsertLine
+            ShortCut = 16462
+          end        
+          item
+            Command = ecDeleteWord
+            ShortCut = 16468
+          end        
+          item
+            Command = ecBlockUnindent
+            ShortCut = 24661
+          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 = <>
+        VisibleSpecialChars = [vscSpace, vscTabAtLast]
+        ReadOnly = True
+        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
+        OnSpecialLineColors = edSpecialLineColors
+        OnStatusChange = edRightStatusChange
+        inline SynLeftGutterPartList1: TSynGutterPartList
+          object SynGutterMarks1: TSynGutterMarks
+            Width = 24
+            MouseActions = <>
+          end
+          object SynGutterLineNumber1: TSynGutterLineNumber
+            Width = 17
+            MouseActions = <>
+            MarkupInfo.Background = clBtnFace
+            MarkupInfo.Foreground = clNone
+            DigitCount = 2
+            ShowOnlyLineNumbersMultiplesOf = 1
+            ZeroStart = False
+            LeadingZeros = False
+            OnFormatLineNumber = RightSynGutterLineNumber1FormatLineNumber
+          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
+            Visible = False
+            MouseActions = <>
+            MarkupInfo.Background = clNone
+            MarkupInfo.Foreground = clGray
+            MouseActionsExpanded = <>
+            MouseActionsCollapsed = <>
+          end
+        end
+      end
+      object btnFindL: TBitBtn
+        Left = 5
+        Height = 26
+        Top = 7
+        Width = 46
+        Glyph.Data = {
+          36040000424D3604000000000000360000002800000010000000100000000100
+          2000000000000004000064000000640000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF36342EFF36342EFF36342EFF3634
+          2EFF36342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2E7F36342EFF3D3D38FF3D3D38FF3D3D38FF36342EFF36342EFF36342EFF3634
+          2EFF36342EFF3D3D38FF36342EFF36342EFF36342E7F00000000000000000000
+          0000000000000000000036342EFF535755FF36342EFF00000000000000003634
+          2EFF535755FF36342EFF00000000000000000000000000000000000000000000
+          0000000000000000000036342EFF535755FF36342EFF00000000000000003634
+          2EFF535755FF36342EFF00000000000000000000000000000000000000000000
+          0000000000000000000036342EFF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF36342EFF00000000000000000000000000000000
+        }
+        GlyphShowMode = gsmAlways
+        OnClick = btnFindLClick
+        TabOrder = 2
+      end
+      object btnFindPreviousL: TBitBtn
+        Left = 54
+        Height = 26
+        Top = 7
+        Width = 46
+        Glyph.Data = {
+          36040000424D3604000000000000360000002800000010000000100000000100
+          2000000000000004000064000000640000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF454642FF36342EFF36342EFF36342EFF454642FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342E7F4546
+          42FF454642FF36342EFF36342EFF36342EFF454642FF454642FF36342E7F0000
+          000000000000000000001E1E91FF1E1E91FF0000000000000000000000000000
+          0000454642FF454642FF00000000454642FF454642FF00000000000000000000
+          000000000000000000001E1E91FF1E1E91FF0000000000000000000000000000
+          00003D3D38FF3D3D38FF000000003D3D38FF3D3D38FF00000000000000000000
+          00001E1E91FF1E1E91FF1E1E91FF1E1E91FF1E1E91FF1E1E91FF000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          00001E1E91551E1E91FF1E1E91FF1E1E91FF1E1E91FF1E1E9155000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000001E1E91551E1E91FF1E1E91FF1E1E915500000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          000000000000000000001E1E91551E1E91550000000000000000
+        }
+        GlyphShowMode = gsmAlways
+        OnClick = btnFindPreviousLClick
+        TabOrder = 3
+      end
+      object btnFindNextL: TBitBtn
+        Left = 101
+        Height = 26
+        Top = 7
+        Width = 46
+        Glyph.Data = {
+          36040000424D3604000000000000360000002800000010000000100000000100
+          2000000000000004000064000000640000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000911E5500911E550000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          00000000000000911E5500911EFF00911EFF00911E5500000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          000000911E5500911EFF00911EFF00911EFF00911EFF00911E5536342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000911EFF00911EFF00911EFF00911EFF00911EFF00911EFF36342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF454642FF36342EFF36342EFF36342EFF454642FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342E7F4546
+          42FF454642FF36342EFF36342EFF36342EFF454642FF454642FF36342E7F0000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          0000454642FF454642FF00000000454642FF454642FF00000000000000000000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          00003D3D38FF3D3D38FF000000003D3D38FF3D3D38FF00000000000000000000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000
+        }
+        GlyphShowMode = gsmAlways
+        OnClick = btnFindNextLClick
+        TabOrder = 4
+      end
+      object btnFindR: TBitBtn
+        Left = 696
+        Height = 26
+        Top = 7
+        Width = 46
+        Anchors = [akTop, akRight]
+        Glyph.Data = {
+          36040000424D3604000000000000360000002800000010000000100000000100
+          2000000000000004000064000000640000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF0000000000000000000000000000
+          000036342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF36342EFF36342EFF36342EFF36342EFF36342EFF3634
+          2EFF36342EFF36342EFF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF535755FF535755FF535755FF36342EFF535755FF535755FF3634
+          2EFF535755FF535755FF535755FF36342EFF36342EFF00000000000000003634
+          2E7F36342EFF3D3D38FF3D3D38FF3D3D38FF36342EFF36342EFF36342EFF3634
+          2EFF36342EFF3D3D38FF36342EFF36342EFF36342E7F00000000000000000000
+          0000000000000000000036342EFF535755FF36342EFF00000000000000003634
+          2EFF535755FF36342EFF00000000000000000000000000000000000000000000
+          0000000000000000000036342EFF535755FF36342EFF00000000000000003634
+          2EFF535755FF36342EFF00000000000000000000000000000000000000000000
+          0000000000000000000036342EFF36342EFF36342EFF00000000000000003634
+          2EFF36342EFF36342EFF00000000000000000000000000000000
+        }
+        GlyphShowMode = gsmAlways
+        OnClick = btnFindRClick
+        TabOrder = 5
+      end
+      object btnFindPreviousR: TBitBtn
+        Left = 744
+        Height = 26
+        Top = 7
+        Width = 46
+        Anchors = [akTop, akRight]
+        Glyph.Data = {
+          36040000424D3604000000000000360000002800000010000000100000000100
+          2000000000000004000064000000640000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF454642FF36342EFF36342EFF36342EFF454642FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          000000000000000000001E1E91FF1E1E91FF000000000000000036342E7F4546
+          42FF454642FF36342EFF36342EFF36342EFF454642FF454642FF36342E7F0000
+          000000000000000000001E1E91FF1E1E91FF0000000000000000000000000000
+          0000454642FF454642FF00000000454642FF454642FF00000000000000000000
+          000000000000000000001E1E91FF1E1E91FF0000000000000000000000000000
+          00003D3D38FF3D3D38FF000000003D3D38FF3D3D38FF00000000000000000000
+          00001E1E91FF1E1E91FF1E1E91FF1E1E91FF1E1E91FF1E1E91FF000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          00001E1E91551E1E91FF1E1E91FF1E1E91FF1E1E91FF1E1E9155000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000001E1E91551E1E91FF1E1E91FF1E1E915500000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          000000000000000000001E1E91551E1E91550000000000000000
+        }
+        GlyphShowMode = gsmAlways
+        OnClick = btnFindPreviousRClick
+        TabOrder = 6
+      end
+      object btnFindNextR: TBitBtn
+        Left = 792
+        Height = 26
+        Top = 7
+        Width = 46
+        Anchors = [akTop, akRight]
+        Glyph.Data = {
+          36040000424D3604000000000000360000002800000010000000100000000100
+          2000000000000004000064000000640000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000911E5500911E550000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          00000000000000911E5500911EFF00911EFF00911E5500000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          000000911E5500911EFF00911EFF00911EFF00911EFF00911E5536342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          000000911EFF00911EFF00911EFF00911EFF00911EFF00911EFF36342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF36342EFF00000000000000000000000036342EFF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF454642FF36342EFF36342EFF36342EFF454642FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342EFF5357
+          55FF535755FF36342EFF535755FF36342EFF535755FF535755FF36342EFF0000
+          0000000000000000000000911EFF00911EFF000000000000000036342E7F4546
+          42FF454642FF36342EFF36342EFF36342EFF454642FF454642FF36342E7F0000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          0000454642FF454642FF00000000454642FF454642FF00000000000000000000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          00003D3D38FF3D3D38FF000000003D3D38FF3D3D38FF00000000000000000000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000911EFF00911EFF0000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000000000000000
+          0000000000000000000000000000000000000000000000000000
+        }
+        GlyphShowMode = gsmAlways
+        OnClick = btnFindNextRClick
+        TabOrder = 7
+      end
+      object PanelButtons: TPanel
+        Left = 248
+        Height = 40
+        Top = 0
+        Width = 328
+        BevelOuter = bvNone
+        ClientHeight = 40
+        ClientWidth = 328
+        TabOrder = 8
+        object btnFirst: TButton
+          Left = 8
+          Height = 25
+          Top = 8
+          Width = 75
+          Caption = 'First'
+          OnClick = btnFirstClick
+          TabOrder = 0
+        end
+        object btnPrevious: TButton
+          Left = 88
+          Height = 25
+          Top = 8
+          Width = 75
+          Caption = 'Previous'
+          OnClick = btnpreviousClick
+          TabOrder = 1
+        end
+        object btnNext: TButton
+          Left = 168
+          Height = 25
+          Top = 8
+          Width = 75
+          Caption = 'Next'
+          OnClick = btnNextClick
+          TabOrder = 2
+        end
+        object btnLast: TButton
+          Left = 248
+          Height = 25
+          Top = 8
+          Width = 75
+          Caption = 'Last'
+          OnClick = btnLastClick
+          TabOrder = 3
+        end
+      end
+    end
+    object tbsPatch: TTabSheet
+      Caption = 'Patch'
+      ClientHeight = 500
+      ClientWidth = 848
+      inline DiffSynEdit: TSynEdit
+        AnchorSideLeft.Control = tbsPatch
+        AnchorSideRight.Control = tbsPatch
+        AnchorSideRight.Side = asrBottom
+        Left = 6
+        Height = 483
+        Top = 6
+        Width = 836
+        Align = alTop
+        BorderSpacing.Around = 6
+        Anchors = [akTop, akLeft, akRight, akBottom]
+        Font.Color = clBlack
+        Font.Height = -12
+        Font.Name = 'courier'
+        Font.Pitch = fpFixed
+        Font.Quality = fqNonAntialiased
+        ParentColor = False
+        ParentFont = False
+        TabOrder = 0
+        BookMarkOptions.Xoffset = -18
+        Gutter.Visible = False
+        Gutter.Width = 59
+        Gutter.MouseActions = <        
+          item
+            ClickCount = ccAny
+            ClickDir = cdDown
+            Command = emcOnMainGutterClick
+          end        
+          item
+            Button = mbRight
+            Command = emcContextMenu
+          end>
+        RightGutter.Width = 0
+        RightGutter.MouseActions = <        
+          item
+            ClickCount = ccAny
+            ClickDir = cdDown
+            Command = emcOnMainGutterClick
+          end        
+          item
+            Button = mbRight
+            Command = emcContextMenu
+          end>
+        Highlighter = SynDiffSyn1
+        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 = 24649
+          end        
+          item
+            Command = ecLineBreak
+            ShortCut = 16461
+          end        
+          item
+            Command = ecInsertLine
+            ShortCut = 16462
+          end        
+          item
+            Command = ecDeleteWord
+            ShortCut = 16468
+          end        
+          item
+            Command = ecBlockUnindent
+            ShortCut = 24661
+          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 = 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>
+        MouseActions = <        
+          item
+            ShiftMask = [ssShift, ssAlt]
+            ClickDir = cdDown
+            Command = emcStartSelections
+            MoveCaret = True
+          end        
+          item
+            Shift = [ssShift]
+            ShiftMask = [ssShift, ssAlt]
+            ClickDir = cdDown
+            Command = emcStartSelections
+            MoveCaret = True
+            Option = 1
+          end        
+          item
+            Shift = [ssAlt]
+            ShiftMask = [ssShift, ssAlt]
+            ClickDir = cdDown
+            Command = emcStartColumnSelections
+            MoveCaret = True
+          end        
+          item
+            Shift = [ssShift, ssAlt]
+            ShiftMask = [ssShift, ssAlt]
+            ClickDir = cdDown
+            Command = emcStartColumnSelections
+            MoveCaret = True
+            Option = 1
+          end        
+          item
+            Button = mbRight
+            Command = emcContextMenu
+          end        
+          item
+            ClickCount = ccDouble
+            ClickDir = cdDown
+            Command = emcSelectWord
+            MoveCaret = True
+          end        
+          item
+            ClickCount = ccTriple
+            ClickDir = cdDown
+            Command = emcSelectLine
+            MoveCaret = True
+          end        
+          item
+            ClickCount = ccQuad
+            ClickDir = cdDown
+            Command = emcSelectPara
+            MoveCaret = True
+          end        
+          item
+            Button = mbMiddle
+            ClickDir = cdDown
+            Command = emcPasteSelection
+            MoveCaret = True
+          end        
+          item
+            Shift = [ssCtrl]
+            ShiftMask = [ssShift, ssAlt, ssCtrl]
+            Command = emcMouseLink
+          end>
+        MouseTextActions = <>
+        MouseSelActions = <        
+          item
+            ClickDir = cdDown
+            Command = emcStartDragMove
+          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 TSynGutterPartList
+          object TSynGutterMarks
+            Width = 24
+            MouseActions = <>
+          end
+          object TSynGutterLineNumber
+            Width = 19
+            MouseActions = <>
+            MarkupInfo.Background = clBtnFace
+            MarkupInfo.Foreground = clNone
+            DigitCount = 2
+            ShowOnlyLineNumbersMultiplesOf = 1
+            ZeroStart = False
+            LeadingZeros = False
+          end
+          object TSynGutterChanges
+            Width = 4
+            MouseActions = <>
+            ModifiedColor = 59900
+            SavedColor = clGreen
+          end
+          object TSynGutterSeparator
+            Width = 2
+            MouseActions = <>
+            MarkupInfo.Background = clWhite
+            MarkupInfo.Foreground = clGray
+          end
+          object TSynGutterCodeFolding
+            MouseActions = <            
+              item
+                Button = mbRight
+                Command = emcCodeFoldContextMenu
+              end            
+              item
+                ShiftMask = [ssShift]
+                Button = mbMiddle
+                ClickCount = ccAny
+                ClickDir = cdDown
+                Command = emcCodeFoldCollaps
+              end            
+              item
+                Shift = [ssShift]
+                ShiftMask = [ssShift]
+                Button = mbMiddle
+                ClickCount = ccAny
+                ClickDir = cdDown
+                Command = emcCodeFoldCollaps
+                Option = 1
+              end            
+              item
+                ClickCount = ccAny
+                ClickDir = cdDown
+                Command = emcNone
+              end>
+            MarkupInfo.Background = clNone
+            MarkupInfo.Foreground = clGray
+            MouseActionsExpanded = <            
+              item
+                ClickCount = ccAny
+                ClickDir = cdDown
+                Command = emcCodeFoldCollaps
+              end>
+            MouseActionsCollapsed = <            
+              item
+                Shift = [ssCtrl]
+                ShiftMask = [ssCtrl]
+                ClickCount = ccAny
+                ClickDir = cdDown
+                Command = emcCodeFoldExpand
+              end            
+              item
+                ShiftMask = [ssCtrl]
+                ClickCount = ccAny
+                ClickDir = cdDown
+                Command = emcCodeFoldExpand
+                Option = 1
+              end>
+          end
+        end
+      end
+    end
+  end
+  object dlgOpen: TOpenDialog
+    DefaultExt = '.pas'
+    Filter = 'pascal files|*.pas;*.pp|any file|*.*'
+    FilterIndex = 0
+    Options = [ofPathMustExist, ofFileMustExist, ofEnableSizing, ofViewDetail]
+    Left = 48
+    Top = 392
+  end
+  object SynDiffSyn1: TSynDiffSyn
+    Enabled = False
+    Left = 104
+    Top = 240
+  end
+  object SynFreePascalSyn1: TSynFreePascalSyn
+    Enabled = False
+    CompilerMode = pcmFPC
+    NestedComments = True
+    TypeHelpers = False
+    Left = 417
+    Top = 112
   end
 end
diff --git a/ide/diffdialog.pas b/ide/diffdialog.pas
index 1ff74b96f9..a105389cbf 100644
--- a/ide/diffdialog.pas
+++ b/ide/diffdialog.pas
@@ -34,7 +34,7 @@
 
 unit DiffDialog;
 
-{$mode objfpc}{$H+}
+{$mode objfpc}{$H+} {$modeswitch advancedrecords}
 
 interface
 
@@ -43,13 +43,15 @@ uses
   // LCL
   Forms, Controls, Buttons, StdCtrls, ExtCtrls, Dialogs, ComCtrls, LCLType,
   // LazUtils
-  FileUtil,
+  FileUtil, IntegerList,
   // SynEdit
   SynEdit, SynHighlighterDiff,
   // IdeIntf
   IDEWindowIntf, IDEHelpIntf, IDEImagesIntf,
   // IDE
-  LazarusIDEStrConsts, EditorOptions, InputHistory, DiffPatch, SourceEditor, EnvironmentOpts;
+  LazarusIDEStrConsts, EditorOptions, InputHistory, DiffPatch, SourceEditor,
+  EnvironmentOpts, diff, Types, SynEditTypes,
+  SynHighlighterPas, Graphics, SynGutterLineNumber;
 
 type
 
@@ -89,7 +91,7 @@ type
     fFile: TAvailableDiffFile;        // Selected File
     fCombobox: TComboBox;             // Reference for the user selection GUI.
     fOnlySelCheckBox: TCheckBox;
-    function TextContents: string;
+    procedure GetLines(ALines:TStrings;var aFirstLine:integer; var aFileName:string);
     procedure SetIndex(NewIndex: integer);
     procedure SetFileName(aFileName: string);
     procedure UpdateIndex;
@@ -100,50 +102,94 @@ type
   { TDiffDlg }
   
   TDiffDlg = class(TForm)
+    btnFindL: TBitBtn;
+    btnFindNextR: TBitBtn;
+    btnFindPreviousR: TBitBtn;
+    btnFindR: TBitBtn;
+    btnFindPreviousL: TBitBtn;
+    btnFindNextL: TBitBtn;
+    btnFirst: TButton;
+    btnCompare: TButton;
+    btnLast: TButton;
+    btnNext: TButton;
+    btnPrevious: TButton;
+    CancelScanningButton: TBitBtn;
+    DiffSynEdit: TSynEdit;
+    edLeft: TSynEdit;
+    edRight: TSynEdit;
     HelpButton: TBitBtn;
     CloseButton: TBitBtn;
-    DiffSynEdit: TSynEdit;
     OpenInEditorButton: TBitBtn;
+    OptionsGroupBox: TCheckGroup;
+    PageControl1: TPageControl;
+    PanelButtons: TPanel;
     ProgressBar1: TProgressBar;
     SynDiffSyn1: TSynDiffSyn;
-    Text1FileOpenButton: TButton;
-    CancelScanningButton: TBitBtn;
     dlgOpen: TOpenDialog;
-
-    Text2FileOpenButton: TButton;
-
-    // text 1
-    Text1GroupBox: TGroupBox;
+    SynFreePascalSyn1: TSynFreePascalSyn;
+    tbsOptions: TTabSheet;
+    tbsCompare: TTabSheet;
+    tbsPatch: TTabSheet;
     Text1Combobox: TComboBox;
+    Text1FileOpenButton: TButton;
+    Text1GroupBox: TGroupBox;
     Text1OnlySelectionCheckBox: TCheckBox;
-    
-    // text 2
-    Text2GroupBox: TGroupBox;
     Text2Combobox: TComboBox;
+    Text2FileOpenButton: TButton;
+    Text2GroupBox: TGroupBox;
     Text2OnlySelectionCheckBox: TCheckBox;
 
-    // options
-    OptionsGroupBox: TCheckGroup;
-
+    procedure btnCompareClick(Sender: TObject);
+    procedure btnFindLClick(Sender: TObject);
+    procedure btnFindNextLClick(Sender: TObject);
+    procedure btnFindNextRClick(Sender: TObject);
+    procedure btnFindPreviousLClick(Sender: TObject);
+    procedure btnFindPreviousRClick(Sender: TObject);
+    procedure btnFindRClick(Sender: TObject);
+    procedure btnFirstClick(Sender: TObject);
+    procedure btnLastClick(Sender: TObject);
+    procedure btnNextClick(Sender: TObject);
+    procedure btnpreviousClick(Sender: TObject);
     procedure CancelScanningButtonClick(Sender: TObject);
+    procedure edSpecialLineColors(Sender: TObject; Line: integer;
+      var Special: boolean; var FG, BG: TColor);
+    procedure edLeftStatusChange(Sender: TObject; Changes: TSynStatusChanges);
+    procedure edRightStatusChange(Sender: TObject; Changes: TSynStatusChanges);
     procedure FileOpenClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
     procedure HelpButtonClick(Sender: TObject);
     procedure OnChangeFlag(Sender: TObject);
+    procedure LeftSynGutterLineNumber1FormatLineNumber(
+      Sender: TSynGutterLineNumber; ALine: integer; out AText: string;
+      const ALineInfo: TSynEditGutterLineInfo);
+    procedure RightSynGutterLineNumber1FormatLineNumber(
+      Sender: TSynGutterLineNumber; ALine: integer; out AText: string;
+      const ALineInfo: TSynEditGutterLineInfo);
+    procedure tbsCompareResize(Sender: TObject);
     procedure Text1ComboboxChange(Sender: TObject);
     procedure Text2ComboboxChange(Sender: TObject);
   private
     fUpdating: Boolean;
-    fIdleConnected: boolean;
-    fCancelled: boolean;
     fAvailableFiles: TAvailableDiffFiles;
     fSelectedFile1: TSelectedDiffFile;
     fSelectedFile2: TSelectedDiffFile;
+    fDiff: TDiff;
+    fLeftLines:TStringList;
+    fRightLines:TStringList;
+    fLeftFirstLineNumber:integer;
+    fRightFirstLineNumber:integer;
+    fLeftTextHashes: TCardinalList;
+    fRightTextHashes: TCardinalList;
+    fCurrentOptions:TTextDiffFlags;
+
+    fRightSearchOptions:TSynSearchOptions;
+    fRightSearchText:string;
+    fLeftSearchOptions:TSynSearchOptions;
+    fLeftSearchText:string;
+
     procedure SetupComponents;
     procedure UpdateDiff;
-    procedure SetIdleConnected(const AValue: boolean);
-    procedure OnIdle(Sender: TObject; var {%H-}Done: Boolean);
-    procedure UpdateProgress(aPosition: Integer);
+    function GetNomalizedKindType(aLineIndex:integer):TChangeKind;
   public
     constructor Create(TheOwner: TComponent); override;
     destructor Destroy; override;
@@ -152,11 +198,9 @@ type
     procedure SaveSettings;
     procedure SetDiffOptions(NewOptions: TTextDiffFlags);
     function GetDiffOptions: TTextDiffFlags;
-
-    property IdleConnected: boolean read fIdleConnected write SetIdleConnected;
   end;
   
-function ShowDiffDialog(Text1Index: integer; out Diff: string): TModalResult;
+function ShowDiffDialog(Text1Index: integer; out ADiff: string): TModalResult;
 
 const
   IgnoreCaseCheckBox = 0;
@@ -171,12 +215,701 @@ implementation
 
 {$R *.lfm}
 
-function ShowDiffDialog(Text1Index: integer; out Diff: string): TModalResult;
+uses
+  LCLIntf, dateutils, crc, strutils,FindReplaceDialog,SrcEditorIntf;
+
+//********************************    support functions
+// todo: move to unit   difmerge.pas ??
+const
+  EMPTY_LINE_HASH = 0;
+
+{ IncrementalCRC32 }
+
+type
+
+IncrementalCRC32 = record
+  crc: cardinal;
+  bytescount: cardinal;
+  procedure Start;
+  procedure NextByte(AByte: byte);
+  procedure Finalize;
+end;
+
+
+var
+  crc32_Table: PCardinal;
+
+procedure IncrementalCRC32.Start;
+begin
+  if crc32_Table = nil then
+    crc32_Table := get_crc32_table;
+  crc := 0 xor $FFFFFFFF;
+  bytescount := 0;
+end;
+
+procedure IncrementalCRC32.NextByte(AByte: byte);
+begin
+  crc := crc32_table[(crc xor AByte) and $ff] xor (crc shr 8);
+  Inc(bytescount);
+end;
+
+procedure IncrementalCRC32.Finalize;
+begin
+  if bytescount > 0 then
+    crc := crc xor $FFFFFFFF
+  else
+    crc := EMPTY_LINE_HASH;
+end;
+
+function HashLine(const ALine: string; AOptions: TTextDiffFlags = []): cardinal;
+var
+  lLen: integer;
+  lstart: integer;
+  lLine: string;
+  lCrc: IncrementalCRC32;
+begin
+  lLine := ALine;
+  lLen := Length(ALine);
+  lstart := 1;
+
+  if tdfIgnoreCase in AOptions then
+    lLine := AnsiLowerCase(ALine);
+
+  //tdfIgnoreEmptyLineChanges  Not affect hash, only affects patch.
+
+  if tdfIgnoreLineEnds in AOptions then
+  begin
+    if (llen > 0) and (lLine[llen] = #10) then
+      Dec(lLen);
+    if (llen > 0) and (lLine[llen] = #13) then
+      Dec(lLen);
+  end;
+
+  if tdfIgnoreSpaceChars in AOptions then
+  begin
+    lCrc.Start;
+    while (lstart <= llen) do
+    begin
+      if not (lLine[lstart] in [' ', #9]) then
+        lCrc.NextByte(byte(lLine[lstart]));
+      Inc(lstart);
+    end;
+    lCrc.Finalize;
+    Result := lCrc.crc;
+    exit;
+  end;
+
+  if tdfIgnoreHeadingSpaces in AOptions then
+  begin
+    while (lstart <= llen) and (lLine[lstart] in [' ', #9]) do
+    begin
+      Inc(lstart);
+    end;
+  end;
+  if tdfIgnoreTrailingSpaces in AOptions then
+  begin
+    while (lLen > 0) and (lLine[lLen] in [' ', #9]) do
+    begin
+      Dec(lLen);
+    end;
+  end;
+  if tdfIgnoreSpaceCharAmount in AOptions then
+  begin
+    lCrc.Start;
+    while (lstart <= llen) do
+    begin
+      if lLine[lstart] in [' ', #9] then
+      begin
+        lCrc.NextByte(Ord(' ')); //first space
+        Inc(lStart);
+        //skip next spaces.
+        while (lstart <= llen) and (lLine[lstart] in [' ', #9]) do
+          Inc(lStart);
+      end
+      else
+        lCrc.NextByte(byte(lLine[lstart]));
+      Inc(lstart);
+    end;
+    lCrc.Finalize;
+    Result := lCrc.crc;
+    exit;
+  end;
+  if (lLen - lstart + 1) <= 0 then
+    Result := CRC32(0, nil, 0)
+  else
+    Result := CRC32(0, pbyte(@lLine[lstart]), lLen - lstart + 1);
+end;
+
+//Line number 1 based as TSynEdit.
+procedure FillHashList(AList: TCardinalList; ALines: TStrings;AOptions:TTextDiffFlags=[]; AFirstLine: integer = 1; ALastLine: integer = maxint);
+var
+  i: integer;
+begin
+  AList.Clear;
+  Dec(AFirstLine);
+  Dec(ALastLine);
+  if AFirstLine < 0 then
+    AFirstLine := 0;
+  if ALastLine > ALines.Count - 1 then
+    ALastLine := ALines.Count - 1;
+  for i := AFirstLine to ALastLine do
+  begin
+    AList.Add(HashLine(ALines[i],AOptions));
+  end;
+end;
+
+function EditorGetLastColumn(AEditor: TSynEdit; ALineNumber: integer): integer; overload;
+var
+  lPoint: TPoint;
+begin
+  lPoint.X := length(AEditor.Lines[ALineNumber - 1]) + 1;
+  lPoint.Y := ALineNumber;
+  lPoint := AEditor.PhysicalToLogicalPos(lPoint);
+  Result := lPoint.X;
+end;
+
+procedure EditorDeleteLine(AEditor: TSynEdit; ALineNumber: integer); overload;
+var
+  lStartPoint, lEndPoint: Tpoint;
+begin
+  if (ALineNumber < 0) or (ALineNumber > AEditor.Lines.Count) then
+    Exit;
+  lStartPoint.X := 1;
+  lStartPoint.Y := ALineNumber;
+  lEndPoint.X := 1;
+  lEndPoint.Y := ALineNumber + 1;
+  if lEndPoint.Y > AEditor.Lines.Count then
+  begin
+    lEndPoint.Y := ALineNumber;
+    lEndPoint.X := EditorGetLastColumn(AEditor, ALineNumber);
+    if ALineNumber > 1 then
+    begin
+      lStartPoint.X := EditorGetLastColumn(AEditor, ALineNumber - 1);
+      lStartPoint.Y := ALineNumber - 1;
+    end;
+  end;
+  AEditor.SetTextBetweenPoints(lStartPoint, lEndPoint, '');
+end;
+
+procedure EditorInsertLine(AEditor: TSynEdit; ALineNumber: integer; AText: string); overload;
+var
+  lStartPoint, lEndPoint: Tpoint;
+  lColumn: integer;
+begin
+  if (ALineNumber < 0) or (ALineNumber > AEditor.Lines.Count + 1) then
+    Exit;
+  if ALineNumber = (AEditor.Lines.Count + 1) then   //append at the end.
+  begin
+    Dec(ALineNumber);
+    lColumn := EditorGetLastColumn(AEditor, ALineNumber);
+    lStartPoint.X := lColumn;
+    lStartPoint.Y := ALineNumber;
+    lEndPoint.X := lColumn;
+    lEndPoint.Y := ALineNumber;
+    AEditor.SetTextBetweenPoints(lStartPoint, lEndPoint, #10 + AText);
+  end
+  else
+  begin                                         //insert
+    lStartPoint.X := 1;
+    lStartPoint.Y := ALineNumber;
+    lEndPoint.X := 1;
+    lEndPoint.Y := ALineNumber;
+    AEditor.SetTextBetweenPoints(lStartPoint, lEndPoint, AText + #10);
+  end;
+end;
+
+procedure EditorReplaceLine(AEditor: TSynEdit; ALineNumber: integer; ANewText: string); overload;
+var
+  lStartPoint, lEndPoint: Tpoint;
+begin
+  if (ALineNumber < 0) or (ALineNumber > AEditor.Lines.Count) then
+    Exit;
+  lStartPoint.X := 1;
+  lStartPoint.Y := ALineNumber;
+  lEndPoint.X := 1;
+  lEndPoint.Y := ALineNumber;
+  lEndPoint.X := EditorGetLastColumn(AEditor, ALineNumber);
+  AEditor.SetTextBetweenPoints(lStartPoint, lEndPoint, ANewText);
+end;
+
+procedure Compare(ADiff:TDiff;AText0:Tstrings;AText1:TStrings;AList0TextHashes, AList1TextHashes: TCardinalList;AEditor0:TSynEdit;AEditor1:TSynEdit);
+var
+  lI: integer;
+begin
+  try
+    ADiff.Execute(AList0TextHashes, AList1TextHashes);
+    AEditor0.BeginUpdate;
+    AEditor1.BeginUpdate;
+    AEditor0.lines.Clear;
+    AEditor1.Lines.Clear;
+    for lI := 0 to ADiff.Count - 1 do
+    begin
+      with ADiff.Compares[lI] do
+      begin
+        case Kind of
+          ckNone:
+          begin
+            AEditor0.Lines.Add(aText0[oldIndex1]);
+            AEditor1.Lines.Add(aText1[oldIndex2]);
+          end;
+          ckAdd:
+          begin
+            AEditor0.Lines.Add('');
+            AEditor1.Lines.Add(aText1[oldIndex2]);
+          end;
+          ckDelete:
+          begin
+            AEditor0.Lines.Add(aText0[oldIndex1]);
+            AEditor1.Lines.Add('');
+          end;
+          ckModify:
+          begin
+            AEditor0.Lines.Add(aText0[oldIndex1]);
+            AEditor1.Lines.Add(aText1[oldIndex2]);
+          end;
+        end;
+      end;
+    end;
+  finally
+    AEditor0.EndUpdate;
+    AEditor1.EndUpdate;
+  end;
+end;
+
+// modified from dateutil.inc
+const
+  FmtUTC = 'yyyy"-"mm"-"dd" "hh":"nn":"ss"."zzz000000 ';
+
+function DateToUnifiedPatchFormat(const ADate: TDateTime; AInputIsUTC: boolean = True): string;
+const
+  FmtOffset: string = '%.02d%.02d';
+  Sign: array[boolean] of char = ('+', '-');
+var
+  Offset: integer;
+begin
+  Result := FormatDateTime(FmtUTC, ADate);
+  Offset := GetLocalTimeOffset;//(ADate, AInputIsUTC);
+  if AInputIsUTC or (Offset = 0) then
+    Result := Result + 'Z'
+  else
+  begin
+    Result := Result + Sign[Offset > 0];
+    Offset := Abs(Offset);
+    Result := Result + Format(FmtOffset, [Offset div MinsPerHour, Offset mod MinsPerHour]);
+  end;
+end;
+
+procedure MakeUnifiedPatch(ADiff: TDiff; ALeftLines: TStrings; ARightLines: TStrings; APatchLines: TStrings;
+  const ALeftFileName: string; const ARightFilename: string; ALeftFileDate: TDateTime = 0; ARigthFileDate: TDateTime = 0;
+  ALeftFirstLineNumber: integer = 1; ARightFirstLineNumber: integer = 1);
+const
+  CONTEXT_LINES = 2;
+  NEW_HUNK_LINES = 8;
+var
+  LineIndex, wJ: integer;
+  DiffFound: boolean;
+  StartLine: integer;
+  CountContext: integer;
+  HunkHeaderIndex: integer;
+  PushLineIndex: integer;
+  PushedLineIndexModify: integer;
+  LeftLineStart, RightLineStart, LeftLinesCount, RightLinesCount: integer;
+  NewHunk: boolean;
+  LeftDateStr, RightDateStr: string;
+  IgnoreEmptyLine: boolean;
+
+  procedure SetInitialLines(ALeftLine: integer; ARightLine: integer);
+  begin
+    if (ALeftLine >= 0) and (LeftLineStart < 0) then
+      LeftLineStart := ALeftLine + 1;
+    if (ARightLine >= 0) and (RightLineStart < 0) then
+      RightLineStart := ARightLine + 1;
+  end;
+
+  procedure TestNoNewLineAtEndOfFile(AStrings: TStrings; AIndex: integer);
+  begin
+    if AIndex = AStrings.Count - 1 then
+    begin
+      if AStrings[AIndex] <> '' then
+        APatchLines.Add('\ no new line at end of file');    //don't translate
+    end;
+  end;
+
+  procedure AddPatchLine(const APrefix: string; const Astrings: TStrings; AIndex: integer);
+  begin
+    APatchLines.Add(APrefix + AStrings[AIndex]);
+    TestNoNewLineAtEndOfFile(AStrings, AIndex);
+  end;
+
+begin
+  Dec(ALeftFirstLineNumber); // 0 offset
+  Dec(ARightFirstLineNumber);
+  APatchLines.Clear;
+  if (ADiff.DiffStats.adds = 0) and (ADiff.DiffStats.deletes = 0) and (ADiff.DiffStats.modifies = 0) then
+    Exit;
+  LeftDateStr := '';
+  RightDateStr := '';
+  if ALeftFileDate <> 0 then
+    LeftDateStr := DateToUnifiedPatchFormat(ALeftFileDate, False);
+  if ARigthFileDate <> 0 then
+    RightDateStr := DateToUnifiedPatchFormat(ARigthFileDate, False);
+  APatchLines.Add('--- ' + ALeftFileName + ' ' + LeftDateStr);
+  APatchLines.Add('+++ ' + ARightFilename + ' ' + RightDateStr);
+  // find blocks with differences
+  LineIndex := 0;
+  StartLine := 0;
+  while (LineIndex < ADiff.Count) do
+  begin
+    DiffFound := False;
+    while (LineIndex < ADiff.Count) and (DiffFound = False) do
+    begin
+      if ADiff.Compares[LineIndex].Kind <> ckNone then
+      begin
+        DiffFound := True;
+        break;
+      end;
+      Inc(LineIndex);
+    end;
+    if DiffFound = False then
+      break;
+    // move back context lines
+    wJ := LineIndex - 1;
+    CountContext := 0;
+    while (wJ >= StartLine) and (ADiff.Compares[wJ].Kind = ckNone) and (CountContext < CONTEXT_LINES) do
+    begin
+      Inc(CountContext);
+      Dec(wJ);
+    end;
+    LineIndex := wJ + 1;
+    HunkHeaderIndex := APatchLines.Count;
+    APatchLines.Add('@@ -ll,rl +lr,rr @@'); // < updated later at end of hunk.
+    LeftLineStart := -1;
+    LeftLinesCount := 0;
+    RightLineStart := -1;
+    RightLinesCount := 0;
+    // Add context lines
+    for wJ := 1 to CountContext do
+    begin
+      AddPatchLine(' ', ALeftLines, ADiff.Compares[LineIndex].oldIndex1);
+      SetInitialLines(ADiff.Compares[LineIndex].oldIndex1, ADiff.Compares[LineIndex].oldIndex2);
+      Inc(LineIndex);
+      Inc(LeftLinesCount);
+      Inc(RightLinesCount);
+    end;
+    while (LineIndex < ADiff.Count) do
+    begin
+      //Add changed lines
+      while (LineIndex < ADiff.Count) and (ADiff.Compares[LineIndex].Kind <> ckNone) do
+      begin
+        case ADiff.Compares[LineIndex].Kind of
+          //ckNone: ;
+          ckAdd:
+          begin
+            AddPatchLine('+', ARightLines, ADiff.Compares[LineIndex].oldIndex2);
+            SetInitialLines(ADiff.Compares[LineIndex].oldIndex1, ADiff.Compares[LineIndex].oldIndex2);
+            Inc(RightLinesCount);
+          end;
+          ckDelete:
+          begin
+            AddPatchLine('-', ALeftLines, ADiff.Compares[LineIndex].oldIndex1);
+            SetInitialLines(ADiff.Compares[LineIndex].oldIndex1, ADiff.Compares[LineIndex].oldIndex2);
+            Inc(LeftLinesCount);
+          end;
+          ckModify:
+          begin
+          {$DEFINE FIRSTDELETEALLMODIFIEDLINES}
+          {$IFDEF FIRSTDELETEALLMODIFIEDLINES}
+            PushedLineIndexModify := LineIndex;
+            while (LineIndex < ADiff.Count) and (ADiff.Compares[LineIndex].Kind = ckModify) do
+            begin
+              AddPatchLine('-', ALeftLines, ADiff.Compares[LineIndex].oldIndex1);
+              SetInitialLines(ADiff.Compares[LineIndex].oldIndex1, ADiff.Compares[LineIndex].oldIndex2);
+              Inc(LineIndex);
+            end;
+            LineIndex := PushedLineIndexModify;
+            while (LineIndex < ADiff.Count) and (ADiff.Compares[LineIndex].Kind = ckModify) do
+            begin
+              AddPatchLine('+', ARightLines, ADiff.Compares[LineIndex].oldIndex2);
+              SetInitialLines(ADiff.Compares[LineIndex].oldIndex1, ADiff.Compares[LineIndex].oldIndex2);
+              Inc(LeftLinesCount);
+              Inc(RightLinesCount);
+              Inc(LineIndex);
+            end;
+            if LineIndex > PushedLineIndexModify then
+              Dec(LineIndex);
+          {$ELSE}
+            AddPatchLine('-', LeftLines, Diff.Compares[LineIndex].oldIndex1);
+            AddPatchLine('+', RightLines, Diff.Compares[LineIndex].oldIndex2);
+            SetInitialLines(Diff.Compares[LineIndex].oldIndex1, Diff.Compares[LineIndex].oldIndex2);
+            Inc(LeftLinesCount);
+            Inc(RightLinesCount);
+          {$ENDIF}
+          end;
+        end;
+        Inc(LineIndex);
+      end;
+      // Add context lines
+      // check if there are less than NEW_HUNK_LINES lines without modifying and add them
+      // if there are more, just add the first CONTEXT_LINES and jump to next HUNK.
+      PushLineIndex := LineIndex;
+      CountContext := 0;
+      NewHunk := False;
+      while (LineIndex < ADiff.Count) do
+      begin
+        if ADiff.Compares[LineIndex].Kind = ckNone then
+        begin
+          Inc(CountContext);
+          if CountContext >= NEW_HUNK_LINES then
+          begin
+            CountContext := CONTEXT_LINES;
+            NewHunk := True;
+            break;
+          end;
+        end
+        else
+        begin
+          break;
+        end;
+        Inc(LineIndex);
+      end;
+      if (LineIndex >= ADiff.Count) and (ADiff.Compares[ADiff.Count - 1].Kind = ckNone) then
+      begin
+        CountContext := CONTEXT_LINES;
+        NewHunk := True;
+      end;
+      LineIndex := PushLineIndex;
+      for PushLineIndex := 1 to CountContext do
+      begin
+        if LineIndex >= ADiff.Count then
+          break;
+        AddPatchLine(' ', ALeftLines, ADiff.Compares[LineIndex].oldIndex1);
+        SetInitialLines(ADiff.Compares[LineIndex].oldIndex1, ADiff.Compares[LineIndex].oldIndex2);
+        Inc(LineIndex);
+        Inc(LeftLinesCount);
+        Inc(RightLinesCount);
+      end;
+      if NewHunk then
+        break;
+    end;
+    // Update hunk data.
+    if LeftLineStart < 0 then LeftLineStart := 0;
+    if RightLineStart < 0 then RightLineStart := 0;
+    if LeftLinesCount < 0 then LeftLinesCount := 0;
+    if RightLinesCount < 0 then RightLinesCount := 0;
+    APatchLines[HunkHeaderIndex] := '@@ -' + IntToStr(LeftLineStart + ALeftFirstLineNumber) + ',' + IntToStr(LeftLinesCount) +
+      ' +' + IntToStr(RightLineStart + ARightFirstLineNumber) + ',' + IntToStr(RightLinesCount) + ' @@';
+    StartLine := LineIndex;
+  end;
+end;
+
+// Tries to apply the first patch to the editor.
+// Only tries the first.
+function ApplyUnifiedPatch(AEditor: TSynEdit; APatch: TStrings; AOnlyTest: boolean; out AErrorMsg: string): boolean;
+const
+  lisDiffMsgOk = 'Ok';
+  lisDiffMsgInvalidFileFormat = 'Invalid patch file format';
+  lisDiffMsgLineNotExists = 'Error, line: %d not exists in editor';
+  lisDiffMsgLinesDontMatch = 'Error, editor line: %d don''t match: [%s] editor [%s]';
+var
+  PatchLine: string;
+  Index: integer;
+  FirstChar: char;
+  LineNumber: integer;
+  EditorLineCount: integer;
+  DeltaLines: integer;
+
+  function GetLineNumber: integer;
+  var
+    I: integer;
+  begin
+    Result := -9999;
+    I := 4;
+    if (I <= length(PatchLine)) and (PatchLine[I] in ['0'..'9']) then
+    begin
+      Result := Ord(PatchLine[I]) - Ord('0');
+      Inc(I);
+    end;
+    while (I <= length(PatchLine)) and (PatchLine[I] in ['0'..'9']) do
+    begin
+      Result := 10 * Result + (Ord(PatchLine[I]) - Ord('0'));
+      Inc(I);
+    end;
+  end;
+
+begin
+  // first test if we can apply the patch.
+  if AOnlyTest = False then
+  begin
+    if not ApplyUnifiedPatch(AEditor, APatch, True, AErrorMsg) then
+    begin
+      exit(False);
+    end;
+  end;
+  try
+    if not AOnlyTest then
+    begin
+      AEditor.BeginUpdate;
+      AEditor.BeginUndoBlock;
+    end;
+    AErrorMsg := lisDiffMsgInvalidFileFormat;
+    if aPatch.Count < 4 then
+      exit(False);
+    Index := 0;
+    PatchLine := APatch[Index];
+    // Skip git header if present.
+    if AnsiStartsStr('From ', PatchLine) then
+    begin
+      while Index < aPatch.Count do
+      begin
+        Inc(Index);
+        PatchLine := APatch[Index];
+        if AnsiStartsStr('index', PatchLine) then
+        begin
+          Inc(Index);
+          PatchLine := APatch[Index];
+          break;
+        end;
+      end;
+    end;
+    // Skip subversion header if present.
+    if AnsiStartsStr('Index', PatchLine) then
+    begin
+      while Index < aPatch.Count do
+      begin
+        Inc(Index);
+        PatchLine := APatch[Index];
+        if AnsiStartsStr('=====', PatchLine) then
+        begin
+          Inc(Index);
+          PatchLine := APatch[Index];
+          break;
+        end;
+      end;
+    end;
+    if aPatch.Count < (Index + 4) then
+      exit(False);
+    if not AnsiStartsStr('---', PatchLine) then
+      exit(False);
+    Inc(Index);
+    PatchLine := APatch[Index];
+    if not AnsiStartsStr('+++', PatchLine) then
+      exit(False);
+    Inc(Index);
+    PatchLine := APatch[Index];
+    if Copy(PatchLine, 1, 4) <> '@@ -' then
+      exit(False);
+    EditorLineCount := AEditor.Lines.Count;
+    DeltaLines := 0;
+    while Index < APatch.Count do
+    begin
+      PatchLine := APatch[Index];
+      if length(PatchLine) < 1 then   // empty line.
+      begin
+        FirstChar := ' ';
+        PatchLine := '';
+      end
+      else
+      begin
+        FirstChar := PatchLine[1];
+        PatchLine := Copy(PatchLine, 2, Length(PatchLine) - 1);
+      end;
+      case FirstChar of
+        '@':
+        begin
+          LineNumber := GetLineNumber;
+          if LineNumber = -9999 then
+            exit(False);
+        end;
+        ' ':
+        begin  //compare if lines are equal.
+          if LineNumber > EditorLineCount then
+          begin
+            AErrorMsg := Format(lisDiffMsgLineNotExists,[LineNumber]);
+            exit(False);
+          end;
+          if PatchLine <> AEditor.Lines[LineNumber + DeltaLines - 1] then
+          begin
+            AErrorMsg := Format(lisDiffMsgLinesDontMatch,[LineNumber,PatchLine,AEditor.Lines[LineNumber + DeltaLines - 1]]);
+            exit(False);
+          end;
+          Inc(LineNumber);
+        end;
+        '+':
+        begin
+          if not AOnlyTest then
+          begin
+            EditorInsertLine(aEditor, LineNumber + DeltaLines, PatchLine);
+            Inc(DeltaLines);
+          end;
+        end;
+        '-':
+        begin
+          if not AOnlyTest then
+          begin
+            EditorDeleteLine(aEditor, LineNumber + DeltaLines);
+            Dec(DeltaLines);
+          end;
+          Inc(LineNumber);
+        end;
+        '\':
+        begin
+        end;
+        'd':  // 'diff' next patch in the file git
+        begin
+          break;
+        end;
+        'I', '=':  // 'Index' next patch in the file subversion
+        begin
+          break;
+        end;
+        else
+          exit(False);
+      end;
+      Inc(Index);
+    end;
+  finally
+    if not AOnlyTest then
+    begin
+      AEditor.EndUndoBlock;
+      AEditor.EndUpdate;
+    end;
+  end;
+  AErrorMsg := lisDiffMsgOk;
+  exit(True);
+end;
+
+// faster than aTo.Text:=aFrom.Text
+procedure CopyStringList(AFrom: TStrings; ATo: TStrings);overload;
+var
+  lI: integer;
+begin
+  ATo.Clear;
+  ATo.Capacity := AFrom.Count;
+  for lI := 0 to AFrom.Count - 1 do
+  begin
+    ATo.Add(AFrom[lI]);
+  end;
+end;
+
+procedure CopyStringList(AFrom: TStrings; ATo: TStrings; AFromLine: integer; AToLine: integer); overload;
+var
+  lI: integer;
+begin
+  ATo.Clear;
+  ATo.Capacity := AToLine - AFromLine + 1;
+  for lI := AFromLine to AToLine do
+    ATo.Add(AFrom[lI]);
+end;
+
+//***************************************  end of support functions
+
+function ShowDiffDialog(Text1Index: integer; out ADiff: string): TModalResult;
 var
   DiffDlg: TDiffDlg;
   Files: TAvailableDiffFiles;
   i: Integer;
   SrcEdit: TSourceEditor;
+  Temp:string;
 begin
   DiffDlg := TDiffDlg.Create(nil);
   Files := TAvailableDiffFiles.Create;
@@ -193,7 +926,10 @@ begin
     DiffDlg.SaveSettings;
     // "Open in editor" button returns mrYes.
     if Result=mrYes then
-      Diff := DiffDlg.DiffSynEdit.Text;
+    begin
+      Temp:=DiffDlg.DiffSynEdit.Text;       //Temp SOLVES EXCEPTION sigsegv AND IDE CRASH.
+      ADiff := Temp;
+    end;
   finally
     Files.Free;
     DiffDlg.Free;
@@ -211,26 +947,27 @@ begin
   fOnlySelCheckBox := aOnlySelCheckBox;
 end;
 
-function TSelectedDiffFile.TextContents: string;
-var
-  dat: TStringList;
+procedure TSelectedDiffFile.GetLines(ALines: TStrings; var aFirstLine: integer; var aFileName: string);
 begin
-  if fFile = nil then Exit('');
+  aFirstLine := 1;
+  aFileName := '';
+  if fFile = nil then Exit;
   if fFile.Editor = nil then
   begin
-    dat := TStringList.Create;
-    try
-      dat.LoadFromFile(fFile.Name);
-      Result := dat.Text;
-    finally
-      dat.Free;
-    end;
+    ALines.LoadFromFile(fFile.Name);
+    AFileName := fFile.Name;
   end
   else begin
+    AFileName := fFile.Editor.FileName;
     if (fFile.SelectionAvailable and fOnlySelCheckBox.Checked) then
-      Result := fFile.Editor.EditorComponent.SelText
+    begin
+      aFirstLine := fFile.Editor.EditorComponent.BlockBegin.Y;
+      //ALines.Text := fFile.Editor.EditorComponent.SelText;
+      CopyStringList(fFile.Editor.EditorComponent.Lines, ALines,aFirstLine - 1, fFile.Editor.EditorComponent.BlockEnd.Y - 1);
+    end
     else
-      Result := fFile.Editor.EditorComponent.Lines.Text;
+      //ALines.Text := fFile.Editor.EditorComponent.Lines.Text;
+      CopyStringList(fFile.Editor.EditorComponent.Lines, ALines);
   end;
 end;
 
@@ -269,18 +1006,27 @@ constructor TDiffDlg.Create(TheOwner: TComponent);
 begin
   inherited Create(TheOwner);
   fUpdating := False;
-  fCancelled := False;
   fSelectedFile1 := TSelectedDiffFile.Create(Self, Text1Combobox, Text1OnlySelectionCheckBox);
   fSelectedFile2 := TSelectedDiffFile.Create(Self, Text2Combobox, Text2OnlySelectionCheckBox);
   Caption := lisCaptionCompareFiles;
   IDEDialogLayoutList.ApplyLayout(Self,600,500);
   SetupComponents;
+  fDiff := TDiff.Create(nil);
+  fLeftLines:=TStringList.Create;
+  fRightLines:=TStringList.Create;
+  fLeftTextHashes:= TCardinalList.Create;
+  fRightTextHashes:= TCardinalList.Create;
 end;
 
 destructor TDiffDlg.Destroy;
 begin
   fSelectedFile2.Free;
   fSelectedFile1.Free;
+  fDiff.Free;
+  fLeftLines.Free;
+  fRightLines.Free;
+  fLeftTextHashes.Free;
+  fRightTextHashes.Free;
   inherited Destroy;
 end;
 
@@ -289,6 +1035,63 @@ begin
   UpdateDiff;
 end;
 
+
+function MyShowDot(Sender: TSynGutterLineNumber;AEditor:TSynEdit;ALine:integer):boolean;
+begin
+  result := ((ALine mod Sender.ShowOnlyLineNumbersMultiplesOf) <> 0)
+    and (ALine <> AEditor.CaretY) and (ALine <> 1)
+    and (ALine <> AEditor.Lines.Count);
+end;
+
+procedure TDiffDlg.LeftSynGutterLineNumber1FormatLineNumber(
+  Sender: TSynGutterLineNumber; ALine: integer; out AText: string;
+  const ALineInfo: TSynEditGutterLineInfo);
+begin
+  if (FDiff.Count > 0) and (aLine > 0) and (aLine <= FDiff.Count) then
+  begin
+    if FDiff.Compares[aLine - 1].Kind = ckAdd then
+    begin
+      aText := '+';
+      Exit;
+    end
+    else
+      aLine := FDiff.Compares[aLine - 1].oldIndex1 + fLeftFirstLineNumber;
+    aText := Sender.FormatLineNumber(aLine, MyShowDot(Sender,edLeft,ALine)); //AlineInfo.ShowDot);
+  end;
+end;
+
+procedure TDiffDlg.RightSynGutterLineNumber1FormatLineNumber(
+  Sender: TSynGutterLineNumber; ALine: integer; out AText: string;
+  const ALineInfo: TSynEditGutterLineInfo);
+begin
+  if (FDiff.Count > 0) and (aLine > 0) and (aLine <= FDiff.Count) then
+  begin
+    if FDiff.Compares[aLine - 1].Kind = ckDelete then
+    begin
+      aText := '-';
+      Exit;
+    end
+    else
+      aLine := FDiff.Compares[aLine - 1].oldIndex2 + fRightFirstLineNumber;
+    aText := Sender.FormatLineNumber(aLine,MyShowDot(Sender,edRight,ALine));  //ALineInfo.ShowDot);
+  end;
+end;
+
+procedure TDiffDlg.tbsCompareResize(Sender: TObject);
+const
+  MARGIN=5;
+  SEPARATION=10;
+var
+  lWidth:integer;
+begin
+  lWidth:= (TTabSheet(Sender).width - MARGIN - MARGIN - SEPARATION ) div 2;
+  edLeft.width:=lWidth;
+  edRight.Left:= edLeft.Left + lWidth + SEPARATION;
+  edRight.Width := lWidth;
+  //center buttons.
+  PanelButtons.Left:=(TTabSheet(Sender).width div 2) - (PanelButtons.width div 2);
+end;
+
 procedure TDiffDlg.FileOpenClick(Sender: TObject);
 begin
   if dlgOpen.Execute then
@@ -310,7 +1113,308 @@ end;
 
 procedure TDiffDlg.CancelScanningButtonClick(Sender: TObject);
 begin
-  fCancelled := True;
+  fDiff.Cancel;
+end;
+
+procedure TDiffDlg.btnCompareClick(Sender: TObject);
+var
+  Text1Src, Text2Src: string;
+  DiffOutput: TDiffOutput;
+  FileNameLeft,FileNameRight:string;
+  Digits:integer;
+const
+  TAB_COMPARE_INDEX=1;
+begin
+  if fUpdating then Exit;
+  fUpdating := True;
+  DiffSynEdit.Lines.Clear;
+  fSelectedFile1.GetLines(fLeftLines,fLeftFirstLineNumber,FileNameLeft);
+  fSelectedFile2.GetLines(fRightLines,fRightFirstLineNumber,FileNameRight);
+  fCurrentOptions:=GetDiffOptions;
+  if (fLeftLines.Count>0) and (fRightLines.Count>0) then
+  begin
+    Text1GroupBox.Enabled := False;
+    Text2GroupBox.Enabled := False;
+    OpenInEditorButton.Enabled := False;
+    CancelScanningButton.Enabled := True;
+    CancelScanningButton.Visible := True;
+    ProgressBar1.Style := pbstMarquee;
+    FillHashList(fLeftTextHashes, fLeftLines, fCurrentOptions);
+    FillHashList(fRightTextHashes, fRightLines, fCurrentOptions);
+    Compare(fDiff, fLeftLines, fRightLines, fLeftTextHashes, fRightTextHashes, edLeft, edRight);
+    if not fDiff.Cancelled then
+    begin
+      MakeUnifiedPatch(fDiff, fLeftLines, fRightLines, DiffSynEdit.Lines, ExtractFileName(FileNameLeft), ExtractFileName(FileNameRight), 0, 0,fLeftFirstLineNumber,fRightFirstLineNumber);
+      //adjust gutter sizes.
+      Digits:=fDiff.Count + fLeftFirstLineNumber;
+      TSynGutterLineNumber(edLeft.Gutter.Parts[1]).DigitCount := length(IntToSTr(Digits));
+      Digits:=fDiff.Count + fRightFirstLineNumber;
+      TSynGutterLineNumber(edRight.Gutter.Parts[1]).DigitCount := length(IntToSTr(Digits));
+      ProgressBar1.Style := pbstNormal;
+      PageControl1.TabIndex := TAB_COMPARE_INDEX;  //compare.
+    end;
+    CancelScanningButton.Visible := False;
+    CancelScanningButton.Enabled := False;
+    OpenInEditorButton.Enabled := True;
+    Text2GroupBox.Enabled := True;
+    Text1GroupBox.Enabled := True;
+  end;
+  fUpdating:=False;
+end;
+
+
+//  *****************    search        ***********************
+procedure DoFind(aEditor:TSynEdit;const aSearchText:string; aOptions:TSynSearchOptions;aForward:boolean);
+var
+  StartPoint:TPoint;
+begin
+  if length(aSearchText)<>0 then
+  begin
+    //Include(aOptions, ssoFindContinue);
+    if aForward then
+      Exclude(aOptions, ssoBackwards)
+    else
+      Include(aOptions, ssoBackwards);
+    if not (ssoFindContinue in aOptions) then
+      StartPoint := Point(1, 1)
+    else
+    begin
+      StartPoint := aEditor.LogicalCaretXY;
+      if ssoBackwards in aOptions then
+      begin
+        if aEditor.SelText=aSearchText then
+          Dec(StartPoint.X,length(aSearchText));
+      end
+      else
+      begin
+        if aEditor.SelText=aSearchText then
+          Inc(StartPoint.X,length(aSearchText));
+      end;
+    end;
+    if aEditor.SearchReplaceEx(aSearchText , '',aOptions, StartPoint) = 0 then
+      ShowMessage(Format(lisUESearchStringNotFound,[aSearchText]));
+  end;
+end;
+
+procedure DoFindDialog(aEditor:TSynEdit;var aSearchText:string; var aSearchOptions:TSynSearchOptions);
+begin
+  LazFindReplaceDialog.FindText:=aSearchText;
+  LazFindReplaceDialog.Options:=aSearchOptions;
+
+  LazFindReplaceDialog.ReplaceWithCheckbox.Checked := False;
+  LazFindReplaceDialog.ReplaceWithCheckboxChange(nil);
+  LazFindReplaceDialog.ReplaceWithCheckbox.Enabled := False;
+
+  if LazFindReplaceDialog.ShowModal = mrOk then
+  begin
+    aSearchText:=LazFindReplaceDialog.FindText;
+    aSearchOptions:=LazFindReplaceDialog.Options;
+    DoFind(aEditor,aSearchText,aSearchOptions,not (ssoBackwards in aSearchOptions));
+  end;
+  LazFindReplaceDialog.ReplaceWithCheckbox.Enabled := True;
+end;
+
+
+procedure TDiffDlg.btnFindRClick(Sender: TObject);
+begin
+  DoFindDialog(edRight,fRightSearchText,fRightSearchOptions);
+end;
+
+procedure TDiffDlg.btnFindNextRClick(Sender: TObject);
+begin
+  DoFind(edRight,fRightSearchText,fRightSearchOptions+[ssoFindContinue], True);
+end;
+
+procedure TDiffDlg.btnFindPreviousRClick(Sender: TObject);
+begin
+  DoFind(edRight,fRightSearchText,fRightSearchOptions+[ssoFindContinue], False);
+end;
+
+procedure TDiffDlg.btnFindLClick(Sender: TObject);
+begin
+  DoFindDialog(edLeft,fLeftSearchText,fLeftSearchOptions);
+end;
+
+procedure TDiffDlg.btnFindNextLClick(Sender: TObject);
+begin
+  DoFind(edLeft,fLeftSearchText,fLeftSearchOptions+[ssoFindContinue], True);
+end;
+
+procedure TDiffDlg.btnFindPreviousLClick(Sender: TObject);
+begin
+  DoFind(edLeft,fLeftSearchText,fLeftSearchOptions+[ssoFindContinue], False);
+end;
+//  **********************************************************
+
+procedure TDiffDlg.btnFirstClick(Sender: TObject);
+begin
+  edLeft.CaretY := 1;
+  if fDiff.Count > 0 then
+  begin
+    if fDiff.Compares[0].Kind = ckNone then
+      btnNextClick(Self);
+  end;
+end;
+
+procedure TDiffDlg.btnLastClick(Sender: TObject);
+var
+  Idx: integer;
+begin
+  Idx := edLeft.Lines.Count - 1;
+  edLeft.CaretY := Idx + 1;
+  if fDiff.Count >= Idx then
+  begin
+    if fDiff.Compares[Idx].Kind = ckNone then
+      btnpreviousClick(Self);
+  end;
+end;
+
+// normalize kind type if we ignore blank line aditions or deletions
+function TDiffDlg.GetNomalizedKindType(aLineIndex:integer):TChangeKind;
+begin
+  result:=fDiff.Compares[aLineIndex - 1].Kind;
+  if tdfIgnoreEmptyLineChanges in fCurrentOptions then
+  begin
+    if result=ckAdd then
+    begin
+      if fDiff.Compares[aLineIndex-1].int2 = EMPTY_LINE_HASH  then
+        result:=ckNone;
+    end
+    else if result=ckDelete then
+    begin
+      if fDiff.Compares[aLineIndex-1].int1 = EMPTY_LINE_HASH  then
+        result:=ckNone;
+    end;
+  end;
+end;
+
+procedure TDiffDlg.btnNextClick(Sender: TObject);
+var
+  LineIndex: integer;
+  Kind, KindTest: TChangeKind;
+begin
+  LineIndex := edLeft.CaretY;
+  if (LineIndex > fDiff.Count) or (LineIndex < 1) then
+    Exit;
+  Kind := GetNomalizedKindType(LineIndex);
+  Inc(LineIndex);
+  if LineIndex > fDiff.Count then
+    Exit;
+  while LineIndex < fDiff.Count do
+  begin
+    KindTest := GetNomalizedKindType(LineIndex);
+    if KindTest <> Kind then
+    begin
+      if KindTest <> ckNone then
+      begin
+        edLeft.CaretY := LineIndex;
+        break;
+      end;
+      Kind := ckNone;
+    end;
+    Inc(LineIndex);
+  end;
+end;
+
+procedure TDiffDlg.btnpreviousClick(Sender: TObject);
+var
+  LineIndex: integer;
+  Kind, KindTest: TChangeKind;
+begin
+  LineIndex := edLeft.CaretY;
+  if (LineIndex > fDiff.Count) or (LineIndex < 1) then
+    Exit;
+  Kind := GetNomalizedKindType(LineIndex);
+  Dec(LineIndex);
+  if LineIndex < 1 then
+    Exit;
+  while LineIndex >= 1 do
+  begin
+    KindTest := GetNomalizedKindType(LineIndex);
+    if KindTest <> Kind then
+    begin
+      if KindTest <> ckNone then
+      begin
+        edLeft.CaretY := LineIndex;
+        break;
+      end;
+      Kind := ckNone;
+    end;
+    Dec(LineIndex);
+  end;
+end;
+
+procedure TDiffDlg.edSpecialLineColors(Sender: TObject; Line: integer; var Special: boolean; var FG, BG: TColor);
+var
+  r, g, b: byte;
+const
+  COLOR_ADDED_LINE = $ffdddd;
+  COLOR_ADDED_EMPTY_LINE = $fff5f5;
+  COLOR_DELETED_LINE = $ddddff;
+  COLOR_DELETED_EMPTY_LINE = $f5f5ff;
+  COLOR_MODIFIED_LINE = $ddffdd;
+  DARKNESS = $a;
+begin
+
+  if (fDiff.Count > 0) and (Line > 0) and (Line <= fDiff.Count) then
+  begin
+    case fDiff.Compares[Line - 1].Kind of
+      //ckNone:
+      //  BG := clWhite;
+      ckAdd:
+      begin
+        BG := COLOR_ADDED_LINE;
+        if (tdfIgnoreEmptyLineChanges in fCurrentOptions) and (fDiff.Compares[Line - 1].int2 = EMPTY_LINE_HASH) then
+        begin
+          BG := COLOR_ADDED_EMPTY_LINE;
+        end;
+      end;
+      ckDelete:
+      begin
+        BG := COLOR_DELETED_LINE;
+        // if (tdfIgnoreEmptyLineChanges in fCurrentOptions) and (edLeft.Lines[fDiff.Compares[Line-1].oldIndex1]='') then
+        if (tdfIgnoreEmptyLineChanges in fCurrentOptions) and (fDiff.Compares[Line - 1].int1 = EMPTY_LINE_HASH) then
+        begin
+          BG := COLOR_DELETED_EMPTY_LINE;
+        end;
+      end;
+      ckModify:
+        BG := COLOR_MODIFIED_LINE;
+    end;
+  end;
+  if Line = TSynEdit(Sender).CaretY then  //current line.
+  begin
+    r := Red(BG) - DARKNESS;
+    g := Green(BG) - DARKNESS;
+    b := Blue(BG) - DARKNESS;
+    BG := RGB(r, g, b);
+  end;
+  Special := True;
+end;
+
+procedure Syncronize(Changes: TSynStatusChanges; aMaster: TSynEdit; aSlave: TSynEdit);
+begin
+  if scTopLine in Changes then
+    aSlave.TopLine := aMaster.TopLine;
+  if scLeftChar in Changes then
+    aSlave.LeftChar := aMaster.LeftChar;
+  if scCaretY in Changes then
+  begin
+    if aSlave.CaretY <> aMaster.CaretY then    // if then to allow text selection.
+      aSlave.CaretY := aMaster.CaretY;
+  end;
+end;
+
+procedure TDiffDlg.edLeftStatusChange(Sender: TObject;
+  Changes: TSynStatusChanges);
+begin
+  Syncronize(Changes, edLeft, edRight);
+end;
+
+procedure TDiffDlg.edRightStatusChange(Sender: TObject;
+  Changes: TSynStatusChanges);
+begin
+  Syncronize(Changes, edRight, edLeft);
 end;
 
 procedure TDiffDlg.HelpButtonClick(Sender: TObject);
@@ -362,7 +1466,6 @@ begin
   OpenInEditorButton.LoadGlyphFromStock(idButtonOpen);
   if OpenInEditorButton.Glyph.Empty then
     IDEImages.AssignImage(OpenInEditorButton, 'laz_open');
-  
   // dialogs
   dlgOpen.Title:=lisOpenExistingFile;
   dlgOpen.Filter:=dlgFilterAll+' ('+GetAllFilesMask+')|'+GetAllFilesMask
@@ -371,65 +1474,36 @@ begin
                  +'|'+dlgFilterLazarusForm+' (*.lfm;*.dfm)|*.lfm;*.dfm'
                  +'|'+dlgFilterLazarusPackage+' (*.lpk)|*.lpk'
                  +'|'+dlgFilterLazarusProjectSource+' (*.lpr)|*.lpr';
-
+  //tabsheets
+  tbsOptions.Caption:=lisDiffTabOptions;
+  tbsCompare.Caption:=lisDiffTabCompare;
+  tbsPatch.Caption:=lisDiffTabPatch;
+
+  //buttons
+  btnCompare.Caption:=lisDiffBtnCompare;
+  btnFirst.Caption:=lisDiffBtnFirst;
+  btnLast.Caption:=lisDiffBtnLast;
+  btnNext.Caption:=lisDiffBtnNext;
+  btnprevious.Caption:=lisDiffBtnprevious;
   // diff
   EditorOpts.GetSynEditSettings(DiffSynEdit);
-end;
-
-procedure TDiffDlg.UpdateDiff;
-begin
-  IdleConnected:=True;
-end;
-
-procedure TDiffDlg.UpdateProgress(aPosition: Integer);
-begin
-  ProgressBar1.Position := aPosition;
-  Application.ProcessMessages;
-end;
 
-procedure TDiffDlg.SetIdleConnected(const AValue: boolean);
-begin
-  if fIdleConnected=AValue then exit;
-  fIdleConnected:=AValue;
-  if fIdleConnected then
-    Application.AddOnIdleHandler(@OnIdle)
-  else
-    Application.RemoveOnIdleHandler(@OnIdle);
+  SourceEditorManagerIntf.GetEditorControlSettings(edLeft);
+  SourceEditorManagerIntf.GetEditorControlSettings(edRight);
+  // code folding not allowed.
+  edLeft.Gutter.Parts[4].Visible:=false;
+  edRight.Gutter.Parts[4].Visible:=false;
+  SourceEditorManagerIntf.GetHighlighterSettings(SynFreePascalSyn1);
+  IDEImages.AssignImage(btnFindL, 'menu_search_find');
+  IDEImages.AssignImage(btnFindR, 'menu_search_find');
+  IDEImages.AssignImage(btnFindPreviousL, 'menu_search_find_previous');
+  IDEImages.AssignImage(btnFindPreviousR, 'menu_search_find_previous');
+  IDEImages.AssignImage(btnFindNextL, 'menu_search_find_next');
+  IDEImages.AssignImage(btnFindNextR, 'menu_search_find_next');
 end;
 
-procedure TDiffDlg.OnIdle(Sender: TObject; var Done: Boolean);
-var
-  Text1Src, Text2Src: string;
-  DiffOutput: TDiffOutput;
+procedure TDiffDlg.UpdateDiff;
 begin
-  IdleConnected := false;
-  if fUpdating then Exit;
-  fUpdating := True;
-  DiffSynEdit.Lines.Text := '';
-  Text1Src := fSelectedFile1.TextContents;
-  Text2Src := fSelectedFile2.TextContents;
-  if (Text1Src <> '') and (Text2Src <> '') then
-  begin
-    Text1GroupBox.Enabled := False;
-    Text2GroupBox.Enabled := False;
-    OpenInEditorButton.Enabled := False;
-    //CancelScanningButton.Enabled := True;
-
-    DiffOutput := TDiffOutput.Create(Text1Src, Text2Src, GetDiffOptions);
-    try
-      ProgressBar1.Max := DiffOutput.GetProgressMax;
-      DiffOutput.OnProgressPos := @UpdateProgress;
-      DiffSynEdit.Lines.Text := DiffOutput.CreateTextDiff;
-    finally
-      DiffOutput.Free;
-    end;
-
-    //CancelScanningButton.Enabled := False;
-    OpenInEditorButton.Enabled := True;
-    Text2GroupBox.Enabled := True;
-    Text1GroupBox.Enabled := True;
-  end;
-  fUpdating:=False;
 end;
 
 procedure TDiffDlg.Init;
@@ -452,8 +1526,6 @@ begin
   // set recent options
   SetDiffOptions(InputHistories.DiffFlags);
 
-  // and action ...
-  UpdateDiff;
 end;
 
 procedure TDiffDlg.FillTextComboBoxes;
@@ -479,6 +1551,8 @@ procedure TDiffDlg.FormCreate(Sender: TObject);
 begin
   Text1Combobox.DropDownCount:=EnvironmentOptions.DropDownCount;
   Text2Combobox.DropDownCount:=EnvironmentOptions.DropDownCount;
+  fCurrentOptions:=GetDiffOptions;
+  PageControl1.TabIndex := 0;
 end;
 
 procedure TDiffDlg.SaveSettings;
diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas
index c1d8c4b64a..a980a6dcb2 100644
--- a/ide/lazarusidestrconsts.pas
+++ b/ide/lazarusidestrconsts.pas
@@ -3909,6 +3909,16 @@ resourcestring
   lisDiffDlgIgnoreSpaces = 'Ignore spaces (newline chars not included)';
   lisDiffDlgOpenDiffInEditor = 'Open difference in editor';
 
+  lisDiffTabOptions = 'Options';
+  lisDiffTabCompare = 'Compare';
+  lisDiffTabPatch = 'Patch';
+  lisDiffBtnCompare = 'Compare';
+  lisDiffBtnFirst = 'First';
+  lisDiffBtnLast = 'Last';
+  lisDiffBtnNext = 'Next';
+  lisDiffBtnPrevious = 'Previous';
+
+
   // packages
   lisPkgFileTypeVirtualUnit = 'Virtual Unit';
   lisPkgFileTypeMainUnit = 'Main Unit';
-- 
2.30.0.windows.1

BetterFileCompareTool.patch (134,115 bytes)   

Juha Manninen

2021-02-22 00:01

developer   ~0129079

Last edited: 2021-02-22 00:04

View 3 revisions

> Although the patch compiles and links without errors, it is not finished yet.

Yes, refactoring is needed. This whole compare tool should be a package itself.
I remember years ago I tried to separate the current Tools -> Compare Files ... feature to a package. Unit DiffPatch is used elsewhere in the IDE and I stopped.
Maybe DiffPatch could be replaced with another unit also elsewhere. Don't know.

Domingo, this should be developed in a branch under revision control. Keeping track of big refactoring patches is cumbersome.
Are you familiar with Git? Martin has a Lazarus mirror in GitHub. You could fork it. I and anybody interested could follow it then.

Domingo Galmés

2021-02-24 00:03

reporter   ~0129130

I'm familiar with Git, I forked the Martin mirror.
I will try to convert in a package, but its dificult remove all dependencies of IDE units.
In few days i will commit changes in a new branch "DiffCompareTool".

the url is.
https://github.com/DomingoGP/lazarus

Issue History

Date Modified Username Field Change
2021-02-21 22:31 Domingo Galmés New Issue
2021-02-21 22:31 Domingo Galmés File Added: lazarus_ERMyayxXj8.png
2021-02-21 22:31 Domingo Galmés File Added: BetterFileCompareTool.patch
2021-02-22 00:01 Juha Manninen Note Added: 0129079
2021-02-22 00:02 Juha Manninen Note Edited: 0129079 View Revisions
2021-02-22 00:04 Juha Manninen Note Edited: 0129079 View Revisions
2021-02-24 00:03 Domingo Galmés Note Added: 0129130