implemented Clean Directories

git-svn-id: trunk@4859 -
This commit is contained in:
mattias 2003-11-28 23:24:57 +00:00
parent b9551298a1
commit f8bf653343
11 changed files with 737 additions and 21 deletions

3
.gitattributes vendored
View File

@ -355,6 +355,9 @@ ide/checkcompileropts.pas svneol=native#text/pascal
ide/checklfmdlg.lfm svneol=native#text/plain
ide/checklfmdlg.lrs svneol=native#text/pascal
ide/checklfmdlg.pas svneol=native#text/pascal
ide/cleandirdlg.lfm svneol=native#text/plain
ide/cleandirdlg.lrs svneol=native#text/pascal
ide/cleandirdlg.pas svneol=native#text/pascal
ide/clipboardhistory.pas svneol=native#text/pascal
ide/codeexplorer.lfm svneol=native#text/plain
ide/codeexplorer.lrs svneol=native#text/pascal

164
ide/cleandirdlg.lfm Normal file
View File

@ -0,0 +1,164 @@
object CleanDirectoryDialog: TCleanDirectoryDialog
CAPTION = 'Clean Directory'
CLIENTHEIGHT = 345
CLIENTWIDTH = 502
ONCREATE = CleanDirectoryDialogCreate
HORZSCROLLBAR.PAGE = 503
VERTSCROLLBAR.PAGE = 346
LEFT = 316
HEIGHT = 345
TOP = 212
WIDTH = 502
object OkButton: TBUTTON
ANCHORS = [aktop, akleft]
CAPTION = 'Ok'
TABSTOP = True
TABORDER = 0
ONCLICK = OkButtonClick
LEFT = 128
HEIGHT = 25
TOP = 312
WIDTH = 97
end
object CancelButton: TBUTTON
ANCHORS = [aktop, akleft]
MODALRESULT = 2
CAPTION = 'Cancel'
TABSTOP = True
TABORDER = 1
LEFT = 269
HEIGHT = 25
TOP = 312
WIDTH = 97
end
object DirGroupbox: TGROUPBOX
ANCHORS = [aktop, akleft, akright]
CAPTION = 'Directory'
CLIENTHEIGHT = 63
CLIENTWIDTH = 482
COLOR = -2147483633
PARENTCOLOR = True
PARENTCTL3D = False
TABORDER = 2
LEFT = 8
HEIGHT = 80
TOP = 8
WIDTH = 486
object DirCombobox: TCOMBOBOX
ANCHORS = [aktop, akleft, akright]
MAXLENGTH = 0
PARENTCTL3D = False
TABORDER = 0
TABSTOP = True
TEXT = 'DirCombobox'
LEFT = 6
HEIGHT = 25
TOP = 9
WIDTH = 468
end
object SubDirsCheckbox: TCHECKBOX
ALLOWGRAYED = True
ANCHORS = [aktop, akleft, akright]
AUTOSIZE = True
CAPTION = 'Clean sub directories'
DRAGCURSOR = 0
TABORDER = 1
TABSTOP = True
LEFT = 6
HEIGHT = 20
TOP = 39
WIDTH = 468
end
end
object RemoveGroupbox: TGROUPBOX
ANCHORS = [aktop, akleft, akright]
CAPTION = 'Remove files matching filter:'
CLIENTHEIGHT = 68
CLIENTWIDTH = 482
COLOR = -2147483633
PARENTCOLOR = True
PARENTCTL3D = False
TABORDER = 3
LEFT = 8
HEIGHT = 85
TOP = 96
WIDTH = 486
object RemoveCombobox: TCOMBOBOX
ANCHORS = [aktop, akleft, akright]
MAXLENGTH = 0
PARENTCTL3D = False
TABORDER = 0
TABSTOP = True
TEXT = 'RemoveCombobox'
LEFT = 6
HEIGHT = 25
TOP = 8
WIDTH = 468
end
object SimpleSyntaxRemoveCheckbox: TCHECKBOX
ALLOWGRAYED = True
ANCHORS = [aktop, akleft]
AUTOSIZE = True
CAPTION = 'Simple syntax (e.g. * instead of .*)'
DRAGCURSOR = 0
TABORDER = 1
TABSTOP = True
LEFT = 6
HEIGHT = 20
TOP = 37
WIDTH = 468
end
end
object KeepGroupbox: TGROUPBOX
ANCHORS = [aktop, akleft, akright]
CAPTION = 'Keep files matching filter:'
CLIENTHEIGHT = 89
CLIENTWIDTH = 482
COLOR = -2147483633
PARENTCOLOR = True
PARENTCTL3D = False
TABORDER = 4
LEFT = 8
HEIGHT = 106
TOP = 190
WIDTH = 486
object KeepCombobox: TCOMBOBOX
ANCHORS = [aktop, akleft, akright]
MAXLENGTH = 0
PARENTCTL3D = False
TABORDER = 0
TABSTOP = True
TEXT = 'KeepCombobox'
LEFT = 6
HEIGHT = 25
TOP = 8
WIDTH = 468
end
object SimpleSyntaxKeepCheckbox: TCHECKBOX
ALLOWGRAYED = True
ANCHORS = [aktop, akleft]
AUTOSIZE = True
CAPTION = 'Simple syntax (e.g. * instead of .*)'
DRAGCURSOR = 0
TABORDER = 1
TABSTOP = True
LEFT = 6
HEIGHT = 20
TOP = 35
WIDTH = 468
end
object KeepTextFilesCheckbox: TCHECKBOX
ALLOWGRAYED = True
ANCHORS = [aktop, akleft]
AUTOSIZE = True
CAPTION = 'Keep Text Files'
DRAGCURSOR = 0
TABORDER = 2
TABSTOP = True
LEFT = 6
HEIGHT = 20
TOP = 61
WIDTH = 468
end
end
end

48
ide/cleandirdlg.lrs Normal file
View File

@ -0,0 +1,48 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TCleanDirectoryDialog','FORMDATA',[
'TPF0'#21'TCleanDirectoryDialog'#20'CleanDirectoryDialog'#7'CAPTION'#6#15'Cle'
+'an Directory'#12'CLIENTHEIGHT'#3'Y'#1#11'CLIENTWIDTH'#3#246#1#8'ONCREATE'#7
+#26'CleanDirectoryDialogCreate'#18'HORZSCROLLBAR.PAGE'#3#247#1#18'VERTSCROLL'
+'BAR.PAGE'#3'Z'#1#4'LEFT'#3'<'#1#6'HEIGHT'#3'Y'#1#3'TOP'#3#212#0#5'WIDTH'#3
+#246#1#0#7'TBUTTON'#8'OkButton'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#7'CAPTION'
+#6#2'Ok'#7'TABSTOP'#9#8'TABORDER'#2#0#7'ONCLICK'#7#13'OkButtonClick'#4'LEFT'
+#3#128#0#6'HEIGHT'#2#25#3'TOP'#3'8'#1#5'WIDTH'#2'a'#0#0#7'TBUTTON'#12'Cancel'
+'Button'#7'ANCHORS'#11#5'aktop'#6'akleft'#0#11'MODALRESULT'#2#2#7'CAPTION'#6
+#6'Cancel'#7'TABSTOP'#9#8'TABORDER'#2#1#4'LEFT'#3#13#1#6'HEIGHT'#2#25#3'TOP'
+#3'8'#1#5'WIDTH'#2'a'#0#0#9'TGROUPBOX'#11'DirGroupbox'#7'ANCHORS'#11#5'aktop'
+#6'akleft'#7'akright'#0#7'CAPTION'#6#9'Directory'#12'CLIENTHEIGHT'#2'?'#11'C'
+'LIENTWIDTH'#3#226#1#5'COLOR'#4#15#0#0#128#11'PARENTCOLOR'#9#11'PARENTCTL3D'
+#8#8'TABORDER'#2#2#4'LEFT'#2#8#6'HEIGHT'#2'P'#3'TOP'#2#8#5'WIDTH'#3#230#1#0#9
+'TCOMBOBOX'#11'DirCombobox'#7'ANCHORS'#11#5'aktop'#6'akleft'#7'akright'#0#9
+'MAXLENGTH'#2#0#11'PARENTCTL3D'#8#8'TABORDER'#2#0#7'TABSTOP'#9#4'TEXT'#6#11
+'DirCombobox'#4'LEFT'#2#6#6'HEIGHT'#2#25#3'TOP'#2#9#5'WIDTH'#3#212#1#0#0#9'T'
+'CHECKBOX'#15'SubDirsCheckbox'#11'ALLOWGRAYED'#9#7'ANCHORS'#11#5'aktop'#6'ak'
+'left'#7'akright'#0#8'AUTOSIZE'#9#7'CAPTION'#6#21'Clean sub directories'#10
+'DRAGCURSOR'#2#0#8'TABORDER'#2#1#7'TABSTOP'#9#4'LEFT'#2#6#6'HEIGHT'#2#20#3'T'
+'OP'#2''''#5'WIDTH'#3#212#1#0#0#0#9'TGROUPBOX'#14'RemoveGroupbox'#7'ANCHORS'
+#11#5'aktop'#6'akleft'#7'akright'#0#7'CAPTION'#6#29'Remove files matching fi'
+'lter:'#12'CLIENTHEIGHT'#2'D'#11'CLIENTWIDTH'#3#226#1#5'COLOR'#4#15#0#0#128
+#11'PARENTCOLOR'#9#11'PARENTCTL3D'#8#8'TABORDER'#2#3#4'LEFT'#2#8#6'HEIGHT'#2
+'U'#3'TOP'#2'`'#5'WIDTH'#3#230#1#0#9'TCOMBOBOX'#14'RemoveCombobox'#7'ANCHORS'
+#11#5'aktop'#6'akleft'#7'akright'#0#9'MAXLENGTH'#2#0#11'PARENTCTL3D'#8#8'TAB'
+'ORDER'#2#0#7'TABSTOP'#9#4'TEXT'#6#14'RemoveCombobox'#4'LEFT'#2#6#6'HEIGHT'#2
+#25#3'TOP'#2#8#5'WIDTH'#3#212#1#0#0#9'TCHECKBOX'#26'SimpleSyntaxRemoveCheckb'
+'ox'#11'ALLOWGRAYED'#9#7'ANCHORS'#11#5'aktop'#6'akleft'#0#8'AUTOSIZE'#9#7'CA'
+'PTION'#6'$Simple syntax (e.g. * instead of .*)'#10'DRAGCURSOR'#2#0#8'TABORD'
+'ER'#2#1#7'TABSTOP'#9#4'LEFT'#2#6#6'HEIGHT'#2#20#3'TOP'#2'%'#5'WIDTH'#3#212#1
+#0#0#0#9'TGROUPBOX'#12'KeepGroupbox'#7'ANCHORS'#11#5'aktop'#6'akleft'#7'akri'
+'ght'#0#7'CAPTION'#6#27'Keep files matching filter:'#12'CLIENTHEIGHT'#2'Y'#11
+'CLIENTWIDTH'#3#226#1#5'COLOR'#4#15#0#0#128#11'PARENTCOLOR'#9#11'PARENTCTL3D'
+#8#8'TABORDER'#2#4#4'LEFT'#2#8#6'HEIGHT'#2'j'#3'TOP'#3#190#0#5'WIDTH'#3#230#1
+#0#9'TCOMBOBOX'#12'KeepCombobox'#7'ANCHORS'#11#5'aktop'#6'akleft'#7'akright'
+#0#9'MAXLENGTH'#2#0#11'PARENTCTL3D'#8#8'TABORDER'#2#0#7'TABSTOP'#9#4'TEXT'#6
+#12'KeepCombobox'#4'LEFT'#2#6#6'HEIGHT'#2#25#3'TOP'#2#8#5'WIDTH'#3#212#1#0#0
+#9'TCHECKBOX'#24'SimpleSyntaxKeepCheckbox'#11'ALLOWGRAYED'#9#7'ANCHORS'#11#5
+'aktop'#6'akleft'#0#8'AUTOSIZE'#9#7'CAPTION'#6'$Simple syntax (e.g. * instea'
+'d of .*)'#10'DRAGCURSOR'#2#0#8'TABORDER'#2#1#7'TABSTOP'#9#4'LEFT'#2#6#6'HEI'
+'GHT'#2#20#3'TOP'#2'#'#5'WIDTH'#3#212#1#0#0#9'TCHECKBOX'#21'KeepTextFilesChe'
+'ckbox'#11'ALLOWGRAYED'#9#7'ANCHORS'#11#5'aktop'#6'akleft'#0#8'AUTOSIZE'#9#7
+'CAPTION'#6#15'Keep Text Files'#10'DRAGCURSOR'#2#0#8'TABORDER'#2#2#7'TABSTOP'
+#9#4'LEFT'#2#6#6'HEIGHT'#2#20#3'TOP'#2'='#5'WIDTH'#3#212#1#0#0#0#0
]);

457
ide/cleandirdlg.pas Normal file
View File

@ -0,0 +1,457 @@
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
Author: Mattias Gaertner
Abstract:
A dialog for cleaning directories.
}
unit CleanDirDlg;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, Buttons,
StdCtrls, FileCtrl, Laz_XMLCfg, SynRegExpr,
LazarusIDEStrConsts, LazConf, IDEProcs, TransferMacros, ExtCtrls;
type
TCleanDirectoryDialog = class(TForm)
KeepTextFilesCheckbox: TCHECKBOX;
SubDirsCheckbox: TCHECKBOX;
SimpleSyntaxKeepCheckbox: TCHECKBOX;
KeepCombobox: TCOMBOBOX;
KeepGroupbox: TGROUPBOX;
SimpleSyntaxRemoveCheckbox: TCHECKBOX;
RemoveCombobox: TCOMBOBOX;
DirCombobox: TCOMBOBOX;
DirGroupbox: TGROUPBOX;
RemoveGroupbox: TGROUPBOX;
OkButton: TBUTTON;
CancelButton: TBUTTON;
procedure CleanDirectoryDialogCreate(Sender: TObject);
procedure OkButtonClick(Sender: TObject);
private
FMacros: TTransferMacroList;
procedure SetMacros(const AValue: TTransferMacroList);
public
procedure LoadSettings;
procedure SaveSettings;
function GetConfigFilename: string;
function SearchFilesToDelete(var List: TStrings): boolean;
function DeleteFiles(List: TStrings): boolean;
procedure AddDirectory(const Directory: string);
property Macros: TTransferMacroList read FMacros write SetMacros;
end;
TShowDeletingFilesDialog = class(TForm)
FilesListBox: TListBox;
OkButton: TBUTTON;
CancelButton: TBUTTON;
public
constructor Create(TheOwner: TComponent); override;
end;
function ShowCleanDirectoryDialog(const DefaultDirectory: string;
Macros: TTransferMacroList): TModalResult;
implementation
const
CleanDirXMLFilename = 'cleandirectorydialog.xml';
CleanDirXMLVersion = 1;
function ShowCleanDirectoryDialog(const DefaultDirectory: string;
Macros: TTransferMacroList): TModalResult;
var
CleanDirectoryDialog: TCleanDirectoryDialog;
begin
CleanDirectoryDialog:=TCleanDirectoryDialog.Create(Application);
CleanDirectoryDialog.Macros:=Macros;
CleanDirectoryDialog.LoadSettings;
CleanDirectoryDialog.AddDirectory(DefaultDirectory);
Result:=CleanDirectoryDialog.ShowModal;
CleanDirectoryDialog.Free;
end;
{ TCleanDirectoryDialog }
procedure TCleanDirectoryDialog.OkButtonClick(Sender: TObject);
var
List: TStrings;
begin
SaveSettings;
if not SearchFilesToDelete(List) then exit;
try
if not DeleteFiles(List) then exit;
finally
List.Free;
end;
ModalResult:=mrOk;
end;
procedure TCleanDirectoryDialog.SetMacros(const AValue: TTransferMacroList);
begin
if FMacros=AValue then exit;
FMacros:=AValue;
end;
procedure TCleanDirectoryDialog.CleanDirectoryDialogCreate(Sender: TObject);
begin
Caption:=lisClDirCleanDirectory;
DirGroupbox.Caption:=lisCodeToolsDefsInsertBehindDirectory;
SubDirsCheckbox.Caption:=lisClDirCleanSubDirectories;
RemoveGroupbox.Caption:=lisClDirRemoveFilesMatchingFilter;
SimpleSyntaxRemoveCheckbox.Caption:=lisClDirSimpleSyntaxEGInsteadOf;
KeepGroupbox.Caption:=lisClDirKeepFilesMatchingFilter;
SimpleSyntaxKeepCheckbox.Caption:=lisClDirSimpleSyntaxEGInsteadOf;
KeepTextFilesCheckbox.Caption:=lisClDirKeepAllTextFiles;
OkButton.Caption:=lisLazBuildOk;
CancelButton.Caption:=dlgCancel;
end;
procedure TCleanDirectoryDialog.LoadSettings;
var
XMLConfig: TXMLConfig;
procedure LoadComboList(AComboBox: TComboBox; const Path: string);
var
List: TStringList;
begin
List:=TStringList.Create;
LoadRecentList(XMLConfig,List,Path+'Directories');
AComboBox.Items.Assign(List);
List.Free;
end;
procedure AddStandardComboItem(AComboBox: TComboBox; const Item: string);
begin
if AComboBox.Items.IndexOf(Item)>=0 then exit;
AComboBox.Items.Add(Item);
AComboBox.ItemIndex:=0;
end;
var
Filename: String;
Path: String;
begin
try
Filename:=GetConfigFilename;
XMLConfig:=TXMLConfig.Create(Filename);
except
writeln('ERROR: unable to open clean directory options "',Filename,'"');
exit;
end;
try
try
Path:='CleanDirectoryOptions/';
//FileVersion:=XMLConfig.GetValue(Path+'Version/Value',0);
SubDirsCheckbox.Checked:=XMLConfig.GetValue(
Path+'SubDirectories/Value',false);
LoadComboList(DirCombobox,Path+'Directories');
LoadComboList(RemoveCombobox,Path+'RemoveFilters');
SimpleSyntaxRemoveCheckbox.Checked:=XMLConfig.GetValue(
Path+'RemoveFilter/SimpleSyntax',true);
LoadComboList(KeepCombobox,Path+'KeepFilters');
SimpleSyntaxKeepCheckbox.Checked:=XMLConfig.GetValue(
Path+'KeepFilter/SimpleSyntax',true);
KeepTextFilesCheckbox.Checked:=XMLConfig.GetValue(
Path+'KeepTextFiles/Value',true);
// set defaults
AddStandardComboItem(DirCombobox,'$(ProjPath)');
AddStandardComboItem(RemoveCombobox,'*.(bak|ppu|ppw|ppl|o|a|so|dll)');
AddStandardComboItem(RemoveCombobox,'*.bak|*~');
AddStandardComboItem(KeepCombobox,
'*.(pas|pp|lpr|lfm|lrs|lpi|lpk|inc|sh|xml)');
finally
XMLConfig.Free;
end;
except
on E: Exception do begin
writeln('ERROR: unable to read clean directory options from "',
Filename,'": ',E.Message);
end;
end;
end;
procedure TCleanDirectoryDialog.SaveSettings;
var
XMLConfig: TXMLConfig;
Filename: String;
Path: String;
begin
try
Filename:=GetConfigFilename;
XMLConfig:=TXMLConfig.CreateClean(Filename);
except
writeln('ERROR: unable to open clean directory options "',Filename,'"');
exit;
end;
try
try
Path:='CleanDirectoryOptions/';
XMLConfig.SetValue(Path+'Version/Value',CleanDirXMLVersion);
XMLConfig.SetDeleteValue(Path+'SubDirectories/Value',
SubDirsCheckbox.Checked,false);
SaveRecentList(XMLConfig,DirCombobox.Items,Path+'Directories');
SaveRecentList(XMLConfig,RemoveCombobox.Items,Path+'RemoveFilters');
XMLConfig.SetDeleteValue(Path+'RemoveFilter/SimpleSyntax',
SimpleSyntaxRemoveCheckbox.Checked,true);
SaveRecentList(XMLConfig,KeepCombobox.Items,Path+'KeepFilters');
XMLConfig.SetDeleteValue(Path+'KeepFilter/SimpleSyntax',
SimpleSyntaxKeepCheckbox.Checked,true);
XMLConfig.SetDeleteValue(Path+'KeepTextFiles/Value',
KeepTextFilesCheckbox.Checked,true);
XMLConfig.Flush;
finally
XMLConfig.Free;
end;
except
on E: Exception do begin
writeln('ERROR: unable to write clean directory options from "',
Filename,'": ',E.Message);
end;
end;
end;
function TCleanDirectoryDialog.GetConfigFilename: string;
begin
Result:=AppendPathDelim(GetPrimaryConfigPath)+CleanDirXMLFilename;
end;
function TCleanDirectoryDialog.SearchFilesToDelete(var List: TStrings): boolean;
var
RemoveFilterRegExpr: TRegExpr;
KeepFilterRegExpr: TRegExpr;
function FileMatches(const Filename: string): boolean;
var
ShortFilename: String;
begin
Result:=false;
ShortFilename:=ExtractFilename(Filename);
if (RemoveFilterRegExpr=nil)
or not RemoveFilterRegExpr.Exec(ExtractFilename(ShortFilename)) then exit;
if (KeepFilterRegExpr<>nil)
and KeepFilterRegExpr.Exec(ExtractFilename(ShortFilename)) then exit;
if KeepTextFilesCheckbox.Checked and FileIsText(Filename) then exit;
Result:=true;
end;
function SearchInDirectory(const MainDirectory: string;
Lvl: integer): boolean;
var
FileInfo: TSearchRec;
FullFilename: String;
begin
Result:=false;
if (not FileExists(MainDirectory)) or (Lvl>20) then exit;
if SysUtils.FindFirst(MainDirectory+FindMask,
faAnyFile,FileInfo)=0
then begin
repeat
// check if special file
if (FileInfo.Name='.') or (FileInfo.Name='..') then continue;
FullFilename:=MainDirectory+FileInfo.Name;
if (FileInfo.Attr and faDirectory)>0 then begin
if SubDirsCheckbox.Checked then begin
// search recursively
if not SearchInDirectory(AppendPathDelim(FullFilename),Lvl+1) then
break;
end;
end else begin
if FileMatches(FullFilename) then
List.Add(FullFilename);
end;
until SysUtils.FindNext(FileInfo)<>0;
end;
SysUtils.FindClose(FileInfo);
Result:=true;
end;
function SetupFilter(var Filter: TRegExpr; SimpleSyntax: boolean;
const FilterAsText: string): boolean;
var
Expr: String;
begin
Result:=false;
if FilterAsText='' then begin
Filter:=nil;
Result:=true;
exit;
end;
Filter:=TRegExpr.Create;
if SimpleSyntax then
Expr:=SimpleSyntaxToRegExpr(FilterAsText)
else
Expr:=FilterAsText;
try
Filter.Expression:=Expr;
Result:=true;
except
on E: Exception do begin
MessageDlg('Invalid Mask',
'The mask "'+FilterAsText+'" is not a valid expression.',
mtError,[mbCancel],0);
end;
end;
end;
var
Directory: String;
begin
Result:=false;
RemoveFilterRegExpr:=nil;
KeepFilterRegExpr:=nil;
List:=nil;
try
// get directory
Directory:=DirCombobox.Text;
if (Macros<>nil) and (not Macros.SubstituteStr(Directory)) then exit;
Directory:=AppendPathDelim(Directory);
// setup filters
SetupFilter(RemoveFilterRegExpr,SimpleSyntaxRemoveCheckbox.Checked,
RemoveCombobox.Text);
SetupFilter(KeepFilterRegExpr,SimpleSyntaxKeepCheckbox.Checked,
KeepCombobox.Text);
// search files
List:=TStringList.Create;
if not SearchInDirectory(Directory,0) then exit;
Result:=true;
finally
RemoveFilterRegExpr.Free;
KeepFilterRegExpr.Free;
if not Result then begin
List.Free;
List:=nil;
end;
end;
end;
function TCleanDirectoryDialog.DeleteFiles(List: TStrings): boolean;
var
i: Integer;
Filename: string;
MsgResult: TModalResult;
ShowDeletingFilesDialog: TShowDeletingFilesDialog;
begin
Result:=false;
if List.Count=0 then begin
Result:=true;
exit;
end;
// ask user for confirmation
ShowDeletingFilesDialog:=TShowDeletingFilesDialog.Create(Self);
try
ShowDeletingFilesDialog.FilesListBox.Items.Assign(List);
if ShowDeletingFilesDialog.ShowModal<>mrOk then exit;
finally
ShowDeletingFilesDialog.Free;
end;
// delete them all
for i:=0 to List.Count-1 do begin
Filename:=List[i];
writeln('Deleting file ',Filename);
if FileExists(Filename) then begin
repeat
if DeleteFile(Filename) then begin
break;
end else begin
MsgResult:=MessageDlg('Error deleting file',
'Unable to delete file "'+Filename+'".',
mtError,[mbAbort,mbIgnore,mbRetry],0);
if (MsgResult=mrIgnore) then break;
if MsgResult=mrAbort then exit;
end;
until false;
end;
end;
Result:=true;
end;
procedure TCleanDirectoryDialog.AddDirectory(const Directory: string);
begin
AddToRecentList(Directory,DirCombobox.Items,20);
end;
{ TShowDeletingFilesDialog }
constructor TShowDeletingFilesDialog.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
Caption:='Delete all these files?';
Width:=400;
Height:=350;
Position:=poScreenCenter;
FilesListBox:=TListBox.Create(Self);
with FilesListBox do begin
Name:='FilesListBox';
Parent:=Self;
Height:=Self.ClientHeight-40;
Align:=alTop;
Anchors:=[akLeft,akTop,akBottom,akRight];
end;
OkButton:=TButton.Create(Self);
with OkButton do begin
Name:='OkButton';
Parent:=Self;
Left:=20;
Top:=Self.ClientHeight-35;
Width:=100;
Height:=25;
Caption:='Delete';
ModalResult:=mrOk;
end;
CancelButton:=TButton.Create(Self);
with CancelButton do begin
Name:='CancelButton';
Parent:=Self;
Left:=150;
Top:=Self.ClientHeight-35;
Width:=100;
Height:=25;
Caption:='Cancel';
ModalResult:=mrCancel;
end;
end;
initialization
{$I cleandirdlg.lrs}
end.

View File

@ -116,13 +116,13 @@ function SearchDirectoryInSearchPath(const SearchPath, Directory: string;
DirStartPos: integer): integer;
// XMLConfig
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStringList;
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStringList;
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
function AddToRecentList(const s: string; RecentList: TStringList;
function AddToRecentList(const s: string; RecentList: TStrings;
Max: integer): boolean;
procedure RemoveFromRecentList(const s: string; RecentList: TStringList);
procedure RemoveFromRecentList(const s: string; RecentList: TStrings);
procedure LoadRect(XMLConfig: TXMLConfig; const Path:string; var ARect:TRect);
procedure SaveRect(XMLConfig: TXMLConfig; const Path:string; var ARect:TRect);
procedure LoadStringList(XMLConfig: TXMLConfig; List: TStrings;
@ -190,7 +190,7 @@ uses
{$ENDIF}
{$EndIf};
function AddToRecentList(const s: string; RecentList: TStringList;
function AddToRecentList(const s: string; RecentList: TStrings;
Max: integer): boolean;
begin
if (RecentList.Count>0) and (RecentList[0]=s) then begin
@ -206,7 +206,7 @@ begin
RecentList.Delete(RecentList.Count-1);
end;
procedure RemoveFromRecentList(const s: string; RecentList: TStringList);
procedure RemoveFromRecentList(const s: string; RecentList: TStrings);
var i: integer;
begin
i:=RecentList.Count-1;
@ -216,7 +216,7 @@ begin
end;
end;
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStringList;
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
begin
SaveStringList(XMLConfig,List,Path);
@ -722,7 +722,7 @@ begin
SysUtils.FindClose(FileInfo);
end;
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStringList;
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
begin
LoadStringList(XMLConfig,List,Path);

View File

@ -131,7 +131,8 @@ const
ecSaveAll = ecUserFirst + 209;
ecClose = ecUserFirst + 210;
ecCloseAll = ecUserFirst + 211;
ecQuit = ecUserFirst + 212;
ecCleanDirectory = ecUserFirst + 212;
ecQuit = ecUserFirst + 213;
// IDE navigation
ecJumpToEditor = ecUserFirst + 300;
@ -613,6 +614,7 @@ begin
ecSaveAll: SetResult(VK_S,[ssCtrl,ssShift],VK_UNKNOWN,[]);
ecClose: SetResult(VK_F4,[ssCtrl],VK_UNKNOWN,[]);
ecCloseAll: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
ecCleanDirectory: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
ecQuit: SetResult(VK_UNKNOWN,[],VK_UNKNOWN,[]);
// view menu
@ -1090,6 +1092,7 @@ begin
ecSaveAll : Result:= srkmecSaveAll;
ecClose : Result:= lismenuclose;
ecCloseAll : Result:= srkmecCloseAll;
ecCleanDirectory : Result:= lisMenuCleanDirectory;
ecQuit : Result:= lismenuquit;
// edit menu
@ -2020,6 +2023,7 @@ begin
AddDefault(C,'SaveAll',ecSaveAll);
AddDefault(C,'Close',ecClose);
AddDefault(C,'CloseAll',ecCloseAll);
AddDefault(C,'Clean Directory',ecCleanDirectory);
AddDefault(C,'Quit',ecQuit);
// view menu

View File

@ -117,6 +117,7 @@ resourcestring
lisMenuClose = 'Close';
lisMenuCloseAll = 'Close all editor files';
lisMenuQuit = 'Quit';
lisMenuCleanDirectory = 'Clean directory';
lisMenuUndo = 'Undo';
lisMenuRedo = 'Redo';
@ -544,7 +545,7 @@ resourcestring
+'Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.';
//IDE components
// IDE components
ideStandard = 'Standard';
ideAdditional = 'Additional';
ideMisc = 'Misc';
@ -553,10 +554,10 @@ resourcestring
ideDataAccess = 'Data Access';
ideInterbase = 'Interbase Data Access';
//Environment dialog
// Environment dialog
dlgBakDirectory='(no subdirectoy)';
//Search dialog
// Search dialog
dlgSearchCaption = 'Searching...';
dlgSearchAbort = 'Search terminated by user.';
@ -741,7 +742,7 @@ resourcestring
dlgIndentCodeTo = 'Indent code to';
dlgCodeToolsTab = 'Code Tools';
//CodeTools dialogue
// CodeTools dialog
dlgCodeToolsOpts = 'CodeTools Options';
dlgCodeCreation = 'Code Creation';
dlgWordsPolicies = 'Words';
@ -783,6 +784,7 @@ resourcestring
dlgInsSpaceAfter = 'Insert space after';
dlgWRDPreview = 'Preview';
// source editor
locwndSrcEditor = 'Lazarus Source Editor';
// compiler options
@ -945,7 +947,7 @@ resourcestring
dlgDownWord = 'Down';
dlgReplaceAll = 'Replace All';
//IDEOptionDefs
// IDEOptionDefs
dlgGetPosition = 'Get position';
dlgLeftPos = 'Left:';
dlgWidthPos = 'Width:';
@ -1087,6 +1089,7 @@ resourcestring
srkmecGotoMarker = 'Go to Marker %d';
srkmecSetMarker = 'Set Marker %d';
srkmecPeriod = 'period';
// sourcenotebook
srkmecJumpToEditor = 'Focus to source editor';
srkmecNextEditor = 'Go to next editor';
@ -1094,6 +1097,7 @@ resourcestring
srkmecMoveEditorLeft = 'Move editor left';
srkmecMoveEditorRight = 'Move editor right';
srkmecGotoEditor = 'Go to editor %d';
// file menu
srkmecNew = 'New';
srkmecNewUnit = 'New unit';
@ -1118,6 +1122,7 @@ resourcestring
srkmecInsertCVSName = 'Insert CVS keyword Name';
srkmecInsertCVSRevision = 'Insert CVS keyword Revision';
srkmecInsertCVSSource = 'Insert CVS keyword Source';
// search menu
srkmecFind = 'Find text';
srkmecFindNext = 'Find next';
@ -1130,6 +1135,7 @@ resourcestring
srkmecAddJumpPoint = 'Add jump point';
srkmecOpenFileAtCursor = 'Open file at cursor';
srkmecGotoIncludeDirective = 'Go to to include directive of current include file';
// view menu
srkmecToggleFormUnit = 'Switch between form and unit';
srkmecToggleObjectInsp = 'View Object Inspector';
@ -1145,6 +1151,7 @@ resourcestring
srkmecViewUnits = 'View units';
srkmecViewForms = 'View forms';
srkmecViewUnitDependencies = 'View unit dependencies';
// codetools
srkmecWordCompletion = 'Word completion';
srkmecCompletecode = 'Complete code';
@ -1154,7 +1161,6 @@ resourcestring
srkmecFindDeclaration = 'Find declaration';
srkmecFindBlockOtherEnd = 'Find block other end';
srkmecFindBlockStart = 'Find block start';
// project uuse menu resource
// run menu
srkmecBuild = 'build program/project';
@ -1169,10 +1175,12 @@ resourcestring
srkmecBuildFile = 'build file';
srkmecRunFile = 'run file';
srkmecConfigBuildFile = 'config build file';
// tools menu
srkmecExtToolSettings = 'External tools settings';
srkmecBuildLazarus = 'Build lazarus';
srkmecExtTool = 'External tool %d';
// environment menu
srkmecEnvironmentOptions = 'General environment options';
srkmecCodeToolsOptions = 'Codetools options';
@ -1180,6 +1188,7 @@ resourcestring
lisMenuRescanFPCSourceDirectory = 'Rescan FPC source directory';
srkmecMakeResourceString = 'Make resource string';
srkmecDiff = 'Diff';
// help menu
srkmecunknown = 'unknown editor command';
@ -1231,7 +1240,7 @@ resourcestring
srVK_SCROLL = 'Scroll';
srVK_IRREGULAR = 'Irregular ';
//Category
// Category
srkmCatCursorMoving = 'Cursor moving commands';
srkmCatSelection = 'Text selection commands';
srkmCatEditing = 'Text editing commands';
@ -1250,7 +1259,7 @@ resourcestring
srkmCarHelpMenu = 'Help menu commands';
lisKeyCatDesigner = 'Designer commands';
//Languages
// Languages
rsLanguageAutomatic = 'Automatic (or english)';
rsLanguageEnglish = 'English';
rsLanguageDeutsch = 'Deutsch';
@ -1262,7 +1271,7 @@ resourcestring
rsLanguageItalian = 'Italian';
rsLanguageCatalan = 'Catalan';
//Units dependencies
// Unit dependencies
dlgUnitDepCaption = 'Unit dependencies';
dlgUnitDepBrowse = 'Browse...';
dlgUnitDepRefresh = 'Refresh';
@ -1297,6 +1306,7 @@ resourcestring
lisLazBuildBuildJITForm = 'Build JITForm';
lisLazBuildWithStaticPackages = 'With Packages';
lisLazBuildOk = 'Ok';
lisClDirKeepAllTextFiles = 'Keep all text files';
lisLazBuildCancel = 'Cancel';
lisLazBuildNone = 'None';
lisLazBuildBuild = 'Build';
@ -1511,7 +1521,7 @@ resourcestring
lisDiffDlgIgnoreSpaces = 'Ignore spaces (newline chars not included)';
lisDiffDlgOpenDiffInEditor = 'Open Diff in editor';
//todolist
// todolist
lisTodoListCaption='ToDo List';
lisTodolistRefresh='Refresh todo items';
lisTodoListGotoLine='Goto selected source line';
@ -2271,6 +2281,13 @@ resourcestring
lisCTDefnoVariableSelected = '<no variable selected>';
lisCTDefVariableName = 'Variable Name';
// clean directory dialog
lisClDirCleanSubDirectories = 'Clean sub directories';
lisClDirRemoveFilesMatchingFilter = 'Remove files matching filter';
lisClDirSimpleSyntaxEGInsteadOf = 'Simple Syntax (e.g. * instead of .*)';
lisClDirKeepFilesMatchingFilter = 'Keep files matching filter';
lisClDirCleanDirectory = 'Clean Directory';
implementation
end.

View File

@ -81,7 +81,7 @@ uses
MiscOptions, InputHistory, UnitDependencies, ClipBoardHistory, ProcessList,
InitialSetupDlgs, NewDialog, MakeResStrDlg, ToDoList, AboutFrm, DialogProcs,
FindReplaceDialog, FindInFilesDlg, CodeExplorer, BuildFileDlg, ExtractProcDlg,
DelphiUnit2Laz,
DelphiUnit2Laz, CleanDirDlg,
// main ide
MainBar;
@ -110,6 +110,7 @@ type
procedure mnuSaveAllClicked(Sender : TObject);
procedure mnuCloseClicked(Sender : TObject);
procedure mnuCloseAllClicked(Sender : TObject);
procedure mnuCleanDirectoryClicked(Sender : TObject);
procedure mnuQuitClicked(Sender : TObject);
// edit menu
@ -1528,6 +1529,7 @@ begin
itmFileClose.OnClick := @mnuCloseClicked;
itmFileCloseAll.Enabled := False;
itmFileCloseAll.OnClick := @mnuCloseAllClicked;
itmFileCleanDirectory.OnClick := @mnuCleanDirectoryClicked;
itmFileQuit.OnClick := @mnuQuitClicked;
end;
@ -1847,6 +1849,11 @@ begin
[cfSaveFirst])=mrOk) do ;
end;
procedure TMainIDE.mnuCleanDirectoryClicked(Sender: TObject);
begin
ShowCleanDirectoryDialog(Project1.ProjectDirectory,MacroList);
end;
Procedure TMainIDE.OnSrcNotebookFileNew(Sender : TObject);
begin
mnuNewFormClicked(Sender);
@ -10206,6 +10213,9 @@ end.
{ =============================================================================
$Log$
Revision 1.678 2003/11/28 23:24:57 mattias
implemented Clean Directories
Revision 1.677 2003/11/28 10:33:43 mattias
fixed todolist by Bob

View File

@ -193,6 +193,7 @@ type
itmFileSaveAll: TMenuItem;
itmFileClose: TMenuItem;
itmFileCloseAll: TMenuItem;
itmFileCleanDirectory: TMenuItem;
itmFileQuit: TMenuItem;
// edit menu
@ -639,6 +640,13 @@ begin
mnuFile.Add(CreateMenuSeparator);
itmFileCleanDirectory := TMenuItem.Create(Self);
itmFileCleanDirectory.Name:='itmFileCleanDirectory';
itmFileCleanDirectory.Caption := lisMenuCleanDirectory;
mnuFile.Add(itmFileCleanDirectory);
mnuFile.Add(CreateMenuSeparator);
itmFileQuit := TMenuItem.Create(Self);
itmFileQuit.Name:='itmFileQuit';
itmFileQuit.Caption := lisMenuQuit;
@ -1428,6 +1436,7 @@ begin
itmFileSaveAll.ShortCut:=CommandToShortCut(ecSaveAll);
itmFileClose.ShortCut:=CommandToShortCut(ecClose);
itmFileCloseAll.ShortCut:=CommandToShortCut(ecCloseAll);
itmFileCleanDirectory.ShortCut:=CommandToShortCut(ecCleanDirectory);
itmFileQuit.ShortCut:=CommandToShortCut(ecQuit);
// edit menu

View File

@ -114,7 +114,7 @@ type
const
PublishModulOptsVersion = 2;
DefPublModIncFilter = '*.(pas|pp|inc|lpr|lfm|lrs|lpi|lpk|xml|fpc|sh)';
DefPublModIncFilter = '*.(pas|pp|inc|lpr|lfm|lrs|lpi|lpk|xml|sh)';
DefPublModExcFilter = '*.(bak|ppu|ppw|ppl|a|o|so);*~;backup';
DefPublishDirectory = '$(TestDir)/publishedproject/';

View File

@ -294,6 +294,7 @@ type
public
property ItemIndex;
published
property Align;
property Anchors;
property ArrowKeysTraverseList;
property AutoDropDown;
@ -1462,6 +1463,9 @@ end.
{ =============================================================================
$Log$
Revision 1.112 2003/11/28 23:24:57 mattias
implemented Clean Directories
Revision 1.111 2003/11/27 19:40:34 mattias
added TListBox.PopupMenu