mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:39:20 +02:00
IDE: Update the popup menu for Source Editor in a right place.
git-svn-id: trunk@35737 -
This commit is contained in:
parent
691b677599
commit
80faea06cf
@ -5339,24 +5339,8 @@ end;
|
|||||||
|
|
||||||
procedure TSourceNotebook.TabPopUpMenuPopup(Sender: TObject);
|
procedure TSourceNotebook.TabPopUpMenuPopup(Sender: TObject);
|
||||||
var
|
var
|
||||||
CurFilename: String;
|
|
||||||
ASrcEdit: TSourceEditor;
|
ASrcEdit: TSourceEditor;
|
||||||
|
|
||||||
function MaybeAddPopup(const ASuffix: String; ANewOnClick: TNotifyEvent = nil;
|
|
||||||
Filename: string = ''): TIDEMenuItem;
|
|
||||||
begin
|
|
||||||
Result:=nil;
|
|
||||||
if ANewOnClick=nil then
|
|
||||||
ANewOnClick:=@OnPopupMenuOpenFile;
|
|
||||||
if Filename='' then
|
|
||||||
Filename:=CurFilename;
|
|
||||||
Filename:=ChangeFileExt(Filename,ASuffix);
|
|
||||||
if FileExistsCached(Filename) then begin
|
|
||||||
Filename:=CreateRelativePath(Filename,ExtractFilePath(ASrcEdit.FileName));
|
|
||||||
Result:=AddContextPopupMenuItem(Format(lisOpenLfm,[Filename]), true, ANewOnClick);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{$IFnDEF SingleSrcWindow}
|
{$IFnDEF SingleSrcWindow}
|
||||||
function ToWindow(ASection: TIDEMenuSection; const OpName: string;
|
function ToWindow(ASection: TIDEMenuSection; const OpName: string;
|
||||||
const OnClickMethod: TNotifyEvent; WinForFind: Boolean = False): Boolean;
|
const OnClickMethod: TNotifyEvent; WinForFind: Boolean = False): Boolean;
|
||||||
@ -5372,8 +5356,7 @@ var
|
|||||||
SharedEditor:=nb.IndexOfEditorInShareWith(ASrcEdit);
|
SharedEditor:=nb.IndexOfEditorInShareWith(ASrcEdit);
|
||||||
if (i <> ThisWin) and ((SharedEditor < 0) <> WinForFind) then begin
|
if (i <> ThisWin) and ((SharedEditor < 0) <> WinForFind) then begin
|
||||||
Result := True;
|
Result := True;
|
||||||
with RegisterIDEMenuCommand(ASection, OpName+IntToStr(i), nb.Caption,
|
with RegisterIDEMenuCommand(ASection,OpName+IntToStr(i),nb.Caption,OnClickMethod) do
|
||||||
OnClickMethod) do
|
|
||||||
Tag := i;
|
Tag := i;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -5381,9 +5364,6 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
var
|
var
|
||||||
MainCodeBuf: TCodeBuffer;
|
|
||||||
FPDocSrc, ShortFileName: String;
|
|
||||||
AnOwner: TObject;
|
|
||||||
NBAvail: Boolean;
|
NBAvail: Boolean;
|
||||||
PageCtrl: TPageControl;
|
PageCtrl: TPageControl;
|
||||||
PopM: TPopupMenu;
|
PopM: TPopupMenu;
|
||||||
@ -5402,7 +5382,83 @@ begin
|
|||||||
//DebugLn(['TSourceNotebook.TabPopUpMenuPopup: Popup PageIndex=', PageIndex]);
|
//DebugLn(['TSourceNotebook.TabPopUpMenuPopup: Popup PageIndex=', PageIndex]);
|
||||||
ASrcEdit:=Editors[PageIndex];
|
ASrcEdit:=Editors[PageIndex];
|
||||||
|
|
||||||
// Readonly, ShowLineNumbers
|
// editor layout
|
||||||
|
SrcEditMenuMoveEditorLeft.MenuItem.Enabled:= (PageCount>1);
|
||||||
|
SrcEditMenuMoveEditorRight.MenuItem.Enabled:= (PageCount>1);
|
||||||
|
SrcEditMenuMoveEditorFirst.MenuItem.Enabled:= (PageCount>1) and (PageIndex>0);
|
||||||
|
SrcEditMenuMoveEditorLast.MenuItem.Enabled:= (PageCount>1) and (PageIndex<(PageCount-1));
|
||||||
|
|
||||||
|
{$IFnDEF SingleSrcWindow}
|
||||||
|
SrcEditMenuEditorLock.Checked := ASrcEdit.IsLocked; // Editor locks
|
||||||
|
// Multi win
|
||||||
|
NBAvail := ToWindow(SrcEditMenuMoveToOtherWindowList, 'MoveToWindow',
|
||||||
|
@SrcEditMenuMoveToExistingWindowClicked);
|
||||||
|
SrcEditMenuMoveToNewWindow.Visible := not NBAvail;
|
||||||
|
SrcEditMenuMoveToNewWindow.Enabled := PageCount > 1;
|
||||||
|
SrcEditMenuMoveToOtherWindow.Visible := NBAvail;
|
||||||
|
SrcEditMenuMoveToOtherWindowNew.Enabled := (PageCount > 1);
|
||||||
|
|
||||||
|
NBAvail := ToWindow(SrcEditMenuCopyToOtherWindowList, 'CopyToWindow',
|
||||||
|
@SrcEditMenuCopyToExistingWindowClicked);
|
||||||
|
SrcEditMenuCopyToNewWindow.Visible := not NBAvail;
|
||||||
|
SrcEditMenuCopyToOtherWindow.Visible := NBAvail;
|
||||||
|
|
||||||
|
NBAvail := ToWindow(SrcEditMenuFindInOtherWindowList, 'FindInWindow',
|
||||||
|
@SrcEditMenuFindInWindowClicked, True);
|
||||||
|
SrcEditMenuFindInOtherWindow.Enabled := NBAvail;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
|
if Assigned(Manager.OnPopupMenu) then
|
||||||
|
Manager.OnPopupMenu(@AddContextPopupMenuItem);
|
||||||
|
SourceTabMenuRoot.NotifySubSectionOnShow(Self);
|
||||||
|
finally
|
||||||
|
SourceTabMenuRoot.EndUpdate;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.SrcPopUpMenuPopup(Sender: TObject);
|
||||||
|
var
|
||||||
|
ASrcEdit: TSourceEditor;
|
||||||
|
CurFilename: String;
|
||||||
|
|
||||||
|
function MaybeAddPopup(const ASuffix: String; ANewOnClick: TNotifyEvent = nil;
|
||||||
|
Filename: string = ''): TIDEMenuItem;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
if ANewOnClick=nil then
|
||||||
|
ANewOnClick:=@OnPopupMenuOpenFile;
|
||||||
|
if Filename='' then
|
||||||
|
Filename:=CurFilename;
|
||||||
|
Filename:=ChangeFileExt(Filename,ASuffix);
|
||||||
|
if FileExistsCached(Filename) then begin
|
||||||
|
Filename:=CreateRelativePath(Filename,ExtractFilePath(ASrcEdit.FileName));
|
||||||
|
Result:=AddContextPopupMenuItem(Format(lisOpenLfm,[Filename]), true, ANewOnClick);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
MarkSrcEdit, se: TSourceEditor;
|
||||||
|
BookMarkID, BookMarkX, BookMarkY: integer;
|
||||||
|
MarkDesc, FPDocSrc, ShortFileName: String;
|
||||||
|
MarkMenuItem: TIDEMenuItem;
|
||||||
|
EditorComp: TSynEdit;
|
||||||
|
MainCodeBuf: TCodeBuffer;
|
||||||
|
AnOwner: TObject;
|
||||||
|
Marks: PSourceMark;
|
||||||
|
i, MarkCount: integer;
|
||||||
|
EditorPopupPoint, EditorCaret: TPoint;
|
||||||
|
SelAvail, SelAvailAndWritable: Boolean;
|
||||||
|
CurWordAtCursor: String;
|
||||||
|
AtIdentifier: Boolean;
|
||||||
|
begin
|
||||||
|
SourceEditorMenuRoot.MenuItem:=SrcPopupMenu.Items;
|
||||||
|
SourceEditorMenuRoot.BeginUpdate;
|
||||||
|
try
|
||||||
|
ASrcEdit:=FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
||||||
|
Assert(Assigned(ASrcEdit), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit=nil');
|
||||||
|
EditorComp:=ASrcEdit.EditorComponent;
|
||||||
|
|
||||||
|
// Files section: Readonly, ShowLineNumbers
|
||||||
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;
|
||||||
@ -5411,12 +5467,6 @@ begin
|
|||||||
UpdateEncodingMenuItems;
|
UpdateEncodingMenuItems;
|
||||||
UpdateLineEndingMenuItems;
|
UpdateLineEndingMenuItems;
|
||||||
|
|
||||||
// editor layout
|
|
||||||
SrcEditMenuMoveEditorLeft.MenuItem.Enabled:= (PageCount>1);
|
|
||||||
SrcEditMenuMoveEditorRight.MenuItem.Enabled:= (PageCount>1);
|
|
||||||
SrcEditMenuMoveEditorFirst.MenuItem.Enabled:= (PageCount>1) and (PageIndex>0);
|
|
||||||
SrcEditMenuMoveEditorLast.MenuItem.Enabled:= (PageCount>1) and (PageIndex<(PageCount-1));
|
|
||||||
|
|
||||||
// add context specific menu items
|
// add context specific menu items
|
||||||
CurFilename:=ASrcEdit.FileName;
|
CurFilename:=ASrcEdit.FileName;
|
||||||
ShortFileName:=ExtractFileName(CurFilename);
|
ShortFileName:=ExtractFileName(CurFilename);
|
||||||
@ -5460,56 +5510,6 @@ begin
|
|||||||
true,@OnPopupMenuOpenFile);
|
true,@OnPopupMenuOpenFile);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{$IFnDEF SingleSrcWindow}
|
|
||||||
SrcEditMenuEditorLock.Checked := ASrcEdit.IsLocked; // Editor locks
|
|
||||||
// Multi win
|
|
||||||
NBAvail := ToWindow(SrcEditMenuMoveToOtherWindowList, 'MoveToWindow',
|
|
||||||
@SrcEditMenuMoveToExistingWindowClicked);
|
|
||||||
SrcEditMenuMoveToNewWindow.Visible := not NBAvail;
|
|
||||||
SrcEditMenuMoveToNewWindow.Enabled := PageCount > 1;
|
|
||||||
SrcEditMenuMoveToOtherWindow.Visible := NBAvail;
|
|
||||||
SrcEditMenuMoveToOtherWindowNew.Enabled := (PageCount > 1);
|
|
||||||
|
|
||||||
NBAvail := ToWindow(SrcEditMenuCopyToOtherWindowList, 'CopyToWindow',
|
|
||||||
@SrcEditMenuCopyToExistingWindowClicked);
|
|
||||||
SrcEditMenuCopyToNewWindow.Visible := not NBAvail;
|
|
||||||
SrcEditMenuCopyToOtherWindow.Visible := NBAvail;
|
|
||||||
|
|
||||||
NBAvail := ToWindow(SrcEditMenuFindInOtherWindowList, 'FindInWindow',
|
|
||||||
@SrcEditMenuFindInWindowClicked, True);
|
|
||||||
SrcEditMenuFindInOtherWindow.Enabled := NBAvail;
|
|
||||||
{$ENDIF}
|
|
||||||
|
|
||||||
if Assigned(Manager.OnPopupMenu) then
|
|
||||||
Manager.OnPopupMenu(@AddContextPopupMenuItem);
|
|
||||||
SourceTabMenuRoot.NotifySubSectionOnShow(Self);
|
|
||||||
finally
|
|
||||||
SourceTabMenuRoot.EndUpdate;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TSourceNotebook.SrcPopUpMenuPopup(Sender: TObject);
|
|
||||||
var
|
|
||||||
ASrcEdit: TSourceEditor;
|
|
||||||
MarkSrcEdit, se: TSourceEditor;
|
|
||||||
BookMarkID, BookMarkX, BookMarkY: integer;
|
|
||||||
MarkDesc: String;
|
|
||||||
MarkMenuItem: TIDEMenuItem;
|
|
||||||
EditorComp: TSynEdit;
|
|
||||||
Marks: PSourceMark;
|
|
||||||
i, MarkCount: integer;
|
|
||||||
EditorPopupPoint, EditorCaret: TPoint;
|
|
||||||
SelAvail, SelAvailAndWritable: Boolean;
|
|
||||||
CurWordAtCursor: String;
|
|
||||||
AtIdentifier: Boolean;
|
|
||||||
begin
|
|
||||||
SourceEditorMenuRoot.MenuItem:=SrcPopupMenu.Items;
|
|
||||||
SourceEditorMenuRoot.BeginUpdate;
|
|
||||||
try
|
|
||||||
ASrcEdit:=FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
|
||||||
Assert(Assigned(ASrcEdit), 'TSourceNotebook.SrcPopUpMenuPopup: ASrcEdit=nil');
|
|
||||||
EditorComp:=ASrcEdit.EditorComponent;
|
|
||||||
|
|
||||||
// Clipboard
|
// Clipboard
|
||||||
SrcEditMenuCut.Enabled := ASrcEdit.SelectionAvailable and not ASrcEdit.ReadOnly;
|
SrcEditMenuCut.Enabled := ASrcEdit.SelectionAvailable and not ASrcEdit.ReadOnly;
|
||||||
SrcEditMenuCopy.Enabled := ASrcEdit.SelectionAvailable;
|
SrcEditMenuCopy.Enabled := ASrcEdit.SelectionAvailable;
|
||||||
|
Loading…
Reference in New Issue
Block a user