File: baseideintf.pas

package info (click to toggle)
lazarus 4.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 275,760 kB
  • sloc: pascal: 2,341,904; xml: 509,420; makefile: 348,726; cpp: 93,608; sh: 3,387; java: 609; perl: 297; sql: 222; ansic: 137
file content (109 lines) | stat: -rw-r--r-- 3,340 bytes parent folder | download
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
101
102
103
104
105
106
107
108
109
{ Copyright (C) 2004

 *****************************************************************************
  See the file COPYING.modifiedLGPL.txt, included in this distribution,
  for details about the license.
 *****************************************************************************

  Author: Mattias Gaertner

  Abstract: Base classes of the IDEIntf.
}
unit BaseIDEIntf;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils,
  // LazUtils
  LazUTF8, LazConfigStorage, AvgLvlTree,
  // BuildIntf
  MacroIntf;
  
type
  TScanModeFPCSources = (
    smsfsSkip,
    smsfsWaitTillDone, // scan now and wait till finished
    smsfsBackground    // start in background
    );

  // new filename flags
  // Normally you don't need to pass any flags.
  TSearchIDEFileFlag = (
    siffDoNotCheckAllPackages, // do not search filename in unrelated packages (e.g. installed but not used by project)
    siffCheckAllProjects, // search filename in all loaded projects
    siffCaseSensitive,  // check case sensitive, otherwise use Pascal case insensitivity (CompareText)
    siffDoNotCheckOpenFiles,  // do not search in files opened in source editor
    siffIgnoreExtension  // compare only filename, ignore file extension
    );
  TSearchIDEFileFlags = set of TSearchIDEFileFlag;

  TLazBuildingFinishedEvent = procedure(Sender: TObject; BuildSuccessful: Boolean) of object;
  TLazLoadSaveCustomDataEvent = procedure(Sender: TObject; Load: boolean;
    CustomData: TStringToStringTree; // on save this is a temporary clone free for altering
    PathDelimChanged: boolean
    ) of object;

  TGetIDEConfigStorage = function(const Filename: string; LoadFromDisk: Boolean
                                  ): TConfigStorage;

var
  // will be set by the IDE
  DefaultConfigClass: TConfigStorageClass = nil;
  GetIDEConfigStorage: TGetIDEConfigStorage = nil; // load errors: raises exceptions

function EnvironmentAsStringList: TStringList;
procedure AssignEnvironmentTo(DestStrings, Overrides: TStrings);

implementation

function EnvironmentAsStringList: TStringList;
var
  i, SysVarCount, e: integer;
  Variable, Value: string;
Begin
  Result:=TStringList.Create;
  SysVarCount:=GetEnvironmentVariableCount;
  for i:=0 to SysVarCount-1 do begin
    Variable:=GetEnvironmentStringUTF8(i+1);
    // On windows some (hidden) environment variables can be returned by
    // GetEnvironmentStringUTF8. These kind of variables start with a =
    if (length(Variable)>0) and (Variable[1]<>'=') then begin
      e:=1;
      while (e<=length(Variable)) and (Variable[e]<>'=') do inc(e);
      Value:=copy(Variable,e+1,length(Variable)-e);
      Variable:=LeftStr(Variable,e-1);
      Result.Values[Variable]:=Value;
    end;
  end;
end;

procedure AssignEnvironmentTo(DestStrings, Overrides: TStrings);
var
  EnvList: TStringList;
  i: integer;
  Variable, Value: string;
begin
  // get system environment
  EnvList:=EnvironmentAsStringList;
  try
    if Overrides<>nil then begin
      // merge overrides
      for i:=0 to Overrides.Count-1 do begin
        Variable:=Overrides.Names[i];
        Value:=Overrides.Values[Variable];
        if Assigned(IDEMacros) then
          IDEMacros.SubstituteMacros(Value);
        EnvList.Values[Variable]:=Value;
      end;
    end;
    DestStrings.Assign(EnvList);
  finally
    EnvList.Free;
  end;
end;

end.