forked from oliverhermanni/XC-Edit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.pas
115 lines (96 loc) · 2.71 KB
/
options.pas
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
110
111
112
113
114
unit options;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
EditBtn, ComCtrls, INIFiles;
type
{ TFormOptions }
TFormOptions = class(TForm)
ButtonCancel: TButton;
ButtonOk: TButton;
EditEmulatorParams: TEdit;
fneEmulatorLocation: TFileNameEdit;
fneMainCompiler: TFileNameEdit;
fneTestCompiler: TFileNameEdit;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
ListBoxTabs: TListBox;
PageControl: TPageControl;
Panel1: TPanel;
Panel2: TPanel;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
procedure ButtonCancelClick(Sender: TObject);
procedure ButtonOkClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure ListBoxTabsClick(Sender: TObject);
private
public
procedure ReadIniFile;
procedure SaveIniFile;
end;
var
FormOptions: TFormOptions;
implementation
{$R *.lfm}
{ TFormOptions }
procedure TFormOptions.FormShow(Sender: TObject);
var t: integer;
begin
ListBoxTabs.Items.Clear;
for t := 0 to PageControl.PageCount-1 do
begin
ListBoxTabs.AddItem(PageControl.Pages[t].Caption, PageControl.Pages[t]);
end;
ListBoxTabs.ItemIndex:=0;
PageControl.PageIndex:=0;
PageControl.ShowTabs := false;
ReadIniFile;
end;
procedure TFormOptions.ButtonCancelClick(Sender: TObject);
begin
FormOptions.Close;
end;
procedure TFormOptions.ButtonOkClick(Sender: TObject);
begin
SaveIniFile;
FormOptions.Close;
end;
procedure TFormOptions.ListBoxTabsClick(Sender: TObject);
begin
PageControl.PageIndex:= ListBoxTabs.ItemIndex;
end;
procedure TFormOptions.ReadIniFile;
var Ini: TIniFile;
begin
Ini := TIniFile.Create(GetAppConfigFile(false));
with FormOptions do begin
// Compiler settings
fneMainCompiler.FileName:= Ini.ReadString('XCBASIC', 'MainCompiler', '');
fneTestCompiler.FileName:= Ini.ReadString('XCBASIC', 'TestCompiler', '');
// Emulator settings
fneEmulatorLocation.Filename:= Ini.ReadString('Emulator', 'Location', '');
EditEmulatorParams.Text:= Ini.ReadString('Emulator','Params', '%prg');
end;
end;
procedure TFormOptions.SaveIniFile;
var Ini: TIniFile;
begin
Ini := TIniFile.Create(GetAppConfigFile(false));
With Ini do begin
// Compiler settings
WriteString('XCBASIC', 'MainCompiler', FormOptions.fneMainCompiler.FileName);
WriteString('XCBASIC', 'TestCompiler', FormOptions.fneTestCompiler.FileName);
// Emulator settings
WriteString('Emulator', 'Location', FormOptions.fneEmulatorLocation.Filename);
WriteString('Emulator', 'Params', FormOptions.EditEmulatorParams.Text);
end;
end;
end.