IDE: recent/history lists: replaced case sensitive comparison with three types

git-svn-id: trunk@37020 -
This commit is contained in:
mattias 2012-04-25 09:03:37 +00:00
parent 8dcc79e336
commit 458181f496
14 changed files with 200 additions and 124 deletions

View File

@ -2366,6 +2366,7 @@ begin
end;
end;
end;
// check missing 'do' after 'with'
if CurrentIdentifierList.StartUpAtomInFrontIs('WITH')
and (not CurrentIdentifierList.StartUpAtomBehindIs('DO'))
and (CurrentIdentifierList.StartBracketLvl=0)

View File

@ -5,10 +5,9 @@ unit BreakPropertyDlg;
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs,
ExtCtrls, StdCtrls, ButtonPanel, EditBtn, Spin,
IDEHelpIntf, BreakPropertyDlgGroups,
DebuggerDlg, Debugger, BaseDebugManager, LazarusIDEStrConsts, InputHistory;
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
ButtonPanel, EditBtn, Spin, IDEHelpIntf, BreakPropertyDlgGroups, DebuggerDlg,
Debugger, BaseDebugManager, LazarusIDEStrConsts, InputHistory, IDEProcs;
type
@ -277,7 +276,8 @@ begin
FBreakpoint.LogMessage := edtLogMessage.Text;
FBreakpoint.LogCallStackLimit := edtLogCallStack.Value;
InputHistories.HistoryLists.GetList('BreakPointExpression', True).Add(edtCondition.Text);
InputHistories.HistoryLists.GetList('BreakPointExpression', True,
rltCaseSensitive).Add(edtCondition.Text);
finally
EnableGroupList.Free;
DisableGroupList.Free;
@ -417,7 +417,8 @@ begin
chkLogCallStack.Caption := lisLogCallStack;
lblLogCallStackLimit.Caption := lisLogCallStackLimit;
chkTakeSnap.Caption := lisTakeSnapshot;
edtCondition.Items.Assign(InputHistories.HistoryLists.GetList('BreakPointExpression', True));
edtCondition.Items.Assign(InputHistories.HistoryLists.GetList(
'BreakPointExpression', True,rltCaseSensitive));
FBreakpoint := ABreakPoint;
FBreakpointsNotification := TIDEBreakPointsNotification.Create;

View File

@ -40,7 +40,7 @@ uses
Classes, SysUtils, LCLType, Forms,
IDEWindowIntf, IDEImagesIntf, LazarusIDEStrConsts,
ComCtrls, StdCtrls, DebuggerDlg, BaseDebugManager,
InputHistory, Debugger, DebuggerStrConst;
InputHistory, IDEProcs, Debugger, DebuggerStrConst;
type
@ -96,7 +96,8 @@ begin
inherited Create(TheOwner);
Caption := lisKMEvaluateModify;
cmbExpression.Items.Assign(InputHistories.HistoryLists.GetList(ClassName, True));
cmbExpression.Items.Assign(InputHistories.HistoryLists.
GetList(ClassName,True,rltCaseSensitive));
tbEvaluate.Caption := lisEvaluate;
tbModify.Caption := lisModify;
@ -122,7 +123,7 @@ var
Opts: TDBGEvaluateFlags;
begin
S := cmbExpression.Text;
InputHistories.HistoryLists.Add(ClassName, S);
InputHistories.HistoryLists.Add(ClassName, S,rltCaseSensitive);
DBGType:=nil;
Opts := [];
if chkTypeCast.Checked then

View File

@ -36,7 +36,7 @@ uses
IDEDialogs, IDEImagesIntf,
// IDE
PackageDefs, PackageSystem, InputHistory, LazarusIDEStrConsts, Project,
DialogProcs;
DialogProcs, IDEProcs;
type
TBuildProjectDialogItem = class
@ -168,7 +168,8 @@ begin
StoreCombo(ProjSrcMaskComboBox);
StoreCombo(PkgOutMaskComboBox);
StoreCombo(PkgSrcMaskComboBox);
InputHistories.HistoryLists.GetList(hlCleanBuildFileMask,true).Assign(ProjOutMaskComboBox.Items);
InputHistories.HistoryLists.GetList(hlCleanBuildFileMask,true,
rltFile).Assign(ProjOutMaskComboBox.Items);
end;
procedure TCleanBuildProjectDialog.ButtonPanel1OKButtonClick(Sender: TObject);
@ -567,7 +568,7 @@ procedure TCleanBuildProjectDialog.Init(AProject: TProject);
var
List: THistoryList;
begin
List:=InputHistories.HistoryLists.GetList(hlCleanBuildFileMask,true);
List:=InputHistories.HistoryLists.GetList(hlCleanBuildFileMask,true,rltFile);
ProjOutMaskComboBox.Items.Assign(List);
ProjOutMaskComboBox.Text:=AProject.CleanOutputFileMask;
ProjSrcMaskComboBox.Items.Assign(List);

View File

@ -88,7 +88,7 @@ begin
CleanDirectoryDialog:=TCleanDirectoryDialog.Create(nil);
CleanDirectoryDialog.Macros:=Macros;
CleanDirectoryDialog.LoadSettings;
AddToRecentList(DefaultDirectory,CleanDirectoryDialog.DirCombobox.Items,20);
AddToRecentList(DefaultDirectory,CleanDirectoryDialog.DirCombobox.Items,20,rltFile);
CleanDirectoryDialog.DirComboBox.ItemIndex:=0;
Result:=CleanDirectoryDialog.ShowModal;
CleanDirectoryDialog.Free;
@ -162,12 +162,13 @@ procedure TCleanDirectoryDialog.LoadSettings;
var
XMLConfig: TXMLConfig;
procedure LoadComboList(AComboBox: TComboBox; const Path: string);
procedure LoadComboList(AComboBox: TComboBox; const Path: string;
ListType: TRecentListType);
var
List: TStringList;
begin
List:=TStringList.Create;
LoadRecentList(XMLConfig,List,Path);
LoadRecentList(XMLConfig,List,Path,ListType);
AComboBox.Items.Assign(List);
if AComboBox.Items.Count > 0 then
AComboBox.ItemIndex := 0;
@ -199,11 +200,11 @@ begin
SubDirsCheckbox.Checked:=XMLConfig.GetValue(
Path+'SubDirectories/Value',false);
LoadComboList(DirCombobox,Path+'Directories');
LoadComboList(RemoveCombobox,Path+'RemoveFilters');
LoadComboList(DirCombobox,Path+'Directories',rltFile);
LoadComboList(RemoveCombobox,Path+'RemoveFilters',rltFile);
SimpleSyntaxRemoveCheckbox.Checked:=XMLConfig.GetValue(
Path+'RemoveFilter/SimpleSyntax',true);
LoadComboList(KeepCombobox,Path+'KeepFilters');
LoadComboList(KeepCombobox,Path+'KeepFilters',rltFile);
SimpleSyntaxKeepCheckbox.Checked:=XMLConfig.GetValue(
Path+'KeepFilter/SimpleSyntax',true);
KeepTextFilesCheckbox.Checked:=XMLConfig.GetValue(
@ -233,9 +234,9 @@ var
Filename: String;
Path: String;
begin
AddComboTextToRecentList(DirCombobox, 20);
AddComboTextToRecentList(RemoveCombobox, 20);
AddComboTextToRecentList(KeepCombobox, 20);
AddComboTextToRecentList(DirCombobox, 20,rltFile);
AddComboTextToRecentList(RemoveCombobox, 20,rltFile);
AddComboTextToRecentList(KeepCombobox, 20,rltFile);
try
InvalidateFileStateCache;
Filename:=GetConfigFilename;

View File

@ -36,7 +36,7 @@ uses
SynEdit, DefineTemplates, ExprEval,
IDEWindowIntf, IDEHelpIntf,
EditorOptions, LazarusIDEStrConsts, InputHistory, CodeToolsOptions,
IDEContextHelpEdit;
IDEContextHelpEdit, IDEProcs;
type
TCodeToolsDefinesNodeValues = class
@ -452,7 +452,7 @@ begin
DirectoryGroupbox.Caption:=lisCodeToolsDefsInsertBehindDirectory;
ButtonPanel.HelpButton.OnClick := @HelpButtonClick;
DirectoryCombobox.Items.Assign(
InputHistories.HistoryLists.GetList(hlCodeToolsDirectories,true));
InputHistories.HistoryLists.GetList(hlCodeToolsDirectories,true,rltFile));
if DirectoryCombobox.Items.Count>0 then
DirectoryCombobox.ItemIndex:=0
else
@ -477,7 +477,7 @@ procedure TCodeToolsDefinesDialog.CodeToolsDefinesDialogCLOSE(Sender: TObject;
var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
InputHistories.HistoryLists.GetList(hlCodeToolsDirectories,true).Assign(
InputHistories.HistoryLists.GetList(hlCodeToolsDirectories,true,rltFile).Assign(
DirectoryCombobox.Items);
CodeToolsOpts.DefinesPreviewMainSplitterPos:=MainSplitter.GetSplitterPosition;
CodeToolsOpts.DefinesPreviewTemplSplitterPos:=TemplatesSplitter.GetSplitterPosition;

View File

@ -968,7 +968,7 @@ var
aProjPath:=SwitchPathDelims(aProjPath, True);
WholeFilePath:=ExtractFilePath(Application.ExeName) + aProjPath + aProjFile;
if FileIsWritable(aProjPath) and FileIsWritable(WholeFilePath) then
AddToRecentList(WholeFilePath, FRecentProjectFiles, FMaxRecentProjectFiles);
AddToRecentList(WholeFilePath,FRecentProjectFiles,FMaxRecentProjectFiles,rltFile);
end;
procedure LoadBackupInfo(var BackupInfo: TBackupInfo; const Path:string);
@ -1132,39 +1132,39 @@ begin
// files
LazarusDirectory:=XMLConfig.GetValue(Path+'LazarusDirectory/Value',LazarusDirectory);
LoadRecentList(XMLConfig,FLazarusDirHistory,
Path+'LazarusDirectory/History/');
Path+'LazarusDirectory/History/',rltFile);
if FLazarusDirHistory.Count=0 then
FLazarusDirHistory.Add(ProgramDirectory(true));
CompilerFilename:=TrimFilename(XMLConfig.GetValue(
Path+'CompilerFilename/Value',CompilerFilename));
LoadRecentList(XMLConfig,FCompilerFileHistory,
Path+'CompilerFilename/History/');
Path+'CompilerFilename/History/',rltFile);
if FCompilerFileHistory.Count=0 then
GetDefaultCompilerFilenames(FCompilerFileHistory);
FPCSourceDirectory:=XMLConfig.GetValue(
Path+'FPCSourceDirectory/Value',FPCSourceDirectory);
LoadRecentList(XMLConfig,FFPCSourceDirHistory,
Path+'FPCSourceDirectory/History/');
Path+'FPCSourceDirectory/History/',rltFile);
if FFPCSourceDirHistory.Count=0 then begin
end;
MakeFilename:=TrimFilename(XMLConfig.GetValue(
Path+'MakeFilename/Value',MakeFilename));
LoadRecentList(XMLConfig,FMakeFileHistory,
Path+'MakeFilename/History/');
Path+'MakeFilename/History/',rltFile);
if FMakeFileHistory.Count=0 then
GetDefaultMakeFilenames(FMakeFileHistory);
TestBuildDirectory:=XMLConfig.GetValue(
Path+'TestBuildDirectory/Value',TestBuildDirectory);
LoadRecentList(XMLConfig,FTestBuildDirHistory,
Path+'TestBuildDirectory/History/');
Path+'TestBuildDirectory/History/',rltFile);
if FTestBuildDirHistory.Count=0 then
GetDefaultTestBuildDirs(FTestBuildDirHistory);
CompilerMessagesFilename:=XMLConfig.GetValue(
Path+'CompilerMessagesFilename/Value',CompilerMessagesFilename);
LoadRecentList(XMLConfig, FCompilerMessagesFileHistory,
Path+'CompilerMessagesFilename/History/');
Path+'CompilerMessagesFilename/History/',rltFile);
// backup
LoadBackupInfo(FBackupInfoProjectFiles
@ -1177,7 +1177,7 @@ begin
DebuggerFilename:=XMLConfig.GetValue(
Path+'DebuggerFilename/Value','');
LoadRecentList(XMLConfig,FDebuggerFileHistory,
Path+'DebuggerFilename/History/');
Path+'DebuggerFilename/History/',rltFile);
DebuggerSearchPath:=XMLConfig.GetValue(
Path+'DebuggerSearchPath/Value','');
// Debugger General Options
@ -1244,15 +1244,15 @@ begin
FMaxRecentOpenFiles:=XMLConfig.GetValue(
Path+'Recent/OpenFiles/Max',FMaxRecentOpenFiles);
LoadRecentList(XMLConfig,FRecentOpenFiles,
Path+'Recent/OpenFiles/');
Path+'Recent/OpenFiles/',rltFile);
FMaxRecentProjectFiles:=XMLConfig.GetValue(
Path+'Recent/ProjectFiles/Max',FMaxRecentProjectFiles);
LoadRecentList(XMLConfig,FRecentProjectFiles,
Path+'Recent/ProjectFiles/');
Path+'Recent/ProjectFiles/',rltFile);
FMaxRecentPackageFiles:=XMLConfig.GetValue(
Path+'Recent/PackageFiles/Max',FMaxRecentOpenFiles);
LoadRecentList(XMLConfig,FRecentPackageFiles,
Path+'Recent/PackageFiles/');
Path+'Recent/PackageFiles/',rltFile);
// Add example projects to an empty project list if examples have write access
if FRecentProjectFiles.count=0 then begin
@ -1654,17 +1654,17 @@ end;
procedure TEnvironmentOptions.AddToRecentOpenFiles(const AFilename: string);
begin
AddToRecentList(AFilename,FRecentOpenFiles,FMaxRecentOpenFiles);
AddToRecentList(AFilename,FRecentOpenFiles,FMaxRecentOpenFiles,rltFile);
end;
procedure TEnvironmentOptions.RemoveFromRecentOpenFiles(const AFilename: string);
begin
RemoveFromRecentList(AFilename,FRecentOpenFiles);
RemoveFromRecentList(AFilename,FRecentOpenFiles,rltFile);
end;
procedure TEnvironmentOptions.AddToRecentProjectFiles(const AFilename: string);
begin
AddToRecentList(AFilename,FRecentProjectFiles,FMaxRecentProjectFiles);
AddToRecentList(AFilename,FRecentProjectFiles,FMaxRecentProjectFiles,rltFile);
{$ifdef Windows}
SHAddToRecentDocs(SHARD_PATHW, PWideChar(UTF8ToUTF16(AFileName)));
{$endif}
@ -1673,7 +1673,7 @@ end;
procedure TEnvironmentOptions.RemoveFromRecentProjectFiles(
const AFilename: string);
begin
RemoveFromRecentList(AFilename,FRecentProjectFiles);
RemoveFromRecentList(AFilename,FRecentProjectFiles,rltFile);
end;
procedure InitLayoutHelper(const FormID: string);

View File

@ -160,11 +160,30 @@ function SearchDirectoryInSearchPath(SearchPath: TStrings;
const Directory: string; DirStartPos: integer = 0): integer;
// XMLConfig
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings; const Path: string);
type
TRecentListType = (
rltCaseSensitive,
rltCaseInsensitive,
rltFile
);
const
RecentListTypeNames: array[TRecentListType] of string = (
'CaseSensitive',
'CaseInsensitive',
'File'
);
function StrToRecentListType(s: string): TRecentListType;
function CompareRecentListItem(s1, s2: string; ListType: TRecentListType): boolean;
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings; const Path: string;
ListType: TRecentListType);
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStrings; const Path: string);
function AddToRecentList(const s: string; RecentList: TStrings; Max: integer): boolean;
function AddComboTextToRecentList(cb: TCombobox; Max: integer): boolean;
procedure RemoveFromRecentList(const s: string; RecentList: TStrings);
function AddToRecentList(const s: string; RecentList: TStrings; Max: integer;
ListType: TRecentListType): boolean;
function AddComboTextToRecentList(cb: TCombobox; Max: integer;
ListType: TRecentListType): boolean;
procedure RemoveFromRecentList(const s: string; RecentList: TStrings;
ListType: TRecentListType);
procedure CleanUpRecentList(List: TStrings; ListType: TRecentListType);
procedure LoadRect(XMLConfig: TXMLConfig; const Path:string;
var ARect:TRect);
procedure LoadRect(XMLConfig: TXMLConfig; const Path:string;
@ -282,31 +301,31 @@ uses
Unix, BaseUnix;
{$EndIf}
function AddToRecentList(const s: string; RecentList: TStrings; Max: integer): boolean;
function AddToRecentList(const s: string; RecentList: TStrings; Max: integer;
ListType: TRecentListType): boolean;
begin
if (RecentList.Count>0) and (RecentList[0]=s) then
exit(false)
else
Result:=true;
RemoveFromRecentList(s,RecentList);
if (RecentList.Count>0) and CompareRecentListItem(RecentList[0],s,ListType) then
exit(false);
Result:=true;
RemoveFromRecentList(s,RecentList,ListType);
RecentList.Insert(0,s);
if Max>0 then
while RecentList.Count>Max do
RecentList.Delete(RecentList.Count-1);
end;
function AddComboTextToRecentList(cb: TCombobox; Max: integer): boolean;
function AddComboTextToRecentList(cb: TCombobox; Max: integer;
ListType: TRecentListType): boolean;
var
List: TStringList;
begin
List := TStringList.Create;
try
List.Assign(cb.Items);
if (List.Count>0) and (List[0]=cb.Text) then
exit(false)
else
Result:=true;
RemoveFromRecentList(cb.Text,List);
if (List.Count>0) and CompareRecentListItem(List[0],cb.Text,ListType) then
exit(false);
Result:=true;
RemoveFromRecentList(cb.Text,List,ListType);
List.Insert(0,cb.Text);
if Max>0 then
while List.Count>Max do
@ -318,14 +337,14 @@ begin
end;
end;
procedure RemoveFromRecentList(const s: string; RecentList: TStrings);
var i: integer;
procedure RemoveFromRecentList(const s: string; RecentList: TStrings;
ListType: TRecentListType);
var
i: integer;
begin
i:=RecentList.Count-1;
while i>=0 do begin
if RecentList[i]=s then RecentList.Delete(i);
dec(i);
end;
for i:=RecentList.Count-1 downto 0 do
if CompareRecentListItem(RecentList[i],s,ListType) then
RecentList.Delete(i);
end;
procedure SaveRecentList(XMLConfig: TXMLConfig; List: TStrings; const Path: string);
@ -957,10 +976,28 @@ begin
FindCloseUTF8(FileInfo);
end;
function StrToRecentListType(s: string): TRecentListType;
begin
for Result:=Low(TRecentListType) to high(TRecentListType) do
if SysUtils.CompareText(s,RecentListTypeNames[Result])=0 then exit;
Result:=rltCaseSensitive;
end;
function CompareRecentListItem(s1, s2: string; ListType: TRecentListType
): boolean;
begin
case ListType of
rltCaseInsensitive: Result:=UTF8LowerCase(s1)=UTF8LowerCase(s2);
rltFile: Result:=CompareFilenames(ChompPathDelim(s1),ChompPathDelim(s2))=0;
else Result:=s1=s2;
end;
end;
procedure LoadRecentList(XMLConfig: TXMLConfig; List: TStrings;
const Path: string);
const Path: string; ListType: TRecentListType);
begin
LoadStringList(XMLConfig,List,Path);
CleanUpRecentList(List,ListType);
end;
procedure LoadPoint(XMLConfig: TXMLConfig; const Path: string;
@ -1070,6 +1107,15 @@ begin
end;
end;
procedure CleanUpRecentList(List: TStrings; ListType: TRecentListType);
var
i: Integer;
begin
for i:=List.Count-1 downto 1 do
if CompareRecentListItem(List[i],List[i-1],ListType) then
List.Delete(i);
end;
procedure LoadRect(XMLConfig: TXMLConfig; const Path: string;
var ARect: TRect);
begin

View File

@ -290,7 +290,7 @@ end;
procedure TImExportCompOptsDlg.LoadRecentList;
begin
RecentListbox.Items.Assign(
InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true));
InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile));
if RecentListbox.Items.Count>0 then
RecentListbox.ItemIndex:=0;
UpdateRecentButtons;
@ -298,7 +298,7 @@ end;
procedure TImExportCompOptsDlg.SaveRecentList;
begin
InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true).Assign(
InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile).Assign(
RecentListbox.Items);
InputHistories.Save;
end;
@ -316,7 +316,7 @@ procedure TImExportCompOptsDlg.SetFilename(const AValue: string);
begin
if FFilename=AValue then exit;
FFilename:=AValue;
InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true).
InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile).
AppendEntry(FFilename);
LoadRecentList;
end;

View File

@ -72,20 +72,23 @@ type
THistoryList = class(TStringList)
private
FListType: TRecentListType;
FMaxCount: integer;
FName: string;
procedure SetMaxCount(const AValue: integer);
procedure SetName(const AValue: string);
public
constructor Create;
constructor Create(TheListType: TRecentListType);
destructor Destroy; override;
function Push(const Entry: string): integer;
procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
procedure AppendEntry(const Entry: string);
function IndexOf(const S: string): Integer; override;
public
property Name: string read FName write SetName;
property MaxCount: integer read FMaxCount write SetMaxCount;
property ListType: TRecentListType read FListType;
end;
@ -105,8 +108,8 @@ type
procedure SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
function IndexOfName(const Name: string): integer;
function GetList(const Name: string;
CreateIfNotExists: boolean): THistoryList;
procedure Add(const ListName, Entry: string);
CreateIfNotExists: boolean; ListType: TRecentListType): THistoryList;
procedure Add(const ListName, Entry: string; ListType: TRecentListType);
property Items[Index: integer]: THistoryList read GetItems;
end;
@ -218,7 +221,7 @@ type
FMaxFindHistory: Integer;
// Unit dependencies
FUnitDependenciesHistory: TStringList;
FUnitDependenciesHistory: TStringList; // root files
FMaxUnitDependenciesHistory: integer;
// FPC config cache
@ -496,12 +499,12 @@ begin
// Find- and replace-history
FMaxFindHistory:=XMLConfig.GetValue(Path+'Find/History/Max',FMaxFindHistory);
FFindAutoComplete:=XMLConfig.GetValue(Path+'Find/AutoComplete/Value',FFindAutoComplete);
LoadRecentList(XMLConfig,FFindHistory,Path+'Find/History/Find/');
LoadRecentList(XMLConfig,FReplaceHistory,Path+'Find/History/Replace/');
LoadRecentList(XMLConfig,FFindHistory,Path+'Find/History/Find/',rltCaseSensitive);
LoadRecentList(XMLConfig,FReplaceHistory,Path+'Find/History/Replace/',rltCaseSensitive);
LoadRecentList(XMLConfig,FFindInFilesPathHistory,Path+
'FindInFiles/History/Paths/');
'FindInFiles/History/Paths/',rltFile);
LoadRecentList(XMLConfig,FFindInFilesMaskHistory,Path+
'FindInFiles/History/Masks/');
'FindInFiles/History/Masks/',rltFile);
FFindInFilesSearchOptions:=[];
for FIFOption:=Low(TLazFindInFileSearchOption) to
High(TLazFindInFileSearchOption)
@ -524,7 +527,7 @@ begin
end;
// unit dependencies
LoadRecentList(XMLConfig,FUnitDependenciesHistory,Path+'UnitDependencies/History/');
LoadRecentList(XMLConfig,FUnitDependenciesHistory,Path+'UnitDependencies/History/',rltFile);
// fpc config cache
FFPCConfigCache.LoadFromXMLConfig(XMLConfig,'FPCConfigCache/');
// file dialog
@ -533,7 +536,7 @@ begin
Height:=XMLConfig.GetValue(Path+'FileDialog/Height',0);
InitialDir:=XMLConfig.GetValue(Path+'FileDialog/InitialDir','');
MaxHistory:=XMLConfig.GetValue(Path+'FileDialog/MaxHistory',20);
LoadRecentList(XMLConfig,HistoryList,Path+'FileDialog/HistoryList/');
LoadRecentList(XMLConfig,HistoryList,Path+'FileDialog/HistoryList/',rltFile);
end;
FCleanOutputFileMask:=XMLConfig.GetValue(Path+'Clean/OutputFilemask',
DefaultProjectCleanOutputFileMask);
@ -697,27 +700,28 @@ end;
function TInputHistories.AddToFindHistory(const AFindStr: string): boolean;
begin
Result:=AddToRecentList(AFindStr,FFindHistory,FMaxFindHistory);
Result:=AddToRecentList(AFindStr,FFindHistory,FMaxFindHistory,rltCaseSensitive);
end;
function TInputHistories.AddToReplaceHistory(const AReplaceStr: String): boolean;
begin
Result:=AddToRecentList(AReplaceStr,FReplaceHistory,FMaxFindHistory);
Result:=AddToRecentList(AReplaceStr,FReplaceHistory,FMaxFindHistory,rltCaseSensitive);
end;
function TInputHistories.AddToFindInFilesPathHistory(const APathStr: String): boolean;
begin
Result:= AddToRecentList(APathStr,FFindInFilesPathHistory,FMaxFindHistory);
Result:= AddToRecentList(APathStr,FFindInFilesPathHistory,FMaxFindHistory,rltFile);
end;
function TInputHistories.AddToFindInFilesMaskHistory(const AMaskStr: String): boolean;
begin
Result:= AddToRecentList(AMaskStr,FFindInFilesMaskHistory,FMaxFindHistory);
Result:= AddToRecentList(AMaskStr,FFindInFilesMaskHistory,FMaxFindHistory,rltFile);
end;
function TInputHistories.AddToUnitDependenciesHistory(const ARootFilename: String): boolean;
begin
Result:=AddToRecentList(ARootFilename,FUnitDependenciesHistory,FMaxUnitDependenciesHistory);
Result:=AddToRecentList(ARootFilename,FUnitDependenciesHistory,
FMaxUnitDependenciesHistory,rltFile);
end;
function TInputHistories.LastFPCUnitLinksValid: boolean;
@ -755,7 +759,8 @@ begin
FFileDialogSettings.Height:=SourceDialog.Height;
s:=ExtractFilePath(FFileDialogSettings.InitialDir);
if s<>'' then
AddToRecentList(s,FFileDialogSettings.HistoryList,FFileDialogSettings.MaxHistory);
AddToRecentList(s,FFileDialogSettings.HistoryList,
FFileDialogSettings.MaxHistory,rltFile);
end;
procedure TInputHistories.SetFileDialogSettingsInitialDir(const InitialDir: string);
@ -801,8 +806,9 @@ begin
FName:=AValue;
end;
constructor THistoryList.Create;
constructor THistoryList.Create(TheListType: TRecentListType);
begin
FListType:=TheListType;
FMaxCount:=20;
end;
@ -813,7 +819,7 @@ end;
function THistoryList.Push(const Entry: string): integer;
begin
AddToRecentList(Entry,Self,MaxCount);
AddToRecentList(Entry,Self,MaxCount,ListType);
Result:=-1;
end;
@ -823,12 +829,15 @@ begin
if FName='' then
FName:=XMLConfig.GetValue(Path+'Name','');
FMaxCount:=XMLConfig.GetValue(Path+'MaxCount',MaxCount);
LoadRecentList(XMLConfig,Self,Path);
FListType:=StrToRecentListType(XMLConfig.GetValue(Path+'Type',''));
LoadRecentList(XMLConfig,Self,Path,ListType);
end;
procedure THistoryList.SaveToXMLConfig(XMLConfig: TXMLConfig; const Path: string);
begin
XMLConfig.SetDeleteValue(Path+'Name',Name,'');
XMLConfig.SetDeleteValue(Path+'Type',RecentListTypeNames[ListType],
RecentListTypeNames[rltCaseSensitive]);
XMLConfig.SetDeleteValue(Path+'MaxCount',MaxCount,20);
SaveRecentList(XMLConfig,Self,Path);
end;
@ -839,6 +848,16 @@ begin
Add(Entry);
end;
function THistoryList.IndexOf(const S: string): Integer;
var
i: Integer;
begin
for i:=0 to Count-1 do
if CompareRecentListItem(S,Strings[i],ListType) then
exit(i);
Result:=-1;
end;
{ THistoryLists }
function THistoryLists.GetItems(Index: integer): THistoryList;
@ -881,13 +900,15 @@ var
MergeCount, i: integer;
CurList: THistoryList;
ListName, ListPath: string;
ListType: TRecentListType;
begin
MergeCount:=XMLConfig.GetValue(Path+'Count',0);
for i:=0 to MergeCount-1 do begin
ListPath:=GetXMLListPath(Path,i);
ListName:=XMLConfig.GetValue(ListPath+'Name','');
if ListName='' then continue;
CurList:=GetList(ListName,true);
ListType:=StrToRecentListType(XMLConfig.GetValue(ListPath+'Type',''));
CurList:=GetList(ListName,true,ListType);
CurList.LoadFromXMLConfig(XMLConfig,ListPath);
end;
end;
@ -913,8 +934,8 @@ begin
dec(Result);
end;
function THistoryLists.GetList(const Name: string;
CreateIfNotExists: boolean): THistoryList;
function THistoryLists.GetList(const Name: string; CreateIfNotExists: boolean;
ListType: TRecentListType): THistoryList;
var
i: integer;
begin
@ -922,16 +943,17 @@ begin
if i>=0 then
Result:=Items[i]
else if CreateIfNotExists then begin
Result:=THistoryList.Create;
Result:=THistoryList.Create(ListType);
Result.Name:=Name;
FItems.Add(Result);
end else
Result:=nil;
end;
procedure THistoryLists.Add(const ListName, Entry: string);
procedure THistoryLists.Add(const ListName, Entry: string;
ListType: TRecentListType);
begin
GetList(ListName,true).Push(Entry);
GetList(ListName,true,ListType).Push(Entry);
end;
{ TFPCConfigCache }

View File

@ -45,7 +45,7 @@ uses
CodeToolManager, CodeAtom, CodeToolsStructs, CodeCache,
IDEHelpIntf,
LazarusIDEStrConsts,
EditorOptions, InputHistory, MiscOptions;
EditorOptions, InputHistory, MiscOptions, IDEProcs;
type
@ -353,7 +353,8 @@ var
begin
// get the Prefixes history list
HistoryList:=
InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true);
InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true,
rltCaseSensitive);
IdentPrefixComboBox.Items.Assign(HistoryList);
if IdentPrefixComboBox.Items.Count>0 then
IdentPrefixComboBox.Text:=IdentPrefixComboBox.Items[0]
@ -367,7 +368,8 @@ var
begin
// get the Length history list
HistoryList:=
InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true);
InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true,
rltCaseSensitive);
IdentLengthComboBox.Items.Assign(HistoryList);
if IdentLengthComboBox.Items.Count>0 then
IdentLengthComboBox.Text:=IdentLengthComboBox.Items[0]
@ -610,7 +612,7 @@ begin
or (IdentPrefixComboBox.Text='') then
exit;
HistoryList:=
InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true);
InputHistories.HistoryLists.GetList(hlMakeResourceStringPrefixes,true,rltCaseSensitive);
if HistoryList.Count=0 then
HistoryList.Assign(IdentPrefixComboBox.Items);
HistoryList.Push(IdentPrefixComboBox.Text);
@ -624,7 +626,7 @@ begin
or (IdentLengthComboBox.Text='') then
exit;
HistoryList:=
InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true);
InputHistories.HistoryLists.GetList(hlMakeResourceStringLengths,true,rltCaseSensitive);
if HistoryList.Count=0 then
HistoryList.Assign(IdentLengthComboBox.Items);
HistoryList.Push(IdentLengthComboBox.Text);

View File

@ -41,7 +41,7 @@ uses
StdCtrls, Dialogs, LCLType,
IDEWindowIntf, IDEHelpIntf,
ProjectDefs, PackageDefs, PublishModule, IDEOptionDefs, InputHistory,
LazarusIDEStrConsts, ExtCtrls, ButtonPanel;
LazarusIDEStrConsts, IDEProcs, ExtCtrls, ButtonPanel;
type
{ TPublishProjectDialog }
@ -209,14 +209,14 @@ var
List: THistoryList;
begin
// destination directories
List:=InputHistories.HistoryLists.GetList(hlPublishProjectDestDirs,true);
List:=InputHistories.HistoryLists.GetList(hlPublishProjectDestDirs,true,rltFile);
List.AppendEntry(SetDirSeparators('$(TestDir)/publishedproject/'));
List.AppendEntry(SetDirSeparators('$(TestDir)/publishedpackage/'));
List.AppendEntry(SetDirSeparators('$(ProjPath)/published/'));
DestDirComboBox.Items.Assign(List);
// command after
List:=InputHistories.HistoryLists.GetList(hlPublishProjectCommandsAfter,true);
List:=InputHistories.HistoryLists.GetList(hlPublishProjectCommandsAfter,true,rltCaseSensitive);
List.AppendEntry(SetDirSeparators(
'tar czf $MakeFile($(ProjPublishDir)).tgz $(ProjPublishDir)'));
List.AppendEntry(SetDirSeparators(
@ -227,14 +227,14 @@ begin
// file filter
List:=InputHistories.HistoryLists.GetList(hlPublishProjectIncludeFileFilter,
true);
true,rltFile);
if List.Count=0 then begin
List.Add(DefPublProjIncFilter);
end;
IncludeFilterCombobox.Items.Assign(List);
List:=InputHistories.HistoryLists.GetList(hlPublishProjectExcludeFileFilter,
true);
true,rltFile);
if List.Count=0 then begin
List.Add(DefPublProjExcFilter);
end;
@ -245,21 +245,21 @@ procedure TPublishProjectDialog.SaveHistoryLists;
begin
// destination directories
SetComboBox(DestDirComboBox,DestDirComboBox.Text,20);
InputHistories.HistoryLists.GetList(hlPublishProjectDestDirs,true).Assign(
InputHistories.HistoryLists.GetList(hlPublishProjectDestDirs,true,rltFile).Assign(
DestDirComboBox.Items);
// command after
SetComboBox(CommandAfterCombobox,CommandAfterCombobox.Text,20);
InputHistories.HistoryLists.GetList(hlPublishProjectCommandsAfter,true).Assign(
CommandAfterCombobox.Items);
InputHistories.HistoryLists.GetList(hlPublishProjectCommandsAfter,true,
rltCaseSensitive).Assign(CommandAfterCombobox.Items);
// file filter
SetComboBox(IncludeFilterCombobox,IncludeFilterCombobox.Text,20);
InputHistories.HistoryLists.GetList(hlPublishProjectIncludeFileFilter,true).Assign(
IncludeFilterCombobox.Items);
InputHistories.HistoryLists.GetList(hlPublishProjectIncludeFileFilter,true,
rltFile).Assign(IncludeFilterCombobox.Items);
SetComboBox(ExcludeFilterCombobox,ExcludeFilterCombobox.Text,20);
InputHistories.HistoryLists.GetList(hlPublishProjectExcludeFileFilter,true).Assign(
ExcludeFilterCombobox.Items);
InputHistories.HistoryLists.GetList(hlPublishProjectExcludeFileFilter,true,
rltFile).Assign(ExcludeFilterCombobox.Items);
end;
procedure TPublishProjectDialog.SetOptions(const AValue: TPublishModuleOptions);

View File

@ -555,10 +555,11 @@ end;
procedure TRunParamsOptsDlg.SaveToOptions;
procedure SaveComboHistory(AComboBox: TComboBox; const History: string);
procedure SaveComboHistory(AComboBox: TComboBox; const History: string;
ListType: TRecentListType);
begin
AComboBox.AddHistoryItem(AComboBox.Text,20,true,false);
InputHistories.HistoryLists.GetList(History,true).Assign(AComboBox.Items);
InputHistories.HistoryLists.GetList(History,true,ListType).Assign(AComboBox.Items);
end;
begin
@ -573,13 +574,13 @@ begin
fOptions.Display := Trim(DisplayEdit.Text);
// history list: WorkingDirectoryComboBox
SaveComboHistory(WorkingDirectoryComboBox,hlWorkingDirectory);
SaveComboHistory(WorkingDirectoryComboBox,hlWorkingDirectory,rltFile);
// history list: UseLaunchingApplicationComboBox
SaveComboHistory(UseLaunchingApplicationComboBox,hlLaunchingApplication);
SaveComboHistory(UseLaunchingApplicationComboBox,hlLaunchingApplication,rltFile);
// history list: CmdLineParametersComboBox
SaveComboHistory(CmdLineParametersComboBox,hlCmdLineParameters);
SaveComboHistory(CmdLineParametersComboBox,hlCmdLineParameters,rltCaseSensitive);
// environment
SaveUserOverrides;
@ -624,14 +625,14 @@ begin
HostApplicationEdit.Text := fOptions.HostApplicationFilename;
// WorkingDirectoryComboBox
List:=InputHistories.HistoryLists.GetList(hlWorkingDirectory,true);
List:=InputHistories.HistoryLists.GetList(hlWorkingDirectory,true,rltFile);
List.AppendEntry(fOptions.WorkingDirectory);
WorkingDirectoryComboBox.Items.Assign(List);
WorkingDirectoryComboBox.Text := fOptions.WorkingDirectory;
// UseLaunchingApplicationComboBox
UseLaunchingApplicationCheckBox.Checked := fOptions.UseLaunchingApplication;
List := InputHistories.HistoryLists.GetList(hlLaunchingApplication,true);
List := InputHistories.HistoryLists.GetList(hlLaunchingApplication,true,rltFile);
List.AppendEntry(fOptions.LaunchingApplicationPathPlusParams);
S := FindTerminalInPath;
if S <> '' then
@ -648,7 +649,7 @@ begin
UseLaunchingApplicationComboBox.Text:=fOptions.LaunchingApplicationPathPlusParams;
// CmdLineParametersComboBox
List:=InputHistories.HistoryLists.GetList(hlCmdLineParameters,true);
List:=InputHistories.HistoryLists.GetList(hlCmdLineParameters,true,rltCaseSensitive);
List.AppendEntry(fOptions.CmdLineParams);
CmdLineParametersComboBox.Items.Assign(List);
CmdLineParametersComboBox.Text := fOptions.CmdLineParams;

View File

@ -952,7 +952,7 @@ begin
// open failed
if not FileExistsUTF8(AFilename) then begin
// file does not exist -> delete it from recent file list
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles);
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles,rltFile);
UpdateEnvironment;
end;
end;
@ -1188,7 +1188,7 @@ begin
then begin
if DeleteFileUTF8(OldPkgFilename) then begin
RemoveFromRecentList(OldPkgFilename,
EnvironmentOptions.RecentPackageFiles);
EnvironmentOptions.RecentPackageFiles,rltFile);
end else begin
IDEMessageDialog(lisPkgMangDeleteFailed,
Format(lisPkgMangUnableToDeleteFile, ['"', OldPkgFilename, '"']),
@ -1626,7 +1626,7 @@ end;
procedure TPkgManager.AddFileToRecentPackages(const Filename: string);
begin
AddToRecentList(Filename,EnvironmentOptions.RecentPackageFiles,
EnvironmentOptions.MaxRecentPackageFiles);
EnvironmentOptions.MaxRecentPackageFiles,rltFile);
SetRecentPackagesMenu;
MainIDE.SaveEnvironment;
end;
@ -2119,7 +2119,7 @@ begin
AFilename:=APackage.Filename;
if FileExistsCached(AFilename) then begin
AddToRecentList(AFilename,EnvironmentOptions.RecentPackageFiles,
EnvironmentOptions.MaxRecentPackageFiles);
EnvironmentOptions.MaxRecentPackageFiles,rltFile);
SetRecentPackagesMenu;
end;
end;
@ -2180,7 +2180,7 @@ begin
and (not (pofRevert in Flags)) then begin
DoQuestionDlg(lisPkgMangInvalidFileExtension,
Format(lisPkgMangTheFileIsNotALazarusPackage, ['"', AFilename, '"']));
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles);
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles,rltFile);
SetRecentPackagesMenu;
exit;
end;
@ -2193,7 +2193,7 @@ begin
DoQuestionDlg(lisPkgMangInvalidPackageFilename,
Format(lisPkgMangThePackageFileNameInIsNotAValidLazarusPackageName, ['"',
AlternativePkgName, '"', #13, '"', AFilename, '"']));
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles);
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles,rltFile);
SetRecentPackagesMenu;
exit;
end;
@ -2201,7 +2201,7 @@ begin
// add to recent packages
if pofAddToRecent in Flags then begin
AddToRecentList(AFilename,EnvironmentOptions.RecentPackageFiles,
EnvironmentOptions.MaxRecentPackageFiles);
EnvironmentOptions.MaxRecentPackageFiles,rltFile);
SetRecentPackagesMenu;
end;
@ -2220,7 +2220,7 @@ begin
IDEMessageDialog(lisFileNotFound,
Format(lisPkgMangFileNotFound, ['"', AFilename, '"']),
mtError,[mbCancel]);
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles);
RemoveFromRecentList(AFilename,EnvironmentOptions.RecentPackageFiles,rltFile);
SetRecentPackagesMenu;
Result:=mrCancel;
exit;