IDE: use preview syntax highlighter for conditionals

git-svn-id: trunk@27459 -
This commit is contained in:
mattias 2010-09-25 22:39:12 +00:00
parent 200f270cbb
commit 69a72989a9
3 changed files with 35 additions and 37 deletions

View File

@ -75,9 +75,9 @@
- prefix with package name - prefix with package name
- with macros from other packages/projects - with macros from other packages/projects
- show build macros in inherited compiler options - show build macros in inherited compiler options
- use syntax highlighter settings like the editor previews
ToDo: ToDo:
- use syntax highlighter settings like the editor previews
- show syntax errors of conditionals - show syntax errors of conditionals
- code completion - code completion
- when package is renamed, rename macros too - when package is renamed, rename macros too

View File

@ -1,7 +1,5 @@
object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame inherited CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Left = 0
Height = 430 Height = 430
Top = 0
Width = 496 Width = 496
ClientHeight = 430 ClientHeight = 430
ClientWidth = 496 ClientWidth = 496
@ -9,19 +7,19 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Visible = False Visible = False
DesignLeft = 308 DesignLeft = 308
DesignTop = 268 DesignTop = 268
object MacrosGroupBox: TGroupBox object MacrosGroupBox: TGroupBox[0]
Left = 0 Left = 0
Height = 243 Height = 243
Top = 0 Top = 0
Width = 496 Width = 496
Align = alTop Align = alTop
Caption = 'MacrosGroupBox' Caption = 'MacrosGroupBox'
ClientHeight = 224 ClientHeight = 222
ClientWidth = 492 ClientWidth = 488
TabOrder = 0 TabOrder = 0
object BuildMacrosTreeView: TTreeView object BuildMacrosTreeView: TTreeView
Left = 0 Left = 0
Height = 224 Height = 222
Top = 0 Top = 0
Width = 227 Width = 227
Align = alLeft Align = alLeft
@ -37,26 +35,26 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
end end
object Splitter1: TSplitter object Splitter1: TSplitter
Left = 233 Left = 233
Height = 224 Height = 222
Top = 0 Top = 0
Width = 5 Width = 5
end end
object BuildMacroSelectedGroupBox: TGroupBox object BuildMacroSelectedGroupBox: TGroupBox
Left = 244 Left = 244
Height = 224 Height = 222
Top = 0 Top = 0
Width = 248 Width = 244
Align = alClient Align = alClient
BorderSpacing.Left = 6 BorderSpacing.Left = 6
Caption = 'BuildMacroSelectedGroupBox' Caption = 'BuildMacroSelectedGroupBox'
ClientHeight = 205 ClientHeight = 201
ClientWidth = 244 ClientWidth = 236
TabOrder = 2 TabOrder = 2
object BuildMacroDefaultLabel: TLabel object BuildMacroDefaultLabel: TLabel
Left = 6 Left = 6
Height = 18 Height = 18
Top = 72 Top = 72
Width = 232 Width = 224
Align = alTop Align = alTop
BorderSpacing.Top = 15 BorderSpacing.Top = 15
BorderSpacing.Around = 6 BorderSpacing.Around = 6
@ -67,7 +65,7 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Left = 6 Left = 6
Height = 18 Height = 18
Top = 6 Top = 6
Width = 232 Width = 224
Align = alTop Align = alTop
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 6 BorderSpacing.Top = 6
@ -79,7 +77,7 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Left = 6 Left = 6
Height = 27 Height = 27
Top = 24 Top = 24
Width = 232 Width = 224
Align = alTop Align = alTop
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Right = 6 BorderSpacing.Right = 6
@ -88,7 +86,7 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
end end
end end
end end
object MacrosSplitter: TSplitter object MacrosSplitter: TSplitter[1]
Cursor = crVSplit Cursor = crVSplit
Left = 0 Left = 0
Height = 5 Height = 5
@ -97,21 +95,21 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Align = alTop Align = alTop
ResizeAnchor = akTop ResizeAnchor = akTop
end end
object ConditionalsGroupBox: TGroupBox object ConditionalsGroupBox: TGroupBox[2]
Left = 0 Left = 0
Height = 182 Height = 182
Top = 248 Top = 248
Width = 496 Width = 496
Align = alClient Align = alClient
Caption = 'ConditionalsGroupBox' Caption = 'ConditionalsGroupBox'
ClientHeight = 163 ClientHeight = 161
ClientWidth = 492 ClientWidth = 488
TabOrder = 2 TabOrder = 2
inline CondSynEdit: TSynEdit inline CondSynEdit: TSynEdit
Left = 0 Left = 0
Height = 163 Height = 161
Top = 0 Top = 0
Width = 492 Width = 488
Align = alClient Align = alClient
Font.Height = 9 Font.Height = 9
Font.Name = '-misc-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso10646-1' Font.Name = '-misc-dejavu sans mono-*-*-*-*-*-*-*-*-*-*-iso10646-1'
@ -120,7 +118,7 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
TabOrder = 0 TabOrder = 0
Gutter.Width = 55 Gutter.Width = 51
Gutter.MouseActions = < Gutter.MouseActions = <
item item
Shift = [] Shift = []
@ -168,7 +166,6 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Option = 0 Option = 0
Priority = 0 Priority = 0
end> end>
Highlighter = ConditionalsSynPasSyn
Keystrokes = < Keystrokes = <
item item
Command = ecUp Command = ecUp
@ -722,7 +719,7 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
Width = 24 Width = 24
end end
object SynGutterLineNumber1: TSynGutterLineNumber object SynGutterLineNumber1: TSynGutterLineNumber
Width = 15 Width = 11
MouseActions = <> MouseActions = <>
MarkupInfo.Background = clBtnFace MarkupInfo.Background = clBtnFace
MarkupInfo.Foreground = clNone MarkupInfo.Foreground = clNone
@ -828,16 +825,9 @@ object CompOptBuildMacrosFrame: TCompOptBuildMacrosFrame
end end
end end
end end
object BuildMacrosTVPopupMenu: TPopupMenu object BuildMacrosTVPopupMenu: TPopupMenu[3]
OnPopup = BuildMacrosTVPopupMenuPopup OnPopup = BuildMacrosTVPopupMenuPopup
left = 99 left = 99
top = 77 top = 77
end end
object ConditionalsSynPasSyn: TSynPasSyn
Enabled = False
CompilerMode = pcmDelphi
NestedComments = False
left = 182
top = 313
end
end end

View File

@ -31,9 +31,9 @@ interface
uses uses
Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, StdCtrls, Grids, Classes, SysUtils, LCLProc, FileUtil, Controls, Forms, StdCtrls, Grids,
Buttons, ExtCtrls, Dialogs, ComCtrls, Menus, AvgLvlTree, IDEImagesIntf, Buttons, ExtCtrls, Dialogs, ComCtrls, Menus, AvgLvlTree, IDEImagesIntf,
KeywordFuncLists, CodeToolsCfgScript, KeywordFuncLists, CodeToolsCfgScript, SynEdit, SynHighlighterPas, ProjectIntf,
ProjectIntf, PackageIntf, CompilerOptions, IDEOptionsIntf, PackageIntf, CompilerOptions, IDEOptionsIntf, EditorOptions,
LazarusIDEStrConsts, CompOptsModes, PackageDefs, SynEdit, SynHighlighterPas; LazarusIDEStrConsts, CompOptsModes, SourceSynEditor, PackageDefs;
type type
TCBMNodeType = ( TCBMNodeType = (
@ -57,7 +57,6 @@ type
BuildMacroDefaultLabel: TLabel; BuildMacroDefaultLabel: TLabel;
BuildMacroDescriptionLabel: TLabel; BuildMacroDescriptionLabel: TLabel;
ConditionalsGroupBox: TGroupBox; ConditionalsGroupBox: TGroupBox;
ConditionalsSynPasSyn: TSynPasSyn;
CondSynEdit: TSynEdit; CondSynEdit: TSynEdit;
MacrosGroupBox: TGroupBox; MacrosGroupBox: TGroupBox;
MacrosSplitter: TSplitter; MacrosSplitter: TSplitter;
@ -73,6 +72,7 @@ type
procedure NewValueClick(Sender: TObject); procedure NewValueClick(Sender: TObject);
procedure DeleteValueClick(Sender: TObject); procedure DeleteValueClick(Sender: TObject);
private private
FHighlighter: TIDESynFreePasSyn;
FBuildMacros: TIDEBuildMacros; FBuildMacros: TIDEBuildMacros;
fVarImgID: LongInt; fVarImgID: LongInt;
fValueImgID: LongInt; fValueImgID: LongInt;
@ -555,6 +555,14 @@ procedure TCompOptBuildMacrosFrame.LoadFromOptions(Options: TBaseCompilerOptions
begin begin
BuildMacros:=Options.BuildMacros as TIDEBuildMacros; BuildMacros:=Options.BuildMacros as TIDEBuildMacros;
CondSynEdit.Lines.Text:=Options.Conditionals; CondSynEdit.Lines.Text:=Options.Conditionals;
EditorOpts.GetSynEditPreviewSettings(CondSynEdit);
CondSynEdit.ReadOnly:=false;
if FHighlighter=nil then
begin
FHighlighter := TPreviewPasSyn.Create(Self);
CondSynEdit.Highlighter:=FHighlighter;
end;
EditorOpts.ReadHighlighterSettings(FHighlighter, '');
end; end;
procedure TCompOptBuildMacrosFrame.SaveToOptions(Options: TBaseCompilerOptions procedure TCompOptBuildMacrosFrame.SaveToOptions(Options: TBaseCompilerOptions