📄 mru.pas
字号:
unit MRU;
interface
uses
Classes, SysUtils;
type
TMRUList = class
private
FFiles:TStringList;
FMaxCount : Integer;
public
constructor Create(MaxCount:Integer);
procedure AddFile(AFileName:String);
function GetList:TStringList;
end;
implementation
{ TMRUList }
procedure TMRUList.AddFile(AFileName: String);
var
i:Integer;
begin
i := FFiles.IndexOf(AFileName);
if i= -1 then
begin
if FFiles.Count = FMaxCount then
begin
FFiles.Delete(FMaxCount-1);
FFiles.Insert(0,AFileName);
end
else
FFiles.Insert(0,AFileName);
end
else
begin
FFiles.Delete(i);
FFiles.Insert(0,AFileName);
end;
end;
constructor TMRUList.Create(MaxCount:Integer);
begin
inherited Create;
if (MaxCount<2) or (MaxCount>10) then
raise ERangeError.Create('Max MRU Count should locate in [2,10]');
FMaxCount := MaxCount;
FFiles := TStringList.Create;
FFiles.CaseSensitive := False;
FFiles.Duplicates := dupIgnore;
FFiles.Sorted := False;
end;
function TMRUList.GetList: TStringList;
begin
Result := FFiles;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -