mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-01 16:12:36 +02:00
IDE: conditionals: show syntax error
git-svn-id: trunk@27460 -
This commit is contained in:
parent
69a72989a9
commit
50a7636bc3
@ -76,9 +76,9 @@
|
||||
- with macros from other packages/projects
|
||||
- show build macros in inherited compiler options
|
||||
- use syntax highlighter settings like the editor previews
|
||||
- show syntax errors of conditionals
|
||||
|
||||
ToDo:
|
||||
- show syntax errors of conditionals
|
||||
- code completion
|
||||
- when package is renamed, rename macros too
|
||||
- move the project target file to compiler options
|
||||
|
@ -1,8 +1,8 @@
|
||||
inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
Height = 430
|
||||
Width = 496
|
||||
ClientHeight = 430
|
||||
ClientWidth = 496
|
||||
Height = 444
|
||||
Width = 514
|
||||
ClientHeight = 444
|
||||
ClientWidth = 514
|
||||
TabOrder = 0
|
||||
Visible = False
|
||||
DesignLeft = 308
|
||||
@ -11,11 +11,11 @@ inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
Left = 0
|
||||
Height = 243
|
||||
Top = 0
|
||||
Width = 496
|
||||
Width = 514
|
||||
Align = alTop
|
||||
Caption = 'MacrosGroupBox'
|
||||
ClientHeight = 222
|
||||
ClientWidth = 488
|
||||
ClientWidth = 506
|
||||
TabOrder = 0
|
||||
object BuildMacrosTreeView: TTreeView
|
||||
Left = 0
|
||||
@ -43,18 +43,18 @@ inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
Left = 244
|
||||
Height = 222
|
||||
Top = 0
|
||||
Width = 244
|
||||
Width = 262
|
||||
Align = alClient
|
||||
BorderSpacing.Left = 6
|
||||
Caption = 'BuildMacroSelectedGroupBox'
|
||||
ClientHeight = 201
|
||||
ClientWidth = 236
|
||||
ClientWidth = 254
|
||||
TabOrder = 2
|
||||
object BuildMacroDefaultLabel: TLabel
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 72
|
||||
Width = 224
|
||||
Width = 242
|
||||
Align = alTop
|
||||
BorderSpacing.Top = 15
|
||||
BorderSpacing.Around = 6
|
||||
@ -65,7 +65,7 @@ inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
Left = 6
|
||||
Height = 18
|
||||
Top = 6
|
||||
Width = 224
|
||||
Width = 242
|
||||
Align = alTop
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Top = 6
|
||||
@ -77,7 +77,7 @@ inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
Left = 6
|
||||
Height = 27
|
||||
Top = 24
|
||||
Width = 224
|
||||
Width = 242
|
||||
Align = alTop
|
||||
BorderSpacing.Left = 6
|
||||
BorderSpacing.Right = 6
|
||||
@ -91,25 +91,25 @@ inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
Left = 0
|
||||
Height = 5
|
||||
Top = 243
|
||||
Width = 496
|
||||
Width = 514
|
||||
Align = alTop
|
||||
ResizeAnchor = akTop
|
||||
end
|
||||
object ConditionalsGroupBox: TGroupBox[2]
|
||||
Left = 0
|
||||
Height = 182
|
||||
Height = 196
|
||||
Top = 248
|
||||
Width = 496
|
||||
Width = 514
|
||||
Align = alClient
|
||||
Caption = 'ConditionalsGroupBox'
|
||||
ClientHeight = 161
|
||||
ClientWidth = 488
|
||||
ClientHeight = 175
|
||||
ClientWidth = 506
|
||||
TabOrder = 2
|
||||
inline CondSynEdit: TSynEdit
|
||||
Left = 0
|
||||
Height = 161
|
||||
Height = 153
|
||||
Top = 0
|
||||
Width = 488
|
||||
Width = 506
|
||||
Align = alClient
|
||||
Font.Height = 9
|
||||
Font.Name = '-misc-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso10646-1'
|
||||
@ -714,6 +714,7 @@ inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
'CondSynEdit'
|
||||
)
|
||||
BracketHighlightStyle = sbhsBoth
|
||||
OnChange = CondSynEditChange
|
||||
inline SynLeftGutterPartList1: TSynGutterPartList
|
||||
object SynGutterMarks1: TSynGutterMarks
|
||||
Width = 24
|
||||
@ -824,6 +825,23 @@ inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
|
||||
inline SynRightGutterPartList1: TSynRightGutterPartList
|
||||
end
|
||||
end
|
||||
object CondStatusbar: TStatusBar
|
||||
Left = 0
|
||||
Height = 22
|
||||
Top = 153
|
||||
Width = 506
|
||||
Panels = <
|
||||
item
|
||||
Width = 50
|
||||
end
|
||||
item
|
||||
Width = 50
|
||||
end
|
||||
item
|
||||
Width = 50
|
||||
end>
|
||||
SimplePanel = False
|
||||
end
|
||||
end
|
||||
object BuildMacrosTVPopupMenu: TPopupMenu[3]
|
||||
OnPopup = BuildMacrosTVPopupMenuPopup
|
||||
|
@ -29,10 +29,11 @@ unit Compiler_BuildMacro_Options;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, StdCtrls, Grids,
|
||||
Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, StdCtrls, Grids, LCLType,
|
||||
Buttons, ExtCtrls, Dialogs, ComCtrls, Menus, AvgLvlTree, IDEImagesIntf,
|
||||
KeywordFuncLists, CodeToolsCfgScript, SynEdit, SynHighlighterPas, ProjectIntf,
|
||||
PackageIntf, CompilerOptions, IDEOptionsIntf, EditorOptions,
|
||||
KeywordFuncLists, CodeToolsCfgScript,
|
||||
SynEdit, SynHighlighterPas, SynEditKeyCmds,
|
||||
ProjectIntf, PackageIntf, CompilerOptions, IDEOptionsIntf, EditorOptions,
|
||||
LazarusIDEStrConsts, CompOptsModes, SourceSynEditor, PackageDefs;
|
||||
|
||||
type
|
||||
@ -57,6 +58,7 @@ type
|
||||
BuildMacroDefaultLabel: TLabel;
|
||||
BuildMacroDescriptionLabel: TLabel;
|
||||
ConditionalsGroupBox: TGroupBox;
|
||||
CondStatusbar: TStatusBar;
|
||||
CondSynEdit: TSynEdit;
|
||||
MacrosGroupBox: TGroupBox;
|
||||
MacrosSplitter: TSplitter;
|
||||
@ -67,19 +69,28 @@ type
|
||||
var AllowEdit: Boolean);
|
||||
procedure BuildMacrosTreeViewSelectionChanged(Sender: TObject);
|
||||
procedure BuildMacrosTVPopupMenuPopup(Sender: TObject);
|
||||
procedure CondSynEditChange(Sender: TObject);
|
||||
procedure CondSynEditStatusChange(Sender: TObject;
|
||||
Changes: TSynStatusChanges);
|
||||
procedure DeleteBuildMacroClick(Sender: TObject);
|
||||
procedure NewBuildMacroClick(Sender: TObject);
|
||||
procedure NewValueClick(Sender: TObject);
|
||||
procedure DeleteValueClick(Sender: TObject);
|
||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||
private
|
||||
FHighlighter: TIDESynFreePasSyn;
|
||||
FBuildMacros: TIDEBuildMacros;
|
||||
FIdleConnected: Boolean;
|
||||
FStatusMessage: string;
|
||||
fVarImgID: LongInt;
|
||||
fValueImgID: LongInt;
|
||||
fDefValueImgID: LongInt;
|
||||
fEngine: TCTConfigScriptEngine;
|
||||
procedure SaveItemProperties;
|
||||
procedure SetBuildMacros(const AValue: TIDEBuildMacros);
|
||||
procedure RebuildTreeView;
|
||||
procedure SetIdleConnected(const AValue: Boolean);
|
||||
procedure SetStatusMessage(const AValue: string);
|
||||
function TreeViewAddBuildMacro(aBuildMacro: TLazBuildMacro): TTreeNode;
|
||||
procedure TreeViewAddValue(ValuesTVNode: TTreeNode; aValue: string);
|
||||
function GetNodeInfo(Node: TTreeNode; out BuildMacro: TLazBuildMacro): TCBMNodeType;
|
||||
@ -88,6 +99,8 @@ type
|
||||
function GetBuildMacroTVNode(aBuildMacro: TLazBuildMacro): TTreeNode;
|
||||
function GetMacroNamePrefix(PrefixType: TCBMPrefixType): string;
|
||||
procedure UpdateItemPropertyControls;
|
||||
procedure UpdateMessages;
|
||||
procedure UpdateStatusBar;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
@ -99,6 +112,8 @@ type
|
||||
property BuildMacros: TIDEBuildMacros read FBuildMacros write SetBuildMacros; // local copy
|
||||
procedure LoadFromOptions(Options: TBaseCompilerOptions);
|
||||
procedure SaveToOptions(Options: TBaseCompilerOptions);
|
||||
property IdleConnected: Boolean read FIdleConnected write SetIdleConnected;
|
||||
property StatusMessage: string read FStatusMessage write SetStatusMessage;
|
||||
end;
|
||||
|
||||
implementation
|
||||
@ -175,6 +190,12 @@ begin
|
||||
BuildMacrosTreeView.EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.OnIdle(Sender: TObject; var Done: Boolean);
|
||||
begin
|
||||
IdleConnected:=false;
|
||||
UpdateMessages;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.DeleteBuildMacroClick(Sender: TObject);
|
||||
var
|
||||
aBuildMacro: TIDEBuildMacro;
|
||||
@ -231,6 +252,18 @@ begin
|
||||
Add('Delete build macro ...',@DeleteBuildMacroClick);
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.CondSynEditChange(Sender: TObject);
|
||||
begin
|
||||
UpdateStatusBar;
|
||||
IdleConnected:=true;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.CondSynEditStatusChange(Sender: TObject;
|
||||
Changes: TSynStatusChanges);
|
||||
begin
|
||||
UpdateStatusBar;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.BuildMacrosTreeViewEditing(Sender: TObject;
|
||||
Node: TTreeNode; var AllowEdit: Boolean);
|
||||
var
|
||||
@ -361,6 +394,7 @@ begin
|
||||
BuildMacros.Assign(AValue);
|
||||
RebuildTreeView;
|
||||
UpdateItemPropertyControls;
|
||||
IdleConnected:=true;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.RebuildTreeView;
|
||||
@ -377,6 +411,23 @@ begin
|
||||
BuildMacrosTreeView.EndUpdate;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.SetIdleConnected(const AValue: Boolean);
|
||||
begin
|
||||
if FIdleConnected=AValue then exit;
|
||||
FIdleConnected:=AValue;
|
||||
if FIdleConnected then
|
||||
Application.AddOnIdleHandler(@OnIdle)
|
||||
else
|
||||
Application.RemoveOnIdleHandler(@OnIdle);
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.SetStatusMessage(const AValue: string);
|
||||
begin
|
||||
if FStatusMessage=AValue then exit;
|
||||
FStatusMessage:=AValue;
|
||||
CondStatusbar.Panels[2].Text := FStatusMessage;
|
||||
end;
|
||||
|
||||
function TCompOptBuildMacrosFrame.TreeViewAddBuildMacro(
|
||||
aBuildMacro: TLazBuildMacro): TTreeNode;
|
||||
var
|
||||
@ -487,6 +538,31 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.UpdateMessages;
|
||||
begin
|
||||
fEngine.Execute(CondSynEdit.Lines.Text,1);
|
||||
if fEngine.ErrorCount>0 then begin
|
||||
StatusMessage:=fEngine.GetErrorStr(0);
|
||||
end else begin
|
||||
StatusMessage:='No errors';
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.UpdateStatusBar;
|
||||
var
|
||||
PanelCharMode: String;
|
||||
PanelXY: String;
|
||||
begin
|
||||
PanelXY := Format(' %6d:%4d',[CondSynEdit.CaretY,CondSynEdit.CaretX]);
|
||||
if CondSynEdit.InsertMode then
|
||||
PanelCharMode := uepIns
|
||||
else
|
||||
PanelCharMode := uepOvr;
|
||||
|
||||
CondStatusbar.Panels[0].Text := PanelXY;
|
||||
CondStatusbar.Panels[1].Text := PanelCharMode;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.SaveItemProperties;
|
||||
var
|
||||
BuildMacro: TLazBuildMacro;
|
||||
@ -502,6 +578,7 @@ begin
|
||||
inherited Create(TheOwner);
|
||||
|
||||
FBuildMacros:=TIDEBuildMacros.Create(nil);
|
||||
fEngine:=TCTConfigScriptEngine.Create;
|
||||
|
||||
MacrosGroupBox.Caption:='Build macros:';
|
||||
BuildMacrosTreeView.Images := IDEImages.Images_24;
|
||||
@ -513,10 +590,13 @@ begin
|
||||
BuildMacroDescriptionLabel.Caption:='Description:';
|
||||
|
||||
ConditionalsGroupBox.Caption:='Conditionals:';
|
||||
|
||||
CondSynEdit.OnStatusChange:=@CondSynEditStatusChange;
|
||||
end;
|
||||
|
||||
destructor TCompOptBuildMacrosFrame.Destroy;
|
||||
begin
|
||||
FreeAndNil(fEngine);
|
||||
FreeAndNil(FBuildMacros);
|
||||
inherited Destroy;
|
||||
end;
|
||||
@ -563,6 +643,7 @@ begin
|
||||
CondSynEdit.Highlighter:=FHighlighter;
|
||||
end;
|
||||
EditorOpts.ReadHighlighterSettings(FHighlighter, '');
|
||||
UpdateStatusBar;
|
||||
end;
|
||||
|
||||
procedure TCompOptBuildMacrosFrame.SaveToOptions(Options: TBaseCompilerOptions
|
||||
|
Loading…
Reference in New Issue
Block a user