This repository has been archived by the owner on Oct 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usettings.pas
80 lines (63 loc) · 3.07 KB
/
usettings.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
unit uSettings;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, SynEditHighlighter, SynHighlighterAny, jsonConf, uMain, SynEdit, uKerboscriptHighlighter;
procedure ReadSettings(Highlighter: TKerboscriptHighlighter; MainForm: TfrmMain);
var
Settings: TJSONConfig;
implementation
uses Graphics, Forms;
procedure WriteHighlighterSection(Section: string; Attributes: TLazSynCustomTextAttributes);
begin
Settings.OpenKey('editor/highlighter/' + Section, True);
Settings.SetValue('background', Attributes.Background);
Settings.SetValue('foreground', Attributes.Foreground);
Settings.SetValue('style', longint(Attributes.Style));
Settings.CloseKey;
end;
function ReadHighlighterSection(Section: string; DefaultValues: TSynHighlighterAttributes): TSynHighlighterAttributes;
begin
Result := TSynHighlighterAttributes.Create('', '');
Settings.OpenKey('editor/highlighter/' + Section, True);
Result.Foreground := Settings.GetValue('foreground', DefaultValues.Foreground);
Result.Background := Settings.GetValue('background', DefaultValues.Background);
Result.Style := TFontStyles(Settings.GetValue('style', longint(DefaultValues.Style)));
Settings.CloseKey;
end;
procedure ReadSettings(Highlighter: TKerboscriptHighlighter; MainForm: TfrmMain);
var Used: string;
begin
//Syntax highlighting
Used := Settings.GetValue('highlighters/inuse', 'Saturn');
Highlighter.LoadFromJSON(Settings, Used);
Settings.OpenKey('editor/highlighter/matchedbracket', True);
MainForm.seHidden.BracketMatchColor.Foreground :=
Settings.GetValue('foreground', MainForm.seHidden.BracketMatchColor.Foreground);
MainForm.seHidden.BracketMatchColor.Background :=
Settings.GetValue('background', MainForm.seHidden.BracketMatchColor.Background);
MainForm.seHidden.BracketMatchColor.Style :=
TFontStyles(Settings.GetValue('style', longint(MainForm.seHidden.BracketMatchColor.Style)));
Settings.CloseKey;
MainForm.seHidden.Font.Name := Settings.GetValue('editor/font/name', MainForm.seHidden.Font.Name);
MainForm.seHidden.Font.Size := Settings.GetValue('editor/font/size', MainForm.seHidden.Font.Size);
MainForm.seHidden.Font.Quality := TFontQuality(Settings.GetValue('editor/font/quality', ord(MainForm.seHidden.Font.Quality)));
MainForm.seHidden.ExtraCharSpacing := Settings.GetValue('editor/font/charsep', 0);
MainForm.seHidden.Color := Settings.GetValue('editor/highlighter/whitespace', MainForm.seHidden.Color);
if Settings.GetValue('window/maximized', False) or Settings.GetValue('window/ismaximized', False) then
MainForm.WindowState := wsMaximized
else
begin
MainForm.Left := Settings.GetValue('window/x', (Screen.Width - 800) div 2);
MainForm.Top := Settings.GetValue('window/y', (Screen.Height - 600) div 2);
MainForm.Width := Settings.GetValue('window/width', 800);
MainForm.Height := Settings.GetValue('window/height', 600);
end;
end;
initialization
Settings := TJSONConfig.Create(nil);
Settings.Filename := 'Saturn.cfg';
finalization
Settings.Flush;
Settings.Free;
end.