Menu

[327ada]: / Source / Macros.pas  Maximize  Restore  History

Download this file

102 lines (83 with data), 3.5 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
{
This file is part of Dev-C++
Copyright (c) 2004 Bloodshed Software
Dev-C++ is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Dev-C++ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Dev-C++; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}
unit Macros;
interface
uses
SysUtils, devCfg, Version;
function ParseMacros(Str: String): String;
implementation
uses
Main, editor, Dialogs, Utils, Classes;
procedure Replace(var Str: String; Old, New: String);
begin
Str := StringReplace(Str, Old, New, [rfReplaceAll]);
end;
function ParseMacros(Str: String): String;
var
e: TEditor;
begin
Result := Str;
e := MainForm.EditorList.GetEditor;
Replace(Result, '<DEFAULT>', devDirs.Default);
Replace(Result, '<DEVCPP>', ExtractFileDir(ParamStr(0)));
Replace(Result, '<DEVCPPVERSION>', DEVCPP_VERSION);
Replace(Result, '<EXECPATH>', devDirs.Exec);
Replace(Result, '<DATE>', DateToStr(Now));
Replace(Result, '<DATETIME>', DateTimeToStr(Now));
// Only provide the first cpp dir
with devCompilerSets.CompilationSet do begin
if Assigned(devCompilerSets.CompilationSet) and (CppDir.Count > 0) then
Replace(Result, '<INCLUDE>', CppDir[0])
else
Replace(Result, '<INCLUDE>', '');
// Only provide the first lib dir
if Assigned(devCompilerSets.CompilationSet) and (LibDir.Count > 0) then
Replace(Result, '<LIB>', LibDir[0])
else
Replace(Result, '<LIB>', '');
end;
// Project-dependent macros
if Assigned(MainForm.Project) then begin
Replace(Result, '<EXENAME>', MainForm.Project.Executable);
Replace(Result, '<PROJECTNAME>', MainForm.Project.Name);
Replace(Result, '<PROJECTFILE>', MainForm.Project.FileName);
Replace(Result, '<PROJECTPATH>', MainForm.Project.Directory);
Replace(Result, '<SOURCESPCLIST>', MainForm.Project.ListUnitStr(' '));
end else if Assigned(e) then begin // Non-project editor macros
Replace(Result, '<EXENAME>', '"' + ChangeFileExt(e.FileName, EXE_EXT) + '"');
Replace(Result, '<PROJECTNAME>', e.FileName);
Replace(Result, '<PROJECTFILE>', e.FileName);
Replace(Result, '<PROJECTPATH>', ExtractFilePath(e.FileName));
Replace(Result, '<SOURCESPCLIST>', ''); // clear unchanged macros
end else begin // clear unchanged macros
Replace(Result, '<EXENAME>', '');
Replace(Result, '<PROJECTNAME>', '');
Replace(Result, '<PROJECTFILE>', '');
Replace(Result, '<PROJECTPATH>', '');
Replace(Result, '<SOURCESPCLIST>', '');
end;
// Editor macros
if Assigned(e) then begin
Replace(Result, '<SOURCENAME>', e.FileName);
Replace(Result, '<SOURCENAME>', ExtractFilePath(e.FileName));
Replace(Result, '<WORDXY>', e.Text.WordAtCursor);
end else begin // clear unchanged macros
Replace(Result, '<SOURCENAME>', '');
Replace(Result, '<SOURCENAME>', '');
Replace(Result, '<WORDXY>', '');
end;
end;
end.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.