mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 04:36:42 +02:00
IDE: Reload also .lfm file in designer when a unit was changed on disk. Improve DiskDiffsDialog. Issue #21587.
git-svn-id: trunk@64048 -
This commit is contained in:
parent
78d5022afa
commit
4f131502bd
@ -1,16 +1,16 @@
|
||||
object DiskDiffsDlg: TDiskDiffsDlg
|
||||
Left = 314
|
||||
Height = 353
|
||||
Top = 351
|
||||
Left = 396
|
||||
Height = 361
|
||||
Top = 348
|
||||
Width = 600
|
||||
ActiveControl = FilesListBox
|
||||
Caption = 'DiskDiffsDlg'
|
||||
ClientHeight = 353
|
||||
ClientHeight = 361
|
||||
ClientWidth = 600
|
||||
KeyPreview = True
|
||||
OnClose = FormClose
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '1.7'
|
||||
LCLVersion = '2.1.0.0'
|
||||
object FilesListBox: TCheckListBox
|
||||
Left = 6
|
||||
Height = 86
|
||||
@ -23,16 +23,15 @@ object DiskDiffsDlg: TDiskDiffsDlg
|
||||
ItemHeight = 0
|
||||
OnClick = FilesListBoxClick
|
||||
TabOrder = 0
|
||||
TopIndex = -1
|
||||
end
|
||||
inline DiffSynEdit: TSynEdit
|
||||
AnchorSideBottom.Control = CheckDiskChangesWithLoadingCheckBox
|
||||
AnchorSideBottom.Control = WarnSpeedButton
|
||||
Left = 6
|
||||
Height = 167
|
||||
Height = 145
|
||||
Top = 97
|
||||
Width = 588
|
||||
Align = alTop
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Right = 6
|
||||
BorderSpacing.Around = 6
|
||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||
Font.Height = -12
|
||||
Font.Name = 'courier'
|
||||
@ -43,7 +42,7 @@ object DiskDiffsDlg: TDiskDiffsDlg
|
||||
TabOrder = 2
|
||||
BookMarkOptions.Xoffset = -18
|
||||
Gutter.Visible = False
|
||||
Gutter.Width = 59
|
||||
Gutter.Width = 55
|
||||
Gutter.MouseActions = <
|
||||
item
|
||||
ClickCount = ccAny
|
||||
@ -468,6 +467,10 @@ object DiskDiffsDlg: TDiskDiffsDlg
|
||||
SelectedColor.ItalicPriority = 50
|
||||
SelectedColor.UnderlinePriority = 50
|
||||
SelectedColor.StrikeOutPriority = 50
|
||||
ScrollOnEditLeftOptions.ScrollExtraPercent = 20
|
||||
ScrollOnEditLeftOptions.ScrollExtraMax = 10
|
||||
ScrollOnEditRightOptions.ScrollExtraPercent = 30
|
||||
ScrollOnEditRightOptions.ScrollExtraMax = 25
|
||||
BracketHighlightStyle = sbhsBoth
|
||||
BracketMatchColor.Background = clNone
|
||||
BracketMatchColor.Foreground = clNone
|
||||
@ -486,7 +489,7 @@ object DiskDiffsDlg: TDiskDiffsDlg
|
||||
MouseActions = <>
|
||||
end
|
||||
object SynGutterLineNumber1: TSynGutterLineNumber
|
||||
Width = 19
|
||||
Width = 15
|
||||
MouseActions = <>
|
||||
MarkupInfo.Background = clBtnFace
|
||||
MarkupInfo.Foreground = clNone
|
||||
@ -573,68 +576,143 @@ object DiskDiffsDlg: TDiskDiffsDlg
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideBottom.Control = BtnPanel
|
||||
Left = 6
|
||||
Height = 19
|
||||
Top = 270
|
||||
Width = 241
|
||||
Anchors = [akLeft]
|
||||
Height = 21
|
||||
Top = 286
|
||||
Width = 278
|
||||
Anchors = [akLeft, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'CheckDiskChangesWithLoadingCheckBox'
|
||||
TabOrder = 3
|
||||
end
|
||||
object BtnPanel: TPanel
|
||||
Left = 0
|
||||
Height = 37
|
||||
Top = 316
|
||||
Width = 600
|
||||
Align = alBottom
|
||||
AutoSize = True
|
||||
BevelOuter = bvNone
|
||||
ClientHeight = 37
|
||||
ClientWidth = 600
|
||||
TabOrder = 5
|
||||
object RevertButton: TButton
|
||||
Left = 499
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 95
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'RevertButton'
|
||||
Default = True
|
||||
ModalResult = 6
|
||||
TabOrder = 1
|
||||
end
|
||||
object IgnoreDiskChangesButton: TButton
|
||||
Left = 329
|
||||
Height = 25
|
||||
Top = 6
|
||||
Width = 164
|
||||
Align = alRight
|
||||
AutoSize = True
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'IgnoreDiskChangesButton'
|
||||
ModalResult = 5
|
||||
TabOrder = 0
|
||||
end
|
||||
end
|
||||
object AutoCheckModifiedFilesCheckBox: TCheckBox
|
||||
AnchorSideLeft.Control = Owner
|
||||
AnchorSideTop.Control = CheckDiskChangesWithLoadingCheckBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideBottom.Control = BtnPanel
|
||||
object BtnPanel: TButtonPanel
|
||||
Left = 6
|
||||
Height = 15
|
||||
Top = 295
|
||||
Width = 202
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'AutoCheckModifiedFilesCheckBox'
|
||||
Height = 42
|
||||
Top = 313
|
||||
Width = 588
|
||||
OKButton.Name = 'OKButton'
|
||||
OKButton.DefaultCaption = True
|
||||
HelpButton.Name = 'HelpButton'
|
||||
HelpButton.DefaultCaption = True
|
||||
CloseButton.Name = 'CloseButton'
|
||||
CloseButton.DefaultCaption = True
|
||||
CancelButton.Name = 'CancelButton'
|
||||
CancelButton.DefaultCaption = True
|
||||
TabOrder = 4
|
||||
ShowButtons = [pbOK, pbCancel, pbHelp]
|
||||
end
|
||||
object WarnLabel: TLabel
|
||||
AnchorSideLeft.Control = WarnSpeedButton
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = WarnSpeedButton
|
||||
AnchorSideTop.Side = asrCenter
|
||||
Left = 45
|
||||
Height = 19
|
||||
Top = 255
|
||||
Width = 66
|
||||
BorderSpacing.Around = 6
|
||||
Caption = 'WarnLabel'
|
||||
Font.Color = clMaroon
|
||||
ParentColor = False
|
||||
ParentFont = False
|
||||
end
|
||||
object WarnSpeedButton: TSpeedButton
|
||||
AnchorSideLeft.Control = CheckDiskChangesWithLoadingCheckBox
|
||||
AnchorSideBottom.Control = CheckDiskChangesWithLoadingCheckBox
|
||||
Left = 6
|
||||
Height = 32
|
||||
Top = 248
|
||||
Width = 33
|
||||
Anchors = [akLeft, akBottom]
|
||||
Flat = True
|
||||
Transparent = False
|
||||
end
|
||||
object SynDiffSyn1: TSynDiffSyn
|
||||
Enabled = False
|
||||
left = 135
|
||||
top = 138
|
||||
UnknownAttri.BackPriority = 0
|
||||
UnknownAttri.ForePriority = 0
|
||||
UnknownAttri.FramePriority = 0
|
||||
UnknownAttri.BoldPriority = 0
|
||||
UnknownAttri.ItalicPriority = 0
|
||||
UnknownAttri.UnderlinePriority = 0
|
||||
UnknownAttri.StrikeOutPriority = 0
|
||||
SpaceAttri.BackPriority = 0
|
||||
SpaceAttri.ForePriority = 0
|
||||
SpaceAttri.FramePriority = 0
|
||||
SpaceAttri.BoldPriority = 0
|
||||
SpaceAttri.ItalicPriority = 0
|
||||
SpaceAttri.UnderlinePriority = 0
|
||||
SpaceAttri.StrikeOutPriority = 0
|
||||
OrigFileAttri.BackPriority = 0
|
||||
OrigFileAttri.ForePriority = 0
|
||||
OrigFileAttri.FramePriority = 0
|
||||
OrigFileAttri.BoldPriority = 0
|
||||
OrigFileAttri.ItalicPriority = 0
|
||||
OrigFileAttri.UnderlinePriority = 0
|
||||
OrigFileAttri.StrikeOutPriority = 0
|
||||
NewFileAttri.BackPriority = 0
|
||||
NewFileAttri.ForePriority = 0
|
||||
NewFileAttri.FramePriority = 0
|
||||
NewFileAttri.BoldPriority = 0
|
||||
NewFileAttri.ItalicPriority = 0
|
||||
NewFileAttri.UnderlinePriority = 0
|
||||
NewFileAttri.StrikeOutPriority = 0
|
||||
ChunkMarkerAttri.BackPriority = 0
|
||||
ChunkMarkerAttri.ForePriority = 0
|
||||
ChunkMarkerAttri.FramePriority = 0
|
||||
ChunkMarkerAttri.BoldPriority = 0
|
||||
ChunkMarkerAttri.ItalicPriority = 0
|
||||
ChunkMarkerAttri.UnderlinePriority = 0
|
||||
ChunkMarkerAttri.StrikeOutPriority = 0
|
||||
ChunkNewAttri.BackPriority = 0
|
||||
ChunkNewAttri.ForePriority = 0
|
||||
ChunkNewAttri.FramePriority = 0
|
||||
ChunkNewAttri.BoldPriority = 0
|
||||
ChunkNewAttri.ItalicPriority = 0
|
||||
ChunkNewAttri.UnderlinePriority = 0
|
||||
ChunkNewAttri.StrikeOutPriority = 0
|
||||
ChunkOldAttri.BackPriority = 0
|
||||
ChunkOldAttri.ForePriority = 0
|
||||
ChunkOldAttri.FramePriority = 0
|
||||
ChunkOldAttri.BoldPriority = 0
|
||||
ChunkOldAttri.ItalicPriority = 0
|
||||
ChunkOldAttri.UnderlinePriority = 0
|
||||
ChunkOldAttri.StrikeOutPriority = 0
|
||||
ChunkMixedAttri.BackPriority = 0
|
||||
ChunkMixedAttri.ForePriority = 0
|
||||
ChunkMixedAttri.FramePriority = 0
|
||||
ChunkMixedAttri.BoldPriority = 0
|
||||
ChunkMixedAttri.ItalicPriority = 0
|
||||
ChunkMixedAttri.UnderlinePriority = 0
|
||||
ChunkMixedAttri.StrikeOutPriority = 0
|
||||
LineAddedAttri.BackPriority = 0
|
||||
LineAddedAttri.ForePriority = 0
|
||||
LineAddedAttri.FramePriority = 0
|
||||
LineAddedAttri.BoldPriority = 0
|
||||
LineAddedAttri.ItalicPriority = 0
|
||||
LineAddedAttri.UnderlinePriority = 0
|
||||
LineAddedAttri.StrikeOutPriority = 0
|
||||
LineRemovedAttri.BackPriority = 0
|
||||
LineRemovedAttri.ForePriority = 0
|
||||
LineRemovedAttri.FramePriority = 0
|
||||
LineRemovedAttri.BoldPriority = 0
|
||||
LineRemovedAttri.ItalicPriority = 0
|
||||
LineRemovedAttri.UnderlinePriority = 0
|
||||
LineRemovedAttri.StrikeOutPriority = 0
|
||||
LineChangedAttri.BackPriority = 0
|
||||
LineChangedAttri.ForePriority = 0
|
||||
LineChangedAttri.FramePriority = 0
|
||||
LineChangedAttri.BoldPriority = 0
|
||||
LineChangedAttri.ItalicPriority = 0
|
||||
LineChangedAttri.UnderlinePriority = 0
|
||||
LineChangedAttri.StrikeOutPriority = 0
|
||||
LineContextAttri.BackPriority = 0
|
||||
LineContextAttri.ForePriority = 0
|
||||
LineContextAttri.FramePriority = 0
|
||||
LineContextAttri.BoldPriority = 0
|
||||
LineContextAttri.ItalicPriority = 0
|
||||
LineContextAttri.UnderlinePriority = 0
|
||||
LineContextAttri.StrikeOutPriority = 0
|
||||
Left = 135
|
||||
Top = 138
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,4 @@
|
||||
{
|
||||
/***************************************************************************
|
||||
diskdiffsdialog.pas
|
||||
- form for showing the diffs of editor files changed on disk
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
***************************************************************************
|
||||
* *
|
||||
* This source is free software; you can redistribute it and/or modify *
|
||||
@ -24,6 +18,8 @@
|
||||
* *
|
||||
***************************************************************************
|
||||
|
||||
Abstract:
|
||||
form for showing the diffs of editor files changed on disk
|
||||
}
|
||||
unit DiskDiffsDialog;
|
||||
|
||||
@ -35,11 +31,13 @@ uses
|
||||
// RTL + FCL
|
||||
Classes, SysUtils,
|
||||
// LCL
|
||||
LCLProc, LCLType, Forms, Controls, StdCtrls, ExtCtrls, CheckLst,
|
||||
LCLProc, LCLType, Forms, StdCtrls, ExtCtrls, CheckLst, ButtonPanel, Buttons,
|
||||
// CodeTools
|
||||
FileProcs, CodeCache,
|
||||
// LazUtils
|
||||
LazUTF8Classes, LazFileUtils,
|
||||
LazUTF8Classes, LazFileUtils, UITypes,
|
||||
// IdeIntf
|
||||
IDEImagesIntf,
|
||||
// SynEdit
|
||||
SynEdit, SynHighlighterDiff,
|
||||
// IDE
|
||||
@ -58,13 +56,12 @@ type
|
||||
{ TDiskDiffsDlg }
|
||||
|
||||
TDiskDiffsDlg = class(TForm)
|
||||
BtnPanel: TPanel;
|
||||
BtnPanel: TButtonPanel;
|
||||
CheckDiskChangesWithLoadingCheckBox: TCheckBox;
|
||||
AutoCheckModifiedFilesCheckBox: TCheckBox;
|
||||
DiffSynEdit: TSynEdit;
|
||||
FilesListBox: TCheckListBox;
|
||||
RevertButton: TButton;
|
||||
IgnoreDiskChangesButton: TButton;
|
||||
WarnLabel: TLabel;
|
||||
WarnSpeedButton: TSpeedButton;
|
||||
Splitter: TSplitter;
|
||||
SynDiffSyn1: TSynDiffSyn;
|
||||
procedure FilesListBoxClick(Sender: TObject);
|
||||
@ -73,7 +70,9 @@ type
|
||||
FIgnoreList: TFPList;
|
||||
FPackageList: TStringList;
|
||||
FUnitList: TFPList;
|
||||
FHasLocalModifications: Boolean;
|
||||
FCachedDiffs: TFPList; // List of PDiffItem
|
||||
procedure AddFile2Box(AInfo: TObject; AFileName: string; AModified: Boolean);
|
||||
procedure FillFilesListBox;
|
||||
procedure ApplyChecks;
|
||||
procedure ShowDiff;
|
||||
@ -97,29 +96,22 @@ implementation
|
||||
var
|
||||
DiskDiffsDlg: TDiskDiffsDlg = nil;
|
||||
|
||||
function ShowDiskDiffsDialog(AnUnitList: TFPList; APackageList: TStringList;
|
||||
AnIgnoreList: TFPList): TModalResult;
|
||||
// Procedures used by ShowDiskDiffsDialog
|
||||
|
||||
function ListsAreEmpty: boolean;
|
||||
begin
|
||||
Result:=((AnUnitList=nil) or (AnUnitList.Count=0))
|
||||
and ((APackageList=nil) or (APackageList.Count=0));
|
||||
end;
|
||||
|
||||
procedure CheckUnitsWithLoading;
|
||||
var
|
||||
procedure CheckUnitsWithLoading(AnUnitList: TFPList);
|
||||
var
|
||||
i: Integer;
|
||||
CurUnit: TUnitInfo;
|
||||
Changed: Boolean;
|
||||
CodeOk: Boolean;
|
||||
MemCode: TCodeBuffer;
|
||||
s, DiskEncoding, MemEncoding: String;
|
||||
fs: TFileStreamUTF8;
|
||||
begin
|
||||
for i:=AnUnitList.Count-1 downto 0 do
|
||||
begin
|
||||
if AnUnitList=nil then exit;
|
||||
for i:=AnUnitList.Count-1 downto 0 do begin
|
||||
CurUnit:=TUnitInfo(AnUnitList[i]);
|
||||
MemCode:=CurUnit.Source;
|
||||
Changed:=true;
|
||||
CodeOk:=false;
|
||||
try
|
||||
fs := TFileStreamUTF8.Create(MemCode.Filename, fmOpenRead or fmShareDenyNone);
|
||||
try
|
||||
@ -136,7 +128,7 @@ function ShowDiskDiffsDialog(AnUnitList: TFPList; APackageList: TStringList;
|
||||
and (DiskEncoding=MemCode.DiskEncoding)
|
||||
and (length(s)=MemCode.SourceLength)
|
||||
and (s=MemCode.Source) then begin
|
||||
Changed:=false;
|
||||
CodeOk:=true;
|
||||
end;
|
||||
finally
|
||||
fs.Free;
|
||||
@ -144,29 +136,30 @@ function ShowDiskDiffsDialog(AnUnitList: TFPList; APackageList: TStringList;
|
||||
except
|
||||
// unable to load
|
||||
end;
|
||||
if not Changed then begin
|
||||
if (CurUnit.Source<>nil) then CurUnit.Source.MakeFileDateValid;
|
||||
if CodeOk then begin
|
||||
if CurUnit.Source<>nil then
|
||||
CurUnit.Source.MakeFileDateValid;
|
||||
AnUnitList.Delete(i);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure CheckPackagesWithLoading;
|
||||
var
|
||||
procedure CheckPackagesWithLoading(APackageList: TStringList);
|
||||
var
|
||||
i: Integer;
|
||||
CurPackage: TLazPackage;
|
||||
PackageDidNotChange: Boolean;
|
||||
PackageOk: Boolean;
|
||||
fs: TFileStreamUTF8;
|
||||
CurSource, DiskSource: string;
|
||||
AltFilename: String;
|
||||
begin
|
||||
for i:=APackageList.Count-1 downto 0 do
|
||||
begin
|
||||
if APackageList=nil then exit;
|
||||
for i:=APackageList.Count-1 downto 0 do begin
|
||||
AltFilename:=APackageList[i];
|
||||
CurPackage:=TLazPackage(APackageList.Objects[i]);
|
||||
PackageDidNotChange:=false;
|
||||
PackageOk:=false;
|
||||
if CurPackage.LPKSource=nil then
|
||||
continue;// this package was not loaded/saved
|
||||
continue; // this package was not loaded/saved
|
||||
if CompareFilenames(CurPackage.Filename,AltFilename)<>0 then
|
||||
continue; // lpk has vanished, an alternative lpk was found => show
|
||||
try
|
||||
@ -178,31 +171,38 @@ function ShowDiskDiffsDialog(AnUnitList: TFPList; APackageList: TStringList;
|
||||
SetLength(DiskSource,fs.Size);
|
||||
fs.Read(DiskSource[1],length(DiskSource));
|
||||
if DiskSource=CurSource then
|
||||
PackageDidNotChange:=true;
|
||||
PackageOk:=true;
|
||||
end;
|
||||
finally
|
||||
fs.Free;
|
||||
end;
|
||||
except
|
||||
// unable to load
|
||||
on E: Exception do begin
|
||||
on E: Exception do
|
||||
DebugLn(['CheckPackagesWithLoading Filename=',CurPackage.Filename,' Error=',E.Message]);
|
||||
end;
|
||||
end;
|
||||
if PackageDidNotChange then begin
|
||||
if PackageOk then
|
||||
APackageList.Delete(i);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function ShowDiskDiffsDialog(AnUnitList: TFPList; APackageList: TStringList;
|
||||
AnIgnoreList: TFPList): TModalResult;
|
||||
|
||||
function ListsAreEmpty: boolean;
|
||||
begin
|
||||
Result:=((AnUnitList=nil) or (AnUnitList.Count=0))
|
||||
and ((APackageList=nil) or (APackageList.Count=0));
|
||||
end;
|
||||
|
||||
begin
|
||||
if (DiskDiffsDlg<>nil) or ListsAreEmpty then begin
|
||||
Result:=mrIgnore;
|
||||
exit;
|
||||
end;
|
||||
if (DiskDiffsDlg<>nil) or ListsAreEmpty then
|
||||
exit(mrIgnore);
|
||||
if EnvironmentOptions.CheckDiskChangesWithLoading then begin
|
||||
CheckUnitsWithLoading;
|
||||
CheckPackagesWithLoading;
|
||||
if Assigned(AnUnitList) then
|
||||
CheckUnitsWithLoading(AnUnitList);
|
||||
if Assigned(APackageList) then
|
||||
CheckPackagesWithLoading(APackageList);
|
||||
if ListsAreEmpty then exit(mrIgnore);
|
||||
end;
|
||||
DiskDiffsDlg:=TDiskDiffsDlg.Create(nil);
|
||||
@ -211,10 +211,13 @@ begin
|
||||
DiskDiffsDlg.IgnoreList:=AnIgnoreList;
|
||||
DiskDiffsDlg.FillFilesListBox;
|
||||
Result:=DiskDiffsDlg.ShowModal;
|
||||
if Result=mrYes then
|
||||
DiskDiffsDlg.ApplyChecks;
|
||||
case Result of
|
||||
mrOK : DiskDiffsDlg.ApplyChecks;
|
||||
mrCancel : Result:=mrIgnore;
|
||||
end;
|
||||
DiskDiffsDlg.Free;
|
||||
DiskDiffsDlg:=nil;
|
||||
Assert(Result in [mrOK,mrIgnore], 'ShowDiskDiffsDialog: Invalid result '+IntToStr(Result));
|
||||
end;
|
||||
|
||||
{ TDiskDiffsDlg }
|
||||
@ -227,42 +230,47 @@ end;
|
||||
procedure TDiskDiffsDlg.FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
begin
|
||||
EnvironmentOptions.CheckDiskChangesWithLoading:=CheckDiskChangesWithLoadingCheckBox.Checked;
|
||||
EnvironmentOptions.DiskChangesAutoCheckModified:=AutoCheckModifiedFilesCheckBox.Checked;
|
||||
end;
|
||||
|
||||
procedure TDiskDiffsDlg.AddFile2Box(AInfo: TObject; AFileName: string; AModified: Boolean);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
if AModified then
|
||||
AFileName:='*'+AFileName;
|
||||
i:=FilesListBox.Items.AddObject(AFileName,AInfo);
|
||||
if AModified then
|
||||
FHasLocalModifications:=True
|
||||
else
|
||||
FilesListBox.Checked[i]:=True;
|
||||
end;
|
||||
|
||||
procedure TDiskDiffsDlg.FillFilesListBox;
|
||||
var i, ii: integer;
|
||||
AnUnitInfo: TUnitInfo;
|
||||
var
|
||||
i: integer;
|
||||
UInfo: TUnitInfo;
|
||||
APackage: TLazPackage;
|
||||
AFileName: string;
|
||||
begin
|
||||
FHasLocalModifications:=False;
|
||||
FilesListBox.Items.BeginUpdate;
|
||||
FilesListBox.Items.Clear;
|
||||
if UnitList<>nil then
|
||||
begin
|
||||
for i:=0 to UnitList.Count-1 do begin
|
||||
AnUnitInfo:=TUnitInfo(UnitList[i]);
|
||||
AFileName:=AnUnitInfo.ShortFilename;
|
||||
if AnUnitInfo.Modified then
|
||||
AFileName:='*'+AFileName;
|
||||
ii := FilesListBox.Items.AddObject(AFileName,AnUnitInfo);
|
||||
if AutoCheckModifiedFilesCheckBox.Checked or not AnUnitInfo.Modified then
|
||||
FilesListBox.Checked[ii] := True;
|
||||
UInfo:=TUnitInfo(UnitList[i]);
|
||||
AddFile2Box(UInfo, UInfo.ShortFilename, UInfo.Modified);
|
||||
end;
|
||||
end;
|
||||
if PackageList<>nil then
|
||||
begin
|
||||
for i:=0 to PackageList.Count-1 do begin
|
||||
APackage:=TLazPackage(PackageList.Objects[i]);
|
||||
AFileName:=APackage.Filename;
|
||||
if APackage.Modified then
|
||||
AFileName:='*'+AFileName;
|
||||
ii := FilesListBox.Items.AddObject(AFileName,APackage);
|
||||
if AutoCheckModifiedFilesCheckBox.Checked or not APackage.Modified then
|
||||
FilesListBox.Checked[ii] := True;
|
||||
AddFile2Box(APackage, APackage.Filename, APackage.Modified);
|
||||
end;
|
||||
end;
|
||||
FilesListBox.Items.EndUpdate;
|
||||
WarnSpeedButton.Visible:=FHasLocalModifications;
|
||||
WarnLabel.Visible:=FHasLocalModifications;
|
||||
end;
|
||||
|
||||
procedure TDiskDiffsDlg.ShowDiff;
|
||||
@ -375,15 +383,19 @@ begin
|
||||
Caption:=lisDiskDiffSomeFilesHaveChangedOnDisk;
|
||||
EditorOpts.GetSynEditSettings(DiffSynEdit);
|
||||
DiffSynEdit.Lines.Text:=lisDiskDiffClickOnOneOfTheAboveItemsToSeeTheDiff;
|
||||
RevertButton.Caption:=lisDiskDiffReloadCheckedFilesFromDisk;
|
||||
IgnoreDiskChangesButton.Caption:=lisDiskDiffIgnoreAllDiskChanges;
|
||||
|
||||
BtnPanel.OkButton.Caption:=lisDiskDiffReloadCheckedFilesFromDisk;
|
||||
Assert(BtnPanel.OKButton.ModalResult=mrOK, 'OKButton.ModalResult<>mrOK');
|
||||
// Cancel button now means Ignore All Disk Changes
|
||||
BtnPanel.CancelButton.Caption:=lisDiskDiffIgnoreAllDiskChanges;
|
||||
|
||||
IDEImages.AssignImage(WarnSpeedButton, 'state_warning');
|
||||
WarnLabel.Caption:=lisDiskDiffSomeFilesChangedLocally;
|
||||
WarnLabel.Visible:=False;
|
||||
WarnSpeedButton.Visible:=False;
|
||||
|
||||
CheckDiskChangesWithLoadingCheckBox.Caption:=lisCheckForDiskFileChangesViaContent;
|
||||
CheckDiskChangesWithLoadingCheckBox.Checked:=EnvironmentOptions.CheckDiskChangesWithLoading;
|
||||
AutoCheckModifiedFilesCheckBox.Caption:=lisAutoCheckModifiedFiles;
|
||||
AutoCheckModifiedFilesCheckBox.Checked:=EnvironmentOptions.DiskChangesAutoCheckModified;
|
||||
|
||||
DefaultControl:=RevertButton;
|
||||
CancelControl:=IgnoreDiskChangesButton;
|
||||
end;
|
||||
|
||||
procedure TDiskDiffsDlg.ApplyChecks;
|
||||
|
@ -613,7 +613,6 @@ type
|
||||
// hints
|
||||
FAskSaveSessionOnly: boolean;
|
||||
FCheckDiskChangesWithLoading: boolean;
|
||||
FDiskChangesAutoCheckModified: boolean;
|
||||
FShowHintsForComponentPalette: boolean;
|
||||
FShowHintsForMainSpeedButtons: boolean;
|
||||
|
||||
@ -887,8 +886,6 @@ type
|
||||
// hints
|
||||
property CheckDiskChangesWithLoading: boolean read FCheckDiskChangesWithLoading
|
||||
write FCheckDiskChangesWithLoading;
|
||||
property DiskChangesAutoCheckModified: boolean read FDiskChangesAutoCheckModified
|
||||
write FDiskChangesAutoCheckModified;
|
||||
property ShowHintsForComponentPalette: boolean read FShowHintsForComponentPalette
|
||||
write FShowHintsForComponentPalette;
|
||||
property ShowHintsForMainSpeedButtons: boolean read FShowHintsForMainSpeedButtons
|
||||
@ -2150,7 +2147,6 @@ begin
|
||||
|
||||
// hints
|
||||
FCheckDiskChangesWithLoading:=false;
|
||||
FDiskChangesAutoCheckModified:=false;
|
||||
FShowHintsForComponentPalette:=true;
|
||||
FShowHintsForMainSpeedButtons:=true;
|
||||
|
||||
@ -2639,7 +2635,6 @@ begin
|
||||
|
||||
// hints
|
||||
FCheckDiskChangesWithLoading:=FXMLCfg.GetValue(Path+'CheckDiskChangesWithLoading/Value',false);
|
||||
FDiskChangesAutoCheckModified:=FXMLCfg.GetValue(Path+'DiskChangesAutoCheckModified/Value',false);
|
||||
FShowHintsForComponentPalette:=FXMLCfg.GetValue(Path+'ShowHintsForComponentPalette/Value',true);
|
||||
FShowHintsForMainSpeedButtons:=FXMLCfg.GetValue(Path+'ShowHintsForMainSpeedButtons/Value',true);
|
||||
|
||||
@ -3007,7 +3002,6 @@ begin
|
||||
|
||||
// hints
|
||||
FXMLCfg.SetDeleteValue(Path+'CheckDiskChangesWithLoading/Value',FCheckDiskChangesWithLoading,false);
|
||||
FXMLCfg.SetDeleteValue(Path+'DiskChangesAutoCheckModified/Value',FDiskChangesAutoCheckModified,false);
|
||||
FXMLCfg.SetDeleteValue(Path+'ShowHintsForComponentPalette/Value',FShowHintsForComponentPalette,true);
|
||||
FXMLCfg.SetDeleteValue(Path+'ShowHintsForMainSpeedButtons/Value',FShowHintsForMainSpeedButtons,true);
|
||||
|
||||
|
@ -1299,9 +1299,8 @@ resourcestring
|
||||
lisElevateTheMessagePriorityToAlwaysShowItByDefaultIt = 'Elevate the message'
|
||||
+' priority to always show it (by default it has low priority "verbose")';
|
||||
lisMessagesWindow = 'Messages Window';
|
||||
lisCheckForDiskFileChangesViaContent = 'Check for disk file changes via content '
|
||||
+'rather than timestamp';
|
||||
lisAutoCheckModifiedFiles = 'Automatically check (select) modified files';
|
||||
lisCheckForDiskFileChangesViaContent =
|
||||
'Check for disk file changes via content rather than timestamp';
|
||||
lisSlowerButMoreAccurate = 'Slower but more accurate.';
|
||||
|
||||
// Search dialog
|
||||
@ -4254,6 +4253,8 @@ resourcestring
|
||||
lisDiskDiffSomeFilesHaveChangedOnDisk = 'Some files have changed on disk:';
|
||||
lisDiskDiffClickOnOneOfTheAboveItemsToSeeTheDiff = 'Click on one of the '
|
||||
+'above items to see the diff';
|
||||
lisDiskDiffSomeFilesChangedLocally = 'Some files changed locally.'
|
||||
+' Either local or external changes will be overwritten.';
|
||||
lisDiskDiffReloadCheckedFilesFromDisk = 'Reload checked files from disk';
|
||||
lisDiskDiffIgnoreAllDiskChanges = 'Ignore all disk changes';
|
||||
|
||||
|
20
ide/main.pp
20
ide/main.pp
@ -8552,11 +8552,10 @@ begin
|
||||
Format(lisTheProjectInformationFileHasChangedOnDisk,[Project1.ProjectInfoFile,LineEnding]),
|
||||
mtConfirmation, [mrYes, lisReopenProject,
|
||||
mrIgnore], '') = mrYes
|
||||
then begin
|
||||
DoOpenProjectFile(Project1.ProjectInfoFile,[ofRevert]);
|
||||
end else begin
|
||||
then
|
||||
DoOpenProjectFile(Project1.ProjectInfoFile,[ofRevert])
|
||||
else
|
||||
Project1.IgnoreProjectInfoFileOnDisk;
|
||||
end;
|
||||
exit(mrOk);
|
||||
end;
|
||||
|
||||
@ -8564,23 +8563,24 @@ begin
|
||||
PkgBoss.GetPackagesChangedOnDisk(APackageList, True);
|
||||
if (AnUnitList=nil) and (APackageList=nil) then exit;
|
||||
Result:=ShowDiskDiffsDialog(AnUnitList,APackageList,AIgnoreList);
|
||||
if Result in [mrYes,mrYesToAll] then
|
||||
Result:=mrOk;
|
||||
|
||||
// reload units
|
||||
if AnUnitList<>nil then begin
|
||||
for i:=0 to AnUnitList.Count-1 do begin
|
||||
CurUnit:=TUnitInfo(AnUnitList[i]);
|
||||
//DebugLn(['DoCheckFilesOnDisk revert ',CurUnit.Filename,' EditorIndex=',CurUnit.EditorIndex]);
|
||||
if (Result=mrOk)
|
||||
and (AIgnoreList.IndexOf(CurUnit)<0) then // ignore current
|
||||
begin
|
||||
if CurUnit.OpenEditorInfoCount > 0 then begin
|
||||
if CurUnit.OpenEditorInfoCount > 0 then
|
||||
begin
|
||||
// Revert one Editor-View, the others follow
|
||||
Result:=OpenEditorFile(CurUnit.Filename, CurUnit.OpenEditorInfo[0].PageIndex,
|
||||
CurUnit.OpenEditorInfo[0].WindowID, nil, [ofRevert], True);
|
||||
//DebugLn(['DoCheckFilesOnDisk OpenEditorFile=',Result]);
|
||||
end else if CurUnit.IsMainUnit then begin
|
||||
// Reload the form file in designer if there is one
|
||||
if Assigned(CurUnit.Component) then
|
||||
LoadLFM(CurUnit,[ofOnlyIfExists,ofRevert],[]);
|
||||
end else if CurUnit.IsMainUnit then
|
||||
begin
|
||||
Result:=RevertMainUnit;
|
||||
//DebugLn(['DoCheckFilesOnDisk RevertMainUnit=',Result]);
|
||||
end else
|
||||
|
@ -268,6 +268,7 @@ type
|
||||
this attribute contains the component name,
|
||||
even if the unit is not loaded, or the designer form is not created.
|
||||
A component can be for example a TForm or a TDataModule }
|
||||
fComponentLFMLoadDate: longint; // Load time of associated LFM form file.
|
||||
fComponentResourceName: string;
|
||||
FComponentLastBinStreamSize: TStreamSeekType;
|
||||
FComponentLastLFMStreamSize: TStreamSeekType;
|
||||
@ -303,6 +304,7 @@ type
|
||||
FSetBookmarLock: Integer;
|
||||
FUnitResourceFileformat: TUnitResourcefileFormatClass;
|
||||
|
||||
function ComponentLFMOnDiskHasChanged: boolean;
|
||||
function GetEditorInfo(Index: Integer): TUnitEditorInfo;
|
||||
function GetHasResources: boolean;
|
||||
function GetModified: boolean;
|
||||
@ -332,6 +334,7 @@ type
|
||||
procedure SetRunFileIfActive(const AValue: boolean);
|
||||
procedure SetSessionModified(const AValue: boolean);
|
||||
procedure SetSource(ABuffer: TCodeBuffer);
|
||||
procedure SetTimeStamps;
|
||||
procedure SetUserReadOnly(const NewValue: boolean);
|
||||
protected
|
||||
function GetFileName: string; override;
|
||||
@ -2142,20 +2145,43 @@ begin
|
||||
Result:=FRevertLockCount>0;
|
||||
end;
|
||||
|
||||
function TUnitInfo.ComponentLFMOnDiskHasChanged: boolean;
|
||||
// Associated LFM resource file on disk has changed since last load/save
|
||||
var
|
||||
ResFilename: String;
|
||||
begin
|
||||
if fComponentLFMLoadDate=0 then Exit(false); // 0 means there is no LFM file.
|
||||
ResFilename:=UnitResourceFileformat.GetUnitResourceFilename(Filename,true);
|
||||
Result:=fComponentLFMLoadDate<>FileAgeCached(ResFilename);
|
||||
if Result then
|
||||
DebugLn(['TUnitInfo.ComponentLFMOnDiskHasChanged ', ResFilename, ' changed on disk.']);
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.SetTimeStamps;
|
||||
var
|
||||
ResFilename: String;
|
||||
begin
|
||||
fSourceChangeStep:=FSource.ChangeStep; // Indicates any change is source
|
||||
// Associated LFM resource file timestamp
|
||||
//if Component=nil then exit; <- Component is here always nil for some reason.
|
||||
ResFilename:=UnitResourceFileformat.GetUnitResourceFilename(Filename,true);
|
||||
if FileExistsCached(ResFilename) then
|
||||
fComponentLFMLoadDate:=FileAgeCached(ResFilename);
|
||||
end;
|
||||
|
||||
function TUnitInfo.ChangedOnDisk(CompareOnlyLoadSaveTime: boolean;
|
||||
IgnoreModifiedFlag: boolean): boolean;
|
||||
begin
|
||||
Result:=(Source<>nil) and Source.FileOnDiskHasChanged(IgnoreModifiedFlag);
|
||||
//if Result then debugln(['TUnitInfo.ChangedOnDisk ',Filename,' FileAgeCached=',FileAgeCached(Source.Filename)]);
|
||||
if not Result then
|
||||
Result:=ComponentLFMOnDiskHasChanged;
|
||||
if Result
|
||||
and (not CompareOnlyLoadSaveTime)
|
||||
and FIgnoreFileDateOnDiskValid
|
||||
and (FIgnoreFileDateOnDisk=Source.FileDateOnDisk) then
|
||||
Result:=false;
|
||||
if (not IsVirtual) and FileExistsCached(Filename) then
|
||||
FileReadOnly:=not FileIsWritableCached(Filename)
|
||||
else
|
||||
FileReadOnly:=false;
|
||||
FileReadOnly:=(not IsVirtual) and FileExistsCached(Filename)
|
||||
and not FileIsWritableCached(Filename);
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.IgnoreCurrentFileDateOnDisk;
|
||||
@ -2391,7 +2417,7 @@ procedure TUnitInfo.SetSource(ABuffer: TCodeBuffer);
|
||||
begin
|
||||
if fSource=ABuffer then begin
|
||||
if fSource<>nil then
|
||||
fSourceChangeStep:=FSource.ChangeStep;
|
||||
SetTimeStamps;
|
||||
exit;
|
||||
end;
|
||||
if (fSource<>nil) and IsAutoRevertLocked then
|
||||
@ -2399,7 +2425,7 @@ begin
|
||||
fSource:=ABuffer;
|
||||
FIgnoreFileDateOnDiskValid:=false;
|
||||
if (fSource<>nil) then begin
|
||||
fSourceChangeStep:=FSource.ChangeStep;
|
||||
SetTimeStamps;
|
||||
if IsAutoRevertLocked then
|
||||
fSource.LockAutoDiskRevert;
|
||||
SetInternalFilename(fSource.FileName);
|
||||
@ -2624,7 +2650,7 @@ begin
|
||||
{$ENDIF}
|
||||
fModified:=AValue;
|
||||
if (not fModified) and Assigned(Source) then
|
||||
fSourceChangeStep:=Source.ChangeStep;
|
||||
SetTimeStamps;
|
||||
end;
|
||||
|
||||
procedure TUnitInfo.SetProject(const AValue: TProject);
|
||||
|
Loading…
Reference in New Issue
Block a user