mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 20:00:27 +02:00
IDEIntf: added event for quick syntax check
git-svn-id: trunk@26682 -
This commit is contained in:
parent
1b0b91f3d3
commit
224f77db3c
@ -11806,11 +11806,17 @@ var
|
||||
NewCode: TCodeBuffer;
|
||||
NewX, NewY, NewTopLine: integer;
|
||||
ErrorMsg: string;
|
||||
Handled: Boolean;
|
||||
begin
|
||||
Result:=mrOk;
|
||||
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
||||
if (ActiveUnitInfo=nil) or (ActiveUnitInfo.Source=nil)
|
||||
or (ActiveSrcEdit=nil) then exit;
|
||||
|
||||
Handled:=false;
|
||||
Result:=DoCallModalHandledHandler(lihtQuickSyntaxCheck,Handled);
|
||||
if Handled then exit;
|
||||
|
||||
SaveSourceEditorChangesToCodeCache(nil);
|
||||
CodeToolBoss.VisibleEditorLines:=ActiveSrcEdit.EditorComponent.LinesInWindow;
|
||||
if CodeToolBoss.CheckSyntax(ActiveUnitInfo.Source,NewCode,NewX,NewY,
|
||||
|
@ -125,6 +125,8 @@ type
|
||||
TModalResultFunction = function(Sender: TObject): TModalResult of object;
|
||||
TLazProjectChangedFunction = function(Sender: TObject;
|
||||
AProject: TLazProject): TModalResult of object;
|
||||
TModalHandledFunction = function(Sender: TObject; var Handled: boolean
|
||||
): TModalResult of object;
|
||||
|
||||
TLazarusIDEHandlerType = (
|
||||
lihtSavingAll, // called before IDE saves everything
|
||||
@ -135,14 +137,14 @@ type
|
||||
lihtProjectClose, // called before IDE closes a project
|
||||
lihtProjectBuilding, // called before IDE builds the project
|
||||
lihtProjectDependenciesCompiling, // called before IDE compiles dependencies of project
|
||||
lihtProjectDependenciesCompiled // called after IDE compiled dependencies of project
|
||||
lihtProjectDependenciesCompiled, // called after IDE compiled dependencies of project
|
||||
lihtQuickSyntaxCheck // called when quick syntax check is clicked (menu item or shortcut)
|
||||
);
|
||||
|
||||
{ TLazIDEInterface }
|
||||
|
||||
TLazIDEInterface = class(TComponent)
|
||||
private
|
||||
FLazarusIDEHandlers: array[TLazarusIDEHandlerType] of TMethodList;
|
||||
FMainBarSubTitle: string;
|
||||
FOpenEditorsOnCodeToolChange: boolean;
|
||||
FOpenMainSourceOnCodeToolChange: boolean;
|
||||
@ -152,6 +154,7 @@ type
|
||||
procedure RemoveHandler(HandlerType: TLazarusIDEHandlerType;
|
||||
const AMethod: TMethod);
|
||||
protected
|
||||
FLazarusIDEHandlers: array[TLazarusIDEHandlerType] of TMethodList;
|
||||
fOwningComponent: TComponent;
|
||||
|
||||
function GetActiveProject: TLazProject; virtual; abstract;
|
||||
@ -160,6 +163,8 @@ type
|
||||
): TModalResult;
|
||||
function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
|
||||
AProject: TLazProject): TModalResult;
|
||||
function DoCallModalHandledHandler(HandlerType: TLazarusIDEHandlerType;
|
||||
var Handled: boolean): TModalResult;
|
||||
procedure SetMainBarSubTitle(const AValue: string); virtual;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
@ -318,6 +323,11 @@ type
|
||||
AsLast: boolean = false);
|
||||
procedure RemoveHandlerOnProjectDependenciesCompiled(
|
||||
const OnProjDependenciesCompiledEvent: TModalResultFunction);
|
||||
procedure AddHandlerOnQuickSyntaxCheck(
|
||||
const OnQuickSyntaxCheckEvent: TModalHandledFunction;
|
||||
AsLast: boolean = false);
|
||||
procedure RemoveHandlerOnQuickSyntaxCheck(
|
||||
const OnQuickSyntaxCheckEvent: TModalHandledFunction);
|
||||
end;
|
||||
|
||||
var
|
||||
@ -383,6 +393,21 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TLazIDEInterface.DoCallModalHandledHandler(
|
||||
HandlerType: TLazarusIDEHandlerType; var Handled: boolean): TModalResult;
|
||||
var
|
||||
i: longint;
|
||||
begin
|
||||
i:=FLazarusIDEHandlers[HandlerType].Count;
|
||||
while FLazarusIDEHandlers[HandlerType].NextDownIndex(i) do
|
||||
begin
|
||||
Handled:=false;
|
||||
Result:=TModalHandledFunction(FLazarusIDEHandlers[HandlerType][i])(Self,Handled);
|
||||
if Handled then exit;
|
||||
end;
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
constructor TLazIDEInterface.Create(TheOwner: TComponent);
|
||||
begin
|
||||
LazarusIDE:=Self;
|
||||
@ -527,6 +552,18 @@ begin
|
||||
TMethod(OnProjDependenciesCompiledEvent));
|
||||
end;
|
||||
|
||||
procedure TLazIDEInterface.AddHandlerOnQuickSyntaxCheck(
|
||||
const OnQuickSyntaxCheckEvent: TModalHandledFunction; AsLast: boolean);
|
||||
begin
|
||||
AddHandler(lihtQuickSyntaxCheck,TMethod(OnQuickSyntaxCheckEvent),AsLast);
|
||||
end;
|
||||
|
||||
procedure TLazIDEInterface.RemoveHandlerOnQuickSyntaxCheck(
|
||||
const OnQuickSyntaxCheckEvent: TModalHandledFunction);
|
||||
begin
|
||||
RemoveHandler(lihtQuickSyntaxCheck,TMethod(OnQuickSyntaxCheckEvent));
|
||||
end;
|
||||
|
||||
initialization
|
||||
RegisterPropertyEditor(TypeInfo(AnsiString),
|
||||
THTMLBrowserHelpViewer,'BrowserPath',TFileNamePropertyEditor);
|
||||
|
Loading…
Reference in New Issue
Block a user