mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-15 15:28:13 +02:00
added context senstive ope .pas,.pp,.lfm,.lrs file in src editor popup menu
git-svn-id: trunk@6967 -
This commit is contained in:
parent
004ed4fa3e
commit
bd0040e16f
@ -50,7 +50,7 @@ uses
|
|||||||
SynEditTypes, SynEdit, SynRegExpr, SynEditHighlighter, SynEditAutoComplete,
|
SynEditTypes, SynEdit, SynRegExpr, SynEditHighlighter, SynEditAutoComplete,
|
||||||
SynEditKeyCmds, SynCompletion,
|
SynEditKeyCmds, SynCompletion,
|
||||||
// IDE interface
|
// IDE interface
|
||||||
HelpIntf, SrcEditorIntf,
|
HelpIntf, SrcEditorIntf, LazIDEIntf,
|
||||||
// IDE units
|
// IDE units
|
||||||
LazarusIDEStrConsts, LazConf, IDECommands, EditorOptions, KeyMapping, Project,
|
LazarusIDEStrConsts, LazConf, IDECommands, EditorOptions, KeyMapping, Project,
|
||||||
WordCompletion, FindReplaceDialog, FindInFilesDlg, IDEProcs, IDEOptionDefs,
|
WordCompletion, FindReplaceDialog, FindInFilesDlg, IDEProcs, IDEOptionDefs,
|
||||||
@ -377,6 +377,10 @@ type
|
|||||||
procedure NotebookShowTabHint(Sender: TObject; HintInfo: Pointer);
|
procedure NotebookShowTabHint(Sender: TObject; HintInfo: Pointer);
|
||||||
Procedure OpenAtCursorClicked(Sender: TObject);
|
Procedure OpenAtCursorClicked(Sender: TObject);
|
||||||
Procedure ReadOnlyClicked(Sender: TObject);
|
Procedure ReadOnlyClicked(Sender: TObject);
|
||||||
|
procedure OnPopupMenuOpenPasFile(Sender: TObject);
|
||||||
|
procedure OnPopupMenuOpenPPFile(Sender: TObject);
|
||||||
|
procedure OnPopupMenuOpenLFMFile(Sender: TObject);
|
||||||
|
procedure OnPopupMenuOpenLRSFile(Sender: TObject);
|
||||||
Procedure ShowUnitInfo(Sender: TObject);
|
Procedure ShowUnitInfo(Sender: TObject);
|
||||||
procedure SrcPopUpMenuPopup(Sender: TObject);
|
procedure SrcPopUpMenuPopup(Sender: TObject);
|
||||||
Procedure ToggleLineNumbersClicked(Sender: TObject);
|
Procedure ToggleLineNumbersClicked(Sender: TObject);
|
||||||
@ -384,6 +388,7 @@ type
|
|||||||
fAutoFocusLock: integer;
|
fAutoFocusLock: integer;
|
||||||
FCodeTemplateModul: TSynEditAutoComplete;
|
FCodeTemplateModul: TSynEditAutoComplete;
|
||||||
fCustomPopupMenuItems: TList;
|
fCustomPopupMenuItems: TList;
|
||||||
|
fContextPopupMenuItems: TList;
|
||||||
FIncrementalSearchPos: TPoint; // last set position
|
FIncrementalSearchPos: TPoint; // last set position
|
||||||
fIncrementalSearchStartPos: TPoint; // position where to start searching
|
fIncrementalSearchStartPos: TPoint; // position where to start searching
|
||||||
fIncrementalSearchCancelPos: TPoint;// position where to jump on cancel
|
fIncrementalSearchCancelPos: TPoint;// position where to jump on cancel
|
||||||
@ -433,6 +438,10 @@ type
|
|||||||
function AddUserDefinedPopupMenuItem(const NewCaption: string;
|
function AddUserDefinedPopupMenuItem(const NewCaption: string;
|
||||||
const NewEnabled: boolean;
|
const NewEnabled: boolean;
|
||||||
const NewOnClick: TNotifyEvent): TMenuItem;
|
const NewOnClick: TNotifyEvent): TMenuItem;
|
||||||
|
procedure RemoveContextMenuItems;
|
||||||
|
function AddContextPopupMenuItem(const NewCaption: string;
|
||||||
|
const NewEnabled: boolean;
|
||||||
|
const NewOnClick: TNotifyEvent): TMenuItem;
|
||||||
|
|
||||||
procedure UpdateActiveEditColors;
|
procedure UpdateActiveEditColors;
|
||||||
procedure SetIncrementalSearchStr(const AValue: string);
|
procedure SetIncrementalSearchStr(const AValue: string);
|
||||||
@ -2280,6 +2289,7 @@ begin
|
|||||||
FreeThenNil(FHintTimer);
|
FreeThenNil(FHintTimer);
|
||||||
FreeThenNil(FHintWindow);
|
FreeThenNil(FHintWindow);
|
||||||
FreeThenNil(fCustomPopupMenuItems);
|
FreeThenNil(fCustomPopupMenuItems);
|
||||||
|
FreeThenNil(fContextPopupMenuItems);
|
||||||
|
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
end;
|
end;
|
||||||
@ -2762,10 +2772,12 @@ var
|
|||||||
EditorPopupPoint: TPoint;
|
EditorPopupPoint: TPoint;
|
||||||
SelAvail: Boolean;
|
SelAvail: Boolean;
|
||||||
SelAvailAndWritable: Boolean;
|
SelAvailAndWritable: Boolean;
|
||||||
|
CurFilename: String;
|
||||||
begin
|
begin
|
||||||
if not (Sender is TPopupMenu) then exit;
|
if not (Sender is TPopupMenu) then exit;
|
||||||
|
|
||||||
RemoveUserDefinedMenuItems;
|
RemoveUserDefinedMenuItems;
|
||||||
|
RemoveContextMenuItems;
|
||||||
|
|
||||||
ASrcEdit:=
|
ASrcEdit:=
|
||||||
FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
FindSourceEditorWithEditorComponent(TPopupMenu(Sender).PopupComponent);
|
||||||
@ -2826,6 +2838,31 @@ begin
|
|||||||
FreeMem(Marks);
|
FreeMem(Marks);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// add context specific menu items
|
||||||
|
CurFilename:=ASrcEdit.FileName;
|
||||||
|
if FilenameIsPascalUnit(CurFilename)
|
||||||
|
and (FilenameIsAbsolute(CurFilename)) then begin
|
||||||
|
if FileExists(ChangeFileExt(CurFilename,'.lfm')) then
|
||||||
|
AddContextPopupMenuItem(
|
||||||
|
'Open '+ChangeFileExt(ExtractFileName(CurFilename),'.lfm'),
|
||||||
|
true,@OnPopupMenuOpenLFMFile);
|
||||||
|
if FileExists(ChangeFileExt(CurFilename,'.lrs')) then
|
||||||
|
AddContextPopupMenuItem(
|
||||||
|
'Open '+ChangeFileExt(ExtractFileName(CurFilename),'.lrs'),
|
||||||
|
true,@OnPopupMenuOpenLRSFile);
|
||||||
|
end;
|
||||||
|
if (CompareFileExt(CurFilename,'.lfm',true)=0)
|
||||||
|
and (FilenameIsAbsolute(CurFilename)) then begin
|
||||||
|
if FileExists(ChangeFileExt(CurFilename,'.pas')) then
|
||||||
|
AddContextPopupMenuItem(
|
||||||
|
'Open '+ChangeFileExt(ExtractFileName(CurFilename),'.pas'),
|
||||||
|
true,@OnPopupMenuOpenPasFile);
|
||||||
|
if FileExists(ChangeFileExt(CurFilename,'.pp')) then
|
||||||
|
AddContextPopupMenuItem(
|
||||||
|
'Open '+ChangeFileExt(ExtractFileName(CurFilename),'.pp'),
|
||||||
|
true,@OnPopupMenuOpenPPFile);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TSourceNotebook.NotebookShowTabHint(Sender: TObject;
|
procedure TSourceNotebook.NotebookShowTabHint(Sender: TObject;
|
||||||
@ -2866,6 +2903,11 @@ Procedure TSourceNotebook.BuildPopupMenu;
|
|||||||
Result := TMenuItem.Create(Self);
|
Result := TMenuItem.Create(Self);
|
||||||
Result.Caption := '-';
|
Result.Caption := '-';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure AddFileTypeSpecificMenuItems;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
SubMenuItem: TMenuItem;
|
SubMenuItem: TMenuItem;
|
||||||
@ -2900,6 +2942,8 @@ Begin
|
|||||||
OnClick := @CloseClicked;
|
OnClick := @CloseClicked;
|
||||||
end;
|
end;
|
||||||
SrcPopupMenu.Items.Add(ClosePageMenuItem);
|
SrcPopupMenu.Items.Add(ClosePageMenuItem);
|
||||||
|
|
||||||
|
AddFileTypeSpecificMenuItems;
|
||||||
|
|
||||||
SrcPopupMenu.Items.Add(Seperator);
|
SrcPopupMenu.Items.Add(Seperator);
|
||||||
|
|
||||||
@ -3124,6 +3168,40 @@ begin
|
|||||||
SrcPopUpMenu.Items.Insert(NewIndex,Result);
|
SrcPopUpMenu.Items.Insert(NewIndex,Result);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.RemoveContextMenuItems;
|
||||||
|
var
|
||||||
|
AMenuItem: TMenuItem;
|
||||||
|
begin
|
||||||
|
if fContextPopupMenuItems=nil then exit;
|
||||||
|
while fContextPopupMenuItems.Count>0 do begin
|
||||||
|
AMenuItem:=TMenuItem(fContextPopupMenuItems[fContextPopupMenuItems.Count-1]);
|
||||||
|
AMenuItem.Free;
|
||||||
|
fContextPopupMenuItems.Delete(fContextPopupMenuItems.Count-1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TSourceNotebook.AddContextPopupMenuItem(const NewCaption: string;
|
||||||
|
const NewEnabled: boolean; const NewOnClick: TNotifyEvent): TMenuItem;
|
||||||
|
var
|
||||||
|
NewIndex: Integer;
|
||||||
|
begin
|
||||||
|
if fContextPopupMenuItems=nil then fContextPopupMenuItems:=TList.Create;
|
||||||
|
if fContextPopupMenuItems.Count=0 then begin
|
||||||
|
Result:=TMenuItem.Create(Self);
|
||||||
|
Result.Caption:='-';
|
||||||
|
fContextPopupMenuItems.Add(Result);
|
||||||
|
NewIndex:=fContextPopupMenuItems.Count+ClosePageMenuItem.MenuIndex;
|
||||||
|
SrcPopUpMenu.Items.Insert(NewIndex,Result);
|
||||||
|
end;
|
||||||
|
Result:=TMenuItem.Create(Self);
|
||||||
|
fContextPopupMenuItems.Add(Result);
|
||||||
|
Result.Caption:=NewCaption;
|
||||||
|
Result.Enabled:=NewEnabled;
|
||||||
|
Result.OnClick:=NewOnClick;
|
||||||
|
NewIndex:=fContextPopupMenuItems.Count+ClosePageMenuItem.MenuIndex;
|
||||||
|
SrcPopUpMenu.Items.Insert(NewIndex,Result);
|
||||||
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
Procedure TSourceNotebook.EditorChanged
|
Procedure TSourceNotebook.EditorChanged
|
||||||
Params: Sender: TObject
|
Params: Sender: TObject
|
||||||
@ -3815,6 +3893,34 @@ begin
|
|||||||
UpdateStatusBar;
|
UpdateStatusBar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.OnPopupMenuOpenPasFile(Sender: TObject);
|
||||||
|
begin
|
||||||
|
MainIDEInterface.DoOpenEditorFile(ChangeFileExt(GetActiveSE.Filename,'.pas'),
|
||||||
|
Notebook.PageIndex+1,
|
||||||
|
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofUseCache,ofDoNotLoadResource]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.OnPopupMenuOpenPPFile(Sender: TObject);
|
||||||
|
begin
|
||||||
|
MainIDEInterface.DoOpenEditorFile(ChangeFileExt(GetActiveSE.Filename,'.pp'),
|
||||||
|
Notebook.PageIndex+1,
|
||||||
|
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofUseCache,ofDoNotLoadResource]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.OnPopupMenuOpenLFMFile(Sender: TObject);
|
||||||
|
begin
|
||||||
|
MainIDEInterface.DoOpenEditorFile(ChangeFileExt(GetActiveSE.Filename,'.lfm'),
|
||||||
|
Notebook.PageIndex+1,
|
||||||
|
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofUseCache,ofDoNotLoadResource]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TSourceNotebook.OnPopupMenuOpenLRSFile(Sender: TObject);
|
||||||
|
begin
|
||||||
|
MainIDEInterface.DoOpenEditorFile(ChangeFileExt(GetActiveSE.Filename,'.lrs'),
|
||||||
|
Notebook.PageIndex+1,
|
||||||
|
[ofOnlyIfExists,ofAddToRecent,ofRegularFile,ofUseCache,ofDoNotLoadResource]);
|
||||||
|
end;
|
||||||
|
|
||||||
Procedure TSourceNotebook.ShowUnitInfo(Sender: TObject);
|
Procedure TSourceNotebook.ShowUnitInfo(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnShowUnitInfo) then FOnShowUnitInfo(Sender);
|
if Assigned(FOnShowUnitInfo) then FOnShowUnitInfo(Sender);
|
||||||
|
Loading…
Reference in New Issue
Block a user