-
Notifications
You must be signed in to change notification settings - Fork 0
/
MemoHighlight.pas
125 lines (105 loc) · 2.9 KB
/
MemoHighlight.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
115
116
117
118
119
120
121
122
123
124
125
Unit MemoHighlight;
Interface
Uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, SynEdit, SynMemo, Vcl.Buttons, System.IniFiles,
Projects, Highlighters;
Type
TfmMemoHighlight = Class(TForm)
sbOK: TSpeedButton;
sbCancel: TSpeedButton;
smMemo: TSynMemo;
Procedure sbCancelClick(Sender: TObject);
Procedure sbOKClick(Sender: TObject);
Procedure FormCloseQuery(Sender: TObject; Var CanClose: Boolean);
Constructor Create(AOwner: TComponent; AConfigPath: String); Reintroduce; Overload;
Procedure FormShow(Sender: TObject);
Private
ConfigPath: String;
End;
Var
fmMemoHighlight: TfmMemoHighlight;
Procedure SetSynMemoHighlighter(ASynMemo: TSynMemo;
AHighlighter: TProjectSynMemoHighlighter);
Implementation
{$R *.dfm}
Procedure SetSynMemoHighlighter(ASynMemo: TSynMemo;
AHighlighter: TProjectSynMemoHighlighter);
Begin
With dmHighlighters Do
Begin
Case AHighlighter Of
psmhCNET:
ASynMemo.Highlighter := shCSS;
psmhC:
ASynMemo.Highlighter := shCPP;
psmhHTML:
ASynMemo.Highlighter := shHTML;
psmhINI:
ASynMemo.Highlighter := shINI;
psmhInnoSetupScript:
ASynMemo.Highlighter := shINNO;
psmhJava:
ASynMemo.Highlighter := shJAVA;
psmhJavaScript:
ASynMemo.Highlighter := shJSCRIPT;
psmhObjectPascal:
ASynMemo.Highlighter := shPAS;
psmhPerl:
ASynMemo.Highlighter := shPERL;
psmhPHP:
ASynMemo.Highlighter := shPHP;
psmhSQL:
ASynMemo.Highlighter := shSQL;
psmhUNIXShellScript:
ASynMemo.Highlighter := shUNIX;
Else
ASynMemo.Highlighter := Nil;
End;
End;
End;
{ TfmMemoHighlight }
Constructor TfmMemoHighlight.Create(AOwner: TComponent; AConfigPath: String);
Begin
Inherited Create(AOwner);
ConfigPath := AConfigPath;
End;
Procedure TfmMemoHighlight.FormCloseQuery(Sender: TObject;
Var CanClose: Boolean);
Begin
With TMemIniFile.Create(ConfigPath) Do
Try
EraseSection(Name);
If WindowState = TWindowState.WsNormal Then
Begin
WriteInteger(Name, 'Width', Width);
WriteInteger(Name, 'Height', Height);
WriteInteger(Name, 'Left', Left);
WriteInteger(Name, 'Top', Top);
End;
UpdateFile;
Finally
Free;
End;
End;
Procedure TfmMemoHighlight.FormShow(Sender: TObject);
Begin
With TMemIniFile.Create(ConfigPath) Do
Try
Width := ReadInteger(Name, 'Width', Width);
Height := ReadInteger(Name, 'Height', Height);
Left := ReadInteger(Name, 'Left', Left);
Top := ReadInteger(Name, 'Top', Top);
Finally
Free;
End;
End;
Procedure TfmMemoHighlight.sbCancelClick(Sender: TObject);
Begin
ModalResult := mrCancel;
End;
Procedure TfmMemoHighlight.sbOKClick(Sender: TObject);
Begin
ModalResult := mrOk;
End;
End.