mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 04:29:28 +02:00
added Execute evnets to IDE command registration
git-svn-id: trunk@8675 -
This commit is contained in:
parent
a558a796c6
commit
1039473e76
@ -49,28 +49,28 @@ begin
|
|||||||
CmdFormatSelection:=RegisterIDECommand(Cat,
|
CmdFormatSelection:=RegisterIDECommand(Cat,
|
||||||
SCmdPFSelection,
|
SCmdPFSelection,
|
||||||
SDescrPFSelection,
|
SDescrPFSelection,
|
||||||
Key);
|
Key,nil,@PrettyPrintSelection);
|
||||||
Key:=IDEShortCut(VK_P,[SSctrl,ssAlt],VK_UNKNOWN,[]);
|
Key:=IDEShortCut(VK_P,[SSctrl,ssAlt],VK_UNKNOWN,[]);
|
||||||
CmdFormatFile:=RegisterIDECommand(Cat,
|
CmdFormatFile:=RegisterIDECommand(Cat,
|
||||||
SCmdPFFile,
|
SCmdPFFile,
|
||||||
SDescrPFFile,
|
SDescrPFFile,
|
||||||
Key);
|
Key,nil,@PrettyPrintFile);
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor,
|
RegisterIDEMenuCommand(SrcEditSubMenuRefactor,
|
||||||
SCmdPFSelection,
|
SCmdPFSelection,
|
||||||
SDescrPFSelection,
|
SDescrPFSelection,
|
||||||
Nil,@PrettyPrintSelection,CmdFormatSelection);
|
Nil,nil,CmdFormatSelection);
|
||||||
RegisterIDEMenuCommand(SrcEditSubMenuRefactor,
|
RegisterIDEMenuCommand(SrcEditSubMenuRefactor,
|
||||||
SCmdPFFile,
|
SCmdPFFile,
|
||||||
SDescrPFFile,
|
SDescrPFFile,
|
||||||
Nil,@PrettyPrintFile,CmdFormatFile);
|
Nil,nil,CmdFormatFile);
|
||||||
RegisterIDEMenuCommand(itmEditBlockIndentation,
|
RegisterIDEMenuCommand(itmEditBlockIndentation,
|
||||||
SCmdPFSelection,
|
SCmdPFSelection,
|
||||||
SDescrPFSelection,
|
SDescrPFSelection,
|
||||||
Nil,@PrettyPrintSelection,CmdFormatSelection);
|
Nil,nil,CmdFormatSelection);
|
||||||
RegisterIDEMenuCommand(itmEditBlockIndentation,
|
RegisterIDEMenuCommand(itmEditBlockIndentation,
|
||||||
SCmdPFFile,
|
SCmdPFFile,
|
||||||
SDescrPFFile,
|
SDescrPFFile,
|
||||||
Nil,@PrettyPrintFile,CmdFormatFile);
|
Nil,nil,CmdFormatFile);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure PrettyPrintStream(SIn,SOut : TStream);
|
Procedure PrettyPrintStream(SIn,SOut : TStream);
|
||||||
|
@ -388,7 +388,7 @@ Procedure ClassID(Value: Token;
|
|||||||
Functions to create options and set defaults.
|
Functions to create options and set defaults.
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
Procedure CreateOptions (Var Option : OptionTable);
|
Procedure CreateOptions (Out Option : OptionTable);
|
||||||
|
|
||||||
Var Sym : KeySymbol;
|
Var Sym : KeySymbol;
|
||||||
T : TTokenScope;
|
T : TTokenScope;
|
||||||
|
@ -86,7 +86,9 @@ type
|
|||||||
TheScope: TIDECommandScope): integer;
|
TheScope: TIDECommandScope): integer;
|
||||||
function Add(Category: TIDECommandCategory; Command: TIDECommand):integer;
|
function Add(Category: TIDECommandCategory; Command: TIDECommand):integer;
|
||||||
function Add(Category: TIDECommandCategory; const Name: string;
|
function Add(Category: TIDECommandCategory; const Name: string;
|
||||||
Command: word; const TheKeyA, TheKeyB: TIDEShortCut):integer;
|
Command: word; const TheKeyA, TheKeyB: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil):integer;
|
||||||
function AddDefault(Category: TIDECommandCategory; const Name: string;
|
function AddDefault(Category: TIDECommandCategory; const Name: string;
|
||||||
Command: word):integer;
|
Command: word):integer;
|
||||||
procedure SetExtToolCount(NewCount: integer);
|
procedure SetExtToolCount(NewCount: integer);
|
||||||
@ -121,7 +123,9 @@ type
|
|||||||
Scope: TIDECommandScope): TIDECommandCategory; override;
|
Scope: TIDECommandScope): TIDECommandCategory; override;
|
||||||
function CreateCommand(Category: TIDECommandCategory;
|
function CreateCommand(Category: TIDECommandCategory;
|
||||||
const AName, Description: string;
|
const AName, Description: string;
|
||||||
const TheShortcutA, TheShortcutB: TIDEShortCut
|
const TheShortcutA, TheShortcutB: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil
|
||||||
): TIDECommand; override;
|
): TIDECommand; override;
|
||||||
public
|
public
|
||||||
property ExtToolCount: integer read fExtToolCount write SetExtToolCount;// in menu
|
property ExtToolCount: integer read fExtToolCount write SetExtToolCount;// in menu
|
||||||
@ -2377,10 +2381,12 @@ end;
|
|||||||
|
|
||||||
function TKeyCommandRelationList.Add(Category: TIDECommandCategory;
|
function TKeyCommandRelationList.Add(Category: TIDECommandCategory;
|
||||||
const Name: string;
|
const Name: string;
|
||||||
Command:word; const TheKeyA, TheKeyB: TIDEShortCut):integer;
|
Command:word; const TheKeyA, TheKeyB: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent;
|
||||||
|
const OnExecuteProc: TNotifyProcedure):integer;
|
||||||
begin
|
begin
|
||||||
Result:=FRelations.Add(TKeyCommandRelation.Create(Category,Name,Command,
|
Result:=FRelations.Add(TKeyCommandRelation.Create(Category,Name,Command,
|
||||||
TheKeyA,TheKeyB));
|
TheKeyA,TheKeyB,OnExecuteMethod,OnExecuteProc));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TKeyCommandRelationList.AddDefault(Category: TIDECommandCategory;
|
function TKeyCommandRelationList.AddDefault(Category: TIDECommandCategory;
|
||||||
@ -2761,11 +2767,14 @@ end;
|
|||||||
|
|
||||||
function TKeyCommandRelationList.CreateCommand(Category: TIDECommandCategory;
|
function TKeyCommandRelationList.CreateCommand(Category: TIDECommandCategory;
|
||||||
const AName, Description: string; const TheShortcutA,
|
const AName, Description: string; const TheShortcutA,
|
||||||
TheShortcutB: TIDEShortCut): TIDECommand;
|
TheShortcutB: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent;
|
||||||
|
const OnExecuteProc: TNotifyProcedure): TIDECommand;
|
||||||
begin
|
begin
|
||||||
Result:=Relations[Add(Category as TKeyCommandCategory,
|
Result:=Relations[Add(Category as TKeyCommandCategory,
|
||||||
CreateUniqueCommandName(AName),
|
CreateUniqueCommandName(AName),
|
||||||
CreateNewCommandID,TheShortcutA,TheShortcutB)];
|
CreateNewCommandID,TheShortcutA,TheShortcutB,
|
||||||
|
OnExecuteMethod,OnExecuteProc)];
|
||||||
Result.LocalizedName:=Description;
|
Result.LocalizedName:=Description;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2791,7 +2800,8 @@ function TKeyCommandRelationList.Add(Category: TIDECommandCategory;
|
|||||||
Command: TIDECommand): integer;
|
Command: TIDECommand): integer;
|
||||||
begin
|
begin
|
||||||
Result:=FRelations.Add(TKeyCommandRelation.Create(Category,Command.Name,
|
Result:=FRelations.Add(TKeyCommandRelation.Create(Category,Command.Name,
|
||||||
Command.Command,Command.ShortcutA,Command.ShortcutB));
|
Command.Command,Command.ShortcutA,Command.ShortcutB,
|
||||||
|
Command.OnExecute,Command.OnExecuteProc));
|
||||||
Relations[Result].LocalizedName:=Command.LocalizedName;
|
Relations[Result].LocalizedName:=Command.LocalizedName;
|
||||||
//if Command.Command=12000 then
|
//if Command.Command=12000 then
|
||||||
// debugln('TKeyCommandRelationList.Add A ',Command.Name,' ',KeyAndShiftStateToEditorKeyString(Command.ShortcutA),' ',KeyAndShiftStateToEditorKeyString(Relations[Result].ShortcutA),' ',dbgs(Command));
|
// debugln('TKeyCommandRelationList.Add A ',Command.Name,' ',KeyAndShiftStateToEditorKeyString(Command.ShortcutA),' ',KeyAndShiftStateToEditorKeyString(Relations[Result].ShortcutA),' ',dbgs(Command));
|
||||||
|
@ -389,7 +389,9 @@ type
|
|||||||
public
|
public
|
||||||
function AsShortCut: TShortCut; virtual;
|
function AsShortCut: TShortCut; virtual;
|
||||||
constructor Create(TheCategory: TIDECommandCategory; const TheName: String;
|
constructor Create(TheCategory: TIDECommandCategory; const TheName: String;
|
||||||
TheCommand: word; const TheShortcutA, TheShortcutB: TIDEShortCut);
|
TheCommand: word; const TheShortcutA, TheShortcutB: TIDEShortCut;
|
||||||
|
const ExecuteMethod: TNotifyEvent;
|
||||||
|
const ExecuteProc: TNotifyProcedure);
|
||||||
constructor Create(ACommand: TIDECommand; ACategory: TIDECommandCategory);
|
constructor Create(ACommand: TIDECommand; ACategory: TIDECommandCategory);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure Assign(ACommand: TIDECommand);
|
procedure Assign(ACommand: TIDECommand);
|
||||||
@ -426,7 +428,9 @@ type
|
|||||||
Scope: TIDECommandScope = nil): TIDECommandCategory; virtual; abstract;
|
Scope: TIDECommandScope = nil): TIDECommandCategory; virtual; abstract;
|
||||||
function CreateCommand(Category: TIDECommandCategory;
|
function CreateCommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string;
|
const Name, Description: string;
|
||||||
const TheShortcutA, TheShortcutB: TIDEShortCut
|
const TheShortcutA, TheShortcutB: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil
|
||||||
): TIDECommand; virtual; abstract;
|
): TIDECommand; virtual; abstract;
|
||||||
function CategoryCount: integer; virtual; abstract;
|
function CategoryCount: integer; virtual; abstract;
|
||||||
public
|
public
|
||||||
@ -473,14 +477,22 @@ function RegisterIDECommandCategory(Parent: TIDECommandCategory;
|
|||||||
|
|
||||||
// register a new IDE command (i.e. a shortcut, IDE function)
|
// register a new IDE command (i.e. a shortcut, IDE function)
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string): TIDECommand;
|
const Name, Description: string;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string; Key1: word; Shift1: TShiftState): TIDECommand;
|
const Name, Description: string; Key1: word; Shift1: TShiftState;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string; const ShortCut1: TIDEShortCut): TIDECommand;
|
const Name, Description: string; const ShortCut1: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string;
|
const Name, Description: string;
|
||||||
const ShortCut1, ShortCut2: TIDEShortCut): TIDECommand;
|
const ShortCut1, ShortCut2: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
|
||||||
|
|
||||||
// register a new IDE command scope (i.e. a set of windows)
|
// register a new IDE command scope (i.e. a set of windows)
|
||||||
function RegisterIDECommandScope(const Name: string): TIDECommandScope;
|
function RegisterIDECommandScope(const Name: string): TIDECommandScope;
|
||||||
@ -593,31 +605,43 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string): TIDECommand;
|
const Name, Description: string;
|
||||||
|
const OnExecuteMethod: TNotifyEvent = nil;
|
||||||
|
const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
|
||||||
begin
|
begin
|
||||||
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(VK_UNKNOWN,[]));
|
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(VK_UNKNOWN,[]),
|
||||||
|
OnExecuteMethod,OnExecuteProc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string;
|
const Name, Description: string;
|
||||||
Key1: word; Shift1: TShiftState): TIDECommand;
|
Key1: word; Shift1: TShiftState;
|
||||||
|
const OnExecuteMethod: TNotifyEvent;
|
||||||
|
const OnExecuteProc: TNotifyProcedure): TIDECommand;
|
||||||
begin
|
begin
|
||||||
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(Key1,Shift1));
|
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(Key1,Shift1),
|
||||||
|
OnExecuteMethod,OnExecuteProc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string; const ShortCut1: TIDEShortCut): TIDECommand;
|
const Name, Description: string; const ShortCut1: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent;
|
||||||
|
const OnExecuteProc: TNotifyProcedure): TIDECommand;
|
||||||
begin
|
begin
|
||||||
Result:=RegisterIDECommand(Category,Name,Description,
|
Result:=RegisterIDECommand(Category,Name,Description,
|
||||||
ShortCut1,IDEShortCut(VK_UNKNOWN,[]));
|
ShortCut1,IDEShortCut(VK_UNKNOWN,[]),
|
||||||
|
OnExecuteMethod,OnExecuteProc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function RegisterIDECommand(Category: TIDECommandCategory;
|
function RegisterIDECommand(Category: TIDECommandCategory;
|
||||||
const Name, Description: string;
|
const Name, Description: string;
|
||||||
const ShortCut1, ShortCut2: TIDEShortCut): TIDECommand;
|
const ShortCut1, ShortCut2: TIDEShortCut;
|
||||||
|
const OnExecuteMethod: TNotifyEvent;
|
||||||
|
const OnExecuteProc: TNotifyProcedure): TIDECommand;
|
||||||
begin
|
begin
|
||||||
Result:=IDECommandList.CreateCommand(Category,Name,Description,
|
Result:=IDECommandList.CreateCommand(Category,Name,Description,
|
||||||
ShortCut1,ShortCut2);
|
ShortCut1,ShortCut2,OnExecuteMethod,
|
||||||
|
OnExecuteProc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function RegisterIDECommandScope(const Name: string): TIDECommandScope;
|
function RegisterIDECommandScope(const Name: string): TIDECommandScope;
|
||||||
@ -700,7 +724,9 @@ end;
|
|||||||
|
|
||||||
constructor TIDECommand.Create(TheCategory: TIDECommandCategory;
|
constructor TIDECommand.Create(TheCategory: TIDECommandCategory;
|
||||||
const TheName: String; TheCommand: word;
|
const TheName: String; TheCommand: word;
|
||||||
const TheShortcutA, TheShortcutB: TIDEShortCut);
|
const TheShortcutA, TheShortcutB: TIDEShortCut;
|
||||||
|
const ExecuteMethod: TNotifyEvent;
|
||||||
|
const ExecuteProc: TNotifyProcedure);
|
||||||
begin
|
begin
|
||||||
fCommand:=TheCommand;
|
fCommand:=TheCommand;
|
||||||
fName:=TheName;
|
fName:=TheName;
|
||||||
@ -709,6 +735,8 @@ begin
|
|||||||
DefaultShortcutA:=ShortcutA;
|
DefaultShortcutA:=ShortcutA;
|
||||||
DefaultShortcutB:=ShortcutB;
|
DefaultShortcutB:=ShortcutB;
|
||||||
Category:=TheCategory;
|
Category:=TheCategory;
|
||||||
|
FOnExecute:=ExecuteMethod;
|
||||||
|
FOnExecuteProc:=ExecuteProc;
|
||||||
//DebugLn('TIDECommand.Create Name=',Name,' ',ShortCutToText(AsShortCut),' ',dbgs(Pointer(Self)));
|
//DebugLn('TIDECommand.Create Name=',Name,' ',ShortCutToText(AsShortCut),' ',dbgs(Pointer(Self)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user