added Execute evnets to IDE command registration

git-svn-id: trunk@8675 -
This commit is contained in:
mattias 2006-01-31 15:50:46 +00:00
parent a558a796c6
commit 1039473e76
4 changed files with 67 additions and 29 deletions

View File

@ -49,28 +49,28 @@ begin
CmdFormatSelection:=RegisterIDECommand(Cat,
SCmdPFSelection,
SDescrPFSelection,
Key);
Key,nil,@PrettyPrintSelection);
Key:=IDEShortCut(VK_P,[SSctrl,ssAlt],VK_UNKNOWN,[]);
CmdFormatFile:=RegisterIDECommand(Cat,
SCmdPFFile,
SDescrPFFile,
Key);
Key,nil,@PrettyPrintFile);
RegisterIDEMenuCommand(SrcEditSubMenuRefactor,
SCmdPFSelection,
SDescrPFSelection,
Nil,@PrettyPrintSelection,CmdFormatSelection);
Nil,nil,CmdFormatSelection);
RegisterIDEMenuCommand(SrcEditSubMenuRefactor,
SCmdPFFile,
SDescrPFFile,
Nil,@PrettyPrintFile,CmdFormatFile);
Nil,nil,CmdFormatFile);
RegisterIDEMenuCommand(itmEditBlockIndentation,
SCmdPFSelection,
SDescrPFSelection,
Nil,@PrettyPrintSelection,CmdFormatSelection);
Nil,nil,CmdFormatSelection);
RegisterIDEMenuCommand(itmEditBlockIndentation,
SCmdPFFile,
SDescrPFFile,
Nil,@PrettyPrintFile,CmdFormatFile);
Nil,nil,CmdFormatFile);
end;
Procedure PrettyPrintStream(SIn,SOut : TStream);

View File

@ -388,7 +388,7 @@ Procedure ClassID(Value: Token;
Functions to create options and set defaults.
---------------------------------------------------------------------}
Procedure CreateOptions (Var Option : OptionTable);
Procedure CreateOptions (Out Option : OptionTable);
Var Sym : KeySymbol;
T : TTokenScope;

View File

@ -86,7 +86,9 @@ type
TheScope: TIDECommandScope): integer;
function Add(Category: TIDECommandCategory; Command: TIDECommand):integer;
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;
Command: word):integer;
procedure SetExtToolCount(NewCount: integer);
@ -121,7 +123,9 @@ type
Scope: TIDECommandScope): TIDECommandCategory; override;
function CreateCommand(Category: TIDECommandCategory;
const AName, Description: string;
const TheShortcutA, TheShortcutB: TIDEShortCut
const TheShortcutA, TheShortcutB: TIDEShortCut;
const OnExecuteMethod: TNotifyEvent = nil;
const OnExecuteProc: TNotifyProcedure = nil
): TIDECommand; override;
public
property ExtToolCount: integer read fExtToolCount write SetExtToolCount;// in menu
@ -2377,10 +2381,12 @@ end;
function TKeyCommandRelationList.Add(Category: TIDECommandCategory;
const Name: string;
Command:word; const TheKeyA, TheKeyB: TIDEShortCut):integer;
Command:word; const TheKeyA, TheKeyB: TIDEShortCut;
const OnExecuteMethod: TNotifyEvent;
const OnExecuteProc: TNotifyProcedure):integer;
begin
Result:=FRelations.Add(TKeyCommandRelation.Create(Category,Name,Command,
TheKeyA,TheKeyB));
TheKeyA,TheKeyB,OnExecuteMethod,OnExecuteProc));
end;
function TKeyCommandRelationList.AddDefault(Category: TIDECommandCategory;
@ -2761,11 +2767,14 @@ end;
function TKeyCommandRelationList.CreateCommand(Category: TIDECommandCategory;
const AName, Description: string; const TheShortcutA,
TheShortcutB: TIDEShortCut): TIDECommand;
TheShortcutB: TIDEShortCut;
const OnExecuteMethod: TNotifyEvent;
const OnExecuteProc: TNotifyProcedure): TIDECommand;
begin
Result:=Relations[Add(Category as TKeyCommandCategory,
CreateUniqueCommandName(AName),
CreateNewCommandID,TheShortcutA,TheShortcutB)];
CreateNewCommandID,TheShortcutA,TheShortcutB,
OnExecuteMethod,OnExecuteProc)];
Result.LocalizedName:=Description;
end;
@ -2791,7 +2800,8 @@ function TKeyCommandRelationList.Add(Category: TIDECommandCategory;
Command: TIDECommand): integer;
begin
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;
//if Command.Command=12000 then
// debugln('TKeyCommandRelationList.Add A ',Command.Name,' ',KeyAndShiftStateToEditorKeyString(Command.ShortcutA),' ',KeyAndShiftStateToEditorKeyString(Relations[Result].ShortcutA),' ',dbgs(Command));

View File

@ -389,7 +389,9 @@ type
public
function AsShortCut: TShortCut; virtual;
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);
destructor Destroy; override;
procedure Assign(ACommand: TIDECommand);
@ -426,7 +428,9 @@ type
Scope: TIDECommandScope = nil): TIDECommandCategory; virtual; abstract;
function CreateCommand(Category: TIDECommandCategory;
const Name, Description: string;
const TheShortcutA, TheShortcutB: TIDEShortCut
const TheShortcutA, TheShortcutB: TIDEShortCut;
const OnExecuteMethod: TNotifyEvent = nil;
const OnExecuteProc: TNotifyProcedure = nil
): TIDECommand; virtual; abstract;
function CategoryCount: integer; virtual; abstract;
public
@ -473,14 +477,22 @@ function RegisterIDECommandCategory(Parent: TIDECommandCategory;
// register a new IDE command (i.e. a shortcut, IDE function)
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;
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;
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;
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)
function RegisterIDECommandScope(const Name: string): TIDECommandScope;
@ -593,31 +605,43 @@ begin
end;
function RegisterIDECommand(Category: TIDECommandCategory;
const Name, Description: string): TIDECommand;
const Name, Description: string;
const OnExecuteMethod: TNotifyEvent = nil;
const OnExecuteProc: TNotifyProcedure = nil): TIDECommand;
begin
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(VK_UNKNOWN,[]));
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(VK_UNKNOWN,[]),
OnExecuteMethod,OnExecuteProc);
end;
function RegisterIDECommand(Category: TIDECommandCategory;
const Name, Description: string;
Key1: word; Shift1: TShiftState): TIDECommand;
Key1: word; Shift1: TShiftState;
const OnExecuteMethod: TNotifyEvent;
const OnExecuteProc: TNotifyProcedure): TIDECommand;
begin
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(Key1,Shift1));
Result:=RegisterIDECommand(Category,Name,Description,IDEShortCut(Key1,Shift1),
OnExecuteMethod,OnExecuteProc);
end;
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
Result:=RegisterIDECommand(Category,Name,Description,
ShortCut1,IDEShortCut(VK_UNKNOWN,[]));
ShortCut1,IDEShortCut(VK_UNKNOWN,[]),
OnExecuteMethod,OnExecuteProc);
end;
function RegisterIDECommand(Category: TIDECommandCategory;
const Name, Description: string;
const ShortCut1, ShortCut2: TIDEShortCut): TIDECommand;
const ShortCut1, ShortCut2: TIDEShortCut;
const OnExecuteMethod: TNotifyEvent;
const OnExecuteProc: TNotifyProcedure): TIDECommand;
begin
Result:=IDECommandList.CreateCommand(Category,Name,Description,
ShortCut1,ShortCut2);
ShortCut1,ShortCut2,OnExecuteMethod,
OnExecuteProc);
end;
function RegisterIDECommandScope(const Name: string): TIDECommandScope;
@ -700,7 +724,9 @@ end;
constructor TIDECommand.Create(TheCategory: TIDECommandCategory;
const TheName: String; TheCommand: word;
const TheShortcutA, TheShortcutB: TIDEShortCut);
const TheShortcutA, TheShortcutB: TIDEShortCut;
const ExecuteMethod: TNotifyEvent;
const ExecuteProc: TNotifyProcedure);
begin
fCommand:=TheCommand;
fName:=TheName;
@ -709,6 +735,8 @@ begin
DefaultShortcutA:=ShortcutA;
DefaultShortcutB:=ShortcutB;
Category:=TheCategory;
FOnExecute:=ExecuteMethod;
FOnExecuteProc:=ExecuteProc;
//DebugLn('TIDECommand.Create Name=',Name,' ',ShortCutToText(AsShortCut),' ',dbgs(Pointer(Self)));
end;