codetools directory values: added treeview and memo to view the templates and how they were parsed

git-svn-id: trunk@9161 -
This commit is contained in:
mattias 2006-04-22 15:59:30 +00:00
parent d613b09c25
commit c0fe7541cd
9 changed files with 346 additions and 118 deletions

View File

@ -290,6 +290,11 @@ type
Result: string;
end;
PReadFunctionData = ^TReadFunctionData;
TDefTreeCalculate = procedure(Tree: TDefineTree; Node: TDefineTemplate;
ValueParsed: boolean; const ParsedValue: string;
ExpressionCalculated: boolean; const ExpressionResult: string;
Execute: boolean) of object;
TDefineTree = class
private
@ -301,6 +306,7 @@ type
FErrorTemplate: TDefineTemplate;
FMacroFunctions: TKeyWordFunctionList;
FMacroVariables: TKeyWordFunctionList;
FOnCalculate: TDefTreeCalculate;
FOnGetVirtualDirectoryAlias: TOnGetVirtualDirectoryAlias;
FOnGetVirtualDirectoryDefines: TOnGetVirtualDirectoryDefines;
FOnPrepareTree: TNotifyEvent;
@ -332,6 +338,7 @@ type
read FOnGetVirtualDirectoryDefines write FOnGetVirtualDirectoryDefines;
property OnReadValue: TOnReadValue read FOnReadValue write FOnReadValue;
property OnPrepareTree: TNotifyEvent read FOnPrepareTree write FOnPrepareTree;
property OnCalculate: TDefTreeCalculate read FOnCalculate write FOnCalculate;
property MacroFunctions: TKeyWordFunctionList read FMacroFunctions;
property MacroVariables: TKeyWordFunctionList read FMacroVariables;
public
@ -2184,8 +2191,11 @@ var
// jump to end of else templates
while (DefTempl.Next<>nil)
and (DefTempl.Next.Action in [da_Else,da_ElseIf])
do
do begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',false);
DefTempl:=DefTempl.Next;
end;
end;
// procedure CalculateTemplate(DefTempl: TDefineTemplate; const CurPath: string);
@ -2196,44 +2206,71 @@ var
case DefTempl.Action of
da_Block:
// calculate children
CalculateTemplate(DefTempl.FirstChild,CurPath);
begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',true);
CalculateTemplate(DefTempl.FirstChild,CurPath);
end;
da_Define:
// Define for a single Directory (not SubDirs)
if FilenameIsMatching(CurPath,ExpandedDirectory,true) then begin
ReadValue(DirDef,DefTempl.Value,CurPath,TempValue);
DirDef.Values.Variables[DefTempl.Variable]:=TempValue;
begin
if FilenameIsMatching(CurPath,ExpandedDirectory,true) then begin
ReadValue(DirDef,DefTempl.Value,CurPath,TempValue);
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,true,TempValue,false,'',true);
DirDef.Values.Variables[DefTempl.Variable]:=TempValue;
end else begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',false);
end;
end;
da_DefineRecurse:
// Define for current and sub directories
begin
ReadValue(DirDef,DefTempl.Value,CurPath,TempValue);
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,true,TempValue,false,'',true);
DirDef.Values.Variables[DefTempl.Variable]:=TempValue;
end;
da_Undefine:
// Undefine for a single Directory (not SubDirs)
if FilenameIsMatching(CurPath,ExpandedDirectory,true) then begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',true);
DirDef.Values.Undefine(DefTempl.Variable);
end else begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',false);
end;
da_UndefineRecurse:
// Undefine for current and sub directories
DirDef.Values.Undefine(DefTempl.Variable);
begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',true);
DirDef.Values.Undefine(DefTempl.Variable);
end;
da_UndefineAll:
// Undefine every value for current and sub directories
DirDef.Values.Clear;
begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',true);
DirDef.Values.Clear;
end;
da_If, da_ElseIf:
begin
// test expression in value
ReadValue(DirDef,DefTempl.Value,CurPath,TempValue);
EvalResult:=DirDef.Values.Eval(TempValue);
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,true,TempValue,true,EvalResult,EvalResult='1');
//debugln('da_If,da_ElseIf: DefTempl.Value="',DbgStr(DefTempl.Value),'" CurPath="',CurPath,'" TempValue="',TempValue,'" EvalResult=',EvalResult);
if DirDef.Values.ErrorPosition>=0 then begin
ReadValue(DirDef,DefTempl.Value,CurPath,TempValue);
FErrorDescription:=Format(ctsSyntaxErrorInExpr,[TempValue]);
FErrorTemplate:=DefTempl;
end else if EvalResult='1' then
@ -2247,32 +2284,50 @@ var
// ' Is=',dbgs(DirDef.Values.IsDefined(DefTempl.Variable)),
// ' CurPath="',CurPath,'"',
// ' Values.Count=',dbgs(DirDef.Values.Count));
if DirDef.Values.IsDefined(DefTempl.Variable) then
if DirDef.Values.IsDefined(DefTempl.Variable) then begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',true);
CalculateIfChilds;
end else begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',false);
end;
end;
da_IfNDef:
// test if variable is not defined
if not DirDef.Values.IsDefined(DefTempl.Variable) then
if not DirDef.Values.IsDefined(DefTempl.Variable) then begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',true);
CalculateIfChilds;
end else begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',false);
end;
da_Else:
// execute childs
CalculateTemplate(DefTempl.FirstChild,CurPath);
begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,false,'',false,'',true);
CalculateTemplate(DefTempl.FirstChild,CurPath);
end;
da_Directory:
begin
// template for a sub directory
ReadValue(DirDef,DefTempl.Value,CurPath,TempValue);
{$ifdef win32}
if CurPath='' then
SubPath:=TempValue
else
{$endif}
SubPath:=CurPath+PathDelim+TempValue;
// CurPath can be ''
SubPath:=AppendPathDelim(CurPath)+TempValue;
// test if ExpandedDirectory is part of SubPath
if FilenameIsMatching(SubPath,ExpandedDirectory,false) then
if FilenameIsMatching(SubPath,ExpandedDirectory,false) then begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,true,SubPath,false,'',true);
CalculateTemplate(DefTempl.FirstChild,SubPath);
end else begin
if Assigned(OnCalculate) then
OnCalculate(Self,DefTempl,true,SubPath,false,'',false);
end;
end;
end;
if ErrorTemplate<>nil then exit;
@ -3247,9 +3302,6 @@ var
ParentDefTempl.AddChild(IfTargetOSIsNotSrcOS2);
end;
// function CreateFPCSrcTemplate(const FPCSrcDir,
// UnitSearchPath: string;
// UnitLinkListValid: boolean; var UnitLinkList: string): TDefineTemplate;
var
DefTempl, MainDir, FCLDir, RTLDir, RTLOSDir, PackagesDir, CompilerDir,
UtilsDir, DebugSvrDir: TDefineTemplate;
@ -3265,8 +3317,7 @@ begin
Result:=nil;
if (FPCSrcDir='') or (not DirPathExists(FPCSrcDir)) then exit;
DS:=PathDelim;
Dir:=FPCSrcDir;
if Dir[length(Dir)]<>DS then Dir:=Dir+DS;
Dir:=AppendPathDelim(FPCSrcDir);
TargetOS:='$('+ExternalMacroStart+'TargetOS)';
SrcOS:='$('+ExternalMacroStart+'SrcOS)';
SrcOS2:='$('+ExternalMacroStart+'SrcOS2)';

View File

@ -1477,7 +1477,7 @@ begin
CreateComponents;
MainSplitter.SetSplitterPosition(
Max(20,Min(ClientWidth-100,CodeToolsOpts.DefinesEditMainSplitterTop)));
Max(20,Min(ClientHeight-100,CodeToolsOpts.DefinesEditMainSplitterTop)));
FDefineTree:=TDefineTree.Create;
end;

View File

@ -1,26 +1,27 @@
object CodeToolsDefinesDialog: TCodeToolsDefinesDialog
Caption = 'CodeToolsDefinesDialog'
ClientHeight = 450
ClientWidth = 485
ClientWidth = 502
OnClose = CodeToolsDefinesDialogCLOSE
OnCreate = CodeToolsDefinesDialogCREATE
OnDestroy = FormDestroy
PixelsPerInch = 112
HorzScrollBar.Page = 484
HorzScrollBar.Page = 501
VertScrollBar.Page = 449
Left = 423
Height = 450
Top = 228
Width = 485
Width = 502
object DirectoryGroupbox: TGroupBox
Align = alTop
Caption = 'DirectoryGroupbox'
ClientHeight = 31
ClientWidth = 481
ClientWidth = 498
ParentCtl3D = False
TabOrder = 0
OnResize = DirectoryGroupboxRESIZE
Height = 48
Width = 485
Width = 502
object DirectoryCombobox: TComboBox
AutoCompleteText = [cbactEndOfLineComplete, cbactSearchAscending]
MaxLength = 0
@ -45,26 +46,26 @@ object CodeToolsDefinesDialog: TCodeToolsDefinesDialog
end
end
object ValuesListview: TListView
Align = alClient
Align = alLeft
Columns = <>
TabOrder = 1
ViewStyle = vsReport
OnSelectItem = ValuesListviewSELECTITEM
Height = 271
Top = 48
Width = 280
Width = 296
end
object ValueGroupbox: TGroupBox
Align = alBottom
Anchors = [akLeft, akBottom]
Caption = 'Value'
ClientHeight = 85
ClientWidth = 481
ClientWidth = 498
ParentCtl3D = False
TabOrder = 2
Height = 102
Top = 319
Width = 485
Width = 502
object ValueSynedit: TSynEdit
Align = alBottom
Font.Height = -15
@ -74,9 +75,11 @@ object CodeToolsDefinesDialog: TCodeToolsDefinesDialog
ParentColor = False
ParentCtl3D = False
TabOrder = 0
Width = 481
Width = 498
BookMarkOptions.Xoffset = -18
BookMarkOptions.OnChange = nil
Gutter.Visible = False
Gutter.OnChange = nil
Gutter.CodeFoldingWidth = 14
Keystrokes = <
item
@ -404,9 +407,10 @@ object CodeToolsDefinesDialog: TCodeToolsDefinesDialog
)
Options = [eoAutoIndent, eoDragDropEditing, eoScrollPastEol, eoShowScrollHint, eoSmartTabs, eoTabsToSpaces, eoTrimTrailingSpaces, eoBracketHighlight, eoShowCtrlMouseLinks]
ReadOnly = True
SelectedColor.OnChange = nil
Cursor = crIBeam
Height = 85
Width = 481
Width = 498
end
end
object CloseButton: TButton
@ -418,26 +422,55 @@ object CodeToolsDefinesDialog: TCodeToolsDefinesDialog
TabOrder = 3
Height = 29
Top = 421
Width = 485
Width = 502
end
object MainSplitter: TSplitter
Align = alRight
Height = 271
Width = 4
ResizeAnchor = akRight
Cursor = crHSplit
Left = 280
Left = 296
Height = 271
Top = 48
Width = 4
end
object ParsedTemplatesTreeView: TTreeView
Align = alRight
DefaultItemHeight = 14
object TemplatesGroupBox: TGroupBox
Align = alClient
Caption = 'TemplatesGroupBox'
ClientHeight = 254
ClientWidth = 198
TabOrder = 4
Left = 285
Left = 300
Height = 271
Top = 48
Width = 200
Width = 202
object ParsedTemplatesTreeView: TTreeView
Align = alTop
DefaultItemHeight = 14
TabOrder = 0
OnSelectionChanged = ParsedTemplatesTreeViewSelectionChanged
Height = 122
Width = 198
end
object TemplatesSplitter: TSplitter
Align = alTop
Cursor = crVSplit
Height = 5
Width = 198
ResizeAnchor = akTop
Cursor = crVSplit
Height = 5
Top = 122
Width = 198
end
object TemplatesMemo: TMemo
Align = alClient
Lines.Strings = (
'Memo1'
)
TabOrder = 1
Height = 127
Top = 127
Width = 198
end
end
end

View File

@ -2,39 +2,40 @@
LazarusResources.Add('TCodeToolsDefinesDialog','FORMDATA',[
'TPF0'#23'TCodeToolsDefinesDialog'#22'CodeToolsDefinesDialog'#7'Caption'#6#22
+'CodeToolsDefinesDialog'#12'ClientHeight'#3#194#1#11'ClientWidth'#3#229#1#7
+'CodeToolsDefinesDialog'#12'ClientHeight'#3#194#1#11'ClientWidth'#3#246#1#7
+'OnClose'#7#27'CodeToolsDefinesDialogCLOSE'#8'OnCreate'#7#28'CodeToolsDefine'
+'sDialogCREATE'#13'PixelsPerInch'#2'p'#18'HorzScrollBar.Page'#3#228#1#18'Ver'
+'tScrollBar.Page'#3#193#1#4'Left'#3#167#1#6'Height'#3#194#1#3'Top'#3#228#0#5
+'Width'#3#229#1#0#9'TGroupBox'#17'DirectoryGroupbox'#5'Align'#7#5'alTop'#7'C'
+'aption'#6#17'DirectoryGroupbox'#12'ClientHeight'#2#31#11'ClientWidth'#3#225
+#1#11'ParentCtl3D'#8#8'TabOrder'#2#0#8'OnResize'#7#23'DirectoryGroupboxRESIZ'
+'E'#6'Height'#2'0'#5'Width'#3#229#1#0#9'TComboBox'#17'DirectoryCombobox'#16
+'AutoCompleteText'#11#22'cbactEndOfLineComplete'#20'cbactSearchAscending'#0#9
+'MaxLength'#2#0#8'OnChange'#7#23'DirectoryComboboxCHANGE'#11'ParentCtl3D'#8#8
+'TabOrder'#2#0#4'Text'#6#17'DirectoryCombobox'#4'Left'#2#6#6'Height'#2#25#3
+'Top'#2#1#5'Width'#3'h'#1#0#0#7'TButton'#21'DirectoryBrowseButton'#25'Border'
+'Spacing.InnerBorder'#2#2#7'Caption'#6#3'...'#7'OnClick'#7#26'DirectoryBrows'
+'eButtonCLICK'#8'TabOrder'#2#1#4'Left'#3'w'#1#6'Height'#2#26#3'Top'#2#1#5'Wi'
+'dth'#2#31#0#0#0#9'TListView'#14'ValuesListview'#5'Align'#7#8'alClient'#7'Co'
+'lumns'#14#0#8'TabOrder'#2#1#9'ViewStyle'#7#8'vsReport'#12'OnSelectItem'#7#24
+'ValuesListviewSELECTITEM'#6'Height'#3#15#1#3'Top'#2'0'#5'Width'#3#24#1#0#0#9
+'TGroupBox'#13'ValueGroupbox'#5'Align'#7#8'alBottom'#7'Anchors'#11#6'akLeft'
+#8'akBottom'#0#7'Caption'#6#5'Value'#12'ClientHeight'#2'U'#11'ClientWidth'#3
+#225#1#11'ParentCtl3D'#8#8'TabOrder'#2#2#6'Height'#2'f'#3'Top'#3'?'#1#5'Widt'
+'h'#3#229#1#0#8'TSynEdit'#12'ValueSynedit'#5'Align'#7#8'alBottom'#11'Font.He'
+'ight'#2#241#9'Font.Name'#6#7'courier'#6'Height'#2'U'#4'Name'#6#12'ValueSyne'
+'dit'#11'ParentColor'#8#11'ParentCtl3D'#8#8'TabOrder'#2#0#5'Width'#3#225#1#23
+'BookMarkOptions.Xoffset'#2#238#14'Gutter.Visible'#8#23'Gutter.CodeFoldingWi'
+'dth'#2#14#10'Keystrokes'#14#1#7'Command'#2#3#8'ShortCut'#2'&'#0#1#7'Command'
+#2'g'#8'ShortCut'#3'& '#0#1#7'Command'#3#211#0#8'ShortCut'#3'&@'#0#1#7'Comma'
+'nd'#2#4#8'ShortCut'#2'('#0#1#7'Command'#2'h'#8'ShortCut'#3'( '#0#1#7'Comman'
+'d'#3#212#0#8'ShortCut'#3'(@'#0#1#7'Command'#2#1#8'ShortCut'#2'%'#0#1#7'Comm'
+'and'#2'e'#8'ShortCut'#3'% '#0#1#7'Command'#2#5#8'ShortCut'#3'%@'#0#1#7'Comm'
+'and'#2'i'#8'ShortCut'#3'%`'#0#1#7'Command'#2#2#8'ShortCut'#2''''#0#1#7'Comm'
+'and'#2'f'#8'ShortCut'#3''' '#0#1#7'Command'#2#6#8'ShortCut'#3'''@'#0#1#7'Co'
+'mmand'#2'j'#8'ShortCut'#3'''`'#0#1#7'Command'#2#10#8'ShortCut'#2'"'#0#1#7'C'
+'ommand'#2'n'#8'ShortCut'#3'" '#0#1#7'Command'#2#14#8'ShortCut'#3'"@'#0#1#7
+'sDialogCREATE'#9'OnDestroy'#7#11'FormDestroy'#13'PixelsPerInch'#2'p'#18'Hor'
+'zScrollBar.Page'#3#245#1#18'VertScrollBar.Page'#3#193#1#4'Left'#3#167#1#6'H'
+'eight'#3#194#1#3'Top'#3#228#0#5'Width'#3#246#1#0#9'TGroupBox'#17'DirectoryG'
+'roupbox'#5'Align'#7#5'alTop'#7'Caption'#6#17'DirectoryGroupbox'#12'ClientHe'
+'ight'#2#31#11'ClientWidth'#3#242#1#11'ParentCtl3D'#8#8'TabOrder'#2#0#8'OnRe'
+'size'#7#23'DirectoryGroupboxRESIZE'#6'Height'#2'0'#5'Width'#3#246#1#0#9'TCo'
+'mboBox'#17'DirectoryCombobox'#16'AutoCompleteText'#11#22'cbactEndOfLineComp'
+'lete'#20'cbactSearchAscending'#0#9'MaxLength'#2#0#8'OnChange'#7#23'Director'
+'yComboboxCHANGE'#11'ParentCtl3D'#8#8'TabOrder'#2#0#4'Text'#6#17'DirectoryCo'
+'mbobox'#4'Left'#2#6#6'Height'#2#25#3'Top'#2#1#5'Width'#3'h'#1#0#0#7'TButton'
+#21'DirectoryBrowseButton'#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#3
+'...'#7'OnClick'#7#26'DirectoryBrowseButtonCLICK'#8'TabOrder'#2#1#4'Left'#3
+'w'#1#6'Height'#2#26#3'Top'#2#1#5'Width'#2#31#0#0#0#9'TListView'#14'ValuesLi'
+'stview'#5'Align'#7#6'alLeft'#7'Columns'#14#0#8'TabOrder'#2#1#9'ViewStyle'#7
+#8'vsReport'#12'OnSelectItem'#7#24'ValuesListviewSELECTITEM'#6'Height'#3#15#1
+#3'Top'#2'0'#5'Width'#3'('#1#0#0#9'TGroupBox'#13'ValueGroupbox'#5'Align'#7#8
+'alBottom'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#7'Caption'#6#5'Value'#12'Cl'
+'ientHeight'#2'U'#11'ClientWidth'#3#242#1#11'ParentCtl3D'#8#8'TabOrder'#2#2#6
+'Height'#2'f'#3'Top'#3'?'#1#5'Width'#3#246#1#0#8'TSynEdit'#12'ValueSynedit'#5
+'Align'#7#8'alBottom'#11'Font.Height'#2#241#9'Font.Name'#6#7'courier'#6'Heig'
+'ht'#2'U'#4'Name'#6#12'ValueSynedit'#11'ParentColor'#8#11'ParentCtl3D'#8#8'T'
+'abOrder'#2#0#5'Width'#3#242#1#23'BookMarkOptions.Xoffset'#2#238#24'BookMark'
+'Options.OnChange'#13#14'Gutter.Visible'#8#15'Gutter.OnChange'#13#23'Gutter.'
+'CodeFoldingWidth'#2#14#10'Keystrokes'#14#1#7'Command'#2#3#8'ShortCut'#2'&'#0
+#1#7'Command'#2'g'#8'ShortCut'#3'& '#0#1#7'Command'#3#211#0#8'ShortCut'#3'&@'
+#0#1#7'Command'#2#4#8'ShortCut'#2'('#0#1#7'Command'#2'h'#8'ShortCut'#3'( '#0
+#1#7'Command'#3#212#0#8'ShortCut'#3'(@'#0#1#7'Command'#2#1#8'ShortCut'#2'%'#0
+#1#7'Command'#2'e'#8'ShortCut'#3'% '#0#1#7'Command'#2#5#8'ShortCut'#3'%@'#0#1
+#7'Command'#2'i'#8'ShortCut'#3'%`'#0#1#7'Command'#2#2#8'ShortCut'#2''''#0#1#7
+'Command'#2'f'#8'ShortCut'#3''' '#0#1#7'Command'#2#6#8'ShortCut'#3'''@'#0#1#7
+'Command'#2'j'#8'ShortCut'#3'''`'#0#1#7'Command'#2#10#8'ShortCut'#2'"'#0#1#7
+'Command'#2'n'#8'ShortCut'#3'" '#0#1#7'Command'#2#14#8'ShortCut'#3'"@'#0#1#7
+'Command'#2'r'#8'ShortCut'#3'"`'#0#1#7'Command'#2#9#8'ShortCut'#2'!'#0#1#7'C'
+'ommand'#2'm'#8'ShortCut'#3'! '#0#1#7'Command'#2#13#8'ShortCut'#3'!@'#0#1#7
+'Command'#2'q'#8'ShortCut'#3'!`'#0#1#7'Command'#2#7#8'ShortCut'#2'$'#0#1#7'C'
@ -64,21 +65,29 @@ LazarusResources.Add('TCodeToolsDefinesDialog','FORMDATA',[
+#1#8'ShortCut'#3'2`'#0#1#7'Command'#3'b'#1#8'ShortCut'#3'3`'#0#1#7'Command'#3
+'c'#1#8'ShortCut'#3'4`'#0#1#7'Command'#3'd'#1#8'ShortCut'#3'5`'#0#1#7'Comman'
+'d'#3'e'#1#8'ShortCut'#3'6`'#0#1#7'Command'#3'f'#1#8'ShortCut'#3'7`'#0#1#7'C'
+'ommand'#3'g'#1#8'ShortCut'#3'8`'#0#1#7'Command'#3'h'#1#8'ShortCut'#3'9`'#0#1
,#7'Command'#3#231#0#8'ShortCut'#3'N`'#0#1#7'Command'#3#232#0#8'ShortCut'#3'C'
,'ommand'#3'g'#1#8'ShortCut'#3'8`'#0#1#7'Command'#3'h'#1#8'ShortCut'#3'9`'#0#1
+#7'Command'#3#231#0#8'ShortCut'#3'N`'#0#1#7'Command'#3#232#0#8'ShortCut'#3'C'
+'`'#0#1#7'Command'#3#233#0#8'ShortCut'#3'L`'#0#1#7'Command'#3'd'#2#8'ShortCu'
+'t'#2#9#0#1#7'Command'#3'e'#2#8'ShortCut'#3#9' '#0#1#7'Command'#3#250#0#8'Sh'
+'ortCut'#3'B`'#0#0#13'Lines.Strings'#1#6#12'ValueSynedit'#0#7'Options'#11#12
+'eoAutoIndent'#17'eoDragDropEditing'#15'eoScrollPastEol'#16'eoShowScrollHint'
+#11'eoSmartTabs'#14'eoTabsToSpaces'#20'eoTrimTrailingSpaces'#18'eoBracketHig'
+'hlight'#20'eoShowCtrlMouseLinks'#0#8'ReadOnly'#9#6'Cursor'#7#7'crIBeam'#6'H'
+'eight'#2'U'#5'Width'#3#225#1#0#0#0#7'TButton'#11'CloseButton'#5'Align'#7#8
+'alBottom'#7'Anchors'#11#6'akLeft'#8'akBottom'#0#25'BorderSpacing.InnerBorde'
+'r'#2#2#7'Caption'#6#11'CloseButton'#11'ModalResult'#2#2#8'TabOrder'#2#3#6'H'
+'eight'#2#29#3'Top'#3#165#1#5'Width'#3#229#1#0#0#9'TSplitter'#12'MainSplitte'
+'r'#5'Align'#7#7'alRight'#6'Height'#3#15#1#5'Width'#2#4#12'ResizeAnchor'#7#7
+'akRight'#6'Cursor'#7#8'crHSplit'#4'Left'#3#24#1#6'Height'#3#15#1#3'Top'#2'0'
+#5'Width'#2#4#0#0#9'TTreeView'#23'ParsedTemplatesTreeView'#5'Align'#7#7'alRi'
+'ght'#17'DefaultItemHeight'#2#14#8'TabOrder'#2#4#4'Left'#3#29#1#6'Height'#3
+#15#1#3'Top'#2'0'#5'Width'#3#200#0#0#0#0
+'hlight'#20'eoShowCtrlMouseLinks'#0#8'ReadOnly'#9#22'SelectedColor.OnChange'
+#13#6'Cursor'#7#7'crIBeam'#6'Height'#2'U'#5'Width'#3#242#1#0#0#0#7'TButton'
+#11'CloseButton'#5'Align'#7#8'alBottom'#7'Anchors'#11#6'akLeft'#8'akBottom'#0
+#25'BorderSpacing.InnerBorder'#2#2#7'Caption'#6#11'CloseButton'#11'ModalResu'
+'lt'#2#2#8'TabOrder'#2#3#6'Height'#2#29#3'Top'#3#165#1#5'Width'#3#246#1#0#0#9
+'TSplitter'#12'MainSplitter'#6'Height'#3#15#1#5'Width'#2#4#6'Cursor'#7#8'crH'
+'Split'#4'Left'#3'('#1#6'Height'#3#15#1#3'Top'#2'0'#5'Width'#2#4#0#0#9'TGrou'
+'pBox'#17'TemplatesGroupBox'#5'Align'#7#8'alClient'#7'Caption'#6#17'Template'
+'sGroupBox'#12'ClientHeight'#3#254#0#11'ClientWidth'#3#198#0#8'TabOrder'#2#4
+#4'Left'#3','#1#6'Height'#3#15#1#3'Top'#2'0'#5'Width'#3#202#0#0#9'TTreeView'
+#23'ParsedTemplatesTreeView'#5'Align'#7#5'alTop'#17'DefaultItemHeight'#2#14#8
+'TabOrder'#2#0#18'OnSelectionChanged'#7'''ParsedTemplatesTreeViewSelectionCh'
+'anged'#6'Height'#2'z'#5'Width'#3#198#0#0#0#9'TSplitter'#17'TemplatesSplitte'
+'r'#5'Align'#7#5'alTop'#6'Cursor'#7#8'crVSplit'#6'Height'#2#5#5'Width'#3#198
+#0#12'ResizeAnchor'#7#5'akTop'#6'Cursor'#7#8'crVSplit'#6'Height'#2#5#3'Top'#2
+'z'#5'Width'#3#198#0#0#0#5'TMemo'#13'TemplatesMemo'#5'Align'#7#8'alClient'#13
+'Lines.Strings'#1#6#5'Memo1'#0#8'TabOrder'#2#1#6'Height'#2''#3'Top'#2''#5
+'Width'#3#198#0#0#0#0#0
]);

View File

@ -5,12 +5,22 @@ unit CodeToolsDefPreview;
interface
uses
Classes, SysUtils, Math, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ComCtrls, ExtCtrls, FileUtil,
Classes, SysUtils, Math,
LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, Buttons, ComCtrls, ExtCtrls, FileUtil, AVGLvlTree,
SynEdit, DefineTemplates, ExprEval,
LazarusIDEStrConsts, InputHistory, IDEWindowIntf, CodeToolsOptions;
type
TCodeToolsDefinesNodeValues = class
public
Node: TDefineTemplate;
ValueParsed: boolean;
ParsedValue: string;
ExpressionCalculated: boolean;
ExpressionResult: string;
Execute: boolean;
end;
{ TCodeToolsDefinesDialog }
@ -19,6 +29,9 @@ type
DirectoryBrowseButton: TButton;
DirectoryCombobox: TComboBox;
DirectoryGroupbox: TGroupBox;
TemplatesMemo: TMemo;
TemplatesSplitter: TSplitter;
TemplatesGroupBox: TGroupBox;
MainSplitter: TSplitter;
ParsedTemplatesTreeView: TTreeView;
ValueSynedit: TSynEdit;
@ -30,16 +43,24 @@ type
procedure DirectoryBrowseButtonCLICK(Sender: TObject);
procedure DirectoryComboboxCHANGE(Sender: TObject);
procedure DirectoryGroupboxRESIZE(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure ParsedTemplatesTreeViewSelectionChanged(Sender: TObject);
procedure ValuesListviewSELECTITEM(Sender: TObject; Item: TListItem;
Selected: Boolean);
private
FDefineTree: TDefineTree;
FNodeValues: TAvgLvlTree;
procedure SetDefineTree(const AValue: TDefineTree);
procedure UpdateValues;
procedure UpdateValue;
procedure UpdateTemplateValues;
procedure ClearValues;
procedure FillTemplateTree;
procedure SetComboBox(AComboBox: TComboBox; const NewText: string);
procedure DefineTreeCalculate(Tree: TDefineTree; Node: TDefineTemplate;
ValueParsed: boolean; const ParsedValue: string;
ExpressionCalculated: boolean; const ExpressionResult: string;
Execute: boolean);
public
property DefineTree: TDefineTree read FDefineTree write SetDefineTree;
end;
@ -54,6 +75,8 @@ procedure AddDefineNodes(ATreeView: TTreeView; ANode: TDefineTemplate;
AParent: TTreeNode; WithChilds,WithNextSiblings: boolean);
procedure SetNodeImages(ANode: TTreeNode; WithSubNodes: boolean);
function CompareNodeValues(Data1, Data2: Pointer): Integer;
function CompareNodeAndNodeValues(Node, NodeValues: Pointer): Integer;
implementation
@ -134,6 +157,18 @@ begin
end;
end;
function CompareNodeValues(Data1, Data2: Pointer): Integer;
begin
Result:=ComparePointers(TCodeToolsDefinesNodeValues(Data1).Node,
TCodeToolsDefinesNodeValues(Data2).Node);
end;
function CompareNodeAndNodeValues(Node, NodeValues: Pointer): Integer;
begin
Result:=ComparePointers(TCodeToolsDefinesNodeValues(Node),
TCodeToolsDefinesNodeValues(NodeValues).Node);
end;
{ TCodeToolsDefinesDialog }
procedure TCodeToolsDefinesDialog.DirectoryGroupboxRESIZE(Sender: TObject);
@ -147,6 +182,20 @@ begin
SetBounds(x,0,Parent.ClientWidth-x,DirectoryCombobox.Height);
end;
procedure TCodeToolsDefinesDialog.FormDestroy(Sender: TObject);
begin
if FNodeValues<>nil then begin
FNodeValues.FreeAndClear;
FreeAndNil(FNodeValues);
end;
end;
procedure TCodeToolsDefinesDialog.ParsedTemplatesTreeViewSelectionChanged(
Sender: TObject);
begin
UpdateTemplateValues;
end;
procedure TCodeToolsDefinesDialog.ValuesListviewSELECTITEM(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
@ -162,12 +211,14 @@ begin
end;
procedure TCodeToolsDefinesDialog.UpdateValues;
// let the codetools calculate the defines for the directory
var
Dir: String;
Defines: TExpressionEvaluator;
i: Integer;
ListItem: TListItem;
Value: String;
OldOnCalculate: TDefTreeCalculate;
begin
Dir:=TrimFilename(DirectoryCombobox.Text);
if (DefineTree=nil) or (not FilenameIsAbsolute(Dir))
@ -175,8 +226,20 @@ begin
ClearValues;
exit;
end;
//writeln('TCodeToolsDefinesDialog.UpdateValues ',Dir);
Defines:=DefineTree.GetDefinesForDirectory(Dir,false);
// set our debug function, clear codetools cache and calculate the values
if FNodeValues<>nil then
FNodeValues.FreeAndClear;
DefineTree.ClearCache;// make sure the defines are reparsed
OldOnCalculate:=DefineTree.OnCalculate;
DefineTree.OnCalculate:=@DefineTreeCalculate;
try
Defines:=DefineTree.GetDefinesForDirectory(Dir,false);
finally
DefineTree.OnCalculate:=OldOnCalculate;
end;
// fill the ValuesListview
ValuesListview.BeginUpdate;
for i:=0 to Defines.Count-1 do begin
if ValuesListview.Items.Count<=i then
@ -219,14 +282,51 @@ begin
end;
end;
procedure TCodeToolsDefinesDialog.UpdateTemplateValues;
var
SelTreeNode: TTreeNode;
SelDefNode: TDefineTemplate;
s: string;
AVLNode: TAvgLvlTreeNode;
NodeValues: TCodeToolsDefinesNodeValues;
begin
SelTreeNode:=ParsedTemplatesTreeView.Selected;
if SelTreeNode=nil then begin
TemplatesMemo.Text:='No node selected';
end else begin
SelDefNode:=TDefineTemplate(SelTreeNode.Data);
s:='Name="'+SelDefNode.Name+'"'+LineEnding;
s:=s+'Description="'+SelDefNode.Description+'"'+LineEnding;
s:=s+'Action="'+DefineActionNames[SelDefNode.Action]+'"'+LineEnding;
s:=s+'Variable="'+SelDefNode.Variable+'"'+LineEnding;
s:=s+'Value="'+SelDefNode.Value+'"'+LineEnding;
if FNodeValues<>nil then begin
AVLNode:=FNodeValues.FindKey(SelDefNode,@CompareNodeAndNodeValues);
if AVLNode<>nil then begin
NodeValues:=TCodeToolsDefinesNodeValues(AVLNode.Data);
if NodeValues.ValueParsed then
s:=s+'Parsed Value="'+NodeValues.ParsedValue+'"'+LineEnding;
if NodeValues.ExpressionCalculated then
s:=s+'Expression Result="'+NodeValues.ExpressionResult+'"'+LineEnding;
s:=s+'Executed="'+dbgs(NodeValues.Execute)+'"'+LineEnding;
end;
end;
TemplatesMemo.Text:=s;
end;
end;
procedure TCodeToolsDefinesDialog.ClearValues;
begin
ValuesListview.Items.Clear;
if FNodeValues<>nil then
FNodeValues.FreeAndClear;
end;
procedure TCodeToolsDefinesDialog.FillTemplateTree;
begin
RebuildDefineTreeView(ParsedTemplatesTreeView,DefineTree.RootTemplate);
UpdateTemplateValues;
end;
procedure TCodeToolsDefinesDialog.SetComboBox(AComboBox: TComboBox;
@ -243,6 +343,25 @@ begin
//writeln('TCodeToolsDefinesDialog.SetComboBox Text=',AComboBox.Text,' NewText=',NewText);
end;
procedure TCodeToolsDefinesDialog.DefineTreeCalculate(Tree: TDefineTree;
Node: TDefineTemplate; ValueParsed: boolean; const ParsedValue: string;
ExpressionCalculated: boolean; const ExpressionResult: string;
Execute: boolean);
var
NewNodeValues: TCodeToolsDefinesNodeValues;
begin
NewNodeValues:=TCodeToolsDefinesNodeValues.Create;
NewNodeValues.Node:=Node;
NewNodeValues.ValueParsed:=ValueParsed;
NewNodeValues.ParsedValue:=ParsedValue;
NewNodeValues.ExpressionCalculated:=ExpressionCalculated;
NewNodeValues.ExpressionResult:=ExpressionResult;
NewNodeValues.Execute:=Execute;
if FNodeValues=nil then
FNodeValues:=TAvgLvlTree.Create(@CompareNodeValues);
FNodeValues.Add(NewNodeValues);
end;
procedure TCodeToolsDefinesDialog.CodeToolsDefinesDialogCREATE(Sender: TObject);
var
ListColumn: TListColumn;
@ -267,16 +386,23 @@ begin
else
DirectoryCombobox.Text:='';
TemplatesGroupBox.Caption:=lisCTDefDefineTemplates;
MainSplitter.SetSplitterPosition(
Max(20,Min(ClientWidth-100,CodeToolsOpts.DefinesPreviewMainSplitterPos)));
TemplatesSplitter.SetSplitterPosition(
Max(20,Min(TemplatesGroupBox.ClientHeight-50,
CodeToolsOpts.DefinesPreviewTemplSplitterPos)));
end;
procedure TCodeToolsDefinesDialog.CodeToolsDefinesDialogCLOSE(Sender: TObject;
var CloseAction: TCloseAction);
begin
IDEDialogLayoutList.SaveLayout(Self);
InputHistories.HistoryLists.GetList(hlCodeToolsDirectories,true).Assign(
DirectoryCombobox.Items);
CodeToolsOpts.DefinesPreviewMainSplitterPos:=MainSplitter.Left;
CodeToolsOpts.DefinesPreviewMainSplitterPos:=MainSplitter.GetSplitterPosition;
CodeToolsOpts.DefinesPreviewTemplSplitterPos:=TemplatesSplitter.GetSplitterPosition;
CodeToolsOpts.Save;
end;

View File

@ -60,6 +60,7 @@ type
FGlobalDefineTemplates: TDefineTemplate;
FDefinesEditMainSplitterTop: integer;
FDefinesPreviewMainSplitterPos: integer;
FDefinesPreviewTemplSplitterPos: integer;
// CodeCreation
FAddInheritedCodeToOverrideMethod: boolean;
@ -113,6 +114,8 @@ type
write FDefinesEditMainSplitterTop;
property DefinesPreviewMainSplitterPos: integer
read FDefinesPreviewMainSplitterPos write FDefinesPreviewMainSplitterPos;
property DefinesPreviewTemplSplitterPos: integer
read FDefinesPreviewTemplSplitterPos write FDefinesPreviewTemplSplitterPos;
// CodeCreation
property CompleteProperties: boolean
@ -420,7 +423,9 @@ begin
FDefinesEditMainSplitterTop:=XMLConfig.GetValue(
'CodeToolsOptions/DefinesEditMainSplitter/Top',100);
FDefinesPreviewMainSplitterPos:=XMLConfig.GetValue(
'CodeToolsOptions/DefinesPreviewMainSplitter/Position',100);
'CodeToolsOptions/DefinesPreviewMainSplitter/Position',280);
FDefinesPreviewTemplSplitterPos:=XMLConfig.GetValue(
'CodeToolsOptions/DefinesPreviewTemplSplitter/Position',100);
// CodeCreation
FAddInheritedCodeToOverrideMethod:=XMLConfig.GetValue(
@ -511,6 +516,8 @@ begin
FDefinesEditMainSplitterTop,100);
XMLConfig.SetDeleteValue('CodeToolsOptions/DefinesPreviewMainSplitter/Position',
FDefinesPreviewMainSplitterPos,280);
XMLConfig.SetDeleteValue('CodeToolsOptions/DefinesPreviewTemplSplitter/Position',
FDefinesPreviewTemplSplitterPos,100);
// CodeCreation
XMLConfig.SetDeleteValue(
@ -607,6 +614,7 @@ begin
FGlobalDefineTemplates.SetDefineOwner(Self,true);
FDefinesEditMainSplitterTop:=CodeToolsOpts.DefinesEditMainSplitterTop;
FDefinesPreviewMainSplitterPos:=CodeToolsOpts.DefinesPreviewMainSplitterPos;
FDefinesPreviewTemplSplitterPos:=CodeToolsOpts.DefinesPreviewTemplSplitterPos;
// CodeCreation
FLineLength:=CodeToolsOpts.FLineLength;
@ -645,6 +653,7 @@ begin
ClearGlobalDefineTemplates;
FDefinesEditMainSplitterTop:=100;
FDefinesPreviewMainSplitterPos:=280;
FDefinesPreviewTemplSplitterPos:=100;
// CodeCreation
FAddInheritedCodeToOverrideMethod:=true;
@ -694,6 +703,7 @@ begin
CodeToolsOpts.FGlobalDefineTemplates,true,true))
and (FDefinesEditMainSplitterTop=CodeToolsOpts.fDefinesEditMainSplitterTop)
and (FDefinesPreviewMainSplitterPos=CodeToolsOpts.FDefinesPreviewMainSplitterPos)
and (FDefinesPreviewTemplSplitterPos=CodeToolsOpts.FDefinesPreviewTemplSplitterPos)
// CodeCreation
and (FLineLength=CodeToolsOpts.FLineLength)

View File

@ -133,6 +133,7 @@ resourcestring
lisMenuSaveAs = 'Save As';
lisMenuSaveAll = 'Save All';
lisMenuClose = 'Close';
lisCTDefDefineTemplates = 'Define templates';
lisMenuCloseAll = 'Close all editor files';
lisMenuCleanDirectory = 'Clean directory';
lisMenuQuit = 'Quit';

View File

@ -419,6 +419,7 @@ type
function GetOtherResizeControl: TControl;
procedure MoveSplitter(Offset: integer);
procedure SetSplitterPosition(NewPosition: integer);
function GetSplitterPosition: integer;
public
property Align default alLeft;
property ResizeStyle: TResizeStyle read FResizeStyle write SetResizeStyle default rsUpdate;

View File

@ -207,35 +207,24 @@ var
end;
procedure SetAlignControlSize(NewSize: Integer);
var
NewBounds: TRect;
begin
NewBounds:=CurResizeControl.BoundsRect;
//DebugLn('SetAlignControlSize ',DbgSName(Self),' CurResizeControl=',DbgSName(CurResizeControl),' OldBounds=',dbgs(NewBounds),' NewSize=',dbgs(NewSize));
case ResizeAnchor of
akLeft:
CurResizeControl.Width := NewSize;
NewBounds.Right := NewBounds.Left+NewSize;
akRight:
begin
Parent.DisableAlign;
try
CurResizeControl.Left := CurResizeControl.Left
+ (CurResizeControl.Width - NewSize);
CurResizeControl.Width := NewSize;
finally
Parent.EnableAlign;
end;
end;
NewBounds.Left := NewBounds.Right-NewSize;
akTop:
CurResizeControl.Height := NewSize;
NewBounds.Bottom := NewBounds.Top+NewSize;
akBottom:
begin
Parent.DisableAlign;
try
CurResizeControl.Top := CurResizeControl.Top
+ (CurResizeControl.Height - NewSize);
CurResizeControl.Height := NewSize;
finally
Parent.EnableAlign;
end;
end;
NewBounds.Top := NewBounds.Bottom-NewSize;
end;
//DebugLn('SetAlignControlSize ',DbgSName(Self),' CurResizeControl=',DbgSName(CurResizeControl),' NewBounds=',dbgs(NewBounds));
CurResizeControl.BoundsRect:=NewBounds;
//DebugLn('SetAlignControlSize ',DbgSName(Self),' CurResizeControl=',DbgSName(CurResizeControl),' NowBounds=',dbgs(CurResizeControl.BoundsRect));
end;
function CalcNewSize(StartSize, EndSize, Offset: Integer): Integer;
@ -331,6 +320,7 @@ var
CurMaxShrink: integer;
CurMaxEnlarge: integer;
begin
//DebugLn('TCustomSplitter.MoveSplitter ',DbgSName(Self),' Offset=',dbgs(Offset));
if Offset = 0 then Exit;
if Align in [alLeft,alTop,alRight,alBottom] then begin
@ -384,6 +374,7 @@ begin
end;
end;
//DebugLn('TCustomSplitter.MoveSplitter ',DbgSName(Self),' StartSize=',dbgs(StartSize),' EndSize=',dbgs(EndSize),' Offset=',dbgs(Offset));
NewSize := CalcNewSize(StartSize, EndSize, Offset);
// OnCanResize event
@ -446,11 +437,17 @@ begin
end;
procedure TCustomSplitter.SetSplitterPosition(NewPosition: integer);
begin
//DebugLn('TCustomSplitter.SetSplitterPosition ',DbgSName(Self),' NewPosition=',dbgs(NewPosition),' ',dbgs(GetSplitterPosition));
MoveSplitter(NewPosition-GetSplitterPosition);
end;
function TCustomSplitter.GetSplitterPosition: integer;
begin
if ResizeAnchor in [akLeft,akRight] then
MoveSplitter(NewPosition-Left)
Result:=Left
else
MoveSplitter(NewPosition-Top);
Result:=Top;
end;
procedure TCustomSplitter.SetBeveled(const AValue: boolean);