IDEIntf: added handlers: lihtRunDebug, lihtRunWithoutDebugBuilding, lihtRunWithoutDebugInit

git-svn-id: trunk@56793 -
This commit is contained in:
mattias 2017-12-19 14:16:45 +00:00
parent 5e9de6d214
commit f92c4017da
2 changed files with 83 additions and 5 deletions

View File

@ -247,6 +247,9 @@ type
lihtShowDesignerFormOfSource, // called after showing a designer form for code editor (AEditor can be nil!)
lihtShowSourceOfActiveDesignerForm, // called after showing a code of designer form
lihtChangeToolStatus, //called when IDEToolStatus has changed (e.g. itNone->itBuilder etc.)
lihtRunDebug, // called when Run was clicked, after building, before starting the debugger
lihtRunWithoutDebugBuilding, // called when Run a project without debugger was clicked, before building
lihtRunWithoutDebugInit, // called when Run a project without debugger was clicked, after building
lihtRunFinished //called when ran program finishes
);
@ -378,6 +381,9 @@ type
function GetProjectFileForProjectEditor(AEditor: TSourceEditorInterface): TLazProjectFile; virtual; abstract;
function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
AProject: TLazProject): TModalResult;
function DoCallRunDebug(var Handled: boolean): TModalResult;
function DoCallRunWithoutDebugBuilding(var Handled: boolean): TModalResult;
function DoCallRunWithoutDebugInit(var Handled: boolean): TModalResult;
procedure DoCallRunFinishedHandler;
function DoAddUnitToProject(AEditor: TSourceEditorInterface): TModalResult; virtual; abstract;
@ -531,6 +537,15 @@ type
AsLast: boolean = false);
procedure RemoveHandlerOnChangeToolStatus(
const OnChangeToolStatus: TLazToolStatusChangeEvent);
procedure AddHandlerOnRunDebug(const Event: TModalHandledFunction;
AsLast: boolean = false);
procedure RemoveHandlerOnRunDebug(const Event: TModalHandledFunction);
procedure AddHandlerOnRunWithoutDebugBuilding(const Event: TModalHandledFunction;
AsLast: boolean = false);
procedure RemoveHandlerOnRunWithoutDebugBuilding(const Event: TModalHandledFunction);
procedure AddHandlerOnRunWithoutDebugInit(const Event: TModalHandledFunction;
AsLast: boolean = false);
procedure RemoveHandlerOnRunWithoutDebugInit(const Event: TModalHandledFunction);
procedure AddHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent;
AsLast: boolean = false);
procedure RemoveHandlerOnRunFinished(const OnRunFinishedEvent: TNotifyEvent);
@ -769,6 +784,23 @@ begin
end;
end;
function TLazIDEInterface.DoCallRunDebug(var Handled: boolean): TModalResult;
begin
Result:=DoCallModalHandledHandler(lihtRunDebug,Handled);
end;
function TLazIDEInterface.DoCallRunWithoutDebugBuilding(var Handled: boolean
): TModalResult;
begin
Result:=DoCallModalHandledHandler(lihtRunWithoutDebugBuilding,Handled);
end;
function TLazIDEInterface.DoCallRunWithoutDebugInit(var Handled: boolean
): TModalResult;
begin
Result:=DoCallModalHandledHandler(lihtRunWithoutDebugInit,Handled);
end;
procedure TLazIDEInterface.DoCallRunFinishedHandler;
begin
DoCallNotifyHandler(lihtRunFinished);
@ -1004,6 +1036,42 @@ begin
RemoveHandler(lihtChangeToolStatus,TMethod(OnChangeToolStatus));
end;
procedure TLazIDEInterface.AddHandlerOnRunDebug(
const Event: TModalHandledFunction; AsLast: boolean);
begin
AddHandler(lihtRunDebug,TMethod(Event),AsLast);
end;
procedure TLazIDEInterface.RemoveHandlerOnRunDebug(
const Event: TModalHandledFunction);
begin
RemoveHandler(lihtRunDebug,TMethod(Event));
end;
procedure TLazIDEInterface.AddHandlerOnRunWithoutDebugBuilding(
const Event: TModalHandledFunction; AsLast: boolean);
begin
AddHandler(lihtRunWithoutDebugBuilding,TMethod(Event),AsLast);
end;
procedure TLazIDEInterface.RemoveHandlerOnRunWithoutDebugBuilding(
const Event: TModalHandledFunction);
begin
RemoveHandler(lihtRunWithoutDebugBuilding,TMethod(Event));
end;
procedure TLazIDEInterface.AddHandlerOnRunWithoutDebugInit(
const Event: TModalHandledFunction; AsLast: boolean);
begin
AddHandler(lihtRunWithoutDebugInit,TMethod(Event),AsLast);
end;
procedure TLazIDEInterface.RemoveHandlerOnRunWithoutDebugInit(
const Event: TModalHandledFunction);
begin
RemoveHandler(lihtRunWithoutDebugInit,TMethod(Event));
end;
procedure TLazIDEInterface.AddHandlerOnRunFinished(
const OnRunFinishedEvent: TNotifyEvent; AsLast: boolean);
begin

View File

@ -7018,6 +7018,8 @@ begin
end;
function TMainIDE.DoRunProject: TModalResult;
var
Handled: Boolean;
begin
DebugLn('Hint: (lazarus) [TMainIDE.DoRunProject] INIT');
@ -7029,7 +7031,9 @@ begin
end;
debugln('Hint: (lazarus) [TMainIDE.DoRunProject] Debugger=',EnvironmentOptions.DebuggerConfig.DebuggerClass);
Result := mrCancel;
Handled:=false;
Result:=DoCallRunDebug(Handled);
if Handled then exit;
Result := DebugBoss.StartDebugging;
@ -7040,19 +7044,26 @@ function TMainIDE.DoRunProjectWithoutDebug: TModalResult;
var
Process: TProcessUTF8;
ExeCmdLine, ExeWorkingDirectory, ExeFile, Params: string;
RunAppBundle: Boolean;
RunAppBundle, Handled: Boolean;
ARunMode: TRunParamsOptionsMode;
begin
debugln(['TMainIDE.DoRunProjectWithoutDebug START']);
debugln(['Hint: (lazarus) [TMainIDE.DoRunProjectWithoutDebug] START']);
if Project1=nil then
Exit(mrNone);
Handled:=false;
Result:=DoCallRunWithoutDebugBuilding(Handled);
if Handled then exit;
Result := DoBuildProject(crRun,[]);
if Result <> mrOK then
Exit;
Result:=DoCallRunWithoutDebugInit(Handled);
if Handled then exit;
ExeCmdLine := MainBuildBoss.GetRunCommandLine;
debugln(['TMainIDE.DoRunProjectWithoutDebug ExeCmdLine="',ExeCmdLine,'"']);
debugln(['Hint: (lazarus) [TMainIDE.DoRunProjectWithoutDebug] ExeCmdLine="',ExeCmdLine,'"']);
if ExeCmdLine='' then
begin
IDEMessageDialog(lisUnableToRun, lisLaunchingApplicationInvalid,
@ -7066,7 +7077,6 @@ begin
RunAppBundle:=RunAppBundle and Project1.UseAppBundle;
SplitCmdLine(ExeCmdLine,ExeFile,Params);
Process.Executable := ExeFile;
Process.Parameters.Text := Params;
ARunMode := Project1.RunParameterOptions.GetActiveMode;