mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: [Differ] Paint background option
This commit is contained in:
parent
9f73c4e7df
commit
3264c324e4
4 changed files with 79 additions and 12 deletions
|
|
@ -1,7 +1,7 @@
|
|||
object frmDiffer: TfrmDiffer
|
||||
Left = 282
|
||||
Left = 402
|
||||
Height = 379
|
||||
Top = 83
|
||||
Top = 82
|
||||
Width = 760
|
||||
Caption = 'Compare files'
|
||||
ClientHeight = 359
|
||||
|
|
@ -314,6 +314,14 @@ object frmDiffer: TfrmDiffer
|
|||
Action = actIgnoreCase
|
||||
AutoCheck = True
|
||||
end
|
||||
object miDivider4: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
object miPaintBackground: TMenuItem
|
||||
Action = actPaintBackground
|
||||
AutoCheck = True
|
||||
OnClick = actPaintBackgroundExecute
|
||||
end
|
||||
object miDivider3: TMenuItem
|
||||
Caption = '-'
|
||||
end
|
||||
|
|
@ -354,9 +362,11 @@ object frmDiffer: TfrmDiffer
|
|||
end
|
||||
object miFirstDiff: TMenuItem
|
||||
Action = actFirstDiff
|
||||
OnClick = actFirstDiffExecute
|
||||
end
|
||||
object miLastDiff: TMenuItem
|
||||
Action = actLastDiff
|
||||
OnClick = actLastDiffExecute
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -420,6 +430,12 @@ object frmDiffer: TfrmDiffer
|
|||
Caption = 'Binary'
|
||||
OnExecute = actBinaryCompareExecute
|
||||
end
|
||||
object actPaintBackground: TAction
|
||||
AutoCheck = True
|
||||
Caption = 'Paint Background'
|
||||
Checked = True
|
||||
OnExecute = actPaintBackgroundExecute
|
||||
end
|
||||
end
|
||||
object ImageList: TImageList
|
||||
Height = 22
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ TFRMDIFFER.MNUFILE.CAPTION=File
|
|||
TFRMDIFFER.MISAVE.CAPTION=Save
|
||||
TFRMDIFFER.MNUEDIT.CAPTION=Edit
|
||||
TFRMDIFFER.MNUOPTIONS.CAPTION=&Options
|
||||
TFRMDIFFER.MIDIVIDER4.CAPTION=-
|
||||
TFRMDIFFER.MIDIVIDER3.CAPTION=-
|
||||
TFRMDIFFER.MIKEEPSCROLLING.CAPTION=Keep Scrolling
|
||||
TFRMDIFFER.MNUACTIONS.CAPTION=&Actions
|
||||
|
|
@ -20,3 +21,4 @@ TFRMDIFFER.ACTIGNOREWHITESPACE.CAPTION=Ignore Blanks
|
|||
TFRMDIFFER.ACTKEEPSCROLLING.CAPTION=actKeepScrolling
|
||||
TFRMDIFFER.ACTCANCELCOMPARE.CAPTION=Cancel
|
||||
TFRMDIFFER.ACTBINARYCOMPARE.CAPTION=Binary
|
||||
TFRMDIFFER.ACTPAINTBACKGROUND.CAPTION=Paint Background
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ type
|
|||
|
||||
TfrmDiffer = class(TForm)
|
||||
actBinaryCompare: TAction;
|
||||
actPaintBackground: TAction;
|
||||
actStartCompare: TAction;
|
||||
actFirstDiff: TAction;
|
||||
actIgnoreCase: TAction;
|
||||
|
|
@ -31,6 +32,8 @@ type
|
|||
edtFileNameRight: TFileNameEdit;
|
||||
ImageList: TImageList;
|
||||
MainMenu: TMainMenu;
|
||||
miPaintBackground: TMenuItem;
|
||||
miDivider4: TMenuItem;
|
||||
miBinaryCompare: TMenuItem;
|
||||
miKeepScrolling: TMenuItem;
|
||||
miDivider3: TMenuItem;
|
||||
|
|
@ -74,6 +77,7 @@ type
|
|||
procedure actFirstDiffExecute(Sender: TObject);
|
||||
procedure actLastDiffExecute(Sender: TObject);
|
||||
procedure actNextDiffExecute(Sender: TObject);
|
||||
procedure actPaintBackgroundExecute(Sender: TObject);
|
||||
procedure actPrevDiffExecute(Sender: TObject);
|
||||
procedure actStartCompareExecute(Sender: TObject);
|
||||
procedure actKeepScrollingExecute(Sender: TObject);
|
||||
|
|
@ -229,6 +233,20 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.actPaintBackgroundExecute(Sender: TObject);
|
||||
begin
|
||||
if actPaintBackground.Checked then
|
||||
begin
|
||||
SynDiffEditLeft.PaintStyle:= psBackground;
|
||||
SynDiffEditRight.PaintStyle:= psBackground;
|
||||
end
|
||||
else
|
||||
begin
|
||||
SynDiffEditLeft.PaintStyle:= psForeground;
|
||||
SynDiffEditRight.PaintStyle:= psForeground;
|
||||
end
|
||||
end;
|
||||
|
||||
procedure TfrmDiffer.actPrevDiffExecute(Sender: TObject);
|
||||
var
|
||||
Line: Integer;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ const
|
|||
clPaleRed : TColor = $AAAAFF;
|
||||
clPaleBlue : TColor = $FFAAAA;
|
||||
|
||||
type
|
||||
TPaintStyle = (psForeground, psBackground);
|
||||
|
||||
type
|
||||
|
||||
{ TSynDiffGutterLineNumber }
|
||||
|
|
@ -71,12 +74,14 @@ type
|
|||
|
||||
TSynDiffEdit = class(TCustomSynEdit)
|
||||
private
|
||||
FPaintStyle: TPaintStyle;
|
||||
FDiff: TDiff;
|
||||
FSpecialLineMarkupEvent: TSpecialLineMarkupEvent;
|
||||
FDiffCount: Integer;
|
||||
private
|
||||
function GetDiffCount: Integer;
|
||||
function GetDiffKind(Index: Integer): TChangeKind;
|
||||
procedure SetPaintStyle(const AValue: TPaintStyle);
|
||||
protected
|
||||
procedure SpecialLineMarkupEvent(Sender: TObject; Line: Integer;
|
||||
var Special: boolean; AMarkup: TSynSelectedColor);
|
||||
|
|
@ -84,6 +89,7 @@ type
|
|||
constructor Create(AOwner: TComponent); override;
|
||||
procedure BeginCompare(ADiff: TDiff);
|
||||
procedure EndCompare(ADiffCount: Integer);
|
||||
property PaintStyle: TPaintStyle read FPaintStyle write SetPaintStyle;
|
||||
property Diff: TDiff read FDiff write FDiff;
|
||||
property DiffKind[Index: Integer]: TChangeKind read GetDiffKind;
|
||||
property DiffCount: Integer read GetDiffCount;
|
||||
|
|
@ -119,20 +125,45 @@ begin
|
|||
end;
|
||||
end;
|
||||
|
||||
procedure TSynDiffEdit.SetPaintStyle(const AValue: TPaintStyle);
|
||||
begin
|
||||
if FPaintStyle <> AValue then
|
||||
begin
|
||||
FPaintStyle := AValue;
|
||||
Invalidate;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynDiffEdit.SpecialLineMarkupEvent(Sender: TObject; Line: Integer;
|
||||
var Special: boolean; AMarkup: TSynSelectedColor);
|
||||
var
|
||||
Kind: TChangeKind;
|
||||
LineColor: TColor;
|
||||
begin
|
||||
AMarkup.Foreground:= clWindowText;
|
||||
Special:= (DiffCount <> 0);
|
||||
if Line >= DiffCount then Exit;
|
||||
|
||||
if Special and (Line < DiffCount) then
|
||||
with AMarkup do
|
||||
case DiffKind[Line-1] of
|
||||
ckNone: Background := clWhite;
|
||||
ckModify: Background := clPaleBlue;
|
||||
ckDelete: Background := clPaleRed;
|
||||
ckAdd: Background := clPaleGreen;
|
||||
Kind:= DiffKind[Line - 1];
|
||||
Special:= (Kind <> ckNone);
|
||||
|
||||
if Special then
|
||||
with AMarkup do
|
||||
begin
|
||||
case Kind of
|
||||
ckModify: LineColor := clPaleBlue;
|
||||
ckDelete: LineColor := clPaleRed;
|
||||
ckAdd: LineColor := clPaleGreen;
|
||||
end;
|
||||
if FPaintStyle = psForeground then
|
||||
begin
|
||||
Foreground := LineColor;
|
||||
Background := clWindow;
|
||||
end
|
||||
else
|
||||
begin
|
||||
Foreground:= clWindowText;
|
||||
Background := LineColor;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSynDiffEdit.BeginCompare(ADiff: TDiff);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue