summaryrefslogtreecommitdiff
path: root/examples/apps
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2013-03-13 00:55:56 +0000
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2013-03-13 00:55:56 +0000
commit00970a7e27253d10bb1cb0d6bace0b4c3a91ba1e (patch)
tree7dd4a86ebeac5fb4fef62913bc8e37396eb64e66 /examples/apps
parent1bc6eb96c5a6e37032b672f091f3a72a37163aaa (diff)
downloadfpGUI-00970a7e27253d10bb1cb0d6bace0b4c3a91ba1e.tar.xz
ide: when a project is loaded, project macros are merged with ide macros
Diffstat (limited to 'examples/apps')
-rw-r--r--examples/apps/ide/src/ideconst.pas2
-rw-r--r--examples/apps/ide/src/project.pas25
2 files changed, 27 insertions, 0 deletions
diff --git a/examples/apps/ide/src/ideconst.pas b/examples/apps/ide/src/ideconst.pas
index 3570bcbf..03c43ec4 100644
--- a/examples/apps/ide/src/ideconst.pas
+++ b/examples/apps/ide/src/ideconst.pas
@@ -26,6 +26,8 @@ const
// Predefined Macros
+ cMacroPrefix = '${';
+ cMacroSuffix = '}';
cMacro_FPCSrcDir = '${FPCSRCDIR}';
cMacro_FPGuiDir = '${FPGUIDIR}';
cMacro_FPGuiLibDir = '${FPGUILIBDIR}';
diff --git a/examples/apps/ide/src/project.pas b/examples/apps/ide/src/project.pas
index f31e724f..1aa740aa 100644
--- a/examples/apps/ide/src/project.pas
+++ b/examples/apps/ide/src/project.pas
@@ -25,6 +25,7 @@ type
FMakeOptions: TStringList;
FMacroNames: TStringList;
FUnitOutputDir: TfpgString;
+ procedure MergeWithGlobalMacros;
public
constructor Create;
destructor Destroy; override;
@@ -33,6 +34,7 @@ type
function GenerateCmdLine(const AShowOnly: Boolean = False; const ABuildMode: integer = -1): TfpgString;
procedure ClearAndInitMakeOptions(const ASize: integer);
procedure ClearAndInitUnitDirsGrid(const ASize: integer);
+ procedure ClearAndInitMacrosGrid(const ASize: integer);
property ProjectDir: TfpgString read FProjectDir write FProjectDir;
property ProjectName: TfpgString read FProjectName write FProjectName;
property MainUnit: TfpgString read FMainUnit write FMainUnit;
@@ -60,6 +62,7 @@ uses
ideconst
,ideutils
,fpg_utils
+ ,idemacros
;
@@ -82,6 +85,20 @@ end;
{ TProject }
+procedure TProject.MergeWithGlobalMacros;
+var
+ o: TIDEMacro;
+ i: integer;
+ n,v: TfpgString;
+begin
+ for i := 0 to MacroNames.Count-1 do
+ begin
+ MacroNames.GetNameValue(i, n, v);
+ o := TIDEMacro.Create(cMacroPrefix + n + cMacroSuffix, v, '');
+ GMacroList.Add(o);
+ end;
+end;
+
constructor TProject.Create;
begin
inherited Create;
@@ -264,6 +281,9 @@ begin
// Load Macro definitions
LoadList(cProjectOptions, MacroNames, 'MacroCount', 'Macro');
+ if MacroNames.Count > 0 then
+ GMacroList.ResetToDefaults;
+ MergeWithGlobalMacros;
// Load Unit search dirs
LoadList(cProjectOptions, UnitDirs, 'UnitDirsCount', 'UnitDir');
@@ -357,6 +377,11 @@ begin
SetLength(FUnitDirsGrid, 10, ASize); // 10 columns by X rows
end;
+procedure TProject.ClearAndInitMacrosGrid(const ASize: integer);
+begin
+ FMacroNames.Clear;
+end;
+
initialization
uProject := nil;