mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Go to first/last difference
This commit is contained in:
parent
6da1713fd0
commit
9f73c4e7df
2 changed files with 51 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
object frmDiffer: TfrmDiffer
|
||||
Left = 110
|
||||
Left = 282
|
||||
Height = 379
|
||||
Top = 120
|
||||
Top = 83
|
||||
Width = 760
|
||||
Caption = 'Compare files'
|
||||
ClientHeight = 359
|
||||
|
|
@ -380,6 +380,7 @@ object frmDiffer: TfrmDiffer
|
|||
object actLastDiff: TAction
|
||||
Caption = 'Last Difference'
|
||||
ImageIndex = 3
|
||||
OnExecute = actLastDiffExecute
|
||||
end
|
||||
object actNextDiff: TAction
|
||||
Caption = 'Next Difference'
|
||||
|
|
@ -394,6 +395,7 @@ object frmDiffer: TfrmDiffer
|
|||
object actFirstDiff: TAction
|
||||
Caption = 'First Difference'
|
||||
ImageIndex = 6
|
||||
OnExecute = actFirstDiffExecute
|
||||
end
|
||||
object actIgnoreCase: TAction
|
||||
AutoCheck = True
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ type
|
|||
btnCancelCompare: TToolButton;
|
||||
Divider4: TToolButton;
|
||||
procedure actBinaryCompareExecute(Sender: TObject);
|
||||
procedure actFirstDiffExecute(Sender: TObject);
|
||||
procedure actLastDiffExecute(Sender: TObject);
|
||||
procedure actNextDiffExecute(Sender: TObject);
|
||||
procedure actPrevDiffExecute(Sender: TObject);
|
||||
procedure actStartCompareExecute(Sender: TObject);
|
||||
|
|
@ -270,6 +272,51 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.actFirstDiffExecute(Sender: TObject);
|
||||
var
|
||||
Line: Integer;
|
||||
Kind: TChangeKind;
|
||||
begin
|
||||
// Start at first line
|
||||
Line := 0;
|
||||
if Line = SynDiffEditLeft.Lines.Count then Exit;
|
||||
// Skip unmodified lines
|
||||
Kind := ckNone;
|
||||
while (Line < SynDiffEditLeft.Lines.Count - 1) and
|
||||
(SynDiffEditLeft.DiffKind[Line] = Kind) do Inc(Line);
|
||||
Inc(Line);
|
||||
SynDiffEditLeft.CaretY := Line;
|
||||
SynDiffEditLeft.TopLine := Line;
|
||||
if not actKeepScrolling.Checked then
|
||||
begin
|
||||
SynDiffEditRight.CaretY := Line;
|
||||
SynDiffEditRight.TopLine := Line;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.actLastDiffExecute(Sender: TObject);
|
||||
var
|
||||
Line: Integer;
|
||||
Kind: TChangeKind;
|
||||
begin
|
||||
Line := SynDiffEditLeft.Lines.Count - 1;
|
||||
if Line = 0 then Exit;
|
||||
// Skip unmodified lines
|
||||
Kind := ckNone;
|
||||
while (Line > 0) and (SynDiffEditLeft.DiffKind[Line] = Kind) do Dec(Line);
|
||||
// Find top line of previous difference
|
||||
Kind:= SynDiffEditLeft.DiffKind[Line];
|
||||
while (Line > 0) and (SynDiffEditLeft.DiffKind[Line] = Kind) do Dec(Line);
|
||||
if (Line <> 0) then Inc(Line, 2);
|
||||
SynDiffEditLeft.CaretY := Line;
|
||||
SynDiffEditLeft.TopLine := Line;
|
||||
if not actKeepScrolling.Checked then
|
||||
begin
|
||||
SynDiffEditRight.CaretY := Line;
|
||||
SynDiffEditRight.TopLine := Line;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.actKeepScrollingExecute(Sender: TObject);
|
||||
begin
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue