mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 19:35:57 +02:00
IDEIntf: fixed crash on TIDEMenuSection.Clear, bug #30574
git-svn-id: branches/fixes_1_6@52936 -
This commit is contained in:
parent
e8d8a7b44e
commit
ae9d3b9797
@ -129,6 +129,7 @@ type
|
||||
procedure SetChildrenAsSubMenu(const AValue: boolean); virtual;
|
||||
procedure SetVisible(const AValue: Boolean); override;
|
||||
procedure SetSubMenuImages(const AValue: TCustomImageList); virtual;
|
||||
procedure SetMenuItem(const AValue: TMenuItem); override;
|
||||
procedure ClearMenuItems; override;
|
||||
procedure FreeTopSeparator;
|
||||
procedure FreeBottomSeparator;
|
||||
@ -972,6 +973,15 @@ begin
|
||||
MenuItem.SubMenuImages:=SubMenuImages;
|
||||
end;
|
||||
|
||||
procedure TIDEMenuSection.SetMenuItem(const AValue: TMenuItem);
|
||||
begin
|
||||
inherited SetMenuItem(AValue);
|
||||
if (Section=nil) and (MenuItem<>nil) then begin
|
||||
// root section -> create menu items
|
||||
UpdateContainer;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TIDEMenuSection.ClearMenuItems;
|
||||
var
|
||||
i: Integer;
|
||||
@ -1062,6 +1072,7 @@ var
|
||||
SubSection: TIDEMenuSection;
|
||||
aVisible: Boolean;
|
||||
begin
|
||||
if imssClearing in aSection.FStates then exit;
|
||||
aVisible:=aSection.RealVisible;
|
||||
for i:=0 to aSection.Count-1 do begin
|
||||
Item:=aSection[i];
|
||||
|
@ -2754,146 +2754,141 @@ var
|
||||
VisibleCnt: Integer;
|
||||
begin
|
||||
MessagesMenuRoot.MenuItem:=MsgCtrlPopupMenu.Items;
|
||||
MessagesMenuRoot.BeginUpdate;
|
||||
try
|
||||
HasText:=false;
|
||||
HasFilename:=false;
|
||||
MsgType:='';
|
||||
CanFilterMsgType:=false;
|
||||
Line:=nil;
|
||||
HasViewContent:=false;
|
||||
Running:=false;
|
||||
HasText:=false;
|
||||
HasFilename:=false;
|
||||
MsgType:='';
|
||||
CanFilterMsgType:=false;
|
||||
Line:=nil;
|
||||
HasViewContent:=false;
|
||||
Running:=false;
|
||||
|
||||
// check all
|
||||
for i:=0 to MessagesCtrl.ViewCount-1 do begin
|
||||
View:=MessagesCtrl.Views[i];
|
||||
if View.HasContent then
|
||||
HasViewContent:=true;
|
||||
if View.Running then
|
||||
Running:=true;
|
||||
end;
|
||||
|
||||
MsgFindMenuItem.OnClick:=@FindMenuItemClick;
|
||||
|
||||
// check selection
|
||||
View:=MessagesCtrl.SelectedView;
|
||||
if View<>nil then begin
|
||||
LineNumber:=MessagesCtrl.SelectedLine;
|
||||
if (LineNumber>=0) and (LineNumber<View.Lines.Count) then begin
|
||||
Line:=View.Lines[LineNumber];
|
||||
HasFilename:=Line.Filename<>'';
|
||||
HasText:=Line.Msg<>'';
|
||||
if (Line.SubTool<>'') and (Line.MsgID<>0) then begin
|
||||
MsgType:=GetMsgPattern(Line.SubTool,Line.MsgID,true,40);
|
||||
CanFilterMsgType:=ord(Line.Urgency)<ord(mluError);
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
// no line selected => use last visible View
|
||||
View:=MessagesCtrl.GetLastViewWithContent;
|
||||
end;
|
||||
ToolOptionsCaption:='';
|
||||
|
||||
// About
|
||||
if View<>nil then
|
||||
begin
|
||||
MsgAboutToolMenuItem.Caption:=Format(lisAbout2, [View.Caption]);
|
||||
MsgAboutSection.Visible:=true;
|
||||
if (View.Tool<>nil) and (View.Tool.Data is TIDEExternalToolData) then begin
|
||||
ToolData:=TIDEExternalToolData(View.Tool.Data);
|
||||
if ToolData.Kind=IDEToolCompilePackage then
|
||||
ToolOptionsCaption:=Format(lisCPOpenPackage, [ToolData.ModuleName]);
|
||||
end;
|
||||
end else
|
||||
MsgAboutSection.Visible:=false;
|
||||
MsgAboutToolMenuItem.OnClick:=@AboutToolMenuItemClick;
|
||||
VisibleCnt:=1;
|
||||
MsgOpenToolOptionsMenuItem.Visible:=ToolOptionsCaption<>'';
|
||||
if MsgOpenToolOptionsMenuItem.Visible then
|
||||
begin
|
||||
inc(VisibleCnt);
|
||||
//only assign caption if it is not empty to avoid its "unlocalizing",
|
||||
//this is visible e.g. in EditorToolBar menu tree
|
||||
MsgOpenToolOptionsMenuItem.Caption:=ToolOptionsCaption;
|
||||
end
|
||||
else
|
||||
//assign default caption if item is not visible (needed for EditorToolBar)
|
||||
MsgOpenToolOptionsMenuItem.Caption:=lisOpenToolOptions;
|
||||
MsgOpenToolOptionsMenuItem.OnClick:=@OpenToolsOptionsMenuItemClick;
|
||||
MsgAboutSection.ChildrenAsSubMenu:=VisibleCnt>1;
|
||||
|
||||
// Filtering
|
||||
if CanFilterMsgType then begin
|
||||
MsgFilterMsgOfTypeMenuItem.Caption:=Format(lisFilterAllMessagesOfType, [MsgType]);
|
||||
MsgFilterMsgOfTypeMenuItem.Visible:=true;
|
||||
end else begin
|
||||
//assign default caption if item is not visible (needed for EditorToolBar)
|
||||
MsgFilterMsgOfTypeMenuItem.Caption:=lisFilterAllMessagesOfCertainType;
|
||||
MsgFilterMsgOfTypeMenuItem.Visible:=false;
|
||||
end;
|
||||
MsgFilterMsgOfTypeMenuItem.OnClick:=@FilterMsgOfTypeMenuItemClick;
|
||||
MsgFilterHintsWithoutPosMenuItem.Checked:=MessagesCtrl.ActiveFilter.FilterNotesWithoutPos;
|
||||
MsgFilterHintsWithoutPosMenuItem.OnClick:=@FilterHintsWithoutPosMenuItemClick;
|
||||
|
||||
MinUrgency:=MessagesCtrl.ActiveFilter.MinUrgency;
|
||||
MsgFilterNoneMenuItem.Checked:=MinUrgency in [mluNone..mluDebug];
|
||||
MsgFilterNoneMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterDebugMenuItem.Checked:=MinUrgency in [mluVerbose3..mluVerbose];
|
||||
MsgFilterDebugMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterVerboseMenuItem.Checked:=MinUrgency=mluHint;
|
||||
MsgFilterVerboseMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterHintsMenuItem.Checked:=MinUrgency=mluNote;
|
||||
MsgFilterHintsMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterNotesMenuItem.Checked:=MinUrgency in [mluWarning..mluImportant];
|
||||
MsgFilterNotesMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterWarningsMenuItem.Checked:=MinUrgency>=mluError;
|
||||
MsgFilterWarningsMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
|
||||
// Copying
|
||||
MsgCopyMsgMenuItem.Enabled:=HasText;
|
||||
MsgCopyMsgMenuItem.OnClick:=@CopyMsgMenuItemClick;
|
||||
MsgCopyFilenameMenuItem.Enabled:=HasFilename;
|
||||
MsgCopyFilenameMenuItem.OnClick:=@CopyFilenameMenuItemClick;
|
||||
MsgCopyAllMenuItem.Enabled:=not Running;
|
||||
MsgCopyAllMenuItem.OnClick:=@CopyAllMenuItemClick;
|
||||
MsgCopyShownMenuItem.Enabled:=HasViewContent;
|
||||
MsgCopyShownMenuItem.OnClick:=@CopyShownMenuItemClick;
|
||||
|
||||
// Saving
|
||||
MsgSaveAllToFileMenuItem.Enabled:=not Running;
|
||||
MsgSaveAllToFileMenuItem.OnClick:=@SaveAllToFileMenuItemClick;
|
||||
MsgSaveShownToFileMenuItem.Enabled:=HasViewContent;
|
||||
MsgSaveShownToFileMenuItem.OnClick:=@SaveShownToFileMenuItemClick;
|
||||
MsgHelpMenuItem.Enabled:=HasText;
|
||||
MsgHelpMenuItem.OnClick:=@HelpMenuItemClick;
|
||||
MsgEditHelpMenuItem.OnClick:=@EditHelpMenuItemClick;
|
||||
MsgClearMenuItem.OnClick:=@ClearMenuItemClick;
|
||||
MsgClearMenuItem.Enabled:=View<>nil;
|
||||
|
||||
// Options
|
||||
MsgWndStayOnTopMenuItem.Checked:=mcoWndStayOnTop in MessagesCtrl.Options;
|
||||
MsgWndStayOnTopMenuItem.OnClick:=@WndStayOnTopMenuItemClick;
|
||||
MsgFileStyleShortMenuItem.Checked:=MessagesCtrl.FilenameStyle=mwfsShort;
|
||||
MsgFileStyleShortMenuItem.OnClick:=@FileStyleMenuItemClick;
|
||||
MsgFileStyleRelativeMenuItem.Checked:=MessagesCtrl.FilenameStyle=mwfsRelative;
|
||||
MsgFileStyleRelativeMenuItem.OnClick:=@FileStyleMenuItemClick;
|
||||
MsgFileStyleFullMenuItem.Checked:=MessagesCtrl.FilenameStyle=mwfsFull;
|
||||
MsgFileStyleFullMenuItem.OnClick:=@FileStyleMenuItemClick;
|
||||
|
||||
MsgTranslateMenuItem.Checked:=mcoShowTranslated in MessagesCtrl.Options;
|
||||
MsgTranslateMenuItem.OnClick:=@TranslateMenuItemClick;
|
||||
MsgShowIDMenuItem.Checked:=mcoShowMessageID in MessagesCtrl.Options;
|
||||
MsgShowIDMenuItem.OnClick:=@ShowIDMenuItemClick;
|
||||
MsgMoreOptionsMenuItem.OnClick:=@MoreOptionsMenuItemClick;
|
||||
|
||||
UpdateRemoveCompOptHideMsgItems;
|
||||
UpdateRemoveMsgTypeFilterItems;
|
||||
UpdateFilterItems;
|
||||
|
||||
UpdateQuickFixes(Line);
|
||||
finally
|
||||
MessagesMenuRoot.EndUpdate;
|
||||
// check all
|
||||
for i:=0 to MessagesCtrl.ViewCount-1 do begin
|
||||
View:=MessagesCtrl.Views[i];
|
||||
if View.HasContent then
|
||||
HasViewContent:=true;
|
||||
if View.Running then
|
||||
Running:=true;
|
||||
end;
|
||||
|
||||
MsgFindMenuItem.OnClick:=@FindMenuItemClick;
|
||||
|
||||
// check selection
|
||||
View:=MessagesCtrl.SelectedView;
|
||||
if View<>nil then begin
|
||||
LineNumber:=MessagesCtrl.SelectedLine;
|
||||
if (LineNumber>=0) and (LineNumber<View.Lines.Count) then begin
|
||||
Line:=View.Lines[LineNumber];
|
||||
HasFilename:=Line.Filename<>'';
|
||||
HasText:=Line.Msg<>'';
|
||||
if (Line.SubTool<>'') and (Line.MsgID<>0) then begin
|
||||
MsgType:=GetMsgPattern(Line.SubTool,Line.MsgID,true,40);
|
||||
CanFilterMsgType:=ord(Line.Urgency)<ord(mluError);
|
||||
end;
|
||||
end;
|
||||
end else begin
|
||||
// no line selected => use last visible View
|
||||
View:=MessagesCtrl.GetLastViewWithContent;
|
||||
end;
|
||||
ToolOptionsCaption:='';
|
||||
|
||||
// About
|
||||
if View<>nil then
|
||||
begin
|
||||
MsgAboutToolMenuItem.Caption:=Format(lisAbout2, [View.Caption]);
|
||||
MsgAboutSection.Visible:=true;
|
||||
if (View.Tool<>nil) and (View.Tool.Data is TIDEExternalToolData) then begin
|
||||
ToolData:=TIDEExternalToolData(View.Tool.Data);
|
||||
if ToolData.Kind=IDEToolCompilePackage then
|
||||
ToolOptionsCaption:=Format(lisCPOpenPackage, [ToolData.ModuleName]);
|
||||
end;
|
||||
end else
|
||||
MsgAboutSection.Visible:=false;
|
||||
MsgAboutToolMenuItem.OnClick:=@AboutToolMenuItemClick;
|
||||
VisibleCnt:=1;
|
||||
MsgOpenToolOptionsMenuItem.Visible:=ToolOptionsCaption<>'';
|
||||
if MsgOpenToolOptionsMenuItem.Visible then
|
||||
begin
|
||||
inc(VisibleCnt);
|
||||
//only assign caption if it is not empty to avoid its "unlocalizing",
|
||||
//this is visible e.g. in EditorToolBar menu tree
|
||||
MsgOpenToolOptionsMenuItem.Caption:=ToolOptionsCaption;
|
||||
end
|
||||
else
|
||||
//assign default caption if item is not visible (needed for EditorToolBar)
|
||||
MsgOpenToolOptionsMenuItem.Caption:=lisOpenToolOptions;
|
||||
MsgOpenToolOptionsMenuItem.OnClick:=@OpenToolsOptionsMenuItemClick;
|
||||
MsgAboutSection.ChildrenAsSubMenu:=VisibleCnt>1;
|
||||
|
||||
// Filtering
|
||||
if CanFilterMsgType then begin
|
||||
MsgFilterMsgOfTypeMenuItem.Caption:=Format(lisFilterAllMessagesOfType, [MsgType]);
|
||||
MsgFilterMsgOfTypeMenuItem.Visible:=true;
|
||||
end else begin
|
||||
//assign default caption if item is not visible (needed for EditorToolBar)
|
||||
MsgFilterMsgOfTypeMenuItem.Caption:=lisFilterAllMessagesOfCertainType;
|
||||
MsgFilterMsgOfTypeMenuItem.Visible:=false;
|
||||
end;
|
||||
MsgFilterMsgOfTypeMenuItem.OnClick:=@FilterMsgOfTypeMenuItemClick;
|
||||
MsgFilterHintsWithoutPosMenuItem.Checked:=MessagesCtrl.ActiveFilter.FilterNotesWithoutPos;
|
||||
MsgFilterHintsWithoutPosMenuItem.OnClick:=@FilterHintsWithoutPosMenuItemClick;
|
||||
|
||||
MinUrgency:=MessagesCtrl.ActiveFilter.MinUrgency;
|
||||
MsgFilterNoneMenuItem.Checked:=MinUrgency in [mluNone..mluDebug];
|
||||
MsgFilterNoneMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterDebugMenuItem.Checked:=MinUrgency in [mluVerbose3..mluVerbose];
|
||||
MsgFilterDebugMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterVerboseMenuItem.Checked:=MinUrgency=mluHint;
|
||||
MsgFilterVerboseMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterHintsMenuItem.Checked:=MinUrgency=mluNote;
|
||||
MsgFilterHintsMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterNotesMenuItem.Checked:=MinUrgency in [mluWarning..mluImportant];
|
||||
MsgFilterNotesMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
MsgFilterWarningsMenuItem.Checked:=MinUrgency>=mluError;
|
||||
MsgFilterWarningsMenuItem.OnClick:=@FilterUrgencyMenuItemClick;
|
||||
|
||||
// Copying
|
||||
MsgCopyMsgMenuItem.Enabled:=HasText;
|
||||
MsgCopyMsgMenuItem.OnClick:=@CopyMsgMenuItemClick;
|
||||
MsgCopyFilenameMenuItem.Enabled:=HasFilename;
|
||||
MsgCopyFilenameMenuItem.OnClick:=@CopyFilenameMenuItemClick;
|
||||
MsgCopyAllMenuItem.Enabled:=not Running;
|
||||
MsgCopyAllMenuItem.OnClick:=@CopyAllMenuItemClick;
|
||||
MsgCopyShownMenuItem.Enabled:=HasViewContent;
|
||||
MsgCopyShownMenuItem.OnClick:=@CopyShownMenuItemClick;
|
||||
|
||||
// Saving
|
||||
MsgSaveAllToFileMenuItem.Enabled:=not Running;
|
||||
MsgSaveAllToFileMenuItem.OnClick:=@SaveAllToFileMenuItemClick;
|
||||
MsgSaveShownToFileMenuItem.Enabled:=HasViewContent;
|
||||
MsgSaveShownToFileMenuItem.OnClick:=@SaveShownToFileMenuItemClick;
|
||||
MsgHelpMenuItem.Enabled:=HasText;
|
||||
MsgHelpMenuItem.OnClick:=@HelpMenuItemClick;
|
||||
MsgEditHelpMenuItem.OnClick:=@EditHelpMenuItemClick;
|
||||
MsgClearMenuItem.OnClick:=@ClearMenuItemClick;
|
||||
MsgClearMenuItem.Enabled:=View<>nil;
|
||||
|
||||
// Options
|
||||
MsgWndStayOnTopMenuItem.Checked:=mcoWndStayOnTop in MessagesCtrl.Options;
|
||||
MsgWndStayOnTopMenuItem.OnClick:=@WndStayOnTopMenuItemClick;
|
||||
MsgFileStyleShortMenuItem.Checked:=MessagesCtrl.FilenameStyle=mwfsShort;
|
||||
MsgFileStyleShortMenuItem.OnClick:=@FileStyleMenuItemClick;
|
||||
MsgFileStyleRelativeMenuItem.Checked:=MessagesCtrl.FilenameStyle=mwfsRelative;
|
||||
MsgFileStyleRelativeMenuItem.OnClick:=@FileStyleMenuItemClick;
|
||||
MsgFileStyleFullMenuItem.Checked:=MessagesCtrl.FilenameStyle=mwfsFull;
|
||||
MsgFileStyleFullMenuItem.OnClick:=@FileStyleMenuItemClick;
|
||||
|
||||
MsgTranslateMenuItem.Checked:=mcoShowTranslated in MessagesCtrl.Options;
|
||||
MsgTranslateMenuItem.OnClick:=@TranslateMenuItemClick;
|
||||
MsgShowIDMenuItem.Checked:=mcoShowMessageID in MessagesCtrl.Options;
|
||||
MsgShowIDMenuItem.OnClick:=@ShowIDMenuItemClick;
|
||||
MsgMoreOptionsMenuItem.OnClick:=@MoreOptionsMenuItemClick;
|
||||
|
||||
UpdateRemoveCompOptHideMsgItems;
|
||||
UpdateRemoveMsgTypeFilterItems;
|
||||
UpdateFilterItems;
|
||||
|
||||
UpdateQuickFixes(Line);
|
||||
end;
|
||||
|
||||
procedure TMessagesFrame.OnSelectFilterClick(Sender: TObject);
|
||||
|
@ -6528,109 +6528,104 @@ var
|
||||
begin
|
||||
PopM:=TPopupMenu(Sender);
|
||||
SourceTabMenuRoot.MenuItem:=PopM.Items;
|
||||
SourceTabMenuRoot.BeginUpdate;
|
||||
try
|
||||
// Get the tab that was clicked
|
||||
if PopM.PopupComponent is TPageControl then begin
|
||||
PageCtrl:=TPageControl(PopM.PopupComponent);
|
||||
PageI:=PageCtrl.TabIndexAtClientPos(PageCtrl.ScreenToClient(PopM.PopupPoint));
|
||||
if (PageI>=0) and (PageI<PageCtrl.PageCount) then
|
||||
PageIndex := PageI // Todo: This should be in MouseDown / or both, whichever is first
|
||||
else
|
||||
DebugLn(['TSourceNotebook.TabPopUpMenuPopup: Popup PageIndex=', PageI]);
|
||||
// Get the tab that was clicked
|
||||
if PopM.PopupComponent is TPageControl then begin
|
||||
PageCtrl:=TPageControl(PopM.PopupComponent);
|
||||
PageI:=PageCtrl.TabIndexAtClientPos(PageCtrl.ScreenToClient(PopM.PopupPoint));
|
||||
if (PageI>=0) and (PageI<PageCtrl.PageCount) then
|
||||
PageIndex := PageI // Todo: This should be in MouseDown / or both, whichever is first
|
||||
else
|
||||
DebugLn(['TSourceNotebook.TabPopUpMenuPopup: Popup PageIndex=', PageI]);
|
||||
end;
|
||||
ASrcEdit:=ActiveEditor as TSourceEditor;
|
||||
|
||||
{$IFnDEF SingleSrcWindow}
|
||||
// Multi win
|
||||
ToWindow(SrcEditMenuMoveToOtherWindowList, 'MoveToWindow',
|
||||
@SrcEditMenuMoveToExistingWindowClicked);
|
||||
ToWindow(SrcEditMenuCopyToOtherWindowList, 'CopyToWindow',
|
||||
@SrcEditMenuCopyToExistingWindowClicked);
|
||||
ToWindow(SrcEditMenuFindInOtherWindowList, 'FindInWindow',
|
||||
@SrcEditMenuFindInWindowClicked, True);
|
||||
{$ENDIF}
|
||||
|
||||
SrcEditMenuSectionEditors.Clear;
|
||||
if Manager <> nil then begin
|
||||
EdList := TStringList.Create;
|
||||
EdList.OwnsObjects := False;
|
||||
EdList.Sorted := True;
|
||||
// sort
|
||||
for i := 0 to EditorCount - 1 do
|
||||
EdList.AddObject(Editors[i].PageName+' '+Editors[i].FileName, Editors[i]);
|
||||
|
||||
|
||||
RecMenu := RegisterIDESubMenu(SrcEditMenuSectionEditors, lisRecentTabs, lisRecentTabs);
|
||||
RecMenu.Visible := False;
|
||||
ProjMenu := RegisterIDESubMenu(SrcEditMenuSectionEditors, dlgEnvProject, dlgEnvProject);
|
||||
ProjMenu.Visible := False;
|
||||
RegisterIDESubMenu(SrcEditMenuSectionEditors, lisMEOther, lisMEOther).Visible := False;
|
||||
|
||||
//first add all pages in the correct order since the editor order can be different from the tab order
|
||||
for i := 0 to EdList.Count - 1 do
|
||||
begin
|
||||
EditorCur := TSourceEditor(EdList.Objects[i]);
|
||||
s := lisMEOther;
|
||||
P := nil;
|
||||
if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then
|
||||
s := dlgEnvProject
|
||||
else begin
|
||||
Manager.OnPackageForSourceEditor(P, EditorCur);
|
||||
if P <> nil then
|
||||
s := Format(lisTabsFor, [p.Name]);
|
||||
end;
|
||||
|
||||
if SrcEditMenuSectionEditors.FindByName(S) is TIDEMenuSection then begin
|
||||
M := TIDEMenuSection(SrcEditMenuSectionEditors.FindByName(S))
|
||||
end else begin
|
||||
M := RegisterIDESubMenu(SrcEditMenuSectionEditors, S, S);
|
||||
M.UserTag := PtrUInt(P);
|
||||
end;
|
||||
M.Visible := True;
|
||||
|
||||
AddEditorToMenuSection(EditorCur, M, i);
|
||||
// use tag to count modified
|
||||
if EditorCur.Modified then M.Tag := m.Tag + 1;
|
||||
end;
|
||||
ASrcEdit:=ActiveEditor as TSourceEditor;
|
||||
|
||||
{$IFnDEF SingleSrcWindow}
|
||||
// Multi win
|
||||
ToWindow(SrcEditMenuMoveToOtherWindowList, 'MoveToWindow',
|
||||
@SrcEditMenuMoveToExistingWindowClicked);
|
||||
ToWindow(SrcEditMenuCopyToOtherWindowList, 'CopyToWindow',
|
||||
@SrcEditMenuCopyToExistingWindowClicked);
|
||||
ToWindow(SrcEditMenuFindInOtherWindowList, 'FindInWindow',
|
||||
@SrcEditMenuFindInWindowClicked, True);
|
||||
{$ENDIF}
|
||||
|
||||
SrcEditMenuSectionEditors.Clear;
|
||||
if Manager <> nil then begin
|
||||
EdList := TStringList.Create;
|
||||
EdList.OwnsObjects := False;
|
||||
EdList.Sorted := True;
|
||||
// sort
|
||||
for i := 0 to EditorCount - 1 do
|
||||
EdList.AddObject(Editors[i].PageName+' '+Editors[i].FileName, Editors[i]);
|
||||
|
||||
|
||||
RecMenu := RegisterIDESubMenu(SrcEditMenuSectionEditors, lisRecentTabs, lisRecentTabs);
|
||||
RecMenu.Visible := False;
|
||||
ProjMenu := RegisterIDESubMenu(SrcEditMenuSectionEditors, dlgEnvProject, dlgEnvProject);
|
||||
ProjMenu.Visible := False;
|
||||
RegisterIDESubMenu(SrcEditMenuSectionEditors, lisMEOther, lisMEOther).Visible := False;
|
||||
|
||||
//first add all pages in the correct order since the editor order can be different from the tab order
|
||||
for i := 0 to EdList.Count - 1 do
|
||||
begin
|
||||
EditorCur := TSourceEditor(EdList.Objects[i]);
|
||||
s := lisMEOther;
|
||||
P := nil;
|
||||
if (EditorCur.GetProjectFile <> nil) and (EditorCur.GetProjectFile.IsPartOfProject) then
|
||||
s := dlgEnvProject
|
||||
else begin
|
||||
Manager.OnPackageForSourceEditor(P, EditorCur);
|
||||
if P <> nil then
|
||||
s := Format(lisTabsFor, [p.Name]);
|
||||
end;
|
||||
|
||||
if SrcEditMenuSectionEditors.FindByName(S) is TIDEMenuSection then begin
|
||||
M := TIDEMenuSection(SrcEditMenuSectionEditors.FindByName(S))
|
||||
end else begin
|
||||
M := RegisterIDESubMenu(SrcEditMenuSectionEditors, S, S);
|
||||
M.UserTag := PtrUInt(P);
|
||||
end;
|
||||
M.Visible := True;
|
||||
|
||||
AddEditorToMenuSection(EditorCur, M, i);
|
||||
// use tag to count modified
|
||||
if EditorCur.Modified then M.Tag := m.Tag + 1;
|
||||
end;
|
||||
|
||||
EdList.Free;
|
||||
|
||||
// add recent tabs. skip 0 since that is the active tab
|
||||
for i := 1 to Min(10, FHistoryList.Count-1) do
|
||||
begin
|
||||
EditorCur := FindSourceEditorWithPageIndex(FNotebook.IndexOf(TCustomPage(FHistoryList[i])));
|
||||
if (EditorCur = nil) or (not EditorCur.FEditor.HandleAllocated) then continue; // show only if it was visited
|
||||
AddEditorToMenuSection(EditorCur, RecMenu, i);
|
||||
RecMenu.Visible := True;
|
||||
end;
|
||||
|
||||
for i := 0 to SrcEditMenuSectionEditors.Count - 1 do begin
|
||||
if SrcEditMenuSectionEditors.Items[i] is TIDEMenuSection then begin
|
||||
M := SrcEditMenuSectionEditors.Items[i] as TIDEMenuSection;
|
||||
|
||||
if M.Tag = 0 then
|
||||
M.Caption := M.Caption + Format(' (%d)', [M.Count])
|
||||
else
|
||||
M.Caption := M.Caption + Format(' (*%d/%d)', [M.Tag, M.Count]);
|
||||
|
||||
if M.UserTag <> 0 then
|
||||
RegisterIDEMenuCommand(
|
||||
RegisterIDEMenuSection(M as TIDEMenuSection, 'Open lpk sect '+TIDEPackage(M.UserTag).Filename),
|
||||
'Open lpk '+TIDEPackage(M.UserTag).Filename,
|
||||
lisCompPalOpenPackage, @OnPopupOpenPackageFile, nil, nil, '', M.UserTag);
|
||||
end;
|
||||
end;
|
||||
|
||||
if ProjMenu.Visible then begin
|
||||
RegisterIDEMenuCommand(
|
||||
RegisterIDEMenuSection(ProjMenu, 'Open proj sect '),
|
||||
'Open proj', lisOpenProject2, @OnPopupOpenProjectInsp);
|
||||
end;
|
||||
EdList.Free;
|
||||
|
||||
// add recent tabs. skip 0 since that is the active tab
|
||||
for i := 1 to Min(10, FHistoryList.Count-1) do
|
||||
begin
|
||||
EditorCur := FindSourceEditorWithPageIndex(FNotebook.IndexOf(TCustomPage(FHistoryList[i])));
|
||||
if (EditorCur = nil) or (not EditorCur.FEditor.HandleAllocated) then continue; // show only if it was visited
|
||||
AddEditorToMenuSection(EditorCur, RecMenu, i);
|
||||
RecMenu.Visible := True;
|
||||
end;
|
||||
finally
|
||||
SourceTabMenuRoot.EndUpdate;
|
||||
|
||||
for i := 0 to SrcEditMenuSectionEditors.Count - 1 do begin
|
||||
if SrcEditMenuSectionEditors.Items[i] is TIDEMenuSection then begin
|
||||
M := SrcEditMenuSectionEditors.Items[i] as TIDEMenuSection;
|
||||
|
||||
if M.Tag = 0 then
|
||||
M.Caption := M.Caption + Format(' (%d)', [M.Count])
|
||||
else
|
||||
M.Caption := M.Caption + Format(' (*%d/%d)', [M.Tag, M.Count]);
|
||||
|
||||
if M.UserTag <> 0 then
|
||||
RegisterIDEMenuCommand(
|
||||
RegisterIDEMenuSection(M as TIDEMenuSection, 'Open lpk sect '+TIDEPackage(M.UserTag).Filename),
|
||||
'Open lpk '+TIDEPackage(M.UserTag).Filename,
|
||||
lisCompPalOpenPackage, @OnPopupOpenPackageFile, nil, nil, '', M.UserTag);
|
||||
end;
|
||||
end;
|
||||
|
||||
if ProjMenu.Visible then begin
|
||||
RegisterIDEMenuCommand(
|
||||
RegisterIDEMenuSection(ProjMenu, 'Open proj sect '),
|
||||
'Open proj', lisOpenProject2, @OnPopupOpenProjectInsp);
|
||||
end;
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -6666,93 +6661,89 @@ begin
|
||||
IDECommandList.ExecuteUpdateEvents;
|
||||
|
||||
SourceEditorMenuRoot.MenuItem:=SrcPopupMenu.Items;
|
||||
SourceEditorMenuRoot.BeginUpdate;
|
||||
try
|
||||
RemoveUserDefinedMenuItems;
|
||||
RemoveContextMenuItems;
|
||||
RemoveUserDefinedMenuItems;
|
||||
RemoveContextMenuItems;
|
||||
|
||||
ASrcEdit:=FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
||||
Assert(Assigned(ASrcEdit), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit=nil');
|
||||
Assert((ASrcEdit=GetActiveSE), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit<>GetActiveSE');
|
||||
EditorComp:=ASrcEdit.EditorComponent;
|
||||
ASrcEdit:=FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
||||
Assert(Assigned(ASrcEdit), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit=nil');
|
||||
Assert((ASrcEdit=GetActiveSE), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit<>GetActiveSE');
|
||||
EditorComp:=ASrcEdit.EditorComponent;
|
||||
|
||||
SrcEditMenuReadOnly.Checked:=ASrcEdit.ReadOnly;
|
||||
SrcEditMenuShowLineNumbers.Checked := ASrcEdit.EditorComponent.Gutter.LineNumberPart.Visible;
|
||||
SrcEditMenuDisableI18NForLFM.Visible:=false;
|
||||
SrcEditMenuReadOnly.Checked:=ASrcEdit.ReadOnly;
|
||||
SrcEditMenuShowLineNumbers.Checked := ASrcEdit.EditorComponent.Gutter.LineNumberPart.Visible;
|
||||
SrcEditMenuDisableI18NForLFM.Visible:=false;
|
||||
|
||||
UpdateHighlightMenuItems(ASrcEdit);
|
||||
UpdateEncodingMenuItems(ASrcEdit);
|
||||
UpdateLineEndingMenuItems(ASrcEdit);
|
||||
UpdateHighlightMenuItems(ASrcEdit);
|
||||
UpdateEncodingMenuItems(ASrcEdit);
|
||||
UpdateLineEndingMenuItems(ASrcEdit);
|
||||
|
||||
// ask Codetools
|
||||
CurFilename:=ASrcEdit.FileName;
|
||||
ShortFileName:=ExtractFileName(CurFilename);
|
||||
MainCodeBuf:=nil;
|
||||
if FilenameIsPascalUnit(ShortFileName)
|
||||
or (CompareFileExt(ShortFileName,'.inc',true)=0) then
|
||||
MainCodeBuf:=CodeToolBoss.GetMainCode(ASrcEdit.CodeBuffer)
|
||||
else if FilenameIsPascalSource(ShortFileName) then
|
||||
MainCodeBuf:=ASrcEdit.CodeBuffer;
|
||||
// ask Codetools
|
||||
CurFilename:=ASrcEdit.FileName;
|
||||
ShortFileName:=ExtractFileName(CurFilename);
|
||||
MainCodeBuf:=nil;
|
||||
if FilenameIsPascalUnit(ShortFileName)
|
||||
or (CompareFileExt(ShortFileName,'.inc',true)=0) then
|
||||
MainCodeBuf:=CodeToolBoss.GetMainCode(ASrcEdit.CodeBuffer)
|
||||
else if FilenameIsPascalSource(ShortFileName) then
|
||||
MainCodeBuf:=ASrcEdit.CodeBuffer;
|
||||
|
||||
if (FilenameIsAbsolute(CurFilename)) then begin
|
||||
if (MainCodeBuf<>nil) and (MainCodeBuf<>ASrcEdit.CodeBuffer)
|
||||
and (not MainCodeBuf.IsVirtual) then begin
|
||||
// this is an include file => add link to open unit
|
||||
CurFilename:=MainCodeBuf.Filename;
|
||||
ShortFileName:=ExtractFileName(CurFilename);
|
||||
AddContextPopupMenuItem(
|
||||
Format(lisOpenLfm,
|
||||
[CreateRelativePath(CurFilename,ExtractFilePath(ASrcEdit.Filename))]),
|
||||
true,@OnPopupMenuOpenFile);
|
||||
end;
|
||||
if FilenameIsPascalUnit(ShortFileName) then begin
|
||||
MaybeAddPopup('.lfm');
|
||||
MaybeAddPopup('.dfm');
|
||||
MaybeAddPopup('.lrs');
|
||||
MaybeAddPopup('.s');
|
||||
end;
|
||||
// ToDo: unit resources
|
||||
if (CompareFileExt(ShortFileName,'.lfm',true)=0)
|
||||
or (CompareFileExt(ShortFileName,'.dfm',true)=0) then begin
|
||||
MaybeAddPopup('.pas');
|
||||
MaybeAddPopup('.pp');
|
||||
MaybeAddPopup('.p');
|
||||
end;
|
||||
if (CompareFileExt(ShortFileName,'.lpi',true)=0)
|
||||
or (CompareFileExt(ShortFileName,'.lpk',true)=0) then begin
|
||||
AddContextPopupMenuItem(
|
||||
Format(lisOpenLfm,[ShortFileName]),true,@OnPopupMenuOpenFile);
|
||||
end;
|
||||
FPDocSrc:=LazarusHelp.GetFPDocFilenameForSource(CurFilename,false,AnOwner);
|
||||
if FPDocSrc<>'' then
|
||||
AddContextPopupMenuItem(
|
||||
Format(lisOpenLfm,
|
||||
[CreateRelativePath(FPDocSrc,ExtractFilePath(CurFilename))]),
|
||||
true,@OnPopupMenuOpenFile);
|
||||
if (FilenameIsAbsolute(CurFilename)) then begin
|
||||
if (MainCodeBuf<>nil) and (MainCodeBuf<>ASrcEdit.CodeBuffer)
|
||||
and (not MainCodeBuf.IsVirtual) then begin
|
||||
// this is an include file => add link to open unit
|
||||
CurFilename:=MainCodeBuf.Filename;
|
||||
ShortFileName:=ExtractFileName(CurFilename);
|
||||
AddContextPopupMenuItem(
|
||||
Format(lisOpenLfm,
|
||||
[CreateRelativePath(CurFilename,ExtractFilePath(ASrcEdit.Filename))]),
|
||||
true,@OnPopupMenuOpenFile);
|
||||
end;
|
||||
|
||||
EditorPopupPoint:=EditorComp.ScreenToClient(SrcPopUpMenu.PopupPoint);
|
||||
if EditorPopupPoint.X<=EditorComp.Gutter.Width then begin
|
||||
EditorCaret := EditorComp.PhysicalToLogicalPos(EditorComp.PixelsToRowColumn(EditorPopupPoint));
|
||||
// user clicked on gutter
|
||||
SourceEditorMarks.GetMarksForLine(ASrcEdit, EditorCaret.y, Marks, MarkCount);
|
||||
if Marks <> nil then begin
|
||||
for i := 0 to MarkCount-1 do
|
||||
Marks[i].CreatePopupMenuItems(@AddUserDefinedPopupMenuItem);
|
||||
FreeMem(Marks);
|
||||
end;
|
||||
if (EditorCaret.Y<=EditorComp.Lines.Count)
|
||||
and (MessagesView<>nil) then
|
||||
MessagesView.SourceEditorPopup(EditorComp.Marks.Line[EditorCaret.Y],
|
||||
EditorComp.LogicalCaretXY);
|
||||
if FilenameIsPascalUnit(ShortFileName) then begin
|
||||
MaybeAddPopup('.lfm');
|
||||
MaybeAddPopup('.dfm');
|
||||
MaybeAddPopup('.lrs');
|
||||
MaybeAddPopup('.s');
|
||||
end;
|
||||
|
||||
if Assigned(Manager.OnPopupMenu) then
|
||||
Manager.OnPopupMenu(@AddContextPopupMenuItem);
|
||||
SourceEditorMenuRoot.NotifySubSectionOnShow(Self);
|
||||
finally
|
||||
SourceEditorMenuRoot.EndUpdate;
|
||||
// ToDo: unit resources
|
||||
if (CompareFileExt(ShortFileName,'.lfm',true)=0)
|
||||
or (CompareFileExt(ShortFileName,'.dfm',true)=0) then begin
|
||||
MaybeAddPopup('.pas');
|
||||
MaybeAddPopup('.pp');
|
||||
MaybeAddPopup('.p');
|
||||
end;
|
||||
if (CompareFileExt(ShortFileName,'.lpi',true)=0)
|
||||
or (CompareFileExt(ShortFileName,'.lpk',true)=0) then begin
|
||||
AddContextPopupMenuItem(
|
||||
Format(lisOpenLfm,[ShortFileName]),true,@OnPopupMenuOpenFile);
|
||||
end;
|
||||
FPDocSrc:=LazarusHelp.GetFPDocFilenameForSource(CurFilename,false,AnOwner);
|
||||
if FPDocSrc<>'' then
|
||||
AddContextPopupMenuItem(
|
||||
Format(lisOpenLfm,
|
||||
[CreateRelativePath(FPDocSrc,ExtractFilePath(CurFilename))]),
|
||||
true,@OnPopupMenuOpenFile);
|
||||
end;
|
||||
|
||||
EditorPopupPoint:=EditorComp.ScreenToClient(SrcPopUpMenu.PopupPoint);
|
||||
if EditorPopupPoint.X<=EditorComp.Gutter.Width then begin
|
||||
EditorCaret := EditorComp.PhysicalToLogicalPos(EditorComp.PixelsToRowColumn(EditorPopupPoint));
|
||||
// user clicked on gutter
|
||||
SourceEditorMarks.GetMarksForLine(ASrcEdit, EditorCaret.y, Marks, MarkCount);
|
||||
if Marks <> nil then begin
|
||||
for i := 0 to MarkCount-1 do
|
||||
Marks[i].CreatePopupMenuItems(@AddUserDefinedPopupMenuItem);
|
||||
FreeMem(Marks);
|
||||
end;
|
||||
if (EditorCaret.Y<=EditorComp.Lines.Count)
|
||||
and (MessagesView<>nil) then
|
||||
MessagesView.SourceEditorPopup(EditorComp.Marks.Line[EditorCaret.Y],
|
||||
EditorComp.LogicalCaretXY);
|
||||
end;
|
||||
|
||||
if Assigned(Manager.OnPopupMenu) then
|
||||
Manager.OnPopupMenu(@AddContextPopupMenuItem);
|
||||
SourceEditorMenuRoot.NotifySubSectionOnShow(Self);
|
||||
//SrcPopupMenu.Items.WriteDebugReport('TSourceNotebook.SrcPopUpMenuPopup() ');
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.DbgPopUpMenuPopup(Sender: TObject);
|
||||
@ -6809,8 +6800,6 @@ begin
|
||||
Images := IDEImages.Images_16;
|
||||
end;
|
||||
|
||||
// assign the root TMenuItem to the registered menu root.
|
||||
// This will automatically create all registered items
|
||||
{$IFDEF VerboseMenuIntf}
|
||||
SrcPopupMenu.Items.WriteDebugReport('TSourceNotebook.BuildPopupMenu ');
|
||||
SourceTabMenuRoot.ConsistencyCheck;
|
||||
|
Loading…
Reference in New Issue
Block a user