mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 12:39:18 +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;
|
NewCode: TCodeBuffer;
|
||||||
NewX, NewY, NewTopLine: integer;
|
NewX, NewY, NewTopLine: integer;
|
||||||
ErrorMsg: string;
|
ErrorMsg: string;
|
||||||
|
Handled: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:=mrOk;
|
Result:=mrOk;
|
||||||
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
GetCurrentUnit(ActiveSrcEdit,ActiveUnitInfo);
|
||||||
if (ActiveUnitInfo=nil) or (ActiveUnitInfo.Source=nil)
|
if (ActiveUnitInfo=nil) or (ActiveUnitInfo.Source=nil)
|
||||||
or (ActiveSrcEdit=nil) then exit;
|
or (ActiveSrcEdit=nil) then exit;
|
||||||
|
|
||||||
|
Handled:=false;
|
||||||
|
Result:=DoCallModalHandledHandler(lihtQuickSyntaxCheck,Handled);
|
||||||
|
if Handled then exit;
|
||||||
|
|
||||||
SaveSourceEditorChangesToCodeCache(nil);
|
SaveSourceEditorChangesToCodeCache(nil);
|
||||||
CodeToolBoss.VisibleEditorLines:=ActiveSrcEdit.EditorComponent.LinesInWindow;
|
CodeToolBoss.VisibleEditorLines:=ActiveSrcEdit.EditorComponent.LinesInWindow;
|
||||||
if CodeToolBoss.CheckSyntax(ActiveUnitInfo.Source,NewCode,NewX,NewY,
|
if CodeToolBoss.CheckSyntax(ActiveUnitInfo.Source,NewCode,NewX,NewY,
|
||||||
|
@ -125,6 +125,8 @@ type
|
|||||||
TModalResultFunction = function(Sender: TObject): TModalResult of object;
|
TModalResultFunction = function(Sender: TObject): TModalResult of object;
|
||||||
TLazProjectChangedFunction = function(Sender: TObject;
|
TLazProjectChangedFunction = function(Sender: TObject;
|
||||||
AProject: TLazProject): TModalResult of object;
|
AProject: TLazProject): TModalResult of object;
|
||||||
|
TModalHandledFunction = function(Sender: TObject; var Handled: boolean
|
||||||
|
): TModalResult of object;
|
||||||
|
|
||||||
TLazarusIDEHandlerType = (
|
TLazarusIDEHandlerType = (
|
||||||
lihtSavingAll, // called before IDE saves everything
|
lihtSavingAll, // called before IDE saves everything
|
||||||
@ -135,14 +137,14 @@ type
|
|||||||
lihtProjectClose, // called before IDE closes a project
|
lihtProjectClose, // called before IDE closes a project
|
||||||
lihtProjectBuilding, // called before IDE builds the project
|
lihtProjectBuilding, // called before IDE builds the project
|
||||||
lihtProjectDependenciesCompiling, // called before IDE compiles dependencies of 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 }
|
||||||
|
|
||||||
TLazIDEInterface = class(TComponent)
|
TLazIDEInterface = class(TComponent)
|
||||||
private
|
private
|
||||||
FLazarusIDEHandlers: array[TLazarusIDEHandlerType] of TMethodList;
|
|
||||||
FMainBarSubTitle: string;
|
FMainBarSubTitle: string;
|
||||||
FOpenEditorsOnCodeToolChange: boolean;
|
FOpenEditorsOnCodeToolChange: boolean;
|
||||||
FOpenMainSourceOnCodeToolChange: boolean;
|
FOpenMainSourceOnCodeToolChange: boolean;
|
||||||
@ -152,6 +154,7 @@ type
|
|||||||
procedure RemoveHandler(HandlerType: TLazarusIDEHandlerType;
|
procedure RemoveHandler(HandlerType: TLazarusIDEHandlerType;
|
||||||
const AMethod: TMethod);
|
const AMethod: TMethod);
|
||||||
protected
|
protected
|
||||||
|
FLazarusIDEHandlers: array[TLazarusIDEHandlerType] of TMethodList;
|
||||||
fOwningComponent: TComponent;
|
fOwningComponent: TComponent;
|
||||||
|
|
||||||
function GetActiveProject: TLazProject; virtual; abstract;
|
function GetActiveProject: TLazProject; virtual; abstract;
|
||||||
@ -160,6 +163,8 @@ type
|
|||||||
): TModalResult;
|
): TModalResult;
|
||||||
function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
|
function DoCallProjectChangedHandler(HandlerType: TLazarusIDEHandlerType;
|
||||||
AProject: TLazProject): TModalResult;
|
AProject: TLazProject): TModalResult;
|
||||||
|
function DoCallModalHandledHandler(HandlerType: TLazarusIDEHandlerType;
|
||||||
|
var Handled: boolean): TModalResult;
|
||||||
procedure SetMainBarSubTitle(const AValue: string); virtual;
|
procedure SetMainBarSubTitle(const AValue: string); virtual;
|
||||||
public
|
public
|
||||||
constructor Create(TheOwner: TComponent); override;
|
constructor Create(TheOwner: TComponent); override;
|
||||||
@ -318,6 +323,11 @@ type
|
|||||||
AsLast: boolean = false);
|
AsLast: boolean = false);
|
||||||
procedure RemoveHandlerOnProjectDependenciesCompiled(
|
procedure RemoveHandlerOnProjectDependenciesCompiled(
|
||||||
const OnProjDependenciesCompiledEvent: TModalResultFunction);
|
const OnProjDependenciesCompiledEvent: TModalResultFunction);
|
||||||
|
procedure AddHandlerOnQuickSyntaxCheck(
|
||||||
|
const OnQuickSyntaxCheckEvent: TModalHandledFunction;
|
||||||
|
AsLast: boolean = false);
|
||||||
|
procedure RemoveHandlerOnQuickSyntaxCheck(
|
||||||
|
const OnQuickSyntaxCheckEvent: TModalHandledFunction);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -383,6 +393,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
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);
|
constructor TLazIDEInterface.Create(TheOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
LazarusIDE:=Self;
|
LazarusIDE:=Self;
|
||||||
@ -527,6 +552,18 @@ begin
|
|||||||
TMethod(OnProjDependenciesCompiledEvent));
|
TMethod(OnProjDependenciesCompiledEvent));
|
||||||
end;
|
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
|
initialization
|
||||||
RegisterPropertyEditor(TypeInfo(AnsiString),
|
RegisterPropertyEditor(TypeInfo(AnsiString),
|
||||||
THTMLBrowserHelpViewer,'BrowserPath',TFileNamePropertyEditor);
|
THTMLBrowserHelpViewer,'BrowserPath',TFileNamePropertyEditor);
|
||||||
|
Loading…
Reference in New Issue
Block a user