mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 22:56:06 +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 SetChildrenAsSubMenu(const AValue: boolean); virtual;
|
||||||
procedure SetVisible(const AValue: Boolean); override;
|
procedure SetVisible(const AValue: Boolean); override;
|
||||||
procedure SetSubMenuImages(const AValue: TCustomImageList); virtual;
|
procedure SetSubMenuImages(const AValue: TCustomImageList); virtual;
|
||||||
|
procedure SetMenuItem(const AValue: TMenuItem); override;
|
||||||
procedure ClearMenuItems; override;
|
procedure ClearMenuItems; override;
|
||||||
procedure FreeTopSeparator;
|
procedure FreeTopSeparator;
|
||||||
procedure FreeBottomSeparator;
|
procedure FreeBottomSeparator;
|
||||||
@ -972,6 +973,15 @@ begin
|
|||||||
MenuItem.SubMenuImages:=SubMenuImages;
|
MenuItem.SubMenuImages:=SubMenuImages;
|
||||||
end;
|
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;
|
procedure TIDEMenuSection.ClearMenuItems;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
@ -1062,6 +1072,7 @@ var
|
|||||||
SubSection: TIDEMenuSection;
|
SubSection: TIDEMenuSection;
|
||||||
aVisible: Boolean;
|
aVisible: Boolean;
|
||||||
begin
|
begin
|
||||||
|
if imssClearing in aSection.FStates then exit;
|
||||||
aVisible:=aSection.RealVisible;
|
aVisible:=aSection.RealVisible;
|
||||||
for i:=0 to aSection.Count-1 do begin
|
for i:=0 to aSection.Count-1 do begin
|
||||||
Item:=aSection[i];
|
Item:=aSection[i];
|
||||||
|
@ -2754,146 +2754,141 @@ var
|
|||||||
VisibleCnt: Integer;
|
VisibleCnt: Integer;
|
||||||
begin
|
begin
|
||||||
MessagesMenuRoot.MenuItem:=MsgCtrlPopupMenu.Items;
|
MessagesMenuRoot.MenuItem:=MsgCtrlPopupMenu.Items;
|
||||||
MessagesMenuRoot.BeginUpdate;
|
HasText:=false;
|
||||||
try
|
HasFilename:=false;
|
||||||
HasText:=false;
|
MsgType:='';
|
||||||
HasFilename:=false;
|
CanFilterMsgType:=false;
|
||||||
MsgType:='';
|
Line:=nil;
|
||||||
CanFilterMsgType:=false;
|
HasViewContent:=false;
|
||||||
Line:=nil;
|
Running:=false;
|
||||||
HasViewContent:=false;
|
|
||||||
Running:=false;
|
|
||||||
|
|
||||||
// check all
|
// check all
|
||||||
for i:=0 to MessagesCtrl.ViewCount-1 do begin
|
for i:=0 to MessagesCtrl.ViewCount-1 do begin
|
||||||
View:=MessagesCtrl.Views[i];
|
View:=MessagesCtrl.Views[i];
|
||||||
if View.HasContent then
|
if View.HasContent then
|
||||||
HasViewContent:=true;
|
HasViewContent:=true;
|
||||||
if View.Running then
|
if View.Running then
|
||||||
Running:=true;
|
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;
|
|
||||||
end;
|
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;
|
end;
|
||||||
|
|
||||||
procedure TMessagesFrame.OnSelectFilterClick(Sender: TObject);
|
procedure TMessagesFrame.OnSelectFilterClick(Sender: TObject);
|
||||||
|
@ -6528,109 +6528,104 @@ var
|
|||||||
begin
|
begin
|
||||||
PopM:=TPopupMenu(Sender);
|
PopM:=TPopupMenu(Sender);
|
||||||
SourceTabMenuRoot.MenuItem:=PopM.Items;
|
SourceTabMenuRoot.MenuItem:=PopM.Items;
|
||||||
SourceTabMenuRoot.BeginUpdate;
|
// Get the tab that was clicked
|
||||||
try
|
if PopM.PopupComponent is TPageControl then begin
|
||||||
// Get the tab that was clicked
|
PageCtrl:=TPageControl(PopM.PopupComponent);
|
||||||
if PopM.PopupComponent is TPageControl then begin
|
PageI:=PageCtrl.TabIndexAtClientPos(PageCtrl.ScreenToClient(PopM.PopupPoint));
|
||||||
PageCtrl:=TPageControl(PopM.PopupComponent);
|
if (PageI>=0) and (PageI<PageCtrl.PageCount) then
|
||||||
PageI:=PageCtrl.TabIndexAtClientPos(PageCtrl.ScreenToClient(PopM.PopupPoint));
|
PageIndex := PageI // Todo: This should be in MouseDown / or both, whichever is first
|
||||||
if (PageI>=0) and (PageI<PageCtrl.PageCount) then
|
else
|
||||||
PageIndex := PageI // Todo: This should be in MouseDown / or both, whichever is first
|
DebugLn(['TSourceNotebook.TabPopUpMenuPopup: Popup PageIndex=', PageI]);
|
||||||
else
|
end;
|
||||||
DebugLn(['TSourceNotebook.TabPopUpMenuPopup: Popup PageIndex=', PageI]);
|
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;
|
end;
|
||||||
ASrcEdit:=ActiveEditor as TSourceEditor;
|
|
||||||
|
|
||||||
{$IFnDEF SingleSrcWindow}
|
EdList.Free;
|
||||||
// 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;
|
|
||||||
|
|
||||||
|
// 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;
|
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;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -6666,93 +6661,89 @@ begin
|
|||||||
IDECommandList.ExecuteUpdateEvents;
|
IDECommandList.ExecuteUpdateEvents;
|
||||||
|
|
||||||
SourceEditorMenuRoot.MenuItem:=SrcPopupMenu.Items;
|
SourceEditorMenuRoot.MenuItem:=SrcPopupMenu.Items;
|
||||||
SourceEditorMenuRoot.BeginUpdate;
|
RemoveUserDefinedMenuItems;
|
||||||
try
|
RemoveContextMenuItems;
|
||||||
RemoveUserDefinedMenuItems;
|
|
||||||
RemoveContextMenuItems;
|
|
||||||
|
|
||||||
ASrcEdit:=FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
ASrcEdit:=FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
||||||
Assert(Assigned(ASrcEdit), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit=nil');
|
Assert(Assigned(ASrcEdit), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit=nil');
|
||||||
Assert((ASrcEdit=GetActiveSE), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit<>GetActiveSE');
|
Assert((ASrcEdit=GetActiveSE), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit<>GetActiveSE');
|
||||||
EditorComp:=ASrcEdit.EditorComponent;
|
EditorComp:=ASrcEdit.EditorComponent;
|
||||||
|
|
||||||
SrcEditMenuReadOnly.Checked:=ASrcEdit.ReadOnly;
|
SrcEditMenuReadOnly.Checked:=ASrcEdit.ReadOnly;
|
||||||
SrcEditMenuShowLineNumbers.Checked := ASrcEdit.EditorComponent.Gutter.LineNumberPart.Visible;
|
SrcEditMenuShowLineNumbers.Checked := ASrcEdit.EditorComponent.Gutter.LineNumberPart.Visible;
|
||||||
SrcEditMenuDisableI18NForLFM.Visible:=false;
|
SrcEditMenuDisableI18NForLFM.Visible:=false;
|
||||||
|
|
||||||
UpdateHighlightMenuItems(ASrcEdit);
|
UpdateHighlightMenuItems(ASrcEdit);
|
||||||
UpdateEncodingMenuItems(ASrcEdit);
|
UpdateEncodingMenuItems(ASrcEdit);
|
||||||
UpdateLineEndingMenuItems(ASrcEdit);
|
UpdateLineEndingMenuItems(ASrcEdit);
|
||||||
|
|
||||||
// ask Codetools
|
// ask Codetools
|
||||||
CurFilename:=ASrcEdit.FileName;
|
CurFilename:=ASrcEdit.FileName;
|
||||||
ShortFileName:=ExtractFileName(CurFilename);
|
ShortFileName:=ExtractFileName(CurFilename);
|
||||||
MainCodeBuf:=nil;
|
MainCodeBuf:=nil;
|
||||||
if FilenameIsPascalUnit(ShortFileName)
|
if FilenameIsPascalUnit(ShortFileName)
|
||||||
or (CompareFileExt(ShortFileName,'.inc',true)=0) then
|
or (CompareFileExt(ShortFileName,'.inc',true)=0) then
|
||||||
MainCodeBuf:=CodeToolBoss.GetMainCode(ASrcEdit.CodeBuffer)
|
MainCodeBuf:=CodeToolBoss.GetMainCode(ASrcEdit.CodeBuffer)
|
||||||
else if FilenameIsPascalSource(ShortFileName) then
|
else if FilenameIsPascalSource(ShortFileName) then
|
||||||
MainCodeBuf:=ASrcEdit.CodeBuffer;
|
MainCodeBuf:=ASrcEdit.CodeBuffer;
|
||||||
|
|
||||||
if (FilenameIsAbsolute(CurFilename)) then begin
|
if (FilenameIsAbsolute(CurFilename)) then begin
|
||||||
if (MainCodeBuf<>nil) and (MainCodeBuf<>ASrcEdit.CodeBuffer)
|
if (MainCodeBuf<>nil) and (MainCodeBuf<>ASrcEdit.CodeBuffer)
|
||||||
and (not MainCodeBuf.IsVirtual) then begin
|
and (not MainCodeBuf.IsVirtual) then begin
|
||||||
// this is an include file => add link to open unit
|
// this is an include file => add link to open unit
|
||||||
CurFilename:=MainCodeBuf.Filename;
|
CurFilename:=MainCodeBuf.Filename;
|
||||||
ShortFileName:=ExtractFileName(CurFilename);
|
ShortFileName:=ExtractFileName(CurFilename);
|
||||||
AddContextPopupMenuItem(
|
AddContextPopupMenuItem(
|
||||||
Format(lisOpenLfm,
|
Format(lisOpenLfm,
|
||||||
[CreateRelativePath(CurFilename,ExtractFilePath(ASrcEdit.Filename))]),
|
[CreateRelativePath(CurFilename,ExtractFilePath(ASrcEdit.Filename))]),
|
||||||
true,@OnPopupMenuOpenFile);
|
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);
|
|
||||||
end;
|
end;
|
||||||
|
if FilenameIsPascalUnit(ShortFileName) then begin
|
||||||
EditorPopupPoint:=EditorComp.ScreenToClient(SrcPopUpMenu.PopupPoint);
|
MaybeAddPopup('.lfm');
|
||||||
if EditorPopupPoint.X<=EditorComp.Gutter.Width then begin
|
MaybeAddPopup('.dfm');
|
||||||
EditorCaret := EditorComp.PhysicalToLogicalPos(EditorComp.PixelsToRowColumn(EditorPopupPoint));
|
MaybeAddPopup('.lrs');
|
||||||
// user clicked on gutter
|
MaybeAddPopup('.s');
|
||||||
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;
|
end;
|
||||||
|
// ToDo: unit resources
|
||||||
if Assigned(Manager.OnPopupMenu) then
|
if (CompareFileExt(ShortFileName,'.lfm',true)=0)
|
||||||
Manager.OnPopupMenu(@AddContextPopupMenuItem);
|
or (CompareFileExt(ShortFileName,'.dfm',true)=0) then begin
|
||||||
SourceEditorMenuRoot.NotifySubSectionOnShow(Self);
|
MaybeAddPopup('.pas');
|
||||||
finally
|
MaybeAddPopup('.pp');
|
||||||
SourceEditorMenuRoot.EndUpdate;
|
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;
|
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;
|
end;
|
||||||
|
|
||||||
procedure TSourceNotebook.DbgPopUpMenuPopup(Sender: TObject);
|
procedure TSourceNotebook.DbgPopUpMenuPopup(Sender: TObject);
|
||||||
@ -6809,8 +6800,6 @@ begin
|
|||||||
Images := IDEImages.Images_16;
|
Images := IDEImages.Images_16;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// assign the root TMenuItem to the registered menu root.
|
|
||||||
// This will automatically create all registered items
|
|
||||||
{$IFDEF VerboseMenuIntf}
|
{$IFDEF VerboseMenuIntf}
|
||||||
SrcPopupMenu.Items.WriteDebugReport('TSourceNotebook.BuildPopupMenu ');
|
SrcPopupMenu.Items.WriteDebugReport('TSourceNotebook.BuildPopupMenu ');
|
||||||
SourceTabMenuRoot.ConsistencyCheck;
|
SourceTabMenuRoot.ConsistencyCheck;
|
||||||
|
Loading…
Reference in New Issue
Block a user