mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 12:00:18 +02:00
implemented diff dialog
git-svn-id: trunk@3927 -
This commit is contained in:
parent
982893e660
commit
4c31d09eb5
@ -35,7 +35,7 @@ unit InputHistory;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, IDEProcs, Laz_XMLCfg, LazConf, Dialogs;
|
||||
Classes, SysUtils, DiffPatch, IDEProcs, Laz_XMLCfg, LazConf, Dialogs;
|
||||
|
||||
const
|
||||
// these are the names of the various history lists in the IDE:
|
||||
@ -94,6 +94,9 @@ type
|
||||
|
||||
TInputHistories = class
|
||||
private
|
||||
FDiffFlags: TTextDiffFlags;
|
||||
FDiffText2: string;
|
||||
FDiffText2OnlySelection: boolean;
|
||||
FFileDialogSettings: TFileDialogSettings;
|
||||
FFilename: string;
|
||||
|
||||
@ -165,6 +168,12 @@ type
|
||||
|
||||
// various history lists
|
||||
property HistoryLists: THistoryLists read FHistoryLists;
|
||||
|
||||
// diff dialog
|
||||
property DiffFlags: TTextDiffFlags read FDiffFlags write FDiffFlags;
|
||||
property DiffText2: string read FDiffText2 write FDiffText2;
|
||||
property DiffText2OnlySelection: boolean read FDiffText2OnlySelection
|
||||
write FDiffText2OnlySelection;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -177,6 +186,8 @@ implementation
|
||||
const
|
||||
DefaultHistoryFile = 'inputhistory.xml';
|
||||
InputHistoryVersion = 1;
|
||||
DefaultDiffFlags = [tdfIgnoreCase,tdfIgnoreEmptyLineChanges,
|
||||
tdfIgnoreLineEnds,tdfIgnoreTrailingSpaces];
|
||||
|
||||
{ TInputHistories }
|
||||
|
||||
@ -238,20 +249,28 @@ begin
|
||||
InitialDir:='';
|
||||
end;
|
||||
FLastFPCPath:='';
|
||||
FDiffFlags:=DefaultDiffFlags;
|
||||
FDiffText2:='';
|
||||
FDiffText2OnlySelection:=false;
|
||||
end;
|
||||
|
||||
procedure TInputHistories.LoadFromXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
var
|
||||
DiffFlag: TTextDiffFlag;
|
||||
begin
|
||||
// Find- and replace-history
|
||||
fMaxFindHistory:=XMLConfig.GetValue(Path+'Find/History/Max',FMaxFindHistory);
|
||||
LoadRecentList(XMLConfig,FFindHistory,Path+'Find/History/Find/');
|
||||
LoadRecentList(XMLConfig,FReplaceHistory,Path+'Find/History/Replace/');
|
||||
// unit dependencies
|
||||
LoadRecentList(XMLConfig,FUnitDependenciesHistory,Path+'UnitDependencies/History/');
|
||||
// fpc
|
||||
FLastFPCAge:=XMLConfig.GetValue(Path+'FPCUnitLinks/FPCAge',-1);
|
||||
FLastFPCPath:=XMLConfig.GetValue(Path+'FPCUnitLinks/FPCPath','');
|
||||
FLastFPCSearchPath:=XMLConfig.GetValue(Path+'FPCUnitLinks/FPCSearchPath','');
|
||||
FLastFPCUnitLinks:=XMLConfig.GetValue(Path+'FPCUnitLinks/UnitLinks','');
|
||||
// file dialog
|
||||
with FFileDialogSettings do begin
|
||||
Width:=XMLConfig.GetValue(Path+'FileDialog/Width',0);
|
||||
Height:=XMLConfig.GetValue(Path+'FileDialog/Height',0);
|
||||
@ -259,21 +278,39 @@ begin
|
||||
MaxHistory:=XMLConfig.GetValue(Path+'FileDialog/MaxHistory',20);
|
||||
LoadRecentList(XMLConfig,HistoryList,Path+'FileDialog/HistoryList/');
|
||||
end;
|
||||
// history lists
|
||||
FHistoryLists.LoadFromXMLConfig(XMLConfig,Path+'HistoryLists/');
|
||||
// diff dialog
|
||||
FDiffFlags:=[];
|
||||
for DiffFlag:=Low(TTextDiffFlag) to High(TTextDiffFlag) do begin
|
||||
if XMLConfig.GetValue(
|
||||
Path+'DiffDialog/Options/'+TextDiffFlagNames[DiffFlag],
|
||||
DiffFlag in DefaultDiffFlags)
|
||||
then
|
||||
Include(FDiffFlags,DiffFlag);
|
||||
end;
|
||||
FDiffText2:=XMLConfig.GetValue(Path+'DiffDialog/Text2/Name','');
|
||||
FDiffText2OnlySelection:=
|
||||
XMLConfig.GetValue(Path+'DiffDialog/Text2/OnlySelection',false);
|
||||
end;
|
||||
|
||||
procedure TInputHistories.SaveToXMLConfig(XMLConfig: TXMLConfig;
|
||||
const Path: string);
|
||||
var
|
||||
DiffFlag: TTextDiffFlag;
|
||||
begin
|
||||
// Find- and replace-history
|
||||
XMLConfig.SetDeleteValue(Path+'Find/History/Max',FMaxFindHistory,20);
|
||||
SaveRecentList(XMLConfig,FFindHistory,Path+'Find/History/Find/');
|
||||
SaveRecentList(XMLConfig,FReplaceHistory,Path+'Find/History/Replace/');
|
||||
// unit dependencies
|
||||
SaveRecentList(XMLConfig,FUnitDependenciesHistory,Path+'UnitDependencies/History/');
|
||||
// fpc
|
||||
XMLConfig.SetDeleteValue(Path+'FPCUnitLinks/FPCAge',FLastFPCAge,0);
|
||||
XMLConfig.SetDeleteValue(Path+'FPCUnitLinks/FPCPath',FLastFPCPath,'');
|
||||
XMLConfig.SetDeleteValue(Path+'FPCUnitLinks/FPCSearchPath',FLastFPCSearchPath,'');
|
||||
XMLConfig.SetDeleteValue(Path+'FPCUnitLinks/UnitLinks',FLastFPCUnitLinks,'');
|
||||
// file dialog
|
||||
with FFileDialogSettings do begin
|
||||
XMLConfig.SetDeleteValue(Path+'FileDialog/Width',Width,0);
|
||||
XMLConfig.SetDeleteValue(Path+'FileDialog/Height',Height,0);
|
||||
@ -281,7 +318,17 @@ begin
|
||||
XMLConfig.SetDeleteValue(Path+'FileDialog/MaxHistory',MaxHistory,20);
|
||||
SaveRecentList(XMLConfig,HistoryList,Path+'FileDialog/HistoryList/');
|
||||
end;
|
||||
// history lists
|
||||
FHistoryLists.SaveToXMLConfig(XMLConfig,Path+'HistoryLists/');
|
||||
// diff dialog
|
||||
for DiffFlag:=Low(TTextDiffFlag) to High(TTextDiffFlag) do begin
|
||||
XMLConfig.SetDeleteValue(
|
||||
Path+'DiffDialog/Options/'+TextDiffFlagNames[DiffFlag],
|
||||
DiffFlag in DiffFlags,DiffFlag in DefaultDiffFlags);
|
||||
end;
|
||||
XMLConfig.SetDeleteValue(Path+'DiffDialog/Text2/Name',FDiffText2,'');
|
||||
XMLConfig.SetDeleteValue(Path+'DiffDialog/Text2/OnlySelection',
|
||||
FDiffText2OnlySelection,false);
|
||||
end;
|
||||
|
||||
procedure TInputHistories.SetLazarusDefaultFilename;
|
||||
|
@ -106,6 +106,7 @@ const
|
||||
ecGuessMisplacedIFDEF = ecUserFirst + 105;
|
||||
ecConvertDFM2LFM = ecUserFirst + 106;
|
||||
ecMakeResourceString = ecUserFirst + 107;
|
||||
ecDiff = ecUserFirst + 108;
|
||||
|
||||
ecNew = ecUserFirst + 201;
|
||||
ecNewUnit = ecUserFirst + 202;
|
||||
@ -609,13 +610,14 @@ begin
|
||||
ecBuildLazarus : Result:= srkmecBuildLazarus;
|
||||
ecExtToolFirst..
|
||||
ecExtToolLast : Result:= Format(srkmecExtTool,[cmd-ecExtToolFirst+1]);
|
||||
ecMakeResourceString : Result:= srkmecMakeResourceString;
|
||||
ecDiff : Result:= srkmecDiff;
|
||||
|
||||
// environment menu
|
||||
ecEnvironmentOptions : Result:= srkmecEnvironmentOptions;
|
||||
ecEditorOptions : Result:= lismenueditoroptions;
|
||||
ecCodeToolsOptions : Result:= srkmecCodeToolsOptions;
|
||||
ecCodeToolsDefinesEd : Result:= srkmecCodeToolsDefinesEd;
|
||||
ecMakeResourceString : Result:= srkmecMakeResourceString;
|
||||
|
||||
// help menu
|
||||
ecAboutLazarus : Result:= lisMenuAboutLazarus;
|
||||
@ -1437,6 +1439,7 @@ begin
|
||||
Add(C,'Build Lazarus',ecBuildLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add(C,'Configure "Build Lazarus"',ecConfigBuildLazarus,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add(C,'Make resource string',ecMakeResourceString,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
Add(C,'Diff editor files',ecDiff,VK_UNKNOWN,[],VK_UNKNOWN,[]);
|
||||
|
||||
// environment menu
|
||||
C:=Categories[AddCategory('EnvironmentMenu',srkmCatEnvMenu,caAll)];
|
||||
|
@ -207,6 +207,7 @@ resourcestring
|
||||
lisMenuGuessUnclosedBlock = 'Guess unclosed block';
|
||||
lisMenuGuessMisplacedIFDEF = 'Guess misplaced IFDEF/ENDIF';
|
||||
lisMenuMakeResourceString = 'Make Resource String';
|
||||
lisMenuDiff = 'Diff';
|
||||
lisMenuConvertDFMtoLFM = 'Convert DFM file to LFM';
|
||||
lisMenuBuildLazarus = 'Build Lazarus';
|
||||
lisMenuConfigureBuildLazarus = 'Configure "Build Lazarus"';
|
||||
@ -887,6 +888,7 @@ resourcestring
|
||||
srkmecCodeToolsOptions = 'Codetools options';
|
||||
srkmecCodeToolsDefinesEd = 'Codetools defines editor';
|
||||
srkmecMakeResourceString = 'Make resource string';
|
||||
srkmecDiff = 'Diff';
|
||||
// help menu
|
||||
srkmecunknown = 'unknown editor command';
|
||||
|
||||
@ -1138,6 +1140,50 @@ resourcestring
|
||||
+'child nodes.';
|
||||
lisCodeToolsDefsNewNode = 'NewNode';
|
||||
lisCodeToolsDefsCodeToolsDefinesEditor = 'CodeTools Defines Editor';
|
||||
|
||||
// code template dialog
|
||||
lisCodeTemplAddCodeTemplate = 'Add code template';
|
||||
lisCodeTemplAdd = 'Add';
|
||||
lisCodeTemplEditCodeTemplate = 'Edit code template';
|
||||
lisCodeTemplChange = 'Change';
|
||||
lisCodeTemplToken = 'Token:';
|
||||
lisCodeTemplComment = 'Comment:';
|
||||
lisCodeTemplATokenAlreadyExists = ' A token %s%s%s already exists! ';
|
||||
lisCodeTemplError = 'Error';
|
||||
|
||||
// make resource string dialog
|
||||
lisMakeResourceString = 'Make ResourceString';
|
||||
lisMakeResStrInvalidResourcestringSect = 'Invalid Resourcestring section';
|
||||
lisMakeResStrPleaseChooseAResourstring = 'Please choose a resourstring '
|
||||
+'section from the list.';
|
||||
lisMakeResStrResourcestringAlreadyExis = 'Resourcestring already exists';
|
||||
lisMakeResStrChooseAnotherName = 'The resourcestring %s%s%s already exists.%'
|
||||
+'sPlease choose another name.%sUse Ignore to add it anyway.';
|
||||
lisMakeResStrStringConstantInSource = 'String Constant in source';
|
||||
lisMakeResStrConversionOptions = 'Conversion Options';
|
||||
lisMakeResStrIdentifierPrefix = 'Identifier Prefix:';
|
||||
lisMakeResStrIdentifierLength = 'Identifier Length:';
|
||||
lisMakeResStrCustomIdentifier = 'Custom Identifier';
|
||||
lisMakeResStrResourcestringSection = 'Resourcestring Section:';
|
||||
lisMakeResStrStringsWithSameValue = 'Strings with same value:';
|
||||
lisMakeResStrAppendToSection = 'Append to section';
|
||||
lisMakeResStrInsertAlphabetically = 'Insert alphabetically';
|
||||
lisMakeResStrSourcePreview = 'Source preview';
|
||||
|
||||
// diff dialog
|
||||
lisDiffDlgText1 = 'Text1';
|
||||
lisDiffDlgOnlySelection = 'Only selection';
|
||||
lisDiffDlgText2 = 'Text2';
|
||||
lisDiffDlgCaseInsensitive = 'Case Insensitive';
|
||||
lisDiffDlgIgnoreIfEmptyLinesWereAdd = 'Ignore if empty lines were added or '
|
||||
+'removed';
|
||||
lisDiffDlgIgnoreSpacesAtStartOfLine = 'Ignore spaces at start of line';
|
||||
lisDiffDlgIgnoreSpacesAtEndOfLine = 'Ignore spaces at end of line';
|
||||
lisDiffDlgIgnoreIfLineEndCharsDiffe = 'Ignore difference in line ends (e.'
|
||||
+'g. #10 = #13#10)';
|
||||
lisDiffDlgIgnoreIfSpaceCharsWereAdd = 'Ignore amount of space chars';
|
||||
lisDiffDlgIgnoreSpaces = 'Ignore spaces (newline chars not included)';
|
||||
lisDiffDlgOpenDiffInEditor = 'Open Diff in editor';
|
||||
|
||||
implementation
|
||||
end.
|
||||
|
@ -68,11 +68,12 @@ type
|
||||
TNewFlags = set of TNewFlag;
|
||||
|
||||
// save file flags
|
||||
TSaveFlag = (sfSaveAs,
|
||||
sfSaveToTestDir,
|
||||
sfProjectSaving,
|
||||
sfCheckAmbigiousFiles
|
||||
);
|
||||
TSaveFlag = (
|
||||
sfSaveAs,
|
||||
sfSaveToTestDir,
|
||||
sfProjectSaving,
|
||||
sfCheckAmbigiousFiles
|
||||
);
|
||||
TSaveFlags = set of TSaveFlag;
|
||||
|
||||
// open file flags
|
||||
@ -257,6 +258,7 @@ type
|
||||
itmToolGuessMisplacedIFDEF: TMenuItem;
|
||||
itmToolConvertDFMtoLFM: TMenuItem;
|
||||
itmToolMakeResourceString: TMenuItem;
|
||||
itmToolDiff: TMenuItem;
|
||||
itmToolBuildLazarus: TMenuItem;
|
||||
itmToolConfigureBuildLazarus: TMenuItem;
|
||||
|
||||
@ -1036,6 +1038,11 @@ begin
|
||||
itmToolMakeResourceString.Caption := lisMenuMakeResourceString;
|
||||
mnuTools.Add(itmToolMakeResourceString);
|
||||
|
||||
itmToolDiff := TMenuItem.Create(Self);
|
||||
itmToolDiff.Name:='itmToolDiff';
|
||||
itmToolDiff.Caption := lisMenuDiff;
|
||||
mnuTools.Add(itmToolDiff);
|
||||
|
||||
mnuTools.Add(CreateMenuSeparator);
|
||||
|
||||
itmToolConvertDFMtoLFM := TMenuItem.Create(Self);
|
||||
@ -1201,6 +1208,7 @@ begin
|
||||
itmToolGuessUnclosedBlock.ShortCut:=CommandToShortCut(ecGuessUnclosedBlock);
|
||||
itmToolGuessMisplacedIFDEF.ShortCut:=CommandToShortCut(ecGuessMisplacedIFDEF);
|
||||
itmToolMakeResourceString.ShortCut:=CommandToShortCut(ecMakeResourceString);
|
||||
itmToolDiff.ShortCut:=CommandToShortCut(ecDiff);
|
||||
itmToolConvertDFMtoLFM.ShortCut:=CommandToShortCut(ecConvertDFM2LFM);
|
||||
itmToolBuildLazarus.ShortCut:=CommandToShortCut(ecBuildLazarus);
|
||||
itmToolConfigureBuildLazarus.ShortCut:=CommandToShortCut(ecConfigBuildLazarus);
|
||||
|
@ -336,17 +336,16 @@ var
|
||||
begin
|
||||
Index:=ResStrSectionComboBox.ItemIndex;
|
||||
if (Index<0) or (Index>=Positions.Count) then begin
|
||||
MessageDlg('Invalid Resourcestring section',
|
||||
'Please choose a resourstring section from the list.',
|
||||
MessageDlg(lisMakeResStrInvalidResourcestringSect,
|
||||
lisMakeResStrPleaseChooseAResourstring,
|
||||
mtError,[mbCancel],0);
|
||||
exit;
|
||||
end;
|
||||
if ResStrExistsInAnySection(IdentifierEdit.Text)
|
||||
and (not ResStrExistsWithSameValue(IdentifierEdit.Text)) then begin
|
||||
if MessageDlg('Resourcestring already exists',
|
||||
'The resourcestring "'+IdentifierEdit.Text+'" already exists.'#13
|
||||
+'Please choose another name.'#13
|
||||
+'Use Ignore to add it anyway.',
|
||||
if MessageDlg(lisMakeResStrResourcestringAlreadyExis,
|
||||
Format(lisMakeResStrChooseAnotherName, ['"', IdentifierEdit.Text, '"',
|
||||
#13, #13]),
|
||||
mtWarning,[mbOk,mbIgnore],0)
|
||||
=mrOk
|
||||
then
|
||||
@ -382,7 +381,7 @@ begin
|
||||
with StringConstGroupBox do begin
|
||||
Name:='StringConstGroupBox';
|
||||
Parent:=Self;
|
||||
Caption:='String Constant in source';
|
||||
Caption:=lisMakeResStrStringConstantInSource;
|
||||
end;
|
||||
|
||||
StringConstSynEdit:=TSynEdit.Create(Self);
|
||||
@ -398,7 +397,7 @@ begin
|
||||
with ConversionGroupBox do begin
|
||||
Name:='ConversionGroupBox';
|
||||
Parent:=Self;
|
||||
Caption:='Conversion Options';
|
||||
Caption:=lisMakeResStrConversionOptions;
|
||||
OnResize:=@ConversionGroupBoxResize;
|
||||
end;
|
||||
|
||||
@ -407,7 +406,7 @@ begin
|
||||
with IdentPrefixLabel do begin
|
||||
Name:='IdentPrefixLabel';
|
||||
Parent:=ConversionGroupBox;
|
||||
Caption:='Identifier Prefix:';
|
||||
Caption:=lisMakeResStrIdentifierPrefix;
|
||||
end;
|
||||
|
||||
IdentPrefixComboBox:=TComboBox.Create(Self);
|
||||
@ -422,7 +421,7 @@ begin
|
||||
with IdentLengthLabel do begin
|
||||
Name:='IdentLengthLabel';
|
||||
Parent:=ConversionGroupBox;
|
||||
Caption:='Identifier Length:';
|
||||
Caption:=lisMakeResStrIdentifierLength;
|
||||
end;
|
||||
|
||||
IdentLengthComboBox:=TComboBox.Create(Self);
|
||||
@ -437,7 +436,7 @@ begin
|
||||
with CustomIdentifierCheckBox do begin
|
||||
Name:='CustomIdentifierCheckBox';
|
||||
Parent:=ConversionGroupBox;
|
||||
Caption:='Custom Identifier';
|
||||
Caption:=lisMakeResStrCustomIdentifier;
|
||||
Checked:=false;
|
||||
OnClick:=@CustomIdentifierCheckBoxClick;
|
||||
end;
|
||||
@ -455,7 +454,7 @@ begin
|
||||
with ResStrSectionLabel do begin
|
||||
Name:='ResStrSectionLabel';
|
||||
Parent:=ConversionGroupBox;
|
||||
Caption:='Resourcestring Section:';
|
||||
Caption:=lisMakeResStrResourcestringSection;
|
||||
end;
|
||||
|
||||
ResStrSectionComboBox:=TComboBox.Create(Self);
|
||||
@ -470,7 +469,7 @@ begin
|
||||
with ResStrWithSameValueLabel do begin
|
||||
Name:='ResStrWithSameValueLabel';
|
||||
Parent:=ConversionGroupBox;
|
||||
Caption:='Strings with same value:';
|
||||
Caption:=lisMakeResStrStringsWithSameValue;
|
||||
end;
|
||||
|
||||
ResStrWithSameValuesCombobox:=TComboBox.Create(Self);
|
||||
@ -485,14 +484,14 @@ begin
|
||||
with AppendResStrRadioButton do begin
|
||||
Name:='AppendResStrRadioButton';
|
||||
Parent:=ConversionGroupBox;
|
||||
Caption:='Append to section';
|
||||
Caption:=lisMakeResStrAppendToSection;
|
||||
end;
|
||||
|
||||
InsertAlphabeticallyResStrRadioButton:=TRadioButton.Create(Self);
|
||||
with InsertAlphabeticallyResStrRadioButton do begin
|
||||
Name:='InsertAlphabeticallyResStrRadioButton';
|
||||
Parent:=ConversionGroupBox;
|
||||
Caption:='Insert alphabetically';
|
||||
Caption:=lisMakeResStrInsertAlphabetically;
|
||||
end;
|
||||
|
||||
// converted source preview
|
||||
@ -500,7 +499,7 @@ begin
|
||||
with SrcPreviewGroupBox do begin
|
||||
Name:='SrcPreviewGroupBox';
|
||||
Parent:=Self;
|
||||
Caption:='Source preview';
|
||||
Caption:=lisMakeResStrSourcePreview;
|
||||
end;
|
||||
|
||||
SrcPreviewSynEdit:=TSynEdit.Create(Self);
|
||||
@ -516,7 +515,7 @@ begin
|
||||
with OkButton do begin
|
||||
Name:='OkButton';
|
||||
Parent:=Self;
|
||||
Caption:='Ok';
|
||||
Caption:=lisLazBuildOk;
|
||||
OnClick:=@OkButtonClick;
|
||||
end;
|
||||
|
||||
@ -524,7 +523,7 @@ begin
|
||||
with CancelButton do begin
|
||||
Name:='CancelButton';
|
||||
Parent:=Self;
|
||||
Caption:='Cancel';
|
||||
Caption:=dlgCancel;
|
||||
OnClick:=@CancelButtonClick;
|
||||
end;
|
||||
end;
|
||||
@ -534,7 +533,7 @@ begin
|
||||
inherited Create(TheOwner);
|
||||
if LazarusResources.Find(Classname)=nil then begin
|
||||
Name:='MakeResStrDialog';
|
||||
Caption := 'Make ResourceString';
|
||||
Caption := lisMakeResourceString;
|
||||
Width:=550;
|
||||
Height:=400;
|
||||
Position:=poScreenCenter;
|
||||
|
Loading…
Reference in New Issue
Block a user