mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 08:38:19 +02:00
SrcEdit: Tab-Menu: group files by package
git-svn-id: trunk@36209 -
This commit is contained in:
parent
de7eaefc28
commit
416d52d6f0
@ -2098,6 +2098,7 @@ begin
|
||||
SourceEditorManager.OnViewJumpHistory := @OnSrcNotebookViewJumpHistory;
|
||||
SourceEditorManager.OnPopupMenu := @OnSrcNoteBookPopupMenu;
|
||||
SourceEditorManager.OnNoteBookCloseQuery := @OnSrcNoteBookCloseQuery;
|
||||
SourceEditorManager.OnPackageForSourceEditor := @PkgBoss.GetPackageOfSourceEditor;
|
||||
DebugBoss.ConnectSourceNotebookEvents;
|
||||
|
||||
OnSearchResultsViewSelectionChanged := @SearchResultsViewSelectionChanged;
|
||||
|
@ -70,6 +70,7 @@ uses
|
||||
type
|
||||
TSourceNotebook = class;
|
||||
TSourceEditorManager = class;
|
||||
TSourceEditor = class;
|
||||
|
||||
TNotifyFileEvent = procedure(Sender: TObject; Filename : AnsiString) of object;
|
||||
|
||||
@ -78,6 +79,9 @@ type
|
||||
TOnUserCommandProcessed = procedure(Sender: TObject;
|
||||
Command: word; var Handled: boolean) of object;
|
||||
|
||||
TPackageForSourceEditorEvent = function(out APackage: TIDEPackage;
|
||||
ASrcEdit: TObject): TLazPackageFile of object;
|
||||
|
||||
TOnLinesInsertedDeleted = procedure(Sender : TObject;
|
||||
FirstLine,Count : Integer) of Object;
|
||||
TPlaceBookMarkEvent = procedure(Sender: TObject; var Mark: TSynEditMark) of object;
|
||||
@ -156,8 +160,6 @@ type
|
||||
read FIdentCompletionJumpToError write FIdentCompletionJumpToError;
|
||||
end;
|
||||
|
||||
TSourceEditor = class;
|
||||
|
||||
{ TSourceEditorSharedValues }
|
||||
|
||||
TSourceEditorSharedValues = class(TSourceEditorSharedValuesBase)
|
||||
@ -1073,6 +1075,7 @@ type
|
||||
FOnMouseLink: TSynMouseLinkEvent;
|
||||
FOnNoteBookCloseQuery: TCloseEvent;
|
||||
FOnOpenFileAtCursorClicked: TNotifyEvent;
|
||||
FOnPackageForSourceEditor: TPackageForSourceEditorEvent;
|
||||
FOnPlaceMark: TPlaceBookMarkEvent;
|
||||
FOnPopupMenu: TSrcEditPopupMenuEvent;
|
||||
FOnProcessUserCommand: TOnProcessUserCommand;
|
||||
@ -1137,6 +1140,8 @@ type
|
||||
property OnPopupMenu: TSrcEditPopupMenuEvent read FOnPopupMenu write FOnPopupMenu;
|
||||
property OnNoteBookCloseQuery: TCloseEvent
|
||||
read FOnNoteBookCloseQuery write FOnNoteBookCloseQuery;
|
||||
property OnPackageForSourceEditor: TPackageForSourceEditorEvent
|
||||
read FOnPackageForSourceEditor write FOnPackageForSourceEditor;
|
||||
end;
|
||||
|
||||
function SourceEditorManager: TSourceEditorManager;
|
||||
@ -5392,8 +5397,9 @@ var
|
||||
PageI: integer;
|
||||
i: Integer;
|
||||
S: String;
|
||||
PageList: TList;
|
||||
EditorCur: TSourceEditor;
|
||||
P: TIDEPackage;
|
||||
M: TIDEMenuSection;
|
||||
begin
|
||||
PopM:=TPopupMenu(Sender);
|
||||
SourceTabMenuRoot.MenuItem:=PopM.Items;
|
||||
@ -5437,15 +5443,25 @@ begin
|
||||
|
||||
if SourceEditorManager<>nil then begin
|
||||
SrcEditMenuSectionEditors.Clear;
|
||||
PageList := TList.Create;
|
||||
|
||||
//first add all pages in the correct order since the editor order can be different from the tab order
|
||||
for i := 0 to Count - 1 do
|
||||
PageList.Add(FindSourceEditorWithPageIndex(i));
|
||||
|
||||
for i := 0 to PageList.Count - 1 do
|
||||
for i := 0 to EditorCount - 1 do
|
||||
begin
|
||||
EditorCur := TSourceEditor(PageList[i]);
|
||||
EditorCur := FindSourceEditorWithPageIndex(i);
|
||||
s := lisMEOther;
|
||||
if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then
|
||||
s := dlgEnvProject
|
||||
else begin
|
||||
Manager.OnPackageForSourceEditor(P, EditorCur);
|
||||
if P <> nil then
|
||||
s := p.Name;
|
||||
end;
|
||||
|
||||
if SrcEditMenuSectionEditors.FindByName(S) is TIDEMenuSection then
|
||||
M := TIDEMenuSection(SrcEditMenuSectionEditors.FindByName(S))
|
||||
else
|
||||
M := RegisterIDESubMenu(SrcEditMenuSectionEditors, S, S);
|
||||
|
||||
S := ExtractFileName(EditorCur.FileName);
|
||||
// check for modification
|
||||
if EditorCur.Modified then
|
||||
@ -5453,10 +5469,9 @@ begin
|
||||
//swap around so file name is first followed by the directory
|
||||
if S <> EditorCur.FileName then
|
||||
S := S +' in '+ExtractFileDir(EditorCur.FileName);
|
||||
RegisterIDEMenuCommand(SrcEditMenuSectionEditors, 'File'+IntToStr(i),
|
||||
RegisterIDEMenuCommand(M, 'File'+IntToStr(i),
|
||||
s, @ExecuteEditorItemClick, nil, nil, '', PtrUInt(EditorCur));
|
||||
end;
|
||||
PageList.Free;
|
||||
end;
|
||||
finally
|
||||
SourceTabMenuRoot.EndUpdate;
|
||||
|
@ -232,6 +232,7 @@ type
|
||||
function GetSourceFilesOfOwners(OwnerList: TFPList): TStrings; virtual; abstract;
|
||||
function GetPossibleOwnersOfUnit(const UnitFilename: string;
|
||||
Flags: TPkgIntfOwnerSearchFlags): TFPList; virtual; abstract;
|
||||
function GetPackageOfSourceEditor(out APackage: TIDEPackage; ASrcEdit: TObject): TLazPackageFile; virtual; abstract;
|
||||
|
||||
function GetPackageCount: integer; virtual; abstract;
|
||||
function GetPackages(Index: integer): TIDEPackage; virtual; abstract;
|
||||
|
@ -216,6 +216,7 @@ type
|
||||
function GetPossibleOwnersOfUnit(const UnitFilename: string;
|
||||
Flags: TPkgIntfOwnerSearchFlags): TFPList; override;
|
||||
function GetPackageOfCurrentSourceEditor(out APackage: TLazPackage): TPkgFile;
|
||||
function GetPackageOfSourceEditor(out APackage: TIDEPackage; ASrcEdit: TObject): TLazPackageFile; override;
|
||||
function IsOwnerDependingOnPkg(AnOwner: TObject; const PkgName: string;
|
||||
out DependencyOwner: TObject): boolean; override;
|
||||
function AddDependencyToOwners(OwnerList: TFPList; APackage: TIDEPackage;
|
||||
@ -3188,14 +3189,24 @@ function TPkgManager.GetPackageOfCurrentSourceEditor(out APackage: TLazPackage
|
||||
): TPkgFile;
|
||||
var
|
||||
SrcEdit: TSourceEditor;
|
||||
Filename: String;
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=nil;
|
||||
APackage:=nil;
|
||||
SrcEdit:=SourceEditorManager.GetActiveSE;
|
||||
if SrcEdit=nil then exit;
|
||||
Filename:=SrcEdit.FileName;
|
||||
Result := TPkgFile(GetPackageOfSourceEditor(APackage, SrcEdit));
|
||||
end;
|
||||
|
||||
function TPkgManager.GetPackageOfSourceEditor(out APackage: TIDEPackage;
|
||||
ASrcEdit: TObject): TLazPackageFile;
|
||||
var
|
||||
Filename: String;
|
||||
i: Integer;
|
||||
begin
|
||||
Result:=nil;
|
||||
APackage:=nil;
|
||||
if ASrcEdit=nil then exit;
|
||||
Filename:=TSourceEditor(ASrcEdit).FileName;
|
||||
Result:=SearchFile(Filename,[],nil);
|
||||
if Result<>nil then begin
|
||||
APackage:=Result.LazPackage;
|
||||
@ -3203,7 +3214,7 @@ begin
|
||||
end;
|
||||
for i:=0 to PackageGraph.Count-1 do begin
|
||||
APackage:=PackageGraph[i];
|
||||
if CompareFilenames(APackage.GetSrcFilename,SrcEdit.FileName)=0 then
|
||||
if CompareFilenames(TLazPackage(APackage).GetSrcFilename,FileName)=0 then
|
||||
exit;
|
||||
end;
|
||||
APackage:=nil;
|
||||
|
Loading…
Reference in New Issue
Block a user