LazEdit: open file in unused open current editor if available, else in newly created editor

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2476 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
lazarus-bart 2012-07-07 22:35:12 +00:00
parent 04181a810d
commit 7826dd6b83
2 changed files with 12 additions and 1 deletions

View File

@ -99,6 +99,7 @@ type
procedure LoadFromFileUtf8(const Utf8Fn: String; const AsTemplate: Boolean = False);
procedure SaveToFileAnsi(const AnsiFn: String);
procedure SaveToFileUtf8(const Utf8Fn: String);
function IsUnused: Boolean;
procedure SetHighlighterByFileType(const AFileType: TEditorFileType; const Permanent: Boolean = False);
procedure MarkSelection(const Pre, Post: String);
@ -690,6 +691,12 @@ begin
end;
end;
function TEditor.IsUnused: Boolean;
begin
//debugln('TEditor.IsUnused: Modified = ',DbgS(Modified),', FFileName = "',FFileName,'", Length(Text) = ',DbgS(Length(Text)));
Result := (not Modified) and (FFileName = EmptyStr) and (Length(Text) = 0);
end;
procedure TEditor.SetHighlighterByFileType(const AFileType: TEditorFileType; const Permanent: Boolean = False);
begin
if Assigned(FEditorPageControl) then

View File

@ -2048,7 +2048,11 @@ begin
Exit;
end;
end;}
Ed := NoteBook.AddPage;
//If available, open new file in unused open Tab (if that is the current active one)
if (Assigned(NoteBook.CurrentEditor) and (NoteBook.CurrentEditor.IsUnused)) then
Ed := NoteBook.CurrentEditor
else
Ed := NoteBook.AddPage;
if Assigned(Ed) then
begin
try