Diff tool: remove Save button, change "Diff" to "Compare files", try to prevent people creating invalid patches with it.

git-svn-id: trunk@46027 -
This commit is contained in:
juha 2014-08-10 14:05:17 +00:00
parent 4a1e95898b
commit 30cd69fe8f
5 changed files with 137 additions and 272 deletions

View File

@ -5,16 +5,16 @@ object DiffDlg: TDiffDlg
Width = 598 Width = 598
HelpType = htKeyword HelpType = htKeyword
BorderIcons = [biSystemMenu] BorderIcons = [biSystemMenu]
Caption = 'Diff dialog' Caption = 'Compare files'
ClientHeight = 522 ClientHeight = 522
ClientWidth = 598 ClientWidth = 598
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '0.9.31' LCLVersion = '1.3'
object Text1GroupBox: TGroupBox object Text1GroupBox: TGroupBox
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner AnchorSideTop.Control = Owner
Left = 6 Left = 6
Height = 53 Height = 57
Top = 6 Top = 6
Width = 586 Width = 586
Align = alTop Align = alTop
@ -22,7 +22,7 @@ object DiffDlg: TDiffDlg
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Text1GroupBox' Caption = 'Text1GroupBox'
ClientHeight = 36 ClientHeight = 38
ClientWidth = 582 ClientWidth = 582
TabOrder = 0 TabOrder = 0
object Text1Combobox: TComboBox object Text1Combobox: TComboBox
@ -30,9 +30,9 @@ object DiffDlg: TDiffDlg
AnchorSideTop.Control = Text1GroupBox AnchorSideTop.Control = Text1GroupBox
AnchorSideRight.Control = Text1FileOpenButton AnchorSideRight.Control = Text1FileOpenButton
Left = 6 Left = 6
Height = 23 Height = 25
Top = 6 Top = 6
Width = 316 Width = 320
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -47,10 +47,10 @@ object DiffDlg: TDiffDlg
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Text1GroupBox AnchorSideRight.Control = Text1GroupBox
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 372 Left = 376
Height = 26 Height = 21
Top = 4 Top = 8
Width = 204 Width = 200
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 6 BorderSpacing.Right = 6
@ -64,8 +64,8 @@ object DiffDlg: TDiffDlg
AnchorSideRight.Control = Text1OnlySelectionCheckBox AnchorSideRight.Control = Text1OnlySelectionCheckBox
AnchorSideBottom.Control = Text1Combobox AnchorSideBottom.Control = Text1Combobox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 328 Left = 332
Height = 23 Height = 25
Top = 6 Top = 6
Width = 32 Width = 32
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
@ -78,14 +78,14 @@ object DiffDlg: TDiffDlg
object Text2GroupBox: TGroupBox object Text2GroupBox: TGroupBox
AnchorSideTop.Control = Text1GroupBox AnchorSideTop.Control = Text1GroupBox
Left = 6 Left = 6
Height = 53 Height = 57
Top = 65 Top = 69
Width = 586 Width = 586
Align = alTop Align = alTop
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Text2GroupBox' Caption = 'Text2GroupBox'
ClientHeight = 36 ClientHeight = 38
ClientWidth = 582 ClientWidth = 582
TabOrder = 1 TabOrder = 1
object Text2Combobox: TComboBox object Text2Combobox: TComboBox
@ -93,9 +93,9 @@ object DiffDlg: TDiffDlg
AnchorSideTop.Control = Text2GroupBox AnchorSideTop.Control = Text2GroupBox
AnchorSideRight.Control = Text2FileOpenButton AnchorSideRight.Control = Text2FileOpenButton
Left = 6 Left = 6
Height = 23 Height = 25
Top = 6 Top = 6
Width = 316 Width = 320
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -110,10 +110,10 @@ object DiffDlg: TDiffDlg
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Text2GroupBox AnchorSideRight.Control = Text2GroupBox
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 372 Left = 376
Height = 26 Height = 21
Top = 4 Top = 8
Width = 204 Width = 200
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 6 BorderSpacing.Top = 6
BorderSpacing.Right = 6 BorderSpacing.Right = 6
@ -127,8 +127,8 @@ object DiffDlg: TDiffDlg
AnchorSideRight.Control = Text2OnlySelectionCheckBox AnchorSideRight.Control = Text2OnlySelectionCheckBox
AnchorSideBottom.Control = Text2Combobox AnchorSideBottom.Control = Text2Combobox
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 328 Left = 332
Height = 23 Height = 25
Top = 6 Top = 6
Width = 32 Width = 32
Anchors = [akTop, akRight, akBottom] Anchors = [akTop, akRight, akBottom]
@ -147,7 +147,7 @@ object DiffDlg: TDiffDlg
AnchorSideBottom.Control = ProgressBar1 AnchorSideBottom.Control = ProgressBar1
Left = 6 Left = 6
Height = 109 Height = 109
Top = 345 Top = 344
Width = 586 Width = 586
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
AutoFill = True AutoFill = True
@ -170,8 +170,8 @@ object DiffDlg: TDiffDlg
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideBottom.Control = OptionsGroupBox AnchorSideBottom.Control = OptionsGroupBox
Left = 6 Left = 6
Height = 215 Height = 206
Top = 124 Top = 132
Width = 586 Width = 586
Align = alTop Align = alTop
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -189,50 +189,24 @@ object DiffDlg: TDiffDlg
Gutter.Width = 55 Gutter.Width = 55
Gutter.MouseActions = < Gutter.MouseActions = <
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 13 Command = emcOnMainGutterClick
MoveCaret = False
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbRight Button = mbRight
ClickCount = ccSingle Command = emcContextMenu
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end> end>
RightGutter.Width = 0 RightGutter.Width = 0
RightGutter.MouseActions = < RightGutter.MouseActions = <
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 13 Command = emcOnMainGutterClick
MoveCaret = False
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbRight Button = mbRight
ClickCount = ccSingle Command = emcContextMenu
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end> end>
Highlighter = SynDiffSyn1 Highlighter = SynDiffSyn1
Keystrokes = < Keystrokes = <
@ -558,141 +532,113 @@ object DiffDlg: TDiffDlg
end> end>
MouseActions = < MouseActions = <
item item
Shift = []
ShiftMask = [ssShift, ssAlt] ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown ClickDir = cdDown
Command = 1 Command = emcStartSelections
MoveCaret = True MoveCaret = True
Option = 0
Priority = 0
end end
item item
Shift = [ssShift] Shift = [ssShift]
ShiftMask = [ssShift, ssAlt] ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown ClickDir = cdDown
Command = 1 Command = emcStartSelections
MoveCaret = True MoveCaret = True
Option = 1 Option = 1
Priority = 0
end end
item item
Shift = [ssAlt] Shift = [ssAlt]
ShiftMask = [ssShift, ssAlt] ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown ClickDir = cdDown
Command = 3 Command = emcStartColumnSelections
MoveCaret = True MoveCaret = True
Option = 0
Priority = 0
end end
item item
Shift = [ssShift, ssAlt] Shift = [ssShift, ssAlt]
ShiftMask = [ssShift, ssAlt] ShiftMask = [ssShift, ssAlt]
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown ClickDir = cdDown
Command = 3 Command = emcStartColumnSelections
MoveCaret = True MoveCaret = True
Option = 1 Option = 1
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbRight Button = mbRight
ClickCount = ccSingle Command = emcContextMenu
ClickDir = cdUp
Command = 12
MoveCaret = False
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccDouble ClickCount = ccDouble
ClickDir = cdDown ClickDir = cdDown
Command = 6 Command = emcSelectWord
MoveCaret = True MoveCaret = True
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccTriple ClickCount = ccTriple
ClickDir = cdDown ClickDir = cdDown
Command = 7 Command = emcSelectLine
MoveCaret = True MoveCaret = True
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccQuad ClickCount = ccQuad
ClickDir = cdDown ClickDir = cdDown
Command = 8 Command = emcSelectPara
MoveCaret = True MoveCaret = True
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbMiddle Button = mbMiddle
ClickCount = ccSingle
ClickDir = cdDown ClickDir = cdDown
Command = 10 Command = emcPasteSelection
MoveCaret = True MoveCaret = True
Option = 0
Priority = 0
end end
item item
Shift = [ssCtrl] Shift = [ssCtrl]
ShiftMask = [ssShift, ssAlt, ssCtrl] ShiftMask = [ssShift, ssAlt, ssCtrl]
Button = mbLeft Command = emcMouseLink
ClickCount = ccSingle
ClickDir = cdUp
Command = 11
MoveCaret = False
Option = 0
Priority = 0
end> end>
MouseTextActions = <>
MouseSelActions = < MouseSelActions = <
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccSingle
ClickDir = cdDown ClickDir = cdDown
Command = 9 Command = emcStartDragMove
MoveCaret = False
Option = 0
Priority = 0
end> end>
Lines.Strings = ( Lines.Strings = (
'DiffSynEdit' 'DiffSynEdit'
) )
VisibleSpecialChars = [vscSpace, vscTabAtLast] VisibleSpecialChars = [vscSpace, vscTabAtLast]
SelectedColor.FrameEdges = sfeAround
SelectedColor.BackPriority = 50
SelectedColor.ForePriority = 50
SelectedColor.FramePriority = 50
SelectedColor.BoldPriority = 50
SelectedColor.ItalicPriority = 50
SelectedColor.UnderlinePriority = 50
SelectedColor.StrikeOutPriority = 50
IncrementColor.FrameEdges = sfeAround
HighlightAllColor.FrameEdges = sfeAround
BracketHighlightStyle = sbhsBoth BracketHighlightStyle = sbhsBoth
BracketMatchColor.Background = clNone
BracketMatchColor.Foreground = clNone
BracketMatchColor.FrameEdges = sfeAround
BracketMatchColor.Style = [fsBold]
FoldedCodeColor.Background = clNone
FoldedCodeColor.Foreground = clGray
FoldedCodeColor.FrameColor = clGray
FoldedCodeColor.FrameEdges = sfeAround
MouseLinkColor.Background = clNone
MouseLinkColor.Foreground = clBlue
MouseLinkColor.FrameEdges = sfeAround
LineHighlightColor.Background = clNone
LineHighlightColor.Foreground = clNone
LineHighlightColor.FrameEdges = sfeAround
inline TSynGutterPartList inline TSynGutterPartList
object TSynGutterMarks object TSynGutterMarks
Width = 24 Width = 24
MouseActions = <>
end end
object TSynGutterLineNumber object TSynGutterLineNumber
Width = 15 Width = 15
MouseActions = <> MouseActions = <>
MarkupInfo.Background = clBtnFace MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone MarkupInfo.Foreground = clNone
MarkupInfo.FrameEdges = sfeAround
DigitCount = 2 DigitCount = 2
ShowOnlyLineNumbersMultiplesOf = 1 ShowOnlyLineNumbersMultiplesOf = 1
ZeroStart = False ZeroStart = False
@ -700,35 +646,29 @@ object DiffDlg: TDiffDlg
end end
object TSynGutterChanges object TSynGutterChanges
Width = 4 Width = 4
MouseActions = <>
ModifiedColor = 59900 ModifiedColor = 59900
SavedColor = clGreen SavedColor = clGreen
end end
object TSynGutterSeparator object TSynGutterSeparator
Width = 2 Width = 2
MouseActions = <>
MarkupInfo.Background = clWhite
MarkupInfo.Foreground = clGray
MarkupInfo.FrameEdges = sfeAround
end end
object TSynGutterCodeFolding object TSynGutterCodeFolding
MouseActions = < MouseActions = <
item item
Shift = []
ShiftMask = []
Button = mbRight Button = mbRight
ClickCount = ccSingle Command = emcCodeFoldContextMenu
ClickDir = cdUp
Command = 16
MoveCaret = False
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = [ssShift] ShiftMask = [ssShift]
Button = mbMiddle Button = mbMiddle
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 14 Command = emcCodeFoldCollaps
MoveCaret = False
Option = 0
Priority = 0
end end
item item
Shift = [ssShift] Shift = [ssShift]
@ -736,103 +676,65 @@ object DiffDlg: TDiffDlg
Button = mbMiddle Button = mbMiddle
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 14 Command = emcCodeFoldCollaps
MoveCaret = False
Option = 1 Option = 1
Priority = 0
end end
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 0 Command = emcNone
MoveCaret = False
Option = 0
Priority = 0
end> end>
MarkupInfo.Background = clNone MarkupInfo.Background = clNone
MarkupInfo.Foreground = clGray MarkupInfo.Foreground = clGray
MarkupInfo.FrameEdges = sfeAround
MouseActionsExpanded = < MouseActionsExpanded = <
item item
Shift = []
ShiftMask = []
Button = mbLeft
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 14 Command = emcCodeFoldCollaps
MoveCaret = False
Option = 0
Priority = 0
end> end>
MouseActionsCollapsed = < MouseActionsCollapsed = <
item item
Shift = [ssCtrl] Shift = [ssCtrl]
ShiftMask = [ssCtrl] ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 15 Command = emcCodeFoldExpand
MoveCaret = False
Option = 0
Priority = 0
end end
item item
Shift = []
ShiftMask = [ssCtrl] ShiftMask = [ssCtrl]
Button = mbLeft
ClickCount = ccAny ClickCount = ccAny
ClickDir = cdDown ClickDir = cdDown
Command = 15 Command = emcCodeFoldExpand
MoveCaret = False
Option = 1 Option = 1
Priority = 0
end> end>
end end
end end
end end
object SaveDiffButton: TBitBtn object OpenInEditorButton: TBitBtn
AnchorSideRight.Control = CloseButton AnchorSideRight.Control = CloseButton
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 459 Left = 373
Height = 25 Height = 26
Top = 491 Top = 490
Width = 64 Width = 137
Anchors = [akRight, akBottom]
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Save Diff'
NumGlyphs = 0
OnClick = SaveDiffButtonClick
TabOrder = 4
end
object OpenInEditorButton: TBitBtn
AnchorSideRight.Control = SaveDiffButton
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 320
Height = 25
Top = 491
Width = 133
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'OpenInEditorButton' Caption = 'OpenInEditorButton'
ModalResult = 6 ModalResult = 6
NumGlyphs = 0 TabOrder = 4
TabOrder = 5
end end
object CloseButton: TBitBtn object CloseButton: TBitBtn
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 529 Left = 516
Height = 26 Height = 27
Top = 490 Top = 489
Width = 63 Width = 76
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -840,25 +742,23 @@ object DiffDlg: TDiffDlg
Caption = '&Close' Caption = '&Close'
Kind = bkClose Kind = bkClose
ModalResult = 2 ModalResult = 2
NumGlyphs = 0 TabOrder = 5
TabOrder = 6
end end
object HelpButton: TBitBtn object HelpButton: TBitBtn
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideBottom.Control = Owner AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 6 Left = 6
Height = 26 Height = 33
Top = 490 Top = 483
Width = 57 Width = 76
Anchors = [akLeft, akBottom] Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = '&Help' Caption = '&Help'
Kind = bkHelp Kind = bkHelp
NumGlyphs = 0
OnClick = HelpButtonClick OnClick = HelpButtonClick
TabOrder = 7 TabOrder = 6
end end
object ProgressBar1: TProgressBar object ProgressBar1: TProgressBar
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
@ -867,36 +767,29 @@ object DiffDlg: TDiffDlg
AnchorSideBottom.Control = CloseButton AnchorSideBottom.Control = CloseButton
Left = 6 Left = 6
Height = 24 Height = 24
Top = 460 Top = 459
Width = 466 Width = 462
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Step = 0 Step = 0
TabOrder = 8 TabOrder = 7
end end
object CancelScanningButton: TBitBtn object CancelScanningButton: TBitBtn
AnchorSideTop.Control = ProgressBar1 AnchorSideTop.Control = ProgressBar1
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 478 Left = 474
Height = 25 Height = 26
Top = 460 Top = 458
Width = 114 Width = 118
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'Cancel Scanning' Caption = 'Cancel Scanning'
Enabled = False Enabled = False
OnClick = CancelScanningButtonClick OnClick = CancelScanningButtonClick
TabOrder = 9 TabOrder = 8
end
object dlgSave: TSaveDialog
DefaultExt = '.diff'
Filter = 'diff|*.diff|any file|*.*'
FilterIndex = 0
left = 272
top = 48
end end
object dlgOpen: TOpenDialog object dlgOpen: TOpenDialog
DefaultExt = '.pas' DefaultExt = '.pas'

View File

@ -28,7 +28,7 @@
Author: Mattias Gaertner Author: Mattias Gaertner
Abstract: Abstract:
The TDiffDlg is the dialog for showing the differences between two files. The TDiffDlg is a dialog for showing differences between two files.
} }
@ -81,11 +81,9 @@ type
DiffSynEdit: TSynEdit; DiffSynEdit: TSynEdit;
OpenInEditorButton: TBitBtn; OpenInEditorButton: TBitBtn;
ProgressBar1: TProgressBar; ProgressBar1: TProgressBar;
SaveDiffButton: TBitBtn;
SynDiffSyn1: TSynDiffSyn; SynDiffSyn1: TSynDiffSyn;
Text1FileOpenButton: TButton; Text1FileOpenButton: TButton;
CancelScanningButton: TBitBtn; CancelScanningButton: TBitBtn;
dlgSave: TSaveDialog;
dlgOpen: TOpenDialog; dlgOpen: TOpenDialog;
Text2FileOpenButton: TButton; Text2FileOpenButton: TButton;
@ -107,7 +105,6 @@ type
procedure FileOpenClick(Sender: TObject); procedure FileOpenClick(Sender: TObject);
procedure HelpButtonClick(Sender: TObject); procedure HelpButtonClick(Sender: TObject);
procedure OnChangeFlag(Sender: TObject); procedure OnChangeFlag(Sender: TObject);
procedure SaveDiffButtonClick(Sender: TObject);
procedure Text1ComboboxChange(Sender: TObject); procedure Text1ComboboxChange(Sender: TObject);
procedure Text2ComboboxChange(Sender: TObject); procedure Text2ComboboxChange(Sender: TObject);
private private
@ -135,8 +132,7 @@ type
property IdleConnected: boolean read fIdleConnected write SetIdleConnected; property IdleConnected: boolean read fIdleConnected write SetIdleConnected;
end; end;
function ShowDiffDialog(Text1Index: integer; function ShowDiffDialog(Text1Index: integer; out Diff: string): TModalResult;
var OpenDiffInEditor: boolean; var Diff: string): TModalResult;
const const
IgnoreCaseCheckBox = 0; IgnoreCaseCheckBox = 0;
@ -151,36 +147,33 @@ implementation
{$R *.lfm} {$R *.lfm}
function ShowDiffDialog(Text1Index: integer; function ShowDiffDialog(Text1Index: integer; out Diff: string): TModalResult;
var OpenDiffInEditor: boolean; var Diff: string): TModalResult;
var var
DiffDlg: TDiffDlg; DiffDlg: TDiffDlg;
Files: TDiffFiles; Files: TDiffFiles;
i: Integer; i: Integer;
SrcEdit: TSourceEditor; SrcEdit: TSourceEditor;
begin begin
DiffDlg := TDiffDlg.Create(nil);
Files := TDiffFiles.Create; Files := TDiffFiles.Create;
for i:=0 to SourceEditorManager.SourceEditorCount - 1 do begin try
SrcEdit := SourceEditorManager.SourceEditors[i]; // FindSourceEditorWithPageIndex(i); // Get available files
Files.Add(TDiffFile.Create(SrcEdit.PageName, SrcEdit, SrcEdit.SelectionAvailable)); for i:=0 to SourceEditorManager.SourceEditorCount - 1 do begin
SrcEdit := SourceEditorManager.SourceEditors[i]; // FindSourceEditorWithPageIndex(i);
Files.Add(TDiffFile.Create(SrcEdit.PageName, SrcEdit, SrcEdit.SelectionAvailable));
end;
DiffDlg.Files := Files;
DiffDlg.SetText1Index(Text1Index);
DiffDlg.Init;
Result := DiffDlg.ShowModal;
DiffDlg.SaveSettings;
// "Open in editor" button returns mrYes.
if Result=mrYes then
Diff := DiffDlg.DiffSynEdit.Text;
finally
Files.Free;
DiffDlg.Free;
end; end;
OpenDiffInEditor:=false;
DiffDlg:=TDiffDlg.Create(nil);
DiffDlg.Files:=Files;
DiffDlg.SetText1Index(Text1Index);
DiffDlg.Init;
Result:=DiffDlg.ShowModal;
DiffDlg.SaveSettings;
if Result=mrYes then begin
OpenDiffInEditor:=true;
Diff:=DiffDlg.DiffSynEdit.Text;
Result:=mrOk;
end;
Files.Free;
DiffDlg.Free;
end; end;
{ TDiffDlg } { TDiffDlg }
@ -228,16 +221,6 @@ begin
LazarusHelp.ShowHelpForIDEControl(Self); LazarusHelp.ShowHelpForIDEControl(Self);
end; end;
procedure TDiffDlg.SaveDiffButtonClick(Sender: TObject);
begin
if dlgSave.Execute then begin
try
SaveStringsToFileUTF8(DiffSynEdit.Lines,dlgSave.FileName);
except
end;
end;
end;
procedure TDiffDlg.Text1ComboboxChange(Sender: TObject); procedure TDiffDlg.Text1ComboboxChange(Sender: TObject);
begin begin
SetText1Index(Text1Combobox.Items.IndexOf(Text1Combobox.Text)); SetText1Index(Text1Combobox.Items.IndexOf(Text1Combobox.Text));
@ -251,12 +234,12 @@ end;
procedure TDiffDlg.SetupComponents; procedure TDiffDlg.SetupComponents;
begin begin
// text 1 // text 1
Text1GroupBox.Caption:=lisDiffDlgText1; Text1GroupBox.Caption:=lisDiffDlgFile1;
Text1OnlySelectionCheckBox.Caption:=lisDiffDlgOnlySelection; Text1OnlySelectionCheckBox.Caption:=lisDiffDlgOnlySelection;
Text1FileOpenButton.Caption:='...'; Text1FileOpenButton.Caption:='...';
// text 2 // text 2
Text2GroupBox.Caption:=lisDiffDlgText2; Text2GroupBox.Caption:=lisDiffDlgFile2;
Text2OnlySelectionCheckBox.Caption:=lisDiffDlgOnlySelection; Text2OnlySelectionCheckBox.Caption:=lisDiffDlgOnlySelection;
Text2FileOpenButton.Caption:='...'; Text2FileOpenButton.Caption:='...';
@ -277,17 +260,12 @@ begin
CancelScanningButton.LoadGlyphFromResourceName(hInstance, 'btn_cancel'); CancelScanningButton.LoadGlyphFromResourceName(hInstance, 'btn_cancel');
CloseButton.Caption:=lisClose; CloseButton.Caption:=lisClose;
OpenInEditorButton.Caption:=lisDiffDlgOpenDiffInEditor; OpenInEditorButton.Caption:=lisDiffDlgOpenDiffInEditor;
SaveDiffButton.Caption:=lisDlgSave;
HelpButton.Caption:=lisMenuHelp; HelpButton.Caption:=lisMenuHelp;
OpenInEditorButton.LoadGlyphFromStock(idButtonOpen); OpenInEditorButton.LoadGlyphFromStock(idButtonOpen);
if OpenInEditorButton.Glyph.Empty then if OpenInEditorButton.Glyph.Empty then
OpenInEditorButton.LoadGlyphFromResourceName(HInstance, 'laz_open'); OpenInEditorButton.LoadGlyphFromResourceName(HInstance, 'laz_open');
SaveDiffButton.LoadGlyphFromStock(idButtonSave);
if SaveDiffButton.Glyph.Empty then
SaveDiffButton.LoadGlyphFromResourceName(HInstance, 'laz_save');
// dialogs // dialogs
dlgOpen.Title:=lisOpenExistingFile; dlgOpen.Title:=lisOpenExistingFile;
dlgOpen.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask dlgOpen.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask
@ -296,8 +274,6 @@ begin
+'|'+lisLazarusForm+' (*.lfm;*.dfm)|*.lfm;*.dfm' +'|'+lisLazarusForm+' (*.lfm;*.dfm)|*.lfm;*.dfm'
+'|'+lisLazarusPackage+' (*.lpk)|*.lpk' +'|'+lisLazarusPackage+' (*.lpk)|*.lpk'
+'|'+lisLazarusProjectSource+' (*.lpr)|*.lpr'; +'|'+lisLazarusProjectSource+' (*.lpr)|*.lpr';
dlgSave.Title:=lisSaveFileAs;
dlgSave.Filter:=dlgAllFiles+' ('+GetAllFilesMask+')|'+GetAllFilesMask;
// diff // diff
EditorOpts.GetSynEditSettings(DiffSynEdit); EditorOpts.GetSynEditSettings(DiffSynEdit);
@ -360,7 +336,6 @@ begin
Text1GroupBox.Enabled := False; Text1GroupBox.Enabled := False;
Text2GroupBox.Enabled := False; Text2GroupBox.Enabled := False;
OpenInEditorButton.Enabled := False; OpenInEditorButton.Enabled := False;
SaveDiffButton.Enabled := False;
//CancelScanningButton.Enabled := True; //CancelScanningButton.Enabled := True;
DiffOutput:=TDiffOutput.Create(Text1Src, Text2Src, GetDiffOptions, ProgressBar1); DiffOutput:=TDiffOutput.Create(Text1Src, Text2Src, GetDiffOptions, ProgressBar1);
@ -371,7 +346,6 @@ begin
end; end;
//CancelScanningButton.Enabled := False; //CancelScanningButton.Enabled := False;
SaveDiffButton.Enabled := True;
OpenInEditorButton.Enabled := True; OpenInEditorButton.Enabled := True;
Text2GroupBox.Enabled := True; Text2GroupBox.Enabled := True;
Text1GroupBox.Enabled := True; Text1GroupBox.Enabled := True;
@ -384,7 +358,7 @@ begin
inherited Create(TheOwner); inherited Create(TheOwner);
fUpdating := False; fUpdating := False;
fCancelled := False; fCancelled := False;
Caption := lisCaptionDiff; Caption := lisCaptionCompareFiles;
IDEDialogLayoutList.ApplyLayout(Self,600,500); IDEDialogLayoutList.ApplyLayout(Self,600,500);
SetupComponents; SetupComponents;
end; end;

View File

@ -511,8 +511,8 @@ resourcestring
lisMenuGuessUnclosedBlock = 'Guess Unclosed Block'; lisMenuGuessUnclosedBlock = 'Guess Unclosed Block';
lisMenuGuessMisplacedIFDEF = 'Guess Misplaced IFDEF/ENDIF'; lisMenuGuessMisplacedIFDEF = 'Guess Misplaced IFDEF/ENDIF';
lisMenuMakeResourceString = 'Make Resource String ...'; lisMenuMakeResourceString = 'Make Resource String ...';
lisCaptionDiff = 'Diff'; lisCaptionCompareFiles = 'Compare files (not for creating patches)';
lisMenuDiff = 'Diff ...'; lisMenuCompareFiles = 'Compare files ...';
lisMenuConvertDFMtoLFM = 'Convert Binary DFM to Text LFM + Check Syntax ...'; lisMenuConvertDFMtoLFM = 'Convert Binary DFM to Text LFM + Check Syntax ...';
lisMenuCheckLFM = 'Check LFM File in Editor'; lisMenuCheckLFM = 'Check LFM File in Editor';
lisMenuDelphiConversion = 'Delphi Conversion'; lisMenuDelphiConversion = 'Delphi Conversion';
@ -3398,9 +3398,9 @@ resourcestring
lisTheApplicationBundleWasCreatedFor = 'The Application Bundle was created for "%s"'; lisTheApplicationBundleWasCreatedFor = 'The Application Bundle was created for "%s"';
// diff dialog // diff dialog
lisDiffDlgText1 = 'Text1'; lisDiffDlgFile1 = 'File1';
lisDiffDlgOnlySelection = 'Only selection'; lisDiffDlgOnlySelection = 'Only selection';
lisDiffDlgText2 = 'Text2'; lisDiffDlgFile2 = 'File2';
lisDiffDlgCaseInsensitive = 'Case Insensitive'; lisDiffDlgCaseInsensitive = 'Case Insensitive';
lisDiffDlgIgnoreIfEmptyLinesWereAdd = 'Ignore if empty lines were added or removed'; lisDiffDlgIgnoreIfEmptyLinesWereAdd = 'Ignore if empty lines were added or removed';
lisDiffDlgIgnoreSpacesAtStartOfLine = 'Ignore spaces at start of line'; lisDiffDlgIgnoreSpacesAtStartOfLine = 'Ignore spaces at start of line';
@ -3409,7 +3409,7 @@ resourcestring
+'g. #10 = #13#10)'; +'g. #10 = #13#10)';
lisDiffDlgIgnoreIfSpaceCharsWereAdd = 'Ignore amount of space chars'; lisDiffDlgIgnoreIfSpaceCharsWereAdd = 'Ignore amount of space chars';
lisDiffDlgIgnoreSpaces = 'Ignore spaces (newline chars not included)'; lisDiffDlgIgnoreSpaces = 'Ignore spaces (newline chars not included)';
lisDiffDlgOpenDiffInEditor = 'Open Diff in editor'; lisDiffDlgOpenDiffInEditor = 'Open difference in editor';
// packages // packages
lisPkgFileTypeUnit = 'Unit'; lisPkgFileTypeUnit = 'Unit';

View File

@ -9928,7 +9928,6 @@ function TMainIDE.DoDiff: TModalResult;
var var
ActiveSrcEdit: TSourceEditor; ActiveSrcEdit: TSourceEditor;
ActiveUnitInfo: TUnitInfo; ActiveUnitInfo: TUnitInfo;
OpenDiffInEditor: boolean;
DiffText: string; DiffText: string;
NewDiffFilename: String; NewDiffFilename: String;
begin begin
@ -9936,10 +9935,9 @@ begin
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo); GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
if ActiveSrcEdit=nil then exit; if ActiveSrcEdit=nil then exit;
Result:=ShowDiffDialog(ActiveSrcEdit.PageIndex, Result:=ShowDiffDialog(ActiveSrcEdit.PageIndex, DiffText);
OpenDiffInEditor,DiffText); if Result = mrYes then begin
if OpenDiffInEditor then begin NewDiffFilename:=CreateSrcEditPageName('','FileDifference.diff', nil);
NewDiffFilename:=CreateSrcEditPageName('','diff.txt', nil);
Result:=DoNewEditorFile(FileDescriptorText,NewDiffFilename,DiffText, Result:=DoNewEditorFile(FileDescriptorText,NewDiffFilename,DiffText,
[nfOpenInEditor]); [nfOpenInEditor]);
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo); GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);

View File

@ -997,7 +997,7 @@ begin
CreateMenuSeparatorSection(mnuTools,itmSecondaryTools,'itmSecondaryTools'); CreateMenuSeparatorSection(mnuTools,itmSecondaryTools,'itmSecondaryTools');
ParentMI:=itmSecondaryTools; ParentMI:=itmSecondaryTools;
CreateMenuItem(ParentMI,itmToolManageExamples,'itmToolManageExamples',lisMenuExampleProjects, 'camera'); CreateMenuItem(ParentMI,itmToolManageExamples,'itmToolManageExamples',lisMenuExampleProjects, 'camera');
CreateMenuItem(ParentMI,itmToolDiff,'itmToolDiff',lisMenuDiff, 'menu_tool_diff'); CreateMenuItem(ParentMI,itmToolDiff,'itmToolDiff',lisMenuCompareFiles, 'menu_tool_diff');
CreateMenuSubSection(mnuTools,itmDelphiConversion,'itmDelphiConversion',lisMenuDelphiConversion,'menu_tool_dfm_to_lfm'); CreateMenuSubSection(mnuTools,itmDelphiConversion,'itmDelphiConversion',lisMenuDelphiConversion,'menu_tool_dfm_to_lfm');
ParentMI:=itmDelphiConversion; ParentMI:=itmDelphiConversion;