mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 01:58:22 +02:00
IDE: get rid of PageIndex and WindowIndex params in TFileOpenClose methods.
git-svn-id: trunk@45706 -
This commit is contained in:
parent
9b627e08b7
commit
5ac2862006
@ -60,9 +60,9 @@ type
|
|||||||
private
|
private
|
||||||
FFileName: string;
|
FFileName: string;
|
||||||
FUseWindowID: Boolean;
|
FUseWindowID: Boolean;
|
||||||
// Used by OpenEditorFile
|
|
||||||
FPageIndex: integer;
|
FPageIndex: integer;
|
||||||
FWindowIndex: integer;
|
FWindowIndex: integer;
|
||||||
|
// Used by OpenEditorFile
|
||||||
FUnitIndex: integer;
|
FUnitIndex: integer;
|
||||||
FEditorInfo: TUnitEditorInfo;
|
FEditorInfo: TUnitEditorInfo;
|
||||||
FNewEditorInfo: TUnitEditorInfo;
|
FNewEditorInfo: TUnitEditorInfo;
|
||||||
@ -73,8 +73,7 @@ type
|
|||||||
FActiveSrcEdit: TSourceEditor;
|
FActiveSrcEdit: TSourceEditor;
|
||||||
FActiveUnitInfo: TUnitInfo;
|
FActiveUnitInfo: TUnitInfo;
|
||||||
FIsIncludeDirective: boolean;
|
FIsIncludeDirective: boolean;
|
||||||
function OpenFileInSourceEditor(AnEditorInfo: TUnitEditorInfo;
|
function OpenFileInSourceEditor(AnEditorInfo: TUnitEditorInfo): TModalResult;
|
||||||
PageIndex, WindowIndex: integer): TModalResult;
|
|
||||||
// Used by GetAvailableUnitEditorInfo
|
// Used by GetAvailableUnitEditorInfo
|
||||||
function AvailSrcWindowIndex(AnUnitInfo: TUnitInfo): Integer;
|
function AvailSrcWindowIndex(AnUnitInfo: TUnitInfo): Integer;
|
||||||
// Used by OpenEditorFile
|
// Used by OpenEditorFile
|
||||||
@ -100,7 +99,7 @@ type
|
|||||||
function OpenEditorFile(APageIndex, AWindowIndex: integer;
|
function OpenEditorFile(APageIndex, AWindowIndex: integer;
|
||||||
AEditorInfo: TUnitEditorInfo; AFlags: TOpenFlags): TModalResult;
|
AEditorInfo: TUnitEditorInfo; AFlags: TOpenFlags): TModalResult;
|
||||||
function OpenFileAtCursor: TModalResult;
|
function OpenFileAtCursor: TModalResult;
|
||||||
function OpenMainUnit(PageIndex, WindowIndex: integer): TModalResult;
|
function OpenMainUnit: TModalResult;
|
||||||
function RevertMainUnit: TModalResult;
|
function RevertMainUnit: TModalResult;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -371,9 +370,11 @@ var
|
|||||||
begin
|
begin
|
||||||
Opener := TFileOpenClose.Create;
|
Opener := TFileOpenClose.Create;
|
||||||
try
|
try
|
||||||
Opener.FUseWindowID := UseWindowID;
|
Opener.FPageIndex := PageIndex;
|
||||||
|
Opener.FWindowIndex := WindowIndex;
|
||||||
Opener.FFlags := Flags;
|
Opener.FFlags := Flags;
|
||||||
Result := Opener.OpenMainUnit(PageIndex, WindowIndex);
|
Opener.FUseWindowID := UseWindowID;
|
||||||
|
Result := Opener.OpenMainUnit;
|
||||||
finally
|
finally
|
||||||
Opener.Free;
|
Opener.Free;
|
||||||
end;
|
end;
|
||||||
@ -403,8 +404,7 @@ begin
|
|||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileOpenClose.OpenFileInSourceEditor(AnEditorInfo: TUnitEditorInfo;
|
function TFileOpenClose.OpenFileInSourceEditor(AnEditorInfo: TUnitEditorInfo): TModalResult;
|
||||||
PageIndex, WindowIndex: integer): TModalResult;
|
|
||||||
var
|
var
|
||||||
NewSrcEdit: TSourceEditor;
|
NewSrcEdit: TSourceEditor;
|
||||||
AFilename: string;
|
AFilename: string;
|
||||||
@ -421,19 +421,19 @@ begin
|
|||||||
//debugln(['TFileOpenClose.OpenFileInSourceEditor ',AnEditorInfo.UnitInfo.Filename,' Window=',WindowIndex,'/',SourceEditorManager.SourceWindowCount,' Page=',PageIndex]);
|
//debugln(['TFileOpenClose.OpenFileInSourceEditor ',AnEditorInfo.UnitInfo.Filename,' Window=',WindowIndex,'/',SourceEditorManager.SourceWindowCount,' Page=',PageIndex]);
|
||||||
AnUnitInfo := AnEditorInfo.UnitInfo;
|
AnUnitInfo := AnEditorInfo.UnitInfo;
|
||||||
AFilename:=AnUnitInfo.Filename;
|
AFilename:=AnUnitInfo.Filename;
|
||||||
if (WindowIndex < 0) then
|
if (FWindowIndex < 0) then
|
||||||
SrcNotebook := SourceEditorManager.ActiveOrNewSourceWindow
|
SrcNotebook := SourceEditorManager.ActiveOrNewSourceWindow
|
||||||
else
|
else
|
||||||
if FUseWindowID then begin
|
if FUseWindowID then begin
|
||||||
SrcNotebook := SourceEditorManager.SourceWindowWithID(WindowIndex);
|
SrcNotebook := SourceEditorManager.SourceWindowWithID(FWindowIndex);
|
||||||
WindowIndex := SourceEditorManager.IndexOfSourceWindow(SrcNotebook);
|
FWindowIndex := SourceEditorManager.IndexOfSourceWindow(SrcNotebook);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (WindowIndex >= SourceEditorManager.SourceWindowCount) then begin
|
if (FWindowIndex >= SourceEditorManager.SourceWindowCount) then begin
|
||||||
SrcNotebook := SourceEditorManager.NewSourceWindow;
|
SrcNotebook := SourceEditorManager.NewSourceWindow;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
SrcNotebook := SourceEditorManager.SourceWindows[WindowIndex];
|
SrcNotebook := SourceEditorManager.SourceWindows[FWindowIndex];
|
||||||
|
|
||||||
// get syntax highlighter type
|
// get syntax highlighter type
|
||||||
if (uifInternalFile in AnUnitInfo.Flags) then
|
if (uifInternalFile in AnUnitInfo.Flags) then
|
||||||
@ -444,7 +444,7 @@ begin
|
|||||||
SrcNotebook.IncUpdateLock;
|
SrcNotebook.IncUpdateLock;
|
||||||
try
|
try
|
||||||
//DebugLn(['TFileOpenClose.OpenFileInSourceEditor Revert=',ofRevert in Flags,' ',AnUnitInfo.Filename,' PageIndex=',PageIndex]);
|
//DebugLn(['TFileOpenClose.OpenFileInSourceEditor Revert=',ofRevert in Flags,' ',AnUnitInfo.Filename,' PageIndex=',PageIndex]);
|
||||||
if (not (ofRevert in FFlags)) or (PageIndex<0) then begin
|
if (not (ofRevert in FFlags)) or (FPageIndex<0) then begin
|
||||||
// create a new source editor
|
// create a new source editor
|
||||||
|
|
||||||
// update marks and cursor positions in Project1, so that merging the old
|
// update marks and cursor positions in Project1, so that merging the old
|
||||||
@ -467,7 +467,7 @@ begin
|
|||||||
NewExecutionLine:=-1;
|
NewExecutionLine:=-1;
|
||||||
end else begin
|
end else begin
|
||||||
// revert code in existing source editor
|
// revert code in existing source editor
|
||||||
NewSrcEdit:=SourceEditorManager.SourceEditorsByPage[WindowIndex, PageIndex];
|
NewSrcEdit:=SourceEditorManager.SourceEditorsByPage[FWindowIndex, FPageIndex];
|
||||||
NewCaretXY:=NewSrcEdit.EditorComponent.CaretXY;
|
NewCaretXY:=NewSrcEdit.EditorComponent.CaretXY;
|
||||||
NewTopLine:=NewSrcEdit.EditorComponent.TopLine;
|
NewTopLine:=NewSrcEdit.EditorComponent.TopLine;
|
||||||
FoldState := NewSrcEdit.EditorComponent.FoldState;
|
FoldState := NewSrcEdit.EditorComponent.FoldState;
|
||||||
@ -646,27 +646,29 @@ begin
|
|||||||
until (LockRun > 1) or (Result <> nil);
|
until (LockRun > 1) or (Result <> nil);
|
||||||
FUseWindowID:=False;
|
FUseWindowID:=False;
|
||||||
FFlags:=[];
|
FFlags:=[];
|
||||||
|
FPageIndex:=-1;
|
||||||
if (Result = nil) then
|
if (Result = nil) then
|
||||||
case Access.SearchOpenNew of
|
case Access.SearchOpenNew of
|
||||||
eoeaNoNewTab: ;
|
eoeaNoNewTab: ;
|
||||||
eoeaNewTabInExistingWindowOnly:
|
eoeaNewTabInExistingWindowOnly:
|
||||||
begin
|
begin
|
||||||
w := AvailSrcWindowIndex(AnUnitInfo);
|
FWindowIndex := AvailSrcWindowIndex(AnUnitInfo);
|
||||||
if w >= 0 then
|
if FWindowIndex >= 0 then
|
||||||
if OpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo, -1, w) = mrOk then
|
if OpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo) = mrOk then
|
||||||
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
|
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
|
||||||
end;
|
end;
|
||||||
eoeaNewTabInNewWindowOnly:
|
eoeaNewTabInNewWindowOnly:
|
||||||
begin
|
begin
|
||||||
if OpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo,
|
FWindowIndex := SourceEditorManager.SourceWindowCount;
|
||||||
-1, SourceEditorManager.SourceWindowCount) = mrOk then
|
if OpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo) = mrOk then
|
||||||
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
|
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
|
||||||
end;
|
end;
|
||||||
eoeaNewTabInExistingOrNewWindow:
|
eoeaNewTabInExistingOrNewWindow:
|
||||||
begin
|
begin
|
||||||
w := AvailSrcWindowIndex(AnUnitInfo);
|
FWindowIndex := AvailSrcWindowIndex(AnUnitInfo);
|
||||||
if w < 0 then w := SourceEditorManager.SourceWindowCount;
|
if FWindowIndex < 0 then
|
||||||
if OpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo, -1, w) = mrOk then
|
FWindowIndex := SourceEditorManager.SourceWindowCount;
|
||||||
|
if OpenFileInSourceEditor(AnUnitInfo.GetClosedOrNewEditorInfo) = mrOk then
|
||||||
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
|
Result := AnUnitInfo.OpenEditorInfo[0]; // newly opened will be last focused
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -747,7 +749,7 @@ begin
|
|||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
FNewEditorInfo := FNewUnitInfo.GetClosedOrNewEditorInfo;
|
FNewEditorInfo := FNewUnitInfo.GetClosedOrNewEditorInfo;
|
||||||
OpenFileInSourceEditor(FNewEditorInfo, FPageIndex, FWindowIndex);
|
OpenFileInSourceEditor(FNewEditorInfo);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -774,7 +776,9 @@ begin
|
|||||||
if MacroListViewer.MacroByFullName(FFileName) <> nil then
|
if MacroListViewer.MacroByFullName(FFileName) <> nil then
|
||||||
FNewUnitInfo.Source.Source := MacroListViewer.MacroByFullName(FFileName).GetAsSource;
|
FNewUnitInfo.Source.Source := MacroListViewer.MacroByFullName(FFileName).GetAsSource;
|
||||||
FUseWindowID:=True;
|
FUseWindowID:=True;
|
||||||
OpenFileInSourceEditor(FNewEditorInfo, FNewEditorInfo.PageIndex, FNewEditorInfo.WindowID);
|
FPageIndex := FNewEditorInfo.PageIndex;
|
||||||
|
FWindowIndex := FNewEditorInfo.WindowID;
|
||||||
|
OpenFileInSourceEditor(FNewEditorInfo);
|
||||||
end;
|
end;
|
||||||
// else unknown internal file
|
// else unknown internal file
|
||||||
exit(mrIgnore);
|
exit(mrIgnore);
|
||||||
@ -997,7 +1001,7 @@ end;
|
|||||||
|
|
||||||
function TFileOpenClose.OpenEditorFile(APageIndex, AWindowIndex: integer;
|
function TFileOpenClose.OpenEditorFile(APageIndex, AWindowIndex: integer;
|
||||||
AEditorInfo: TUnitEditorInfo; AFlags: TOpenFlags): TModalResult;
|
AEditorInfo: TUnitEditorInfo; AFlags: TOpenFlags): TModalResult;
|
||||||
var // WindowIndex is WindowID
|
var
|
||||||
s, DiskFilename: String;
|
s, DiskFilename: String;
|
||||||
Reverting: Boolean;
|
Reverting: Boolean;
|
||||||
begin
|
begin
|
||||||
@ -1067,10 +1071,9 @@ begin
|
|||||||
// check if this is a hidden unit:
|
// check if this is a hidden unit:
|
||||||
// if this is the main unit, it is already
|
// if this is the main unit, it is already
|
||||||
// loaded and needs only to be shown in the sourceeditor/formeditor
|
// loaded and needs only to be shown in the sourceeditor/formeditor
|
||||||
if (not (ofRevert in FFlags))
|
if (not (ofRevert in FFlags)) and (CompareFilenames(Project1.MainFilename,FFilename)=0)
|
||||||
and (CompareFilenames(Project1.MainFilename,FFilename)=0)
|
|
||||||
then begin
|
then begin
|
||||||
Result:=OpenMainUnit(FPageIndex,FWindowIndex);
|
Result:=OpenMainUnit;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1169,7 +1172,7 @@ begin
|
|||||||
and (not FileIsWritable(FNewUnitInfo.Filename));
|
and (not FileIsWritable(FNewUnitInfo.Filename));
|
||||||
//debugln('[TFileOpenClose.OpenEditorFile] B');
|
//debugln('[TFileOpenClose.OpenEditorFile] B');
|
||||||
// open file in source notebook
|
// open file in source notebook
|
||||||
Result:=OpenFileInSourceEditor(FNewEditorInfo, FPageIndex, FWindowIndex);
|
Result:=OpenFileInSourceEditor(FNewEditorInfo);
|
||||||
if Result<>mrOk then begin
|
if Result<>mrOk then begin
|
||||||
DebugLn(['TFileOpenClose.OpenEditorFile failed OpenFileInSourceEditor: ',FFilename]);
|
DebugLn(['TFileOpenClose.OpenEditorFile failed OpenFileInSourceEditor: ',FFilename]);
|
||||||
exit;
|
exit;
|
||||||
@ -1383,7 +1386,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileOpenClose.OpenMainUnit(PageIndex, WindowIndex: integer): TModalResult;
|
function TFileOpenClose.OpenMainUnit: TModalResult;
|
||||||
var
|
var
|
||||||
MainUnitInfo: TUnitInfo;
|
MainUnitInfo: TUnitInfo;
|
||||||
begin
|
begin
|
||||||
@ -1405,7 +1408,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// open file in source notebook
|
// open file in source notebook
|
||||||
Result:=OpenFileInSourceEditor(MainUnitInfo.GetClosedOrNewEditorInfo,PageIndex,WindowIndex);
|
Result:=OpenFileInSourceEditor(MainUnitInfo.GetClosedOrNewEditorInfo);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
|
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
@ -1423,7 +1426,7 @@ begin
|
|||||||
if Project1.MainUnitInfo.OpenEditorInfoCount > 0 then
|
if Project1.MainUnitInfo.OpenEditorInfoCount > 0 then
|
||||||
// main unit is loaded, so we can just revert
|
// main unit is loaded, so we can just revert
|
||||||
Result:=OpenEditorFile(Project1.MainUnitInfo.EditorInfo[0].PageIndex,
|
Result:=OpenEditorFile(Project1.MainUnitInfo.EditorInfo[0].PageIndex,
|
||||||
Project1.MainUnitInfo.EditorInfo[0].WindowID, nil, [ofRevert])
|
Project1.MainUnitInfo.EditorInfo[0].WindowID, nil, [ofRevert])
|
||||||
else begin
|
else begin
|
||||||
// main unit is only loaded in background
|
// main unit is only loaded in background
|
||||||
// -> just reload the source and update the source name
|
// -> just reload the source and update the source name
|
||||||
|
Loading…
Reference in New Issue
Block a user