~ubuntu-branches/ubuntu/dapper/fpc/dapper

« back to all changes in this revision

Viewing changes to utils/fpdoc/fpde/fpdeopts.pp

  • Committer: Bazaar Package Importer
  • Author(s): Carlos Laviola
  • Date: 2004-08-12 16:29:37 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040812162937-moo8ulvysp1ln771
Tags: 1.9.4-5
fp-compiler: needs ld, adding dependency on binutils.  (Closes: #265265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{$mode objfpc}
 
2
{$H+}
 
3
unit fpdeopts;
 
4
 
 
5
Interface
 
6
 
 
7
uses SysUtils,IniFiles;
 
8
 
 
9
Var
 
10
  SkipEmptyNodes   : Boolean;  
 
11
  ConfirmDelete    : Boolean;
 
12
  CreateBackup     : Boolean;
 
13
  MaxRecentUsed    : Integer;
 
14
  BackupExtension  : String;  
 
15
  DefaultExtension : String;
 
16
 
 
17
Procedure LoadOptions;
 
18
Procedure SaveOptions;
 
19
Function  GetOptionFileName : String;
 
20
 
 
21
Implementation
 
22
 
 
23
Const
 
24
  DefFilename         = 'fpde.ini';
 
25
  SecPrefs            = 'Preferences';
 
26
  KeySkipEmptyNodes   = 'SkipEmptyNodes';
 
27
  KeyConfirmDelete    = 'ConfirmDelete';
 
28
  KeyCreateBackup     = 'CreateBackup';
 
29
  KeyBackupExtension  = 'BackupExtension';  
 
30
  KeyDefaultExtension = 'DefaultExtension';
 
31
  KeyMaxRecentUsed    = 'MaxMRUitems';
 
32
  
 
33
{$ifndef win32}
 
34
Function GetOptionFileName : String;
 
35
 
 
36
Const
 
37
  fpdedir = '.fpde';
 
38
 
 
39
Var
 
40
  HomeDir : String;
 
41
 
 
42
begin
 
43
  HomeDir:=GetEnvironmentVariable('HOME');
 
44
  If (HomeDir<>'') then
 
45
    begin
 
46
    HomeDir:=IncludeTrailingPathDelimiter(HomeDir)+fpdedir;
 
47
    If not DirectoryExists(HomeDir) then
 
48
      If Not CreateDir(HomeDir) then
 
49
        HomeDir:=''
 
50
      else
 
51
        HomeDir:=HomeDir;  
 
52
    end;
 
53
  Result:=IncludeTrailingPathDelimiter(HomeDir)+DefFileName;
 
54
end;
 
55
 
 
56
{$else}
 
57
 
 
58
Function GetOptionFileName : String;
 
59
 
 
60
begin
 
61
  Result:=ExtractFilePath(Paramstr(0))+DefFileName;  
 
62
end;
 
63
{$endif}
 
64
 
 
65
Procedure LoadOptions;
 
66
 
 
67
begin
 
68
  With TInifile.Create(GetOptionFileName) do
 
69
    Try
 
70
      SkipEmptyNodes:=ReadBool(SecPrefs,KeySkipEmptyNodes,SkipEmptyNodes);
 
71
      ConfirmDelete:=ReadBool(SecPrefs,KeyConfirmDelete,ConfirmDelete);
 
72
      CreateBackup:=ReadBool(SecPrefs,KeyCreateBackup,CreateBackup);
 
73
      BackupExtension:=ReadString(SecPrefs,KeyBackupExtension,BackupExtension);
 
74
      DefaultExtension:=ReadString(SecPrefs,KeyDefaultExtension,DefaultExtension);
 
75
    finally
 
76
      Free;
 
77
    end;
 
78
end;
 
79
 
 
80
Procedure SaveOptions;
 
81
 
 
82
begin
 
83
  With TInifile.Create(GetOptionFileName) do
 
84
    Try
 
85
      WriteBool(SecPrefs,KeySkipEmptyNodes,SkipEmptyNodes);
 
86
      WriteBool(SecPrefs,KeyConfirmDelete,ConfirmDelete);
 
87
      WriteBool(SecPrefs,KeyCreateBackup,CreateBackup);
 
88
      WriteString(SecPrefs,KeyBackupExtension,BackupExtension);
 
89
      WriteString(SecPrefs,KeyDefaultExtension,DefaultExtension);
 
90
      UpdateFile;
 
91
    finally
 
92
      Free;
 
93
    end;
 
94
end;
 
95
 
 
96
Initialization
 
97
  SkipEmptyNodes   := True;
 
98
  ConfirmDelete    := True;
 
99
  CreateBackup     := True;
 
100
  BackupExtension  := '.~xml';
 
101
  DefaultExtension := '.xml';
 
102
  MaxRecentUSed    := 10;
 
103
end.