mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-03 18:01:29 +02:00
cody: simplified code
git-svn-id: trunk@37604 -
This commit is contained in:
parent
1925587551
commit
6efbc9529f
@ -40,29 +40,55 @@ uses
|
|||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
|
function CreateRefactorCommand(CmdCatCodeTools: TIDECommandCategory;
|
||||||
|
Name, Description: string;
|
||||||
|
const OnExecuteMethod: TNotifyEvent; const OnExecuteProc: TNotifyProcedure;
|
||||||
|
const MenuCaption: string = ''): TIDECommand;
|
||||||
|
function CreateSourceCommand(CmdCatCodeTools: TIDECommandCategory;
|
||||||
|
Name, Description: string;
|
||||||
|
const OnExecuteMethod: TNotifyEvent; const OnExecuteProc: TNotifyProcedure;
|
||||||
|
const MenuCaption: string = ''): TIDECommand;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
function CreateRefactorCommand(CmdCatCodeTools: TIDECommandCategory;
|
||||||
|
Name, Description: string;
|
||||||
|
const OnExecuteMethod: TNotifyEvent; const OnExecuteProc: TNotifyProcedure;
|
||||||
|
const MenuCaption: string): TIDECommand;
|
||||||
|
begin
|
||||||
|
Result:=RegisterIDECommand(CmdCatCodeTools, Name, Description,
|
||||||
|
CleanIDEShortCut,CleanIDEShortCut,OnExecuteMethod,OnExecuteProc);
|
||||||
|
RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'SrcEditRefactor'+Name,
|
||||||
|
MenuCaption, nil, nil, Result);
|
||||||
|
RegisterIDEMenuCommand(itmRefactorAdvanced, 'BarRefactor'+Name,
|
||||||
|
MenuCaption, nil, nil, Result);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CreateSourceCommand(CmdCatCodeTools: TIDECommandCategory; Name,
|
||||||
|
Description: string; const OnExecuteMethod: TNotifyEvent;
|
||||||
|
const OnExecuteProc: TNotifyProcedure; const MenuCaption: string
|
||||||
|
): TIDECommand;
|
||||||
|
begin
|
||||||
|
Result:=RegisterIDECommand(CmdCatCodeTools, Name, Description,
|
||||||
|
CleanIDEShortCut,CleanIDEShortCut,OnExecuteMethod,OnExecuteProc);
|
||||||
|
RegisterIDEMenuCommand(SrcEditSubMenuSource, 'SrcEditSource'+Name,
|
||||||
|
MenuCaption, nil, nil, Result);
|
||||||
|
RegisterIDEMenuCommand(itmSourceInsertions, 'BarSource'+Name,
|
||||||
|
MenuCaption, nil, nil, Result);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
var
|
var
|
||||||
CmdCatProjectMenu: TIDECommandCategory;
|
CmdCatProjectMenu: TIDECommandCategory;
|
||||||
CmdCatCodeTools: TIDECommandCategory;
|
CmdCatCodeTools: TIDECommandCategory;
|
||||||
CmdCatFileMenu: TIDECommandCategory;
|
CmdCatFileMenu: TIDECommandCategory;
|
||||||
PPUListCommand: TIDECommand;
|
PPUListCommand: TIDECommand;
|
||||||
AddAssignMethodCommand: TIDECommand;
|
|
||||||
ExplodeAWithBlockCommand: TIDECommand;
|
|
||||||
AddAWithBlockCommand: TIDECommand;
|
|
||||||
InsertFileAtCursorCommand: TIDECommand;
|
|
||||||
DeclareVariableCommand: TIDECommand;
|
|
||||||
TVIconRes: TLResource;
|
TVIconRes: TLResource;
|
||||||
InsertCallInheritedCommand: TIDECommand;
|
|
||||||
ShowCodeNodeInfoCommand: TIDECommand;
|
ShowCodeNodeInfoCommand: TIDECommand;
|
||||||
CmdCatView: TIDECommandCategory;
|
CmdCatView: TIDECommandCategory;
|
||||||
ViewCodyWindowCommand: TIDECommand;
|
ViewCodyWindowCommand: TIDECommand;
|
||||||
{$IFDEF EnableCodyExperiments}
|
{$IFDEF EnableCodyExperiments}
|
||||||
CopyDeclarationToClipboardCommand: TIDECommand;
|
|
||||||
CutDeclarationToClipboardCommand: TIDECommand;
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ShowIdentifierDictionaryCommand: TIDECommand;
|
|
||||||
begin
|
begin
|
||||||
CodyOptions:=TCodyMiscOptions.Create;
|
CodyOptions:=TCodyMiscOptions.Create;
|
||||||
CodyOptions.LoadSafe;
|
CodyOptions.LoadSafe;
|
||||||
@ -93,92 +119,47 @@ begin
|
|||||||
// Source menu - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// Source menu - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
// insert file at cursor
|
// insert file at cursor
|
||||||
InsertFileAtCursorCommand:=RegisterIDECommand(CmdCatFileMenu,
|
CreateSourceCommand(CmdCatFileMenu,'InsertFileAtCursor',
|
||||||
'InsertFileAtCursor',crsInsertFileAtCursor,
|
crsInsertFileAtCursor,nil,@InsertFileAtCursor);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@InsertFileAtCursor);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuSource,'SrcEditInsertFileAtCursor',
|
|
||||||
crsInsertFileAtCursor,nil,nil,InsertFileAtCursorCommand);
|
|
||||||
RegisterIDEMenuCommand(itmSourceInsertions,'InsertFileAtCursor',
|
|
||||||
crsInsertFileAtCursor,nil,nil,InsertFileAtCursorCommand);
|
|
||||||
|
|
||||||
// add call inherited
|
// add call inherited
|
||||||
InsertCallInheritedCommand:=RegisterIDECommand(CmdCatCodeTools, 'InsertCallInherited',
|
CreateSourceCommand(CmdCatCodeTools,'InsertCallInherited',
|
||||||
crsInsertCallInherited,
|
crsInsertCallInherited,nil,@InsertCallInherited);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@InsertCallInherited);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuSource, 'SrcEditAddCallInherited',
|
|
||||||
crsInsertCallInherited, nil, nil, InsertCallInheritedCommand);
|
|
||||||
RegisterIDEMenuCommand(itmSourceInsertions, 'InsertCallInherited',
|
|
||||||
crsInsertCallInherited, nil, nil, InsertCallInheritedCommand);
|
|
||||||
|
|
||||||
// declare variable
|
|
||||||
DeclareVariableCommand:=RegisterIDECommand(CmdCatCodeTools, 'DeclareVariable',
|
|
||||||
crsDeclareVariable,
|
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@ShowDeclareVariableDialog);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'SrcEditDeclareVariable',
|
|
||||||
crsDeclareVariable2, nil, nil, DeclareVariableCommand);
|
|
||||||
RegisterIDEMenuCommand(itmRefactorCodeTools, 'DeclareVariable',
|
|
||||||
crsDeclareVariable2, nil, nil, DeclareVariableCommand);
|
|
||||||
|
|
||||||
// Show unit / identifier dictionary
|
// Show unit / identifier dictionary
|
||||||
InitUnitDictionary;
|
InitUnitDictionary;
|
||||||
ShowIdentifierDictionaryCommand:=RegisterIDECommand(CmdCatCodeTools, 'ShowUnitDictionary',
|
CreateSourceCommand(CmdCatCodeTools,'ShowUnitDictionary',
|
||||||
crsShowUnitIdentifierDictionary,
|
crsShowUnitIdentifierDictionary,nil,@ShowUnitDictionaryDialog);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@ShowUnitDictionaryDialog);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuSource, 'SrcEditShowIdentifierDictionary',
|
|
||||||
crsShowUnitIdentifierDictionary, nil, nil, ShowIdentifierDictionaryCommand);
|
|
||||||
RegisterIDEMenuCommand(itmSourceInsertions, 'ShowIdentifierDictionary',
|
|
||||||
crsShowUnitIdentifierDictionary, nil, nil, ShowIdentifierDictionaryCommand);
|
|
||||||
|
|
||||||
|
|
||||||
// Refactor menu - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// Refactor menu - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
// declare variable
|
||||||
|
CreateRefactorCommand(CmdCatCodeTools,'DeclareVariable',
|
||||||
|
crsDeclareVariable,nil,@ShowDeclareVariableDialog,crsDeclareVariable2);
|
||||||
|
|
||||||
// add Assign method
|
// add Assign method
|
||||||
AddAssignMethodCommand:=RegisterIDECommand(CmdCatCodeTools, 'AddAssignMethod',
|
CreateRefactorCommand(CmdCatCodeTools,'AddAssignMethod',
|
||||||
crsAddAssignMethod,
|
crsAddAssignMethod,nil,@ShowAddAssignMethodDialog,crsAddAssignMethod2);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@ShowAddAssignMethodDialog);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'SrcEditAddAssignMethod',
|
|
||||||
crsAddAssignMethod2,nil,nil,AddAssignMethodCommand);
|
|
||||||
RegisterIDEMenuCommand(itmRefactorAdvanced, 'AddAssignMethod',
|
|
||||||
crsAddAssignMethod2,nil,nil,AddAssignMethodCommand);
|
|
||||||
|
|
||||||
// Copy declaration to clipboard
|
// Copy declaration to clipboard
|
||||||
{$IFDEF EnableCodyExperiments}
|
{$IFDEF EnableCodyExperiments}
|
||||||
CopyDeclarationToClipboardCommand:=RegisterIDECommand(CmdCatCodeTools,
|
CreateRefactorCommand(CmdCatCodeTools,'CopyDeclarationToClipboard',
|
||||||
'CopyDeclarationToClipboard', crsCopyDeclarationToClipboard,
|
crsCopyDeclarationToClipboard,nil,@CopyDeclarationToClipboard);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@CopyDeclarationToClipboard);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'SrcEditCopyDeclarationToClipboard',
|
|
||||||
crsCopyDeclarationToClipboard,nil,nil,CopyDeclarationToClipboardCommand);
|
|
||||||
RegisterIDEMenuCommand(itmRefactorCodeTools, 'CopyDeclarationToClipboard',
|
|
||||||
crsCopyDeclarationToClipboard,nil,nil,CopyDeclarationToClipboardCommand);
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
// Cut declaration to clipboard
|
// Cut declaration to clipboard
|
||||||
{$IFDEF EnableCodyExperiments}
|
{$IFDEF EnableCodyExperiments}
|
||||||
CutDeclarationToClipboardCommand:=RegisterIDECommand(CmdCatCodeTools,
|
CreateRefactorCommand(CmdCatCodeTools,'CutDeclarationToClipboard',
|
||||||
'CutDeclarationToClipboard', crsCutDeclarationToClipboard,
|
crsCutDeclarationToClipboard,nil,@CutDeclarationToClipboard);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@CutDeclarationToClipboard);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'SrcEditCutDeclarationToClipboard',
|
|
||||||
crsCutDeclarationToClipboard,nil,nil,CutDeclarationToClipboardCommand);
|
|
||||||
RegisterIDEMenuCommand(itmRefactorCodeTools, 'CutDeclarationToClipboard',
|
|
||||||
crsCutDeclarationToClipboard,nil,nil,CutDeclarationToClipboardCommand);
|
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
// explode a With block
|
// explode a With block
|
||||||
ExplodeAWithBlockCommand:=RegisterIDECommand(CmdCatCodeTools, 'ExplodeAWithBlock',
|
CreateRefactorCommand(CmdCatCodeTools,'ExplodeAWithBlock',
|
||||||
crsExplodeAWithBlock,
|
crsExplodeAWithBlock,nil,@ExplodeAWithBlockCmd);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@ExplodeAWithBlockCmd);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'SrcEditExplodeAWithBlock',
|
|
||||||
crsExplodeAWithBlock, nil, nil, ExplodeAWithBlockCommand);
|
|
||||||
RegisterIDEMenuCommand(itmRefactorAdvanced, 'ExplodeAWithBlock',
|
|
||||||
crsExplodeAWithBlock, nil, nil, ExplodeAWithBlockCommand);
|
|
||||||
// add a With block
|
// add a With block
|
||||||
AddAWithBlockCommand:=RegisterIDECommand(CmdCatCodeTools, 'AddAWithBlock',
|
CreateRefactorCommand(CmdCatCodeTools,'AddAWithBlock',
|
||||||
crsAddAWithBlock,
|
crsAddAWithBlock,nil,@ShowAddWithBlockDialog);
|
||||||
CleanIDEShortCut,CleanIDEShortCut,nil,@ShowAddWithBlockDialog);
|
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor, 'SrcEditAddAWithBlock',
|
|
||||||
crsAddAWithBlock, nil, nil, AddAWithBlockCommand);
|
|
||||||
RegisterIDEMenuCommand(itmRefactorAdvanced, 'AddAWithBlock',
|
|
||||||
crsAddAWithBlock, nil, nil, AddAWithBlockCommand);
|
|
||||||
|
|
||||||
// IDE internals menu - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// IDE internals menu - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user