Line Filter
Check-in [283cb61474]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Source as released by Merijn
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1: 283cb6147461f5710ad58de5e24d209745143029
User & Date: tinus 2013-02-21 22:50:19.052
Context
2013-02-21
22:50
Source as released by Merijn Leaf check-in: 283cb61474 user: tinus tags: trunk
22:23
initial empty check-in check-in: 96906f7016 user: tinus tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Added src/AdvancedSearch.dfm.










































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
object FormAdvancedSearch: TFormAdvancedSearch
  Left = 0
  Top = 0
  BorderStyle = bsToolWindow
  Caption = 'advanced search'
  ClientHeight = 546
  ClientWidth = 338
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  FormStyle = fsStayOnTop
  OldCreateOrder = False
  Position = poScreenCenter
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object ButtonOK: TButton
    Left = 260
    Top = 513
    Width = 75
    Height = 25
    Caption = 'OK'
    Default = True
    ModalResult = 1
    TabOrder = 0
  end
  object ButtonCancel: TButton
    Left = 176
    Top = 513
    Width = 75
    Height = 25
    Cancel = True
    Caption = 'Cancel'
    ModalResult = 2
    TabOrder = 1
    OnClick = ButtonCancelClick
  end
  object GroupBoxIncludes: TGroupBox
    AlignWithMargins = True
    Left = 3
    Top = 3
    Width = 332
    Height = 153
    Align = alTop
    Caption = ' lines include '
    TabOrder = 2
    object MemoInclude: TMemo
      AlignWithMargins = True
      Left = 5
      Top = 18
      Width = 322
      Height = 130
      Align = alClient
      BevelInner = bvNone
      BevelOuter = bvNone
      BorderStyle = bsNone
      Color = clWhite
      TabOrder = 0
    end
  end
  object GroupBoxNoInclude: TGroupBox
    AlignWithMargins = True
    Left = 3
    Top = 162
    Width = 332
    Height = 153
    Align = alTop
    Caption = ' lines do not include '
    TabOrder = 3
    object MemoNoInclude: TMemo
      AlignWithMargins = True
      Left = 5
      Top = 18
      Width = 322
      Height = 130
      Align = alClient
      BevelInner = bvNone
      BevelOuter = bvNone
      BorderStyle = bsNone
      Color = clWhite
      TabOrder = 0
    end
  end
  object PanelOutput: TPanel
    Left = 0
    Top = 414
    Width = 338
    Height = 83
    Align = alTop
    BevelOuter = bvNone
    TabOrder = 4
    object Label1: TLabel
      Left = 8
      Top = 13
      Width = 36
      Height = 13
      Caption = 'output:'
    end
    object RadioButtonOutputToCurrent: TRadioButton
      Left = 18
      Top = 33
      Width = 233
      Height = 17
      Caption = 'current file (hide/show lines)'
      Checked = True
      TabOrder = 0
      TabStop = True
    end
    object RadioButtonOutputToNew: TRadioButton
      Left = 18
      Top = 50
      Width = 233
      Height = 17
      Caption = 'new file'
      TabOrder = 1
    end
  end
  object PanelSearch: TPanel
    Left = 0
    Top = 318
    Width = 338
    Height = 96
    Align = alTop
    BevelOuter = bvNone
    TabOrder = 5
    object Label2: TLabel
      Left = 8
      Top = 13
      Width = 36
      Height = 13
      Caption = 'search:'
    end
    object RadioButtonSearchLiteral: TRadioButton
      Left = 18
      Top = 33
      Width = 233
      Height = 17
      Caption = 'literal'
      Checked = True
      TabOrder = 0
      TabStop = True
    end
    object RadioButtonSearchExtended: TRadioButton
      Left = 18
      Top = 50
      Width = 83
      Height = 17
      Caption = 'extended'
      ParentShowHint = False
      ShowHint = False
      TabOrder = 1
    end
    object RadioButtonSearchRegex: TRadioButton
      Left = 18
      Top = 67
      Width = 119
      Height = 17
      Caption = 'regular expression'
      TabOrder = 2
    end
  end
end
Added src/AdvancedSearch.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
unit AdvancedSearch;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ToolTips;

type
  TFormAdvancedSearch = class(TForm)
    ButtonOK: TButton;
    ButtonCancel: TButton;
    GroupBoxIncludes: TGroupBox;
    MemoInclude: TMemo;
    GroupBoxNoInclude: TGroupBox;
    MemoNoInclude: TMemo;
    PanelOutput: TPanel;
    Label1: TLabel;
    RadioButtonOutputToCurrent: TRadioButton;
    RadioButtonOutputToNew: TRadioButton;
    PanelSearch: TPanel;
    Label2: TLabel;
    RadioButtonSearchLiteral: TRadioButton;
    RadioButtonSearchExtended: TRadioButton;
    RadioButtonSearchRegex: TRadioButton;
    procedure ButtonCancelClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
   fExtendedBalloon: TBalloonToolTipControl;
   fExtendedTooltip: TToolTip;
  public
    { Public declarations }
  end;

implementation



{$R *.dfm}

procedure TFormAdvancedSearch.ButtonCancelClick(Sender: TObject);
begin
 Close();
end;

procedure TFormAdvancedSearch.FormCreate(Sender: TObject);
begin
 fExtendedBalloon := TBalloonToolTipControl.Create(Self);
 fExtendedBalloon.Icon := ttiInfo;
 fExtendedBalloon.Title := 'extended search';
 fExtendedBalloon.InitialTime := 10;
 fExtendedBalloon.AutoPopTime := 10000;

 fExtendedTooltip := TToolTip.Create(RadioButtonSearchExtended);

 fExtendedTooltip.Text := #13#10 +
                          'extended search gives extra searching options:' + #13#10 +
                          #13#10 +
                          '  \t  tab character' + #13#10 +
                          '  \\  backslash' + #13#10 +
                          '  \Hxx  any hexidecimal character';

 fExtendedBalloon.Add(fExtendedTooltip);
end;

end.
Added src/NPP Plugin.bdsproj.






































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
<?xml version="1.0" encoding="utf-8"?>
<BorlandProject>
	<PersonalityInfo>
		<Option>
			<Option Name="Personality">Delphi.Personality</Option>
			<Option Name="ProjectType">VCLApplication</Option>
			<Option Name="Version">1.0</Option>
			<Option Name="GUID">{B53DE5B9-8379-4410-9A8C-6DDE6C18A441}</Option>
		</Option>
	</PersonalityInfo>
	<Delphi.Personality>
		<Source>
			<Source Name="MainSource">NPP Plugin.dpr</Source>
		</Source>
		<FileVersion>
			<FileVersion Name="Version">7.0</FileVersion>
		</FileVersion>
		<Compiler>
			<Compiler Name="A">8</Compiler>
			<Compiler Name="B">0</Compiler>
			<Compiler Name="C">0</Compiler>
			<Compiler Name="D">1</Compiler>
			<Compiler Name="E">0</Compiler>
			<Compiler Name="F">0</Compiler>
			<Compiler Name="G">1</Compiler>
			<Compiler Name="H">1</Compiler>
			<Compiler Name="I">1</Compiler>
			<Compiler Name="J">0</Compiler>
			<Compiler Name="K">0</Compiler>
			<Compiler Name="L">1</Compiler>
			<Compiler Name="M">0</Compiler>
			<Compiler Name="N">1</Compiler>
			<Compiler Name="O">0</Compiler>
			<Compiler Name="P">1</Compiler>
			<Compiler Name="Q">0</Compiler>
			<Compiler Name="R">0</Compiler>
			<Compiler Name="S">0</Compiler>
			<Compiler Name="T">0</Compiler>
			<Compiler Name="U">0</Compiler>
			<Compiler Name="V">1</Compiler>
			<Compiler Name="W">0</Compiler>
			<Compiler Name="X">1</Compiler>
			<Compiler Name="Y">2</Compiler>
			<Compiler Name="Z">1</Compiler>
			<Compiler Name="ShowHints">True</Compiler>
			<Compiler Name="ShowWarnings">True</Compiler>
			<Compiler Name="UnitAliases">WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;</Compiler>
			<Compiler Name="NamespacePrefix"></Compiler>
			<Compiler Name="GenerateDocumentation">False</Compiler>
			<Compiler Name="DefaultNamespace"></Compiler>
			<Compiler Name="SymbolDeprecated">False</Compiler>
			<Compiler Name="SymbolLibrary">True</Compiler>
			<Compiler Name="SymbolPlatform">True</Compiler>
			<Compiler Name="SymbolExperimental">True</Compiler>
			<Compiler Name="UnitLibrary">True</Compiler>
			<Compiler Name="UnitPlatform">True</Compiler>
			<Compiler Name="UnitDeprecated">True</Compiler>
			<Compiler Name="UnitExperimental">True</Compiler>
			<Compiler Name="HResultCompat">True</Compiler>
			<Compiler Name="HidingMember">True</Compiler>
			<Compiler Name="HiddenVirtual">True</Compiler>
			<Compiler Name="Garbage">True</Compiler>
			<Compiler Name="BoundsError">True</Compiler>
			<Compiler Name="ZeroNilCompat">True</Compiler>
			<Compiler Name="StringConstTruncated">True</Compiler>
			<Compiler Name="ForLoopVarVarPar">True</Compiler>
			<Compiler Name="TypedConstVarPar">True</Compiler>
			<Compiler Name="AsgToTypedConst">True</Compiler>
			<Compiler Name="CaseLabelRange">True</Compiler>
			<Compiler Name="ForVariable">True</Compiler>
			<Compiler Name="ConstructingAbstract">True</Compiler>
			<Compiler Name="ComparisonFalse">True</Compiler>
			<Compiler Name="ComparisonTrue">True</Compiler>
			<Compiler Name="ComparingSignedUnsigned">True</Compiler>
			<Compiler Name="CombiningSignedUnsigned">True</Compiler>
			<Compiler Name="UnsupportedConstruct">True</Compiler>
			<Compiler Name="FileOpen">True</Compiler>
			<Compiler Name="FileOpenUnitSrc">True</Compiler>
			<Compiler Name="BadGlobalSymbol">True</Compiler>
			<Compiler Name="DuplicateConstructorDestructor">True</Compiler>
			<Compiler Name="InvalidDirective">True</Compiler>
			<Compiler Name="PackageNoLink">True</Compiler>
			<Compiler Name="PackageThreadVar">True</Compiler>
			<Compiler Name="ImplicitImport">True</Compiler>
			<Compiler Name="HPPEMITIgnored">True</Compiler>
			<Compiler Name="NoRetVal">True</Compiler>
			<Compiler Name="UseBeforeDef">True</Compiler>
			<Compiler Name="ForLoopVarUndef">True</Compiler>
			<Compiler Name="UnitNameMismatch">True</Compiler>
			<Compiler Name="NoCFGFileFound">True</Compiler>
			<Compiler Name="ImplicitVariants">True</Compiler>
			<Compiler Name="UnicodeToLocale">True</Compiler>
			<Compiler Name="LocaleToUnicode">True</Compiler>
			<Compiler Name="ImagebaseMultiple">True</Compiler>
			<Compiler Name="SuspiciousTypecast">True</Compiler>
			<Compiler Name="PrivatePropAccessor">True</Compiler>
			<Compiler Name="UnsafeType">False</Compiler>
			<Compiler Name="UnsafeCode">False</Compiler>
			<Compiler Name="UnsafeCast">False</Compiler>
			<Compiler Name="OptionTruncated">True</Compiler>
			<Compiler Name="WideCharReduced">True</Compiler>
			<Compiler Name="DuplicatesIgnored">True</Compiler>
			<Compiler Name="UnitInitSeq">True</Compiler>
			<Compiler Name="LocalPInvoke">True</Compiler>
			<Compiler Name="MessageDirective">True</Compiler>
			<Compiler Name="CodePage"></Compiler>
		</Compiler>
		<Linker>
			<Linker Name="MapFile">3</Linker>
			<Linker Name="OutputObjs">0</Linker>
			<Linker Name="GenerateHpps">False</Linker>
			<Linker Name="ConsoleApp">1</Linker>
			<Linker Name="DebugInfo">False</Linker>
			<Linker Name="RemoteSymbols">False</Linker>
			<Linker Name="GenerateDRC">False</Linker>
			<Linker Name="MinStackSize">16384</Linker>
			<Linker Name="MaxStackSize">1048576</Linker>
			<Linker Name="ImageBase">4194304</Linker>
			<Linker Name="ExeDescription"></Linker>
		</Linker>
		<Directories>
			<Directories Name="OutputDir"></Directories>
			<Directories Name="UnitOutputDir"></Directories>
			<Directories Name="PackageDLLOutputDir"></Directories>
			<Directories Name="PackageDCPOutputDir"></Directories>
			<Directories Name="SearchPath">delphisci</Directories>
			<Directories Name="Packages">vclx;vcl;rtl;indy;dsnapcon;dsnap;dbrtl;vcldb;VclSmp;adortl;bdertl;vcldbx;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;dclOfficeXP</Directories>
			<Directories Name="Conditionals">EUREKALOG;EUREKALOG_VER6</Directories>
			<Directories Name="DebugSourceDirs"></Directories>
			<Directories Name="UsePackages">False</Directories>
		</Directories>
		<Parameters>
			<Parameters Name="RunParams"></Parameters>
			<Parameters Name="HostApplication">d:\apps\Notepad++\notepad++.exe</Parameters>
			<Parameters Name="Launcher"></Parameters>
			<Parameters Name="UseLauncher">False</Parameters>
			<Parameters Name="DebugCWD"></Parameters>
			<Parameters Name="Debug Symbols Search Path"></Parameters>
			<Parameters Name="LoadAllSymbols">True</Parameters>
			<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
		</Parameters>
		<Language>
			<Language Name="ActiveLang"></Language>
			<Language Name="ProjectLang">$00000000</Language>
			<Language Name="RootDir"></Language>
		</Language>
		<VersionInfo>
			<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
			<VersionInfo Name="AutoIncBuild">False</VersionInfo>
			<VersionInfo Name="MajorVer">2</VersionInfo>
			<VersionInfo Name="MinorVer">9</VersionInfo>
			<VersionInfo Name="Release">0</VersionInfo>
			<VersionInfo Name="Build">2</VersionInfo>
			<VersionInfo Name="Debug">False</VersionInfo>
			<VersionInfo Name="PreRelease">False</VersionInfo>
			<VersionInfo Name="Special">False</VersionInfo>
			<VersionInfo Name="Private">False</VersionInfo>
			<VersionInfo Name="DLL">False</VersionInfo>
			<VersionInfo Name="Locale">1033</VersionInfo>
			<VersionInfo Name="CodePage">1252</VersionInfo>
		</VersionInfo>
		<VersionInfoKeys>
			<VersionInfoKeys Name="CompanyName"></VersionInfoKeys>
			<VersionInfoKeys Name="FileDescription"></VersionInfoKeys>
			<VersionInfoKeys Name="FileVersion">2.9.0.2</VersionInfoKeys>
			<VersionInfoKeys Name="InternalName"></VersionInfoKeys>
			<VersionInfoKeys Name="LegalCopyright"></VersionInfoKeys>
			<VersionInfoKeys Name="LegalTrademarks"></VersionInfoKeys>
			<VersionInfoKeys Name="OriginalFilename"></VersionInfoKeys>
			<VersionInfoKeys Name="ProductName"></VersionInfoKeys>
			<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
			<VersionInfoKeys Name="Comments"></VersionInfoKeys>
		</VersionInfoKeys>
	</Delphi.Personality>
<!-- EurekaLog First Line
[Exception Log]
EurekaLog Version=6104
Activate=1
Activate Handle=1
Save Log File=1
Foreground Tab=0
Freeze Activate=0
Freeze Timeout=60
SMTP From=eurekalog@email.com
SMTP Host=
SMTP Port=25
SMTP UserID=
SMTP Password=
Append to Log=0
TerminateBtn Operation=1
Errors Number=32
Errors Terminate=3
Email Address=
Email Object=
Email Send Options=0
Output Path=
Encrypt Password=
AutoCloseDialogSecs=0
WebSendMode=0
SupportULR=
HTMLLayout Count=15
HTMLLine0="%3Chtml%3E"
HTMLLine1="  %3Chead%3E"
HTMLLine2="  %3C/head%3E"
HTMLLine3="  %3Cbody TopMargin=10 LeftMargin=10%3E"
HTMLLine4="    %3Ctable width="100%%" border="0"%3E"
HTMLLine5="      %3Ctr%3E"
HTMLLine6="        %3Ctd nowrap%3E"
HTMLLine7="          %3Cfont face="Lucida Console, Courier" size="2"%3E"
HTMLLine8="            %3C%%HTML_TAG%%%3E"
HTMLLine9="          %3C/font%3E"
HTMLLine10="        %3C/td%3E"
HTMLLine11="      %3C/tr%3E"
HTMLLine12="    %3C/table%3E"
HTMLLine13="  %3C/body%3E"
HTMLLine14="%3C/html%3E"
AutoCrashOperation=1
AutoCrashNumber=10
AutoCrashMinutes=1
WebURL=
WebUserID=
WebPassword=
WebPort=0
AttachedFiles=
ProxyURL=
ProxyUser=
ProxyPassword=
ProxyPort=8080
TrakerUser=
TrakerPassword=
TrakerAssignTo=
TrakerProject=
TrakerCategory=
TrakerTrialID=
ZipPassword=
PreBuildEvent=
PostSuccessfulBuildEvent=
PostFailureBuildEvent=
ExceptionDialogType=2
Count=0
EMail Message Line Count=0
loNoDuplicateErrors=0
loAppendReproduceText=0
loDeleteLogAtVersionChange=0
loAddComputerNameInLogFileName=0
loSaveModulesAndProcessesSections=1
loSaveAssemblerAndCPUSections=1
soAppStartDate=1
soAppName=1
soAppVersionNumber=1
soAppParameters=1
soAppCompilationDate=1
soAppUpTime=1
soExcDate=1
soExcAddress=1
soExcModuleName=1
soExcModuleVersion=1
soExcType=1
soExcMessage=1
soExcID=1
soExcCount=1
soExcStatus=1
soExcNote=1
soUserID=1
soUserName=1
soUserEmail=1
soUserPrivileges=1
soUserCompany=1
soActCtlsFormClass=1
soActCtlsFormText=1
soActCtlsControlClass=1
soActCtlsControlText=1
soCmpName=1
soCmpTotalMemory=1
soCmpFreeMemory=1
soCmpTotalDisk=1
soCmpFreeDisk=1
soCmpSysUpTime=1
soCmpProcessor=1
soCmpDisplayMode=1
soCmpDisplayDPI=1
soCmpVideoCard=1
soCmpPrinter=1
soOSType=1
soOSBuildN=1
soOSUpdate=1
soOSLanguage=1
soOSCharset=1
soNetIP=1
soNetSubmask=1
soNetGateway=1
soNetDNS1=1
soNetDNS2=1
soNetDHCP=1
soCustomData=1
sndShowSendDialog=1
sndShowSuccessFailureMsg=0
sndSendEntireLog=0
sndSendXMLLogCopy=0
sndSendScreenshot=0
sndUseOnlyActiveWindow=0
sndSendLastHTMLPage=1
sndSendInSeparatedThread=0
sndAddDateInFileName=0
sndAddComputerNameInFileName=0
edoSendErrorReportChecked=1
edoAttachScreenshotChecked=1
edoShowCopyToClipOption=1
edoShowDetailsButton=1
edoShowInDetailedMode=0
edoShowInTopMostMode=1
edoUseEurekaLogLookAndFeel=1
edoShowSendErrorReportOption=1
edoShowAttachScreenshotOption=1
edoShowCustomButton=0
csoShowDLLs=1
csoShowBPLs=1
csoShowBorlandThreads=1
csoShowWindowsThreads=1
csoDoNotStoreProcNames=0
boPauseBorlandThreads=1
boDoNotPauseMainThread=0
boPauseWindowsThreads=1
boUseMainModuleOptions=1
boCopyLogInCaseOfError=1
boSaveCompressedCopyInCaseOfError=0
boHandleSafeCallExceptions=0
boCallRTLExceptionEvent=0
boCatchHandledExceptions=0
loCatchLeaks=0
loGroupsSonLeaks=1
loHideBorlandLeaks=1
loFreeAllLeaks=1
loCatchLeaksExceptions=1
cfoReduceFileSize=1
cfoCheckFileCorruption=0
Count mtInformationMsgCaption=1
mtInformationMsgCaption0="Information."
Count mtQuestionMsgCaption=1
mtQuestionMsgCaption0="Question."
Count mtErrorMsgCaption=1
mtErrorMsgCaption0="Error."
Count mtDialog_Caption=1
mtDialog_Caption0="Error occurred"
Count mtDialog_ErrorMsgCaption=2
mtDialog_ErrorMsgCaption0="An error has occurred during program execution."
mtDialog_ErrorMsgCaption1="Please read the following information for further details."
Count mtDialog_GeneralCaption=1
mtDialog_GeneralCaption0="General"
Count mtDialog_GeneralHeader=1
mtDialog_GeneralHeader0="General Information"
Count mtDialog_CallStackCaption=1
mtDialog_CallStackCaption0="Call Stack"
Count mtDialog_CallStackHeader=1
mtDialog_CallStackHeader0="Call Stack Information"
Count mtDialog_ModulesCaption=1
mtDialog_ModulesCaption0="Modules"
Count mtDialog_ModulesHeader=1
mtDialog_ModulesHeader0="Modules Information"
Count mtDialog_ProcessesCaption=1
mtDialog_ProcessesCaption0="Processes"
Count mtDialog_ProcessesHeader=1
mtDialog_ProcessesHeader0="Processes Information"
Count mtDialog_AsmCaption=1
mtDialog_AsmCaption0="Assembler"
Count mtDialog_AsmHeader=1
mtDialog_AsmHeader0="Assembler Information"
Count mtDialog_CPUCaption=1
mtDialog_CPUCaption0="CPU"
Count mtDialog_CPUHeader=1
mtDialog_CPUHeader0="CPU Information"
Count mtDialog_OKButtonCaption=1
mtDialog_OKButtonCaption0="%26OK"
Count mtDialog_TerminateButtonCaption=1
mtDialog_TerminateButtonCaption0="%26Terminate"
Count mtDialog_RestartButtonCaption=1
mtDialog_RestartButtonCaption0="%26Restart"
Count mtDialog_DetailsButtonCaption=1
mtDialog_DetailsButtonCaption0="%26Details"
Count mtDialog_CustomButtonCaption=1
mtDialog_CustomButtonCaption0="%26Help"
Count mtDialog_SendMessage=1
mtDialog_SendMessage0="%26Send this error via Internet"
Count mtDialog_ScreenshotMessage=1
mtDialog_ScreenshotMessage0="%26Attach a Screenshot image"
Count mtDialog_CopyMessage=1
mtDialog_CopyMessage0="%26Copy to Clipboard"
Count mtDialog_SupportMessage=1
mtDialog_SupportMessage0="Go to the Support Page"
Count mtMSDialog_ErrorMsgCaption=1
mtMSDialog_ErrorMsgCaption0="The application has encountered a problem. We are sorry for the inconvenience."
Count mtMSDialog_RestartCaption=1
mtMSDialog_RestartCaption0="Restart application."
Count mtMSDialog_TerminateCaption=1
mtMSDialog_TerminateCaption0="Terminate application."
Count mtMSDialog_PleaseCaption=1
mtMSDialog_PleaseCaption0="Please tell us about this problem."
Count mtMSDialog_DescriptionCaption=1
mtMSDialog_DescriptionCaption0="We have created an error report that you can send to us. We will treat this report as confidential and anonymous."
Count mtMSDialog_SeeDetailsCaption=1
mtMSDialog_SeeDetailsCaption0="To see what data the error report contains,"
Count mtMSDialog_SeeClickCaption=1
mtMSDialog_SeeClickCaption0="click here."
Count mtMSDialog_HowToReproduceCaption=1
mtMSDialog_HowToReproduceCaption0="What were you doing when the problem happended (optional)?"
Count mtMSDialog_EmailCaption=1
mtMSDialog_EmailCaption0="Email address (optional):"
Count mtMSDialog_SendButtonCaption=1
mtMSDialog_SendButtonCaption0="%26Send Error Report"
Count mtMSDialog_NoSendButtonCaption=1
mtMSDialog_NoSendButtonCaption0="%26Don't Send"
Count mtLog_AppHeader=1
mtLog_AppHeader0="Application"
Count mtLog_AppStartDate=1
mtLog_AppStartDate0="Start Date"
Count mtLog_AppName=1
mtLog_AppName0="Name/Description"
Count mtLog_AppVersionNumber=1
mtLog_AppVersionNumber0="Version Number"
Count mtLog_AppParameters=1
mtLog_AppParameters0="Parameters"
Count mtLog_AppCompilationDate=1
mtLog_AppCompilationDate0="Compilation Date"
Count mtLog_AppUpTime=1
mtLog_AppUpTime0="Up Time"
Count mtLog_ExcHeader=1
mtLog_ExcHeader0="Exception"
Count mtLog_ExcDate=1
mtLog_ExcDate0="Date"
Count mtLog_ExcAddress=1
mtLog_ExcAddress0="Address"
Count mtLog_ExcModuleName=1
mtLog_ExcModuleName0="Module Name"
Count mtLog_ExcModuleVersion=1
mtLog_ExcModuleVersion0="Module Version"
Count mtLog_ExcType=1
mtLog_ExcType0="Type"
Count mtLog_ExcMessage=1
mtLog_ExcMessage0="Message"
Count mtLog_ExcID=1
mtLog_ExcID0="ID"
Count mtLog_ExcCount=1
mtLog_ExcCount0="Count"
Count mtLog_ExcStatus=1
mtLog_ExcStatus0="Status"
Count mtLog_ExcNote=1
mtLog_ExcNote0="Note"
Count mtLog_UserHeader=1
mtLog_UserHeader0="User"
Count mtLog_UserID=1
mtLog_UserID0="ID"
Count mtLog_UserName=1
mtLog_UserName0="Name"
Count mtLog_UserEmail=1
mtLog_UserEmail0="Email"
Count mtLog_UserCompany=1
mtLog_UserCompany0="Company"
Count mtLog_UserPrivileges=1
mtLog_UserPrivileges0="Privileges"
Count mtLog_ActCtrlsHeader=1
mtLog_ActCtrlsHeader0="Active Controls"
Count mtLog_ActCtrlsFormClass=1
mtLog_ActCtrlsFormClass0="Form Class"
Count mtLog_ActCtrlsFormText=1
mtLog_ActCtrlsFormText0="Form Text"
Count mtLog_ActCtrlsControlClass=1
mtLog_ActCtrlsControlClass0="Control Class"
Count mtLog_ActCtrlsControlText=1
mtLog_ActCtrlsControlText0="Control Text"
Count mtLog_CmpHeader=1
mtLog_CmpHeader0="Computer"
Count mtLog_CmpName=1
mtLog_CmpName0="Name"
Count mtLog_CmpTotalMemory=1
mtLog_CmpTotalMemory0="Total Memory"
Count mtLog_CmpFreeMemory=1
mtLog_CmpFreeMemory0="Free Memory"
Count mtLog_CmpTotalDisk=1
mtLog_CmpTotalDisk0="Total Disk"
Count mtLog_CmpFreeDisk=1
mtLog_CmpFreeDisk0="Free Disk"
Count mtLog_CmpSystemUpTime=1
mtLog_CmpSystemUpTime0="System Up Time"
Count mtLog_CmpProcessor=1
mtLog_CmpProcessor0="Processor"
Count mtLog_CmpDisplayMode=1
mtLog_CmpDisplayMode0="Display Mode"
Count mtLog_CmpDisplayDPI=1
mtLog_CmpDisplayDPI0="Display DPI"
Count mtLog_CmpVideoCard=1
mtLog_CmpVideoCard0="Video Card"
Count mtLog_CmpPrinter=1
mtLog_CmpPrinter0="Printer"
Count mtLog_OSHeader=1
mtLog_OSHeader0="Operating System"
Count mtLog_OSType=1
mtLog_OSType0="Type"
Count mtLog_OSBuildN=1
mtLog_OSBuildN0="Build #"
Count mtLog_OSUpdate=1
mtLog_OSUpdate0="Update"
Count mtLog_OSLanguage=1
mtLog_OSLanguage0="Language"
Count mtLog_OSCharset=1
mtLog_OSCharset0="Charset"
Count mtLog_NetHeader=1
mtLog_NetHeader0="Network"
Count mtLog_NetIP=1
mtLog_NetIP0="IP Address"
Count mtLog_NetSubmask=1
mtLog_NetSubmask0="Submask"
Count mtLog_NetGateway=1
mtLog_NetGateway0="Gateway"
Count mtLog_NetDNS1=1
mtLog_NetDNS10="DNS 1"
Count mtLog_NetDNS2=1
mtLog_NetDNS20="DNS 2"
Count mtLog_NetDHCP=1
mtLog_NetDHCP0="DHCP"
Count mtLog_CustInfoHeader=1
mtLog_CustInfoHeader0="Custom Information"
Count mtCallStack_Address=1
mtCallStack_Address0="Address"
Count mtCallStack_Name=1
mtCallStack_Name0="Module"
Count mtCallStack_Unit=1
mtCallStack_Unit0="Unit"
Count mtCallStack_Class=1
mtCallStack_Class0="Class"
Count mtCallStack_Procedure=1
mtCallStack_Procedure0="Procedure/Method"
Count mtCallStack_Line=1
mtCallStack_Line0="Line"
Count mtCallStack_MainThread=1
mtCallStack_MainThread0="Main"
Count mtCallStack_ExceptionThread=1
mtCallStack_ExceptionThread0="Exception Thread"
Count mtCallStack_RunningThread=1
mtCallStack_RunningThread0="Running Thread"
Count mtCallStack_CallingThread=1
mtCallStack_CallingThread0="Calling Thread"
Count mtCallStack_ThreadID=1
mtCallStack_ThreadID0="ID"
Count mtCallStack_ThreadPriority=1
mtCallStack_ThreadPriority0="Priority"
Count mtCallStack_ThreadClass=1
mtCallStack_ThreadClass0="Class"
Count mtCallStack_LeakCaption=1
mtCallStack_LeakCaption0="Memory Leak"
Count mtCallStack_LeakData=1
mtCallStack_LeakData0="Data"
Count mtCallStack_LeakType=1
mtCallStack_LeakType0="Type"
Count mtCallStack_LeakSize=1
mtCallStack_LeakSize0="Total size"
Count mtCallStack_LeakCount=1
mtCallStack_LeakCount0="Count"
Count mtSendDialog_Caption=1
mtSendDialog_Caption0="Send."
Count mtSendDialog_Message=1
mtSendDialog_Message0="Message"
Count mtSendDialog_Resolving=1
mtSendDialog_Resolving0="Resolving DNS..."
Count mtSendDialog_Login=1
mtSendDialog_Login0="Login..."
Count mtSendDialog_Connecting=1
mtSendDialog_Connecting0="Connecting with server..."
Count mtSendDialog_Connected=1
mtSendDialog_Connected0="Connected with server."
Count mtSendDialog_Sending=1
mtSendDialog_Sending0="Sending message..."
Count mtSendDialog_Sent=1
mtSendDialog_Sent0="Message sent."
Count mtSendDialog_SelectProject=1
mtSendDialog_SelectProject0="Select project..."
Count mtSendDialog_Searching=1
mtSendDialog_Searching0="Searching..."
Count mtSendDialog_Modifying=1
mtSendDialog_Modifying0="Modifying..."
Count mtSendDialog_Disconnecting=1
mtSendDialog_Disconnecting0="Disconnecting..."
Count mtSendDialog_Disconnected=1
mtSendDialog_Disconnected0="Disconnected."
Count mtReproduceDialog_Caption=1
mtReproduceDialog_Caption0="Request"
Count mtReproduceDialog_Request=1
mtReproduceDialog_Request0="Please describe the steps to reproduce the error:"
Count mtReproduceDialog_OKButtonCaption=1
mtReproduceDialog_OKButtonCaption0="%26OK"
Count mtModules_Handle=1
mtModules_Handle0="Handle"
Count mtModules_Name=1
mtModules_Name0="Name"
Count mtModules_Description=1
mtModules_Description0="Description"
Count mtModules_Version=1
mtModules_Version0="Version"
Count mtModules_Size=1
mtModules_Size0="Size"
Count mtModules_LastModified=1
mtModules_LastModified0="Modified"
Count mtModules_Path=1
mtModules_Path0="Path"
Count mtProcesses_ID=1
mtProcesses_ID0="ID"
Count mtProcesses_Name=1
mtProcesses_Name0="Name"
Count mtProcesses_Description=1
mtProcesses_Description0="Description"
Count mtProcesses_Version=1
mtProcesses_Version0="Version"
Count mtProcesses_Memory=1
mtProcesses_Memory0="Memory"
Count mtProcesses_Priority=1
mtProcesses_Priority0="Priority"
Count mtProcesses_Threads=1
mtProcesses_Threads0="Threads"
Count mtProcesses_Path=1
mtProcesses_Path0="Path"
Count mtCPU_Registers=1
mtCPU_Registers0="Registers"
Count mtCPU_Stack=1
mtCPU_Stack0="Stack"
Count mtCPU_MemoryDump=1
mtCPU_MemoryDump0="Memory Dump"
Count mtSend_SuccessMsg=1
mtSend_SuccessMsg0="The message was sent successfully."
Count mtSend_FailureMsg=1
mtSend_FailureMsg0="Sorry, sending the message didn't work."
Count mtSend_BugClosedMsg=2
mtSend_BugClosedMsg0="These BUG is just closed."
mtSend_BugClosedMsg1="Contact the program support to obtain an update."
Count mtSend_UnknownErrorMsg=1
mtSend_UnknownErrorMsg0="Unknown error."
Count mtSend_InvalidLoginMsg=1
mtSend_InvalidLoginMsg0="Invalid login request."
Count mtSend_InvalidSearchMsg=1
mtSend_InvalidSearchMsg0="Invalid search request."
Count mtSend_InvalidSelectionMsg=1
mtSend_InvalidSelectionMsg0="Invalid selection request."
Count mtSend_InvalidInsertMsg=1
mtSend_InvalidInsertMsg0="Invalid insert request."
Count mtSend_InvalidModifyMsg=1
mtSend_InvalidModifyMsg0="Invalid modify request."
Count mtFileCrackedMsg=2
mtFileCrackedMsg0="This file is cracked."
mtFileCrackedMsg1="The application will be closed."
Count mtException_LeakMultiFree=1
mtException_LeakMultiFree0="Multi Free memory leak."
Count mtException_LeakMemoryOverrun=1
mtException_LeakMemoryOverrun0="Memory Overrun leak."
Count mtException_AntiFreeze=1
mtException_AntiFreeze0="The application seems to be frozen."
Count mtInvalidEmailMsg=1
mtInvalidEmailMsg0="Invalid email."
TextsCollection=
cfoUseEL7=0
EurekaLog Last Line -->
</BorlandProject>
Added src/NPP Plugin.cfg.


























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
-$A8
-$B-
-$C-
-$D+
-$E-
-$F-
-$G+
-$H+
-$I+
-$J-
-$K-
-$L+
-$M-
-$N+
-$O-
-$P+
-$Q-
-$R-
-$S-
-$T-
-$U-
-$V+
-$W-
-$X+
-$Y+
-$Z1
-GD
-cg
-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
-H+
-W+
-M
-$M16384,1048576
-K$00400000
-LE"C:\Users\Merijn\Documents\Borland Studio Projects\Bpl"
-LN"C:\Users\Merijn\Documents\Borland Studio Projects\Bpl"
-U"delphisci"
-O"delphisci"
-I"delphisci"
-R"delphisci"
-DEUREKALOG;EUREKALOG_VER6
-w-SYMBOL_DEPRECATED
-w-UNSAFE_TYPE
-w-UNSAFE_CODE
-w-UNSAFE_CAST
Added src/NPP Plugin.dpr.




































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
library DllEntry;

uses
  ExceptionLog,
  Forms,
  SysUtils,
  Windows,
  Dialogs,
  Controls,
  Classes,
  SCIInterface,
  Messages,
  QStrings,
  NPPInterface in 'NPPInterface.pas',
  Progress in 'Progress.pas' {FormProgress},
  AdvancedSearch in 'AdvancedSearch.pas' {FormAdvancedSearch};

type RNPPData = record
      _nppHandle: HWND;
      _scintillaMainHandle: HWND;
      _scintillaSecondHandle: HWND;
     end;

     TProc = procedure; cdecl;

     RFuncItem = record
      _itemName: array[0..63] of widechar;
      _pFunc: TProc;
      _cmdID: integer;
      _init2Check: integer;
      _PShKey: pointer;
     end;

     TFilterType = (ftKeep, ftRemove);

var NPPData: RNPPData;

    FuncItems: array of RFuncItem;

    fSCIInterface: TSCIInterface;
    fNPPInterface: TNPPInterface;
    fFormSearchParams: TFormAdvancedSearch;


procedure DoFilter(FilterType: TFilterType);
var i: integer;
    LineCount: integer;
    SubStrPos: integer;
    CurLine: string;
    SelText: string;
    FilteredData: string;
    Progress: TFormProgress;
begin
 Progress := nil;

 try
  SelText := fSCIInterface.SelText;

  if SelText <> '' then
  begin
   LineCount := fSCIInterface.LineCount;

   Progress := TFormProgress.Create(nil);
   Progress.Show();
   Progress.ProgressBar.Max := LineCount;

   for i := 0 to LineCount - 1 do
   begin
    CurLine := fSCIInterface.Line[i];

    SubStrPos := Q_PosStr(SelText, CurLine);

    if ((FilterType = ftKeep) and (SubStrPos > 0)) or ((FilterType = ftRemove) and (SubStrPos = 0)) then
     FilteredData := FilteredData + CurLine;

    Progress.Step();

    if Progress.Cancel then
     break;
   end;

   fNPPInterface.NewFile();
   fSCIInterface.AppendText(FilteredData);
  end;
 finally
  Progress.Free();
 end;
end;

function UnwrapExtended(Line: string): string;
// unwraps 'extended' search line to following scheme:
//
// \t    tab character
// \\    backslash
// \Hxx  any hexidecimal character
begin
 result := Line;
end;


type TSearchType = (stNormal, stExtended, stRegEx);
     TSearchOutput = (soCurFile, soNewFile);

{procedure DoAdvancedFilter(HasLines, HasNotLines: TStrings; SearchType: TSearchType; SearchOutput: TSearchOutput);
var i, j: integer;
    LineCount: integer;
    SubStrPos: integer;
    CurLine: string;
    MyHasLines, MyHasNotLines: TStringList;
    SelText: string;
    FilteredData: string;
    Progress: TFormProgress;
begin
 Progress := nil;

 MyHasLines := TStringList.Create();
 MyHasNotLines := TStringList.Create();

 try
  MyHasLines.Assign(HasLines);
  MyHasNotLines.Assign(HasNotLines);

  if SearchType = stExtended then
  begin
   for i := 0 to MyHasLines.Count  - 1 do
    MyHasLines[i] := UnWrapExtended(MyHasLines[i]);

   for i := 0 to MyHasNotLines.Count  - 1 do
    MyHasNotLines[i] := UnWrapExtended(MyHasNotLines[i]);
  end;


  SelText := fSCIInterface.SelText;

  if SelText <> '' then
  begin
   LineCount := fSCIInterface.LineCount;

   Progress := TFormProgress.Create(nil);
   Progress.Show();
   Progress.ProgressBar.Max := LineCount;

   for i := 0 to LineCount - 1 do
   begin
    CurLine := fSCIInterface.Line[i];

    SubStrPos := Q_PosStr(SelText, CurLine);

    if ((FilterType = ftKeep) and (SubStrPos > 0)) or ((FilterType = ftRemove) and (SubStrPos = 0)) then
     FilteredData := FilteredData + CurLine;

    Progress.Step();

    if Progress.Cancel then
     break;
   end;

   fNPPInterface.NewFile();
   fSCIInterface.AppendText(FilteredData);
  end;
 finally
  Progress.Free();
  MyHasLines.Free();
  MyHasNotLines.Free();
 end;
end;}

{procedure ShowFormSearchParams;
var SearchType: TSearchType;
    SearchOutput: TSearchOutput;
begin
 if not assigned(fFormSearchParams) then
 begin
  fFormSearchParams := TFormAdvancedSearch.Create(nil);
//  fFormSearchParams.ParentWindow := fNPPInterface.NPPHandle;
 end;

 if fFormSearchParams.ShowModal() = mrOK then
 begin
  if fFormSearchParams.RadioButtonSearchExtended.Checked then SearchType := stExtended else
  if fFormSearchParams.RadioButtonSearchRegex.Checked then    SearchType := stRegEx else
                                                              SearchType := stNormal;

  if fFormSearchParams.RadioButtonOutputToCurrent.Checked then SearchOutput := soCurFile else
                                                               SearchOutput := soNewFile;

  DoAdvancedFilter(fFormSearchParams.MemoInclude.Lines, fFormSearchParams.MemoNoInclude.Lines, SearchType, SearchOutput);
 end;
end;}

procedure CallbackKeep; cdecl;
begin
 DoFilter(ftKeep);
end;

procedure CallbackRemove; cdecl;
begin
 DoFilter(ftRemove);
end;

//procedure CallbackAdvanced; cdecl;
//begin
// ShowFormSearchParams();
// ShowMessage('not implemented yet');

//end;

procedure CallbackShowAllLines; cdecl;
begin
 fSCIInterface.ShowAllLines();
end;

procedure CreateMenuItems;

 procedure AddMenuItem(Callback: TProc; Name: widestring);
 var i: integer;
 begin
  Name := Copy(Name, 1, 64); // limit the string to 64 characters
  i := Length(FuncItems);
  SetLength(FuncItems, i + 1);

  ZeroMemory(@FuncItems[i], SizeOf(RFuncItem));
  FuncItems[i]._pFunc := Callback;
  CopyMemory(@FuncItems[i]._itemName[0], @Name[1], Length(Name) * SizeOf(WideChar));
  FuncItems[i]._cmdID := i;
 end;

begin
 SetLength(FuncItems, 0);

 AddMenuItem(CallbackKeep, '&Keep lines with selection');
 AddMenuItem(CallbackRemove, '&Remove lines with selection');
// AddMenuitem(callbackkeep, '-');
// AddMenuItem(CallbackAdvanced, '&Advanced');
// AddMenuItem(CallbackShowAllLines, 'Sho&w all lines');
end;

procedure UpdateMenu;
var hm: HMENU;
    i: integer;
begin
 // manipulate menu
 hm := GetMenu(NPPData._nppHandle);

 for i := 0 to Length(FuncItems) - 1 do
  if ansistring(FuncItems[i]._itemName) = '-' then
   ModifyMenu(hm, FuncItems[i]._CmdID, MF_BYCOMMAND or MF_SEPARATOR, 0, nil);
end;

procedure DLLEntryPoint(dwReason: DWord);
begin
 case dwReason of
  DLL_PROCESS_ATTACH:
   begin
    CreateMenuItems();

    fSCIInterface := TSCIInterface.Create();
    fNPPInterface := TNPPInterface.Create();

    fFormSearchParams := nil;
   end;

  DLL_PROCESS_DETACH:
   begin
    fSCIInterface.Free();
    fNPPInterface.Free();

    fFormSearchParams.Free();
   end;
 end;
end;

procedure setInfo(NotePadPlusData: RNPPData); cdecl; // Needs struct nppdata
begin
 NPPData := NotePadPlusData;
 fNPPInterface.NPPHandle := NPPData._nppHandle;
 fSCIInterface.SCIHandle := NPPData._scintillaMainHandle;
end;

function getName: PWChar; cdecl;
begin
 Result := '&Line filter';
end;

function getFuncsArray(var nFuncs: integer): Pointer; cdecl;
begin
 nFuncs := Length(FuncItems);
 result := FuncItems;
end;

procedure beNotified; cdecl;
begin
end;

function messageProc(p1, p2: integer; p3: pointer): integer; cdecl;
begin
 if p1 = WM_CREATE then
  UpdateMenu();

 Result := 0;
end;

function isUnicode: boolean; cdecl;
begin
 result := true;
end;

exports
 isUnicode,
 setInfo,
 getName,
 getFuncsArray,
 beNotified,
 messageProc;
begin
 { First, assign the procedure to the DLLProc variable }
 DllProc := @DLLEntryPoint;

 { Now invoke the procedure to reflect that the DLL is attaching to the process }
 DLLEntryPoint(DLL_PROCESS_ATTACH);
end.

Added src/NPP Plugin.drc.












































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
/* VER180
  Generated by the Borland Delphi Pascal Compiler
  because -GD or --drc was supplied to the compiler.

  This file contains compiler-generated resources that
  were bound to the executable.
  If this file is empty, then no compiler-generated
  resources were bound to the produced executable.
*/

#define Consts_SDockedCtlNeedsName 65312
#define Consts_SDockTreeRemoveError 65313
#define Consts_SDockZoneNotFound 65314
#define Consts_SDockZoneHasNoCtl 65315
#define Consts_SDockZoneVersionConflict 65316
#define Consts_SANSIEncoding 65317
#define Consts_SASCIIEncoding 65318
#define Consts_SUnicodeEncoding 65319
#define Consts_SBigEndianEncoding 65320
#define Consts_SUTF8Encoding 65321
#define Consts_SUTF7Encoding 65322
#define ToolTips_S_EId 65323
#define Consts_SmkcPgUp 65328
#define Consts_SmkcPgDn 65329
#define Consts_SmkcEnd 65330
#define Consts_SmkcHome 65331
#define Consts_SmkcLeft 65332
#define Consts_SmkcUp 65333
#define Consts_SmkcRight 65334
#define Consts_SmkcDown 65335
#define Consts_SmkcIns 65336
#define Consts_SmkcDel 65337
#define Consts_SmkcShift 65338
#define Consts_SmkcCtrl 65339
#define Consts_SmkcAlt 65340
#define Consts_SOutOfRange 65341
#define Consts_SIconToClipboard 65342
#define Consts_SDuplicateMenus 65343
#define Consts_SMsgDlgYes 65344
#define Consts_SMsgDlgNo 65345
#define Consts_SMsgDlgOK 65346
#define Consts_SMsgDlgCancel 65347
#define Consts_SMsgDlgHelp 65348
#define Consts_SMsgDlgAbort 65349
#define Consts_SMsgDlgRetry 65350
#define Consts_SMsgDlgIgnore 65351
#define Consts_SMsgDlgAll 65352
#define Consts_SMsgDlgNoToAll 65353
#define Consts_SMsgDlgYesToAll 65354
#define Consts_SmkcBkSp 65355
#define Consts_SmkcTab 65356
#define Consts_SmkcEsc 65357
#define Consts_SmkcEnter 65358
#define Consts_SmkcSpace 65359
#define Consts_SControlParentSetToSelf 65360
#define Consts_SOKButton 65361
#define Consts_SCancelButton 65362
#define Consts_SYesButton 65363
#define Consts_SNoButton 65364
#define Consts_SHelpButton 65365
#define Consts_SCloseButton 65366
#define Consts_SIgnoreButton 65367
#define Consts_SRetryButton 65368
#define Consts_SAbortButton 65369
#define Consts_SAllButton 65370
#define Consts_SCannotDragForm 65371
#define Consts_SMsgDlgWarning 65372
#define Consts_SMsgDlgError 65373
#define Consts_SMsgDlgInformation 65374
#define Consts_SMsgDlgConfirm 65375
#define Consts_SImageReadFail 65376
#define Consts_SImageWriteFail 65377
#define Consts_SWindowDCError 65378
#define Consts_SWindowClass 65379
#define Consts_SCannotFocus 65380
#define Consts_SParentRequired 65381
#define Consts_SMDIChildNotVisible 65382
#define Consts_SVisibleChanged 65383
#define Consts_SCannotShowModal 65384
#define Consts_SPropertyOutOfRange 65385
#define Consts_SMenuIndexError 65386
#define Consts_SMenuReinserted 65387
#define Consts_SMenuNotFound 65388
#define Consts_SNoTimers 65389
#define Consts_SGroupIndexTooLow 65390
#define Consts_SNoMDIForm 65391
#define RTLConsts_SThreadError 65392
#define HelpIntfs_hNoTableOfContents 65393
#define HelpIntfs_hNothingFound 65394
#define HelpIntfs_hNoContext 65395
#define HelpIntfs_hNoContextFound 65396
#define HelpIntfs_hNoTopics 65397
#define Consts_SInvalidBitmap 65398
#define Consts_SInvalidIcon 65399
#define Consts_SChangeIconSize 65400
#define Consts_SUnknownClipboardFormat 65401
#define Consts_SOutOfResources 65402
#define Consts_SNoCanvasHandle 65403
#define Consts_SInvalidImageSize 65404
#define Consts_SInvalidImageList 65405
#define Consts_SReplaceImage 65406
#define Consts_SImageIndexError 65407
#define RTLConsts_SInvalidRegType 65408
#define RTLConsts_SListCapacityError 65409
#define RTLConsts_SListCountError 65410
#define RTLConsts_SListIndexError 65411
#define RTLConsts_SMemoryStreamError 65412
#define RTLConsts_SPropertyException 65413
#define RTLConsts_SReadError 65414
#define RTLConsts_SReadOnlyProperty 65415
#define RTLConsts_SRegGetDataFailed 65416
#define RTLConsts_SResNotFound 65417
#define RTLConsts_SSeekNotImplemented 65418
#define RTLConsts_SSortedListError 65419
#define RTLConsts_SUnknownGroup 65420
#define RTLConsts_SUnknownProperty 65421
#define RTLConsts_SWriteError 65422
#define RTLConsts_SThreadCreateError 65423
#define RTLConsts_SAncestorNotFound 65424
#define RTLConsts_SAssignError 65425
#define RTLConsts_SBitsIndexError 65426
#define RTLConsts_SCantWriteResourceStreamError 65427
#define RTLConsts_SCheckSynchronizeError 65428
#define RTLConsts_SClassNotFound 65429
#define RTLConsts_SDuplicateClass 65430
#define RTLConsts_SDuplicateItem 65431
#define RTLConsts_SDuplicateName 65432
#define RTLConsts_SDuplicateString 65433
#define RTLConsts_SFCreateErrorEx 65434
#define RTLConsts_SFOpenErrorEx 65435
#define RTLConsts_SInvalidImage 65436
#define RTLConsts_SInvalidName 65437
#define RTLConsts_SInvalidPropertyPath 65438
#define RTLConsts_SInvalidPropertyValue 65439
#define SysConst_SLongMonthNameNov 65440
#define SysConst_SLongMonthNameDec 65441
#define SysConst_SShortDayNameSun 65442
#define SysConst_SShortDayNameMon 65443
#define SysConst_SShortDayNameTue 65444
#define SysConst_SShortDayNameWed 65445
#define SysConst_SShortDayNameThu 65446
#define SysConst_SShortDayNameFri 65447
#define SysConst_SShortDayNameSat 65448
#define SysConst_SLongDayNameSun 65449
#define SysConst_SLongDayNameMon 65450
#define SysConst_SLongDayNameTue 65451
#define SysConst_SLongDayNameWed 65452
#define SysConst_SLongDayNameThu 65453
#define SysConst_SLongDayNameFri 65454
#define SysConst_SLongDayNameSat 65455
#define SysConst_SShortMonthNameJul 65456
#define SysConst_SShortMonthNameAug 65457
#define SysConst_SShortMonthNameSep 65458
#define SysConst_SShortMonthNameOct 65459
#define SysConst_SShortMonthNameNov 65460
#define SysConst_SShortMonthNameDec 65461
#define SysConst_SLongMonthNameJan 65462
#define SysConst_SLongMonthNameFeb 65463
#define SysConst_SLongMonthNameMar 65464
#define SysConst_SLongMonthNameApr 65465
#define SysConst_SLongMonthNameMay 65466
#define SysConst_SLongMonthNameJun 65467
#define SysConst_SLongMonthNameJul 65468
#define SysConst_SLongMonthNameAug 65469
#define SysConst_SLongMonthNameSep 65470
#define SysConst_SLongMonthNameOct 65471
#define SysConst_SVarUnexpected 65472
#define SysConst_SExternalException 65473
#define SysConst_SAssertionFailed 65474
#define SysConst_SIntfCastError 65475
#define SysConst_SSafecallException 65476
#define SysConst_SAssertError 65477
#define SysConst_SAbstractError 65478
#define SysConst_SModuleAccessViolation 65479
#define SysConst_SOSError 65480
#define SysConst_SUnkOSError 65481
#define SysConst_SShortMonthNameJan 65482
#define SysConst_SShortMonthNameFeb 65483
#define SysConst_SShortMonthNameMar 65484
#define SysConst_SShortMonthNameApr 65485
#define SysConst_SShortMonthNameMay 65486
#define SysConst_SShortMonthNameJun 65487
#define SysConst_SDispatchError 65488
#define SysConst_SReadAccess 65489
#define SysConst_SWriteAccess 65490
#define SysConst_SFormatTooLong 65491
#define SysConst_SVarArrayCreate 65492
#define SysConst_SVarArrayBounds 65493
#define SysConst_SVarArrayLocked 65494
#define SysConst_SInvalidVarCast 65495
#define SysConst_SInvalidVarOp 65496
#define SysConst_SInvalidVarOpWithHResultWithPrefix 65497
#define SysConst_SVarTypeCouldNotConvert 65498
#define SysConst_SVarTypeConvertOverflow 65499
#define SysConst_SVarOverflow 65500
#define SysConst_SVarInvalid 65501
#define SysConst_SVarBadType 65502
#define SysConst_SVarNotImplemented 65503
#define SysConst_SInvalidOp 65504
#define SysConst_SZeroDivide 65505
#define SysConst_SOverflow 65506
#define SysConst_SUnderflow 65507
#define SysConst_SInvalidPointer 65508
#define SysConst_SInvalidCast 65509
#define SysConst_SAccessViolationArg3 65510
#define SysConst_SAccessViolationNoArg 65511
#define SysConst_SStackOverflow 65512
#define SysConst_SControlC 65513
#define SysConst_SPrivilege 65514
#define SysConst_SOperationAborted 65515
#define SysConst_SException 65516
#define SysConst_SExceptTitle 65517
#define SysConst_SInvalidFormat 65518
#define SysConst_SArgumentMissing 65519
#define SysConst_SInvalidInteger 65520
#define SysConst_SInvalidFloat 65521
#define SysConst_STimeEncodeError 65522
#define SysConst_SDateEncodeError 65523
#define SysConst_SOutOfMemory 65524
#define SysConst_SInOutError 65525
#define SysConst_SFileNotFound 65526
#define SysConst_SInvalidFilename 65527
#define SysConst_STooManyOpenFiles 65528
#define SysConst_SAccessDenied 65529
#define SysConst_SEndOfFile 65530
#define SysConst_SDiskFull 65531
#define SysConst_SInvalidInput 65532
#define SysConst_SDivByZero 65533
#define SysConst_SRangeError 65534
#define SysConst_SIntOverflow 65535
STRINGTABLE
BEGIN
	Consts_SDockedCtlNeedsName,	"Docked control must have a name"
	Consts_SDockTreeRemoveError,	"Error removing control from dock tree"
	Consts_SDockZoneNotFound,	" - Dock zone not found"
	Consts_SDockZoneHasNoCtl,	" - Dock zone has no control"
	Consts_SDockZoneVersionConflict,	"Error loading dock zone from the stream. Expecting version %d, but found %d."
	Consts_SANSIEncoding,	"ANSI"
	Consts_SASCIIEncoding,	"ASCII"
	Consts_SUnicodeEncoding,	"Unicode"
	Consts_SBigEndianEncoding,	"Big Endian Unicode"
	Consts_SUTF8Encoding,	"UTF-8"
	Consts_SUTF7Encoding,	"UTF-7"
	ToolTips_S_EId,	"Invalid tool id %d"
	Consts_SmkcPgUp,	"PgUp"
	Consts_SmkcPgDn,	"PgDn"
	Consts_SmkcEnd,	"End"
	Consts_SmkcHome,	"Home"
	Consts_SmkcLeft,	"Left"
	Consts_SmkcUp,	"Up"
	Consts_SmkcRight,	"Right"
	Consts_SmkcDown,	"Down"
	Consts_SmkcIns,	"Ins"
	Consts_SmkcDel,	"Del"
	Consts_SmkcShift,	"Shift+"
	Consts_SmkcCtrl,	"Ctrl+"
	Consts_SmkcAlt,	"Alt+"
	Consts_SOutOfRange,	"Value must be between %d and %d"
	Consts_SIconToClipboard,	"Clipboard does not support Icons"
	Consts_SDuplicateMenus,	"Menu '%s' is already being used by another form"
	Consts_SMsgDlgYes,	"&Yes"
	Consts_SMsgDlgNo,	"&No"
	Consts_SMsgDlgOK,	"OK"
	Consts_SMsgDlgCancel,	"Cancel"
	Consts_SMsgDlgHelp,	"&Help"
	Consts_SMsgDlgAbort,	"&Abort"
	Consts_SMsgDlgRetry,	"&Retry"
	Consts_SMsgDlgIgnore,	"&Ignore"
	Consts_SMsgDlgAll,	"&All"
	Consts_SMsgDlgNoToAll,	"N&o to All"
	Consts_SMsgDlgYesToAll,	"Yes to &All"
	Consts_SmkcBkSp,	"BkSp"
	Consts_SmkcTab,	"Tab"
	Consts_SmkcEsc,	"Esc"
	Consts_SmkcEnter,	"Enter"
	Consts_SmkcSpace,	"Space"
	Consts_SControlParentSetToSelf,	"A control cannot have itself as its parent"
	Consts_SOKButton,	"OK"
	Consts_SCancelButton,	"Cancel"
	Consts_SYesButton,	"&Yes"
	Consts_SNoButton,	"&No"
	Consts_SHelpButton,	"&Help"
	Consts_SCloseButton,	"&Close"
	Consts_SIgnoreButton,	"&Ignore"
	Consts_SRetryButton,	"&Retry"
	Consts_SAbortButton,	"Abort"
	Consts_SAllButton,	"&All"
	Consts_SCannotDragForm,	"Cannot drag a form"
	Consts_SMsgDlgWarning,	"Warning"
	Consts_SMsgDlgError,	"Error"
	Consts_SMsgDlgInformation,	"Information"
	Consts_SMsgDlgConfirm,	"Confirm"
	Consts_SImageReadFail,	"Failed to read ImageList data from stream"
	Consts_SImageWriteFail,	"Failed to write ImageList data to stream"
	Consts_SWindowDCError,	"Error creating window device context"
	Consts_SWindowClass,	"Error creating window class"
	Consts_SCannotFocus,	"Cannot focus a disabled or invisible window"
	Consts_SParentRequired,	"Control '%s' has no parent window"
	Consts_SMDIChildNotVisible,	"Cannot hide an MDI Child Form"
	Consts_SVisibleChanged,	"Cannot change Visible in OnShow or OnHide"
	Consts_SCannotShowModal,	"Cannot make a visible window modal"
	Consts_SPropertyOutOfRange,	"%s property out of range"
	Consts_SMenuIndexError,	"Menu index out of range"
	Consts_SMenuReinserted,	"Menu inserted twice"
	Consts_SMenuNotFound,	"Sub-menu is not in menu"
	Consts_SNoTimers,	"Not enough timers available"
	Consts_SGroupIndexTooLow,	"GroupIndex cannot be less than a previous menu item's GroupIndex"
	Consts_SNoMDIForm,	"Cannot create form. No MDI forms are currently active"
	RTLConsts_SThreadError,	"Thread Error: %s (%d)"
	HelpIntfs_hNoTableOfContents,	"Unable to find a Table of Contents"
	HelpIntfs_hNothingFound,	"No help found for %s"
	HelpIntfs_hNoContext,	"No context-sensitive help installed"
	HelpIntfs_hNoContextFound,	"No help found for context"
	HelpIntfs_hNoTopics,	"No topic-based help system installed"
	Consts_SInvalidBitmap,	"Bitmap image is not valid"
	Consts_SInvalidIcon,	"Icon image is not valid"
	Consts_SChangeIconSize,	"Cannot change the size of an icon"
	Consts_SUnknownClipboardFormat,	"Unsupported clipboard format"
	Consts_SOutOfResources,	"Out of system resources"
	Consts_SNoCanvasHandle,	"Canvas does not allow drawing"
	Consts_SInvalidImageSize,	"Invalid image size"
	Consts_SInvalidImageList,	"Invalid ImageList"
	Consts_SReplaceImage,	"Unable to Replace Image"
	Consts_SImageIndexError,	"Invalid ImageList Index"
	RTLConsts_SInvalidRegType,	"Invalid data type for '%s'"
	RTLConsts_SListCapacityError,	"List capacity out of bounds (%d)"
	RTLConsts_SListCountError,	"List count out of bounds (%d)"
	RTLConsts_SListIndexError,	"List index out of bounds (%d)"
	RTLConsts_SMemoryStreamError,	"Out of memory while expanding memory stream"
	RTLConsts_SPropertyException,	"Error reading %s%s%s: %s"
	RTLConsts_SReadError,	"Stream read error"
	RTLConsts_SReadOnlyProperty,	"Property is read-only"
	RTLConsts_SRegGetDataFailed,	"Failed to get data for '%s'"
	RTLConsts_SResNotFound,	"Resource %s not found"
	RTLConsts_SSeekNotImplemented,	"%s.Seek not implemented"
	RTLConsts_SSortedListError,	"Operation not allowed on sorted list"
	RTLConsts_SUnknownGroup,	"%s not in a class registration group"
	RTLConsts_SUnknownProperty,	"Property %s does not exist"
	RTLConsts_SWriteError,	"Stream write error"
	RTLConsts_SThreadCreateError,	"Thread creation error: %s"
	RTLConsts_SAncestorNotFound,	"Ancestor for '%s' not found"
	RTLConsts_SAssignError,	"Cannot assign a %s to a %s"
	RTLConsts_SBitsIndexError,	"Bits index out of range"
	RTLConsts_SCantWriteResourceStreamError,	"Can't write to a read-only resource stream"
	RTLConsts_SCheckSynchronizeError,	"CheckSynchronize called from thread $%x, which is NOT the main thread"
	RTLConsts_SClassNotFound,	"Class %s not found"
	RTLConsts_SDuplicateClass,	"A class named %s already exists"
	RTLConsts_SDuplicateItem,	"List does not allow duplicates ($0%x)"
	RTLConsts_SDuplicateName,	"A component named %s already exists"
	RTLConsts_SDuplicateString,	"String list does not allow duplicates"
	RTLConsts_SFCreateErrorEx,	"Cannot create file \"%s\". %s"
	RTLConsts_SFOpenErrorEx,	"Cannot open file \"%s\". %s"
	RTLConsts_SInvalidImage,	"Invalid stream format"
	RTLConsts_SInvalidName,	"''%s'' is not a valid component name"
	RTLConsts_SInvalidPropertyPath,	"Invalid property path"
	RTLConsts_SInvalidPropertyValue,	"Invalid property value"
	SysConst_SLongMonthNameNov,	"November"
	SysConst_SLongMonthNameDec,	"December"
	SysConst_SShortDayNameSun,	"Sun"
	SysConst_SShortDayNameMon,	"Mon"
	SysConst_SShortDayNameTue,	"Tue"
	SysConst_SShortDayNameWed,	"Wed"
	SysConst_SShortDayNameThu,	"Thu"
	SysConst_SShortDayNameFri,	"Fri"
	SysConst_SShortDayNameSat,	"Sat"
	SysConst_SLongDayNameSun,	"Sunday"
	SysConst_SLongDayNameMon,	"Monday"
	SysConst_SLongDayNameTue,	"Tuesday"
	SysConst_SLongDayNameWed,	"Wednesday"
	SysConst_SLongDayNameThu,	"Thursday"
	SysConst_SLongDayNameFri,	"Friday"
	SysConst_SLongDayNameSat,	"Saturday"
	SysConst_SShortMonthNameJul,	"Jul"
	SysConst_SShortMonthNameAug,	"Aug"
	SysConst_SShortMonthNameSep,	"Sep"
	SysConst_SShortMonthNameOct,	"Oct"
	SysConst_SShortMonthNameNov,	"Nov"
	SysConst_SShortMonthNameDec,	"Dec"
	SysConst_SLongMonthNameJan,	"January"
	SysConst_SLongMonthNameFeb,	"February"
	SysConst_SLongMonthNameMar,	"March"
	SysConst_SLongMonthNameApr,	"April"
	SysConst_SLongMonthNameMay,	"May"
	SysConst_SLongMonthNameJun,	"June"
	SysConst_SLongMonthNameJul,	"July"
	SysConst_SLongMonthNameAug,	"August"
	SysConst_SLongMonthNameSep,	"September"
	SysConst_SLongMonthNameOct,	"October"
	SysConst_SVarUnexpected,	"Unexpected variant error"
	SysConst_SExternalException,	"External exception %x"
	SysConst_SAssertionFailed,	"Assertion failed"
	SysConst_SIntfCastError,	"Interface not supported"
	SysConst_SSafecallException,	"Exception in safecall method"
	SysConst_SAssertError,	"%s (%s, line %d)"
	SysConst_SAbstractError,	"Abstract Error"
	SysConst_SModuleAccessViolation,	"Access violation at address %p in module '%s'. %s of address %p"
	SysConst_SOSError,	"System Error.  Code: %d.\r\n%s"
	SysConst_SUnkOSError,	"A call to an OS function failed"
	SysConst_SShortMonthNameJan,	"Jan"
	SysConst_SShortMonthNameFeb,	"Feb"
	SysConst_SShortMonthNameMar,	"Mar"
	SysConst_SShortMonthNameApr,	"Apr"
	SysConst_SShortMonthNameMay,	"May"
	SysConst_SShortMonthNameJun,	"Jun"
	SysConst_SDispatchError,	"Variant method calls not supported"
	SysConst_SReadAccess,	"Read"
	SysConst_SWriteAccess,	"Write"
	SysConst_SFormatTooLong,	"Format string too long"
	SysConst_SVarArrayCreate,	"Error creating variant or safe array"
	SysConst_SVarArrayBounds,	"Variant or safe array index out of bounds"
	SysConst_SVarArrayLocked,	"Variant or safe array is locked"
	SysConst_SInvalidVarCast,	"Invalid variant type conversion"
	SysConst_SInvalidVarOp,	"Invalid variant operation"
	SysConst_SInvalidVarOpWithHResultWithPrefix,	"Invalid variant operation (%s%.8x)\n%s"
	SysConst_SVarTypeCouldNotConvert,	"Could not convert variant of type (%s) into type (%s)"
	SysConst_SVarTypeConvertOverflow,	"Overflow while converting variant of type (%s) into type (%s)"
	SysConst_SVarOverflow,	"Variant overflow"
	SysConst_SVarInvalid,	"Invalid argument"
	SysConst_SVarBadType,	"Invalid variant type"
	SysConst_SVarNotImplemented,	"Operation not supported"
	SysConst_SInvalidOp,	"Invalid floating point operation"
	SysConst_SZeroDivide,	"Floating point division by zero"
	SysConst_SOverflow,	"Floating point overflow"
	SysConst_SUnderflow,	"Floating point underflow"
	SysConst_SInvalidPointer,	"Invalid pointer operation"
	SysConst_SInvalidCast,	"Invalid class typecast"
	SysConst_SAccessViolationArg3,	"Access violation at address %p. %s of address %p"
	SysConst_SAccessViolationNoArg,	"Access violation"
	SysConst_SStackOverflow,	"Stack overflow"
	SysConst_SControlC,	"Control-C hit"
	SysConst_SPrivilege,	"Privileged instruction"
	SysConst_SOperationAborted,	"Operation aborted"
	SysConst_SException,	"Exception %s in module %s at %p.\r\n%s%s\r\n"
	SysConst_SExceptTitle,	"Application Error"
	SysConst_SInvalidFormat,	"Format '%s' invalid or incompatible with argument"
	SysConst_SArgumentMissing,	"No argument for format '%s'"
	SysConst_SInvalidInteger,	"'%s' is not a valid integer value"
	SysConst_SInvalidFloat,	"'%s' is not a valid floating point value"
	SysConst_STimeEncodeError,	"Invalid argument to time encode"
	SysConst_SDateEncodeError,	"Invalid argument to date encode"
	SysConst_SOutOfMemory,	"Out of memory"
	SysConst_SInOutError,	"I/O error %d"
	SysConst_SFileNotFound,	"File not found"
	SysConst_SInvalidFilename,	"Invalid filename"
	SysConst_STooManyOpenFiles,	"Too many open files"
	SysConst_SAccessDenied,	"File access denied"
	SysConst_SEndOfFile,	"Read beyond end of file"
	SysConst_SDiskFull,	"Disk full"
	SysConst_SInvalidInput,	"Invalid numeric input"
	SysConst_SDivByZero,	"Division by zero"
	SysConst_SRangeError,	"Range check error"
	SysConst_SIntOverflow,	"Integer overflow"
END

Added src/NPPConsts.inc.


























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
const
//Here you can find how to use these messages : http://notepad-plus.sourceforge.net/uk/plugins-HOWTO.php
NPPMSG                                        = (WM_USER + 1000);

NPPM_GETCURRENTSCINTILLA                      = (NPPMSG + 4);
NPPM_GETCURRENTLANGTYPE                       = (NPPMSG + 5);
NPPM_SETCURRENTLANGTYPE                       = (NPPMSG + 6);

NPPM_GETNBOPENFILES                           =	(NPPMSG + 7);
ALL_OPEN_FILES                                =		0;
PRIMARY_VIEW                                  =		1;
SECOND_VIEW                                   =		2;

NPPM_GETOPENFILENAMES                         =	(NPPMSG + 8);


NPPM_MODELESSDIALOG                           = (NPPMSG + 12);
MODELESSDIALOGADD                             =		0;
MODELESSDIALOGREMOV                           = 	1;

NPPM_GETNBSESSIONFILES                        = (NPPMSG + 13);
NPPM_GETSESSIONFILES                          = (NPPMSG + 14);
NPPM_SAVESESSION                              = (NPPMSG + 15);
NPPM_SAVECURRENTSESSION                       = (NPPMSG + 16);

//		struct sessionInfo {
//			char* sessionFilePathName;
//			int nbFile;
//			char** files;
//		};

NPPM_GETOPENFILENAMESPRIMARY                  = (NPPMSG + 17);
NPPM_GETOPENFILENAMESSECOND                   = (NPPMSG + 18);
	
NPPM_CREATESCINTILLAHANDLE                    = (NPPMSG + 20);
NPPM_DESTROYSCINTILLAHANDLE                   = (NPPMSG + 21);
NPPM_GETNBUSERLANG                            = (NPPMSG + 22);

NPPM_GETCURRENTDOCINDEX                       = (NPPMSG + 23);
MAIN_VIEW                                     = 0;
SUB_VIEW                                      = 1;

NPPM_SETSTATUSBAR                             = (NPPMSG + 24);
STATUSBAR_DOC_TYPE                            = 0;
STATUSBAR_DOC_SIZE                            = 1;
STATUSBAR_CUR_POS                             = 2;
STATUSBAR_EOF_FORMAT                          = 3;
STATUSBAR_UNICODE_TYPE                        = 4;
STATUSBAR_TYPING_MODE                         = 5;

PPM_GETMENUHANDLE                             = (NPPMSG + 25);
NPPPLUGINMENU                                 = 0;

PPM_ENCODESCI                                 = (NPPMSG + 26);
	//ascii file to unicode
	//int NPPM_ENCODESCI(MAIN_VIEW/SUB_VIEW, 0)
	//return new unicodeMode
	
PPM_DECODESCI                                 = (NPPMSG + 27);
	//unicode file to ascii
	//int NPPM_DECODESCI(MAIN_VIEW/SUB_VIEW, 0)
	//return old unicodeMode

PPM_ACTIVATEDOC                               = (NPPMSG + 28);
	//void NPPM_ACTIVATEDOC(int index2Activate, int view)

PPM_LAUNCHFINDINFILESDLG                      = (NPPMSG + 29);
	//void NPPM_LAUNCHFINDINFILESDLG(char * dir2Search, char * filtre)

PPM_DMMSHOW                                   = (NPPMSG + 30);
PPM_DMMHIDE                                   =	(NPPMSG + 31);
PPM_DMMUPDATEDISPINFO                         = (NPPMSG + 32);
	//void NPPM_DMMxxx(0, tTbData->hClient)

PPM_DMMREGASDCKDLG                            = (NPPMSG + 33);
	//void NPPM_DMMREGASDCKDLG(0, &tTbData)

PPM_LOADSESSION                               = (NPPMSG + 34);
	//void NPPM_LOADSESSION(0, const char* file name)

PPM_DMMVIEWOTHERTAB                           = (NPPMSG + 35);
	//void WM_DMM_VIEWOTHERTAB(0, tTbData->hClient)

PPM_RELOADFILE                                = (NPPMSG + 36);
	//BOOL NPPM_RELOADFILE(BOOL withAlert, char *filePathName2Reload)

PPM_SWITCHTOFILE                              = (NPPMSG + 37);
	//BOOL NPPM_SWITCHTOFILE(0, char *filePathName2switch)

PPM_SAVECURRENTFILE                           = (NPPMSG + 38);
	//BOOL WM_SWITCHTOFILE(0, 0)

PPM_SAVEALLFILES                              =	(NPPMSG + 39);
	//BOOL NPPM_SAVEALLFILES(0, 0)

PPM_SETMENUITEMCHECK                          =	(NPPMSG + 40);
	//void WM_PIMENU_CHECK(UINT	funcItem[X]._cmdID, TRUE/FALSE)

PPM_ADDTOOLBARICON                            = (NPPMSG + 41);
	//void WM_ADDTOOLBARICON(UINT funcItem[X]._cmdID, toolbarIcons icon)
//		struct toolbarIcons {
//			HBITMAP	hToolbarBmp;
//			HICON	hToolbarIcon;
//		};

PPM_GETWINDOWSVERSION                         = (NPPMSG + 42);
	//winVer NPPM_GETWINDOWSVERSION(0, 0)

PPM_DMMGETPLUGINHWNDBYNAME                    = (NPPMSG + 43);
	//HWND WM_DMM_GETPLUGINHWNDBYNAME(const char *windowName, const char *moduleName)
	// if moduleName is NULL, then return value is NULL
	// if windowName is NULL, then the first found window handle which matches with the moduleName will be returned
	
PPM_MAKECURRENTBUFFERDIRTY                    = (NPPMSG + 44);
	//BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0)

PPM_GETENABLETHEMETEXTUREFUNC                 = (NPPMSG + 45);
	//BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0)

PPM_GETPLUGINSCONFIGDIR                       = (NPPMSG + 46);
	//void NPPM_GETPLUGINSCONFIGDIR(int strLen, char *str)

VAR_NOT_RECOGNIZED                            = 0;
FULL_CURRENT_PATH                             = 1;
CURRENT_DIRECTORY                             = 2;
FILE_NAME                                     = 3;
NAME_PART                                     = 4;
EXT_PART                                      = 5;
CURRENT_WORD                                  = 6;
NPP_DIRECTORY                                 = 7;

RUNCOMMAND_USER                                = (WM_USER + 3000);
NPPM_GETFULLCURRENTPATH                        =	(RUNCOMMAND_USER + FULL_CURRENT_PATH);
NPPM_GETCURRENTDIRECTORY                       =	(RUNCOMMAND_USER + CURRENT_DIRECTORY);
NPPM_GETFILENAME                               =	(RUNCOMMAND_USER + FILE_NAME);
NPPM_GETNAMEPART                               =	(RUNCOMMAND_USER + NAME_PART);
NPPM_GETEXTPART                                =	(RUNCOMMAND_USER + EXT_PART);
NPPM_GETCURRENTWORD                            =	(RUNCOMMAND_USER + CURRENT_WORD);
NPPM_GETNPPDIRECTORY                           =	(RUNCOMMAND_USER + NPP_DIRECTORY);

// Notification code
NPPN_FIRST                                    = 1000;
NPPN_READY                                    = (NPPN_FIRST + 1); // To notify plugins that all the procedures of launchment of notepad++ are done.
NPPN_TBMODIFICATION                           = (NPPN_FIRST + 2); // To notify plugins that toolbar icons can be registered
NPPN_FILEBEFORECLOSE                          = (NPPN_FIRST + 3); // To notify plugins that the current file is about to be closed
NPPN_FILEOPENED                               = (NPPN_FIRST + 4); // To notify plugins that the current file is just opened
NPPN_FILECLOSED                               = (NPPN_FIRST + 5); // To notify plugins that the current file is just closed
NPPN_FILEBEFOREOPEN                           = (NPPN_FIRST + 6); // To notify plugins that the current file is about to be opened
NPPN_FILEBEFORESAVE                           = (NPPN_FIRST + 7); // To notify plugins that the current file is about to be saved
NPPN_FILESAVED                                = (NPPN_FIRST + 8); // To notify plugins that the current file is just saved
NPPN_SHUTDOWN                                 = (NPPN_FIRST + 9); // To notify plugins that Notepad++ is about to be shutdowned.

 IDI_M30ICON                                  = 100;
 IDR_MENU1                                    = 101;
 IDR_ACCELERATOR1                             = 102;
 IDR_RT_MANIFEST                              = 103;

 IDI_NEW_OFF_ICON                             = 201;
 IDI_OPEN_OFF_ICON                            = 202;
 IDI_CLOSE_OFF_ICON                           = 203;
 IDI_CLOSEALL_OFF_ICON                        = 204;
 IDI_SAVE_OFF_ICON                            = 205;
 IDI_SAVEALL_OFF_ICON                         = 206;
 IDI_CUT_OFF_ICON                             = 207;   
 IDI_COPY_OFF_ICON                            = 208;   
 IDI_PASTE_OFF_ICON                           = 209;   
 IDI_UNDO_OFF_ICON                            = 210;
 IDI_REDO_OFF_ICON                            = 211;   
 IDI_FIND_OFF_ICON                            = 212;   
 IDI_REPLACE_OFF_ICON                         = 213;
 IDI_ZOOMIN_OFF_ICON                          = 214;
 IDI_ZOOMOUT_OFF_ICON                         = 215;
 IDI_VIEW_UD_DLG_OFF_ICON                     = 216;
 IDI_PRINT_OFF_ICON                           = 217;
 IDI_VIEW_ALL_CHAR_ON_ICON                    = 218;
 IDI_VIEW_INDENT_ON_ICON                      = 219;
 IDI_VIEW_WRAP_ON_ICON                        = 220;

 IDI_STARTRECORD_OFF_ICON                     = 221;
 IDI_STARTRECORD_ON_ICON                      = 222;
 IDI_STARTRECORD_DISABLE_ICON                 = 223;
 IDI_STOPRECORD_OFF_ICON                      = 224;
 IDI_STOPRECORD_ON_ICON                       = 225;
 IDI_STOPRECORD_DISABLE_ICON                  = 226;
 IDI_PLAYRECORD_OFF_ICON                      = 227;
 IDI_PLAYRECORD_ON_ICON                       = 228;
 IDI_PLAYRECORD_DISABLE_ICON                  = 229;
 IDI_SAVERECORD_OFF_ICON                      = 230;
 IDI_SAVERECORD_ON_ICON                       = 231;
 IDI_SAVERECORD_DISABLE_ICON                  = 232;

// multi run macro
 IDI_MMPLAY_DIS_ICON                          = 233;
 IDI_MMPLAY_OFF_ICON                          = 234;
 IDI_MMPLAY_ON_ICON                           = 235;

 IDI_NEW_ON_ICON                              = 301;
 IDI_OPEN_ON_ICON                             = 302;
 IDI_CLOSE_ON_ICON                            = 303;
 IDI_CLOSEALL_ON_ICON                         = 304;
 IDI_SAVE_ON_ICON                             = 305;
 IDI_SAVEALL_ON_ICON                          = 306;
 IDI_CUT_ON_ICON                              = 307;
 IDI_COPY_ON_ICON                             = 308;
 IDI_PASTE_ON_ICON                            = 309;
 IDI_UNDO_ON_ICON                             = 310;
 IDI_REDO_ON_ICON                             = 311;
 IDI_FIND_ON_ICON                             = 312;
 IDI_REPLACE_ON_ICON                          = 313;
 IDI_ZOOMIN_ON_ICON                           = 314;
 IDI_ZOOMOUT_ON_ICON                          = 315;
 IDI_VIEW_UD_DLG_ON_ICON                      = 316;
 IDI_PRINT_ON_ICON                            = 317;
 IDI_VIEW_ALL_CHAR_OFF_ICON                   = 318;
 IDI_VIEW_INDENT_OFF_ICON                     = 319;
 IDI_VIEW_WRAP_OFF_ICON                       = 320;

// IDI_NEW_DISABLE_ICON                       = 401;
// IDI_OPEN_ON_ICON                           = 402;
 IDI_SAVE_DISABLE_ICON                        = 403;
 IDI_SAVEALL_DISABLE_ICON                     = 404;
// IDI_CLOSE_ON_ICON                          = 405;
// IDI_CLOSEALL_ON_ICON                       = 406;
 IDI_CUT_DISABLE_ICON                         = 407;
 IDI_COPY_DISABLE_ICON                        = 408;
 IDI_PASTE_DISABLE_ICON                       = 409;
 IDI_UNDO_DISABLE_ICON                        = 410;
 IDI_REDO_DISABLE_ICON                        = 411;
 IDI_DELETE_ICON                              = 412;

 IDI_SYNCV_OFF_ICON                           = 413;
 IDI_SYNCV_ON_ICON                            = 414;
 IDI_SYNCV_DISABLE_ICON                       = 415;

 IDI_SYNCH_OFF_ICON                           = 416;
 IDI_SYNCH_ON_ICON                            = 417;
 IDI_SYNCH_DISABLE_ICON                       = 418;

 IDI_SAVED_ICON                               = 501;
 IDI_UNSAVED_ICON                             = 502;
 IDI_READONLY_ICON                            = 503;
 IDI_FIND_RESULT_ICON                         = 504;

 IDC_MY_CUR                                   = 1402;
 IDC_UP_ARROW                                 = 1403;
 IDC_DRAG_TAB                                 = 1404;
 IDC_DRAG_INTERDIT_TAB                        = 1405;
 IDC_DRAG_PLUS_TAB                            = 1406;
 IDC_MACRO_RECORDING                          = 1407;

 IDR_SAVEALL                                  = 1500;
 IDR_CLOSEFILE                                = 1501;
 IDR_CLOSEALL                                 = 1502;
 IDR_FIND                                     = 1503;
 IDR_REPLACE                                  = 1504;
 IDR_ZOOMIN                                   = 1505;
 IDR_ZOOMOUT                                  = 1506;
 IDR_WRAP                                     = 1507;
 IDR_INVISIBLECHAR                            = 1508;
 IDR_INDENTGUIDE                              = 1509;
 IDR_SHOWPANNEL                               = 1510;
 IDR_STARTRECORD                              = 1511;
 IDR_STOPRECORD                               = 1512;
 IDR_PLAYRECORD                               = 1513;
 IDR_SAVERECORD                               = 1514;
 IDR_SYNCV                                    = 1515;
 IDR_SYNCH                                    = 1516;
 IDR_FILENEW                                  = 1517;
 IDR_FILEOPEN                                 = 1518;
 IDR_FILESAVE                                 = 1519;
 IDR_PRINT                                    = 1520;
 IDR_CUT                                      = 1521;
 IDR_COPY                                     = 1522;
 IDR_PASTE                                    = 1523;
 IDR_UNDO                                     = 1524;
 IDR_REDO                                     = 1525;
 IDR_M_PLAYRECORD                             = 1526;

 IDR_CLOSETAB                                 = 1530;
 IDR_CLOSETAB_INACT                           = 1531;
 IDR_CLOSETAB_HOVER                           = 1532;
 IDR_CLOSETAB_PUSH                            = 1533;

 ID_MACRO                                     = 20000;
 ID_MACRO_LIMIT                               = 20200;

 ID_USER_CMD                                  = 21000;
 ID_USER_CMD_LIMIT                            = 21200;

 ID_PLUGINS_CMD                               = 22000;
 ID_PLUGINS_CMD_LIMIT                         = 22500;

 IDM                                          = 40000;

IDM_FILE                                      = (IDM + 1000);
IDM_FILE_NEW                                  = (IDM_FILE + 1);
IDM_FILE_OPEN                                 = (IDM_FILE + 2);
IDM_FILE_CLOSE                                = (IDM_FILE + 3);
IDM_FILE_CLOSEALL                             = (IDM_FILE + 4);
IDM_FILE_CLOSEALL_BUT_CURRENT                 = (IDM_FILE + 5);
IDM_FILE_SAVE                                 = (IDM_FILE + 6); 
IDM_FILE_SAVEALL                              = (IDM_FILE + 7); 
IDM_FILE_SAVEAS                               = (IDM_FILE + 8);
IDM_FILE_ASIAN_LANG                           = (IDM_FILE + 9);  
IDM_FILE_PRINT                                = (IDM_FILE + 10);
IDM_FILE_EXIT                                 = (IDM_FILE + 11);
IDM_FILE_LOADSESSION                          = (IDM_FILE + 12);
IDM_FILE_SAVESESSION                          = (IDM_FILE + 13);
IDM_FILE_RELOAD                               = (IDM_FILE + 14);
 
 // A mettre à jour si on ajoute nouveau menu item dans le menu "File"
 IDM_FILEMENU_LASTONE                         = IDM_FILE_RELOAD;
 
IDM_EDIT                                      = (IDM + 2000);
IDM_EDIT_CUT                                  = (IDM_EDIT + 1); 
IDM_EDIT_COPY                                 = (IDM_EDIT + 2);
IDM_EDIT_UNDO                                 = (IDM_EDIT + 3);
IDM_EDIT_REDO                                 = (IDM_EDIT + 4);
IDM_EDIT_PASTE                                = (IDM_EDIT + 5);
IDM_EDIT_DELETE                               = (IDM_EDIT + 6);
IDM_EDIT_SELECTALL                            = (IDM_EDIT + 7);
	
IDM_EDIT_INS_TAB                              = (IDM_EDIT + 8);
IDM_EDIT_RMV_TAB                              = (IDM_EDIT + 9);
IDM_EDIT_DUP_LINE                             = (IDM_EDIT + 10);
IDM_EDIT_TRANSPOSE_LINE                       = (IDM_EDIT + 11);
IDM_EDIT_SPLIT_LINES                          = (IDM_EDIT + 12);
IDM_EDIT_JOIN_LINES                           = (IDM_EDIT + 13);
IDM_EDIT_LINE_UP                              = (IDM_EDIT + 14);
IDM_EDIT_LINE_DOWN                            = (IDM_EDIT + 15);
IDM_EDIT_UPPERCASE                            = (IDM_EDIT + 16);
IDM_EDIT_LOWERCASE                            = (IDM_EDIT + 17);
IDM_EDIT_STARTRECORDINGMACRO                  = (IDM_EDIT + 18);
IDM_EDIT_STOPRECORDINGMACRO                   = (IDM_EDIT + 19);
IDM_EDIT_TOGGLEMACRORECORDING                 = (IDM_EDIT + 20);
IDM_EDIT_PLAYBACKRECORDEDMACRO                = (IDM_EDIT + 21);
IDM_EDIT_BLOCK_COMMENT                        = (IDM_EDIT + 22);
IDM_EDIT_STREAM_COMMENT                       = (IDM_EDIT + 23);
IDM_EDIT_TRIMTRAILING                         = (IDM_EDIT + 24);
IDM_EDIT_SAVECURRENTMACRO                     = (IDM_EDIT + 25);
IDM_EDIT_RTL                                  = (IDM_EDIT+26);
IDM_EDIT_LTR                                  = (IDM_EDIT+27);
IDM_EDIT_SETREADONLY                          = (IDM_EDIT+28);
IDM_EDIT_FULLPATHTOCLIP                       = (IDM_EDIT+29);
IDM_EDIT_FILENAMETOCLIP                       = (IDM_EDIT+30);
IDM_EDIT_CURRENTDIRTOCLIP                     = (IDM_EDIT+31);
IDM_EDIT_RUNMULTIMACRODLG                     = (IDM_EDIT+32);
IDM_EDIT_CLEARREADONLY                        = (IDM_EDIT+33);
IDM_EDIT_COLUMNMODE                           = (IDM_EDIT+34);
	//Belong to MENU FILE
IDM_OPEN_ALL_RECENT_FILE                      = (IDM_EDIT + 40);
	
IDM_SEARCH                                    = (IDM + 3000);

IDM_SEARCH_FIND                               = (IDM_SEARCH + 1);
IDM_SEARCH_FINDNEXT                           = (IDM_SEARCH + 2);
IDM_SEARCH_REPLACE                            = (IDM_SEARCH + 3);
IDM_SEARCH_GOTOLINE                           = (IDM_SEARCH + 4);
IDM_SEARCH_TOGGLE_BOOKMARK                    = (IDM_SEARCH + 5);
IDM_SEARCH_NEXT_BOOKMARK                      = (IDM_SEARCH + 6);
IDM_SEARCH_PREV_BOOKMARK                      = (IDM_SEARCH + 7);
IDM_SEARCH_CLEAR_BOOKMARKS                    = (IDM_SEARCH + 8);
IDM_SEARCH_GOTOMATCHINGBRACE                  = (IDM_SEARCH + 9);
IDM_SEARCH_FINDPREV                           = (IDM_SEARCH + 10);
IDM_SEARCH_FINDINCREMENT                      = (IDM_SEARCH + 11);
IDM_SEARCH_FINDINFILES                        = (IDM_SEARCH + 13);
IDM_SEARCH_VOLATILE_FINDNEXT                  = (IDM_SEARCH + 14);
IDM_SEARCH_VOLATILE_FINDPREV                  = (IDM_SEARCH + 15);
IDM_SEARCH_MARKALL                            = (IDM_SEARCH + 16);
IDM_SEARCH_UNMARKALL                          = (IDM_SEARCH + 17);

IDM_VIEW                                      = (IDM + 4000);
IDM_VIEW_TOOLBAR_HIDE                         = (IDM_VIEW + 1);
IDM_VIEW_TOOLBAR_REDUCE                       = (IDM_VIEW + 2);	
IDM_VIEW_TOOLBAR_ENLARGE                      = (IDM_VIEW + 3);
IDM_VIEW_TOOLBAR_STANDARD                     = (IDM_VIEW + 4);
IDM_VIEW_REDUCETABBAR                         = (IDM_VIEW + 5);
IDM_VIEW_LOCKTABBAR                           = (IDM_VIEW + 6); 
IDM_VIEW_DRAWTABBAR_TOPBAR                    = (IDM_VIEW + 7);
IDM_VIEW_DRAWTABBAR_INACIVETAB                = (IDM_VIEW + 8); 
IDM_VIEW_STATUSBAR                            = (IDM_VIEW + 9);  
IDM_VIEW_TOGGLE_FOLDALL                       = (IDM_VIEW + 10);
IDM_VIEW_USER_DLG                             = (IDM_VIEW + 11);
IDM_VIEW_LINENUMBER                           = (IDM_VIEW + 12);
IDM_VIEW_SYMBOLMARGIN                         = (IDM_VIEW + 13);
IDM_VIEW_FOLDERMAGIN                          = (IDM_VIEW + 14);
IDM_VIEW_FOLDERMAGIN_SIMPLE                   = (IDM_VIEW + 15);
IDM_VIEW_FOLDERMAGIN_ARROW                    = (IDM_VIEW + 16);
IDM_VIEW_FOLDERMAGIN_CIRCLE                   = (IDM_VIEW + 17);
IDM_VIEW_FOLDERMAGIN_BOX                      = (IDM_VIEW + 18);
IDM_VIEW_ALL_CHARACTERS                       = (IDM_VIEW + 19);
IDM_VIEW_INDENT_GUIDE                         = (IDM_VIEW + 20);
IDM_VIEW_CURLINE_HILITING                     = (IDM_VIEW + 21);
IDM_VIEW_WRAP                                 = (IDM_VIEW + 22);
IDM_VIEW_ZOOMIN                               = (IDM_VIEW + 23);
IDM_VIEW_ZOOMOUT                              = (IDM_VIEW + 24);
IDM_VIEW_TAB_SPACE                            = (IDM_VIEW + 25);
IDM_VIEW_EOL                                  = (IDM_VIEW + 26);
IDM_VIEW_EDGELINE                             = (IDM_VIEW + 27);
IDM_VIEW_EDGEBACKGROUND                       = (IDM_VIEW + 28);
IDM_VIEW_TOGGLE_UNFOLDALL                     = (IDM_VIEW + 29);
IDM_VIEW_FOLD_CURRENT                         = (IDM_VIEW + 30);
IDM_VIEW_UNFOLD_CURRENT                       = (IDM_VIEW + 31);
IDM_VIEW_FULLSCREENTOGGLE                     = (IDM_VIEW + 32);
IDM_VIEW_ZOOMRESTORE                          = (IDM_VIEW + 33);
IDM_VIEW_ALWAYSONTOP                          = (IDM_VIEW + 34);
IDM_VIEW_SYNSCROLLV                           = (IDM_VIEW + 35);
IDM_VIEW_SYNSCROLLH                           = (IDM_VIEW + 36);
IDM_VIEW_EDGENONE                             = (IDM_VIEW + 37);
IDM_VIEW_DRAWTABBAR_CLOSEBOTTUN               = (IDM_VIEW + 38);
IDM_VIEW_DRAWTABBAR_DBCLK2CLOSE               = (IDM_VIEW + 39);
IDM_VIEW_REFRESHTABAR                         = (IDM_VIEW + 40);
IDM_VIEW_WRAP_SYMBOL                          = (IDM_VIEW + 41);

IDM_VIEW_FOLD                                 = (IDM_VIEW + 50);
IDM_VIEW_FOLD_1                               =	(IDM_VIEW_FOLD + 1);
IDM_VIEW_FOLD_2                               =	(IDM_VIEW_FOLD + 2);
IDM_VIEW_FOLD_3                               =	(IDM_VIEW_FOLD + 3);
IDM_VIEW_FOLD_4                               =	(IDM_VIEW_FOLD + 4);
IDM_VIEW_FOLD_5                               =	(IDM_VIEW_FOLD + 5);
IDM_VIEW_FOLD_6                               =	(IDM_VIEW_FOLD + 6);
IDM_VIEW_FOLD_7                               = (IDM_VIEW_FOLD + 7);
IDM_VIEW_FOLD_8                               = (IDM_VIEW_FOLD + 8);

IDM_VIEW_UNFOLD                               =	(IDM_VIEW + 60);
IDM_VIEW_UNFOLD_1                             =	(IDM_VIEW_UNFOLD + 1);
IDM_VIEW_UNFOLD_2                             =	(IDM_VIEW_UNFOLD + 2);
IDM_VIEW_UNFOLD_3                             =	(IDM_VIEW_UNFOLD + 3);
IDM_VIEW_UNFOLD_4                             =	(IDM_VIEW_UNFOLD + 4);
IDM_VIEW_UNFOLD_5                             =	(IDM_VIEW_UNFOLD + 5);
IDM_VIEW_UNFOLD_6                             =	(IDM_VIEW_UNFOLD + 6);
IDM_VIEW_UNFOLD_7                             = (IDM_VIEW_UNFOLD + 7);
IDM_VIEW_UNFOLD_8                             = (IDM_VIEW_UNFOLD + 8);

	

IDM_FORMAT                                    = (IDM + 5000);                          
IDM_FORMAT_TODOS                              =	(IDM_FORMAT + 1);
IDM_FORMAT_TOUNIX                             =	(IDM_FORMAT + 2);
IDM_FORMAT_TOMAC                              =	(IDM_FORMAT + 3);
	//NEW
IDM_FORMAT_ANSI                               =	(IDM_FORMAT + 4);
IDM_FORMAT_UTF_8                              =	(IDM_FORMAT + 5);
IDM_FORMAT_UCS_2BE                            =	(IDM_FORMAT + 6);
IDM_FORMAT_UCS_2LE                            = (IDM_FORMAT + 7);
IDM_FORMAT_AS_UTF_8                           =	(IDM_FORMAT + 8);
    //WEN
	
IDM_LANG                                      =	(IDM + 6000);
IDM_LANGSTYLE_CONFIG_DLG                      =	(IDM_LANG + 1);
IDM_LANG_C                                    =	(IDM_LANG + 2);
IDM_LANG_CPP                                  =	(IDM_LANG + 3);
IDM_LANG_JAVA                                 =	(IDM_LANG + 4);
IDM_LANG_HTML                                 =	(IDM_LANG + 5);		
IDM_LANG_XML                                  =	(IDM_LANG + 6);
IDM_LANG_JS                                   =	(IDM_LANG + 7);
IDM_LANG_PHP                                  =	(IDM_LANG + 8); 
IDM_LANG_ASP                                  =	(IDM_LANG + 9);
IDM_LANG_CSS                                  = (IDM_LANG + 10);
IDM_LANG_PASCAL                               =	(IDM_LANG + 11);
IDM_LANG_PYTHON                               =	(IDM_LANG + 12);
IDM_LANG_PERL                                 =	(IDM_LANG + 13);
IDM_LANG_OBJC                                 =	(IDM_LANG + 14); 
IDM_LANG_ASCII                                =	(IDM_LANG + 15);
IDM_LANG_TEXT                                 =	(IDM_LANG + 16);
IDM_LANG_RC                                   =	(IDM_LANG + 17);
IDM_LANG_MAKEFILE                             =	(IDM_LANG + 18);
IDM_LANG_INI                                  =	(IDM_LANG + 19);
IDM_LANG_SQL                                  =	(IDM_LANG + 20);
IDM_LANG_VB                                   =	(IDM_LANG + 21);
IDM_LANG_BATCH                                =	(IDM_LANG + 22);
IDM_LANG_CS                                   = (IDM_LANG + 23);
IDM_LANG_LUA                                  = (IDM_LANG + 24);
IDM_LANG_TEX                                  = (IDM_LANG + 25);
IDM_LANG_FORTRAN                              = (IDM_LANG + 26);
IDM_LANG_SH                                   = (IDM_LANG + 27);
IDM_LANG_FLASH                                = (IDM_LANG + 28);
IDM_LANG_NSIS                                 = (IDM_LANG + 29);
IDM_LANG_TCL                                  = (IDM_LANG + 30);
IDM_LANG_LISP                                 = (IDM_LANG + 31);
IDM_LANG_SCHEME                               = (IDM_LANG + 32);
IDM_LANG_ASM                                  = (IDM_LANG + 33);
IDM_LANG_DIFF                                 = (IDM_LANG + 34);
IDM_LANG_PROPS                                = (IDM_LANG + 35);
IDM_LANG_PS                                   = (IDM_LANG + 36);
IDM_LANG_RUBY                                 = (IDM_LANG + 37);
IDM_LANG_SMALLTALK                            = (IDM_LANG + 38);
IDM_LANG_VHDL                                 = (IDM_LANG + 39);
IDM_LANG_CAML                                 = (IDM_LANG + 40);
IDM_LANG_KIX                                  = (IDM_LANG + 41);
IDM_LANG_ADA                                  = (IDM_LANG + 42);
IDM_LANG_VERILOG                              = (IDM_LANG + 43);
IDM_LANG_AU3                                  = (IDM_LANG + 44);
IDM_LANG_MATLAB                               = (IDM_LANG + 45);
IDM_LANG_HASKELL                              = (IDM_LANG + 46);
IDM_LANG_INNO                                 = (IDM_LANG + 47);
IDM_LANG_CMAKE                                = (IDM_LANG + 48);
	
IDM_LANG_USER                                 =	(IDM_LANG + 50);     //46050
IDM_LANG_USER_LIMIT                           =	(IDM_LANG + 80);  //46080
	
IDM_ABOUT                                     =	(IDM  + 7000);
IDM_HOMESWEETHOME                             =	(IDM_ABOUT  + 1);
IDM_PROJECTPAGE                               =	(IDM_ABOUT  + 2);
IDM_ONLINEHELP                                =	(IDM_ABOUT  + 3);
IDM_FORUM                                     =	(IDM_ABOUT  + 4);
IDM_PLUGINSHOME                               =	(IDM_ABOUT  + 5);
	
IDC_MINIMIZED_TRAY                            = (IDM + 7001);

IDM_SETTING                                   = (IDM + 8000);
IDM_SETTING_TAB_SIZE                          = (IDM_SETTING + 1);
IDM_SETTING_TAB_REPLCESPACE                   = (IDM_SETTING + 2);
IDM_SETTING_HISTORY_SIZE                      = (IDM_SETTING + 3);
IDM_SETTING_EDGE_SIZE                         = (IDM_SETTING + 4);
IDM_SETTING_FILEASSOCIATION_DLG               = (IDM_SETTING + 5);
//IDM_SETTING_FILE_AUTODETECTION              = (IDM_SETTING + 6);
IDM_SETTING_HISTORY_DONT_CHECK                = (IDM_SETTING + 7);
IDM_SETTING_TRAYICON                          = (IDM_SETTING + 8);
IDM_SETTING_SHORTCUT_MAPPER                   = (IDM_SETTING + 9);
IDM_SETTING_REMEMBER_LAST_SESSION             = (IDM_SETTING + 10);
IDM_SETTING_PREFERECE                         = (IDM_SETTING + 11);

IDM_SETTING_FILE_AUTODETECTION_ENABLE         = (IDM_SETTING + 12);
IDM_SETTING_FILE_AUTODETECTION_DISABLE        = (IDM_SETTING + 13);
IDM_SETTING_FILE_AUTODETECTION_ENABLESILENTLY = (IDM_SETTING + 14);
{
IDM_SETTING_SETUTF8SANSBOM                    = (IDM_SETTING + 15);
IDM_SETTING_SETANSI                           = (IDM_SETTING + 16);
}
	
IDM_EXECUTE                                   = (IDM + 9000);      

IDC_DOC_GOTO_ANOTHER_VIEW                     =		10001;
IDC_DOC_CLONE_TO_ANOTHER_VIEW                 = 	10002;

IDCMD                                         = 50000;
IDC_AUTOCOMPLETE                              =	(IDCMD+0);
IDC_AUTOCOMPLETE_CURRENTFILE                  =	(IDCMD+1);
//IDC_SEARCH_FINDPREVSELECTED                 =	(IDCMD+2);
IDC_PREV_DOC                                  =	(IDCMD+3);
IDC_NEXT_DOC                                  =	(IDCMD+4);
IDC_EDIT_TOGGLEMACRORECORDING                 =	(IDCMD+5);
IDC_KEY_HOME                                  =	(IDCMD+6);
IDC_KEY_END                                   =	(IDCMD+7);
IDC_KEY_SELECT_2_HOME                         =	(IDCMD+8);
IDC_KEY_SELECT_2_END                          =	(IDCMD+9);
	
IDCMD_LIMIT                                   =	(IDCMD+20);

IDSCINTILLA                                   = 60000;				
IDSCINTILLA_KEY_HOME                          = (IDSCINTILLA+0);
IDSCINTILLA_KEY_HOME_WRAP                     = (IDSCINTILLA+1);
IDSCINTILLA_KEY_END                           = (IDSCINTILLA+2);
IDSCINTILLA_KEY_END_WRAP                      = (IDSCINTILLA+3);
IDSCINTILLA_KEY_LINE_DUP                      = (IDSCINTILLA+4);
IDSCINTILLA_KEY_LINE_CUT                      = (IDSCINTILLA+5);
IDSCINTILLA_KEY_LINE_DEL                      = (IDSCINTILLA+6);
IDSCINTILLA_KEY_LINE_TRANS                    = (IDSCINTILLA+7);
IDSCINTILLA_KEY_LINE_COPY                     = (IDSCINTILLA+8);
IDSCINTILLA_KEY_CUT                           = (IDSCINTILLA+9);
IDSCINTILLA_KEY_COPY                          = (IDSCINTILLA+10);
IDSCINTILLA_KEY_PASTE                         = (IDSCINTILLA+11);
IDSCINTILLA_KEY_DEL                           = (IDSCINTILLA+12);
IDSCINTILLA_KEY_SELECTALL                     = (IDSCINTILLA+13);
IDSCINTILLA_KEY_OUTDENT                       = (IDSCINTILLA+14);
IDSCINTILLA_KEY_UNDO                          = (IDSCINTILLA+15);
IDSCINTILLA_KEY_REDO                          = (IDSCINTILLA+16);
IDSCINTILLA_LIMIT                             =	(IDSCINTILLA+30);

IDD_FILEVIEW_DIALOG                           =		1000;
IDC_BUTTON_PRINT                              =  1001;

IDD_CREATE_DIRECTORY                          =		1100;
IDC_STATIC_CURRENT_FOLDER                     =  1101;
IDC_EDIT_NEW_FOLDER                           =  1102;

IDD_INSERT_INPUT_TEXT                         =		1200;
IDC_EDIT_INPUT_VALUE                          =		1201;
IDC_STATIC_INPUT_TITLE                        =		1202;
IDC_ICON_INPUT_ICON                           =		1203;

IDR_M30_MENU                                  =		1500;
IDR_NPP_ACCELERATORS                          =		1501;
//IDR_NPP_ACCELERATORS_98                     =		1502;

//IDD_FIND_REPLACE_DLG                        =		1600;

IDD_ABOUTBOX                                  = 1700;
IDC_LICENCE_EDIT                              = 1701;
IDC_HOME_ADDR                                 = 1702;
IDC_EMAIL_ADDR                                = 1703;
IDC_ONLINEHELP_ADDR                           = 1704;
IDC_AUTHOR_NAME                               = 1705;

//IDD_USER_DEFINE_BOX                         =	 1800;

//IDD_RUN_DLG                                 =  1900;

IDD_GOLINE                                    =		2000;
ID_GOLINE_EDIT                                =	(IDD_GOLINE + 1);
ID_CURRLINE                                   =	(IDD_GOLINE + 2);
ID_LASTLINE                                   =	(IDD_GOLINE + 3);
ID_URHERE_STATIC                              = (IDD_GOLINE + 4);
ID_UGO_STATIC                                 = (IDD_GOLINE + 5);
ID_NOMORETHAN_STATIC                          = (IDD_GOLINE + 6);

// voir columnEditor_rc.h
//IDD_COLUMNEDIT                              =  2020;


//IDD_COLOUR_POPUP                            =  2100;

// See WordStyleDlgRes.h
//IDD_STYLER_DLG                              = 2200;
//IDD_GLOBAL_STYLER_DLG                       = 2300;

IDD_VALUE_DLG                                 =  2400;
IDC_VALUE_STATIC                              =  2401;
IDC_VALUE_EDIT                                =  2402;

// see TaskListDlg_rc.h
//IDD_TASKLIST_DLG                            =  2450;
IDD_SETTING_DLG                               =  2500;

//See ShortcutMapper_rc.h
//IDD_SHORTCUTMAPPER_DLG                      =  2600;

// See regExtDlg.h
//IDD_REGEXT                                  = 4000;

// See shortcutRc.h
//IDD_SHORTCUT_DLG                            = 5000;

// See preference.rc
//IDD_PREFERENCE_BOX                          = 6000;

NOTEPADPLUS_USER_INTERNAL                     = (WM_USER + 0000);
NPPM_INTERNAL_USERCMDLIST_MODIFIED            = (NOTEPADPLUS_USER_INTERNAL + 1);
NPPM_INTERNAL_CMDLIST_MODIFIED                = (NOTEPADPLUS_USER_INTERNAL + 2);
NPPM_INTERNAL_MACROLIST_MODIFIED              = (NOTEPADPLUS_USER_INTERNAL + 3);
NPPM_INTERNAL_PLUGINCMDLIST_MODIFIED          = (NOTEPADPLUS_USER_INTERNAL + 4);
NPPM_INTERNAL_CLEARSCINTILLAKEY               = (NOTEPADPLUS_USER_INTERNAL + 5);
NPPM_INTERNAL_BINDSCINTILLAKEY                = (NOTEPADPLUS_USER_INTERNAL + 6);
NPPM_INTERNAL_SCINTILLAKEYMODIFIED            = (NOTEPADPLUS_USER_INTERNAL + 7);
NPPM_INTERNAL_SCINTILLAFINFERCOLLAPSE         = (NOTEPADPLUS_USER_INTERNAL + 8);
NPPM_INTERNAL_SCINTILLAFINFERUNCOLLAPSE       = (NOTEPADPLUS_USER_INTERNAL + 9);
// See Notepad_plus_msgs.h
//NOTEPADPLUS_USER                            = (WM_USER + 1000);
SCINTILLA_USER                                = (WM_USER + 2000);


MACRO_USER                                    = (WM_USER + 4000);
WM_ISCURRENTMACRORECORDED                     = (MACRO_USER + 01);
WM_MACRODLGRUNMACRO                           = (MACRO_USER + 02);


// See Notepad_plus_msgs.h
//RUNCOMMAND_USER                             = (WM_USER + 3000);
SPLITTER_USER                                 = (WM_USER + 4000);
WORDSTYLE_USER                                = (WM_USER + 5000);
COLOURPOPUP_USER                              = (WM_USER + 6000);
BABYGRID_USER                                 = (WM_USER + 7000);

//IDD_DOCKING_MNG                             =	(IDM  + 7000);

MENUINDEX_FILE                                = 0;
MENUINDEX_EDIT                                = 1;
MENUINDEX_SEARCH                              = 2;
MENUINDEX_VIEW                                = 3;
MENUINDEX_FORMAT                              = 4;
MENUINDEX_LANGUAGE                            = 5;
MENUINDEX_SETTINGS                            = 6;
MENUINDEX_MACRO                               = 7;
MENUINDEX_RUN                                 = 8;
MENUINDEX_PLUGINS                             = 9;

type TLangType = (L_TXT,
	                 L_PHP,
	                 L_C,
	                 L_CPP,
	                 L_CS,
	                 L_OBJC,
	                 L_JAVA,
	                 L_RC,
	                 L_HTML,
	                 L_XML,
	                 L_MAKEFILE,
	                 L_PASCAL,
	                 L_BATCH,
	                 L_INI,
	                 L_NFO,
	                 L_USER,
	                 L_ASP,
	                 L_SQL,
	                 L_VB,
	                 L_JS,
	                 L_CSS,
	                 L_PERL,
	                 L_PYTHON,
	                 L_LUA,
	                 L_TEX,
	                 L_FORTRAN,
	                 L_BASH,
	                 L_FLASH,
	                 L_NSIS,
	                 L_TCL,
                  L_LISP,
	                 L_SCHEME,
	                 L_ASM,
	                 L_DIFF,
	                 L_PROPS,
	                 L_PS,
	                 L_RUBY,
	                 L_SMALLTALK,
	                 L_VHDL,
                  L_END);
Added src/NPPInterface.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
// $HDR$
// $Log:  157175: NPPInterface.pas 
//
//    Rev 1.0    9/22/2009 16:57:12  merijn
unit NPPInterface;

interface

uses
  Windows, Messages;

{$I NPPConsts.inc}

type TNPPInterface = class(TObject)
     private
      fNPPHandle: hwnd;

      function NPerform(Msg: Cardinal; wParam: integer = 0; lParam: integer = 0): integer;

      function GetCurrentPrimaryScintillaHandle: hwnd;
    function GetCurrentFullPath: string;
    function GetCurrentLangType: TLangType;
    procedure SetCurrentLangType(const Value: TLangType);
     public
      constructor Create;

      property NPPHandle: hwnd read fNPPHandle write fNPPHandle;

      procedure NewFile;
      property CurrentPrimaryScintillaHandle: hwnd read GetCurrentPrimaryScintillaHandle;
      property CurrentFullPath: string read GetCurrentFullPath;

      property LangType: TLangType read GetCurrentLangType write SetCurrentLangType;
     end;

implementation

uses
  SysUtils;

{ TNPPInterface }


function WideStrLen(WideStr: WideString): integer;
begin
 result := 0;

 while (result < Length(WideStr)) and (WideStr[result + 1] <> #0) do
  inc(result);
end;

constructor TNPPInterface.Create;
begin
 inherited;

 fNPPHandle := 0;
end;

function TNPPInterface.GetCurrentFullPath: string;
var Path: WideString;
begin
 SetLength(Path, MAX_PATH);
 ZeroMemory(@Path[1], Length(Path) * SizeOf(WideChar));
 SendMessage(fNPPHandle, NPPM_GETFULLCURRENTPATH, 0, lParam(PWideChar(Path)));
 SetLength(Path, WideStrLen(Path));
 result := Path;
end;

function TNPPInterface.GetCurrentLangType: TLangType;
begin
 SendMessage(fNPPHandle, NPPM_GETCURRENTLANGTYPE, 0, integer(@result));
end;

function TNPPInterface.GetCurrentPrimaryScintillaHandle: hwnd;
var CurEdit: integer;
begin
// result := hwnd(MAIN_VIEW);
 SendMessage(fNPPHandle, NPPM_GETCURRENTSCINTILLA, 0, integer(@CurEdit));
 result := CurEdit;
end;

procedure TNPPInterface.NewFile;
begin
 NPerform(WM_COMMAND, IDM_FILE_NEW)
end;

function TNPPInterface.NPerform(Msg: Cardinal; wParam, lParam: integer): integer;
begin
 if fNPPHandle = 0 then
  raise Exception.Create('no handle defined!');

 result := SendMessage(fNPPHandle, Msg, wParam, lParam);
end;

procedure TNPPInterface.SetCurrentLangType(const Value: TLangType);
begin
 SendMessage(fNPPHandle, NPPM_SETCURRENTLANGTYPE, 0, integer(Value));
end;

end.
Added src/Progress.dfm.
























































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
object FormProgress: TFormProgress
  Left = 0
  Top = 0
  BorderIcons = [biMinimize]
  BorderStyle = bsSizeToolWin
  Caption = 'filtering'
  ClientHeight = 25
  ClientWidth = 302
  Color = clBtnFace
  Constraints.MaxHeight = 59
  Constraints.MinHeight = 51
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  Position = poScreenCenter
  OnCreate = FormCreate
  DesignSize = (
    302
    25)
  PixelsPerInch = 96
  TextHeight = 13
  object SpeedButtonCancel: TSpeedButton
    Left = 254
    Top = 5
    Width = 43
    Height = 17
    Anchors = [akTop, akRight]
    Caption = 'cancel'
    Flat = True
    OnClick = SpeedButtonCancelClick
  end
  object ProgressBar: TProgressBar
    Left = 4
    Top = 5
    Width = 244
    Height = 17
    Anchors = [akLeft, akTop, akRight]
    Step = 1
    TabOrder = 0
  end
end
Added src/Progress.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
unit Progress;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, StdCtrls, Buttons;

type
  TFormProgress = class(TForm)
    ProgressBar: TProgressBar;
    SpeedButtonCancel: TSpeedButton;
    procedure FormCreate(Sender: TObject);
    procedure SpeedButtonCancelClick(Sender: TObject);
  public
   Cancel: boolean;

   procedure Step;
  end;

var
  FormProgress: TFormProgress;

implementation

{$R *.dfm}

procedure TFormProgress.FormCreate(Sender: TObject);
begin
 Cancel := false;
end;

procedure TFormProgress.SpeedButtonCancelClick(Sender: TObject);
begin
 Cancel := true;
end;

procedure TFormProgress.Step;
begin
 ProgressBar.StepIt();
 Application.ProcessMessages();
end;

end.
Added src/QStrings.pas.

more than 10,000 changes

Added src/SCIConsts.inc.






















































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
const
    INVALID_POSITION = -1;
    SCI_START = 2000;
    SCI_OPTIONAL_START = 3000;
    SCI_LEXER_START = 4000;
    SCI_ADDTEXT = 2001;
    SCI_ADDSTYLEDTEXT = 2002;
    SCI_INSERTTEXT = 2003;
    SCI_CLEARALL = 2004;
    SCI_CLEARDOCUMENTSTYLE = 2005;
    SCI_GETLENGTH = 2006;
    SCI_GETCHARAT = 2007;
    SCI_GETCURRENTPOS = 2008;
    SCI_GETANCHOR = 2009;
    SCI_GETSTYLEAT = 2010;
    SCI_REDO = 2011;
    SCI_SETUNDOCOLLECTION = 2012;
    SCI_SELECTALL = 2013;
    SCI_SETSAVEPOINT = 2014;
    SCI_GETSTYLEDTEXT = 2015;
    SCI_CANREDO = 2016;
    SCI_MARKERLINEFROMHANDLE = 2017;
    SCI_MARKERDELETEHANDLE = 2018;
    SCI_GETUNDOCOLLECTION = 2019;
    SCWS_INVISIBLE = 0;
    SCWS_VISIBLEALWAYS = 1;
    SCWS_VISIBLEAFTERINDENT = 2;
    SCI_GETVIEWWS = 2020;
    SCI_SETVIEWWS = 2021;
    SCI_POSITIONFROMPOINT = 2022;
    SCI_POSITIONFROMPOINTCLOSE = 2023;
    SCI_GOTOLINE = 2024;
    SCI_GOTOPOS = 2025;
    SCI_SETANCHOR = 2026;
    SCI_GETCURLINE = 2027;
    SCI_GETENDSTYLED = 2028;
    SC_EOL_CRLF = 0;
    SC_EOL_CR = 1;
    SC_EOL_LF = 2;
    SCI_CONVERTEOLS = 2029;
    SCI_GETEOLMODE = 2030;
    SCI_SETEOLMODE = 2031;
    SCI_STARTSTYLING = 2032;
    SCI_SETSTYLING = 2033;
    SCI_GETBUFFEREDDRAW = 2034;
    SCI_SETBUFFEREDDRAW = 2035;
    SCI_SETTABWIDTH = 2036;
    SCI_GETTABWIDTH = 2121;
    SC_CP_UTF8 = 65001;
    SC_CP_DBCS = 1;
    SCI_SETCODEPAGE = 2037;
    SCI_SETUSEPALETTE = 2039;
    MARKER_MAX = 31;
    SC_MARK_CIRCLE = 0;
    SC_MARK_ROUNDRECT = 1;
    SC_MARK_ARROW = 2;
    SC_MARK_SMALLRECT = 3;
    SC_MARK_SHORTARROW = 4;
    SC_MARK_EMPTY = 5;
    SC_MARK_ARROWDOWN = 6;
    SC_MARK_MINUS = 7;
    SC_MARK_PLUS = 8;
    SC_MARK_VLINE = 9;
    SC_MARK_LCORNER = 10;
    SC_MARK_TCORNER = 11;
    SC_MARK_BOXPLUS = 12;
    SC_MARK_BOXPLUSCONNECTED = 13;
    SC_MARK_BOXMINUS = 14;
    SC_MARK_BOXMINUSCONNECTED = 15;
    SC_MARK_LCORNERCURVE = 16;
    SC_MARK_TCORNERCURVE = 17;
    SC_MARK_CIRCLEPLUS = 18;
    SC_MARK_CIRCLEPLUSCONNECTED = 19;
    SC_MARK_CIRCLEMINUS = 20;
    SC_MARK_CIRCLEMINUSCONNECTED = 21;
    SC_MARK_BACKGROUND = 22;
    SC_MARK_DOTDOTDOT = 23;
    SC_MARK_ARROWS = 24;
    SC_MARK_PIXMAP = 25;
    SC_MARK_FULLRECT = 26;
    SC_MARK_CHARACTER = 10000;
    SC_MARKNUM_FOLDEREND = 25;
    SC_MARKNUM_FOLDEROPENMID = 26;
    SC_MARKNUM_FOLDERMIDTAIL = 27;
    SC_MARKNUM_FOLDERTAIL = 28;
    SC_MARKNUM_FOLDERSUB = 29;
    SC_MARKNUM_FOLDER = 30;
    SC_MARKNUM_FOLDEROPEN = 31;
    SC_MASK_FOLDERS = $FE000000;
    SCI_MARKERDEFINE = 2040;
    SCI_MARKERSETFORE = 2041;
    SCI_MARKERSETBACK = 2042;
    SCI_MARKERADD = 2043;
    SCI_MARKERDELETE = 2044;
    SCI_MARKERDELETEALL = 2045;
    SCI_MARKERGET = 2046;
    SCI_MARKERNEXT = 2047;
    SCI_MARKERPREVIOUS = 2048;
    SCI_MARKERDEFINEPIXMAP = 2049;
    SCI_MARKERADDSET = 2466;
    SCI_MARKERSETALPHA = 2476;
    SC_MARGIN_SYMBOL = 0;
    SC_MARGIN_NUMBER = 1;
    SC_MARGIN_BACK = 2;
    SC_MARGIN_FORE = 3;
    SCI_SETMARGINTYPEN = 2240;
    SCI_GETMARGINTYPEN = 2241;
    SCI_SETMARGINWIDTHN = 2242;
    SCI_GETMARGINWIDTHN = 2243;
    SCI_SETMARGINMASKN = 2244;
    SCI_GETMARGINMASKN = 2245;
    SCI_SETMARGINSENSITIVEN = 2246;
    SCI_GETMARGINSENSITIVEN = 2247;
    STYLE_DEFAULT = 32;
    STYLE_LINENUMBER = 33;
    STYLE_BRACELIGHT = 34;
    STYLE_BRACEBAD = 35;
    STYLE_CONTROLCHAR = 36;
    STYLE_INDENTGUIDE = 37;
    STYLE_CALLTIP = 38;
    STYLE_LASTPREDEFINED = 39;
    STYLE_MAX = 127;
    SC_CHARSET_ANSI = 0;
    SC_CHARSET_DEFAULT = 1;
    SC_CHARSET_BALTIC = 186;
    SC_CHARSET_CHINESEBIG5 = 136;
    SC_CHARSET_EASTEUROPE = 238;
    SC_CHARSET_GB2312 = 134;
    SC_CHARSET_GREEK = 161;
    SC_CHARSET_HANGUL = 129;
    SC_CHARSET_MAC = 77;
    SC_CHARSET_OEM = 255;
    SC_CHARSET_RUSSIAN = 204;
    SC_CHARSET_CYRILLIC = 1251;
    SC_CHARSET_SHIFTJIS = 128;
    SC_CHARSET_SYMBOL = 2;
    SC_CHARSET_TURKISH = 162;
    SC_CHARSET_JOHAB = 130;
    SC_CHARSET_HEBREW = 177;
    SC_CHARSET_ARABIC = 178;
    SC_CHARSET_VIETNAMESE = 163;
    SC_CHARSET_THAI = 222;
    SC_CHARSET_8859_15 = 1000;
    SCI_STYLECLEARALL = 2050;
    SCI_STYLESETFORE = 2051;
    SCI_STYLESETBACK = 2052;
    SCI_STYLESETBOLD = 2053;
    SCI_STYLESETITALIC = 2054;
    SCI_STYLESETSIZE = 2055;
    SCI_STYLESETFONT = 2056;
    SCI_STYLESETEOLFILLED = 2057;
    SCI_STYLERESETDEFAULT = 2058;
    SCI_STYLESETUNDERLINE = 2059;
    SC_CASE_MIXED = 0;
    SC_CASE_UPPER = 1;
    SC_CASE_LOWER = 2;
    SCI_STYLESETCASE = 2060;
    SCI_STYLESETCHARACTERSET = 2066;
    SCI_STYLESETHOTSPOT = 2409;
    SCI_SETSELFORE = 2067;
    SCI_SETSELBACK = 2068;
    SCI_GETSELALPHA = 2477;
    SCI_SETSELALPHA = 2478;
    SCI_SETCARETFORE = 2069;
    SCI_ASSIGNCMDKEY = 2070;
    SCI_CLEARCMDKEY = 2071;
    SCI_CLEARALLCMDKEYS = 2072;
    SCI_SETSTYLINGEX = 2073;
    SCI_STYLESETVISIBLE = 2074;
    SCI_GETCARETPERIOD = 2075;
    SCI_SETCARETPERIOD = 2076;
    SCI_SETWORDCHARS = 2077;
    SCI_BEGINUNDOACTION = 2078;
    SCI_ENDUNDOACTION = 2079;
    INDIC_MAX = 7;
    INDIC_PLAIN = 0;
    INDIC_SQUIGGLE = 1;
    INDIC_TT = 2;
    INDIC_DIAGONAL = 3;
    INDIC_STRIKE = 4;
    INDIC_HIDDEN = 5;
    INDIC_BOX = 6;
    INDIC_ROUNDBOX = 7;
    INDIC0_MASK = $20;
    INDIC1_MASK = $40;
    INDIC2_MASK = $80;
    INDICS_MASK = $E0;
    SCI_INDICSETSTYLE = 2080;
    SCI_INDICGETSTYLE = 2081;
    SCI_INDICSETFORE = 2082;
    SCI_INDICGETFORE = 2083;
    SCI_SETWHITESPACEFORE = 2084;
    SCI_SETWHITESPACEBACK = 2085;
    SCI_SETSTYLEBITS = 2090;
    SCI_GETSTYLEBITS = 2091;
    SCI_SETLINESTATE = 2092;
    SCI_GETLINESTATE = 2093;
    SCI_GETMAXLINESTATE = 2094;
    SCI_GETCARETLINEVISIBLE = 2095;
    SCI_SETCARETLINEVISIBLE = 2096;
    SCI_GETCARETLINEBACK = 2097;
    SCI_SETCARETLINEBACK = 2098;
    SCI_STYLESETCHANGEABLE = 2099;
    SCI_AUTOCSHOW = 2100;
    SCI_AUTOCCANCEL = 2101;
    SCI_AUTOCACTIVE = 2102;
    SCI_AUTOCPOSSTART = 2103;
    SCI_AUTOCCOMPLETE = 2104;
    SCI_AUTOCSTOPS = 2105;
    SCI_AUTOCSETSEPARATOR = 2106;
    SCI_AUTOCGETSEPARATOR = 2107;
    SCI_AUTOCSELECT = 2108;
    SCI_AUTOCSETCANCELATSTART = 2110;
    SCI_AUTOCGETCANCELATSTART = 2111;
    SCI_AUTOCSETFILLUPS = 2112;
    SCI_AUTOCSETCHOOSESINGLE = 2113;
    SCI_AUTOCGETCHOOSESINGLE = 2114;
    SCI_AUTOCSETIGNORECASE = 2115;
    SCI_AUTOCGETIGNORECASE = 2116;
    SCI_USERLISTSHOW = 2117;
    SCI_AUTOCSETAUTOHIDE = 2118;
    SCI_AUTOCGETAUTOHIDE = 2119;
    SCI_AUTOCSETDROPRESTOFWORD = 2270;
    SCI_AUTOCGETDROPRESTOFWORD = 2271;
    SCI_REGISTERIMAGE = 2405;
    SCI_CLEARREGISTEREDIMAGES = 2408;
    SCI_AUTOCGETTYPESEPARATOR = 2285;
    SCI_AUTOCSETTYPESEPARATOR = 2286;
    SCI_AUTOCSETMAXWIDTH = 2208;
    SCI_AUTOCGETMAXWIDTH = 2209;
    SCI_AUTOCSETMAXHEIGHT = 2210;
    SCI_AUTOCGETMAXHEIGHT = 2211;
    SCI_SETINDENT = 2122;
    SCI_GETINDENT = 2123;
    SCI_SETUSETABS = 2124;
    SCI_GETUSETABS = 2125;
    SCI_SETLINEINDENTATION = 2126;
    SCI_GETLINEINDENTATION = 2127;
    SCI_GETLINEINDENTPOSITION = 2128;
    SCI_GETCOLUMN = 2129;
    SCI_SETHSCROLLBAR = 2130;
    SCI_GETHSCROLLBAR = 2131;
    SCI_SETINDENTATIONGUIDES = 2132;
    SCI_GETINDENTATIONGUIDES = 2133;
    SCI_SETHIGHLIGHTGUIDE = 2134;
    SCI_GETHIGHLIGHTGUIDE = 2135;
    SCI_GETLINEENDPOSITION = 2136;
    SCI_GETCODEPAGE = 2137;
    SCI_GETCARETFORE = 2138;
    SCI_GETUSEPALETTE = 2139;
    SCI_GETREADONLY = 2140;
    SCI_SETCURRENTPOS = 2141;
    SCI_SETSELECTIONSTART = 2142;
    SCI_GETSELECTIONSTART = 2143;
    SCI_SETSELECTIONEND = 2144;
    SCI_GETSELECTIONEND = 2145;
    SCI_SETPRINTMAGNIFICATION = 2146;
    SCI_GETPRINTMAGNIFICATION = 2147;
    SC_PRINT_NORMAL = 0;
    SC_PRINT_INVERTLIGHT = 1;
    SC_PRINT_BLACKONWHITE = 2;
    SC_PRINT_COLOURONWHITE = 3;
    SC_PRINT_COLOURONWHITEDEFAULTBG = 4;
    SCI_SETPRINTCOLOURMODE = 2148;
    SCI_GETPRINTCOLOURMODE = 2149;
    SCFIND_WHOLEWORD = 2;
    SCFIND_MATCHCASE = 4;
    SCFIND_WORDSTART = $00100000;
    SCFIND_REGEXP = $00200000;
    SCFIND_POSIX = $00400000;
    SCI_FINDTEXT = 2150;
    SCI_FORMATRANGE = 2151;
    SCI_GETFIRSTVISIBLELINE = 2152;
    SCI_GETLINE = 2153;
    SCI_GETLINECOUNT = 2154;
    SCI_SETMARGINLEFT = 2155;
    SCI_GETMARGINLEFT = 2156;
    SCI_SETMARGINRIGHT = 2157;
    SCI_GETMARGINRIGHT = 2158;
    SCI_GETMODIFY = 2159;
    SCI_SETSEL = 2160;
    SCI_GETSELTEXT = 2161;
    SCI_GETTEXTRANGE = 2162;
    SCI_HIDESELECTION = 2163;
    SCI_POINTXFROMPOSITION = 2164;
    SCI_POINTYFROMPOSITION = 2165;
    SCI_LINEFROMPOSITION = 2166;
    SCI_POSITIONFROMLINE = 2167;
    SCI_LINESCROLL = 2168;
    SCI_SCROLLCARET = 2169;
    SCI_REPLACESEL = 2170;
    SCI_SETREADONLY = 2171;
    SCI_NULL = 2172;
    SCI_CANPASTE = 2173;
    SCI_CANUNDO = 2174;
    SCI_EMPTYUNDOBUFFER = 2175;
    SCI_UNDO = 2176;
    SCI_CUT = 2177;
    SCI_COPY = 2178;
    SCI_PASTE = 2179;
    SCI_CLEAR = 2180;
    SCI_SETTEXT = 2181;
    SCI_GETTEXT = 2182;
    SCI_GETTEXTLENGTH = 2183;
    SCI_GETDIRECTFUNCTION = 2184;
    SCI_GETDIRECTPOINTER = 2185;
    SCI_SETOVERTYPE = 2186;
    SCI_GETOVERTYPE = 2187;
    SCI_SETCARETWIDTH = 2188;
    SCI_GETCARETWIDTH = 2189;
    SCI_SETTARGETSTART = 2190;
    SCI_GETTARGETSTART = 2191;
    SCI_SETTARGETEND = 2192;
    SCI_GETTARGETEND = 2193;
    SCI_REPLACETARGET = 2194;
    SCI_REPLACETARGETRE = 2195;
    SCI_SEARCHINTARGET = 2197;
    SCI_SETSEARCHFLAGS = 2198;
    SCI_GETSEARCHFLAGS = 2199;
    SCI_CALLTIPSHOW = 2200;
    SCI_CALLTIPCANCEL = 2201;
    SCI_CALLTIPACTIVE = 2202;
    SCI_CALLTIPPOSSTART = 2203;
    SCI_CALLTIPSETHLT = 2204;
    SCI_CALLTIPSETBACK = 2205;
    SCI_CALLTIPSETFORE = 2206;
    SCI_CALLTIPSETFOREHLT = 2207;
    SCI_CALLTIPUSESTYLE = 2212;
    SCI_VISIBLEFROMDOCLINE = 2220;
    SCI_DOCLINEFROMVISIBLE = 2221;
    SCI_WRAPCOUNT = 2235;
    SC_FOLDLEVELBASE = $400;
    SC_FOLDLEVELWHITEFLAG = $1000;
    SC_FOLDLEVELHEADERFLAG = $2000;
    SC_FOLDLEVELBOXHEADERFLAG = $4000;
    SC_FOLDLEVELBOXFOOTERFLAG = $8000;
    SC_FOLDLEVELCONTRACTED = $10000;
    SC_FOLDLEVELUNINDENT = $20000;
    SC_FOLDLEVELNUMBERMASK = $0FFF;
    SCI_SETFOLDLEVEL = 2222;
    SCI_GETFOLDLEVEL = 2223;
    SCI_GETLASTCHILD = 2224;
    SCI_GETFOLDPARENT = 2225;
    SCI_SHOWLINES = 2226;
    SCI_HIDELINES = 2227;
    SCI_GETLINEVISIBLE = 2228;
    SCI_SETFOLDEXPANDED = 2229;
    SCI_GETFOLDEXPANDED = 2230;
    SCI_TOGGLEFOLD = 2231;
    SCI_ENSUREVISIBLE = 2232;
    SC_FOLDFLAG_LINEBEFORE_EXPANDED = $0002;
    SC_FOLDFLAG_LINEBEFORE_CONTRACTED = $0004;
    SC_FOLDFLAG_LINEAFTER_EXPANDED = $0008;
    SC_FOLDFLAG_LINEAFTER_CONTRACTED = $0010;
    SC_FOLDFLAG_LEVELNUMBERS = $0040;
    SC_FOLDFLAG_BOX = $0001;
    SCI_SETFOLDFLAGS = 2233;
    SCI_ENSUREVISIBLEENFORCEPOLICY = 2234;
    SCI_SETTABINDENTS = 2260;
    SCI_GETTABINDENTS = 2261;
    SCI_SETBACKSPACEUNINDENTS = 2262;
    SCI_GETBACKSPACEUNINDENTS = 2263;
    SC_TIME_FOREVER = 10000000;
    SCI_SETMOUSEDWELLTIME = 2264;
    SCI_GETMOUSEDWELLTIME = 2265;
    SCI_WORDSTARTPOSITION = 2266;
    SCI_WORDENDPOSITION = 2267;
    SC_WRAP_NONE = 0;
    SC_WRAP_WORD = 1;
    SC_WRAP_CHAR = 2;
    SCI_SETWRAPMODE = 2268;
    SCI_GETWRAPMODE = 2269;
    SC_WRAPVISUALFLAG_NONE = $0000;
    SC_WRAPVISUALFLAG_END = $0001;
    SC_WRAPVISUALFLAG_START = $0002;
    SCI_SETWRAPVISUALFLAGS = 2460;
    SCI_GETWRAPVISUALFLAGS = 2461;
    SC_WRAPVISUALFLAGLOC_DEFAULT = $0000;
    SC_WRAPVISUALFLAGLOC_END_BY_TEXT = $0001;
    SC_WRAPVISUALFLAGLOC_START_BY_TEXT = $0002;
    SCI_SETWRAPVISUALFLAGSLOCATION = 2462;
    SCI_GETWRAPVISUALFLAGSLOCATION = 2463;
    SCI_SETWRAPSTARTINDENT = 2464;
    SCI_GETWRAPSTARTINDENT = 2465;
    SC_CACHE_NONE = 0;
    SC_CACHE_CARET = 1;
    SC_CACHE_PAGE = 2;
    SC_CACHE_DOCUMENT = 3;
    SCI_SETLAYOUTCACHE = 2272;
    SCI_GETLAYOUTCACHE = 2273;
    SCI_SETSCROLLWIDTH = 2274;
    SCI_GETSCROLLWIDTH = 2275;
    SCI_TEXTWIDTH = 2276;
    SCI_SETENDATLASTLINE = 2277;
    SCI_GETENDATLASTLINE = 2278;
    SCI_TEXTHEIGHT = 2279;
    SCI_SETVSCROLLBAR = 2280;
    SCI_GETVSCROLLBAR = 2281;
    SCI_APPENDTEXT = 2282;
    SCI_GETTWOPHASEDRAW = 2283;
    SCI_SETTWOPHASEDRAW = 2284;
    SCI_TARGETFROMSELECTION = 2287;
    SCI_LINESJOIN = 2288;
    SCI_LINESSPLIT = 2289;
    SCI_SETFOLDMARGINCOLOUR = 2290;
    SCI_SETFOLDMARGINHICOLOUR = 2291;
    SCI_LINEDOWN = 2300;
    SCI_LINEDOWNEXTEND = 2301;
    SCI_LINEUP = 2302;
    SCI_LINEUPEXTEND = 2303;
    SCI_CHARLEFT = 2304;
    SCI_CHARLEFTEXTEND = 2305;
    SCI_CHARRIGHT = 2306;
    SCI_CHARRIGHTEXTEND = 2307;
    SCI_WORDLEFT = 2308;
    SCI_WORDLEFTEXTEND = 2309;
    SCI_WORDRIGHT = 2310;
    SCI_WORDRIGHTEXTEND = 2311;
    SCI_HOME = 2312;
    SCI_HOMEEXTEND = 2313;
    SCI_LINEEND = 2314;
    SCI_LINEENDEXTEND = 2315;
    SCI_DOCUMENTSTART = 2316;
    SCI_DOCUMENTSTARTEXTEND = 2317;
    SCI_DOCUMENTEND = 2318;
    SCI_DOCUMENTENDEXTEND = 2319;
    SCI_PAGEUP = 2320;
    SCI_PAGEUPEXTEND = 2321;
    SCI_PAGEDOWN = 2322;
    SCI_PAGEDOWNEXTEND = 2323;
    SCI_EDITTOGGLEOVERTYPE = 2324;
    SCI_CANCEL = 2325;
    SCI_DELETEBACK = 2326;
    SCI_TAB = 2327;
    SCI_BACKTAB = 2328;
    SCI_NEWLINE = 2329;
    SCI_FORMFEED = 2330;
    SCI_VCHOME = 2331;
    SCI_VCHOMEEXTEND = 2332;
    SCI_ZOOMIN = 2333;
    SCI_ZOOMOUT = 2334;
    SCI_DELWORDLEFT = 2335;
    SCI_DELWORDRIGHT = 2336;
    SCI_LINECUT = 2337;
    SCI_LINEDELETE = 2338;
    SCI_LINETRANSPOSE = 2339;
    SCI_LINEDUPLICATE = 2404;
    SCI_LOWERCASE = 2340;
    SCI_UPPERCASE = 2341;
    SCI_LINESCROLLDOWN = 2342;
    SCI_LINESCROLLUP = 2343;
    SCI_DELETEBACKNOTLINE = 2344;
    SCI_HOMEDISPLAY = 2345;
    SCI_HOMEDISPLAYEXTEND = 2346;
    SCI_LINEENDDISPLAY = 2347;
    SCI_LINEENDDISPLAYEXTEND = 2348;
    SCI_HOMEWRAP = 2349;
    SCI_HOMEWRAPEXTEND = 2450;
    SCI_LINEENDWRAP = 2451;
    SCI_LINEENDWRAPEXTEND = 2452;
    SCI_VCHOMEWRAP = 2453;
    SCI_VCHOMEWRAPEXTEND = 2454;
    SCI_LINECOPY = 2455;
    SCI_MOVECARETINSIDEVIEW = 2401;
    SCI_LINELENGTH = 2350;
    SCI_BRACEHIGHLIGHT = 2351;
    SCI_BRACEBADLIGHT = 2352;
    SCI_BRACEMATCH = 2353;
    SCI_GETVIEWEOL = 2355;
    SCI_SETVIEWEOL = 2356;
    SCI_GETDOCPOINTER = 2357;
    SCI_SETDOCPOINTER = 2358;
    SCI_SETMODEVENTMASK = 2359;
    EDGE_NONE = 0;
    EDGE_LINE = 1;
    EDGE_BACKGROUND = 2;
    SCI_GETEDGECOLUMN = 2360;
    SCI_SETEDGECOLUMN = 2361;
    SCI_GETEDGEMODE = 2362;
    SCI_SETEDGEMODE = 2363;
    SCI_GETEDGECOLOUR = 2364;
    SCI_SETEDGECOLOUR = 2365;
    SCI_SEARCHANCHOR = 2366;
    SCI_SEARCHNEXT = 2367;
    SCI_SEARCHPREV = 2368;
    SCI_LINESONSCREEN = 2370;
    SCI_USEPOPUP = 2371;
    SCI_SELECTIONISRECTANGLE = 2372;
    SCI_SETZOOM = 2373;
    SCI_GETZOOM = 2374;
    SCI_CREATEDOCUMENT = 2375;
    SCI_ADDREFDOCUMENT = 2376;
    SCI_RELEASEDOCUMENT = 2377;
    SCI_GETMODEVENTMASK = 2378;
    SCI_SETFOCUSEX = 2380;
    SCI_GETFOCUS = 2381;
    SCI_SETSTATUS = 2382;
    SCI_GETSTATUS = 2383;
    SCI_SETMOUSEDOWNCAPTURES = 2384;
    SCI_GETMOUSEDOWNCAPTURES = 2385;
    SC_CURSORNORMAL = -1;
    SC_CURSORWAIT = 4;
    SCI_SETCURSOR = 2386;
    SCI_GETCURSOR = 2387;
    SCI_SETCONTROLCHARSYMBOL = 2388;
    SCI_GETCONTROLCHARSYMBOL = 2389;
    SCI_WORDPARTLEFT = 2390;
    SCI_WORDPARTLEFTEXTEND = 2391;
    SCI_WORDPARTRIGHT = 2392;
    SCI_WORDPARTRIGHTEXTEND = 2393;
    VISIBLE_SLOP = $01;
    VISIBLE_STRICT = $04;
    SCI_SETVISIBLEPOLICY = 2394;
    SCI_DELLINELEFT = 2395;
    SCI_DELLINERIGHT = 2396;
    SCI_SETXOFFSET = 2397;
    SCI_GETXOFFSET = 2398;
    SCI_CHOOSECARETX = 2399;
    SCI_GRABFOCUS = 2400;
    CARET_SLOP = $01;
    CARET_STRICT = $04;
    CARET_JUMPS = $10;
    CARET_EVEN = $08;
    SCI_SETXCARETPOLICY = 2402;
    SCI_SETYCARETPOLICY = 2403;
    SCI_SETPRINTWRAPMODE = 2406;
    SCI_GETPRINTWRAPMODE = 2407;
    SCI_SETHOTSPOTACTIVEFORE = 2410;
    SCI_SETHOTSPOTACTIVEBACK = 2411;
    SCI_SETHOTSPOTACTIVEUNDERLINE = 2412;
    SCI_SETHOTSPOTSINGLELINE = 2421;
    SCI_PARADOWN = 2413;
    SCI_PARADOWNEXTEND = 2414;
    SCI_PARAUP = 2415;
    SCI_PARAUPEXTEND = 2416;
    SCI_POSITIONBEFORE = 2417;
    SCI_POSITIONAFTER = 2418;
    SCI_COPYRANGE = 2419;
    SCI_COPYTEXT = 2420;
    SC_SEL_STREAM = 0;
    SC_SEL_RECTANGLE = 1;
    SC_SEL_LINES = 2;
    SCI_SETSELECTIONMODE = 2422;
    SCI_GETSELECTIONMODE = 2423;
    SCI_GETLINESELSTARTPOSITION = 2424;
    SCI_GETLINESELENDPOSITION = 2425;
    SCI_LINEDOWNRECTEXTEND = 2426;
    SCI_LINEUPRECTEXTEND = 2427;
    SCI_CHARLEFTRECTEXTEND = 2428;
    SCI_CHARRIGHTRECTEXTEND = 2429;
    SCI_HOMERECTEXTEND = 2430;
    SCI_VCHOMERECTEXTEND = 2431;
    SCI_LINEENDRECTEXTEND = 2432;
    SCI_PAGEUPRECTEXTEND = 2433;
    SCI_PAGEDOWNRECTEXTEND = 2434;
    SCI_STUTTEREDPAGEUP = 2435;
    SCI_STUTTEREDPAGEUPEXTEND = 2436;
    SCI_STUTTEREDPAGEDOWN = 2437;
    SCI_STUTTEREDPAGEDOWNEXTEND = 2438;
    SCI_WORDLEFTEND = 2439;
    SCI_WORDLEFTENDEXTEND = 2440;
    SCI_WORDRIGHTEND = 2441;
    SCI_WORDRIGHTENDEXTEND = 2442;
    SCI_SETWHITESPACECHARS = 2443;
    SCI_SETCHARSDEFAULT = 2444;
    SCI_AUTOCGETCURRENT = 2445;
    SCI_ALLOCATE = 2446;
    SCI_FINDCOLUMN = 2456;
    SCI_GETCARETSTICKY = 2457;
    SCI_SETCARETSTICKY = 2458;
    SCI_TOGGLECARETSTICKY = 2459;
    SCI_SETPASTECONVERTENDINGS = 2467;
    SCI_GETPASTECONVERTENDINGS = 2468;
    SCI_SELECTIONDUPLICATE = 2469;
    SC_ALPHA_TRANSPARENT = 0;
    SC_ALPHA_OPAQUE = 255;
    SC_ALPHA_NOALPHA = 256;
    SCI_SETCARETLINEBACKALPHA = 2470;
    SCI_GETCARETLINEBACKALPHA = 2471;
    SCI_STARTRECORD = 3001;
    SCI_STOPRECORD = 3002;
    SCI_SETLEXER = 4001;
    SCI_GETLEXER = 4002;
    SCI_COLOURISE = 4003;
    SCI_SETPROPERTY = 4004;
    KEYWORDSET_MAX = 8;
    SCI_SETKEYWORDS = 4005;
    SCI_SETLEXERLANGUAGE = 4006;
    SCI_LOADLEXERLIBRARY = 4007;
    SCI_GETPROPERTY = 4008;
    SCI_GETPROPERTYEXPANDED = 4009;
    SCI_GETPROPERTYINT = 4010;
    SCI_GETSTYLEBITSNEEDED = 4011;
    SC_MOD_INSERTTEXT = $1;
    SC_MOD_DELETETEXT = $2;
    SC_MOD_CHANGESTYLE = $4;
    SC_MOD_CHANGEFOLD = $8;
    SC_PERFORMED_USER = $10;
    SC_PERFORMED_UNDO = $20;
    SC_PERFORMED_REDO = $40;
    SC_MULTISTEPUNDOREDO = $80;
    SC_LASTSTEPINUNDOREDO = $100;
    SC_MOD_CHANGEMARKER = $200;
    SC_MOD_BEFOREINSERT = $400;
    SC_MOD_BEFOREDELETE = $800;
    SC_MULTILINEUNDOREDO = $1000;
    SC_MODEVENTMASKALL = $1FFF;
    SCEN_CHANGE = 768;
    SCEN_SETFOCUS = 512;
    SCEN_KILLFOCUS = 256;
    SCK_DOWN = 300;
    SCK_UP = 301;
    SCK_LEFT = 302;
    SCK_RIGHT = 303;
    SCK_HOME = 304;
    SCK_END = 305;
    SCK_PRIOR = 306;
    SCK_NEXT = 307;
    SCK_DELETE = 308;
    SCK_INSERT = 309;
    SCK_ESCAPE = 7;
    SCK_BACK = 8;
    SCK_TAB = 9;
    SCK_RETURN = 13;
    SCK_ADD = 310;
    SCK_SUBTRACT = 311;
    SCK_DIVIDE = 312;
    SCK_WIN = 313;
    SCK_RWIN = 314;
    SCK_MENU = 315;
    SCMOD_NORM = 0;
    SCMOD_SHIFT = 1;
    SCMOD_CTRL = 2;
    SCMOD_ALT = 4;
    SCLEX_CONTAINER = 0;
    SCLEX_NULL = 1;
    SCLEX_PYTHON = 2;
    SCLEX_CPP = 3;
    SCLEX_HTML = 4;
    SCLEX_XML = 5;
    SCLEX_PERL = 6;
    SCLEX_SQL = 7;
    SCLEX_VB = 8;
    SCLEX_PROPERTIES = 9;
    SCLEX_ERRORLIST = 10;
    SCLEX_MAKEFILE = 11;
    SCLEX_BATCH = 12;
    SCLEX_XCODE = 13;
    SCLEX_LATEX = 14;
    SCLEX_LUA = 15;
    SCLEX_DIFF = 16;
    SCLEX_CONF = 17;
    SCLEX_PASCAL = 18;
    SCLEX_AVE = 19;
    SCLEX_ADA = 20;
    SCLEX_LISP = 21;
    SCLEX_RUBY = 22;
    SCLEX_EIFFEL = 23;
    SCLEX_EIFFELKW = 24;
    SCLEX_TCL = 25;
    SCLEX_NNCRONTAB = 26;
    SCLEX_BULLANT = 27;
    SCLEX_VBSCRIPT = 28;
    SCLEX_BAAN = 31;
    SCLEX_MATLAB = 32;
    SCLEX_SCRIPTOL = 33;
    SCLEX_ASM = 34;
    SCLEX_CPPNOCASE = 35;
    SCLEX_FORTRAN = 36;
    SCLEX_F77 = 37;
    SCLEX_CSS = 38;
    SCLEX_POV = 39;
    SCLEX_LOUT = 40;
    SCLEX_ESCRIPT = 41;
    SCLEX_PS = 42;
    SCLEX_NSIS = 43;
    SCLEX_MMIXAL = 44;
    SCLEX_CLW = 45;
    SCLEX_CLWNOCASE = 46;
    SCLEX_LOT = 47;
    SCLEX_YAML = 48;
    SCLEX_TEX = 49;
    SCLEX_METAPOST = 50;
    SCLEX_POWERBASIC = 51;
    SCLEX_FORTH = 52;
    SCLEX_ERLANG = 53;
    SCLEX_OCTAVE = 54;
    SCLEX_MSSQL = 55;
    SCLEX_VERILOG = 56;
    SCLEX_KIX = 57;
    SCLEX_GUI4CLI = 58;
    SCLEX_SPECMAN = 59;
    SCLEX_AU3 = 60;
    SCLEX_APDL = 61;
    SCLEX_BASH = 62;
    SCLEX_ASN1 = 63;
    SCLEX_VHDL = 64;
    SCLEX_CAML = 65;
    SCLEX_BLITZBASIC = 66;
    SCLEX_PUREBASIC = 67;
    SCLEX_HASKELL = 68;
    SCLEX_PHPSCRIPT = 69;
    SCLEX_TADS3 = 70;
    SCLEX_REBOL = 71;
    SCLEX_SMALLTALK = 72;
    SCLEX_FLAGSHIP = 73;
    SCLEX_CSOUND = 74;
    SCLEX_FREEBASIC = 75;
    SCLEX_INNOSETUP = 76;
    SCLEX_OPAL = 77;
    SCLEX_SPICE = 78;
    SCLEX_AUTOMATIC = 1000;
    SCE_P_DEFAULT = 0;
    SCE_P_COMMENTLINE = 1;
    SCE_P_NUMBER = 2;
    SCE_P_STRING = 3;
    SCE_P_CHARACTER = 4;
    SCE_P_WORD = 5;
    SCE_P_TRIPLE = 6;
    SCE_P_TRIPLEDOUBLE = 7;
    SCE_P_CLASSNAME = 8;
    SCE_P_DEFNAME = 9;
    SCE_P_OPERATOR = 10;
    SCE_P_IDENTIFIER = 11;
    SCE_P_COMMENTBLOCK = 12;
    SCE_P_STRINGEOL = 13;
    SCE_P_WORD2 = 14;
    SCE_P_DECORATOR = 15;
    SCE_C_DEFAULT = 0;
    SCE_C_COMMENT = 1;
    SCE_C_COMMENTLINE = 2;
    SCE_C_COMMENTDOC = 3;
    SCE_C_NUMBER = 4;
    SCE_C_WORD = 5;
    SCE_C_STRING = 6;
    SCE_C_CHARACTER = 7;
    SCE_C_UUID = 8;
    SCE_C_PREPROCESSOR = 9;
    SCE_C_OPERATOR = 10;
    SCE_C_IDENTIFIER = 11;
    SCE_C_STRINGEOL = 12;
    SCE_C_VERBATIM = 13;
    SCE_C_REGEX = 14;
    SCE_C_COMMENTLINEDOC = 15;
    SCE_C_WORD2 = 16;
    SCE_C_COMMENTDOCKEYWORD = 17;
    SCE_C_COMMENTDOCKEYWORDERROR = 18;
    SCE_C_GLOBALCLASS = 19;
    SCE_TCL_DEFAULT = 0;
    SCE_TCL_COMMENT = 1;
    SCE_TCL_COMMENTLINE = 2;
    SCE_TCL_NUMBER = 3;
    SCE_TCL_WORD_IN_QUOTE = 4;
    SCE_TCL_IN_QUOTE = 5;
    SCE_TCL_OPERATOR = 6;
    SCE_TCL_IDENTIFIER = 7;
    SCE_TCL_SUBSTITUTION = 8;
    SCE_TCL_SUB_BRACE = 9;
    SCE_TCL_MODIFIER = 10;
    SCE_TCL_EXPAND = 11;
    SCE_TCL_WORD = 12;
    SCE_TCL_WORD2 = 13;
    SCE_TCL_WORD3 = 14;
    SCE_TCL_WORD4 = 15;
    SCE_TCL_WORD5 = 16;
    SCE_TCL_WORD6 = 17;
    SCE_TCL_WORD7 = 18;
    SCE_TCL_WORD8 = 19;
    SCE_TCL_COMMENT_BOX = 20;
    SCE_TCL_BLOCK_COMMENT = 21;
    SCE_H_DEFAULT = 0;
    SCE_H_TAG = 1;
    SCE_H_TAGUNKNOWN = 2;
    SCE_H_ATTRIBUTE = 3;
    SCE_H_ATTRIBUTEUNKNOWN = 4;
    SCE_H_NUMBER = 5;
    SCE_H_DOUBLESTRING = 6;
    SCE_H_SINGLESTRING = 7;
    SCE_H_OTHER = 8;
    SCE_H_COMMENT = 9;
    SCE_H_ENTITY = 10;
    SCE_H_TAGEND = 11;
    SCE_H_XMLSTART = 12;
    SCE_H_XMLEND = 13;
    SCE_H_SCRIPT = 14;
    SCE_H_ASP = 15;
    SCE_H_ASPAT = 16;
    SCE_H_CDATA = 17;
    SCE_H_QUESTION = 18;
    SCE_H_VALUE = 19;
    SCE_H_XCCOMMENT = 20;
    SCE_H_SGML_DEFAULT = 21;
    SCE_H_SGML_COMMAND = 22;
    SCE_H_SGML_1ST_PARAM = 23;
    SCE_H_SGML_DOUBLESTRING = 24;
    SCE_H_SGML_SIMPLESTRING = 25;
    SCE_H_SGML_ERROR = 26;
    SCE_H_SGML_SPECIAL = 27;
    SCE_H_SGML_ENTITY = 28;
    SCE_H_SGML_COMMENT = 29;
    SCE_H_SGML_1ST_PARAM_COMMENT = 30;
    SCE_H_SGML_BLOCK_DEFAULT = 31;
    SCE_HJ_START = 40;
    SCE_HJ_DEFAULT = 41;
    SCE_HJ_COMMENT = 42;
    SCE_HJ_COMMENTLINE = 43;
    SCE_HJ_COMMENTDOC = 44;
    SCE_HJ_NUMBER = 45;
    SCE_HJ_WORD = 46;
    SCE_HJ_KEYWORD = 47;
    SCE_HJ_DOUBLESTRING = 48;
    SCE_HJ_SINGLESTRING = 49;
    SCE_HJ_SYMBOLS = 50;
    SCE_HJ_STRINGEOL = 51;
    SCE_HJ_REGEX = 52;
    SCE_HJA_START = 55;
    SCE_HJA_DEFAULT = 56;
    SCE_HJA_COMMENT = 57;
    SCE_HJA_COMMENTLINE = 58;
    SCE_HJA_COMMENTDOC = 59;
    SCE_HJA_NUMBER = 60;
    SCE_HJA_WORD = 61;
    SCE_HJA_KEYWORD = 62;
    SCE_HJA_DOUBLESTRING = 63;
    SCE_HJA_SINGLESTRING = 64;
    SCE_HJA_SYMBOLS = 65;
    SCE_HJA_STRINGEOL = 66;
    SCE_HJA_REGEX = 67;
    SCE_HB_START = 70;
    SCE_HB_DEFAULT = 71;
    SCE_HB_COMMENTLINE = 72;
    SCE_HB_NUMBER = 73;
    SCE_HB_WORD = 74;
    SCE_HB_STRING = 75;
    SCE_HB_IDENTIFIER = 76;
    SCE_HB_STRINGEOL = 77;
    SCE_HBA_START = 80;
    SCE_HBA_DEFAULT = 81;
    SCE_HBA_COMMENTLINE = 82;
    SCE_HBA_NUMBER = 83;
    SCE_HBA_WORD = 84;
    SCE_HBA_STRING = 85;
    SCE_HBA_IDENTIFIER = 86;
    SCE_HBA_STRINGEOL = 87;
    SCE_HP_START = 90;
    SCE_HP_DEFAULT = 91;
    SCE_HP_COMMENTLINE = 92;
    SCE_HP_NUMBER = 93;
    SCE_HP_STRING = 94;
    SCE_HP_CHARACTER = 95;
    SCE_HP_WORD = 96;
    SCE_HP_TRIPLE = 97;
    SCE_HP_TRIPLEDOUBLE = 98;
    SCE_HP_CLASSNAME = 99;
    SCE_HP_DEFNAME = 100;
    SCE_HP_OPERATOR = 101;
    SCE_HP_IDENTIFIER = 102;
    SCE_HPHP_COMPLEX_VARIABLE = 104;
    SCE_HPA_START = 105;
    SCE_HPA_DEFAULT = 106;
    SCE_HPA_COMMENTLINE = 107;
    SCE_HPA_NUMBER = 108;
    SCE_HPA_STRING = 109;
    SCE_HPA_CHARACTER = 110;
    SCE_HPA_WORD = 111;
    SCE_HPA_TRIPLE = 112;
    SCE_HPA_TRIPLEDOUBLE = 113;
    SCE_HPA_CLASSNAME = 114;
    SCE_HPA_DEFNAME = 115;
    SCE_HPA_OPERATOR = 116;
    SCE_HPA_IDENTIFIER = 117;
    SCE_HPHP_DEFAULT = 118;
    SCE_HPHP_HSTRING = 119;
    SCE_HPHP_SIMPLESTRING = 120;
    SCE_HPHP_WORD = 121;
    SCE_HPHP_NUMBER = 122;
    SCE_HPHP_VARIABLE = 123;
    SCE_HPHP_COMMENT = 124;
    SCE_HPHP_COMMENTLINE = 125;
    SCE_HPHP_HSTRING_VARIABLE = 126;
    SCE_HPHP_OPERATOR = 127;
    SCE_PL_DEFAULT = 0;
    SCE_PL_ERROR = 1;
    SCE_PL_COMMENTLINE = 2;
    SCE_PL_POD = 3;
    SCE_PL_NUMBER = 4;
    SCE_PL_WORD = 5;
    SCE_PL_STRING = 6;
    SCE_PL_CHARACTER = 7;
    SCE_PL_PUNCTUATION = 8;
    SCE_PL_PREPROCESSOR = 9;
    SCE_PL_OPERATOR = 10;
    SCE_PL_IDENTIFIER = 11;
    SCE_PL_SCALAR = 12;
    SCE_PL_ARRAY = 13;
    SCE_PL_HASH = 14;
    SCE_PL_SYMBOLTABLE = 15;
    SCE_PL_VARIABLE_INDEXER = 16;
    SCE_PL_REGEX = 17;
    SCE_PL_REGSUBST = 18;
    SCE_PL_LONGQUOTE = 19;
    SCE_PL_BACKTICKS = 20;
    SCE_PL_DATASECTION = 21;
    SCE_PL_HERE_DELIM = 22;
    SCE_PL_HERE_Q = 23;
    SCE_PL_HERE_QQ = 24;
    SCE_PL_HERE_QX = 25;
    SCE_PL_STRING_Q = 26;
    SCE_PL_STRING_QQ = 27;
    SCE_PL_STRING_QX = 28;
    SCE_PL_STRING_QR = 29;
    SCE_PL_STRING_QW = 30;
    SCE_PL_POD_VERB = 31;
    SCE_RB_DEFAULT = 0;
    SCE_RB_ERROR = 1;
    SCE_RB_COMMENTLINE = 2;
    SCE_RB_POD = 3;
    SCE_RB_NUMBER = 4;
    SCE_RB_WORD = 5;
    SCE_RB_STRING = 6;
    SCE_RB_CHARACTER = 7;
    SCE_RB_CLASSNAME = 8;
    SCE_RB_DEFNAME = 9;
    SCE_RB_OPERATOR = 10;
    SCE_RB_IDENTIFIER = 11;
    SCE_RB_REGEX = 12;
    SCE_RB_GLOBAL = 13;
    SCE_RB_SYMBOL = 14;
    SCE_RB_MODULE_NAME = 15;
    SCE_RB_INSTANCE_VAR = 16;
    SCE_RB_CLASS_VAR = 17;
    SCE_RB_BACKTICKS = 18;
    SCE_RB_DATASECTION = 19;
    SCE_RB_HERE_DELIM = 20;
    SCE_RB_HERE_Q = 21;
    SCE_RB_HERE_QQ = 22;
    SCE_RB_HERE_QX = 23;
    SCE_RB_STRING_Q = 24;
    SCE_RB_STRING_QQ = 25;
    SCE_RB_STRING_QX = 26;
    SCE_RB_STRING_QR = 27;
    SCE_RB_STRING_QW = 28;
    SCE_RB_WORD_DEMOTED = 29;
    SCE_RB_STDIN = 30;
    SCE_RB_STDOUT = 31;
    SCE_RB_STDERR = 40;
    SCE_RB_UPPER_BOUND = 41;
    SCE_B_DEFAULT = 0;
    SCE_B_COMMENT = 1;
    SCE_B_NUMBER = 2;
    SCE_B_KEYWORD = 3;
    SCE_B_STRING = 4;
    SCE_B_PREPROCESSOR = 5;
    SCE_B_OPERATOR = 6;
    SCE_B_IDENTIFIER = 7;
    SCE_B_DATE = 8;
    SCE_B_STRINGEOL = 9;
    SCE_B_KEYWORD2 = 10;
    SCE_B_KEYWORD3 = 11;
    SCE_B_KEYWORD4 = 12;
    SCE_B_CONSTANT = 13;
    SCE_B_ASM = 14;
    SCE_B_LABEL = 15;
    SCE_B_ERROR = 16;
    SCE_B_HEXNUMBER = 17;
    SCE_B_BINNUMBER = 18;
    SCE_PROPS_DEFAULT = 0;
    SCE_PROPS_COMMENT = 1;
    SCE_PROPS_SECTION = 2;
    SCE_PROPS_ASSIGNMENT = 3;
    SCE_PROPS_DEFVAL = 4;
    SCE_PROPS_KEY = 5;
    SCE_L_DEFAULT = 0;
    SCE_L_COMMAND = 1;
    SCE_L_TAG = 2;
    SCE_L_MATH = 3;
    SCE_L_COMMENT = 4;
    SCE_LUA_DEFAULT = 0;
    SCE_LUA_COMMENT = 1;
    SCE_LUA_COMMENTLINE = 2;
    SCE_LUA_COMMENTDOC = 3;
    SCE_LUA_NUMBER = 4;
    SCE_LUA_WORD = 5;
    SCE_LUA_STRING = 6;
    SCE_LUA_CHARACTER = 7;
    SCE_LUA_LITERALSTRING = 8;
    SCE_LUA_PREPROCESSOR = 9;
    SCE_LUA_OPERATOR = 10;
    SCE_LUA_IDENTIFIER = 11;
    SCE_LUA_STRINGEOL = 12;
    SCE_LUA_WORD2 = 13;
    SCE_LUA_WORD3 = 14;
    SCE_LUA_WORD4 = 15;
    SCE_LUA_WORD5 = 16;
    SCE_LUA_WORD6 = 17;
    SCE_LUA_WORD7 = 18;
    SCE_LUA_WORD8 = 19;
    SCE_ERR_DEFAULT = 0;
    SCE_ERR_PYTHON = 1;
    SCE_ERR_GCC = 2;
    SCE_ERR_MS = 3;
    SCE_ERR_CMD = 4;
    SCE_ERR_BORLAND = 5;
    SCE_ERR_PERL = 6;
    SCE_ERR_NET = 7;
    SCE_ERR_LUA = 8;
    SCE_ERR_CTAG = 9;
    SCE_ERR_DIFF_CHANGED = 10;
    SCE_ERR_DIFF_ADDITION = 11;
    SCE_ERR_DIFF_DELETION = 12;
    SCE_ERR_DIFF_MESSAGE = 13;
    SCE_ERR_PHP = 14;
    SCE_ERR_ELF = 15;
    SCE_ERR_IFC = 16;
    SCE_ERR_IFORT = 17;
    SCE_ERR_ABSF = 18;
    SCE_ERR_TIDY = 19;
    SCE_ERR_JAVA_STACK = 20;
    SCE_BAT_DEFAULT = 0;
    SCE_BAT_COMMENT = 1;
    SCE_BAT_WORD = 2;
    SCE_BAT_LABEL = 3;
    SCE_BAT_HIDE = 4;
    SCE_BAT_COMMAND = 5;
    SCE_BAT_IDENTIFIER = 6;
    SCE_BAT_OPERATOR = 7;
    SCE_MAKE_DEFAULT = 0;
    SCE_MAKE_COMMENT = 1;
    SCE_MAKE_PREPROCESSOR = 2;
    SCE_MAKE_IDENTIFIER = 3;
    SCE_MAKE_OPERATOR = 4;
    SCE_MAKE_TARGET = 5;
    SCE_MAKE_IDEOL = 9;
    SCE_DIFF_DEFAULT = 0;
    SCE_DIFF_COMMENT = 1;
    SCE_DIFF_COMMAND = 2;
    SCE_DIFF_HEADER = 3;
    SCE_DIFF_POSITION = 4;
    SCE_DIFF_DELETED = 5;
    SCE_DIFF_ADDED = 6;
    SCE_CONF_DEFAULT = 0;
    SCE_CONF_COMMENT = 1;
    SCE_CONF_NUMBER = 2;
    SCE_CONF_IDENTIFIER = 3;
    SCE_CONF_EXTENSION = 4;
    SCE_CONF_PARAMETER = 5;
    SCE_CONF_STRING = 6;
    SCE_CONF_OPERATOR = 7;
    SCE_CONF_IP = 8;
    SCE_CONF_DIRECTIVE = 9;
    SCE_AVE_DEFAULT = 0;
    SCE_AVE_COMMENT = 1;
    SCE_AVE_NUMBER = 2;
    SCE_AVE_WORD = 3;
    SCE_AVE_STRING = 6;
    SCE_AVE_ENUM = 7;
    SCE_AVE_STRINGEOL = 8;
    SCE_AVE_IDENTIFIER = 9;
    SCE_AVE_OPERATOR = 10;
    SCE_AVE_WORD1 = 11;
    SCE_AVE_WORD2 = 12;
    SCE_AVE_WORD3 = 13;
    SCE_AVE_WORD4 = 14;
    SCE_AVE_WORD5 = 15;
    SCE_AVE_WORD6 = 16;
    SCE_ADA_DEFAULT = 0;
    SCE_ADA_WORD = 1;
    SCE_ADA_IDENTIFIER = 2;
    SCE_ADA_NUMBER = 3;
    SCE_ADA_DELIMITER = 4;
    SCE_ADA_CHARACTER = 5;
    SCE_ADA_CHARACTEREOL = 6;
    SCE_ADA_STRING = 7;
    SCE_ADA_STRINGEOL = 8;
    SCE_ADA_LABEL = 9;
    SCE_ADA_COMMENTLINE = 10;
    SCE_ADA_ILLEGAL = 11;
    SCE_BAAN_DEFAULT = 0;
    SCE_BAAN_COMMENT = 1;
    SCE_BAAN_COMMENTDOC = 2;
    SCE_BAAN_NUMBER = 3;
    SCE_BAAN_WORD = 4;
    SCE_BAAN_STRING = 5;
    SCE_BAAN_PREPROCESSOR = 6;
    SCE_BAAN_OPERATOR = 7;
    SCE_BAAN_IDENTIFIER = 8;
    SCE_BAAN_STRINGEOL = 9;
    SCE_BAAN_WORD2 = 10;
    SCE_LISP_DEFAULT = 0;
    SCE_LISP_COMMENT = 1;
    SCE_LISP_NUMBER = 2;
    SCE_LISP_KEYWORD = 3;
    SCE_LISP_KEYWORD_KW = 4;
    SCE_LISP_SYMBOL = 5;
    SCE_LISP_STRING = 6;
    SCE_LISP_STRINGEOL = 8;
    SCE_LISP_IDENTIFIER = 9;
    SCE_LISP_OPERATOR = 10;
    SCE_LISP_SPECIAL = 11;
    SCE_LISP_MULTI_COMMENT = 12;
    SCE_EIFFEL_DEFAULT = 0;
    SCE_EIFFEL_COMMENTLINE = 1;
    SCE_EIFFEL_NUMBER = 2;
    SCE_EIFFEL_WORD = 3;
    SCE_EIFFEL_STRING = 4;
    SCE_EIFFEL_CHARACTER = 5;
    SCE_EIFFEL_OPERATOR = 6;
    SCE_EIFFEL_IDENTIFIER = 7;
    SCE_EIFFEL_STRINGEOL = 8;
    SCE_NNCRONTAB_DEFAULT = 0;
    SCE_NNCRONTAB_COMMENT = 1;
    SCE_NNCRONTAB_TASK = 2;
    SCE_NNCRONTAB_SECTION = 3;
    SCE_NNCRONTAB_KEYWORD = 4;
    SCE_NNCRONTAB_MODIFIER = 5;
    SCE_NNCRONTAB_ASTERISK = 6;
    SCE_NNCRONTAB_NUMBER = 7;
    SCE_NNCRONTAB_STRING = 8;
    SCE_NNCRONTAB_ENVIRONMENT = 9;
    SCE_NNCRONTAB_IDENTIFIER = 10;
    SCE_FORTH_DEFAULT = 0;
    SCE_FORTH_COMMENT = 1;
    SCE_FORTH_COMMENT_ML = 2;
    SCE_FORTH_IDENTIFIER = 3;
    SCE_FORTH_CONTROL = 4;
    SCE_FORTH_KEYWORD = 5;
    SCE_FORTH_DEFWORD = 6;
    SCE_FORTH_PREWORD1 = 7;
    SCE_FORTH_PREWORD2 = 8;
    SCE_FORTH_NUMBER = 9;
    SCE_FORTH_STRING = 10;
    SCE_FORTH_LOCALE = 11;
    SCE_MATLAB_DEFAULT = 0;
    SCE_MATLAB_COMMENT = 1;
    SCE_MATLAB_COMMAND = 2;
    SCE_MATLAB_NUMBER = 3;
    SCE_MATLAB_KEYWORD = 4;
    SCE_MATLAB_STRING = 5;
    SCE_MATLAB_OPERATOR = 6;
    SCE_MATLAB_IDENTIFIER = 7;
    SCE_MATLAB_DOUBLEQUOTESTRING = 8;
    SCE_SCRIPTOL_DEFAULT = 0;
    SCE_SCRIPTOL_WHITE = 1;
    SCE_SCRIPTOL_COMMENTLINE = 2;
    SCE_SCRIPTOL_PERSISTENT = 3;
    SCE_SCRIPTOL_CSTYLE = 4;
    SCE_SCRIPTOL_COMMENTBLOCK = 5;
    SCE_SCRIPTOL_NUMBER = 6;
    SCE_SCRIPTOL_STRING = 7;
    SCE_SCRIPTOL_CHARACTER = 8;
    SCE_SCRIPTOL_STRINGEOL = 9;
    SCE_SCRIPTOL_KEYWORD = 10;
    SCE_SCRIPTOL_OPERATOR = 11;
    SCE_SCRIPTOL_IDENTIFIER = 12;
    SCE_SCRIPTOL_TRIPLE = 13;
    SCE_SCRIPTOL_CLASSNAME = 14;
    SCE_SCRIPTOL_PREPROCESSOR = 15;
    SCE_ASM_DEFAULT = 0;
    SCE_ASM_COMMENT = 1;
    SCE_ASM_NUMBER = 2;
    SCE_ASM_STRING = 3;
    SCE_ASM_OPERATOR = 4;
    SCE_ASM_IDENTIFIER = 5;
    SCE_ASM_CPUINSTRUCTION = 6;
    SCE_ASM_MATHINSTRUCTION = 7;
    SCE_ASM_REGISTER = 8;
    SCE_ASM_DIRECTIVE = 9;
    SCE_ASM_DIRECTIVEOPERAND = 10;
    SCE_ASM_COMMENTBLOCK = 11;
    SCE_ASM_CHARACTER = 12;
    SCE_ASM_STRINGEOL = 13;
    SCE_ASM_EXTINSTRUCTION = 14;
    SCE_F_DEFAULT = 0;
    SCE_F_COMMENT = 1;
    SCE_F_NUMBER = 2;
    SCE_F_STRING1 = 3;
    SCE_F_STRING2 = 4;
    SCE_F_STRINGEOL = 5;
    SCE_F_OPERATOR = 6;
    SCE_F_IDENTIFIER = 7;
    SCE_F_WORD = 8;
    SCE_F_WORD2 = 9;
    SCE_F_WORD3 = 10;
    SCE_F_PREPROCESSOR = 11;
    SCE_F_OPERATOR2 = 12;
    SCE_F_LABEL = 13;
    SCE_F_CONTINUATION = 14;
    SCE_CSS_DEFAULT = 0;
    SCE_CSS_TAG = 1;
    SCE_CSS_CLASS = 2;
    SCE_CSS_PSEUDOCLASS = 3;
    SCE_CSS_UNKNOWN_PSEUDOCLASS = 4;
    SCE_CSS_OPERATOR = 5;
    SCE_CSS_IDENTIFIER = 6;
    SCE_CSS_UNKNOWN_IDENTIFIER = 7;
    SCE_CSS_VALUE = 8;
    SCE_CSS_COMMENT = 9;
    SCE_CSS_ID = 10;
    SCE_CSS_IMPORTANT = 11;
    SCE_CSS_DIRECTIVE = 12;
    SCE_CSS_DOUBLESTRING = 13;
    SCE_CSS_SINGLESTRING = 14;
    SCE_CSS_IDENTIFIER2 = 15;
    SCE_CSS_ATTRIBUTE = 16;
    SCE_POV_DEFAULT = 0;
    SCE_POV_COMMENT = 1;
    SCE_POV_COMMENTLINE = 2;
    SCE_POV_NUMBER = 3;
    SCE_POV_OPERATOR = 4;
    SCE_POV_IDENTIFIER = 5;
    SCE_POV_STRING = 6;
    SCE_POV_STRINGEOL = 7;
    SCE_POV_DIRECTIVE = 8;
    SCE_POV_BADDIRECTIVE = 9;
    SCE_POV_WORD2 = 10;
    SCE_POV_WORD3 = 11;
    SCE_POV_WORD4 = 12;
    SCE_POV_WORD5 = 13;
    SCE_POV_WORD6 = 14;
    SCE_POV_WORD7 = 15;
    SCE_POV_WORD8 = 16;
    SCE_LOUT_DEFAULT = 0;
    SCE_LOUT_COMMENT = 1;
    SCE_LOUT_NUMBER = 2;
    SCE_LOUT_WORD = 3;
    SCE_LOUT_WORD2 = 4;
    SCE_LOUT_WORD3 = 5;
    SCE_LOUT_WORD4 = 6;
    SCE_LOUT_STRING = 7;
    SCE_LOUT_OPERATOR = 8;
    SCE_LOUT_IDENTIFIER = 9;
    SCE_LOUT_STRINGEOL = 10;
    SCE_ESCRIPT_DEFAULT = 0;
    SCE_ESCRIPT_COMMENT = 1;
    SCE_ESCRIPT_COMMENTLINE = 2;
    SCE_ESCRIPT_COMMENTDOC = 3;
    SCE_ESCRIPT_NUMBER = 4;
    SCE_ESCRIPT_WORD = 5;
    SCE_ESCRIPT_STRING = 6;
    SCE_ESCRIPT_OPERATOR = 7;
    SCE_ESCRIPT_IDENTIFIER = 8;
    SCE_ESCRIPT_BRACE = 9;
    SCE_ESCRIPT_WORD2 = 10;
    SCE_ESCRIPT_WORD3 = 11;
    SCE_PS_DEFAULT = 0;
    SCE_PS_COMMENT = 1;
    SCE_PS_DSC_COMMENT = 2;
    SCE_PS_DSC_VALUE = 3;
    SCE_PS_NUMBER = 4;
    SCE_PS_NAME = 5;
    SCE_PS_KEYWORD = 6;
    SCE_PS_LITERAL = 7;
    SCE_PS_IMMEVAL = 8;
    SCE_PS_PAREN_ARRAY = 9;
    SCE_PS_PAREN_DICT = 10;
    SCE_PS_PAREN_PROC = 11;
    SCE_PS_TEXT = 12;
    SCE_PS_HEXSTRING = 13;
    SCE_PS_BASE85STRING = 14;
    SCE_PS_BADSTRINGCHAR = 15;
    SCE_NSIS_DEFAULT = 0;
    SCE_NSIS_COMMENT = 1;
    SCE_NSIS_STRINGDQ = 2;
    SCE_NSIS_STRINGLQ = 3;
    SCE_NSIS_STRINGRQ = 4;
    SCE_NSIS_FUNCTION = 5;
    SCE_NSIS_VARIABLE = 6;
    SCE_NSIS_LABEL = 7;
    SCE_NSIS_USERDEFINED = 8;
    SCE_NSIS_SECTIONDEF = 9;
    SCE_NSIS_SUBSECTIONDEF = 10;
    SCE_NSIS_IFDEFINEDEF = 11;
    SCE_NSIS_MACRODEF = 12;
    SCE_NSIS_STRINGVAR = 13;
    SCE_NSIS_NUMBER = 14;
    SCE_NSIS_SECTIONGROUP = 15;
    SCE_NSIS_PAGEEX = 16;
    SCE_NSIS_FUNCTIONDEF = 17;
    SCE_NSIS_COMMENTBOX = 18;
    SCE_MMIXAL_LEADWS = 0;
    SCE_MMIXAL_COMMENT = 1;
    SCE_MMIXAL_LABEL = 2;
    SCE_MMIXAL_OPCODE = 3;
    SCE_MMIXAL_OPCODE_PRE = 4;
    SCE_MMIXAL_OPCODE_VALID = 5;
    SCE_MMIXAL_OPCODE_UNKNOWN = 6;
    SCE_MMIXAL_OPCODE_POST = 7;
    SCE_MMIXAL_OPERANDS = 8;
    SCE_MMIXAL_NUMBER = 9;
    SCE_MMIXAL_REF = 10;
    SCE_MMIXAL_CHAR = 11;
    SCE_MMIXAL_STRING = 12;
    SCE_MMIXAL_REGISTER = 13;
    SCE_MMIXAL_HEX = 14;
    SCE_MMIXAL_OPERATOR = 15;
    SCE_MMIXAL_SYMBOL = 16;
    SCE_MMIXAL_INCLUDE = 17;
    SCE_CLW_DEFAULT = 0;
    SCE_CLW_LABEL = 1;
    SCE_CLW_COMMENT = 2;
    SCE_CLW_STRING = 3;
    SCE_CLW_USER_IDENTIFIER = 4;
    SCE_CLW_INTEGER_CONSTANT = 5;
    SCE_CLW_REAL_CONSTANT = 6;
    SCE_CLW_PICTURE_STRING = 7;
    SCE_CLW_KEYWORD = 8;
    SCE_CLW_COMPILER_DIRECTIVE = 9;
    SCE_CLW_RUNTIME_EXPRESSIONS = 10;
    SCE_CLW_BUILTIN_PROCEDURES_FUNCTION = 11;
    SCE_CLW_STRUCTURE_DATA_TYPE = 12;
    SCE_CLW_ATTRIBUTE = 13;
    SCE_CLW_STANDARD_EQUATE = 14;
    SCE_CLW_ERROR = 15;
    SCE_CLW_DEPRECATED = 16;
    SCE_LOT_DEFAULT = 0;
    SCE_LOT_HEADER = 1;
    SCE_LOT_BREAK = 2;
    SCE_LOT_SET = 3;
    SCE_LOT_PASS = 4;
    SCE_LOT_FAIL = 5;
    SCE_LOT_ABORT = 6;
    SCE_YAML_DEFAULT = 0;
    SCE_YAML_COMMENT = 1;
    SCE_YAML_IDENTIFIER = 2;
    SCE_YAML_KEYWORD = 3;
    SCE_YAML_NUMBER = 4;
    SCE_YAML_REFERENCE = 5;
    SCE_YAML_DOCUMENT = 6;
    SCE_YAML_TEXT = 7;
    SCE_YAML_ERROR = 8;
    SCE_TEX_DEFAULT = 0;
    SCE_TEX_SPECIAL = 1;
    SCE_TEX_GROUP = 2;
    SCE_TEX_SYMBOL = 3;
    SCE_TEX_COMMAND = 4;
    SCE_TEX_TEXT = 5;
    SCE_METAPOST_DEFAULT = 0;
    SCE_METAPOST_SPECIAL = 1;
    SCE_METAPOST_GROUP = 2;
    SCE_METAPOST_SYMBOL = 3;
    SCE_METAPOST_COMMAND = 4;
    SCE_METAPOST_TEXT = 5;
    SCE_METAPOST_EXTRA = 6;
    SCE_ERLANG_DEFAULT = 0;
    SCE_ERLANG_COMMENT = 1;
    SCE_ERLANG_VARIABLE = 2;
    SCE_ERLANG_NUMBER = 3;
    SCE_ERLANG_KEYWORD = 4;
    SCE_ERLANG_STRING = 5;
    SCE_ERLANG_OPERATOR = 6;
    SCE_ERLANG_ATOM = 7;
    SCE_ERLANG_FUNCTION_NAME = 8;
    SCE_ERLANG_CHARACTER = 9;
    SCE_ERLANG_MACRO = 10;
    SCE_ERLANG_RECORD = 11;
    SCE_ERLANG_SEPARATOR = 12;
    SCE_ERLANG_NODE_NAME = 13;
    SCE_ERLANG_UNKNOWN = 31;
    SCE_MSSQL_DEFAULT = 0;
    SCE_MSSQL_COMMENT = 1;
    SCE_MSSQL_LINE_COMMENT = 2;
    SCE_MSSQL_NUMBER = 3;
    SCE_MSSQL_STRING = 4;
    SCE_MSSQL_OPERATOR = 5;
    SCE_MSSQL_IDENTIFIER = 6;
    SCE_MSSQL_VARIABLE = 7;
    SCE_MSSQL_COLUMN_NAME = 8;
    SCE_MSSQL_STATEMENT = 9;
    SCE_MSSQL_DATATYPE = 10;
    SCE_MSSQL_SYSTABLE = 11;
    SCE_MSSQL_GLOBAL_VARIABLE = 12;
    SCE_MSSQL_FUNCTION = 13;
    SCE_MSSQL_STORED_PROCEDURE = 14;
    SCE_MSSQL_DEFAULT_PREF_DATATYPE = 15;
    SCE_MSSQL_COLUMN_NAME_2 = 16;
    SCE_V_DEFAULT = 0;
    SCE_V_COMMENT = 1;
    SCE_V_COMMENTLINE = 2;
    SCE_V_COMMENTLINEBANG = 3;
    SCE_V_NUMBER = 4;
    SCE_V_WORD = 5;
    SCE_V_STRING = 6;
    SCE_V_WORD2 = 7;
    SCE_V_WORD3 = 8;
    SCE_V_PREPROCESSOR = 9;
    SCE_V_OPERATOR = 10;
    SCE_V_IDENTIFIER = 11;
    SCE_V_STRINGEOL = 12;
    SCE_V_USER = 19;
    SCE_KIX_DEFAULT = 0;
    SCE_KIX_COMMENT = 1;
    SCE_KIX_STRING1 = 2;
    SCE_KIX_STRING2 = 3;
    SCE_KIX_NUMBER = 4;
    SCE_KIX_VAR = 5;
    SCE_KIX_MACRO = 6;
    SCE_KIX_KEYWORD = 7;
    SCE_KIX_FUNCTIONS = 8;
    SCE_KIX_OPERATOR = 9;
    SCE_KIX_IDENTIFIER = 31;
    SCE_GC_DEFAULT = 0;
    SCE_GC_COMMENTLINE = 1;
    SCE_GC_COMMENTBLOCK = 2;
    SCE_GC_GLOBAL = 3;
    SCE_GC_EVENT = 4;
    SCE_GC_ATTRIBUTE = 5;
    SCE_GC_CONTROL = 6;
    SCE_GC_COMMAND = 7;
    SCE_GC_STRING = 8;
    SCE_GC_OPERATOR = 9;
    SCE_SN_DEFAULT = 0;
    SCE_SN_CODE = 1;
    SCE_SN_COMMENTLINE = 2;
    SCE_SN_COMMENTLINEBANG = 3;
    SCE_SN_NUMBER = 4;
    SCE_SN_WORD = 5;
    SCE_SN_STRING = 6;
    SCE_SN_WORD2 = 7;
    SCE_SN_WORD3 = 8;
    SCE_SN_PREPROCESSOR = 9;
    SCE_SN_OPERATOR = 10;
    SCE_SN_IDENTIFIER = 11;
    SCE_SN_STRINGEOL = 12;
    SCE_SN_REGEXTAG = 13;
    SCE_SN_SIGNAL = 14;
    SCE_SN_USER = 19;
    SCE_AU3_DEFAULT = 0;
    SCE_AU3_COMMENT = 1;
    SCE_AU3_COMMENTBLOCK = 2;
    SCE_AU3_NUMBER = 3;
    SCE_AU3_FUNCTION = 4;
    SCE_AU3_KEYWORD = 5;
    SCE_AU3_MACRO = 6;
    SCE_AU3_STRING = 7;
    SCE_AU3_OPERATOR = 8;
    SCE_AU3_VARIABLE = 9;
    SCE_AU3_SENT = 10;
    SCE_AU3_PREPROCESSOR = 11;
    SCE_AU3_SPECIAL = 12;
    SCE_AU3_EXPAND = 13;
    SCE_AU3_COMOBJ = 14;
    SCE_AU3_UDF = 15;
    SCE_APDL_DEFAULT = 0;
    SCE_APDL_COMMENT = 1;
    SCE_APDL_COMMENTBLOCK = 2;
    SCE_APDL_NUMBER = 3;
    SCE_APDL_STRING = 4;
    SCE_APDL_OPERATOR = 5;
    SCE_APDL_WORD = 6;
    SCE_APDL_PROCESSOR = 7;
    SCE_APDL_COMMAND = 8;
    SCE_APDL_SLASHCOMMAND = 9;
    SCE_APDL_STARCOMMAND = 10;
    SCE_APDL_ARGUMENT = 11;
    SCE_APDL_FUNCTION = 12;
    SCE_SH_DEFAULT = 0;
    SCE_SH_ERROR = 1;
    SCE_SH_COMMENTLINE = 2;
    SCE_SH_NUMBER = 3;
    SCE_SH_WORD = 4;
    SCE_SH_STRING = 5;
    SCE_SH_CHARACTER = 6;
    SCE_SH_OPERATOR = 7;
    SCE_SH_IDENTIFIER = 8;
    SCE_SH_SCALAR = 9;
    SCE_SH_PARAM = 10;
    SCE_SH_BACKTICKS = 11;
    SCE_SH_HERE_DELIM = 12;
    SCE_SH_HERE_Q = 13;
    SCE_ASN1_DEFAULT = 0;
    SCE_ASN1_COMMENT = 1;
    SCE_ASN1_IDENTIFIER = 2;
    SCE_ASN1_STRING = 3;
    SCE_ASN1_OID = 4;
    SCE_ASN1_SCALAR = 5;
    SCE_ASN1_KEYWORD = 6;
    SCE_ASN1_ATTRIBUTE = 7;
    SCE_ASN1_DESCRIPTOR = 8;
    SCE_ASN1_TYPE = 9;
    SCE_ASN1_OPERATOR = 10;
    SCE_VHDL_DEFAULT = 0;
    SCE_VHDL_COMMENT = 1;
    SCE_VHDL_COMMENTLINEBANG = 2;
    SCE_VHDL_NUMBER = 3;
    SCE_VHDL_STRING = 4;
    SCE_VHDL_OPERATOR = 5;
    SCE_VHDL_IDENTIFIER = 6;
    SCE_VHDL_STRINGEOL = 7;
    SCE_VHDL_KEYWORD = 8;
    SCE_VHDL_STDOPERATOR = 9;
    SCE_VHDL_ATTRIBUTE = 10;
    SCE_VHDL_STDFUNCTION = 11;
    SCE_VHDL_STDPACKAGE = 12;
    SCE_VHDL_STDTYPE = 13;
    SCE_VHDL_USERWORD = 14;
    SCE_CAML_DEFAULT = 0;
    SCE_CAML_IDENTIFIER = 1;
    SCE_CAML_TAGNAME = 2;
    SCE_CAML_KEYWORD = 3;
    SCE_CAML_KEYWORD2 = 4;
    SCE_CAML_KEYWORD3 = 5;
    SCE_CAML_LINENUM = 6;
    SCE_CAML_OPERATOR = 7;
    SCE_CAML_NUMBER = 8;
    SCE_CAML_CHAR = 9;
    SCE_CAML_STRING = 11;
    SCE_CAML_COMMENT = 12;
    SCE_CAML_COMMENT1 = 13;
    SCE_CAML_COMMENT2 = 14;
    SCE_CAML_COMMENT3 = 15;
    SCE_HA_DEFAULT = 0;
    SCE_HA_IDENTIFIER = 1;
    SCE_HA_KEYWORD = 2;
    SCE_HA_NUMBER = 3;
    SCE_HA_STRING = 4;
    SCE_HA_CHARACTER = 5;
    SCE_HA_CLASS = 6;
    SCE_HA_MODULE = 7;
    SCE_HA_CAPITAL = 8;
    SCE_HA_DATA = 9;
    SCE_HA_IMPORT = 10;
    SCE_HA_OPERATOR = 11;
    SCE_HA_INSTANCE = 12;
    SCE_HA_COMMENTLINE = 13;
    SCE_HA_COMMENTBLOCK = 14;
    SCE_HA_COMMENTBLOCK2 = 15;
    SCE_HA_COMMENTBLOCK3 = 16;
    SCE_T3_DEFAULT = 0;
    SCE_T3_X_DEFAULT = 1;
    SCE_T3_PREPROCESSOR = 2;
    SCE_T3_BLOCK_COMMENT = 3;
    SCE_T3_LINE_COMMENT = 4;
    SCE_T3_OPERATOR = 5;
    SCE_T3_KEYWORD = 6;
    SCE_T3_NUMBER = 7;
    SCE_T3_IDENTIFIER = 8;
    SCE_T3_S_STRING = 9;
    SCE_T3_D_STRING = 10;
    SCE_T3_X_STRING = 11;
    SCE_T3_LIB_DIRECTIVE = 12;
    SCE_T3_MSG_PARAM = 13;
    SCE_T3_HTML_TAG = 14;
    SCE_T3_HTML_DEFAULT = 15;
    SCE_T3_HTML_STRING = 16;
    SCE_T3_USER1 = 17;
    SCE_T3_USER2 = 18;
    SCE_T3_USER3 = 19;
    SCE_REBOL_DEFAULT = 0;
    SCE_REBOL_COMMENTLINE = 1;
    SCE_REBOL_COMMENTBLOCK = 2;
    SCE_REBOL_PREFACE = 3;
    SCE_REBOL_OPERATOR = 4;
    SCE_REBOL_CHARACTER = 5;
    SCE_REBOL_QUOTEDSTRING = 6;
    SCE_REBOL_BRACEDSTRING = 7;
    SCE_REBOL_NUMBER = 8;
    SCE_REBOL_PAIR = 9;
    SCE_REBOL_TUPLE = 10;
    SCE_REBOL_BINARY = 11;
    SCE_REBOL_MONEY = 12;
    SCE_REBOL_ISSUE = 13;
    SCE_REBOL_TAG = 14;
    SCE_REBOL_FILE = 15;
    SCE_REBOL_EMAIL = 16;
    SCE_REBOL_URL = 17;
    SCE_REBOL_DATE = 18;
    SCE_REBOL_TIME = 19;
    SCE_REBOL_IDENTIFIER = 20;
    SCE_REBOL_WORD = 21;
    SCE_REBOL_WORD2 = 22;
    SCE_REBOL_WORD3 = 23;
    SCE_REBOL_WORD4 = 24;
    SCE_REBOL_WORD5 = 25;
    SCE_REBOL_WORD6 = 26;
    SCE_REBOL_WORD7 = 27;
    SCE_REBOL_WORD8 = 28;
    SCE_SQL_DEFAULT = 0;
    SCE_SQL_COMMENT = 1;
    SCE_SQL_COMMENTLINE = 2;
    SCE_SQL_COMMENTDOC = 3;
    SCE_SQL_NUMBER = 4;
    SCE_SQL_WORD = 5;
    SCE_SQL_STRING = 6;
    SCE_SQL_CHARACTER = 7;
    SCE_SQL_SQLPLUS = 8;
    SCE_SQL_SQLPLUS_PROMPT = 9;
    SCE_SQL_OPERATOR = 10;
    SCE_SQL_IDENTIFIER = 11;
    SCE_SQL_SQLPLUS_COMMENT = 13;
    SCE_SQL_COMMENTLINEDOC = 15;
    SCE_SQL_WORD2 = 16;
    SCE_SQL_COMMENTDOCKEYWORD = 17;
    SCE_SQL_COMMENTDOCKEYWORDERROR = 18;
    SCE_SQL_USER1 = 19;
    SCE_SQL_USER2 = 20;
    SCE_SQL_USER3 = 21;
    SCE_SQL_USER4 = 22;
    SCE_SQL_QUOTEDIDENTIFIER = 23;
    SCE_ST_DEFAULT = 0;
    SCE_ST_STRING = 1;
    SCE_ST_NUMBER = 2;
    SCE_ST_COMMENT = 3;
    SCE_ST_SYMBOL = 4;
    SCE_ST_BINARY = 5;
    SCE_ST_BOOL = 6;
    SCE_ST_SELF = 7;
    SCE_ST_SUPER = 8;
    SCE_ST_NIL = 9;
    SCE_ST_GLOBAL = 10;
    SCE_ST_RETURN = 11;
    SCE_ST_SPECIAL = 12;
    SCE_ST_KWSEND = 13;
    SCE_ST_ASSIGN = 14;
    SCE_ST_CHARACTER = 15;
    SCE_ST_SPEC_SEL = 16;
    SCE_FS_DEFAULT = 0;
    SCE_FS_COMMENT = 1;
    SCE_FS_COMMENTLINE = 2;
    SCE_FS_COMMENTDOC = 3;
    SCE_FS_COMMENTLINEDOC = 4;
    SCE_FS_COMMENTDOCKEYWORD = 5;
    SCE_FS_COMMENTDOCKEYWORDERROR = 6;
    SCE_FS_KEYWORD = 7;
    SCE_FS_KEYWORD2 = 8;
    SCE_FS_KEYWORD3 = 9;
    SCE_FS_KEYWORD4 = 10;
    SCE_FS_NUMBER = 11;
    SCE_FS_STRING = 12;
    SCE_FS_PREPROCESSOR = 13;
    SCE_FS_OPERATOR = 14;
    SCE_FS_IDENTIFIER = 15;
    SCE_FS_DATE = 16;
    SCE_FS_STRINGEOL = 17;
    SCE_FS_CONSTANT = 18;
    SCE_FS_ASM = 19;
    SCE_FS_LABEL = 20;
    SCE_FS_ERROR = 21;
    SCE_FS_HEXNUMBER = 22;
    SCE_FS_BINNUMBER = 23;
    SCE_CSOUND_DEFAULT = 0;
    SCE_CSOUND_COMMENT = 1;
    SCE_CSOUND_NUMBER = 2;
    SCE_CSOUND_OPERATOR = 3;
    SCE_CSOUND_INSTR = 4;
    SCE_CSOUND_IDENTIFIER = 5;
    SCE_CSOUND_OPCODE = 6;
    SCE_CSOUND_HEADERSTMT = 7;
    SCE_CSOUND_USERKEYWORD = 8;
    SCE_CSOUND_COMMENTBLOCK = 9;
    SCE_CSOUND_PARAM = 10;
    SCE_CSOUND_ARATE_VAR = 11;
    SCE_CSOUND_KRATE_VAR = 12;
    SCE_CSOUND_IRATE_VAR = 13;
    SCE_CSOUND_GLOBAL_VAR = 14;
    SCE_CSOUND_STRINGEOL = 15;
    SCE_INNO_DEFAULT = 0;
    SCE_INNO_COMMENT = 1;
    SCE_INNO_KEYWORD = 2;
    SCE_INNO_PARAMETER = 3;
    SCE_INNO_SECTION = 4;
    SCE_INNO_PREPROC = 5;
    SCE_INNO_PREPROC_INLINE = 6;
    SCE_INNO_COMMENT_PASCAL = 7;
    SCE_INNO_KEYWORD_PASCAL = 8;
    SCE_INNO_KEYWORD_USER = 9;
    SCE_INNO_STRING_DOUBLE = 10;
    SCE_INNO_STRING_SINGLE = 11;
    SCE_INNO_IDENTIFIER = 12;
    SCE_OPAL_SPACE = 0;
    SCE_OPAL_COMMENT_BLOCK = 1;
    SCE_OPAL_COMMENT_LINE = 2;
    SCE_OPAL_INTEGER = 3;
    SCE_OPAL_KEYWORD = 4;
    SCE_OPAL_SORT = 5;
    SCE_OPAL_STRING = 6;
    SCE_OPAL_PAR = 7;
    SCE_OPAL_BOOL_CONST = 8;
    SCE_OPAL_DEFAULT = 32;
    SCE_SPICE_DEFAULT = 0;
    SCE_SPICE_IDENTIFIER = 1;
    SCE_SPICE_KEYWORD = 2;
    SCE_SPICE_KEYWORD2 = 3;
    SCE_SPICE_KEYWORD3 = 4;
    SCE_SPICE_NUMBER = 5;
    SCE_SPICE_DELIMITER = 6;
    SCE_SPICE_VALUE = 7;
    SCE_SPICE_COMMENTLINE = 8;
    SCN_STYLENEEDED = 2000;
    SCN_CHARADDED = 2001;
    SCN_SAVEPOINTREACHED = 2002;
    SCN_SAVEPOINTLEFT = 2003;
    SCN_MODIFYATTEMPTRO = 2004;
    SCN_DOUBLECLICK = 2006;
    SCN_UPDATEUI = 2007;
    SCN_MODIFIED = 2008;
    SCN_MACRORECORD = 2009;
    SCN_MARGINCLICK = 2010;
    SCN_NEEDSHOWN = 2011;
    SCN_PAINTED = 2013;
    SCN_USERLISTSELECTION = 2014;
    SCN_DWELLSTART = 2016;
    SCN_DWELLEND = 2017;
    SCN_ZOOM = 2018;
    SCN_HOTSPOTCLICK = 2019;
    SCN_HOTSPOTDOUBLECLICK = 2020;
    SCN_CALLTIPCLICK = 2021;
    SCN_AUTOCSELECTION = 2022;
Added src/SCIInterface.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// $HDR$
// $Log:  157187: SCIInterface.pas 
//
//    Rev 1.0    9/22/2009 16:57:18  merijn
unit SCIInterface;

interface

uses
  Windows;

{$I SCIConsts.inc}

type TNotifyHeader = record
      hwndFrom : Pointer;
      idFrom   : Cardinal;
      code     : Cardinal;
     end;

     TSCNotification = record
      nmhdr             : TNotifyHeader;
      position          : Integer;    // SCN_STYLENEEDED, SCN_MODIFIED
      ch                : Integer;    // SCN_CHARADDED, SCN_KEY
      modifiers         : Integer;    // SCN_KEY
      modificationType  : Integer;    // SCN_MODIFIED
      text              : PChar;      // SCN_MODIFIED
      length            : Integer;    // SCN_MODIFIED
      linesAdded        : Integer;    // SCN_MODIFIED
      message           : Integer;    // SCN_MACRORECORD
      wParam            : Longword;   // SCN_MACRORECORD
      lParam            : LongInt;    // SCN_MACRORECORD
      line              : Integer;    // SCN_MODIFIED
      foldLevelNow      : Integer;    // SCN_MODIFIED
      foldLevelPrev     : Integer;    // SCN_MODIFIED
      margin            : Integer;    // SCN_MARGINCLICK
      listType          : Integer;    // SCN_USERLISTSELECTION
     end;
     PSCNotification = ^TSCNotification;

type TSCIInterface = class(TObject)
     private
      fSCIHandle: hwnd;

      function SPerform(Msg: Cardinal; wParam: integer = 0; lParam: integer = 0): integer; 

      function GetSelText: string;
      function GetSelectionStart: integer;
      function GetSelectionEnd: integer;
      function GetLineLength(LineNr: integer): integer;
      function GetLineNr(LineNr: integer): string;
      function GetLineCount: integer;
      function GetAllText: string;
      procedure SetAllText(const Value: string);
      function GetAllLength: integer;
    procedure SetAllBinary(const Value: string);
    function GetReadOnly: boolean;
    procedure SetReadOnly(const Value: boolean);
     public
      constructor Create;

      procedure AppendText(Text: string);
      procedure ClearAll;

      property SCIHandle: hwnd read fSCIHandle write fSCIHandle;

      property SelText: string read GetSelText;
      property SelectionStart: integer read GetSelectionStart;
      property SelectionEnd: integer read GetSelectionEnd;

      property LineLength[LineNr: integer]: integer read GetLineLength;
      property Line[LineNr: integer]: string read GetLineNr;
      property LineCount: integer read GetLineCount;

      property AllLength: integer read GetAllLength;
      property AllText: string read GetAllText write SetAllText;
      property AllBinary: string read GetAllText write SetAllBinary;

      property ReadOnly: boolean read GetReadOnly write SetReadOnly;



      procedure BeginUndoAction;
      procedure EndUndoAction;

      function ShowLines(LineStart: integer; LineEnd: integer = -1): integer;
      function HideLines(LineStart: integer; LineEnd: integer = -1): integer;
      function ShowAllLines: integer;

      function CreateDocument: integer;
      procedure MarkUnchanged;
     end;


implementation

uses
  SysUtils;

{ TSCIInterface }

procedure TSCIInterface.AppendText(Text: string);
begin
 SPerform(SCI_APPENDTEXT, Length(Text), integer(@Text[1]));
end;

procedure TSCIInterface.BeginUndoAction;
begin
 SPerform(SCI_BEGINUNDOACTION);
end;

procedure TSCIInterface.ClearAll;
begin
 SPerform(SCI_CLEARALL);
end;

constructor TSCIInterface.Create;
begin
 inherited;

 fSCIHandle := 0;
end;

procedure TSCIInterface.SetAllBinary(const Value: string);
begin
 BeginUndoAction();
 ClearAll();
 AppendText(Value);
 EndUndoAction;
end;

procedure TSCIInterface.SetAllText(const Value: string);
var Data: PChar;
begin
 Data := StrAlloc(Length(Value) + 1);
 ZeroMemory(Data, Length(Value) + 1);
 StrPCopy(Data, Value);

 SPerform(SCI_SETTEXT, 0, integer(Data));
 StrDispose(Data);
end;

procedure TSCIInterface.SetReadOnly(const Value: boolean);
begin
 SPerform(SCI_SETREADONLY, 0, integer(value));
end;

function TSCIInterface.ShowAllLines: integer;
begin
 result := SPerform(SCI_SHOWLINES, 0, LineCount - 1);
end;

function TSCIInterface.ShowLines(LineStart, LineEnd: integer): integer;
begin
 if LineEnd = -1 then
  LineEnd := LineStart;

 result := SPerform(SCI_SHOWLINES, LineStart, LineEnd);
end;

function TSCIInterface.SPerform(Msg: Cardinal; wParam: integer = 0; lParam: integer = 0): integer;
begin
 if fSCIHandle = 0 then
  raise Exception.Create('no handle defined!');

 result := SendMessage(fSCIHandle, Msg, wParam, lParam);
end;


function TSCIInterface.CreateDocument: integer;
begin
 result := SPerform(SCI_CREATEDOCUMENT);
end;

procedure TSCIInterface.EndUndoAction;
begin
 SPerform(SCI_ENDUNDOACTION);
end;

function TSCIInterface.GetAllText: string;
begin
 SetLength(result, AllLength + 1);
 SPerform(SCI_GETTEXT, Length(result), integer(@result[1]));

 // now strip the extra 0x00 at the end of the string
 SetLength(result, Length(result) - 1);
end;

function TSCIInterface.GetAllLength: integer;
begin
 result := SPerform(SCI_GETLENGTH);
end;

function TSCIInterface.GetLineCount: integer;
begin
 result := SPerform(SCI_GETLINECOUNT);
end;

function TSCIInterface.GetLineLength(LineNr: integer): integer;
begin
 result := SPerform(SCI_LINELENGTH, LineNr);
end;

function TSCIInterface.GetLineNr(LineNr: integer): string;
begin
 SetLength(result, LineLength[LineNr]);
 SPerform(SCI_GETLINE, LineNr, integer(@result[1]));
end;

function TSCIInterface.GetReadOnly: boolean;
begin
 result := boolean(SPerform(SCI_GETREADONLY));
end;

function TSCIInterface.GetSelectionEnd: integer;
begin
 result := SPerform(SCI_GETSELECTIONEND);
end;

function TSCIInterface.GetSelectionStart: integer;
begin
 result := SPerform(SCI_GETSELECTIONSTART);
end;

function TSCIInterface.GetSelText: string;
var SelLength: integer;
begin
 result := '';

 SelLength := SelectionEnd - SelectionStart;

 if SelLength > 0 then
 begin
  SetLength(Result, SelLength + 1);
  SPerform(SCI_GETSELTEXT, 0, integer(@result[1]));
  result := Copy(result, 1, SelLength);
 end;
end;

function TSCIInterface.HideLines(LineStart, LineEnd: integer): integer;
begin
 if LineEnd = -1 then
  LineEnd := LineStart;

 result := SPerform(SCI_SHOWLINES, LineStart, LineEnd);
end;

procedure TSCIInterface.MarkUnchanged;
begin
 SPerform(SCI_SETSAVEPOINT);
end;

end.
Added src/ToolTips.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
unit ToolTips;

(*******************************************************************************

  Tool tips API Wrapper - allow to manage the tool tips easily

  Programmed by Leonid Lebedev <lebedevlp@mail.ru>, all rights reserved
  Fixed and improved by Samuel Soldat <samuel.soldat@snafu.de>, see SSyymmdd
  Any bug reports and improvement suggestions are welcomed
  Please do have respect for the copyright and do not change this header

  Last update: 13 March 2011

*******************************************************************************)

interface

uses
  SysUtils, Windows, Messages, Graphics, Classes, Controls, CommCtrl;

const
  TTN_GETDISPINFO = (TTN_FIRST - 0);
  TTN_SHOW = (TTN_FIRST - 1);
  TTN_POP = (TTN_FIRST - 2);
  TTN_LINKCLICK = (TTN_FIRST - 3);

  TTID_AUTO = 0;

type
  // An application-defined function that processes messages sent to a window.
  // To explain STRICT in detail see Remarks section of CallWindowProc function.
  {$IFDEF STRICT}
  TWndProc = function(
    hwnd: THandle; {handle of window}
    uMsg: Longword; {message identifier}
    wParam: Longint; {first message parameter}
    lParam: Longint {second message parameter}
  ): Longint; stdcall;
  {$ELSE}
  TWndProc = TFarProc;
  {$ENDIF}

  // Contains information used in handling the TTN_GETDISPINFO notification
  // message.
  TTTNGetDispInfo = packed record
    Msg: Cardinal;
    idCtrl: Longint;
    lpnmtdi: PNMTTDispInfo;
    Result: Longint;
  end;
  TTTNLinkClick = TWMNoParams;
  // Contains information about a notification message.
  TTTNPop = packed record
    Msg: Cardinal;
    idTT: Longint;
    pnmh: PNMHdr;
    Result: Longint;
  end;
  TTTNShow = TTTNPop;

  TToolTipStyle = (ttsAlwaysTip, ttsBalloon, ttsNoAnimate, ttsNoFade,
    ttsNoPrefix, ttsClose, ttsUseVisualStyle);
  TToolTipStyles = set of TToolTipStyle;

  TOnTTGetDispInfo = procedure(
    Sender: TObject;
    var DispInfo: TNMTTDispInfo
  ) of object;
  TOnTTLinkClick = TNotifyEvent;
  TOnTTPop = procedure(
    Sender: TObject;
    Id: Integer;
    const Header: TNMHdr
  ) of object;
  TOnTTShow = TOnTTPop;

  // Lightweight window control class for the tool tips usage.
  TToolTipWindow = class
  private
    fHandle: THandle;
    fParent: TWinControl;
    fWndProcPtr: Pointer;
    fPrevWndProc: Pointer;
    fOnGetDispInfo: TOnTTGetDispInfo;
    fOnLinkClick: TOnTTLinkClick;
    fOnPop: TOnTTPop;
    fOnShow: TOnTTShow;
    fStyles: TToolTipStyles;
    function GetStyles: TToolTipStyles;
  protected
    procedure WndProc(var Msg: TMessage); virtual;

    // Creates an overlapped, pop-up, or child window with an extended window
    // style.
    class function Window_CreateEx(dwExStyle: Longword; lpClassName: PAnsiChar;
      lpWindowName: PAnsiChar; dwStyle: Longword; x, y: Integer;
      nWidth, nHeight: Integer; hWndParent: THandle; hMenu: THandle;
      lpParam: Pointer): THandle;
    // Retrieves information about the specified window.
    class function Window_GetLong(hWnd: THandle; nIndex: Integer): Longint;
    // Changes an attribute of the specified window.
    class function Window_SetLong(hWnd: THandle; nIndex: Integer;
      dwNewLong: Longint): Longint;
    // Changes the size, position, and Z order of a child, pop-up, or top-level
    // window.
    class function Window_SetPos(hWnd: THandle; hWndInsertAfter: THandle;
      x, y: Integer; nWidth, nHeight: Integer; uFlags: Longword): Boolean;
    // Passes message information to the specified window procedure.
    class function Window_CallProc(lpPrevWndFunc: TWndProc; hWnd: THandle;
      Msg: Longword; wParam: Longint; lParam: Longint): Longint;

    // Sent when a window is being destroyed.
    procedure WMDestroy(var Message: TWMDestroy);
    // Sent by a common control to its parent window when an event has occurred
    // or the control requires some information.
    // SS110312: WMNotify now returns result
    function WMNotify(var Message: TWMNotify): Boolean;

    // Sent by a ToolTip control to retrieve information needed to display a
    // ToolTip window. This notification is sent in the form of a WM_NOTIFY
    // message.
    procedure TTNGetDispInfo(var Message: TTTNGetDispInfo); virtual;
    // Sent when a text link inside a balloon ToolTip is clicked.
    procedure TTNLinkClick(var Message: TTTNLinkClick); virtual;
    // Notifies the owner window that a ToolTip is about to be hidden. This
    // notification message is sent in the form of a WM_NOTIFY message.
    procedure TTNPop(var Message: TTTNPop); virtual;
    // Notifies the owner window that a ToolTip control is about to be
    // displayed. This notification message is sent in the form of a WM_NOTIFY
    // message.
    procedure TTNShow(var Message: TTTNShow); virtual;

    function GetWindowExStyle: Longword; virtual;
    function GetWindowClassName: PAnsiChar; virtual;
    function GetWindowStyle: Longword; virtual;
  public
    constructor Create(AParent: TWinControl); virtual;
    constructor CreateStyled(AParent: TWinControl; AStyles: TToolTipStyles);
    procedure AfterConstruction; override;
    property Handle: THandle read fHandle;
    property Parent: TWinControl read fParent;
    property Styles: TToolTipStyles read GetStyles;
    property OnGetDispInfo: TOnTTGetDispInfo read fOnGetDispInfo write fOnGetDispInfo;
    property OnLinkClick: TOnTTLinkClick read fOnLinkClick write fOnLinkClick;
    property OnPop: TOnTTPop read fOnPop write fOnPop;
    property OnShow: TOnTTShow read fOnShow write fOnShow;
  end;

  // Provides information about the title of a tooltip control.
  TTTGetTitleA = packed record
    dwSize: Longword; {size of structure}
    uTitleBitmap: Longword; {the tooltip icon}
    cch: Longword; {the number of characters in the title}
    pszTitle: PAnsiChar; {pointer to a multibyte string that contains the title}
  end;
  TTTGetTitleW = packed record
    dwSize: Longword; {size of structure}
    uTitleBitmap: Longword; {the tooltip icon}
    cch: Longword; {the number of characters in the title}
    pszTitle: PWideChar; {pointer to a wide string that contains the title}
  end;
  {$IFDEF UNICODE}
  TTTGetTitle = TTTGetTitleW;
  {$ELSE}
  TTTGetTitle = TTTGetTitleA;
  {$ENDIF}
  PTTGetTitle = ^TTTGetTitle;

  TToolTipIcon = (ttiNone, ttiInfo, ttiWarning, ttiError, ttiInfoLarge,
    ttiWarningLarge, ttiErrorLarge);

  TToolTipFlag = (ttfAbsolute, ttfCenterTip, ttfIdIsHWND, ttfParseLinks,
    ttfRTLReading, ttfSubClass, ttfTrack, ttfTransparent);
  TToolTipFlags = set of TToolTipFlag;

  TToolTip = class;
  TToolTipControl = class(TToolTipWindow)
  private
    // SS110312: Use TList instead of TObjectList so uses Contnrs obsoleted
    fToolTips: TList;
    fInfo: TTTGetTitle;
    // SS110312: fInfo.pszTitle will refer to fTitle so GetTitle obsoleted
    fTitle: string;
    fFlagsToInclude: TToolTipFlags;
    fFlagsToExclude: TToolTipFlags;
    function GetAutoPopTime: Cardinal;
    procedure SetAutoPopTime(const Value: Cardinal);
    function GetInitialTime: Cardinal;
    procedure SetInitialTime(const Value: Cardinal);
    function GetReshowTime: Cardinal;
    procedure SetReshowTime(const Value: Cardinal);
    function GetMargin: TRect;
    procedure SetMargin(const Value: TRect);
    function GetLeftMargin: Integer;
    procedure SetLeftMargin(const Value: Integer);
    function GetTopMargin: Integer;
    procedure SetTopMargin(const Value: Integer);
    function GetRightMargin: Integer;
    procedure SetRightMargin(const Value: Integer);
    function GetBottomMargin: Integer;
    procedure SetBottomMargin(const Value: Integer);
    function GetMaxTipWidth: Integer;
    procedure SetMaxTipWidth(const Value: Integer);
    function GetBackColor: TColor;
    procedure SetBackColor(const Value: TColor);
    function GetTextColor: TColor;
    procedure SetTextColor(const Value: TColor);
    function GetIcon: TToolTipIcon;
    procedure SetIcon(const Value: TToolTipIcon);
    procedure SetTitle(const Value: string);
    function GetItem(const Index: Integer): TToolTip;
    function GetCount: Integer;
    function GetCurrentTool: TToolInfo;
    function GetCurrentToolExists: Boolean;
    function GetTool(iTool: Cardinal): TToolInfo;
    function GetToolCount: Integer;
  protected
    // Registers specific common control classes from the common control DLL.
    class function CommonControls_InitEx(dwICC: Longword): Boolean;

    procedure TTNGetDispInfo(var Message: TTTNGetDispInfo); override;
    procedure TTNLinkClick(var Message: TTTNLinkClick); override;
    procedure TTNPop(var Message: TTTNPop); override;
    procedure TTNShow(var Message: TTTNShow); override;

    procedure AfterAdjustRect(var ARect: TRect); virtual;

    function EnumTools(iTool: Longword; var AInfo: TToolInfo): Boolean; virtual;
    function HitTest(APoint: TPoint; var AInfo: TToolInfo): Boolean; virtual;

    property Tools[iTool: Cardinal]: TToolInfo read GetTool;
    property Margin: TRect read GetMargin write SetMargin;
    property CurrentToolExists: Boolean read GetCurrentToolExists;
    property CurrentTool: TToolInfo read GetCurrentTool;
    property ToolCount: Integer read GetToolCount;
  public
    // NOTICE: Control destruction will remove all the tool tips owned.
    constructor Create(AParent: TWinControl); override;
    procedure AfterConstruction; override;
    procedure BeforeDestruction; override;
    function Add(AToolTip: TToolTip): Integer; virtual;
    // NOTICE: Remove will destroy AToolTip.
    function Remove(AToolTip: TToolTip): Integer; virtual;
    procedure Activate;
    procedure Deactivate;
    function AdjustTextRect(var ARect: TRect): Boolean;
    function AdjustWindowRect(var ARect: TRect): Boolean;
    // Set all three delay times to default proportions.
    procedure SetAutomaticDelayTime;
    procedure Pop;
    procedure Popup;
    procedure RelayEvent(var Msg: TMsg);
    // SS110312: ATheme is a constant parameter now
    procedure SetWindowTheme(const ATheme: string);
    procedure TrackPosition(X, Y: Word);
    procedure Update;
    function WindowFromPoint(APoint: TPoint): THandle;
    // SS110312: AddHints add tool tips according Hint properties from AControl
    //           and all of its children recursively
    procedure AddHints(AControl: TControl);
    // The amount of time a ToolTip window remains visible if the pointer is
    // stationary within a tool's bounding rectangle.
    property AutoPopTime: Cardinal read GetAutoPopTime write SetAutoPopTime;
    // The amount of time a pointer must remain stationary within a tool's
    // bounding rectangle before the ToolTip window appears.
    property InitialTime: Cardinal read GetInitialTime write SetInitialTime;
    // The amount of time it takes for subsequent ToolTip windows to appear as
    // the pointer moves from one tool to another.
    property ReshowTime: Cardinal read GetReshowTime write SetReshowTime;
    property LeftMargin: Integer read GetLeftMargin write SetLeftMargin;
    property TopMargin: Integer read GetTopMargin write SetTopMargin;
    property RightMargin: Integer read GetRightMargin write SetRightMargin;
    property BottomMargin: Integer read GetBottomMargin write SetBottomMargin;
    property MaxTipWidth: Integer read GetMaxTipWidth write SetMaxTipWidth;
    property BackColor: TColor read GetBackColor write SetBackColor;
    property TextColor: TColor read GetTextColor write SetTextColor;
    property Icon: TToolTipIcon read GetIcon write SetIcon;
    property Title: string read fTitle write SetTitle;
    property Items[const Index: Integer]: TToolTip read GetItem; default;
    property Count: Integer read GetCount;
  end;

  TStandardToolTipControl = class(TToolTipControl)
  public
    constructor Create(AParent: TWinControl); override;
  end;

  TTrackingToolTipControl = class(TToolTipControl)
  public
    constructor Create(AParent: TWinControl); override;
  end;

  TMultilineToolTipControl = class(TStandardToolTipControl)
  public
    constructor Create(AParent: TWinControl); override;
  end;

  TBalloonToolTipControl = class(TToolTipControl)
  public
    constructor Create(AParent: TWinControl); override;
  end;

  TInPlaceToolTipControl = class(TStandardToolTipControl)
  protected
    procedure AfterAdjustRect(var ARect: TRect); override;
  end;

  TToolTipId = Longword;

  TOnToolTipGetDispInfo = function(
    Sender: TObject;
    var Instance: THandle;
    var ResName: string;
    var Text: string;
    Data: Longint
  ): Boolean of object;
  TOnToolTipLinkClick = TNotifyEvent;
  TOnToolTipPop = TNotifyEvent;
  TOnToolTipShow = TOnToolTipPop;

  TToolTip = class
  private
    fOwner: TToolTipControl;
    fControl: TControl;
    fParent: TWinControl;
    fInfo: TToolInfo;
    // SS110312: fInfo.lpszText will refer to fText so GetText obsoleted
    fText: string;
    fTrackActivated: Boolean;
    fOnGetDispInfo: TOnToolTipGetDispInfo;
    fOnLinkClick: TOnToolTipLinkClick;
    fOnPop: TOnToolTipPop;
    fOnShow: TOnToolTipShow;
    procedure SetOwner(const Value: TToolTipControl);
    procedure SetControl(const Value: TControl);
    function GetId: TToolTipId;
    function GetFlags: TToolTipFlags;
    procedure SetFlags(const Value: TToolTipFlags);
    function GetClipRect: TRect;
    procedure SetText(const Value: string);
    function GetBubbleSize: TSize;
    function GetToolInfo: TToolInfo;
  protected
    class function GetWinControl(AControl: TControl): TWinControl;

    function DoGetDispInfo(var Instance: THandle; var ResName: string;
      var Text: string; Data: Longint): Boolean; virtual;
    procedure DoLinkClick; virtual;
    procedure DoPop; virtual;
    procedure DoShow; virtual;

    procedure CheckOwner(const MethodName: string);

    function AddTool: Boolean; virtual;
    procedure DelTool; virtual;
    procedure SetInfo(const Value: TToolInfo); virtual;

    property ToolInfo: TToolInfo read GetToolInfo;
  public
    constructor Create(AControl: TControl; const GetDispInfo: Boolean = False;
       AId: TToolTipId = TTID_AUTO); virtual;
    procedure AfterConstruction; override;
    procedure BeforeDestruction; override;
    procedure SetClipRect(const Value: TRect); overload;
    procedure SetClipRect(AControl: TControl; const Value: TRect); overload;
    procedure NewToolRect(const ARect: TRect);
    procedure TrackActivate;
    procedure TrackDisactivate;
    procedure TrackPosition(X, Y: Word);
    property Owner: TToolTipControl read fOwner write SetOwner;
    property Control: TControl read fControl write SetControl;
    property Parent: TWinControl read fParent;
    property Id: TToolTipId read GetId;
    property Flags: TToolTipFlags read GetFlags write SetFlags;
    property ClipRect: TRect read GetClipRect;
    // NOTICE: GetBubbleSize will return zeroes if called before TrackActivate.
    property BubbleSize: TSize read GetBubbleSize;
    property Text: string read fText write SetText;
    property OnGetDispInfo: TOnToolTipGetDispInfo read fOnGetDispInfo write fOnGetDispInfo;
    property OnLinkClick: TOnToolTipLinkClick read fOnLinkClick write fOnLinkClick;
    property OnPop: TOnToolTipPop read fOnPop write fOnPop;
    property OnShow: TOnToolTipShow read fOnShow write fOnShow;
  end;

  EToolTip = class(Exception);

implementation

uses Types;

resourcestring
  S_EWin32Error = 'Win32 API call of %s failed'#13#10'Error code %d (%s)';
  S_EUnkWin32Error = 'Win32 API call of %s failed'#13#10'Error code %d';
  S_ENotSupported = 'This kind of the tool tips is not supported';
  S_EMessage = 'Error sending message %s';
  S_ECheckOwner = 'Call of %s.%s failed due to ToolTip has no owner window';
  S_ENoWindow = 'Control %s: %s has no parent window';
  S_EId = 'Invalid tool id %d';
  S_ESetText = 'Unable to set ToolTip text due to GetDispInfo was TRUE';

procedure RaiseLastWin32Error(const FunctionName: string);
{$IFNDEF SUPPRESS_WIN32ERROR}
var
  LastError: DWORD;
  Error: EOSError;
{$ENDIF}
begin
  {$IFNDEF SUPPRESS_WIN32ERROR}
  LastError := GetLastError;
  if LastError <> ERROR_SUCCESS then
    Error := EOSError.CreateFmt(S_EWin32Error,
      [FunctionName, LastError, SysErrorMessage(LastError)])
  else
    Error := EOSError.CreateFmt(S_EUnkWin32Error,
      [FunctionName, LastError]);
  Error.ErrorCode := LastError;
  raise Error;
  {$ENDIF}
end;

procedure RaiseToolTipError(const MessageName: string);
begin
  {$IFNDEF SUPPRESS_TOOLTIPERROR}
  raise EToolTip.CreateFmt(S_EMessage, [MessageName]);
  {$ENDIF}
end;

const
  CCM_SETWINDOWTHEME = (CCM_FIRST + $0B);
  TTF_PARSELINKS = $1000;
  TTM_GETBUBBLESIZE = (WM_USER + 30);
  TTM_ADJUSTRECT = (WM_USER + 31);
  {$IFDEF UNICODE}
  TTM_SETTITLE = (WM_USER + 33);
  {$ELSE}
  TTM_SETTITLE = (WM_USER + 32);
  {$ENDIF}
  TTM_POPUP = (WM_USER + 34);
  TTM_GETTITLE = (WM_USER + 35);
  TTM_SETWINDOWTHEME = CCM_SETWINDOWTHEME;
  TTS_BALLOON = $40;

type
  ToolTipsAPI = class
  protected
    // Activates or deactivates a ToolTip control.
    class procedure Activate(hWndControl: THandle; fActivate: Boolean);
    // Registers a tool with a ToolTip control.
    // Returns TRUE if successful, or FALSE otherwise.
    class function Add(hWndControl: THandle; lpti: PToolInfo): Boolean;
    // Calculates a ToolTip control's text display rectangle from its window
    // rectangle, or the ToolTip window rectangle needed to display a specified
    // text display rectangle.
    // Returns a non-zero value if the rectangle is successfully adjusted, and
    // returns zero if an error occurs.
    class function AdjustRect(hWndControl: THandle; fLarger: Boolean; prc: PRect): Longint;
    // Removes a tool from a ToolTip control.
    class procedure Del(hWndControl: THandle; lpti: PToolInfo);
    // Retrieves the information that a ToolTip control maintains about the
    // current tool—that is, the tool for which the ToolTip is currently
    // displaying text.
    // Returns TRUE if any tools are enumerated, or FALSE otherwise.
    class function Enum(hWndControl: THandle; iTool: Longword; lpti: PToolInfo): Boolean;
    // Returns the width and height of a ToolTip control.
    // Returns the width of the ToolTip in the low word and the height in the
    // high word if successful. Otherwise, it returns FALSE.
    class function GetBubbleSize(hWndControl: THandle; pTtm: PToolInfo): Longint;
    // Retrieves the information for the current tool in a ToolTip control.
    // Returns nonzero if successful, or zero otherwise. If lpti is NULL,
    // returns nonzero if a current tool exists, or zero otherwise.
    class function GetCurrent(hWndControl: THandle; lpti: PToolInfo): Longint;
    // Retrieves the initial, pop-up, and reshow durations currently set for a
    // ToolTip control.
    // Returns and INT value with the specified duration in milliseconds.
    class function GetDelayTime(hWndControl: THandle; dwDuration: Longword): Integer;
    // Retrieves the top, left, bottom, and right margins set for a ToolTip
    // window. A margin is the distance, in pixels, between the ToolTip window
    // border and the text contained within the ToolTip window.
    class procedure GetMargin(hWndControl: THandle; lprc: PRect);
    // Retrieves the maximum width for a ToolTip window.
    // Returns an INT value that represents the maximum ToolTip width, in
    // pixels. If no maximum width was set previously, the message returns -1.
    class function GetMaxWidth(hWndControl: THandle): Integer;
    // Retrieves the information a ToolTip control maintains about a tool.
    class procedure GetText(hWndControl: THandle; wNumber: Longint; lpti: PToolInfo);
    // Retrieves the background color in a ToolTip window.
    // Returns a Longword value that represents the background color.
    class function GetBkColor(hWndControl: THandle): Longword;
    // Retrieves the text color in a ToolTip window.
    // Returns a Longword value that represents the text color.
    class function GetTextColor(hWndControl: THandle): Longword;
    // Retrieve information concerning the title of a toolTip control.
    class procedure GetTitle(hWndControl: THandle; pGetTitle: PTTGetTitle);
    // Retrieves a count of the tools maintained by a ToolTip control.
    // Returns a count of tools.
    class function GetCount(hWndControl: THandle): Longint;
    // Retrieves the information that a ToolTip control maintains about a tool.
    // Returns TRUE if successful, or FALSE otherwise.
    class function GetInfo(hWndControl: THandle; lpti: PToolInfo): Boolean;
    // Tests a point to determine whether it is within the bounding rectangle of
    // the specified tool and, if it is, retrieves information about the tool.
    // Returns TRUE if the tool occupies the specified point, or FALSE
    // otherwise.
    class function HitTest(hWndControl: THandle; lphti: PTTHitTestInfo): Boolean;
    // Sets a new bounding rectangle for a tool.
    class procedure NewRect(hWndControl: THandle; lpti: PToolInfo);
    // Removes a displayed ToolTip window from view.
    class procedure Pop(hWndControl: THandle);
    // Causes the ToolTip to display at the coordinates of the last mouse
    // message.
    class procedure Popup(hWndControl: THandle);
    // Passes a mouse message to a ToolTip control for processing.
    class procedure RelayEvent(hWndControl: THandle; lpmsg: PMsg);
    // Sets the initial, pop-up, and reshow durations for a ToolTip control.
    class procedure SetDelayTime(hWndControl: THandle; dwDuration: Word; iTime: Longword);
    // Sets the top, left, bottom, and right margins for a ToolTip window. A
    // margin is the distance, in pixels, between the ToolTip window border and
    // the text contained within the ToolTip window.
    class procedure SetMargin(hWndControl: THandle; lprc: PRect);
    // Sets the maximum width for a ToolTip window.
    // Returns the previous maximum ToolTip width.
    class function SetMaxWidth(hWndControl: THandle; iWidth: Integer): Longint;
    // Sets the background color in a ToolTip window.
    class procedure SetBkColor(hWndControl: THandle; clr: Longword);
    // Sets the text color in a ToolTip window.
    class procedure SetTextColor(hWndControl: THandle; clr: Longword);
    // Adds a standard icon and title string to a ToolTip.
    // Returns TRUE if successful, FALSE if not.
    {$IFDEF UNICODE}
    class function SetTitle(hWndControl: THandle; icon: Integer; pszTitle: PWideChar): Boolean;
    {$ELSE}
    class function SetTitle(hWndControl: THandle; icon: Integer; pszTitle: PAnsiChar): Boolean;
    {$ENDIF}
    // Sets the information that a ToolTip control maintains for a tool.
    class procedure SetInfo(hWndControl: THandle; lpti: PToolInfo);
    // Sets the visual style of a ToolTip control.
    class procedure SetWindowTheme(hWndControl: THandle; pwStr: PWideChar);
    // Activates or deactivates a tracking ToolTip.
    class procedure TrackActivate(hWndControl: THandle; bActivate: Boolean; lpti: PToolInfo);
    // Sets the position of a tracking ToolTip.
    class procedure TrackPosition(hWndControl: THandle; xPos, yPos: Word);
    // Forces the current tool to be redrawn.
    class procedure Update(hWndControl: THandle);
    // Sets the ToolTip text for a tool.
    class procedure UpdateText(hWndControl: THandle; lpti: PToolInfo);
    // Allows a subclass procedure to cause a ToolTip to display text for a
    // window other than the one beneath the mouse cursor.
    // The return value is the handle to the window that contains the point, or
    // NULL if no window exists at the specified point.
    class function WindowFromPoint(hWndControl: THandle; lppt: PPoint): Longint;
  end;

{ ToolTipsAPI }

class procedure ToolTipsAPI.Activate(hWndControl: THandle;
  fActivate: Boolean);
begin
  SendMessage(hWndControl, TTM_ACTIVATE, Integer(fActivate), 0);
end;

class function ToolTipsAPI.Add(hWndControl: THandle;
  lpti: PToolInfo): Boolean;
begin
  Result := SendMessage(hWndControl, TTM_ADDTOOL, 0, Integer(lpti)) <> 0;
  if not Result then
    RaiseToolTipError('TTM_ADDTOOL');
end;

class function ToolTipsAPI.AdjustRect(hWndControl: THandle;
  fLarger: Boolean; prc: PRect): Longint;
begin
  Result := SendMessage(hWndControl, TTM_ADJUSTRECT, Integer(fLarger), Integer(prc));
  if Result = 0 then
    RaiseToolTipError('TTM_ADJUSTRECT');
end;

class procedure ToolTipsAPI.Del(hWndControl: THandle; lpti: PToolInfo);
begin
  SendMessage(hWndControl, TTM_DELTOOL, 0, Integer(lpti));
end;

class function ToolTipsAPI.Enum(hWndControl: THandle; iTool: Longword;
  lpti: PToolInfo): Boolean;
begin
  Result := SendMessage(hWndControl, TTM_ENUMTOOLS, iTool, Integer(lpti)) <> 0;
  if not Result then
    RaiseToolTipError('TTM_ENUMTOOLS');
end;

class function ToolTipsAPI.GetBkColor(hWndControl: THandle): Longword;
begin
  Result := SendMessage(hWndControl, TTM_GETTIPBKCOLOR, 0, 0);
end;

class function ToolTipsAPI.GetBubbleSize(hWndControl: THandle;
  pTtm: PToolInfo): Longint;
begin
  Result := SendMessage(hWndControl, TTM_GETBUBBLESIZE, 0, Integer(pTtm));
  if Result = 0 then
    RaiseToolTipError('TTM_GETBUBBLESIZE');
end;

class function ToolTipsAPI.GetCount(hWndControl: THandle): Longint;
begin
  Result := SendMessage(hWndControl, TTM_GETTOOLCOUNT, 0, 0);
end;

class function ToolTipsAPI.GetCurrent(hWndControl: THandle;
  lpti: PToolInfo): Longint;
begin
  Result := SendMessage(hWndControl, TTM_GETCURRENTTOOL, 0, Integer(lpti));
  if Result = 0 then
    RaiseToolTipError('TTM_GETCURRENTTOOL');
end;

class function ToolTipsAPI.GetDelayTime(hWndControl: THandle;
  dwDuration: Longword): Integer;
begin
  Result := SendMessage(hWndControl, TTM_GETDELAYTIME, dwDuration, 0)
end;

class function ToolTipsAPI.GetInfo(hWndControl: THandle;
  lpti: PToolInfo): Boolean;
begin
  Result := SendMessage(hWndControl, TTM_GETTOOLINFO, 0, Integer(lpti)) <> 0;
  if not Result then
    RaiseToolTipError('TTM_GETTOOLINFO');
end;

class procedure ToolTipsAPI.GetMargin(hWndControl: THandle; lprc: PRect);
begin
  SendMessage(hWndControl, TTM_GETMARGIN, 0, Integer(lprc));
end;

class function ToolTipsAPI.GetMaxWidth(hWndControl: THandle): Integer;
begin
  Result := SendMessage(hWndControl, TTM_GETMAXTIPWIDTH, 0, 0);
end;

class procedure ToolTipsAPI.GetText(hWndControl: THandle; wNumber: Integer;
  lpti: PToolInfo);
begin
  SendMessage(hWndControl, TTM_GETTEXT, wNumber, Integer(lpti));
end;

class function ToolTipsAPI.GetTextColor(hWndControl: THandle): Longword;
begin
  Result := SendMessage(hWndControl, TTM_GETTIPTEXTCOLOR, 0, 0);
end;

class procedure ToolTipsAPI.GetTitle(hWndControl: THandle;
  pGetTitle: PTTGetTitle);
begin
  SendMessage(hWndControl, TTM_GETTITLE, 0, Integer(pGetTitle));
end;

class function ToolTipsAPI.HitTest(hWndControl: THandle;
  lphti: PTTHitTestInfo): Boolean;
begin
  Result := SendMessage(hWndControl, TTM_HITTEST, 0, Integer(lphti)) <> 0;
end;

class procedure ToolTipsAPI.NewRect(hWndControl: THandle; lpti: PToolInfo);
begin
  SendMessage(hWndControl, TTM_NEWTOOLRECT, 0, Integer(lpti));
end;

class procedure ToolTipsAPI.Pop(hWndControl: THandle);
begin
  SendMessage(hWndControl, TTM_POP, 0, 0);
end;

class procedure ToolTipsAPI.Popup(hWndControl: THandle);
begin
  SendMessage(hWndControl, TTM_POPUP, 0, 0);
end;

class procedure ToolTipsAPI.RelayEvent(hWndControl: THandle; lpmsg: PMsg);
begin
  SendMessage(hWndControl, TTM_RELAYEVENT, 0, Integer(lpmsg));
end;

class procedure ToolTipsAPI.SetBkColor(hWndControl: THandle;
  clr: Longword);
begin
  SendMessage(hWndControl, TTM_SETTIPBKCOLOR, clr, 0);
end;

class procedure ToolTipsAPI.SetDelayTime(hWndControl: THandle;
  dwDuration: Word; iTime: Longword);
begin
  SendMessage(hWndControl, TTM_SETDELAYTIME, dwDuration, iTime);
end;

class procedure ToolTipsAPI.SetInfo(hWndControl: THandle; lpti: PToolInfo);
begin
  SendMessage(hWndControl, TTM_SETTOOLINFO, 0, Integer(lpti));
end;

class procedure ToolTipsAPI.SetMargin(hWndControl: THandle; lprc: PRect);
begin
  SendMessage(hWndControl, TTM_SETMARGIN, 0, Integer(lprc));
end;

class function ToolTipsAPI.SetMaxWidth(hWndControl: THandle;
  iWidth: Integer): Longint;
begin
  Result := SendMessage(hWndControl, TTM_SETMAXTIPWIDTH, 0, iWidth);
end;

class procedure ToolTipsAPI.SetTextColor(hWndControl: THandle;
  clr: Longword);
begin
  SendMessage(hWndControl, TTM_SETTIPTEXTCOLOR, clr, 0);
end;

{$IFDEF UNICODE}
class function ToolTipsAPI.SetTitle(hWndControl: THandle; icon: Integer;
  pszTitle: PWideChar): Boolean;
{$ELSE}
class function ToolTipsAPI.SetTitle(hWndControl: THandle; icon: Integer;
  pszTitle: PAnsiChar): Boolean;
{$ENDIF}
begin
  Result := SendMessage(hWndControl, TTM_SETTITLE, icon, Integer(pszTitle)) <> 0;
  if not Result then
    RaiseToolTipError('TTM_SETTITLE');
end;

class procedure ToolTipsAPI.SetWindowTheme(hWndControl: THandle;
  pwStr: PWideChar);
begin
  SendMessage(hWndControl, TTM_SETWINDOWTHEME, 0, Integer(pwStr));
end;

class procedure ToolTipsAPI.TrackActivate(hWndControl: THandle;
  bActivate: Boolean; lpti: PToolInfo);
begin
  SendMessage(hWndControl, TTM_TRACKACTIVATE, Integer(bActivate), Integer(lpti));
end;

class procedure ToolTipsAPI.TrackPosition(hWndControl: THandle; xPos,
  yPos: Word);
begin
  SendMessage(hWndControl, TTM_TRACKPOSITION, 0, MakeLong(xPos, yPos));
end;

class procedure ToolTipsAPI.Update(hWndControl: THandle);
begin
  SendMessage(hWndControl, TTM_UPDATE, 0, 0);
end;

class procedure ToolTipsAPI.UpdateText(hWndControl: THandle;
  lpti: PToolInfo);
begin
  SendMessage(hWndControl, TTM_UPDATETIPTEXT, 0, Integer(lpti));
end;

class function ToolTipsAPI.WindowFromPoint(hWndControl: THandle;
  lppt: PPoint): Longint;
begin
  Result := SendMessage(hWndControl, TTM_WINDOWFROMPOINT, 0, Integer(lppt));
end;

{ TToolTipWindow }

const
  TTS_NOANIMATE = $10;
  TTS_NOFADE = $20;
  TTS_CLOSE = $80;
  TTS_USEVISUALSTYLE = $100;

const
  ToolTipStyleValue: array [TToolTipStyle] of Longword = (TTS_ALWAYSTIP,
    TTS_BALLOON, TTS_NOANIMATE, TTS_NOFADE, TTS_NOPREFIX, TTS_CLOSE,
    TTS_USEVISUALSTYLE);

function ToolTipStylesValue(const Styles: TToolTipStyles): Longword;
var
  Style: TToolTipStyle;
begin
  Result := 0;
  for Style := Low(TToolTipStyle) to High(TToolTipStyle) do
    if Style in Styles then
      Result := Result or ToolTipStyleValue[Style];
end;

function GetToolTipStyles(const Value: Longint): TToolTipStyles;
var
  Style: TToolTipStyle;
begin
  Result := [];
  for Style := Low(TToolTipStyle) to High(TToolTipStyle) do
    if Value and ToolTipStyleValue[Style] <> 0 then
      Include(Result, Style);
end;

procedure TToolTipWindow.AfterConstruction;
const
  nIndex = GWL_WNDPROC; {offset of value to set}
var
  dwNewLong: Longint; {new value}
begin
  inherited;

  // Subclass ToolTip control.
  fWndProcPtr := MakeObjectInstance(WndProc);
  dwNewLong := Longint(fWndProcPtr);
  fPrevWndProc := Pointer(Window_SetLong(Parent.Handle, nIndex, dwNewLong));
end;

constructor TToolTipWindow.Create(AParent: TWinControl);
const
  lpWindowName = nil; {pointer to window name}
  hMenu = 0; {handle to menu, or child-window identifier}
  lpParam = nil; {pointer to window-creation data}
  hWndInsertAfter = HWND_TOPMOST; {placement-order handle}
  uFlags = SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE; {positioning flags}
var
  dwExStyle: Longword; {extended window style}
  lpClassName: PAnsiChar; {pointer to registered class name}
  dwStyle: Longword; {window style}
  x: Integer; {horizontal position of window}
  y: Integer; {vertical position of window}
  nWidth: Integer; {window width}
  nHeight: Integer; {window height}
  hWndParent: THandle; {handle to parent or owner window}
begin
  fParent := AParent;
  (* CREATE A TOOLTIP WINDOW *)
  dwExStyle := WS_EX_TOPMOST or GetWindowExStyle;
  lpClassName := GetWindowClassName;
  // SS110312: WS_EX_TOOLWINDOW removed from window style
  dwStyle := WS_POPUP or GetWindowStyle;
  x := Integer(CW_USEDEFAULT);
  y := Integer(CW_USEDEFAULT);
  nWidth := Integer(CW_USEDEFAULT);
  nHeight := Integer(CW_USEDEFAULT);
  hWndParent := fParent.Handle;
  fHandle := Window_CreateEx(dwExStyle, lpClassName, lpWindowName, dwStyle,
    x, y, nWidth, nHeight, hWndParent, hMenu, lpParam);

  x := 0;
  y := 0;
  nWidth := 0;
  nHeight := 0;
  Window_SetPos(fHandle, hWndInsertAfter, x, y, nWidth, nHeight, uFlags);
end;

constructor TToolTipWindow.CreateStyled(AParent: TWinControl;
  AStyles: TToolTipStyles);
begin
  fStyles := AStyles;

  Create(AParent);
end;

function TToolTipWindow.GetStyles: TToolTipStyles;
const
  nIndex = GWL_STYLE; {offset of value to retrieve}
begin
  fStyles := GetToolTipStyles(Window_GetLong(Handle, nIndex));
  Result := fStyles;
end;

function TToolTipWindow.GetWindowClassName: PAnsiChar;
begin
  Result := TOOLTIPS_CLASS;
end;

function TToolTipWindow.GetWindowExStyle: Longword;
begin
  Result := 0;  
end;

function TToolTipWindow.GetWindowStyle: Longword;
begin
  Result := ToolTipStylesValue(fStyles);
end;

procedure TToolTipWindow.TTNGetDispInfo(var Message: TTTNGetDispInfo);
begin
  if Assigned(fOnGetDispInfo) then
    fOnGetDispInfo(Self, Message.lpnmtdi^);
end;

procedure TToolTipWindow.TTNLinkClick(var Message: TTTNLinkClick);
begin
  if Assigned(fOnLinkClick) then
    fOnLinkClick(Self);
end;

procedure TToolTipWindow.TTNPop(var Message: TTTNPop);
begin
  if Assigned(fOnPop) then
    fOnPop(Self, Message.idTT, Message.pnmh^);
  // SS110312: If in-place tooltip canceled, XP does not send further TTN_GETDISPINFO
  PostMessage(Handle, TTM_POP, 0, 0);
end;

procedure TToolTipWindow.TTNShow(var Message: TTTNShow);
begin
  if Assigned(fOnShow) then
    fOnShow(Self, Message.idTT, Message.pnmh^);
end;

class function TToolTipWindow.Window_CallProc(lpPrevWndFunc: TWndProc;
  hWnd: THandle; Msg: Longword; wParam, lParam: Integer): Longint;
begin
  Result := CallWindowProc(lpPrevWndFunc, hWnd, Msg, wParam, lParam);
end;

class function TToolTipWindow.Window_CreateEx(dwExStyle: Longword;
  lpClassName, lpWindowName: PAnsiChar; dwStyle: Longword; x, y, nWidth,
  nHeight: Integer; hWndParent, hMenu: THandle; lpParam: Pointer): THandle;
begin
  Result := CreateWindowEx(dwExStyle, lpClassName, lpWindowName, dwStyle,
    x, y, nWidth, nHeight, hWndParent, hMenu, HInstance, lpParam);
  if Result = 0 then
    RaiseLastWin32Error('CreateWindowEx');
end;

class function TToolTipWindow.Window_GetLong(hWnd: THandle;
  nIndex: Integer): Longint;
begin
  Result := GetWindowLong(hWnd, nIndex);
  if Result = 0 then
    RaiseLastWin32Error('GetWindowLong');
end;

class function TToolTipWindow.Window_SetLong(hWnd: THandle; nIndex,
  dwNewLong: Integer): Longint;
begin
  Result := SetWindowLong(hWnd, nIndex, dwNewLong);
  if Result = 0 then
    RaiseLastWin32Error('SetWindowLong');
end;

class function TToolTipWindow.Window_SetPos(hWnd, hWndInsertAfter: THandle;
  x, y, nWidth, nHeight: Integer; uFlags: Longword): Boolean;
begin
  Result := SetWindowPos(hWnd, hWndInsertAfter, x, y, nWidth, nHeight, uFlags);
  if not Result then
    RaiseLastWin32Error('SetWindowPos');
end;

procedure TToolTipWindow.WMDestroy(var Message: TWMDestroy);
const
  nIndex = GWL_WNDPROC; {offset of value to set}
var
  dwNewLong: Longint; {new value}
begin
  // Remove the subclass from ToolTip control.
  dwNewLong := Longint(fPrevWndProc);
  Window_SetLong(Parent.Handle, nIndex, dwNewLong);
  FreeObjectInstance(fWndProcPtr);
  // SS110312: Force fParent to point nil
  fParent := nil;
end;

function TToolTipWindow.WMNotify(var Message: TWMNotify): Boolean;
begin
  // SS110312: return True if WM_NOTIFY message has been processed
  Result := Message.NMHdr.hwndFrom = Handle;
  if Result then
    case Message.NMHdr.code of
      TTN_GETDISPINFO: TTNGetDispInfo(TTTNGetDispInfo(Message));
      TTN_LINKCLICK: TTNLinkClick(TTTNLinkClick(Message));
      TTN_POP: TTNPop(TTTNPop(Message));
      TTN_SHOW: TTNShow(TTTNShow(Message));
    end;
end;

procedure TToolTipWindow.WndProc(var Msg: TMessage);
var
  Done: Boolean;
begin
  // SS110312: Message have to be dispatched only if it has not been processed
  Done := False;
  case Msg.Msg of
    WM_NOTIFY: Done := WMNotify(TWMNotify(Msg));
    WM_DESTROY: WMDestroy(TWMDestroy(Msg));
  end;

  if not Done and (Parent <> nil) then
    with Msg do
      Result := Window_CallProc(fPrevWndProc, Parent.Handle, Msg, wParam, lParam);
end;

type
  // SS110312: TToolTipList inherits TList instead of TObjectList
  TToolTipList = class(TList)
  private
    function GetItem(Index: Integer): TToolTip;
    procedure SetItem(Index: Integer; const Value: TToolTip);
  protected
    function GetNextId: TToolTipId;

    function DispatchGetDispInfo(AId: TToolTipId;
      var Instance: THandle; var ResName: string;
      var Text: string; Data: Longint): Boolean; virtual;
    procedure DispatchLinkClick(AId: TToolTipId); virtual;
    procedure DispatchPop(AId: TToolTipId); virtual;
    procedure DispatchShow(AId: TToolTipId); virtual;
  public
    procedure Insert(Index: Integer; AObject: TToolTip); virtual;
    function Add(AObject: TToolTip): Integer;
    function Extract(Item: TToolTip): TToolTip;
    function First: TToolTip;
    function Last: TToolTip;
    function IndexOfId(AId: TToolTipId): Integer; virtual;
    function FindById(AId: TToolTipId): TToolTip;
    property Items[Index: Integer]: TToolTip read GetItem write SetItem; default;
  end;

{ TToolTipList }

function TToolTipList.Add(AObject: TToolTip): Integer;
begin
  Result := Count;
  Insert(Result, AObject);
end;

function TToolTipList.DispatchGetDispInfo(AId: TToolTipId;
  var Instance: THandle; var ResName, Text: string;
  Data: Integer): Boolean;
begin
  Result := FindById(AId).DoGetDispInfo(Instance, ResName, Text, Data);
end;

procedure TToolTipList.DispatchLinkClick(AId: TToolTipId);
begin
  FindById(AId).DoLinkClick;
end;

procedure TToolTipList.DispatchPop(AId: TToolTipId);
begin
  FindById(AId).DoPop;
end;

procedure TToolTipList.DispatchShow(AId: TToolTipId);
begin
  FindById(AId).DoShow;
end;

function TToolTipList.Extract(Item: TToolTip): TToolTip;
begin
  Result := TToolTip(inherited Extract(Item));
end;

function TToolTipList.FindById(AId: TToolTipId): TToolTip;
var
  Index: Integer;
begin
  Index := IndexOfId(AId);
  if Index < 0 then
    raise EToolTip.CreateFmt(S_EId, [AId]);
  Result := GetItem(Index);
end;

function TToolTipList.First: TToolTip;
begin
  Result := TToolTip(inherited First);
end;

function TToolTipList.GetItem(Index: Integer): TToolTip;
begin
  // SS110312: Use Get instead of inherited GetItem
  Result := TToolTip(Get(Index));
end;

function TToolTipList.GetNextId: TToolTipId;
begin
  Result := 1;
  while IndexOfId(Result) >= 0 do
    Inc(Result);
end;

function TToolTipList.IndexOfId(AId: TToolTipId): Integer;
var
  Index: Integer;
begin
  Result := -1;
  if Count = 0 then
    Exit;

  for Index := 0 to Count - 1 do
    if Items[Index].Id = AId then
    begin
      Result := Index;
      Break;
    end;
end;

procedure TToolTipList.Insert(Index: Integer; AObject: TToolTip);
begin
  inherited Insert(Index, AObject);
end;

function TToolTipList.Last: TToolTip;
begin
  Result := TToolTip(inherited Last);
end;

procedure TToolTipList.SetItem(Index: Integer; const Value: TToolTip);
begin
  // SS110312: Use Put instead of inherited SetItem
  Put(Index, Value);
end;

{ TToolTipControl }

var
  CommonControls: Cardinal = 0;

var
  AllToolTips: TToolTipList;

const
  TTI_NONE = 0;
  TTI_INFO = 1;
  TTI_WARNING = 2;
  TTI_ERROR = 3;
  TTI_INFO_LARGE = 4;
  TTI_WARNING_LARGE = 5;
  TTI_ERROR_LARGE = 6;

const
  MAX_TITLE = 99;

const
  ToolTipIconValue: array [TToolTipIcon] of Integer = (TTI_NONE, TTI_INFO,
    TTI_WARNING, TTI_ERROR, TTI_INFO_LARGE, TTI_WARNING_LARGE, TTI_ERROR_LARGE);

function GetToolTipIcon(const Value: Integer): TToolTipIcon;
var
  Icon: TToolTipIcon;
begin
  Result := ttiNone;
  for Icon := Low(TToolTipIcon) to High(TToolTipIcon) do
    if Value = ToolTipIconValue[Icon] then
    begin
      Result := Icon;
      Break;
    end;
end;

procedure TToolTipControl.Activate;
begin
  ToolTipsAPI.Activate(Handle, True);
end;

function TToolTipControl.Add(AToolTip: TToolTip): Integer;
begin
  AToolTip.Flags := AToolTip.Flags + fFlagsToInclude - fFlagsToExclude;

  AToolTip.SetOwner(Self);
  AToolTip.AddTool;

  Result := fToolTips.Add(AToolTip);
end;

procedure TToolTipControl.AddHints(AControl: TControl);
var
  Index: Integer;
begin
  if Length(AControl.Hint) > 0 then
  begin
    AControl.ShowHint := False;
    Add(TToolTip.Create(AControl));
  end;

  if AControl.ComponentCount > 0 then
    for Index := 0 to AControl.ComponentCount - 1 do
      if AControl.Components[Index] is TControl then
        AddHints(TControl(AControl.Components[Index]));
end;

function TToolTipControl.AdjustTextRect(var ARect: TRect): Boolean;
begin
  Result := ToolTipsAPI.AdjustRect(Handle, True, @ARect) <> 0;
  AfterAdjustRect(ARect);
end;

function TToolTipControl.AdjustWindowRect(var ARect: TRect): Boolean;
begin
  Result := ToolTipsAPI.AdjustRect(Handle, False, @ARect) <> 0;
  AfterAdjustRect(ARect);
end;

procedure TToolTipControl.AfterAdjustRect(var ARect: TRect);
begin
  // Nothing to do here
end;

procedure TToolTipControl.AfterConstruction;
begin
  inherited;

  fToolTips := TToolTipList.Create;
end;

procedure TToolTipControl.BeforeDestruction;
begin
  while Count > 0 do
    Remove(Items[0]);

  fToolTips.Free;
  // SS110312: Force fInfo.pszTitle to point nil
  fInfo.pszTitle := nil;

  inherited;
end;

class function TToolTipControl.CommonControls_InitEx(
  dwICC: Longword): Boolean;
var
  iccex: TInitCommonControlsEx; {struct specifying control classes to register}
begin
  Result := CommonControls and dwICC = dwICC;
  if Result then
    Exit;

  iccex.dwSize := SizeOf(TInitCommonControlsEx);
  iccex.dwICC := dwICC;
  Result := InitCommonControlsEx(iccex);
  if not Result then
    RaiseLastWin32Error('InitCommonControlsEx');
  CommonControls := CommonControls or dwICC;
end;

constructor TToolTipControl.Create(AParent: TWinControl);
begin
  inherited;

  ZeroMemory(@fInfo, SizeOf(TTTGetTitle));
  fInfo.dwSize := SizeOf(TTTGetTitle);
  // SS110312: Allocate empty string
  fInfo.cch := 0;
  fTitle := #0;
  fInfo.pszTitle := PChar(fTitle);
end;

procedure TToolTipControl.Deactivate;
begin
  ToolTipsAPI.Activate(Handle, False);
end;

function TToolTipControl.EnumTools(iTool: Longword;
  var AInfo: TToolInfo): Boolean;
begin
  Result := ToolTipsAPI.Enum(Handle, iTool, @AInfo);
end;

function TToolTipControl.GetAutoPopTime: Cardinal;
begin
  Result := ToolTipsAPI.GetDelayTime(Handle, TTDT_AUTOPOP);
end;

function TToolTipControl.GetBackColor: TColor;
begin
  Result := ToolTipsAPI.GetBkColor(Handle);
end;

function TToolTipControl.GetBottomMargin: Integer;
begin
  Result := GetMargin.Bottom;
end;

function TToolTipControl.GetCount: Integer;
begin
  Result := fToolTips.Count;
end;

function TToolTipControl.GetCurrentTool: TToolInfo;
begin
  // SS110312: Result.cbSize must be initialized
  Result.cbSize := SizeOf(ToolInfo);
  ToolTipsAPI.GetCurrent(Handle, @Result);
end;

function TToolTipControl.GetCurrentToolExists: Boolean;
begin
  Result := ToolTipsAPI.GetCurrent(Handle, nil) <> 0;
end;

function TToolTipControl.GetIcon: TToolTipIcon;
begin
  // SS110312: fInfo should not be overriden to avoid memory leaks
//  ToolTipsAPI.GetTitle(Handle, @fInfo);
  Result := GetToolTipIcon(fInfo.uTitleBitmap);
end;

function TToolTipControl.GetInitialTime: Cardinal;
begin
  Result := ToolTipsAPI.GetDelayTime(Handle, TTDT_INITIAL);
end;

function TToolTipControl.GetItem(const Index: Integer): TToolTip;
begin
  Result := TToolTipList(fToolTips).Items[Index];
end;

function TToolTipControl.GetLeftMargin: Integer;
begin
  Result := GetMargin.Left;
end;

function TToolTipControl.GetMargin: TRect;
begin
  ToolTipsAPI.GetMargin(Handle, @Result);
end;

function TToolTipControl.GetMaxTipWidth: Integer;
begin
  Result := ToolTipsAPI.GetMaxWidth(Handle);
end;

function TToolTipControl.GetReshowTime: Cardinal;
begin
  Result := ToolTipsAPI.GetDelayTime(Handle, TTDT_RESHOW);
end;

function TToolTipControl.GetRightMargin: Integer;
begin
  Result := GetMargin.Right;
end;

function TToolTipControl.GetTextColor: TColor;
begin
  Result := ToolTipsAPI.GetTextColor(Handle);
end;

function TToolTipControl.GetTool(iTool: Cardinal): TToolInfo;
begin
  ToolTipsAPI.Enum(Handle, iTool, @Result);
end;

function TToolTipControl.GetToolCount: Integer;
begin
  Result := ToolTipsAPI.GetCount(Handle);
end;

function TToolTipControl.GetTopMargin: Integer;
begin
  Result := GetMargin.Top;
end;

function TToolTipControl.HitTest(APoint: TPoint;
  var AInfo: TToolInfo): Boolean;
var
  AHitTestInfo: TTHitTestInfo;
begin
  AHitTestInfo.hwnd := Parent.Handle;
  AHitTestInfo.pt := APoint;
  AHitTestInfo.ti := AInfo;
  Result := ToolTipsAPI.HitTest(Handle, @AHitTestInfo);
  if Result then
    AInfo := AHitTestInfo.ti;
end;

procedure TToolTipControl.Pop;
begin
  ToolTipsAPI.Pop(Handle);
end;

procedure TToolTipControl.Popup;
begin
  ToolTipsAPI.Popup(Handle);
end;

procedure TToolTipControl.RelayEvent(var Msg: TMsg);
begin
  ToolTipsAPI.RelayEvent(Handle, @Msg);
end;

function TToolTipControl.Remove(AToolTip: TToolTip): Integer;
begin
  AToolTip.DelTool;
  AToolTip.SetOwner(nil);

  Result := fToolTips.Remove(AToolTip);

  // SS110312: Destroy AToolTip
  AToolTip.Free;
end;

procedure TToolTipControl.SetAutomaticDelayTime;
begin
  ToolTipsAPI.SetDelayTime(Handle, TTDT_AUTOMATIC, MakeLong(Word(-1), 0));
end;

procedure TToolTipControl.SetAutoPopTime(const Value: Cardinal);
begin
  ToolTipsAPI.SetDelayTime(Handle, TTDT_AUTOPOP, Value);
end;

procedure TToolTipControl.SetBackColor(const Value: TColor);
begin
  ToolTipsAPI.SetBkColor(Handle, Value);
end;

procedure TToolTipControl.SetBottomMargin(const Value: Integer);
var
  AMargin: TRect;
begin
  AMargin := GetMargin;
  AMargin.Bottom := Value;
  Margin := AMargin;
end;

procedure TToolTipControl.SetIcon(const Value: TToolTipIcon);
begin
  // SS110312: fInfo should not be overriden to avoid memory leaks
//  ToolTipsAPI.GetTitle(Handle, @fInfo);
  fInfo.uTitleBitmap := ToolTipIconValue[Value];
  ToolTipsAPI.SetTitle(Handle, fInfo.uTitleBitmap, fInfo.pszTitle);
end;

procedure TToolTipControl.SetInitialTime(const Value: Cardinal);
begin
  ToolTipsAPI.SetDelayTime(Handle, TTDT_INITIAL, Value);
end;

procedure TToolTipControl.SetLeftMargin(const Value: Integer);
var
  AMargin: TRect;
begin
  AMargin := GetMargin;
  AMargin.Left := Value;
  Margin := AMargin;
end;

procedure TToolTipControl.SetMargin(const Value: TRect);
begin
  ToolTipsAPI.SetMargin(Handle, @Value);
end;

procedure TToolTipControl.SetMaxTipWidth(const Value: Integer);
begin
  ToolTipsAPI.SetMaxWidth(Handle, Value);
end;

procedure TToolTipControl.SetReshowTime(const Value: Cardinal);
begin
  ToolTipsAPI.SetDelayTime(Handle, TTDT_RESHOW, Value);
end;

procedure TToolTipControl.SetRightMargin(const Value: Integer);
var
  AMargin: TRect;
begin
  AMargin := GetMargin;
  AMargin.Right := Value;
  Margin := AMargin;
end;

procedure TToolTipControl.SetTextColor(const Value: TColor);
begin
  ToolTipsAPI.SetTextColor(Handle, Value);
end;

procedure TToolTipControl.SetTitle(const Value: string);
begin
  // SS110312: Use local fTitle instead of memory management routines
  if Value = fTitle then
    Exit;

  // SS110312: Remove title limit
  if Length(Value) = 0 then
    fTitle := #0
  else
    fTitle := Value;
  fInfo.cch := Length(Value);
  fInfo.pszTitle := PChar(fTitle);
  ToolTipsAPI.SetTitle(Handle, fInfo.uTitleBitmap, fInfo.pszTitle);
end;

procedure TToolTipControl.SetTopMargin(const Value: Integer);
var
  AMargin: TRect;
begin
  AMargin := GetMargin;
  AMargin.Top := Value;
  Margin := AMargin;
end;

// SS110312: Unicode support improved
procedure TToolTipControl.SetWindowTheme(const ATheme: string);
{$IFDEF UNICODE}
begin
  ToolTipsAPI.SetWindowTheme(Handle, Pointer(ATheme));
{$ELSE}
var
  S: WideString;
begin
  S := ATheme;
  ToolTipsAPI.SetWindowTheme(Handle, PWideChar(S));
{$ENDIF}
end;

procedure TToolTipControl.TrackPosition(X, Y: Word);
begin
  ToolTipsAPI.TrackPosition(Handle, X, Y);
end;

procedure TToolTipControl.TTNGetDispInfo(var Message: TTTNGetDispInfo);
var
  AId: TToolTipId;
  Instance: THandle;
  ResName: string;
  Text: string;
  Data: Longint;
begin
  inherited;

  with Message do
  begin
    AId := lpnmtdi.hdr.idFrom;
    Instance := lpnmtdi.hinst;
    SetLength(ResName, 0);
    SetLength(Text, 0);
    Data := lpnmtdi.lParam;
    if TToolTipList(fToolTips).DispatchGetDispInfo(AId, Instance, ResName, Text,
      Data) then
      lpnmtdi.uFlags := lpnmtdi.uFlags or TTF_DI_SETITEM;
    lpnmtdi.hinst := Instance;
    if Length(Text) > 0 then
    begin
      // SS110312: Use local fTitle instead of memory management routines
      fInfo.cch := Length(Text);
      fTitle := Text;
      lpnmtdi.lpszText := PChar(fTitle);
    end
    else
      // SS110312: If in-place tooltip canceled, XP does not send further TTN_GETDISPINFO,
      //           see http://www.codeproject.com/KB/wtl/WTLTitleTipHandler.aspx?display=Print
      //           for details (German)
      PostMessage(Handle, TTM_POP, 0, 0);
  end;
end;

procedure TToolTipControl.TTNLinkClick(var Message: TTTNLinkClick);
var
  AId: TToolTipId;
begin
  inherited;

  AId := TWMNotify(Message).IDCtrl;
  TToolTipList(fToolTips).DispatchLinkClick(AId);
end;

procedure TToolTipControl.TTNPop(var Message: TTTNPop);
var
  AId: TToolTipId;
begin
  inherited;

  AId := Message.idTT;
  TToolTipList(fToolTips).DispatchPop(AId);
end;

procedure TToolTipControl.TTNShow(var Message: TTTNShow);
var
  AId: TToolTipId;
begin
  inherited;

  AId := Message.idTT;
  TToolTipList(fToolTips).DispatchShow(AId);
  // SS110312: Do not use default tooltip position
  Message.Result := 1;
end;

procedure TToolTipControl.Update;
begin
  ToolTipsAPI.Update(Handle);
end;

function TToolTipControl.WindowFromPoint(APoint: TPoint): THandle;
begin
  Result := ToolTipsAPI.WindowFromPoint(Handle, @APoint);
end;

{ TStandardToolTipControl }

constructor TStandardToolTipControl.Create(AParent: TWinControl);
const
  dwICC = ICC_WIN95_CLASSES;
begin
  if not CommonControls_InitEx(dwICC) then
    raise EToolTip.Create(S_ENotSupported);

  // SS110312: Deal with value of fStyles if CreateStyled has been executed
  fStyles := fStyles + [ttsAlwaysTip, ttsNoPrefix];
  fFlagsToInclude := [ttfSubClass];
  fFlagsToExclude := [ttfTrack];

  inherited;
end;

{ TTrackingToolTipControl }

constructor TTrackingToolTipControl.Create(AParent: TWinControl);
const
  dwICC = ICC_BAR_CLASSES;
begin
  if not CommonControls_InitEx(dwICC) then
    raise EToolTip.Create(S_ENotSupported);

  fStyles := [ttsAlwaysTip, ttsNoPrefix];
  fFlagsToInclude := [ttfTrack];
  fFlagsToExclude := [ttfSubClass];

  inherited;
end;

{ TMultilineToolTipControl }

const
  TTWM_DEFAULT = 250;

constructor TMultilineToolTipControl.Create(AParent: TWinControl);
begin
  inherited;

  SetMaxTipWidth(TTWM_DEFAULT);
end;

{ TBalloonToolTipControl }

constructor TBalloonToolTipControl.Create(AParent: TWinControl);
const
  dwICC = ICC_WIN95_CLASSES;
begin
  if not CommonControls_InitEx(dwICC) then
    raise EToolTip.Create(S_ENotSupported);

  fStyles := [ttsAlwaysTip, ttsBalloon, ttsNoPrefix];
  fFlagsToInclude := [ttfSubClass, ttfTransparent];
  fFlagsToExclude := [ttfTrack];

  inherited;
end;

{ TToolTip }

procedure MakeWords(const lValue: Longword; var wLow, wHigh: Word);
asm
  push EAX
  mov EAX, lValue
  mov [wLow], AX
  shr EAX, 16
  mov [wHigh], AX
  pop EAX
end;

const
  ToolTipFlagValue: array [TToolTipFlag] of Longword = (TTF_ABSOLUTE,
    TTF_CENTERTIP, TTF_IDISHWND, TTF_PARSELINKS, TTF_RTLREADING, TTF_SUBCLASS,
    TTF_TRACK, TTF_TRANSPARENT);

function ToolTipFlagsValue(const Flags: TToolTipFlags): Longword;
var
  Flag: TToolTipFlag;
begin
  Result := 0;
  for Flag := Low(TToolTipFlag) to High(TToolTipFlag) do
    if Flag in Flags then
      Result := Result or ToolTipFlagValue[Flag];
end;

function GetToolTipFlags(const Value: Longword): TToolTipFlags;
var
  Flag: TToolTipFlag;
begin
  Result := [];
  for Flag := Low(TToolTipFlag) to High(TToolTipFlag) do
    if Value and ToolTipFlagValue[Flag] <> 0 then
      Include(Result, Flag);
end;

function TToolTip.AddTool: Boolean;
begin
  CheckOwner('AddTool');
  Result := ToolTipsAPI.Add(Owner.Handle, @fInfo);
end;

procedure TToolTip.AfterConstruction;
begin
  inherited;

  AllToolTips.Add(Self);
end;

procedure TToolTip.BeforeDestruction;
begin
  AllToolTips.Remove(Self);
  // SS110312: Force fInfo.lpszText to point nil
  fInfo.lpszText := nil;

  inherited;
end;

procedure TToolTip.CheckOwner(const MethodName: string);
begin
  if Owner = nil then
    raise EToolTip.CreateFmt(S_ECheckOwner, [ClassName, MethodName]);
end;

constructor TToolTip.Create(AControl: TControl; const GetDispInfo: Boolean;
  AId: TToolTipId);
begin
  inherited Create;

  fOwner := nil;
  fControl := nil;
  fParent := nil;

  (* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE *)
  ZeroMemory(@fInfo, SizeOf(TToolInfo));
  fInfo.cbSize := SizeOf(TToolInfo);
  // SS110312: fInfo.hwnd is the handle of the window that provide the text,
  //           fInfo.uId becomes the handle of the parent
  if AId = TTID_AUTO then
    fInfo.uId := AllToolTips.GetNextId
  else
    fInfo.uId := AId;
  fInfo.hInst := HInstance;
  if GetDispInfo then
  begin
    fInfo.lpszText := LPSTR_TEXTCALLBACK;
    fInfo.uFlags := fInfo.uFlags or TTF_IDISHWND or TTF_TRANSPARENT;
    fInfo.hwnd := AId;
  end;
  fInfo.lParam := Integer(Self);
  SetControl(AControl);
  // SS110312: Initialize fText
  fText := #0;
end;

procedure TToolTip.DelTool;
begin
  CheckOwner('DelTool');
  ToolTipsAPI.Del(Owner.Handle, @fInfo);
end;

function TToolTip.DoGetDispInfo(var Instance: THandle; var ResName,
  Text: string; Data: Integer): Boolean;
begin
  if Assigned(fOnGetDispInfo) then
    Result := fOnGetDispInfo(Self, Instance, ResName, Text, Data)
  else
    Result := False;
end;

procedure TToolTip.DoLinkClick;
begin
  if Assigned(fOnLinkClick) then
    fOnLinkClick(Self);
end;

procedure TToolTip.DoPop;
begin
  if Assigned(fOnPop) then
    fOnPop(Self);
end;

procedure TToolTip.DoShow;
begin
  if Assigned(fOnShow) then
    fOnShow(Self);
end;

function TToolTip.GetBubbleSize: TSize;
var
  ABubbleSize: Longint;
  wLow, wHigh: Word;
begin
  CheckOwner('GetBubbleSize');
  if fTrackActivated then
    ABubbleSize := ToolTipsAPI.GetBubbleSize(Owner.Handle, @fInfo)
  else
    ABubbleSize := 0;
  wLow := 0;
  wHigh := 0;
  if ABubbleSize <> 0 then
    MakeWords(ABubbleSize, wLow, wHigh);
  Result.cx := wLow;
  Result.cy := wHigh;
end;

function TToolTip.GetClipRect: TRect;
begin
  if Owner <> nil then
    ToolTipsAPI.GetInfo(Owner.Handle, @fInfo);
  Result := fInfo.Rect;
end;

function TToolTip.GetFlags: TToolTipFlags;
begin
  // SS110312: fInfo should not be overriden to avoid memory leaks
//  if Owner <> nil then
//    ToolTipsAPI.GetInfo(Owner.Handle, @fInfo);
  Result := GetToolTipFlags(fInfo.uFlags);
end;

function TToolTip.GetId: TToolTipId;
begin
  Result := fInfo.uId;
end;

function TToolTip.GetToolInfo: TToolInfo;
begin
  CheckOwner('GetToolInfo');
  ToolTipsAPI.GetInfo(Owner.Handle, @Result);
end;

class function TToolTip.GetWinControl(AControl: TControl): TWinControl;
begin
  if AControl is TWinControl then
    Result := TWinControl(AControl)
  else if AControl.Parent <> nil then
    Result := AControl.Parent
  else if AControl.Owner is TControl then
    Result := GetWinControl(TControl(AControl.Owner))
  else
    raise EToolTip.CreateFmt(S_ENoWindow, [AControl.Name, AControl.ClassName]);
end;

procedure TToolTip.NewToolRect(const ARect: TRect);
begin
  fInfo.Rect := ARect;
  if Owner <> nil then
    ToolTipsAPI.NewRect(Owner.Handle, @fInfo);
end;

procedure TToolTip.SetClipRect(const Value: TRect);
begin
  fInfo.Rect := Value;
  if Owner <> nil then
    ToolTipsAPI.SetInfo(Owner.Handle, @fInfo);
end;

procedure TToolTip.SetClipRect(AControl: TControl; const Value: TRect);
var
  ARect: TRect;
begin
  if (AControl = nil) or (AControl is TWinControl) or
    (AControl.Parent = nil) then
    ARect := Value
  else
  begin
    ARect.TopLeft := AControl.ClientToParent(Point(0, 0), AControl.Parent);
    ARect.Right := ARect.Left + AControl.ClientRect.Left +
      AControl.ClientWidth;
    ARect.Bottom := ARect.Top + AControl.ClientRect.Top +
      AControl.ClientHeight;
  end;
  SetClipRect(ARect);
end;

procedure TToolTip.SetControl(const Value: TControl);
var
  ARect: TRect;
begin
  if Value = fControl then
    Exit;

  fControl := Value;
  if fControl = nil then
  begin
    fParent := nil;
    fInfo.hwnd := INVALID_HANDLE_VALUE;
    ZeroMemory(@ARect, SizeOf(TRect));
  end
  else
  begin
    fParent := GetWinControl(fControl);
    // SS110312: Store parental handle depending on TTF_IDISHWND presence
    if fInfo.uFlags and TTF_IDISHWND = TTF_IDISHWND then
      fInfo.uId := fParent.Handle
    else
      fInfo.hwnd := fParent.Handle;
    if fControl is TWinControl then
      ARect := fControl.ClientRect
    else
    begin
      ARect.TopLeft := fControl.ClientToParent(Point(0, 0), fParent);
      ARect.Right := ARect.Left + fControl.ClientRect.Left +
        fControl.ClientWidth;
      ARect.Bottom := ARect.Top + fControl.ClientRect.Top +
        fControl.ClientHeight;
    end;
    if fInfo.lpszText <> LPSTR_TEXTCALLBACK then
      SetText(fControl.Hint);
  end;
  SetClipRect(ARect);
end;

procedure TToolTip.SetFlags(const Value: TToolTipFlags);
begin
  fInfo.uFlags := ToolTipFlagsValue(Value);
  if Owner <> nil then
    ToolTipsAPI.SetInfo(Owner.Handle, @fInfo);
end;

procedure TToolTip.SetInfo(const Value: TToolInfo);
begin
  fInfo := Value;
  if Owner <> nil then
    ToolTipsAPI.SetInfo(Owner.Handle, @fInfo);
end;

procedure TToolTip.SetOwner(const Value: TToolTipControl);
begin
  fOwner := Value;
  if Owner <> nil then
    Owner.Update;
  fTrackActivated := False;
end;

procedure TToolTip.SetText(const Value: string);
begin
  // SS110312: Use local fText instead of memory management routines
  if Value = fText then
    Exit;

  fText := Value;
  if Length(Value) > 0 then
  begin
    if fInfo.lpszText = LPSTR_TEXTCALLBACK then
      raise EToolTip.Create(S_ESetText);

    fInfo.lpszText := PChar(fText);
  end
  else if fInfo.lpszText <> LPSTR_TEXTCALLBACK then
    fInfo.lpszText := nil
  else
  begin
    fText := #0;
    fInfo.lpszText := PChar(fText);
  end;

  if Owner <> nil then
    ToolTipsAPI.UpdateText(Owner.Handle, @fInfo);
end;

procedure TToolTip.TrackActivate;
begin
  CheckOwner('TrackActivate');
  ToolTipsAPI.TrackActivate(Owner.Handle, True, @fInfo);
  fTrackActivated := True;
end;

procedure TToolTip.TrackDisactivate;
begin
  CheckOwner('TrackDisactivate');
  ToolTipsAPI.TrackActivate(Owner.Handle, False, @fInfo);
end;

procedure TToolTip.TrackPosition(X, Y: Word);
begin
  CheckOwner('TrackPosition');
  Owner.TrackPosition(X, Y);
end;

{ TInPlaceToolTipControl }

procedure TInPlaceToolTipControl.AfterAdjustRect(var ARect: TRect);
const
  hWndInsertAfter = HWND_TOP; {placement-order handle}
  uFlags = SWP_NOSIZE or SWP_NOZORDER or SWP_NOACTIVATE; {positioning flags}
var
  x: Integer; {horizontal position of window}
  y: Integer; {vertical position of window}
  nWidth: Integer; {window width}
  nHeight: Integer; {window height}
begin
  inherited;

  x := ARect.Left;
  y := ARect.Top;
  nWidth := 0;
  nHeight := 0;
  Window_SetPos(Handle, hWndInsertAfter, x, y, nWidth, nHeight, uFlags);
end;

initialization
  AllToolTips := TToolTipList.Create;

finalization
  AllToolTips.Free;

end.
Added src/delphisci/Accessor.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
{
 Unit    : Accessor
 Purpose : Delphi implementation of Accessor class.
 Created : 05/03/2001
 Author  : Simon Steele (ss@pnotepad.org)
      $Id: Accessor.pas,v 1.4 2004/11/13 04:29:49 hdalis Exp $
 History : 03/12/2001 Fixed indentation (uses tabs).
           29/09/2004 Initial Release with Delphi Scintilla Interface Components
                      Not really in use yet.
                      hdalis (hdalis@users.sourceforge.net)
           25/02/2005 Changed this to fit the TScintillaBase instead of dealing with handles
                      and such.. Swapped the contents of LevelAt and LineStart functions as it was
                      swapped before..
                      It's a bit more useful for the components now I think..
                      hdalis (hdalis@users.sourceforge.net)
}
{$Include SciCommonDef.Inc}
unit Accessor;
interface
uses scisupport,scilexer, classes, windows;
const
  extremePosition = $7FFFFFFF;
  bufferSize = 4000;
  slopSize = (bufferSize div 8);
  wsSpace = 1;
  wsTab = 2;
  wsSpaceTab = 4;
  wsInconsistent = 8;
{
void WindowAccessor::StartSegment(unsigned int pos) {
void WindowAccessor::ColourTo(unsigned int pos, int chAttr) {
}

type
    PAccessor = ^TAccessor;
    TfnIsCommentLeader = function(styler : PAccessor; pos, len : Integer) : Boolean;
    TAccessor = class(TObject)
    private
        function Get(Position: Integer): Char;
        function InternalIsLeadByte(ch : Char) : Boolean;
    protected
        id : TScintillaBase;
        buf : array[0..bufferSize] of Char;
        styleBuf : array[0..bufferSize] of Char;
        startPos : Integer;
        endPos : Integer;
        codePage : Integer;
        lenDoc : Integer;
        validLen : Integer;
        chFlags : Char;
        chWhile : Char;
        startSeg : Cardinal;
        procedure Fill(Position : Integer);
  public
        function StyleAt(Position : Integer) : Char;
        function GetLine(Position : Integer) : Integer;
        function LineStart(line : Integer) : Integer;
        function LevelAt(line : Integer) : Integer;
        property Chars[Position: Integer]: Char read Get; default;
        // Safe version of [] returns default value for invalid position.
        function SafeGetCharAt(Position : Integer; chDefault : Char = ' ') : Char;
        procedure SetCodePage(codePage_ : Integer);
        function Len : Integer;
        function GetLineState(Line : Integer) : Integer;
        procedure SetLineState(Line, State : Integer);
        procedure StartAt(start : Cardinal; chMask : Char = #31);
        procedure StartSegment(Pos : Cardinal);
        procedure ColourTo(Pos : Cardinal; chAttr : Integer);
        procedure Flush;
        procedure SetLevel(Line, Level : Integer);
        function IndentAmount(Line : Integer; var Flags : Integer; pfnIsCommentLeader : TfnIsCommentLeader) : Integer;
        function IsLeadByte(ch : Char) : Boolean;
        procedure SetFlags(chFlags_, chWhile_ : Char);
        function GetStartSegment : Integer;
        constructor Create(windowID : TScintillaBase);
        destructor Destroy; override;
  end;

function isspacechar(ch : Char) : Boolean;
function tolower(ch : Char) : Char;
function isspace(ch : Char) : Boolean;
function isdigit(ch : Char) : Boolean;
function isoperator(ch : Char) : Boolean;
function isascii(ch : Char) : Boolean;
function isalnum(ch : Char) : Boolean;
function iswordchar(ch : Char) : Boolean;
function iswordstart(ch : Char) : Boolean;

implementation

function isascii(ch : Char) : Boolean;
begin
  Result := Ord(ch) < $80;
end;

function isalnum(ch : Char) : Boolean;
var i : Integer;
begin
  i := Ord(ch);
  Result := (
         ((i >= 48) and (i <= 57)) or
         ((i >= 65) and (i <= 90)) or
         ((i >= 97) and (i <= 122))
         );
end;

function isoperator(ch : Char) : Boolean;
begin
  if (isascii(ch) and isalnum(ch)) then
  begin
      Result := false;
      Exit;
  end;
  // '.' left out as it is used to make up numbers
  Result := ((ch = '%') or (ch = '^') or (ch = '&') or (ch = '*') or
          (ch = '(') or (ch = ')') or (ch = '-') or (ch = '+') or
          (ch = '=') or (ch = '|') or (ch = '{') or (ch = '}') or
          (ch = '[') or (ch = ']') or (ch = ':') or (ch = ';') or
          (ch = '<') or (ch = '>') or (ch = ',') or (ch = '/') or
          (ch = '?') or (ch = '!') or (ch = '.') or (ch = '~'));
end;

function isspacechar(ch : Char) : Boolean;
begin
  Result := ((ch = #09) or (ch = #13) or (ch = #32));
end;

function isspace(ch : Char) : Boolean;
begin
  Result := ((ch = #09) or (ch = #10) or (ch = #13) or (ch = #32));
end;

function tolower(ch : Char) : Char;
var i : Integer;
begin
  i := Ord(ch);
  if (i >= 65) and (i <= 90) then
    Result := Chr(i + 32)
  else
    Result := ch;
end;

function isdigit(ch : Char) : Boolean;
var i : Integer;
begin
  i := Ord(ch);
  Result := ( (i >= 48) and (i <= 57));
end;

function iswordchar(ch : Char) : Boolean;
begin
  Result := isascii(ch) and (isalnum(ch) or (ch = '.') or (ch = '_'));
end;

function iswordstart(ch : Char) : Boolean;
begin
  Result := isascii(ch) and (isalnum(ch) or (ch = '_'));
end;

{ TAccessor }

procedure TAccessor.ColourTo(Pos: Cardinal; chAttr: Integer);
var i : Cardinal;
begin
    if Pos <> (StartSeg - 1) then
    begin
    if Pos < startSeg then
      OutputDebugString('Bad Colour Positions'); // %d - %d : startSeg, pos

    if Cardinal(validLen) + (Pos - startSeg + 1) >= bufferSize then
      Flush;

    if Cardinal(validLen) + (Pos - startSeg + 1) >= bufferSize then
    begin
      // Too big for buffer size so send directly
      id.SetStyling(Pos - startSeg + 1, chAttr);
    end else
    begin
      if (Char(chAttr) <> chWhile) then
        chFlags := #0;
      chAttr := chAttr or Ord(chFlags);
      for i := startSeg to Pos do
      begin
        styleBuf[validLen] := Char(chAttr);
        Inc(validLen);
      end;
    end;
  end;
  startSeg := Pos + 1;
end;

constructor TAccessor.Create(windowID: TScintillaBase);
begin
  inherited Create;
  id := windowID;
  lenDoc := -1;
  startPos := extremePosition;
  endPos := 0;
  codePage := 0;
  validLen := 0;
  chFlags := #0;
  chWhile := #0;
//TODO Properties...
end;

destructor TAccessor.Destroy;
begin
  inherited;
end;

procedure TAccessor.Fill(Position: Integer);
var
  tr : TTextRange;
begin
  if lenDoc = -1 then
    lenDoc := id.GetTextLength;
  startPos := Position - slopSize;
  if (startPos + bufferSize > lenDoc) then
    startPos := lenDoc - bufferSize;
  if (startPos < 0) then
    startPos := 0;
  endPos := startPos + bufferSize;
  if (endPos > lenDoc) then
    endPos := lenDoc;

  tr.chrg.cpMin := startPos;
  tr.chrg.cpMax := endPos;
  tr.lpstrText := buf;

  id.GetTextRange(@tr);
end;

procedure TAccessor.Flush;
begin
    startPos := extremePosition;
    lenDoc := -1;
    if (validLen > 0) then
    begin
    id.SetStylingEx(validLen, PChar(@styleBuf));
    validLen := 0;
  end;
end;

function TAccessor.Get(Position: Integer): Char;
begin
  if (Position < startPos) or (Position >= endPos) then
    Fill(Position);
  Result := buf[Position - startPos];
end;

function TAccessor.GetLine(Position: Integer): Integer;
begin
  Result := id.LineFromPosition(Position);
end;

function TAccessor.GetLineState(Line: Integer): Integer;
begin
  Result := id.GetLineState(Line);
end;

function TAccessor.Len: Integer;
begin
  Result := id.GetTextLength;
end;

function TAccessor.LevelAt(line: Integer): Integer;
begin
  Result := id.GetFoldLevel(line);
end;

function TAccessor.LineStart(line: Integer): Integer;
begin
   Result := id.PositionFromLine(line);
end;

function TAccessor.SafeGetCharAt(Position: Integer; chDefault: Char): Char;
begin
  if (Position < startPos) or (Position >= endPos) then
  begin
    Fill(Position);
    if (Position < startPos) or (Position >= endPos) then
    begin
      Result := chDefault;
      Exit;
      end;
    end;
  Result := buf[Position - startPos];
end;

procedure TAccessor.SetCodePage(codePage_: Integer);
begin
  codePage := codePage_;
end;

procedure TAccessor.SetLevel(Line, Level: Integer);
begin
  id.SetFoldLevel(Line, Level);
end;

procedure TAccessor.SetLineState(Line, State: Integer);
begin
  id.SetLineState(Line, State);
end;

procedure TAccessor.StartAt(start: Cardinal; chMask: Char);
begin
  id.StartStyling(start, Ord(chMask));
end;

procedure TAccessor.StartSegment(Pos: Cardinal);
begin
  startSeg := Pos;
end;

function TAccessor.StyleAt(Position: Integer): Char;
begin
  Result := Char( id.GetStyleAt(Position) );
end;

function TAccessor.IndentAmount(Line : Integer; var Flags : Integer; pfnIsCommentLeader : TfnIsCommentLeader) : Integer;
var
  iend : Integer;
  spaceFlags : Integer;
  Pos : Integer;
  ch : Char;
  chPrev : Char;
  indent : Integer;
  inPrevPrefix : Boolean;
  posPrev : Integer;
begin
    iend := Len;
    spaceFlags := 0;

  // Determines the indentation level of the current line and also checks for consistent
  // indentation compared to the previous line.
  // Indentation is judged consistent when the indentation whitespace of each line lines
  // the same or the indentation of one line is a prefix of the other.

  pos := LineStart(line);
  ch := Chars[Pos];
  indent := 0;
  inPrevPrefix := line > 0;
  if inPrevPrefix then
      posPrev := LineStart(line-1)
    else
      posPrev := 0;

  while ( ((ch = ' ') or (ch = #09)) and (pos < iend) ) do
  begin
    if (inPrevPrefix) then
    begin
      chPrev := Chars[posPrev];
      Inc(posPrev);
      if ((chPrev = ' ') or (chPrev = #09)) then
      begin
        if (chPrev <> ch) then
          spaceFlags := spaceFlags or wsInconsistent;
      end else
      begin
        inPrevPrefix := false;
      end;
    end;
    if (ch = ' ') then
    begin
      spaceFlags := spaceFlags or wsSpace;
      Inc(indent);
    end else
    begin  // Tab
      spaceFlags := spaceFlags or wsTab;
      if ((spaceFlags and wsSpace) = wsSpace) then
        spaceFlags := spaceFlags or wsSpaceTab;
      indent := (indent div 8 + 1) * 8;
    end;
    Inc(Pos);
    ch := Chars[Pos];
  end;

  Flags := spaceFlags;
  indent := indent + SC_FOLDLEVELBASE;
  // if completely empty line or the start of a comment...
  if ( isspace(ch) or ((@pfnIsCommentLeader <> nil) and pfnIsCommentLeader(@self, pos, iend-pos) ) ) then
  begin
    result :=  indent or SC_FOLDLEVELWHITEFLAG;
  end else
    result := indent;
end;

function TAccessor.IsLeadByte(ch: Char): Boolean;
begin
  Result := (codePage > 0) and InternalIsLeadByte(ch);
end;

function TAccessor.InternalIsLeadByte(ch: Char): Boolean;
begin
  if (SC_CP_UTF8 = codePage) then
    // For lexing, all characters >= 0x80 are treated the
    // same so none is considered a lead byte.
    Result :=  false
  else
    Result := IsDBCSLeadByteEx(codePage, Byte(ch));
end;

function TAccessor.GetStartSegment: Integer;
begin
  Result := startSeg;
end;

procedure TAccessor.SetFlags(chFlags_, chWhile_: Char);
begin
  chFlags := chFlags_;
  chWhile := chWhile_;
end;

end.
Added src/delphisci/EdOptionsWin.ddp.

cannot compute difference between binary files

Added src/delphisci/EdOptionsWin.dfm.
























































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
object EdOptionsWindow: TEdOptionsWindow
  Left = 830
  Top = 236
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  Caption = 'Editor Options'
  ClientHeight = 410
  ClientWidth = 380
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBtnText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poScreenCenter
  ShowHint = True
  OnCreate = FormCreate
  OnDestroy = FormDestroy
  PixelsPerInch = 96
  TextHeight = 13
  object OptionPages: TPageControl
    Left = 0
    Top = 0
    Width = 380
    Height = 372
    ActivePage = OptionsPage
    Align = alTop
    TabOrder = 0
    OnChange = OptionPagesChange
    object OptionsPage: TTabSheet
      Caption = 'Options'
      object optionsPanel: TPanel
        Left = 0
        Top = 0
        Width = 372
        Height = 344
        Align = alClient
        BevelOuter = bvNone
        TabOrder = 0
        object viewOptionsBox: TGroupBox
          Left = 0
          Top = 0
          Width = 183
          Height = 188
          Caption = 'View Options'
          TabOrder = 0
          object CodeFoldingCB: TCheckBox
            Left = 38
            Top = 75
            Width = 112
            Height = 17
            Caption = 'Code Folding'
            TabOrder = 2
          end
          object GutterCB: TCheckBox
            Left = 38
            Top = 34
            Width = 112
            Height = 17
            Caption = 'Gutter'
            TabOrder = 0
          end
          object LineNumbersCB: TCheckBox
            Left = 38
            Top = 54
            Width = 112
            Height = 17
            Caption = 'Line Numbers'
            TabOrder = 1
          end
          object IndentationGuidesCB: TCheckBox
            Left = 38
            Top = 96
            Width = 112
            Height = 17
            Caption = 'Indentation Guides'
            TabOrder = 3
          end
          object BraceHiliteCB: TCheckBox
            Left = 38
            Top = 117
            Width = 112
            Height = 17
            Caption = 'Brace Highlight'
            TabOrder = 4
          end
          object WordWrapCB: TComboBox
            Left = 38
            Top = 140
            Width = 120
            Height = 21
            Style = csDropDownList
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 13
            ItemIndex = 0
            ParentFont = False
            TabOrder = 5
            Text = 'No Word wrap'
            Items.Strings = (
              'No Word wrap'
              'Word Wrap'
              'Wrap Characters')
          end
        end
        object gbRightEdge: TGroupBox
          Left = 187
          Top = 190
          Width = 183
          Height = 153
          Caption = 'Right Edge'
          TabOrder = 3
          object Label28: TLabel
            Left = 6
            Top = 71
            Width = 55
            Height = 13
            Caption = 'Edge Color:'
            Transparent = True
          end
          object Label29: TLabel
            Left = 15
            Top = 41
            Width = 46
            Height = 13
            Caption = 'Edge Col:'
            Transparent = True
          end
          object Label30: TLabel
            Left = 6
            Top = 99
            Width = 55
            Height = 13
            Caption = 'Edge Type:'
            Transparent = True
          end
          object EdgeColumnSE: TEdit
            Left = 62
            Top = 38
            Width = 51
            Height = 21
            Hint = 'Edge Column'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ParentFont = False
            TabOrder = 0
            Text = '0'
            OnKeyPress = TestNumericOnly
          end
          object EdgeColorCB: TColorBox
            Left = 62
            Top = 66
            Width = 110
            Height = 22
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 1
          end
          object EdgeTypeCB: TComboBox
            Left = 62
            Top = 94
            Width = 110
            Height = 21
            Style = csDropDownList
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 13
            ParentFont = False
            TabOrder = 2
            Items.Strings = (
              'None'
              'Line'
              'Background')
          end
        end
        object indentationBox: TGroupBox
          Left = 188
          Top = 0
          Width = 183
          Height = 188
          Caption = 'Indentation Options'
          TabOrder = 1
          object Label1: TLabel
            Left = 27
            Top = 128
            Width = 64
            Height = 13
            Caption = 'Indent Width:'
          end
          object Label2: TLabel
            Left = 38
            Top = 100
            Width = 53
            Height = 13
            Caption = 'Tab Width:'
          end
          object KeepIndentCB: TCheckBox
            Left = 26
            Top = 34
            Width = 117
            Height = 17
            Caption = 'Keep Indent'
            TabOrder = 0
          end
          object TabIndentsCB: TCheckBox
            Left = 26
            Top = 54
            Width = 117
            Height = 17
            Caption = 'Tab Indents'
            TabOrder = 1
          end
          object BackSpaceUnIndentsCB: TCheckBox
            Left = 26
            Top = 75
            Width = 117
            Height = 17
            Caption = 'B.Space Unindents'
            TabOrder = 2
          end
          object TabWidthSE: TEdit
            Left = 95
            Top = 96
            Width = 41
            Height = 21
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ParentFont = False
            TabOrder = 3
            OnKeyPress = TestNumericOnly
          end
          object IndentWidthSE: TEdit
            Left = 95
            Top = 124
            Width = 41
            Height = 21
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ParentFont = False
            TabOrder = 4
            OnKeyPress = TestNumericOnly
          end
        end
        object OtherGB: TGroupBox
          Left = 1
          Top = 190
          Width = 183
          Height = 153
          Caption = 'Other Options'
          TabOrder = 2
          object Label3: TLabel
            Left = 18
            Top = 113
            Width = 50
            Height = 13
            Caption = 'EOL Style:'
            Transparent = True
          end
          object Label43: TLabel
            Left = 15
            Top = 85
            Width = 53
            Height = 13
            Caption = 'CodePage:'
          end
          object SaveClearsUndoCB: TCheckBox
            Left = 32
            Top = 40
            Width = 115
            Height = 17
            Hint = 'Clear the undobuffer when saving.'
            Caption = 'Save Clears Undo'
            TabOrder = 0
          end
          object ReadOnlyCB: TCheckBox
            Left = 32
            Top = 60
            Width = 115
            Height = 17
            Caption = 'Read Only'
            TabOrder = 1
          end
          object EOLStyleCB: TComboBox
            Left = 71
            Top = 110
            Width = 97
            Height = 21
            Hint = 
              'Sets the characters that are added into the document when the us' +
              'er presses the Enter key. Default CRLF'
            Style = csDropDownList
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 13
            ParentFont = False
            TabOrder = 2
            Items.Strings = (
              'CR+LF'
              'CR'
              'LF')
          end
          object CodePageCB: TComboBox
            Left = 72
            Top = 82
            Width = 96
            Height = 21
            Style = csDropDownList
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 13
            ParentFont = False
            TabOrder = 3
          end
        end
      end
    end
    object ColorsPage: TTabSheet
      Caption = 'Colors etc'
      ImageIndex = 4
      object colorsPanel: TPanel
        Left = 0
        Top = 0
        Width = 372
        Height = 344
        Align = alClient
        BevelOuter = bvNone
        TabOrder = 0
        object MarkersGB: TGroupBox
          Left = 0
          Top = 124
          Width = 372
          Height = 78
          Align = alTop
          Caption = 'Markers'
          TabOrder = 2
          object Label20: TLabel
            Left = 188
            Top = 22
            Width = 61
            Height = 13
            Caption = 'Marker Back'
            Transparent = True
          end
          object Label21: TLabel
            Left = 8
            Top = 22
            Width = 57
            Height = 13
            Caption = 'Marker Fore'
            Transparent = True
          end
          object Label22: TLabel
            Left = 187
            Top = 48
            Width = 62
            Height = 13
            Caption = 'B.Mark Back'
            Transparent = True
          end
          object Label23: TLabel
            Left = 7
            Top = 48
            Width = 58
            Height = 13
            Caption = 'B.Mark Fore'
            Transparent = True
          end
          object MarkerForeCB: TColorBox
            Left = 70
            Top = 18
            Width = 110
            Height = 22
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 0
          end
          object MarkerBackCB: TColorBox
            Left = 252
            Top = 18
            Width = 110
            Height = 22
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 1
          end
          object BMarkForeCB: TColorBox
            Left = 70
            Top = 45
            Width = 110
            Height = 22
            Hint = 'Bookmark foreground color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 2
          end
          object BMarkBackCB: TColorBox
            Left = 252
            Top = 45
            Width = 110
            Height = 22
            Hint = 'Bookmark background color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 3
          end
        end
        object CaretGB: TGroupBox
          Left = 0
          Top = 49
          Width = 372
          Height = 75
          Align = alTop
          Caption = 'Caret'
          TabOrder = 1
          object Label13: TLabel
            Left = 12
            Top = 24
            Width = 24
            Height = 13
            Caption = 'Color'
            Transparent = True
          end
          object Label15: TLabel
            Left = 165
            Top = 24
            Width = 81
            Height = 13
            Caption = 'Line Background'
            Transparent = True
          end
          object Label14: TLabel
            Left = 8
            Top = 48
            Width = 28
            Height = 13
            Caption = 'Width'
            Transparent = True
          end
          object CaretCB: TColorBox
            Left = 40
            Top = 19
            Width = 110
            Height = 22
            Hint = 'Caret Color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 0
          end
          object CaretBackCB: TColorBox
            Left = 250
            Top = 19
            Width = 110
            Height = 22
            Hint = 'Caret line background color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 1
          end
          object CaretWidthSE: TEdit
            Left = 40
            Top = 45
            Width = 40
            Height = 21
            Hint = 'Width of the caret (0-3)'
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ParentFont = False
            TabOrder = 2
            OnKeyPress = TestNumericOnly
          end
          object CaretLineVisCB: TCheckBox
            Left = 160
            Top = 49
            Width = 103
            Height = 17
            Hint = 
              'Checked when the caretline should be shown with the defined colo' +
              'r'
            Alignment = taLeftJustify
            Caption = 'Caret Line Visible'
            TabOrder = 3
          end
        end
        object SelectionGB: TGroupBox
          Left = 0
          Top = 0
          Width = 372
          Height = 49
          Align = alTop
          Caption = 'Selection'
          TabOrder = 0
          object Label16: TLabel
            Left = 6
            Top = 22
            Width = 54
            Height = 13
            Caption = 'Foreground'
            Transparent = True
          end
          object Label17: TLabel
            Left = 187
            Top = 22
            Width = 58
            Height = 13
            Caption = 'Background'
            Transparent = True
          end
          object SelForeCB: TColorBox
            Left = 63
            Top = 17
            Width = 110
            Height = 22
            Hint = 'Selection foreground color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 0
          end
          object SelBackCB: TColorBox
            Left = 250
            Top = 17
            Width = 110
            Height = 22
            Hint = 'Selection background color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 1
          end
        end
        object HotspotGB: TGroupBox
          Left = 0
          Top = 276
          Width = 372
          Height = 68
          Align = alClient
          Caption = 'Active Hotspot'
          TabOrder = 4
          object Label24: TLabel
            Left = 11
            Top = 23
            Width = 54
            Height = 13
            Caption = 'Foreground'
            Transparent = True
          end
          object Label25: TLabel
            Left = 192
            Top = 23
            Width = 58
            Height = 13
            Caption = 'Background'
            Transparent = True
          end
          object HotActiveForeCB: TColorBox
            Left = 70
            Top = 19
            Width = 110
            Height = 22
            Hint = 'Hotspot foreground color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 0
          end
          object HotActiveBackCB: TColorBox
            Left = 253
            Top = 19
            Width = 110
            Height = 22
            Hint = 'Hotspot background color'
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 1
          end
          object HotActiveUnderlineCB: TCheckBox
            Left = 59
            Top = 45
            Width = 70
            Height = 17
            Hint = 'Underline when the mouse hovers over the hotspot'
            Caption = 'Underline'
            TabOrder = 2
          end
          object HotActiveSingleLineCB: TCheckBox
            Left = 238
            Top = 45
            Width = 74
            Height = 17
            Hint = 'Single line mode stops a hotspot from wrapping onto next line'
            Caption = 'Single Line'
            TabOrder = 3
          end
        end
        object FoldingGB: TGroupBox
          Left = 0
          Top = 202
          Width = 372
          Height = 74
          Align = alTop
          Caption = 'Folding'
          TabOrder = 3
          object Label26: TLabel
            Left = 10
            Top = 22
            Width = 55
            Height = 13
            Caption = 'Fold Margin'
            Transparent = True
          end
          object Label27: TLabel
            Left = 185
            Top = 22
            Width = 64
            Height = 13
            Caption = 'Fold Highlight'
            Transparent = True
          end
          object Label31: TLabel
            Left = 41
            Top = 47
            Width = 24
            Height = 13
            Caption = 'Type'
            Transparent = True
          end
          object FoldLoCB: TColorBox
            Left = 70
            Top = 19
            Width = 110
            Height = 22
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 0
          end
          object FoldHiCB: TColorBox
            Left = 252
            Top = 19
            Width = 110
            Height = 22
            Selected = clDefault
            Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 16
            ParentFont = False
            TabOrder = 1
          end
          object markerTypeCB: TComboBox
            Left = 71
            Top = 45
            Width = 109
            Height = 21
            Style = csDropDownList
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 13
            ParentFont = False
            TabOrder = 2
            Items.Strings = (
              'Circle'
              'Box'
              'Plus/Minus'
              'Arrows'
              'Custom')
          end
        end
      end
    end
    object HighlighterPage: TTabSheet
      Caption = 'LanguageManager'
      ImageIndex = 1
      object highlighterPanel: TPanel
        Left = 0
        Top = 0
        Width = 372
        Height = 344
        Align = alClient
        BevelOuter = bvNone
        TabOrder = 0
        object languageCBBox: TGroupBox
          Left = 0
          Top = 0
          Width = 372
          Height = 45
          Align = alTop
          Caption = 'Language'
          TabOrder = 0
          object LanguageCB: TComboBox
            Left = 9
            Top = 18
            Width = 145
            Height = 21
            Hint = 'The selected language/lexer.'
            Style = csDropDownList
            Font.Charset = DEFAULT_CHARSET
            Font.Color = clWindowText
            Font.Height = -11
            Font.Name = 'MS Sans Serif'
            Font.Style = []
            ItemHeight = 0
            ParentFont = False
            Sorted = True
            TabOrder = 0
            OnChange = LanguageCBChange
          end
          object addLangButton: TBitBtn
            Left = 163
            Top = 17
            Width = 58
            Height = 22
            Hint = 'Add new language'
            Caption = 'Add'
            TabOrder = 1
            OnClick = addLangButtonClick
            Glyph.Data = {
              DE010000424DDE01000000000000760000002800000024000000120000000100
              0400000000006801000000000000000000001000000010000000000000000000
              80000080000000808000800000008000800080800000C0C0C000808080000000
              FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000666666666666666666666666666666666666000066666666FFF666666666
              666666FFF666666600006666666844F66666666666666888F666666600006666
              666844F66666666666666888F666666600006666666844F66666666666666888
              F666666600006666FFF644FFFFF6666666FFF888FFFFF6660000666844444444
              44F66666688888888888F666000066684444444444F66666688888888888F666
              000066688888446888666666688888888888666600006666666844F666666666
              66666888F666666600006666666844F66666666666666888F666666600006666
              666844F66666666666666888F666666600006666666888666666666666666888
              6666666600006666666666666666666666666666666666660000666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000}
            NumGlyphs = 2
          end
          object remLangButton: TBitBtn
            Left = 305
            Top = 17
            Width = 58
            Height = 22
            Hint = 'Remove selected language'
            Caption = 'Rem'
            TabOrder = 3
            OnClick = remLangButtonClick
            Glyph.Data = {
              DE010000424DDE01000000000000760000002800000024000000120000000100
              0400000000006801000000000000000000001000000010000000000000000000
              80000080000000808000800000008000800080800000C0C0C000808080000000
              FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000666666666666661F66666666666666668F66000066661F66666666666666
              668F6666666666660000666111F6666661F666666888F6666668F66600006661
              11F666661F6666666888F666668F666600006666111F66611F66666666888F66
              688F6666000066666111F611F6666666666888F688F66666000066666611111F
              66666666666688888F66666600006666666111F66666666666666888F6666666
              000066666611111F66666666666688888F666666000066666111F61F66666666
              666888F68F66666600006661111F66611F66666668888F66688F666600006611
              11F6666611F666668888F6666688F66600006611F6666666611F666688F66666
              66688F6600006666666666666666666666666666666666660000666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000}
            NumGlyphs = 2
          end
          object copyLangButton: TBitBtn
            Left = 234
            Top = 17
            Width = 58
            Height = 22
            Hint = 'Copy Language'
            Caption = 'Copy'
            TabOrder = 2
            OnClick = copyLangButtonClick
            Glyph.Data = {
              F6000000424DF600000000000000760000002800000010000000100000000100
              04000000000080000000CE0E0000D80E00001000000000000000000000000000
              8000008000000080800080000000800080008080000080808000C0C0C0000000
              FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00888888888888
              8888888888888888888888888844444444488888884FFFFFFF488888884F0000
              0F480000004FFFFFFF480FFFFF4F00000F480F00004FFFFFFF480FFFFF4F00F4
              44480F00004FFFF4F4880FFFFF4FFFF448880F00F044444488880FFFF0F08888
              88880FFFF0088888888800000088888888888888888888888888}
          end
        end
        object highlighterPageCtrl: TPageControl
          Left = 0
          Top = 45
          Width = 372
          Height = 299
          ActivePage = stylesTabSheet
          Align = alClient
          TabOrder = 1
          object stylesTabSheet: TTabSheet
            Caption = 'Styles'
            object Label19: TLabel
              Left = 0
              Top = 112
              Width = 364
              Height = 18
              Align = alTop
              Alignment = taCenter
              AutoSize = False
              Caption = 'Style Definition'
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = [fsBold]
              ParentFont = False
              Layout = tlCenter
            end
            object topStylePanel: TPanel
              Left = 0
              Top = 0
              Width = 364
              Height = 112
              Align = alTop
              BevelOuter = bvNone
              TabOrder = 0
              object GroupBox5: TGroupBox
                Left = 4
                Top = 0
                Width = 162
                Height = 108
                Caption = 'Styles:'
                TabOrder = 0
                object StylesLB: TListBox
                  Left = 9
                  Top = 15
                  Width = 144
                  Height = 85
                  Hint = 'List of styles belonging to the selected language/lexer.'
                  BevelKind = bkSoft
                  BorderStyle = bsNone
                  Font.Charset = DEFAULT_CHARSET
                  Font.Color = clWindowText
                  Font.Height = -11
                  Font.Name = 'MS Sans Serif'
                  Font.Style = []
                  ImeName = 'The styles this language/lexer contains'
                  ItemHeight = 13
                  ParentFont = False
                  TabOrder = 0
                  OnClick = StylesLBClick
                end
              end
              object stylenoBox: TGroupBox
                Left = 171
                Top = 0
                Width = 190
                Height = 108
                Caption = 'Style'
                TabOrder = 1
                object Label4: TLabel
                  Left = 6
                  Top = 23
                  Width = 66
                  Height = 13
                  Caption = 'Style Number:'
                  Transparent = True
                end
                object Label9: TLabel
                  Left = 16
                  Top = 48
                  Width = 56
                  Height = 13
                  Caption = 'Description:'
                  Transparent = True
                end
                object StyleNumberSE: TEdit
                  Left = 73
                  Top = 20
                  Width = 47
                  Height = 21
                  Hint = 'Stylenumber for this style'
                  Font.Charset = DEFAULT_CHARSET
                  Font.Color = clWindowText
                  Font.Height = -11
                  Font.Name = 'MS Sans Serif'
                  Font.Style = []
                  ParentFont = False
                  TabOrder = 0
                  OnExit = StyleElementChanged
                  OnKeyPress = StyleNumberSEKeyPress
                end
                object DescriptionEB: TEdit
                  Left = 72
                  Top = 45
                  Width = 111
                  Height = 21
                  Hint = 'Description of this style'
                  Font.Charset = DEFAULT_CHARSET
                  Font.Color = clWindowText
                  Font.Height = -11
                  Font.Name = 'MS Sans Serif'
                  Font.Style = []
                  ParentFont = False
                  TabOrder = 1
                  OnChange = StyleElementChanged
                end
                object AddStyleB: TBitBtn
                  Left = 37
                  Top = 72
                  Width = 58
                  Height = 22
                  Hint = 'Add Style'
                  Caption = 'Add'
                  TabOrder = 2
                  OnClick = AddStyleBClick
                  Glyph.Data = {
                    DE010000424DDE01000000000000760000002800000024000000120000000100
                    0400000000006801000000000000000000001000000010000000000000000000
                    80000080000000808000800000008000800080800000C0C0C000808080000000
                    FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000666666666666666666666666666666666666000066666666FFF666666666
                    666666FFF666666600006666666844F66666666666666888F666666600006666
                    666844F66666666666666888F666666600006666666844F66666666666666888
                    F666666600006666FFF644FFFFF6666666FFF888FFFFF6660000666844444444
                    44F66666688888888888F666000066684444444444F66666688888888888F666
                    000066688888446888666666688888888888666600006666666844F666666666
                    66666888F666666600006666666844F66666666666666888F666666600006666
                    666844F66666666666666888F666666600006666666888666666666666666888
                    6666666600006666666666666666666666666666666666660000666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000}
                  NumGlyphs = 2
                end
                object DeleteStyleB: TBitBtn
                  Left = 99
                  Top = 72
                  Width = 58
                  Height = 22
                  Hint = 'Delete Style'
                  Caption = 'Rem'
                  TabOrder = 3
                  OnClick = DeleteStyleBClick
                  Glyph.Data = {
                    DE010000424DDE01000000000000760000002800000024000000120000000100
                    0400000000006801000000000000000000001000000010000000000000000000
                    80000080000000808000800000008000800080800000C0C0C000808080000000
                    FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000666666666666661F66666666666666668F66000066661F66666666666666
                    668F6666666666660000666111F6666661F666666888F6666668F66600006661
                    11F666661F6666666888F666668F666600006666111F66611F66666666888F66
                    688F6666000066666111F611F6666666666888F688F66666000066666611111F
                    66666666666688888F66666600006666666111F66666666666666888F6666666
                    000066666611111F66666666666688888F666666000066666111F61F66666666
                    666888F68F66666600006661111F66611F66666668888F66688F666600006611
                    11F6666611F666668888F6666688F66600006611F6666666611F666688F66666
                    66688F6600006666666666666666666666666666666666660000666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000}
                  NumGlyphs = 2
                end
              end
            end
            object StyleDefGB: TPanel
              Left = 0
              Top = 130
              Width = 364
              Height = 141
              Align = alClient
              BevelOuter = bvNone
              TabOrder = 1
              object Label5: TLabel
                Left = 13
                Top = 8
                Width = 24
                Height = 13
                Caption = 'Font:'
                Transparent = True
              end
              object Label6: TLabel
                Left = 13
                Top = 36
                Width = 112
                Height = 13
                Caption = 'Font Size (0 for default):'
                Transparent = True
              end
              object Label7: TLabel
                Left = 16
                Top = 115
                Width = 57
                Height = 13
                Caption = 'Foreground:'
                Transparent = True
              end
              object Label8: TLabel
                Left = 190
                Top = 115
                Width = 61
                Height = 13
                Caption = 'Background:'
                Transparent = True
              end
              object Label10: TLabel
                Left = 18
                Top = 86
                Width = 55
                Height = 13
                Caption = 'Char. Case:'
                Transparent = True
              end
              object DefaultFontCB: TCheckBox
                Left = 228
                Top = 6
                Width = 109
                Height = 17
                Hint = 
                  'If unchecked, use the fontname, else use the default (Style 32 f' +
                  'ont).'
                Caption = 'Use Default Font'
                TabOrder = 0
                OnClick = StyleElementChanged
              end
              object SizeSE: TEdit
                Left = 127
                Top = 33
                Width = 47
                Height = 21
                Hint = 'Size of the font, 0 for default size.'
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                TabOrder = 2
                OnExit = StyleElementChanged
              end
              object ForeCB: TColorBox
                Left = 77
                Top = 111
                Width = 101
                Height = 22
                Hint = 'Foreground color (text color)'
                DefaultColorColor = clDefault
                NoneColorColor = clDefault
                Selected = clDefault
                Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ItemHeight = 16
                ParentFont = False
                TabOrder = 11
                OnChange = StyleElementChanged
              end
              object BackCB: TColorBox
                Left = 254
                Top = 111
                Width = 101
                Height = 22
                Hint = 'Background color'
                DefaultColorColor = clDefault
                NoneColorColor = clDefault
                Selected = clDefault
                Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ItemHeight = 16
                ParentFont = False
                TabOrder = 12
                OnChange = StyleElementChanged
              end
              object ItalicCB: TCheckBox
                Left = 180
                Top = 34
                Width = 43
                Height = 17
                Caption = 'Italic'
                TabOrder = 3
                OnClick = StyleElementChanged
              end
              object BoldCB: TCheckBox
                Left = 228
                Top = 34
                Width = 46
                Height = 17
                Caption = 'Bold'
                TabOrder = 4
                OnClick = StyleElementChanged
              end
              object UnderlineCB: TCheckBox
                Left = 277
                Top = 34
                Width = 68
                Height = 17
                Caption = 'Underline'
                TabOrder = 5
                OnClick = StyleElementChanged
              end
              object VisibleCB: TCheckBox
                Left = 37
                Top = 61
                Width = 54
                Height = 17
                Caption = 'Visible'
                TabOrder = 6
                OnClick = StyleElementChanged
              end
              object ChangeableCB: TCheckBox
                Left = 180
                Top = 61
                Width = 84
                Height = 17
                Caption = 'Changeable'
                TabOrder = 8
                OnClick = StyleElementChanged
              end
              object EOLFilledCB: TCheckBox
                Left = 103
                Top = 61
                Width = 71
                Height = 17
                Caption = 'EOL Filled'
                TabOrder = 7
                OnClick = StyleElementChanged
              end
              object CaseCB: TComboBox
                Left = 77
                Top = 83
                Width = 101
                Height = 21
                Style = csDropDownList
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ItemHeight = 13
                ParentFont = False
                TabOrder = 10
                OnChange = StyleElementChanged
                Items.Strings = (
                  'Mixed'
                  'Upper'
                  'Lower')
              end
              object HotspotCB: TCheckBox
                Left = 277
                Top = 61
                Width = 59
                Height = 17
                Caption = 'Hotspot'
                TabOrder = 9
                OnClick = StyleElementChanged
              end
              object FontCB: TtcFontCombobox
                Left = 40
                Top = 3
                Width = 183
                Height = 24
                Hint = 'Font for the current style (only when Use Default is unchecked)'
                OnChange = StyleElementChanged
                OnClick = StyleElementChanged
                DropDownCount = 12
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -13
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ItemHeight = 18
                ParentFont = False
                TabOrder = 1
                PreviewWidth = 240
                PreviewHeight = 60
                FontTypes = [ftTrueTypeAnsi, ftTrueTypeSymbol]
                ShowPreviewInList = False
              end
            end
          end
          object keywordsTabSheet: TTabSheet
            Caption = 'Keywords'
            ImageIndex = 1
            object Label18: TLabel
              Left = 0
              Top = 112
              Width = 364
              Height = 18
              Align = alTop
              Alignment = taCenter
              AutoSize = False
              Caption = 'Keywords (separated by space)'
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = [fsBold]
              ParentFont = False
              Transparent = True
              Layout = tlCenter
            end
            object topKeywordsPanel: TPanel
              Left = 0
              Top = 0
              Width = 364
              Height = 112
              Align = alTop
              BevelOuter = bvNone
              TabOrder = 0
              object keywordlistBox: TGroupBox
                Left = 4
                Top = 0
                Width = 162
                Height = 108
                Caption = 'Keyword Lists:'
                TabOrder = 0
                object KeyListsLB: TListBox
                  Left = 9
                  Top = 15
                  Width = 144
                  Height = 85
                  Hint = 'Keywordlists for the currently selected language/lexer'
                  BevelKind = bkSoft
                  BorderStyle = bsNone
                  Font.Charset = DEFAULT_CHARSET
                  Font.Color = clWindowText
                  Font.Height = -11
                  Font.Name = 'MS Sans Serif'
                  Font.Style = []
                  ItemHeight = 13
                  ParentFont = False
                  TabOrder = 0
                  OnClick = KeyListsLBClick
                end
              end
              object KeywordListGB: TGroupBox
                Left = 171
                Top = 0
                Width = 190
                Height = 108
                Caption = 'Keyword List'
                TabOrder = 1
                object Label11: TLabel
                  Left = 13
                  Top = 23
                  Width = 59
                  Height = 13
                  Caption = 'List Number:'
                  Transparent = True
                end
                object Label12: TLabel
                  Left = 16
                  Top = 48
                  Width = 56
                  Height = 13
                  Caption = 'Description:'
                  Transparent = True
                end
                object KeyListNumberSE: TEdit
                  Left = 73
                  Top = 20
                  Width = 47
                  Height = 21
                  Hint = 'Keywordlist number for the selected list.'
                  Font.Charset = DEFAULT_CHARSET
                  Font.Color = clWindowText
                  Font.Height = -11
                  Font.Name = 'MS Sans Serif'
                  Font.Style = []
                  ParentFont = False
                  TabOrder = 0
                  OnExit = KeyListElementsChange
                  OnKeyPress = TestNumericOnly
                end
                object KeyListDescriptionEB: TEdit
                  Left = 73
                  Top = 45
                  Width = 111
                  Height = 21
                  Hint = 'Description for the selected list.'
                  Font.Charset = DEFAULT_CHARSET
                  Font.Color = clWindowText
                  Font.Height = -11
                  Font.Name = 'MS Sans Serif'
                  Font.Style = []
                  ParentFont = False
                  TabOrder = 1
                  OnChange = KeyListElementsChange
                end
                object KeyListAdd: TBitBtn
                  Left = 37
                  Top = 72
                  Width = 58
                  Height = 22
                  Hint = 'Add Keyword List'
                  Caption = 'Add'
                  TabOrder = 2
                  OnClick = KeyListAddClick
                  Glyph.Data = {
                    DE010000424DDE01000000000000760000002800000024000000120000000100
                    0400000000006801000000000000000000001000000010000000000000000000
                    80000080000000808000800000008000800080800000C0C0C000808080000000
                    FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000666666666666666666666666666666666666000066666666FFF666666666
                    666666FFF666666600006666666844F66666666666666888F666666600006666
                    666844F66666666666666888F666666600006666666844F66666666666666888
                    F666666600006666FFF644FFFFF6666666FFF888FFFFF6660000666844444444
                    44F66666688888888888F666000066684444444444F66666688888888888F666
                    000066688888446888666666688888888888666600006666666844F666666666
                    66666888F666666600006666666844F66666666666666888F666666600006666
                    666844F66666666666666888F666666600006666666888666666666666666888
                    6666666600006666666666666666666666666666666666660000666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000}
                  NumGlyphs = 2
                end
                object KeyListDelete: TBitBtn
                  Left = 99
                  Top = 72
                  Width = 58
                  Height = 22
                  Hint = 'Delete Keyword List'
                  Caption = 'Rem'
                  TabOrder = 3
                  OnClick = KeyListDeleteClick
                  Glyph.Data = {
                    DE010000424DDE01000000000000760000002800000024000000120000000100
                    0400000000006801000000000000000000001000000010000000000000000000
                    80000080000000808000800000008000800080800000C0C0C000808080000000
                    FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000666666666666661F66666666666666668F66000066661F66666666666666
                    668F6666666666660000666111F6666661F666666888F6666668F66600006661
                    11F666661F6666666888F666668F666600006666111F66611F66666666888F66
                    688F6666000066666111F611F6666666666888F688F66666000066666611111F
                    66666666666688888F66666600006666666111F66666666666666888F6666666
                    000066666611111F66666666666688888F666666000066666111F61F66666666
                    666888F68F66666600006661111F66611F66666668888F66688F666600006611
                    11F6666611F666668888F6666688F66600006611F6666666611F666688F66666
                    66688F6600006666666666666666666666666666666666660000666666666666
                    6666666666666666666666660000666666666666666666666666666666666666
                    0000}
                  NumGlyphs = 2
                end
              end
            end
            object KeywordsM: TMemo
              Left = 0
              Top = 130
              Width = 364
              Height = 141
              Hint = 'List of keywords for the selected list.'
              Align = alClient
              BevelKind = bkSoft
              BorderStyle = bsNone
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = []
              ParentFont = False
              ScrollBars = ssVertical
              TabOrder = 1
              OnChange = KeyListElementsChange
            end
          end
          object DefaultsPage: TTabSheet
            Caption = 'Defaults'
            ImageIndex = 2
            object Label35: TLabel
              Left = 152
              Top = 78
              Width = 61
              Height = 13
              Caption = 'Background:'
              Transparent = True
            end
            object Label32: TLabel
              Left = 0
              Top = 0
              Width = 364
              Height = 18
              Align = alTop
              Alignment = taCenter
              AutoSize = False
              Caption = 'Default style settings'
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = [fsBold]
              ParentFont = False
              Transparent = True
              Layout = tlCenter
            end
            object Label33: TLabel
              Left = 45
              Top = 78
              Width = 24
              Height = 13
              Caption = 'Font:'
            end
            object Label34: TLabel
              Left = 0
              Top = 18
              Width = 364
              Height = 13
              Align = alTop
              Alignment = taCenter
              Caption = 'These settings are used when you use a style'
            end
            object Label36: TLabel
              Left = 0
              Top = 31
              Width = 364
              Height = 13
              Align = alTop
              Alignment = taCenter
              Caption = 
                'which uses the clDefault color, or the '#39'Use default font'#39' is che' +
                'cked.'
            end
            object defaultBackgroundCB: TColorBox
              Left = 219
              Top = 74
              Width = 101
              Height = 22
              Hint = 'Background color'
              DefaultColorColor = clDefault
              NoneColorColor = clDefault
              Selected = clDefault
              Style = [cbStandardColors, cbExtendedColors, cbSystemColors, cbIncludeDefault, cbCustomColor, cbPrettyNames]
              Font.Charset = DEFAULT_CHARSET
              Font.Color = clWindowText
              Font.Height = -11
              Font.Name = 'MS Sans Serif'
              Font.Style = []
              ItemHeight = 16
              ParentFont = False
              TabOrder = 0
            end
            object FontButton: TBitBtn
              Left = 74
              Top = 73
              Width = 68
              Height = 25
              Hint = 'Set default font settings (STYLE_DEFAULT 32)'
              Caption = '&Font'
              TabOrder = 1
              OnClick = FontButtonClick
              Glyph.Data = {
                76010000424D7601000000000000760000002800000020000000100000000100
                04000000000000010000130B0000130B00001000000000000000000000000000
                800000800000008080008000000080008000808000007F7F7F00BFBFBF000000
                FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
                3333333333333333333333333333333333333333FFF33FFFFF33333300033000
                00333337773377777333333330333300033333337FF33777F333333330733300
                0333333377FFF777F33333333700000073333333777777773333333333033000
                3333333337FF777F333333333307300033333333377F777F3333333333703007
                33333333377F7773333333333330000333333333337777F33333333333300003
                33333333337777F3333333333337007333333333337777333333333333330033
                3333333333377333333333333333033333333333333733333333333333333333
                3333333333333333333333333333333333333333333333333333}
              NumGlyphs = 2
            end
          end
          object otherPage: TTabSheet
            Caption = 'Other Settings'
            ImageIndex = 3
            object langOperators: TGroupBox
              Left = 10
              Top = 65
              Width = 346
              Height = 53
              Caption = 'Operators'
              TabOrder = 0
              object Label37: TLabel
                Left = 14
                Top = 23
                Width = 54
                Height = 13
                Caption = 'Assignment'
              end
              object Label38: TLabel
                Left = 142
                Top = 23
                Width = 84
                Height = 13
                Caption = 'End Of Statement'
              end
              object AssignmentOperatorED: TEdit
                Left = 73
                Top = 20
                Width = 50
                Height = 21
                Hint = 'Assignment operator for this language'
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                ParentShowHint = False
                ShowHint = True
                TabOrder = 0
                OnChange = AssignmentOperatorEDChange
              end
              object EndOfStatementED: TEdit
                Left = 231
                Top = 20
                Width = 50
                Height = 21
                Hint = 'End of statement operator for this language'
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                ParentShowHint = False
                ShowHint = True
                TabOrder = 1
                OnChange = EndOfStatementEDChange
              end
            end
            object langComments: TGroupBox
              Left = 10
              Top = 124
              Width = 346
              Height = 117
              Caption = 'Commenting'
              TabOrder = 1
              object Label39: TLabel
                Left = 25
                Top = 22
                Width = 43
                Height = 13
                Caption = 'Box Start'
              end
              object Label40: TLabel
                Left = 248
                Top = 22
                Width = 40
                Height = 13
                Caption = 'Box End'
              end
              object Label41: TLabel
                Left = 133
                Top = 22
                Width = 52
                Height = 13
                Caption = 'Box Middle'
              end
              object Label42: TLabel
                Left = 46
                Top = 80
                Width = 27
                Height = 13
                Caption = 'Block'
              end
              object Label49: TLabel
                Left = 9
                Top = 51
                Width = 58
                Height = 13
                Caption = 'Stream Start'
              end
              object Label50: TLabel
                Left = 129
                Top = 51
                Width = 55
                Height = 13
                Caption = 'Stream End'
              end
              object commentBoxStart: TEdit
                Left = 73
                Top = 18
                Width = 50
                Height = 21
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                TabOrder = 0
                OnChange = commentBoxStartChange
              end
              object commentBoxEnd: TEdit
                Left = 290
                Top = 18
                Width = 50
                Height = 21
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                TabOrder = 2
                OnChange = commentBoxEndChange
              end
              object commentBoxMiddle: TEdit
                Left = 187
                Top = 18
                Width = 50
                Height = 21
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                TabOrder = 1
                OnChange = commentBoxMiddleChange
              end
              object commentBlock: TEdit
                Left = 73
                Top = 76
                Width = 50
                Height = 21
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                TabOrder = 5
                OnChange = commentBlockChange
              end
              object commentStreamStart: TEdit
                Left = 73
                Top = 47
                Width = 50
                Height = 21
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                TabOrder = 3
                OnChange = commentStreamStartChange
              end
              object commentStreamEnd: TEdit
                Left = 187
                Top = 47
                Width = 50
                Height = 21
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                TabOrder = 4
                OnChange = commentStreamEndChange
              end
            end
            object langSettingsBox: TGroupBox
              Left = 10
              Top = 5
              Width = 346
              Height = 52
              Caption = 'Language Settings'
              TabOrder = 2
              object Label53: TLabel
                Left = 26
                Top = 24
                Width = 40
                Height = 13
                Caption = 'StyleBits'
              end
              object Label54: TLabel
                Left = 136
                Top = 24
                Width = 26
                Height = 13
                Caption = 'Lexer'
              end
              object NumStyleBitsED: TEdit
                Left = 72
                Top = 21
                Width = 50
                Height = 21
                Hint = 'Number of stylebits used by this highlighter'
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ParentFont = False
                ParentShowHint = False
                ShowHint = True
                TabOrder = 0
                OnExit = NumStyleBitsEDExit
                OnKeyPress = TestNumericOnly
              end
              object lexerforlangCB: TComboBox
                Left = 170
                Top = 21
                Width = 116
                Height = 21
                Hint = 'Highlighter/lexer to use'
                Style = csDropDownList
                Font.Charset = DEFAULT_CHARSET
                Font.Color = clWindowText
                Font.Height = -11
                Font.Name = 'MS Sans Serif'
                Font.Style = []
                ItemHeight = 0
                ParentFont = False
                ParentShowHint = False
                ShowHint = True
                Sorted = True
                TabOrder = 1
                OnExit = lexerforlangCBExit
              end
            end
          end
        end
      end
    end
    object KeyCommandsPage: TTabSheet
      Caption = 'Key commands'
      ImageIndex = 3
      object keycommandsPanel: TPanel
        Left = 0
        Top = 0
        Width = 372
        Height = 344
        Align = alClient
        BevelOuter = bvNone
        TabOrder = 0
        object KeyCmdList: TListView
          Left = 0
          Top = 0
          Width = 372
          Height = 308
          Align = alClient
          Columns = <
            item
              Caption = 'Command'
              Width = 160
            end
            item
              Caption = 'Keystroke'
              Width = 110
            end>
          ColumnClick = False
          Font.Charset = DEFAULT_CHARSET
          Font.Color = clWindowText
          Font.Height = -11
          Font.Name = 'MS Sans Serif'
          Font.Style = []
          HideSelection = False
          HotTrack = True
          HotTrackStyles = [htUnderlineCold]
          ParentFont = False
          PopupMenu = KeyMenu
          SortType = stText
          TabOrder = 0
          ViewStyle = vsReport
          OnCompare = KeyCmdListCompare
          OnDblClick = btnEditClick
        end
        object keybuttonsPanel: TPanel
          Left = 0
          Top = 308
          Width = 372
          Height = 36
          Align = alBottom
          BevelOuter = bvNone
          PopupMenu = KeyMenu
          TabOrder = 1
          DesignSize = (
            372
            36)
          object btnAdd: TBitBtn
            Left = 127
            Top = 6
            Width = 66
            Height = 25
            Hint = 'Add a new keyboard command'
            Anchors = [akTop, akRight]
            Caption = '&Add'
            TabOrder = 0
            OnClick = btnAddClick
            Glyph.Data = {
              DE010000424DDE01000000000000760000002800000024000000120000000100
              0400000000006801000000000000000000001000000010000000000000000000
              80000080000000808000800000008000800080800000C0C0C000808080000000
              FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000666666666666666666666666666666666666000066666666FFF666666666
              666666FFF666666600006666666844F66666666666666888F666666600006666
              666844F66666666666666888F666666600006666666844F66666666666666888
              F666666600006666FFF644FFFFF6666666FFF888FFFFF6660000666844444444
              44F66666688888888888F666000066684444444444F66666688888888888F666
              000066688888446888666666688888888888666600006666666844F666666666
              66666888F666666600006666666844F66666666666666888F666666600006666
              666844F66666666666666888F666666600006666666888666666666666666888
              6666666600006666666666666666666666666666666666660000666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000}
            NumGlyphs = 2
          end
          object btnEdit: TBitBtn
            Left = 199
            Top = 6
            Width = 66
            Height = 25
            Hint = 'Edit the selected keyboard command'
            Anchors = [akTop, akRight]
            Caption = '&Edit'
            TabOrder = 1
            OnClick = btnEditClick
            Glyph.Data = {
              36040000424D3604000000000000360000002800000010000000100000000100
              2000000000000004000000000000000000000000000000000000008080000080
              8000008080000080800000808000008080000000000000000000000000000000
              0000000000000000000000000000000000000000000000000000008080000080
              800000808000008080000080800000808000000000FFFFFFFF00FFFFFFFFFFFF
              FF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFF0000000000000000000000
              0000008080000000000000000000000000000000000000000000FFFFFFFFFFFF
              FF00000000FFFFFFFF000000000000000000FFFFFF0000000000FFFF00000000
              00000000000000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00000000FFFFFF
              FF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFF0000000000FFFF00000000
              000000FFFFFFFFFFFF0000FFFFFFFFFFFF000000000000000000000000FFFFFF
              FF00FFFFFFFFFFFFFF00FFFFFF0000000000FFFFFF0000000000FFFF00000000
              0000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF000000
              0000FFFFFF0000000000000000FFFFFFFF00FFFFFF0000000000FFFF00000000
              000000FFFFFFFFFFFF0000FFFFFFFFFFFF000000000000000000000000000000
              00000000000000FFFF00000000FFFFFFFF00FFFFFF0000000000FFFF00000000
              0000FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FFFF00FFFFFF0000FF
              FF00FFFFFF0000000000FFFFFFFFFFFFFF00FFFFFF0000000000FFFF00000000
              000000FFFFFFFFFFFF0000000000000000000000000000000000000000000000
              0000000000FFFFFFFF00FFFFFFFFFFFFFF00FFFFFF0000000000000000000000
              00000000000000FFFF00FFFFFF0000FFFF00000000000000000000FFFF000000
              0000FFFFFFFFFFFFFF000000000000000000FFFFFF0000000000008080000080
              8000008080000000000000000000000000000000000000FFFF00000000FFFFFF
              FF00FFFFFFFFFFFFFF00FFFFFFFFFFFFFF00FFFFFF0000000000008080000080
              80000080800000808000008080000000000000FFFF0000000000FFFFFFFFFFFF
              FF00FFFFFFFFFFFFFF0000000000000000000000000000000000008080000080
              800000808000008080000000000000FFFF00000000FFFFFFFF00FFFFFF000000
              0000000000FFFFFFFF00000000FFFFFFFF00FFFFFF0000000000008080000080
              8000008080000000000000FFFF0000000000000000FFFFFFFF00FFFFFFFFFFFF
              FF00FFFFFFFFFFFFFF00000000FFFFFFFF000000000000808000008080000080
              8000000000000000FF000000000000808000000000FFFFFFFF00FFFFFFFFFFFF
              FF00FFFFFFFFFFFFFF0000000000000000000080800000808000008080000080
              8000008080000000000000808000008080000000000000000000000000000000
              0000000000000000000000000000008080000080800000808000}
          end
          object btnDelete: TBitBtn
            Left = 272
            Top = 6
            Width = 66
            Height = 25
            Hint = 'Delete the selected keyboard command'
            Anchors = [akTop, akRight]
            Caption = '&Delete'
            TabOrder = 2
            OnClick = btnDeleteClick
            Glyph.Data = {
              DE010000424DDE01000000000000760000002800000024000000120000000100
              0400000000006801000000000000000000001000000010000000000000000000
              80000080000000808000800000008000800080800000C0C0C000808080000000
              FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000666666666666661F66666666666666668F66000066661F66666666666666
              668F6666666666660000666111F6666661F666666888F6666668F66600006661
              11F666661F6666666888F666668F666600006666111F66611F66666666888F66
              688F6666000066666111F611F6666666666888F688F66666000066666611111F
              66666666666688888F66666600006666666111F66666666666666888F6666666
              000066666611111F66666666666688888F666666000066666111F61F66666666
              666888F68F66666600006661111F66611F66666668888F66688F666600006611
              11F6666611F666668888F6666688F66600006611F6666666611F666688F66666
              66688F6600006666666666666666666666666666666666660000666666666666
              6666666666666666666666660000666666666666666666666666666666666666
              0000}
            NumGlyphs = 2
          end
          object btnReset: TBitBtn
            Left = 35
            Top = 6
            Width = 66
            Height = 25
            Hint = 'Reset the command list to default'
            Anchors = [akTop, akRight]
            Caption = '&Reset'
            TabOrder = 3
            OnClick = btnResetClick
            Glyph.Data = {
              F6000000424DF600000000000000760000002800000010000000100000000100
              04000000000080000000CE0E0000D80E00001000000000000000000000000000
              80000080000000808000800000008000800080800000C0C0C000808080000000
              FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
              7777777777777777777777777777777777777777777777777777777777777777
              7777777777777778477777444447777748777744447777777477774447777777
              7477774474777777747777477748777748777777777844448777777777777777
              7777777777777777777777777777777777777777777777777777}
          end
        end
      end
    end
  end
  object buttonPanel: TPanel
    Left = 0
    Top = 369
    Width = 380
    Height = 41
    Align = alBottom
    BevelInner = bvRaised
    BevelOuter = bvLowered
    TabOrder = 1
    object CancelBtn: TBitBtn
      Left = 290
      Top = 8
      Width = 75
      Height = 25
      Hint = 'Cancel, and revert to previous settings'
      TabOrder = 0
      OnClick = CancelBtnClick
      Kind = bkCancel
    end
    object ApplyBtn: TBitBtn
      Left = 154
      Top = 8
      Width = 75
      Height = 25
      Hint = 'Apply the settings'
      Caption = 'Apply'
      TabOrder = 1
      OnClick = ApplyBtnClick
      Glyph.Data = {
        DE010000424DDE01000000000000760000002800000024000000120000000100
        0400000000006801000000000000000000001000000000000000000000000000
        80000080000000808000800000008000800080800000C0C0C000808080000000
        FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00666666666666
        6666666666666F6666666666000066666636666666666666666686F666666666
        0000666666306666666666666666886F66666666000066666663066666666666
        66666886F6666666000066666663B066666666666666F8F86F66666600006666
        63000F06666666666668888686F666660000666663FBFBF06666666666686F66
        686F666600006666663FB0333666666666668F688886666600006666663BFB06
        6666666666FF8FF686F66666000066630000BFB06666666668888866686F6666
        00006663FBFBFBFB06666666686F6666668F6666000066663FBFB03336666666
        668F666888866666000066663BFBFB06666666666686F66686F6666600006666
        63BFBFB0666666666668F666686F66660000666663FBFBFB0666666666686F66
        6686F66600006666663FBFBFB066666666668FFFFFF8FF660000666666333333
        3336666666668888888886660000666666666666666666666666666666666666
        0000}
      NumGlyphs = 2
    end
    object OKBtn: TBitBtn
      Left = 18
      Top = 8
      Width = 75
      Height = 25
      Hint = 'Apply the settings and close dialog'
      TabOrder = 2
      OnClick = OKBtnClick
      Kind = bkOK
    end
  end
  object FontDialog: TFontDialog
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    Left = 292
  end
  object KeyMenu: TPopupMenu
    Left = 101
    Top = 112
    object LoadKeyCommands1: TMenuItem
      Caption = 'Load Keycommands..'
      OnClick = LoadKeyCommands1Click
    end
    object SaveKeycommands1: TMenuItem
      Caption = '&Save Keycommands..'
      OnClick = SaveKeycommands1Click
    end
  end
  object odia: TOpenDialog
    Filter = 'Keycommands (*.key)|*.key|All Files (*.*)|*.*'
    Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing]
    Title = 'Load keycommands from..'
    Left = 201
    Top = 120
  end
  object sdia: TSaveDialog
    Filter = 'Keycommands (*.key)|*.key|All Files (*.*)|*.*'
    Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing]
    Title = 'Save Keycommands to..'
    Left = 229
    Top = 121
  end
end
Added src/delphisci/EdOptionsWin.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
{$Include SciCommonDef.Inc}
unit EdOptionsWin;
{
Unit    : EdOptionsWin
Purpose : Options Dialog for Scintilla editors
Created : 20/03/2003
     $Id: EdOptionsWin.pas,v 1.7 2004/12/03 17:18:58 hdalis Exp $
Original Author: Kiriakos Vlahos (kvlahos@london.edu)
Current Author : hdalis
History 29/09/2004 Initial Release with Delphi Scintilla Interface Components
                   Extended and customized the optionsbox
                   No longer accepts enums, now it accepts strings.
                   Color,Caret,Hotspot etc properties added.
                   (hdalis@users.sourceforge.net)
        13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                   generate the help.
                   Renamed the Scintilla property to Editor
                   (hdalis@users.sourceforge.net)
        25/10/2004 Redesigned the whole form. Added add,copy,remove languages buttons.
                   Added Active Hotspot options.
                   The Keywords page doesn't exist anymore, it is now a part of the
                   Highlighter page.
                   (hdalis@users.sourceforge.net)
        02/11/2004 No longer displays a list of all lexers, now only defined languages
                   are displayed, i.e those defined in the Highlighter.LanguageList.
                   If you want to add a language, click Add and set the languagename and
                   the lexer to use for it. You can have as many languages defined as you wish.
        09/11/2004 Added EdgeColumn,EdgeType,EdgeColor
                   Some redesign of the Options page to
                   make it fit.. To be adjusted later.
        18/11/2004 Changed the TSciSynLexer to TSciLanguageManager, and changed all properties etc to reflect that.
        26/11/2004 Renamed the SetScintilla function to SetEditor to conform with the rest of them..
BUGFIXES:
        04/11/2004 When a new keylist was added, and you typed a description then the text
                   in the listbox wasn't updated. Fixed.
        15/01/2005 Added Comment* and AssignmentOperator,EndOfStatementOperator to the dialog.
                   Changed the Update* procs to take a TSciLangItem, and use that instead of
                   looking up the language all the time.. Improves performance of the dialog somewhat,
                   microscopic but..
        27/05/2005 Swapped the columns in the KeyBindings listview. Added sort.
                   Fixed a couple of memoryleaks. Now it's sorted by Command.

}
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons,SciLexer,SciLexerMod,SciLexerMemo,SciKeyBindings,
  ComCtrls, ScintillaLanguageManager, tcFontCombobox, Menus;

type
  TEditorOptions = class(TPersistent)
  private
    FReadOnly : boolean;
    FBraceHilite : boolean;
    FGutter: boolean;
    FWordWrap: TWordWrapType;
    FLineNumbers: boolean;
    FIndentation : TIndentationOptions;
    FCodeFolding: sciCodeFoldingFlags;
    FCaretFore : TColor;
    FIndentWidth: Integer;
    FTabWidth: Integer;
    FEOLStyle: TEOLStyle;
    FCaretLineVisible : Boolean;
    FCaretBack : TColor;
    FSaveClearsUndo : Boolean;
    FFont: TFont;
    FLanguageManager: TSciLanguageManager;
    fKeyCommands : TSciKeyCommandCollection;
    FCaretWidth: Integer;
    FSelFore : TColor;
    FSelBack : TColor;
    FFoldLo : TColor;
    FFoldHi : TColor;
    FMarkerFore : TColor;
    FMarkerBack : TColor;
    FBMarkFore : TColor;
    FBMarkBack : TColor;
    FHotActiveFore : TColor;
    FHotActiveBack : TColor;
    FHotActiveUnderline : Boolean;
    FHotActiveSingleLine : Boolean;
    FEdgeColor : TColor;
    FEdgeColumn : TColor;
    FEdgeType : sciEdgeType;
    FColor : TColor;
    FMarkerType : sciMarkerType;
    FCodePage : CodePageType;
    procedure SetFont(const Value: TFont);
    procedure SetLanguageManager(const Value: TSciLanguageManager);
    procedure SetKeyCommands(const Value: TSciKeyCommandCollection);
  public
    constructor Create;
    destructor Destroy; override;
    procedure Assign(Source: TPersistent);override;
    procedure GetOptions(Scintilla : TScintilla);
    procedure SetOptions(Scintilla : TScintilla);
  published
    property LanguageManager : TSciLanguageManager read FLanguageManager write SetLanguageManager;
    property ReadOnly : boolean read fReadOnly write fReadOnly default False;
    property BraceHilite : boolean read FBraceHilite write FBraceHilite default True;
    property Gutter : boolean read FGutter write FGutter default True;
    property Indentation : TIndentationOptions read FIndentation write fIndentation;
    property LineNumbers : boolean read FLineNumbers write FLineNumbers default False;
    property WordWrap : TWordWrapType read FWordWrap write FWordWrap default sciNoWrap;
    property CodeFolding : sciCodeFoldingFlags read FCodeFolding write FCodeFolding default [foldFold,foldCompact,foldComment,foldPreprocessor,foldAtElse,foldHTML,foldHTMLPreProcessor];
    property EOLStyle : TEOLStyle read FEOLStyle write FEOLStyle default eolCRLF;
    property TabWidth : Integer read FTabWidth write FTabWidth  default 8;
    property IndentWidth : Integer read FIndentWidth write FIndentWidth default 0;
    property KeyCommands : TSciKeyCommandCollection read FKeyCommands write SetKeyCommands;
    property CaretFore : TColor read FCaretFore Write FCaretFore;
    property CaretBack : TColor read FCaretBack Write FCaretBack;
    property Font : TFont read FFont write SetFont;
    property CaretWidth : Integer read FCaretWidth write FCaretWidth;
    property CaretLineVisible : Boolean read FCaretLineVisible write FCaretLineVisible;
    property SelFore : TColor read FSelFore write FSelFore default clDefault;
    property SelBack : TColor read FSelBack write FSelBack default clDefault;
    property FoldLo : TColor read FFoldLo write FFoldLo default clDefault;
    property FoldHi : TColor read FFoldHi write FFoldHi default clDefault;
    property MarkerFore : TColor read FMarkerFore write FMarkerFore default clDefault;
    property MarkerBack : TColor read FMarkerBack write FMarkerBack default clDefault;
    property BMarkFore : TColor read FBMarkFore write FBMarkFore default clDefault;
    property BMarkBack : TColor read FBMarkBack write FBMarkBack default clDefault;
    property XSaveClearsUndo : Boolean read FSaveClearsUndo write FSaveClearsUndo default false;
    property HotActiveFore : TColor read FHotActiveFore write FHotActiveFore default clDefault;
    property HotActiveBack : TColor read FHotActiveBack write FHotActiveBack default clDefault;
    property HotActiveUnderline : Boolean read FHotActiveUnderline write FHotActiveUnderline;
    property HotActiveSingleLine : Boolean read FHotActiveSingleLine write FHotActiveSingleLine;
    property EdgeColor : TColor read FEdgeColor write FEdgeColor;
    property EdgeColumn : TColor read FEdgeColumn write FEdgeColumn;
    property EdgeType : sciEdgeType read FEdgeType write FEdgeType;
    property MarkerType : sciMarkerType read FMarkerType write FMarkerType;
    property Color : TColor read FColor write FColor;
    property CodePage : CodePageType read FCodePage write FCodePage;
  end;


  TEdOptionsWindow = class(TForm)
    OptionPages: TPageControl;
    OptionsPage: TTabSheet;
    ColorsPage: TTabSheet;
    colorsPanel: TPanel;
    optionsPanel: TPanel;
    viewOptionsBox: TGroupBox;
    CodeFoldingCB: TCheckBox;
    GutterCB: TCheckBox;
    LineNumbersCB: TCheckBox;
    IndentationGuidesCB: TCheckBox;
    indentationBox: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    KeepIndentCB: TCheckBox;
    TabIndentsCB: TCheckBox;
    BackSpaceUnIndentsCB: TCheckBox;
    buttonPanel: TPanel;
    CancelBtn: TBitBtn;
    ApplyBtn: TBitBtn;
    OKBtn: TBitBtn;
    HighlighterPage: TTabSheet;
    highlighterPanel: TPanel;
    FontDialog: TFontDialog;
    languageCBBox: TGroupBox;
    LanguageCB: TComboBox;
    Label13: TLabel;
    CaretCB: TColorBox;
    Label14: TLabel;
    CaretWidthSE: TEdit;
    KeyCommandsPage: TTabSheet;
    keycommandsPanel: TPanel;
    KeyCmdList: TListView;
    TabWidthSE: TEdit;
    IndentWidthSE: TEdit;
    CaretLineVisCB : TCheckBox;
    CaretBackCB : TColorBox;
    Label15: TLabel;
    Label16: TLabel;
    Label17: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    SelForeCB: TColorBox;
    SelBackCB: TColorBox;
    MarkerForeCB: TColorBox;
    MarkerBackCB: TColorBox;
    BMarkForeCB  : TColorBox;
    BMarkBackCB  : TColorBox;
    Label22 : TLabel;
    Label23 : TLabel;
    addLangButton: TBitBtn;
    remLangButton: TBitBtn;
    copyLangButton: TBitBtn;
    keybuttonsPanel: TPanel;
    btnAdd: TBitBtn;
    btnEdit: TBitBtn;
    btnDelete: TBitBtn;
    btnReset: TBitBtn;
    HotspotGB: TGroupBox;
    Label24: TLabel;
    Label25: TLabel;
    HotActiveForeCB: TColorBox;
    HotActiveBackCB: TColorBox;
    HotActiveUnderlineCB: TCheckBox;
    HotActiveSingleLineCB: TCheckBox;
    FoldingGB: TGroupBox;
    Label26: TLabel;
    Label27: TLabel;
    FoldLoCB: TColorBox;
    FoldHiCB: TColorBox;
    MarkersGB: TGroupBox;
    highlighterPageCtrl: TPageControl;
    stylesTabSheet: TTabSheet;
    keywordsTabSheet: TTabSheet;
    topStylePanel: TPanel;
    GroupBox5: TGroupBox;
    StylesLB: TListBox;
    stylenoBox: TGroupBox;
    Label4: TLabel;
    Label9: TLabel;
    StyleNumberSE: TEdit;
    DescriptionEB: TEdit;
    AddStyleB: TBitBtn;
    DeleteStyleB: TBitBtn;
    topKeywordsPanel: TPanel;
    keywordlistBox: TGroupBox;
    KeyListsLB: TListBox;
    KeywordListGB: TGroupBox;
    Label11: TLabel;
    Label12: TLabel;
    KeyListNumberSE: TEdit;
    KeyListDescriptionEB: TEdit;
    KeyListAdd: TBitBtn;
    KeyListDelete: TBitBtn;
    KeywordsM: TMemo;
    Label18: TLabel;
    Label19: TLabel;
    StyleDefGB: TPanel;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label10: TLabel;
    DefaultFontCB: TCheckBox;
    SizeSE: TEdit;
    ForeCB: TColorBox;
    BackCB: TColorBox;
    ItalicCB: TCheckBox;
    BoldCB: TCheckBox;
    UnderlineCB: TCheckBox;
    VisibleCB: TCheckBox;
    ChangeableCB: TCheckBox;
    EOLFilledCB: TCheckBox;
    CaseCB: TComboBox;
    HotspotCB: TCheckBox;
    FontCB: TtcFontCombobox;
    gbRightEdge: TGroupBox;
    Label28: TLabel;
    Label29: TLabel;
    EdgeColumnSE: TEdit;
    EdgeColorCB: TColorBox;
    BraceHiliteCB: TCheckBox;
    Label30: TLabel;
    EdgeTypeCB: TComboBox;
    markerTypeCB: TComboBox;
    Label31: TLabel;
    OtherGB: TGroupBox;
    SaveClearsUndoCB: TCheckBox;
    ReadOnlyCB: TCheckBox;
    Label3: TLabel;
    EOLStyleCB: TComboBox;
    DefaultsPage: TTabSheet;
    Label35: TLabel;
    defaultBackgroundCB: TColorBox;
    FontButton: TBitBtn;
    Label32: TLabel;
    Label33: TLabel;
    Label34: TLabel;
    Label36: TLabel;
    otherPage: TTabSheet;
    langOperators: TGroupBox;
    Label37: TLabel;
    Label38: TLabel;
    AssignmentOperatorED: TEdit;
    EndOfStatementED: TEdit;
    langComments: TGroupBox;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Label49: TLabel;
    Label50: TLabel;
    commentBoxStart: TEdit;
    commentBoxEnd: TEdit;
    commentBoxMiddle: TEdit;
    commentBlock: TEdit;
    commentStreamStart: TEdit;
    commentStreamEnd: TEdit;
    langSettingsBox: TGroupBox;
    Label53: TLabel;
    Label54: TLabel;
    NumStyleBitsED: TEdit;
    lexerforlangCB: TComboBox;
    WordWrapCB: TComboBox;
    KeyMenu: TPopupMenu;
    LoadKeyCommands1: TMenuItem;
    SaveKeycommands1: TMenuItem;
    odia: TOpenDialog;
    sdia: TSaveDialog;
    Label43: TLabel;
    CodePageCB: TComboBox;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ApplyBtnClick(Sender: TObject);
    procedure FontButtonClick(Sender: TObject);
    procedure OKBtnClick(Sender: TObject);
    procedure CancelBtnClick(Sender: TObject);
    procedure StylesLBClick(Sender: TObject);
    procedure LanguageCBChange(Sender: TObject);
    procedure StyleElementChanged(Sender: TObject);
    procedure DeleteStyleBClick(Sender: TObject);
    procedure AddStyleBClick(Sender: TObject);
    procedure KeyListsLBClick(Sender: TObject);
    procedure KeyListElementsChange(Sender: TObject);
    procedure KeyListDeleteClick(Sender: TObject);
    procedure KeyListAddClick(Sender: TObject);
    procedure btnDeleteClick(Sender: TObject);
    procedure btnResetClick(Sender: TObject);
    procedure btnEditClick(Sender: TObject);
    procedure btnAddClick(Sender: TObject);
    procedure StyleNumberSEKeyPress(Sender : TObject;var ch : Char);
    procedure TestNumericOnly(Sender: TObject; var Key: Char);
    procedure addLangButtonClick(Sender: TObject);
    procedure remLangButtonClick(Sender: TObject);
    procedure copyLangButtonClick(Sender: TObject);
    procedure OptionPagesChange(Sender: TObject);
    procedure KeyCmdListCompare(Sender: TObject; Item1, Item2: TListItem;
      Data: Integer; var Compare: Integer);
    procedure AssignmentOperatorEDChange(Sender: TObject);
    procedure EndOfStatementEDChange(Sender: TObject);
    procedure commentBoxStartChange(Sender: TObject);
    procedure commentBoxMiddleChange(Sender: TObject);
    procedure commentBoxEndChange(Sender: TObject);
    procedure commentBlockChange(Sender: TObject);
    procedure commentStreamStartChange(Sender: TObject);
    procedure commentStreamEndChange(Sender: TObject);
    procedure lexerforlangCBExit(Sender: TObject);
    procedure NumStyleBitsEDExit(Sender: TObject);
    procedure LoadKeyCommands1Click(Sender: TObject);
    procedure SaveKeycommands1Click(Sender: TObject);
  private
    { Private declarations }
    FEditor : TScintilla;
    fEditorOptions : TEditorOptions;
    fOldEditorOptions : TEditorOptions;
    UpdatingStyle : Boolean;
    UpdatingKeyList : Boolean;
    procedure SetEditor(const Value: TScintilla);
    procedure UpdateStyles(curlng : TSciLangItem=nil);
    procedure UpdateKeywords(curlng : TSciLangItem=nil);
    procedure UpdateKeyCommands;
    procedure UpdateOther(curlng : TSciLangItem=nil);
    function  CurrentLang : TSciLangItem;    
  public
    { Public declarations }
    property Editor : TScintilla read FEditor write SetEditor;
    procedure   RescanLanguageList;

  end;

var
  EdOptionsWindow: TEdOptionsWindow;

implementation

{$R *.dfm}

Uses
  SciSupport,SciKeyEditForm,SciAddLanguageFormUnit,SciResLang,sciUtils;

{ TEditorOptions }
constructor TEditorOptions.Create;
begin
  inherited;
  FFont := TFont.Create;
  FLanguageManager := TSciLanguageManager.Create(nil);
  fKeyCommands := TSciKeyCommandCollection.Create(nil);
end;

destructor TEditorOptions.Destroy;
begin
  if assigned(FFont) then FreeAndNil(FFont);
  if assigned (FLanguageManager) then FreeAndNil(FLanguageManager);
  if assigned (fKeyCommands) then FreeAndNil(fKeyCommands); //added to avoid a memoryleak after a tip by mak
  inherited;
end;

procedure TEditorOptions.Assign(Source: TPersistent);
begin
  if Source is TEditorOptions then
    with TEditorOptions(Source) do
    begin
      Self.FReadOnly := ReadOnly;
      Self.FBraceHilite := BraceHilite;
      Self.FGutter := Gutter;
      Self.FWordWrap := WordWrap;
      Self.FLineNumbers := LineNumbers;
      Self.FIndentation := Indentation;
      Self.FCodeFolding := CodeFolding;
      Self.FTabWidth := TabWidth ;
      Self.FIndentWidth := IndentWidth;
      Self.FEOLStyle := EOLStyle;
      Self.SetFont(Font);
      Self.FLanguageManager.Assign(LanguageManager);
      Self.KeyCommands.Assign(KeyCommands);
      Self.FCaretBack :=CaretBack;
      Self.FCaretFore :=CaretFore;
      Self.FSelFore := SelFore;
      Self.FFoldLo :=FoldLo;
      Self.FFoldHi :=FoldHi;
      Self.FMarkerFore :=MarkerFore;
      Self.FMarkerBack :=MarkerBack;
      Self.FBMarkFore :=BMarkFore;
      Self.FBMarkBack :=BMarkBack;
      Self.FSelBack := SelBack;
      Self.FCaretWidth :=CaretWidth;
      Self.FCaretLineVisible :=CaretLineVisible;
      Self.FSaveClearsUndo :=XSaveClearsUndo;
      Self.FHotActiveFore:=HotActiveFore;
      Self.FHotActiveBack:=HotActiveBack;
      Self.FHotActiveUnderline:=HotActiveUnderline;
      Self.FHotActiveSingleLine:=HotActiveSingleLine;
      Self.FEdgeColor:=EdgeColor;
      Self.FEdgeColumn:=EdgeColumn;
      Self.FEdgeType:=EdgeType;
      Self.FMarkerType:=MarkerType;
      Self.FColor:=Color;
      Self.FCodePage:=CodePage;
    end
  else if Source is TScintilla then
  begin
    GetOptions(Source as TScintilla);
  end else
    inherited;
end;

procedure TEditorOptions.GetOptions(Scintilla: TScintilla);
begin
  with Scintilla do
  begin
      FReadOnly := ReadOnly;
      FBraceHilite := BraceHilite;
      FGutter := Gutter1.Width <> 0;
      FWordWrap := WordWrap;
      FLineNumbers := Gutter0.Width <> 0;
      FIndentation := Indentation;
      FCodeFolding := Folding;
      FTabWidth := TabWidth ;
      FIndentWidth := IndentWidth;
      FEOLStyle := EOLStyle;
      Self.SetFont(Font);
      FLanguageManager.Assign(LanguageManager);
      fKeyCommands.Assign(Scintilla.KeyCommands);
      FSelFore:=Colors.SelFore;
      FSelBack:=Colors.SelBack;
      FFoldLo :=Colors.FoldLo;
      FFoldHi :=Colors.FoldHi;
      FMarkerFore :=Colors.MarkerFore;
      FMarkerBack :=Colors.MarkerBack;
      FBMarkFore :=Bookmark.ForeColor;
      FBMarkBack :=Bookmark.BackColor;
      FHotActiveFore:=ActiveHotSpot.ForeColor;
      FHotActiveBack:=ActiveHotSpot.BackColor;
      Self.FHotActiveUnderline:=ActiveHotSpot.Underlined;
      Self.FHotActiveSingleLine:=ActiveHotSpot.SingleLine;
      Self.FEdgeColor:=EdgeColor;
      Self.FCodePage:=CodePage;
      Self.FEdgeColumn:=EdgeColumn;
      Self.FEdgeType:=EdgeMode;
      Self.FMarkerType:=FoldMarkers.MarkerType;
      Self.FColor:=Color;
      FSaveClearsUndo :=ClearUndoAfterSave;
      FCaretFore :=Caret.ForeColor;
      FCaretBack :=Caret.LineBackColor;
      FCaretWidth :=Caret.Width;
      FCaretLineVisible :=Caret.LineVisible;
  end;
end;

procedure TEditorOptions.SetFont(const Value: TFont);
begin
  FFont.Assign(Value);
end;

procedure TEditorOptions.SetKeyCommands(const Value: TSciKeyCommandCollection);
begin
  FKeyCommands.Assign(Value);
end;

procedure TEditorOptions.SetOptions(Scintilla: TScintilla);
begin
  with Scintilla do
  begin
    try
      LanguageManager.BeginUpdate;
      Color:=FColor;
      Caret.ForeColor:=CaretFore;
      //ColorToRGB(CaretFore);
      Caret.Width:=FCaretWidth;
      Caret.LineVisible :=FCaretLineVisible;
      Caret.LineBackColor :=FCaretBack;
      Colors.SelFore :=SelFore;
      Colors.SelBack :=SelBack;
      Colors.FoldLo :=FFoldLo;
      Colors.FoldHi :=FFoldHi;
      Colors.MarkerFore :=FMarkerFore;
      Colors.MarkerBack :=FMarkerBack;
      Bookmark.BackColor :=FBMarkBack;
      Bookmark.ForeColor :=FBMarkFore;
      ActiveHotSpot.ForeColor:=FHotActiveFore;
      ActiveHotSpot.BackColor:=FHotActiveBack;
      ActiveHotSpot.Underlined :=Self.FHotActiveUnderline;
      ActiveHotSpot.SingleLine :=Self.FHotActiveSingleLine;
      ClearUndoAfterSave :=FSaveClearsUndo;
      EdgeColor:=FEdgeColor;
      EdgeColumn:=FEdgeColumn;
      EdgeMode:=FEdgeType;
      CodePage:=FCodePage;
      Scintilla.FoldMarkers.MarkerType:=FMarkerType;
      if ReadOnly <> FReadOnly then ReadOnly := FReadOnly;
      BraceHilite := FBraceHilite;
      if FGutter <> (Gutter1.Width <> 0) then
      begin
        if FGutter then  Gutter1.Width := 16
          else
            Gutter1.Width := 0;
      end;
      if WordWrap <> FWordWrap then WordWrap := FWordWrap;
      if FLineNumbers <> (Gutter0.Width <> 0) then
      begin
        if FLineNumbers then
        begin
          Gutter0.Width := 32;
          Gutter0.MarginType := gutLineNumber;
        end else
          Gutter0.Width := 0;
      end;
      if Indentation <> FIndentation then
        Indentation := FIndentation;
      if CodeFolding<>Folding then
      begin
        Folding:=CodeFolding;
      end;
      if IndentWidth <> FIndentWidth then
        IndentWidth := FIndentWidth;
      if TabWidth <> FTabWidth then
        TabWidth := FTabWidth;
      if EOLStyle <> FEOLStyle then
        EOLStyle := FEOLStyle;
      if (Font.Name <> FFont.Name) or (Font.Size <> FFont.Size) or (Font.Charset <> FFont.Charset) or (Font.Style <> FFont.Style) or (Font.Color<>FFont.Color) then
        Font := FFont;
      LanguageManager.Assign(Self.FLanguageManager);
    finally
      LanguageManager.EndUpdate;
    end;
    //LanguageManager.Update;
    KeyCommands.Assign(FKeyCommands);
  end;
end;

procedure TEditorOptions.SetLanguageManager(const Value: TSciLanguageManager);
begin
  FLanguageManager.Assign(Value);
end;

{ TEdOptionsWindow }

function TEdOptionsWindow.CurrentLang : TSciLangItem;
begin
  Result:=FEditorOptions.LanguageManager.LanguageList.GetStyleList(LanguageCB.Items[LanguageCB.ItemIndex]);
end;

procedure TEdOptionsWindow.SetEditor(const Value: TScintilla);
var
xitm : TSciLangItem;
i : Integer;
cp : String;
begin
  FEditor := Value;
  RescanLanguageList;
  fEditorOptions.GetOptions(Editor);
  with fEditorOptions do
  begin
    ReadOnlyCB.Checked := ReadOnly;
    BraceHiliteCB.Checked := BraceHilite;
    GutterCB.Checked := Gutter;
    WordWrapCB.ItemIndex:= LongInt(WordWrap);
    LineNumbersCB.Checked := LineNumbers;
    KeepIndentCB.Checked := SciLexerMemo.KeepIndent in Indentation;
    TabIndentsCB.Checked := SciLexerMemo.TabIndents in Indentation;
    BackSpaceUnindentsCB.Checked := SciLexerMemo.BackSpaceUnindents in Indentation;
    IndentationGuidesCB.Checked := SciLexerMemo.IndentationGuides in Indentation;
    CodeFoldingCB.Checked := (foldFold in CodeFolding);
    TabWidthSE.Text := IntToStr(TabWidth);
    IndentWidthSE.Text := IntToStr(IndentWidth);
    EOLStyleCB.ItemIndex := Integer(EOLStyle);
    CaretCB.Selected:=CaretFore;
    SelForeCB.Selected:=SelFore;
    SelBackCB.Selected:=SelBack;
    CaretWidthSE.Text:=IntToStr(CaretWidth);
    CaretLineVisCB.Checked :=CaretLineVisible;
    CaretBackCB.Selected :=CaretBack;
    FoldLoCB.Selected :=FoldLo;
    FoldHiCB.Selected :=FoldHi;
    MarkerForeCB.Selected :=MarkerFore;
    MarkerBackCB.Selected :=MarkerBack;
    BMarkForeCB.Selected :=BMarkFore;
    BMarkBackCB.Selected :=BMarkBack;
    HotActiveForeCB.Selected:=HotActiveFore;
    HotActiveBackCB.Selected:=HotActiveBack;
    HotActiveUnderlineCB.Checked:=HotActiveUnderline;
    HotActiveSingleLineCB.Checked:=HotActiveSingleLine;
    SaveClearsUndoCB.Checked :=XSaveClearsUndo;
    EdgeColorCB.Selected:=EdgeColor;
    EdgeColumnSE.Text:=IntToStr(EdgeColumn);
    EdgeTypeCB.ItemIndex:=LongInt(EdgeType);
    markerTypeCB.ItemIndex:=LongInt(MarkerType);
    defaultBackgroundCB.Selected:=Color;
    //  Syntax Highlighter
    LanguageCB.ItemIndex := LanguageCB.Items.IndexOf(LanguageManager.SelectedLanguage);
    xitm:=LanguageManager.LanguageList.Find(LanguageManager.SelectedLanguage);

    if CodePageToIdent(CodePage,cp) then
    begin
      i:=FindStrInList(cp,CodePageCB.Items);
      if (i>=0) then
      begin
        CodePageCB.ItemIndex:=i;
      end;
    end;

    UpdateStyles(xitm);
    UpdateKeywords(xitm);
    UpdateKeyCommands;
    UpdateOther(xitm);
  end;
  fEditor.LanguageManager.FillListWithLanguages(lexerforlangCB.Items,[sciLexers]);
  i:=FindStrInList(xitm.Lexer,lexerforlangCB.Items);
  if (i>=0) then
  begin
    lexerforlangCB.ItemIndex:=i;
  end;
  fOldEditorOptions.Assign(FEditorOptions);
end;

procedure TEdOptionsWindow.UpdateOther(curlng : TSciLangItem);
var
itm : TSciLangItem;
langstr : String;
i : Integer;
begin
  if curlng=nil then
  begin
    langstr:=LanguageCB.Items[LanguageCB.ItemIndex];
    itm:=FEditorOptions.FLanguageManager.LanguageList.GetStyleList(langstr);
  end else
    itm:=curlng;
  commentBoxStart.Text:=itm.CommentBoxStart;
  commentBoxEnd.Text:=itm.CommentBoxEnd;
  commentBoxMiddle.Text:=itm.CommentBoxMiddle;
  commentStreamStart.Text:=itm.CommentStreamStart;
  commentStreamEnd.Text:=itm.CommentStreamEnd;
  commentBlock.Text:=itm.CommentBlock;
  AssignmentOperatorED.Text:=itm.AssignmentOperator;
  EndOfStatementED.Text:=itm.EndOfStatementOperator;
  NumStyleBitsED.Text:=ToStr(itm.NumStyleBits);
  i:=FindStrInList(itm.Lexer,lexerforlangCB.Items);
  if (i>=0) then
  begin
    lexerforlangCB.ItemIndex:=i;
  end;
end;

procedure TEdOptionsWindow.UpdateStyles(curlng : TSciLangItem);
Var
  i : Integer;
  itm : TSciLangItem;
  langstr : String;
begin
  langstr:=LanguageCB.Items[LanguageCB.ItemIndex];
  with FEditorOptions do
  begin
    StylesLB.Items.BeginUpdate;
    try
      StylesLB.Items.Clear;
      if AnsiCompareText(langstr,cContainerLexer)=0 then
      begin
        highlighterPageCtrl.Enabled:=False;
        remLangButton.Enabled:=False;
        copyLangButton.Enabled:=False;

        StylesLB.Items.Add(sSetByCodeOnly);
        StylesLB.Items.Add(sSeeTheHelp);
      end else
      begin
        if (highlighterPageCtrl.Enabled=False) then
          highlighterPageCtrl.Enabled:=True;
        if remLangButton.Enabled=False then remLangButton.Enabled:=True;
        if copyLangButton.Enabled=False then copyLangButton.Enabled:=True;
        if assigned(curlng) then
          itm:=curlng
        else itm:=FLanguageManager.LanguageList.GetStyleList(langstr);
        for i := 0 to itm.Styles.Count - 1 do
          with itm.Styles.Items[i] as TSciStyle do
            StylesLB.Items.Add(Name);
      end;
    finally
      StylesLB.Items.EndUpdate;
    end;
    if AnsiCompareText(langstr,cContainerLexer)<>0 then
    begin
      if StylesLB.Count > 0 then
      begin
        StyleDefGB.Enabled := True;
        StylesLB.ItemIndex := 0;
        StylesLBClick(Self);
      end else
        StyleDefGB.Enabled := False;
    end;
  end;
end;

procedure TEdOptionsWindow.UpdateKeywords(curlng : TSciLangItem);
Var
  i : Integer;
  itm : TSciLangItem;
  langstr : String;
begin
  langstr:=LanguageCB.Items[LanguageCB.ItemIndex];
  with FEditorOptions do
  begin
    KeyListsLB.Items.BeginUpdate;
    try
      KeyListsLB.Items.Clear;
      if AnsiCompareText(langstr,cContainerLexer)=0 then
      begin
        highlighterPageCtrl.Enabled:=False;
        remLangButton.Enabled:=False;
        copyLangButton.Enabled:=False;
        KeylistsLB.Items.Add(sSetByCodeOnly);
        KeylistsLB.Items.Add(sSeeTheHelp);
      end else
      begin
        if (highlighterPageCtrl.Enabled=False) then
          highlighterPageCtrl.Enabled:=True;
        if remLangButton.Enabled=False then remLangButton.Enabled:=True;
        if copyLangButton.Enabled=False then copyLangButton.Enabled:=True;
        if assigned(curlng) then
          itm:=curlng
        else
          itm:=FLanguageManager.LanguageList.GetStyleList(langstr);
        for i := 0 to itm.Keywords.Count - 1 do
          with itm.Keywords.Items[i] as TSciKeywords do
            KeyListsLB.Items.Add(Name);
      end;
    finally
      KeyListsLB.Items.EndUpdate;
    end;
    if AnsiCompareText(langstr,cContainerLexer)<>0 then
    begin
      if KeyListsLB.Count > 0 then
      begin
        KeywordsM.Enabled := True;
        KeyListsLB.ItemIndex := 0;
        KeyListsLBClick(Self);
      end else
      begin
        KeywordsM.Text := '';
        KeywordsM.Enabled := False;
      end;
    end;
  end;
end;

procedure TEdOptionsWindow.UpdateKeyCommands;
Var
  i : Integer;
  KeyCommand : TSciKeyCommand;
  Item : TListItem;
  Ident : string;
begin
  KeyCmdList.Items.BeginUpdate;
  try
    KeyCmdList.Clear;
    for i := 0 to fEditorOptions.fKeyCommands.Count - 1 do
    begin
      KeyCommand := fEditorOptions.fKeyCommands.Items[i] as TSciKeyCommand;
      Item := KeyCmdList.Items.Add;
      Ident:='Unknown';
      IntToIdent(KeyCommand.Command, Ident, Sci_KeyboardCommandMap);
      Item.Caption:=Ident;
      Item.SubItems.Add(ShortCutToText(KeyCommand.ShortCut));
      Item.Data := KeyCommand;
    end;
  finally
    KeyCmdList.Items.EndUpdate;
  end;
end;

procedure   TEdOptionsWindow.RescanLanguageList;
var
cnt,i : Integer;
begin
  LanguageCB.Items.Clear;
  cnt :=FEditor.LanguageManager.LanguageList.Count;
  for i:=0 to (cnt-1) do
  begin
    LanguageCB.Items.Add(FEditor.LanguageManager.LanguageList.Items[i].Name);
  end;
  if (LanguageCB.Items.IndexOf(cContainerLexer)=-1) then
  begin
    LanguageCB.Items.Add(cContainerLexer);
  end;
end;

procedure TEdOptionsWindow.FormCreate(Sender: TObject);
begin
  fEditorOptions := TEditorOptions.Create;
  fOldEditorOptions := TEditorOptions.Create;
  GetCodePageValues(CodePageCB.Items.Append);
end;

procedure TEdOptionsWindow.FormDestroy(Sender: TObject);
begin
  FreeAndNil(fEditorOptions);
  FreeAndNil(fOldEditorOptions);
end;

procedure TEdOptionsWindow.KeyCmdListCompare(Sender: TObject; Item1,
  Item2: TListItem; Data: Integer; var Compare: Integer);
begin
  Compare:=CompStr(Item1.Caption,Item2.Caption);
end;

procedure TEdOptionsWindow.AssignmentOperatorEDChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.AssignmentOperator:=TEdit(Sender).Text;
end;

procedure TEdOptionsWindow.EndOfStatementEDChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.EndOfStatementOperator:=TEdit(Sender).Text;
end;

procedure TEdOptionsWindow.commentBoxStartChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.CommentBoxStart:=TEdit(Sender).Text;

end;

procedure TEdOptionsWindow.commentBoxMiddleChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.CommentBoxMiddle:=TEdit(Sender).Text;
end;

procedure TEdOptionsWindow.commentBoxEndChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.CommentBoxEnd:=TEdit(Sender).Text;
end;

procedure TEdOptionsWindow.commentBlockChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.CommentBlock:=TEdit(Sender).Text;
end;

procedure TEdOptionsWindow.commentStreamStartChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.CommentStreamStart:=TEdit(Sender).Text;
end;

procedure TEdOptionsWindow.commentStreamEndChange(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.CommentStreamEnd:=TEdit(Sender).Text;
end;

procedure TEdOptionsWindow.lexerforlangCBExit(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  if itm.Lexer<>lexerforlangCB.Text then
    itm.Lexer:=lexerforlangCB.Text;
end;

procedure TEdOptionsWindow.NumStyleBitsEDExit(Sender: TObject);
var
  itm : TSciLangItem;
begin
  itm:=CurrentLang;
  itm.NumStyleBits:=ToInt(TEdit(Sender).Text);
end;

procedure TEdOptionsWindow.LoadKeyCommands1Click(Sender: TObject);
begin
  if odia.Execute then
  begin
    LoadKeyCommands(fEditorOptions.fKeyCommands,odia.FileName);
    UpdateKeyCommands;
  end;
end;

procedure TEdOptionsWindow.SaveKeycommands1Click(Sender: TObject);
begin
  if sdia.Execute then
    SaveKeyCommands(fEditorOptions.fKeyCommands,sdia.FileName);
end;

procedure TEdOptionsWindow.StyleNumberSEKeyPress(Sender : TObject;var ch : Char);
begin
  TestNumericOnly(Sender,ch);
  if ch<>#0 then StyleElementChanged(Sender);
end;

procedure TEdOptionsWindow.ApplyBtnClick(Sender: TObject);
var
  cp : LongInt;
begin
  with fEditorOptions do
  begin
    Color:=defaultBackgroundCB.Selected;
    ReadOnly := ReadOnlyCB.Checked;
    BraceHilite := BraceHiliteCB.Checked;
    Gutter := GutterCB.Checked;
    WordWrap := TWordWrapType(WordWrapCB.ItemIndex);
    LineNumbers := LineNumbersCB.Checked;
    XSaveClearsUndo :=SaveClearsUndoCB.Checked;
    Indentation := [];
    if KeepIndentCB.Checked then
      Indentation := Indentation + [SciLexerMemo.KeepIndent];
    if TabIndentsCB.Checked then
      Indentation := Indentation + [SciLexerMemo.TabIndents];
    if BackSpaceUnindentsCB.Checked then
      Indentation := Indentation + [SciLexerMemo.BackSpaceUnindents];
    if IndentationGuidesCB.Checked then
      Indentation := Indentation + [SciLexerMemo.IndentationGuides];
    if CodeFoldingCB.Checked then
    CodeFolding := CodeFolding+[foldFold]
    else
    CodeFolding := CodeFolding-[foldFold];

    TabWidth := ToInt(TabWidthSE.Text);
    IndentWidth := ToInt(IndentWidthSE.Text);
    EOLStyle := TEOLStyle(EOLStyleCB.ItemIndex);
    CaretFore :=CaretCB.Selected;
    SelFore :=SelForeCB.Selected;
    SelBack :=SelBackCB.Selected;
    FoldLo :=FoldLoCB.Selected;
    FoldHi :=FoldHiCB.Selected;
    MarkerFore:=MarkerForeCB.Selected;
    MarkerBack:=MarkerBackCB.Selected;
    BMarkFore :=BMarkForeCB.Selected;
    BMarkBack :=BMarkBackCB.Selected;

    HotActiveFore:=HotActiveForeCB.Selected;
    HotActiveBack :=HotActiveBackCB.Selected;
    HotActiveUnderline :=HotActiveUnderlineCB.Checked;
    HotActiveSingleLine :=HotActiveSingleLineCB.Checked;
    CaretWidth :=ToInt(CaretWidthSE.Text);
    CaretBack :=CaretBackCB.Selected;
    CaretLineVisible :=CaretLineVisCB.Checked;
    EdgeColor:=EdgeColorCB.Selected;
    MarkerType:=sciMarkerType(markerTypeCB.ItemIndex);
    EdgeColumn:=ToInt(EdgeColumnSE.Text);
    EdgeType:=sciEdgeType(EdgeTypeCB.ItemIndex);

    if IdentToCodePage(CodePageCB.Items.Strings[CodePageCB.ItemIndex],cp) then
      CodePage:=cp;
    if Assigned(Editor) then
      SetOptions(FEditor);
  end;
end;

procedure TEdOptionsWindow.FontButtonClick(Sender: TObject);
begin
  FontDialog.Font := fEditorOptions.Font;
  if FontDialog.Execute then
    fEditorOptions.Font := FontDialog.Font;
end;

procedure TEdOptionsWindow.OKBtnClick(Sender: TObject);
begin
  ApplyBtnClick(Self);
end;

procedure TEdOptionsWindow.CancelBtnClick(Sender: TObject);
begin
// removed by hdalis.. No need to refresh the styles if nothing isn't changed.. I thing..
//  if not Assigned(Scintilla) then Exit;
//  fOldEditorOptions.SetOptions(FEditor);
end;

procedure TEdOptionsWindow.StylesLBClick(Sender: TObject);
Var
  SciStyle : TSciStyle;
  langstr : String;
begin
  if StylesLB.ItemIndex >= 0 then
  begin
    // To avoid getting into StyleElementChanged
    UpdatingStyle := True;

    langstr :=LanguageCB.Items[LanguageCB.ItemIndex];
    SciStyle := FEditorOptions.LanguageManager.LanguageList.GetStyleList(langstr).Styles.Items[StylesLB.ItemIndex] as TSciStyle;
    StyleNumberSE.Text := IntToStr(SciStyle.StyleNumber);
    DescriptionEB.Text := SciStyle.Name;
    if SciStyle.FontName = '' then
    begin
      FontCB.FontName := '';
      FontCB.Enabled:=False;
      DefaultFontCB.Checked := True;
    end else
    begin
      FontCB.FontName := SciStyle.FontName;
      FontCB.Enabled:=True;
      DefaultFontCB.Checked := False;
    end;
    SizeSE.Text := IntToStr(SciStyle.FontSize);
    if SciStyle.StyleNumber=STYLE_CONTROLCHAR then
    begin
      ForeCB.Enabled:=False;
      BackCB.Enabled:=False;
    end else
    begin
      if ForeCB.Enabled=False then ForeCB.Enabled:=True;
      if BackCB.Enabled=False then BackCB.Enabled:=True;

      ForeCB.Selected := SciStyle.ForeColor;
      ForeCB.Repaint;
      BackCB.Selected := SciStyle.BackColor;
      BackCB.Repaint;
    end;
    CaseCB.ItemIndex := Integer(SciStyle.CharCase);
    ItalicCB.Checked := fsItalic in SciStyle.FontStyles;
    BoldCB.Checked := fsBold in SciStyle.FontStyles;
    UnderlineCB.Checked := fsUnderline in SciStyle.FontStyles;
    VisibleCB.Checked := SciStyle.Visible;
    ChangeableCB.Checked := SciStyle.Changeable;
    EOLFilledCB.Checked := SciStyle.EOLFilled;
    HotspotCB.Checked := SciStyle.Hotspot;
    // Now set it to false
    UpdatingStyle := False;
  end;
end;

procedure TEdOptionsWindow.LanguageCBChange(Sender: TObject);
var
langstr : String;
itm : TSciLangItem;
begin
  langstr:=LanguageCB.Items[LanguageCB.ItemIndex];
  fEditorOptions.LanguageManager.SelectedLanguage := langstr;
  itm:=fEditorOptions.LanguageManager.LanguageList.Find(langstr);
  UpdateStyles(itm);
  UpdateKeywords(itm);
  UpdateOther(itm);
end;

procedure TEdOptionsWindow.StyleElementChanged(Sender: TObject);
Var
  SciStyle : TSciStyle;
begin
  if UpdatingStyle then
    Exit;
  if StylesLB.ItemIndex >= 0 then
  begin
    SciStyle := FEditorOptions.LanguageManager.LanguageList.GetStyleList(LanguageCB.Items[LanguageCB.ItemIndex]).Styles.Items[StylesLB.ItemIndex] as TSciStyle;
    SciStyle.StyleNumber := ToInt(StyleNumberSE.Text);
    SciStyle.Name := DescriptionEB.Text;
    StylesLB.Items[StylesLB.ItemIndex] := DescriptionEB.Text;
    if DefaultFontCB.Checked=True then
    begin
      SciStyle.FontName := '';
      FontCB.Enabled:=False;
    end  else
    begin
      SciStyle.FontName := FontCB.FontName;
      FontCB.Enabled:=True;
    end;
    SciStyle.FontSize := ToInt(SizeSE.Text);
    SciStyle.ForeColor := ForeCB.Selected;
    SciStyle.BackColor := BackCB.Selected;
    SciStyle.CharCase := TSciCase(CaseCB.ItemIndex);
    SciStyle.FontStyles := [];
    if ItalicCB.Checked then
      SciStyle.FontStyles := SciStyle.FontStyles + [fsItalic];
    if BoldCB.Checked then
      SciStyle.FontStyles := SciStyle.FontStyles + [fsBold];
    if UnderlineCB.Checked then
      SciStyle.FontStyles := SciStyle.FontStyles + [fsUnderline];
    SciStyle.Visible := VisibleCB.Checked;
    SciStyle.Changeable := ChangeableCB.Checked;
    SciStyle.EOLFilled := EOLFilledCB.Checked;
    SciStyle.Hotspot := HotspotCB.Checked;
  end;
end;

procedure TEdOptionsWindow.DeleteStyleBClick(Sender: TObject);
var
itm : TSciLangItem;
style : TSciStyle;
begin
  if StylesLB.ItemIndex >= 0 then
  begin
    itm:=CurrentLang;
    style:=itm.Styles.Items[StylesLB.ItemIndex];
    FreeAndNil(style);
    StylesLB.Items.Delete(StylesLB.ItemIndex);
    UpdateStyles(itm);
  end;
end;

procedure TEdOptionsWindow.AddStyleBClick(Sender: TObject);
var
  langstr : String;
  stylescnt : Integer;
  itm : TSciLangItem;

begin
  langstr:=LanguageCB.Items[LanguageCB.ItemIndex];
  itm:=FEditorOptions.LanguageManager.LanguageList.GetStyleList(langstr);
  with itm.Styles.Add as TSciStyle do
  begin
    Name := sNewStyle;
    StyleNumber :=  itm.Styles.Count-1;
  end;
  UpdateStyles(itm);
  stylescnt:=StylesLB.Items.Count;
  StylesLB.Selected[stylescnt-1] := True;
  StylesLBClick(Self);
end;

procedure TEdOptionsWindow.KeyListsLBClick(Sender: TObject);
var
  SciKeywords : TSciKeywords;
  itm : TSciLangItem;
begin
  if KeyListsLB.ItemIndex >= 0 then
  begin
    // To avoid getting into KeyListElementChanged
    UpdatingKeyList := True;
    itm:=CurrentLang;
    SciKeywords := itm.Keywords.Items[KeyListsLB.ItemIndex] as TSciKeywords;
    KeyListNumberSE.Text := IntToStr(SciKeywords.KeywordListNumber);
    KeyListDescriptionEB.Text := SciKeywords.Name;
{$Ifdef COMPILER6_UP}
    SciKeywords.Keywords.Delimiter := ' ';
    KeywordsM.Text := SciKeywords.Keywords.DelimitedText;
{$Else}
    KeywordsM.Text:=MergeStrings(SciKeywords.Keywords);
{$Endif}
    UpdatingKeyList := False;
  end;
end;

procedure TEdOptionsWindow.KeyListElementsChange(Sender: TObject);
Var
  SciKeywords : TSciKeywords;
begin
  if UpdatingKeyList then
    Exit;
  if KeyListsLB.ItemIndex >= 0 then
  begin
    SciKeywords := CurrentLang.Keywords.Items[KeyListsLB.ItemIndex] as TSciKeywords;
    SciKeywords.Name := KeyListDescriptionEB.Text;
    KeyListsLB.Items[KeyListsLB.ItemIndex] := KeyListDescriptionEB.Text;
    SciKeywords.KeywordListNumber := ToInt(KeyListNumberSE.Text);
{$Ifdef COMPILER6_UP}
    SciKeywords.Keywords.Delimiter := ' ';
    SciKeywords.Keywords.DelimitedText := KeywordsM.Text;
{$Else}
    SplitStrings(KeywordsM.Text,SciKeywords.Keywords);
{$Endif}
  end;
end;

procedure TEdOptionsWindow.KeyListDeleteClick(Sender: TObject);
var
  keywd : TSciKeywords;
begin
  if KeyListsLB.ItemIndex >= 0 then
  begin
    keywd:=CurrentLang.Keywords.Items[KeyListsLB.ItemIndex];
    FreeAndNil(keywd);
    KeyListsLB.Items.Delete(KeyListsLB.ItemIndex);
    UpdateKeywords;
  end;
end;

procedure TEdOptionsWindow.KeyListAddClick(Sender: TObject);
var
  langstr : String;
  itm : TSciLangItem;
begin
  langstr:=LanguageCB.Items[LanguageCB.ItemIndex];
  itm:=FEditorOptions.LanguageManager.LanguageList.GetStyleList(langstr);
  with itm.Keywords.Add as TSciKeywords do
  begin
    Name := sNewKeyList;
    KeywordListNumber:=  itm.Keywords.Count-1;
  end;
  UpdateKeywords(itm);
  KeyListsLB.Selected[KeyListsLB.Items.Count-1] := True;
  KeyListsLBClick(Self);
end;

procedure TEdOptionsWindow.btnDeleteClick(Sender: TObject);
var
  keyc : TSciKeyCommand;
begin
  if Assigned(KeyCmdList.Selected) then
  begin
    keyc:=TSciKeyCommand(KeyCmdList.Selected.Data);
    FreeAndNil(keyc);
    UpdateKeyCommands;
  end;
end;

procedure TEdOptionsWindow.btnResetClick(Sender: TObject);
begin
  fEditorOptions.fKeyCommands.ResetDefaultCommands;
  UpdateKeyCommands;
end;

procedure TEdOptionsWindow.btnEditClick(Sender: TObject);
Var
  KeyCommand : TSciKeyCommand;
begin
  if Assigned(KeyCmdList.Selected) then
  begin
    KeyCommand := TSciKeyCommand(KeyCmdList.Selected.Data);
    with TKeyEditForm.Create(Self) do
    begin
      cmbCommand.ItemIndex :=  cmbCommand.Items.IndexOf(KeyCmdList.Selected.Caption);

      HotKey.HotKey := KeyCommand.ShortCut;
      if (ShowModal = mrOK) and (cmbCommand.ItemIndex >= 0) and (HotKey.HotKey <> 0) then
      begin
        KeyCommand.ShortCut := HotKey.HotKey;
        KeyCommand.Command :=  Integer(cmbCommand.Items.Objects[cmbCommand.ItemIndex]);
        UpdateKeyCommands;
      end;
      Release;
    end;
  end;
end;


procedure TEdOptionsWindow.btnAddClick(Sender: TObject);
Var
  KeyCommand : TSciKeyCommand;
begin
    with TKeyEditForm.Create(Self) do
    begin
      if (ShowModal = mrOK) and (cmbCommand.ItemIndex >= 0) and (HotKey.HotKey <> 0) then
      begin
        KeyCommand := fEditorOptions.fKeyCommands.FindShortCut(HotKey.HotKey);
        if not Assigned(KeyCommand) then
          KeyCommand := fEditorOptions.fKeyCommands.Add as TSciKeyCommand;
        KeyCommand.ShortCut := HotKey.HotKey;
        KeyCommand.Command :=  Integer(cmbCommand.Items.Objects[cmbCommand.ItemIndex]);
        UpdateKeyCommands;
      end;
      Release;
    end;
end;

procedure TEdOptionsWindow.TestNumericOnly(Sender: TObject; var Key: Char);
begin
  if (Key>#31) and ((Key<'0') or (Key>'9')) then Key:=#0;
end;

procedure TEdOptionsWindow.addLangButtonClick(Sender: TObject);
var
  itm : TSciLangItem;
  itmpos : Integer;
begin
  sciAddLanguageForm:=TsciAddLanguageForm.Create(self);
  FEditorOptions.FLanguageManager.FillListWithLanguages(sciAddLanguageForm.LexerToUseCB.Items,[sciLexers]);
  sciAddLanguageForm.LexerToUseCB.ItemIndex:=sciAddLanguageForm.LexerToUseCB.Items.IndexOf('null');
  if sciAddLanguageForm.ShowModal=mrOk then
  begin
    itm:=FEditorOptions.FLanguageManager.AddLanguage(sciAddLanguageForm.languagename.Text,sciAddLanguageForm.LexerToUseCB.Items[sciAddLanguageForm.LexerToUseCB.ItemIndex]);
    if itm<>nil then
    begin
      itmpos:=LanguageCB.Items.Add(sciAddLanguageForm.languagename.Text);
      if itmpos>=0 then
      begin
        //Just check to see if we have this message first.
        LanguageCB.ItemIndex:=itmpos;
        LanguageCBChange(self);
        if (LanguageCB.Items.Count>0) then
          highlighterPageCtrl.Enabled:=True
        else
          highlighterPageCtrl.Enabled:=False;
      end;
    end else
      raise Exception.Create(eCouldntAddTheLanguage);
  end;
end;

procedure TEdOptionsWindow.remLangButtonClick(Sender: TObject);
var
  itmpos : Integer;
  langstr : String;
  notinstat : Boolean;
begin
  itmpos:=LanguageCB.ItemIndex;
  if itmpos=-1 then Exit;
  langstr:=LanguageCB.Items[itmpos];
  if AnsiCompareText(langstr,cContainerLexer)=0 then
  begin
    raise Exception.Create(eCantRemoveLanguage);
    Exit;
  end;

  if(FEditorOptions.FLanguageManager.RemoveLanguage(langstr,notinstat)=True) then
  begin
    if notinstat=True then //if not a static lexer
    begin
      try
        LanguageCB.Items.BeginUpdate;
        LanguageCB.Items.Delete(itmpos);
        if itmpos>=LanguageCB.Items.Count then
          itmpos:=(LanguageCB.Items.Count-1)
        else
          Dec(itmpos);
        LanguageCB.ItemIndex:=itmpos;
        LanguageCBChange(self);
      finally
        LanguageCB.Items.EndUpdate;
      end;
      if (LanguageCB.Items.Count>0) then
        highlighterPageCtrl.Enabled:=True
      else
        highlighterPageCtrl.Enabled:=False;

    end else //it was a static lexer, just update the styles and keywords.
    begin
      UpdateStyles;
      UpdateKeywords;
    end;
  end;

end;

procedure TEdOptionsWindow.copyLangButtonClick(Sender: TObject);
var
  srclang,langstr : String;
  itm : TSciLangItem;
begin
  srclang:=LanguageCB.Items[LanguageCB.ItemIndex];
  if AnsiCompareText(srclang,cContainerLexer)=0 then
  begin
    raise Exception.Create(eCantCopyLanguage);
    Exit;
  end;

  itm:=FEditorOptions.FLanguageManager.DupLanguage(srclang);
  if itm<>nil then
  begin
    langstr:=sLMLanguage+'['+IntToStr(itm.ID)+']';
    if(InputQuery(Format(sCopyLanguageQueryTitle,[srclang]),sNameOfNewLanguage,langstr)) then
    begin
    itm.Name:=langstr;
    LanguageCB.ItemIndex:=LanguageCB.Items.Add(itm.Name);
    LanguageCBChange(self);
    end else
    FEditorOptions.FLanguageManager.LanguageList.Delete(itm.Index);
  end else
  raise Exception.CreateResFmt(@eCouldntCopyLangTo,[srclang,langstr]);
end;

procedure TEdOptionsWindow.OptionPagesChange(Sender: TObject);
begin
  if OptionPages.Showing then
  begin
    case OptionPages.ActivePageIndex of
      0: GutterCB.SetFocus;
      1: SelForeCB.SetFocus;
      2: LanguageCB.SetFocus;
      3: KeyCmdList.SetFocus;
    end;
  end;
end;


end.
Added src/delphisci/LangResources.RES.

cannot compute difference between binary files

Added src/delphisci/LangResources.rc.


>
1
BuiltInLangs 10 "h:\\MyEditor\\Styles\\Black.styles"
Added src/delphisci/SciActions.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
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
  Created: 27/06/2005, 19:51:14
  History: 27/06/2005 Initial Release
           18/05/2006 inherited wasn't called in the destructor of TSciActionBase, resulting in
                      a small memoryleak. Fixed.
      $Id: $
}
{$Include SciCommonDef.Inc}
unit SciActions;
interface
uses Classes,ActnList,SciLexer;
  type
  TSciActionBase=class(TAction)
  private
    FControl : TScintillaBase;
  protected
    procedure SetControl(Value : TScintillaBase);
    function GetControl(Target: TObject): TScintillaBase;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    procedure AssignTo(Dest: TPersistent); override;

  public
    function HandlesTarget(Target: TObject): Boolean; override;

    property Control: TScintillaBase read FControl write SetControl;
    destructor Destroy; override;
  end;

  TSciRedo = class(TSciActionBase)
  public
    procedure UpdateTarget(Target: TObject);override;
    procedure ExecuteTarget(Target: TObject);override;
  published
  end;

implementation
destructor TSciActionBase.Destroy;
begin
  if assigned(FControl) then
    FControl.RemoveFreeNotification(Self);
  inherited;
end;
function TSciActionBase.GetControl(Target: TObject): TScintillaBase;
begin
  Result := Target as TScintillaBase;
end;

procedure TSciActionBase.SetControl(Value : TScintillaBase);
begin
  if Value<>FControl then
  begin
    FControl:=Value;
    if Value <> nil then Value.FreeNotification(Self);
  end;
end;
function TSciActionBase.HandlesTarget(Target: TObject): Boolean;
begin
  Result := ((Control <> nil) and (Target = Control) or
    (Control = nil) and (Target is TScintillaBase)) and TScintillaBase(Target).Focused;
end;
procedure TSciActionBase.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent, Operation);
  if (Operation = opRemove) and (AComponent = Control) then Control := nil;
end;

procedure TSciActionBase.AssignTo(Dest: TPersistent);
begin
  inherited AssignTo(Dest);
  if Dest is TSciActionBase then
    TSciActionBase(Dest).Control:=FControl;
end;

procedure TSciRedo.ExecuteTarget(Target: TObject);
begin
  GetControl(Target).Redo;
end;

procedure TSciRedo.UpdateTarget(Target: TObject);
begin
  if (assigned(Target)) and (GetControl(Target).HandleAllocated) and (GetControl(Target).CanRedo) then
    Enabled:=True
  else
    Enabled:=False;
end;
end.
Added src/delphisci/SciActionsRes.ddp.

cannot compute difference between binary files

Added src/delphisci/SciActionsRes.dfm.




































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
object SciActionsData: TSciActionsData
  OldCreateOrder = False
  Left = 234
  Top = 56
  Height = 150
  Width = 215
  object ActionList1: TActionList
    Images = ImageList1
    Left = 82
    Top = 49
    object SciRedo1: TSciRedo
      Category = 'Edit'
      Caption = '&Redo'
      Hint = 'Redo|Reverses the action of the last undo command'
      ImageIndex = 0
      ShortCut = 24666
    end
  end
  object ImageList1: TImageList
    Left = 57
    Top = 18
    Bitmap = {
      494C010101000400040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
      0000000000003600000028000000400000001000000001002000000000000010
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000008000
      0000808080000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000808080008000
      0000000000000000000000000000000000000000000080000000800000008000
      0000800000008000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000800000000000
      0000000000000000000000000000000000000000000000000000800000008000
      0000800000008000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000800000000000
      0000000000000000000000000000000000000000000000000000000000008000
      0000800000008000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000800000000000
      0000000000000000000000000000000000000000000000000000800000000000
      0000800000008000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000808080008000
      0000000000000000000000000000000000008080800080000000000000000000
      0000000000008000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000008080
      8000800000008000000080000000800000008080800000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      0000000000000000000000000000000000000000000000000000000000000000
      000000000000000000000000000000000000424D3E000000000000003E000000
      2800000040000000100000000100010000000000800000000000000000000000
      000000000000000000000000FFFFFF00FFFF000000000000FFFF000000000000
      FFFF000000000000FFFF000000000000FFFF000000000000E7FF000000000000
      CF83000000000000DFC3000000000000DFE3000000000000DFD3000000000000
      CF3B000000000000E07F000000000000FFFF000000000000FFFF000000000000
      FFFF000000000000FFFF00000000000000000000000000000000000000000000
      000000000000}
  end
end
Added src/delphisci/SciActionsRes.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
unit SciActionsRes;

interface
(*$HPPEMIT '#pragma link "dclact.lib"'*)
uses
  SysUtils, Classes, ImgList, Controls, ActnList, SciActions;

type
  TSciActionsData = class(TDataModule)
    ActionList1: TActionList;
    ImageList1: TImageList;
    SciRedo1: TSciRedo;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  SciActionsData: TSciActionsData;

implementation

{$R *.dfm}

end.
Added src/delphisci/SciAutoComplete.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
  Created: 18/11/2004, 19:51:14
  History: 18/11/2004 Initial Release
           12/04/2005 Added the OnBeforeShow event
           15/04/2005 Added MaxWidth,MaxHeight properties and the OnAutoCSelection event
                      to conform to Scintilla 1.63
           03/06/2005 Reintroduced the functionality of NumStartChars.. Hope it works now.
                      Note: The test for NumStartChars is done BEFORE the OnBeforeShow event,
                      and because of that, if there are'nt enough chars in the word typed,
                      then no OnBeforeShow event is fired.
           18/08/2005 Renamed CompleteWord and CompleteWordOnlyOne to FromDocument and FromDocumentOnlyOne,
                      as this more accurately describes its purpose.. CompleteWord is rather understood
                      to complete words or not, and this is a autocomplete component.. ahem..
           23/03/2006 Fixed a bug in StartAutoCompleteWord which caused length of typed word>NumStartChars when it was not.
      $Id: SciAutoComplete.pas,v 1.1 2004/11/18 19:51:14 hdalis Exp $
     TODO: Find a solution to the setting of the properties of a linked component
           without reassigning the properties in the Loaded procedure.
}
{$Include SciCommonDef.Inc}
unit SciAutoComplete;
interface
uses Classes, SciLexer,SciLexerMemo,SciControllerHandler;

type
  //Note: If we are fetching words from the document, then the ListToDisplay is NIL because this event
  //is fired BEFORE we start to search for words.
  TSciBeforeAutoCompleteShowEvent = procedure(Sender : TObject; const Position : LongInt;const TypedLen : Integer;ListToDisplay : TStrings;var CancelDisplay : Boolean) of object;

TSciAutoComplete = class(TComponent)
  private
    FEditor : TScintillaMemo;
    fCharAddedProc : TCharAddedProc;
    fAutoCSelectionProc : TAutoCSelectionProc;
    FAStrings : TStrings;
    FNumStartChars : Integer;
    FTypeSeparator : Char;
    FStopChars,FAutoStrings,FStartChars : String;
    FAutoCompleteDisabled,FAutoCompleteWord,FAutoCompleteWordOnlyOne,
    FAutoCSetIgnoreCase,FAutoCSetChooseSingle,FAutoCSetAutoHide,
    FAutoCSetDropRestOfWord,FAutoCSetCancelAtStart,autoCCausedByOnlyOne : boolean;
    FAutoCompleteWordCharacters : String;
    FOnAutoCSelection : TSCEvent_autocselection; 
    FOnBeforeShow : TSciBeforeAutoCompleteShowEvent;
    procedure setStrings(Value : TStrings);
    procedure setAutoCompleteStopChars(const Value : String);
    procedure setOpt(const Index : Integer;const Value : Boolean);
    function  getOpt(Index : Integer) : Boolean;
    procedure setScintilla(Value : TScintillaMemo);
    procedure detachScintilla;
    procedure setMaxWidth(const Value : Integer);
    procedure setMaxHeight(const Value : Integer);
    function getMaxWidth : Integer;
    function getMaxHeight : Integer;
    procedure setTypeSeparator(Value : Char);
    function  getTypeSeparator : Char;
  protected
    procedure EvtCharAdded (Sender : TObject; const ch : LongInt);virtual;
    procedure EvtAutoCSelection(Sender : TObject;text : PChar);virtual;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    procedure Loaded; override;

  public
    constructor Create(AOwner : TComponent);override;
    destructor  Destroy; override;
    function  StartAutoCompleteWord(const onlyOneWord : boolean) : Boolean;
    procedure StartAutoComplete;
  published
    property Disabled : Boolean read FAutoCompleteDisabled write FAutoCompleteDisabled default False;
    property NumStartChars : Integer read FNumStartChars write FNumStartChars default 1;
    property StartChars : String read FStartChars write FStartChars;
    property StopChars  : String read FStopChars write setAutoCompleteStopChars;
    property AStrings : TStrings read FAStrings write setStrings;
    property IgnoreCase : Boolean index 0 read getOpt Write setOpt;
    property ChooseSingle : Boolean index 1 read getOpt Write setOpt;
    property AutoHide : Boolean index 2 read getOpt Write setOpt;
    property DropRestOfWord : Boolean index 3 read getOpt Write setOpt;
    property CancelAtStart : Boolean index 4 read getOpt Write setOpt;
    property FromDocument : boolean read FAutoCompleteWord write FAutoCompleteWord default True;
    property FromDocumentOnlyOne : boolean read FAutoCompleteWordOnlyOne write FAutoCompleteWordOnlyOne default False;
    property TypeSeparator : Char read getTypeSeparator write setTypeSeparator default '?';

    property Editor : TScintillaMemo read FEditor write setScintilla;
    property WordCharacters : String read FAutoCompleteWordCharacters write FAutoCompleteWordCharacters;
    property OnBeforeShow : TSciBeforeAutoCompleteShowEvent read FOnBeforeShow write FOnBeforeShow;
    property MaxWidth : Integer read getMaxWidth write setMaxWidth;
    property MaxHeight : Integer read getMaxHeight write setMaxHeight;
    property OnAutoCSelection : TSCEvent_autocselection read FOnAutoCSelection write FOnAutoCSelection;
  end;


implementation

uses Math,SciSupport,sciUtils,SysUtils;

// TSciAutoComplete
constructor TSciAutoComplete.Create(AOwner : TComponent);
begin
  Inherited Create(AOwner);
  FEditor := nil;
  FStartChars :='';
  FStopChars :='';
  FAutoCompleteWordCharacters:='';
  FAutoCompleteWord:=True;
  FAutoCompleteWordOnlyOne:=False;
  FTypeSeparator:='?';
  FNumStartChars:=1;
  FAutoCompleteDisabled:=False;
  FAStrings :=TMyStringList.Create;
  TMyStringList(FAStrings).Sorted:=true;
  TMyStringList(FAStrings).Duplicates :=dupIgnore;
  FCharAddedProc:=TCharAddedProc.Create(EvtCharAdded);
  FAutoCSelectionProc:=TAutoCSelectionProc.Create(EvtAutoCSelection);
end;

destructor TSciAutoComplete.Destroy;
begin
  DetachScintilla;
  if assigned(FAStrings) then FreeAndNil(FAStrings);
  if assigned(fCharAddedProc) then FreeAndNil(FCharAddedProc);
  if assigned(FAutoCSelectionProc) then FreeAndNil(FAutoCSelectionProc);
  inherited Destroy;
end;

procedure TSciAutoComplete.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent,Operation);
  if assigned(AComponent) then
  begin
    if Operation=opRemove then
    begin
      if AComponent=FEditor then
      begin
        DetachScintilla;
        FEditor:=nil;
      end;
    end;
  end;
end;

procedure TSciAutoComplete.Loaded;
begin
  if assigned(FEditor) then
  begin
    {Update the connected Scintilla control with the settings here, as we don't have any Editor attached before now}
    IgnoreCase:=FAutoCSetIgnoreCase;
    ChooseSingle:=FAutoCSetChooseSingle;
    AutoHide:=FAutoCSetAutoHide;
    DropRestOfWord:=FAutoCSetDropRestOfWord;
    CancelAtStart:=FAutoCSetCancelAtStart;
    StopChars:=FStopChars;
  end;
end;

procedure TSciAutoComplete.detachScintilla;
begin
  if assigned(FEditor) then
  begin
    FEditor.RemoveHandler(FCharAddedProc);
    FEditor.RemoveHandler(FAutoCSelectionProc);
  end;
  FEditor:=nil;
end;

procedure TSciAutoComplete.setScintilla(Value : TScintillaMemo);
begin
  if assigned(Value) then
  begin
    DetachScintilla;
    FEditor:=Value;
    if FAutoCompleteWordCharacters='' then
      FAutoCompleteWordCharacters:=FEditor.WordChars;
    FEditor.AddHandler(FCharAddedProc);
    FEditor.AddHandler(FAutoCSelectionProc);
  end else
  begin
    DetachScintilla;
  end;
end;

procedure TSciAutoComplete.setTypeSeparator(Value : Char);
begin
  FTypeSeparator:=Value;
  if not assigned(FEditor) then Exit;
  fEditor.AutoCSetTypeSeparator(Integer(Value));
end;

function  TSciAutoComplete.getTypeSeparator : Char;
begin
  if not assigned(FEditor) then
    Result:=FTypeSeparator
  else
    Result:=Char(fEditor.AutoCGetTypeSeparator);
end;

procedure TSciAutoComplete.setMaxWidth(const Value : Integer);
begin
  if not assigned(FEditor) then Exit;
  FEditor.AutoCSetMaxWidth(Value);
end;

procedure TSciAutoComplete.setMaxHeight(const Value : Integer);
begin
  if not assigned(FEditor) then Exit;
  FEditor.AutoCSetMaxHeight(Value);
end;

function TSciAutoComplete.getMaxWidth : Integer;
begin
  if not assigned(FEditor) then
  begin
    Result:=0;
    Exit;
  end;
  Result:=FEditor.AutoCGetMaxWidth;
end;

function TSciAutoComplete.getMaxHeight : Integer;
begin
  if not assigned(FEditor) then
  begin
    Result:=0;
    Exit;
  end;
  Result:=FEditor.AutoCGetMaxHeight;
end;

procedure TSciAutoComplete.setOpt(const Index : Integer;const Value : Boolean);
begin
  case Index of // Set backup variables, so that when Loaded is called we can assign the settings.
    0:  FAutoCSetIgnoreCase:=Value;
    1:  FAutoCSetChooseSingle:=Value;
    2:  FAutoCSetAutoHide:=Value;
    3:  FAutoCSetDropRestOfWord:=Value;
    4:  FAutoCSetCancelAtStart:=Value;
  end;
  if FEditor=nil then Exit; // Exit if we don't have any attached control.
  case Index of
    0: FEditor.AutoCSetIgnoreCase(Value);
    1: FEditor.AutoCSetChooseSingle(Value);
    2: FEditor.AutoCSetAutoHide(Value);
    3: FEditor.AutoCSetDropRestOfWord(Value);
    4: FEditor.AutoCSetCancelAtStart(Value);
  end;
end;

function TSciAutoComplete.getOpt(Index : Integer) : Boolean;
begin
  if FEditor=nil then
  begin
    case Index of // Return the settings from backup variables if we don't have any attached control.
      0:  Result:=FAutoCSetIgnoreCase;
      1:  Result:=FAutoCSetChooseSingle;
      2:  Result:=FAutoCSetAutoHide;
      3:  Result:=FAutoCSetDropRestOfWord;
      4:  Result:=FAutoCSetCancelAtStart;
      else Result:=False;
    end;
    Exit; // Exit if we don't have any attached control.
  end;
  case Index of
    0: Result :=FEditor.AutoCGetIgnoreCase;
    1: Result :=FEditor.AutoCGetChooseSingle;
    2: Result :=FEditor.AutoCGetAutoHide;
    3: Result :=FEditor.AutoCGetDropRestOfWord;
    4: Result :=FEditor.AutoCGetCancelAtStart;
    else Result :=False;
  end;
end;

procedure TSciAutoComplete.setStrings(Value : TStrings);
begin
  FAStrings.Assign(Value);
  TMyStringList(FAStrings).Sort;
end;

procedure TSciAutoComplete.SetAutoCompleteStopChars(const Value : String);
begin
  FStopChars :=Value;
  if not assigned(FEditor) then Exit;
  FEditor.AutoCStops(PChar(Value));
end;

procedure TSciAutoComplete.StartAutoComplete;
var
  line,startswith : String;
  linenum,current,startword,typedlen : LongInt;
  cancelit : Boolean;
begin
  if not assigned(FEditor) then Exit;
  linenum :=FEditor.GetCurrentLineNumber;
  line :=FEditor.GetLineS(linenum);
  current :=FEditor.GetCaretInLine;
  startword :=current;
  if startword=0 then Exit;
  while ((startword>0) and (CharPos(FEditor.WordChars,AnsiChar(line[startword-1]),1)<>0) or (CharPos(StartChars,AnsiChar(line[startword-1]),1)<>0))
    do startword:=startword-1;
  typedlen :=current-startword+1;
  if typedlen>=FNumStartChars then
  begin
    startswith:=Copy(WideString(line), startword, typedlen);
    if assigned(FOnBeforeShow) then
    begin
      cancelit:=False;
      FOnBeforeShow(Self,FEditor.GetCurrentPos,typedlen,FAStrings,cancelit);
      if cancelit then Exit;
    end;

    FillMatching(startswith,FAutoStrings,FAStrings,IgnoreCase);
    FAutoStrings:=Trim(FAutoStrings);
    if FAutoStrings<>'' then
      FEditor.AutoCShow(typedlen,PChar(FAutoStrings));
  end;
end;

function TSciAutoComplete.StartAutoCompleteWord(const onlyOneWord : boolean) : Boolean;
var
  line,wordsNear,root : String;
  current,startword,doclen,flags,posCurrentWord,minWordLength,nwords,wordMaxSize,wordlen,len,posFind : LongInt;
  allnumber : boolean;
  ft : TTextToFind;
  wordstart : array[0..160] of char;
  wordend : PChar;
  cancelit : Boolean;
begin
  Result:=False;
  if not assigned(FEditor) then Exit;
  line :=FEditor.GetLineS;
  wordMaxSize:=80;
  minWordLength:=0;
  nwords:=0;

  current:=FEditor.GetCaretInLine;
  startword:=current;
  allnumber :=true;
  doclen:=FEditor.GetLength;
  while ((startword>0) and (CharPos(FEditor.WordChars,AnsiChar(line[startword-1]),1)<>0)) do
  begin
    startword:=startword-1;
    if Boolean(line[startword] < '0') or Boolean(line[startword] > '9') then allNumber := false;
  end;
  if Boolean(startword=current) or Boolean(allnumber=true) then
  begin
    Result :=True;
    Exit;
  end;
  root:=Copy(WideString(line), startword, current-startword+1);
  cancelit:=False;
  if assigned(FOnBeforeShow) then
  begin
    cancelit:=False;
    FOnBeforeShow(Self,FEditor.GetCurrentPos,Length(root),nil,cancelit);
    if cancelit then Exit;
  end;

  ft.lpstrText:=PChar(root);
  ft.chrg.cpMin :=0;
  ft.chrgText.cpMin :=0;
  ft.chrgText.cpMax :=0;
  flags:=SCFIND_WORDSTART;
  if not IgnoreCase then
    flags :=flags or SCFIND_MATCHCASE;
  posCurrentWord :=FEditor.GetCurrentPos-Length(root);
  wordsNear:='';
  while true do
  begin
    ft.chrg.cpMax := doclen;
    posFind:=FEditor.FindTextX(flags,@ft);
    if (posFind=-1) or (posFind>=doclen) then
    begin
      Break;
    end;
    if posFind=posCurrentWord then
    begin
      ft.chrg.cpMin := posFind + Length(root);
      Continue;
    end;
    FEditor.GetRange(posFind, Min(posFind + wordMaxSize - 3, doclen), wordstart);
    wordend:=Pointer(wordstart + Length(root));
    while (CharPos(FAutoCompleteWordCharacters,AnsiChar(wordend^))>0) do Inc(wordend); //compare to the wordchars property
    wordend^:=#0;
    wordlen :=(wordend-@wordstart);
    if wordlen>Length(root) then
    begin
      if (Pos(wordstart+' ',wordsNear+' ')=0) then
      begin
        if(nwords>0) then
            wordsNear:=wordsNear+' '+String(wordstart)
        else
        wordsNear:=String(wordstart);

        if minWordLength<wordlen then minWordLength:=wordlen;
        nwords:=nwords+1;
        if (onlyOneWord=true) and Boolean(nwords>1) then
        begin
          result :=true;
          Exit;
        end;
      end;
    end;
    ft.chrg.cpMin := posFind + wordlen;
  end;
  len:=Length(root); //Fixed: was checking length of wordsNear.
  if (len>=NumStartChars) and ((not onlyOneWord) or (minWordLength>len)) then
  begin
    FEditor.AutoCShow(len,PChar(wordsNear));
  end else FEditor.AutoCCancel;
  result :=true;
end;

procedure TSciAutoComplete.EvtAutoCSelection(Sender : TObject;text : PChar);
begin
  if assigned(FOnAutoCSelection) then
    FOnAutoCSelection(Sender,text);
end;

procedure TSciAutoComplete.EvtCharAdded (Sender : TObject; const ch : LongInt);
var
  crange : TCharacterRange;
  selStart,selEnd,style : LongInt;
begin
  if (FAutoCompleteDisabled=True) or (not assigned(FEditor)) then Exit;

  crange:=FEditor.GetSelectionRng();
  selStart:=crange.cpMin;
  selEnd:=crange.cpMax;
  if (selEnd=selStart) and (selStart>0) then
  begin
    style:=FEditor.GetStyleAt(selStart-1);
    if style<>1 then
    begin
      if FEditor.CallTipActive then
      begin
        Exit; // We're in a calltip.. don't disturb..
      end else
      if FEditor.AutoCActive then
      begin
        if (CharPos(FEditor.WordChars,AnsiChar(ch),1)=0) then
        begin
          FEditor.AutoCCancel;
          if (CharPos(StartChars,AnsiChar(ch),1)<>0) or ((FromDocument=False)) then
          begin
            StartAutoComplete;
          end;
        end else
        if (autoCCausedByOnlyOne) then
          StartAutoCompleteWord(FromDocumentOnlyOne);
      end else
      begin
        autoCCausedByOnlyOne := false;
        if (CharPos(StartChars,AnsiChar(ch),1)<>0) or ((FromDocument=False) and (CharPos(FEditor.WordChars,AnsiChar(ch),1)<>0)) then
        begin
          StartAutoComplete;
        end else
        if (FromDocument=true) and ((CharPos(FEditor.WordChars,AnsiChar(ch),1)<>0)) then
        begin
          StartAutoCompleteWord(FromDocumentOnlyOne);
          autoCCausedByOnlyOne := FEditor.AutoCActive;
        end else
        if (FromDocument=False) and ((CharPos(FEditor.WordChars,AnsiChar(ch),1)<>0)) then
        begin
          StartAutoComplete;
        end;
      end;
    end;
  end;
end;
end.
Added src/delphisci/SciBall.ico.

cannot compute difference between binary files

Added src/delphisci/SciCallTips.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
  Created: 18/11/2004, 19:51:14
  History: 18/11/2004 Initial Release
           12/04/2005 Added the OnBeforeShow event
  
      $Id: SciCallTips.pas,v 1.1 2004/11/18 19:51:14 hdalis Exp $

     TODO: Find a solution to the setting of the properties of a linked component
           without reassigning the properties in the Loaded procedure.

}
{$Include SciCommonDef.Inc}
unit SciCallTips;
interface
uses Classes, SysUtils,SciLexerMemo,Graphics,SciControllerHandler;
type
  TSciBeforeCallTipShowEvent = procedure(Sender : TObject; const Position : LongInt;ListToDisplay : TStrings;var CancelDisplay : Boolean) of object;

TSciCallTips = class(TComponent)
  private
    fCharAddedProc : TCharAddedProc;
    fCallTipClickProc : TCallTipClickProc;
    braceCount,FStartCalltipWord,FCurrentCallTip,FMaxCallTips,FLastPosCallTip : LongInt;
    FApiStrings : TStrings;
    FCurrentCallTipWord,FFunctionDefinition,FWordCharacters, FParametersStart, FParametersEnd,FParametersSeparators,FEndDefinition : String;
    FForeColor,FBackColor,FHltColor : TColor;
    FDisabled,FIgnoreCase : Boolean;
    FEditor : TScintillaMemo;
    FOnBeforeShow : TSciBeforeCallTipShowEvent;
    FUseStyle : Boolean;
    FTabSize : Integer;
    procedure SetApiStrings(Value : TStrings);
    procedure SetHltColor(Value : TColor);
    procedure SetForeColor(Value : TColor);
    procedure SetBackColor(Value : TColor);
    procedure FillFunctionDefinition(xpos : LongInt=-1);
    procedure ContinueCallTip;
    procedure CallMatching(const startwith : String;var deststr : String;fromlist : TStrings;const ignorecase : Boolean;const stopat:Char=#0;const wordindex:LongInt=-1;matchlen:LongInt=-1);
    procedure SetScintilla(Value : TScintillaMemo);
    procedure DetachScintilla;
    procedure SetTabSize(const Value : Integer);
    procedure SetUseStyle(const Value : Boolean);
  protected
    procedure Loaded; override;
    procedure EvtCharAdded (Sender : TObject; const ch : LongInt);virtual;
    procedure EvtCallTipClick(Sender : TObject; const position : LongInt);virtual;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  public
    constructor Create(AOwner : TComponent);override;
    destructor  Destroy; override;
    procedure StartCallTip;
  published
    property Disabled : Boolean read FDisabled write FDisabled default False;
    property ApiStrings : TStrings read FApiStrings write SetApiStrings;
    property ForeColor : TColor read FForeColor write SetForeColor default clDefault;
    property BackColor : TColor read FBackColor write SetBackColor default clDefault;
    property HighlightColor : TColor read FHltColor write SetHltColor default clDefault;
    property EndDefinition : String read FEndDefinition write FEndDefinition;
    property Editor : TScintillaMemo read FEditor write SetScintilla;
    property ParametersEnd : String read FParametersEnd write FParametersEnd;
    property ParametersSeparators : String read FParametersSeparators write FParametersSeparators;
    property ParametersStart : String read FParametersStart write FParametersStart;
    property WordCharacters : String read FWordCharacters write FWordCharacters;
    property IgnoreCase : Boolean read FIgnoreCase write FIgnoreCase default False;
    property TabSize : Integer read FTabSize write SetTabSize;
    property UseStyle : Boolean read FUseStyle write SetUseStyle;
    property OnBeforeShow : TSciBeforeCallTipShowEvent read FOnBeforeShow write FOnBeforeShow;
end;

implementation

uses SciSupport,SciLexer,sciUtils,Windows;

// TSciCallTips
constructor TSciCallTips.Create(AOwner : TComponent);
begin
  FEditor:=nil;
  inherited Create(AOwner);
  braceCount:=0;
  FParametersStart:='(';
  FParametersEnd:=')';
  FParametersSeparators:=',';
  FEndDefinition:=')';
  FWordCharacters:='';
  FDisabled:=False;
  FForeColor:=clDefault;
  FBackColor:=clDefault;
  FHltColor:=clDefault;
  FUseStyle:=False;
  FTabSize:=0;
  FIgnoreCase:=False;
  FApiStrings :=TMyStringList.Create;
  TMyStringList(FApiStrings).Sorted:=True;
  TMyStringList(FApiStrings).Duplicates:=dupIgnore;
  FCharAddedProc:=TCharAddedProc.Create(EvtCharAdded);
  FCallTipClickProc:=TCallTipClickProc.Create(EvtCallTipClick);
end;

destructor TSciCallTips.Destroy;
begin
  DetachScintilla;
  if assigned(FApiStrings) then FreeAndNil(FApiStrings);
  if assigned(fCharAddedProc) then FreeAndNil(fCharAddedProc);
  if assigned(fCallTipClickProc) then FreeAndNil(fCallTipClickProc);
  Inherited Destroy;
end;

procedure TSciCallTips.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent,Operation);
  if Operation=opRemove then
  begin
    if AComponent=FEditor then
    begin
      DetachScintilla;
    end;
  end;
end;

procedure TSciCallTips.Loaded;
begin
  Inherited Loaded;
  if assigned(FEditor) then
  begin
  {Update the connected Scintilla control with the settings here, as we don't have any Editor attached before now}
    ForeColor:=FForeColor;
    BackColor:=FBackColor;
    HighlightColor:=FHltColor;
  end;
end;

procedure TSciCallTips.DetachScintilla;
begin
  if FEditor<>nil then
  begin
    FEditor.RemoveHandler(fCharAddedProc);
    FEditor.RemoveHandler(fCallTipClickProc);
  end;
  FEditor:=nil;
end;

procedure TSciCallTips.SetScintilla(Value : TScintillaMemo);
begin
  if assigned(Value) then
  begin
    DetachScintilla;
    FEditor:=Value;
    FEditor.AddHandler(fCharAddedProc);
    FEditor.AddHandler(fCallTipClickProc);
    if FWordCharacters='' then
      FWordCharacters:=FEditor.WordChars;
  end else
  begin
    DetachScintilla;
  end;
end;

procedure TSciCallTips.SetTabSize(const Value : Integer);
begin
  FTabSize:=Value;
  if FUseStyle then
    FEditor.CallTipUseStyle(FTabSize);
end;

procedure TSciCallTips.SetUseStyle(const Value : Boolean);
begin
  FUseStyle:=Value;
  if FUseStyle then
    FEditor.CallTipUseStyle(FTabSize);
end;

procedure TSciCallTips.EvtCharAdded (Sender : TObject; const ch : LongInt);
var
  crange : TCharacterRange;
  selStart,selEnd,style : LongInt;
begin
  if not assigned(FEditor) then Exit;
  crange:=FEditor.GetSelectionRng();
  selStart:=crange.cpMin;
  selEnd:=crange.cpMax;
  if (selEnd=selStart) and (selStart>0) then
  begin
    style:=FEditor.GetStyleAt(selStart-1);
    if style<>1 then
    begin
      if FEditor.CallTipActive then
      begin
        if CharPos(FParametersEnd,AnsiChar(ch),1)<>0 then
        begin
          Dec(braceCount);
          if braceCount<1 then
            FEditor.CallTipCancel
          else
          begin
            StartCallTip;
          end;
        end else
        if CharPos(FParametersStart,AnsiChar(ch),1)<>0 then
        begin
          Inc(braceCount);
          StartCallTip;
        end else
        begin
          ContinueCallTip;
        end;
      end else
      if FEditor.AutoCActive then //We're in a autocompletesession, disturb if neccesary.
      begin
        if (CharPos(FParametersStart,AnsiChar(ch),1)<>0) then
        begin
          Inc(braceCount);
          StartCallTip;
        end else
        if (CharPos(FParametersEnd,AnsiChar(ch),1)<>0) then
        begin
          Dec(braceCount);
        end;
      end else
      begin
        if (CharPos(FParametersStart,AnsiChar(ch),1)<>0) then
        begin
          braceCount:=1;
          StartCallTip;
        end;
      end;
    end;
  end;
end;

procedure TSciCallTips.SetHltColor(Value : TColor);
begin
  FHltColor:=Value;
  if (Value<>clDefault) and assigned(FEditor) then
  begin
    FEditor.CallTipSetForeHlt(Value);
  end;
end;

procedure TSciCallTips.SetForeColor(Value : TColor);
begin
  FForeColor:=Value;
  if (Value<>clDefault) and assigned(FEditor) then
  begin
    FEditor.CallTipSetFore(Value);
  end;
end;

procedure TSciCallTips.SetBackColor(Value : TColor);
begin
  FBackColor:=Value;
  if (Value<>clDefault) and assigned(FEditor) then
  begin
    if FEditor=nil then Exit;
    FEditor.CallTipSetBack(Value);
  end;
end;

procedure TSciCallTips.SetApiStrings(Value : TStrings);
begin
  FApiStrings.Assign(Value);
end;

procedure TSciCallTips.CallMatching(const startwith : String;var deststr : String;fromlist : TStrings;const ignorecase : Boolean;const stopat:Char=#0;const wordindex:LongInt=-1;matchlen:LongInt=-1);
var
  cnt,i,numadded,stopatwhere,amatch : LongInt;
  tmp : String;
begin
  deststr:='';
  numadded:=0;
  cnt:=fromlist.Count;
  if matchlen=-1 then
    matchlen:=Length(startwith);
  for i:=0 to (cnt-1) do
  begin
    tmp:=fromlist.Strings[i];
    if stopat<>#0 then
    begin
      stopatwhere:=Pos(stopat,tmp);
      if stopatwhere>0 then tmp:=Copy(tmp,1,stopatwhere-1);
    end;
    //amatch:=-1;
    if stopat<>#0 then
    begin
      if ignorecase=True then
        amatch:=AnsiStrIComp(PChar(tmp),PChar(startwith))
      else
        amatch:=AnsiStrComp(PChar(tmp),PChar(startwith));
    end else
    begin
      if ignorecase=True then
        amatch:=AnsiStrLIComp(PChar(tmp),PChar(startwith),matchlen)
      else
        amatch:=AnsiStrLComp(PChar(tmp),PChar(startwith),matchlen);
    end;
      if amatch=0 then
      begin
        if (wordindex>=0) and (numadded=(wordindex)) then
        begin
          deststr:=tmp;
          Exit;
        end;
        if numadded>0 then deststr:=deststr+' ';
        deststr:=deststr+tmp;
        numadded:=numadded+1;
      end;
  end;
end;

procedure TSciCallTips.FillFunctionDefinition(xpos : LongInt);
var
  Words : String;
  spacepos : LongInt;
  posEndDef : LongInt;
  calltipenddeflen : LongInt;
  funclen : LongInt;
begin
  if xpos>0 then FLastPosCallTip:=xpos;
  CallMatching(FCurrentCallTipWord,Words,FApiStrings,FIgnoreCase,FParametersStart[1],-1,Length(FCurrentCallTipWord));
  if Words<>'' then
  begin
    FMaxCallTips:=1;
    spacepos:=1;
    repeat
      spacepos:=CharPos(Words,' ',spacepos);
      if spacepos<>0 then
      begin
        Inc(FMaxCallTips);
        Inc(spacepos);
      end;
    until spacepos=0;
    CallMatching(FCurrentCallTipWord,Words,FApiStrings,FIgnoreCase,#0,FCurrentCallTip,Length(FCurrentCallTipWord));
    if Words<>'' then
    begin
      FFunctionDefinition:=Words;
      if FMaxCallTips>1 then
        Insert(#1,FFunctionDefinition,0);
      if FEndDefinition<>'' then
      begin
        calltipenddeflen:=Length(FEndDefinition);
        posEndDef:=Pos(FEndDefinition,FFunctionDefinition);
        funclen:=Length(FFunctionDefinition);
        if FMaxCallTips>1 then
        begin
          if (posEndDef>0) and ((posEndDef+calltipenddeflen+1)< Length(FFunctionDefinition)) then
          begin
            Insert(#10#02,FFunctionDefinition,posEndDef+calltipenddeflen);
          end else
          begin
            FFunctionDefinition:=FFunctionDefinition+#10#02;
          end;
        end else
        begin
          if (posEndDef>1) and ((posEndDef+calltipenddeflen+1)< funclen) then
          begin
            Insert(#10,FFunctionDefinition,posEndDef+calltipenddeflen);
          end;
        end;
      end else
      //added in 0.23
      if FMaxCallTips>1 then
      begin
        Insert(#02,FFunctionDefinition,1);
      end;
      FEditor.CallTipShow(FLastPosCallTip-Length(FCurrentCallTipWord),PChar(FFunctionDefinition));
      ContinueCallTip;
    end;
  end;
end;

procedure TSciCallTips.StartCallTip;
var
  line : String;
  current,xpos,braces : LongInt;
  cancelit : Boolean;
begin
  if not assigned(FEditor) then Exit;
  with FEditor do
  begin
  if (FDisabled=True) then Exit;
    FCurrentCallTip:=0;
    FCurrentCalltipWord:='';
    line:=GetLineS;
    current:=GetCaretInLine;
    xpos:=GetCurrentPos;
    if assigned(FOnBeforeShow) then
    begin
      cancelit:=False;
      FOnBeforeShow(Self,xpos,FApiStrings,cancelit);
      if cancelit then Exit;
    end;

    repeat
      braces:=0;
      while ((current > 0) and ((braces<>0) or (CharPos(FParametersStart,AnsiChar(line[current]),1)=0))) do
      begin
        if (CharPos(FParametersStart,AnsiChar(line[current]),1)<>0) then
          Dec(braces)
        else if (CharPos(FParametersEnd,AnsiChar(line[current]),1)<>0) then
          Inc(braces);
        Dec(current);
        Dec(xpos);
      end;
      if current>0 then
      begin
        Dec(current);
        Dec(xpos);
      end else
        break;
      while (current>0) and (IsSpace(Integer(line[current]))) do
      begin
        Dec(current);
        Dec(xpos);
      end;
    until ((current <= 0) or (CharPos(FWordCharacters,AnsiChar(line[current]),1)<>0));
    if current<=0 then Exit;
    FStartCalltipWord:=current;
    while((FStartCalltipWord>0) and (CharPos(FWordCharacters,AnsiChar(line[FStartCalltipWord-1]),1)<>0)) do
    begin
      Dec(FStartCalltipWord);
    end;
    FCurrentCallTipWord:=System.Copy(line,FStartCalltipWord,(current-FStartCalltipWord)+1);
    FFunctionDefinition:='';
    FillFunctionDefinition(xpos);
  end;
end;

procedure TSciCallTips.ContinueCallTip;
var
  line : String;
  current,braces,commas,i : LongInt;
  startHighlight,endHighlight : LongInt;
  funclen : Integer;
begin
  if (FDisabled=True) or (not assigned(FEditor)) then Exit;
  with FEditor do
  begin
    startHighlight:=0;
    commas:=0;
    braces:=0;
    funclen:=Length(FFunctionDefinition);
    FFunctionDefinition:=FFunctionDefinition+' ';
    line:=GetLineS;
    current:=GetCaretInLine;
    for i:=FStartCalltipWord to (current) do
    begin
      if (CharPos(FParametersStart,AnsiChar(line[i]),1)<>0) then
        Inc(braces)
      else if (CharPos(FParametersEnd,AnsiChar(line[i]),1)<>0) and (braces>0) then
        Dec(braces)
      else if (braces=1) and (CharPos(FParametersSeparators,AnsiChar(line[i]),1)<>0) then
        Inc(commas);
    end;
    while (startHighlight<funclen) and
          (CharPos(FParametersStart,AnsiChar(FFunctionDefinition[startHighlight]),1)=0) do
    begin
      Inc(startHighlight);
    end;
    if (CharPos(FParametersStart,AnsiChar(FFunctionDefinition[startHighlight]),1)<>0) then
    begin
      Inc(startHighlight);
    end;
    while ((startHighlight<funclen) and (commas > 0)) do
    begin
      if (CharPos(FParametersSeparators,AnsiChar(FFunctionDefinition[startHighlight]),1)<>0) then
        Dec(commas);
      if (CharPos(FParametersEnd,AnsiChar(FFunctionDefinition[startHighlight]),1)<>0) then
        commas:=0
      else
        Inc(startHighlight);
    end;
    if (CharPos(FParametersSeparators,AnsiChar(FFunctionDefinition[startHighlight]),1)<>0) then
      Inc(startHighlight);
    endHighlight:=startHighlight;
    while (endHighlight<funclen) and (CharPos(FParametersSeparators,AnsiChar(FFunctionDefinition[endHighlight]),1)=0) and (CharPos(FParametersEnd,AnsiChar(FFunctionDefinition[endHighlight]),1)=0) do
    begin
      Inc(endHighlight);
    end;
    // Adjust the start and end so we do not highlight end or separators.
    if (CharPos(FParametersEnd,AnsiChar(FFunctionDefinition[endHighlight]),1)<>0) or (CharPos(FParametersSeparators,AnsiChar(FFunctionDefinition[endHighlight]),1)<>0) then Dec(endHighlight);
    if (CharPos(FWordCharacters,AnsiChar(FFunctionDefinition[startHighlight]),1)<>0) then Dec(startHighlight);
    CallTipSetHlt(startHighlight,endHighlight);
  end;
end;

procedure TSciCallTips.EvtCallTipClick(Sender : TObject; const position : LongInt);
begin
    case position of
    1:begin
        if (FCurrentCallTip>0) then
        begin
          Dec(FCurrentCallTip);
          FillFunctionDefinition;
        end;
      end;
    //Calltip event was fixed in 1.65, so the down arrow sets position to 2..
    //Also allow 0 for compatibility with previous SciLexer.dlls
    0,2:begin
        if ((FCurrentCallTip+1)<FMaxCalltips)  then
        begin
          Inc(FCurrentCallTip);
          FillFunctionDefinition;
        end;
      end;
    end;
end;


end.
Added src/delphisci/SciCommonDef.Inc.
























































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}

{Notice: This is here because of some intention to eventually get these
controls to support more than Borland C++ Builder 6,Delphi 7, and
Delphi 2005 (Win32 Mode), and BDS2006 (Win32 Mode, somewhat).

Drop me a hint of how (if you you had to) modify the code to get it to
work.

I'm also interested in the package source files you've created for that
version, or other contributions of code.
}
  {$IFDEF VER180}
    {$DEFINE COMPILER10}
    {$DEFINE DELPHI10}
    {$DEFINE DELPHICOMPILER10}
    {$Define HASUTFFUNCS}
  {$ENDIF}

  {$IFDEF VER170}
    {$DEFINE COMPILER9}
    {$DEFINE DELPHI9}
    {$DEFINE DELPHICOMPILER9}
    {$Define HASUTFFUNCS}
  {$ENDIF}

  {$IFDEF VER160}
    {$DEFINE COMPILER8}
    {$DEFINE DELPHI8}
    {$DEFINE DELPHICOMPILER8}
    {$Define HASUTFFUNCS}
  {$ENDIF}

  {$IFDEF VER150}
    {$DEFINE COMPILER7}
    {$IFDEF BCB}
      {$DEFINE BCB7}
    {$ELSE}
      {$DEFINE DELPHI7}
      {$DEFINE DELPHICOMPILER7}
    {$ENDIF}
    {$Define HASUTFFUNCS}
  {$ENDIF}

  {$IFDEF VER140}
    {$DEFINE COMPILER6}
    {$IFDEF BCB}
      {$DEFINE BCB6}
      {$Define HASUTFFUNCS}
    {$ELSE}
      {$DEFINE DELPHI6}
      {$DEFINE DELPHICOMPILER6}
    {$ENDIF}
  {$ENDIF}

  {$IFDEF VER130}
    {$DEFINE COMPILER5}
    {$IFDEF BCB}
      {$DEFINE BCB5}
    {$ELSE}
      {$DEFINE DELPHI5}
      {$DEFINE DELPHICOMPILER5}
    {$ENDIF}
  {$ENDIF}

  {$IFDEF BCB}
    {$DEFINE CPPBUILDER}
    {$DEFINE BCBCOMPILER}
  {$ELSE ~BCB}
    {$DEFINE DELPHI}
    {$DEFINE DELPHICOMPILER}
  {$ENDIF ~BCB}

{$Ifdef COMPILER5}
  {$Define COMPILER5_UP}
{$Endif}

{$Ifdef COMPILER6}
  {$Define COMPILER5_UP}
  {$Define COMPILER6_UP}
{$Endif}

{$Ifdef COMPILER7}
  {$Define COMPILER5_UP}
  {$Define COMPILER6_UP}
  {$Define COMPILER7_UP}
{$Endif}
{$Ifdef COMPILER8}
  {$Define COMPILER5_UP}
  {$Define COMPILER6_UP}
  {$Define COMPILER7_UP}
  {$Define COMPILER8_UP}
{$Endif}
{$Ifdef COMPILER9}
  {$Define COMPILER5_UP}
  {$Define COMPILER6_UP}
  {$Define COMPILER7_UP}
  {$Define COMPILER8_UP}
  {$Define COMPILER9_UP}
{$Endif}
{$Ifdef COMPILER10}
  {$Define COMPILER5_UP}
  {$Define COMPILER6_UP}
  {$Define COMPILER7_UP}
  {$Define COMPILER8_UP}
  {$Define COMPILER9_UP}
  {$Define COMPILER10_UP}
{$Endif}

{$Define BADFILEEXISTS}
{.$Define USENEWLOADLEXER}
{
  If you want the more specialized LoadLexerLibrary in TScintilla then remove the dot above.
}
//Newabbrews is not done yet, and isn't tested.
{.$Define NEWABBREVS}

{$Define ALLOWSEARCHPOPUPMENUS}
{If USEDEFAULTSTREAMBYDEFAULT is defined then TSciStreamDefault is used as the default StreamClass without needed any assignment.
}
{.$Define USEDEFAULTSTREAMBYDEFAULT}
Added src/delphisci/SciConfirmReplaceDlg.ddp.

cannot compute difference between binary files

Added src/delphisci/SciConfirmReplaceDlg.dfm.




































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
object ConfirmReplaceDialog: TConfirmReplaceDialog
  Left = 619
  Top = 163
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  Caption = 'Confirm the replace'
  ClientHeight = 98
  ClientWidth = 328
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBtnText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poOwnerFormCenter
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object BasePanel: TPanel
    Left = 0
    Top = 0
    Width = 328
    Height = 98
    Align = alClient
    BevelOuter = bvNone
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clBtnText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = []
    ParentFont = False
    TabOrder = 0
    object lblConfirmation: TLabel
      Left = 60
      Top = 12
      Width = 261
      Height = 44
      AutoSize = False
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
      WordWrap = True
    end
    object Image1: TImage
      Left = 16
      Top = 16
      Width = 32
      Height = 32
    end
    object btnReplace: TBitBtn
      Left = 8
      Top = 67
      Width = 75
      Height = 23
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
      TabOrder = 0
      Kind = bkYes
    end
    object btnSkip: TBitBtn
      Left = 87
      Top = 67
      Width = 75
      Height = 23
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
      TabOrder = 1
      Kind = bkNo
    end
    object btnCancel: TBitBtn
      Left = 166
      Top = 67
      Width = 75
      Height = 23
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
      TabOrder = 2
      Kind = bkCancel
    end
    object btnReplaceAll: TBitBtn
      Left = 245
      Top = 67
      Width = 75
      Height = 23
      Caption = '&All'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ModalResult = 10
      ParentFont = False
      TabOrder = 3
      Glyph.Data = {
        F2010000424DF201000000000000760000002800000024000000130000000100
        0400000000007C01000000000000000000001000000000000000000000000000
        80000080000000808000800000008000800080800000C0C0C000808080000000
        FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333334433333
        3333333333388F3333333333000033334224333333333333338338F333333333
        0000333422224333333333333833338F33333333000033422222243333333333
        83333338F3333333000034222A22224333333338F33F33338F33333300003222
        A2A2224333333338F383F3338F33333300003A2A222A222433333338F8333F33
        38F33333000034A22222A22243333338833333F3338F333300004222A2222A22
        2433338F338F333F3338F3330000222A3A2224A22243338F3838F338F3338F33
        0000A2A333A2224A2224338F83338F338F3338F300003A33333A2224A2224338
        333338F338F3338F000033333333A2224A2243333333338F338F338F00003333
        33333A2224A2233333333338F338F83300003333333333A2224A333333333333
        8F338F33000033333333333A222433333333333338F338F30000333333333333
        A224333333333333338F38F300003333333333333A223333333333333338F8F3
        000033333333333333A3333333333333333383330000}
      NumGlyphs = 2
    end
  end
end
Added src/delphisci/SciConfirmReplaceDlg.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
{-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is: dlgConfirmReplaceText.pas, released 2000-06-23.

The Original Code is part of the SearchReplaceDemo project, written by
Michael Hieke for the SynEdit component suite.
All Rights Reserved.

Contributors to the SynEdit project are listed in the Contributors.txt file.

Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.

$Id: SciConfirmReplaceDlg.pas,v 1.4 2004/11/13 04:29:50 hdalis Exp $

You may retrieve the latest version of this file at the SynEdit home page,
located at http://SynEdit.SourceForge.net

Known Issues:
-------------------------------------------------------------------------------}
{
  History:   29/09/2004 Initial Release with Delphi Scintilla Interface Components
                        Removed Dialogs from the uses list.
             24/11/2004 Corrected a little bug. When All was selected, it didn't return
                        the mrYesToAll that was expected.. Now it does..
}
{$Include SciCommonDef.Inc}
unit SciConfirmReplaceDlg;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  StdCtrls, ExtCtrls, Buttons;

type
  TConfirmReplaceDialog = class(TForm)
    BasePanel: TPanel;
    lblConfirmation: TLabel;
    Image1: TImage;
    btnReplace: TBitBtn;
    btnSkip: TBitBtn;
    btnCancel: TBitBtn;
    btnReplaceAll: TBitBtn;
    procedure FormCreate(Sender: TObject);
  public
    procedure PrepareShow(editorRect: TRect; X, Y1, Y2: Integer;AReplaceText: string);
  end;

implementation

{$R *.DFM}
uses SciResLang;

{ TConfirmReplaceDialog }

procedure TConfirmReplaceDialog.FormCreate(Sender: TObject);
begin
  Image1.Picture.Icon.Handle := LoadIcon(0, IDI_QUESTION);
end;

procedure TConfirmReplaceDialog.PrepareShow(editorRect: TRect;
  X, Y1, Y2: Integer; AReplaceText: string);
var
  nW, nH: Integer;
begin
  lblConfirmation.Caption := Format(SAskReplaceText, [AReplaceText]);
  nW := editorRect.Right - editorRect.Left;
  nH := editorRect.Bottom - editorRect.Top;

  if nW <= Width then
    X := editorRect.Left - (Width - nW) div 2
  else begin
    if X + Width > editorRect.Right then
      X := editorRect.Right - Width;
  end;
  if Y2 > editorRect.Top + MulDiv(nH, 2, 3) then
    Y2 := Y1 - Height - 4
  else
    Inc(Y2, 4);
  SetBounds(X, Y2, Width, Height);
end;

end.




Added src/delphisci/SciControllerHandler.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
      $Id: SciControllerHandler.pas,v 1.5 2004/11/18 04:29:51 hdalis Exp $
  Purpose: This manages, and forwards OnCharAdded, OnMacroRecord, OnCallTipClick,
           OnAutoCSelection to any registered eventhandlers..
           Internally used.

  History: 18/11/2004 Initial Release
           15/04/2005 Changed the connection to the ownerclass to wait until the
                      class calls TSciController.Connect, cause it didn't get the
                      initialized events of the owner when the owner created TSciController
                      in the Create constructor.
           03/06/2005 Removed all the Add*Handler and Remove*Handler, and replaced them
                      with AddHandler and RemoveHandler, which itself detects what kind
                      of handler you are trying to add or remove.
                      MUST be a valid handler (those classes ending with Proc below).
}
{$Include SciCommonDef.Inc}
unit SciControllerHandler;
interface
uses Classes,SciLexer;

Type

TControllerControl = class (TScintillaBase)
public
  property OnCharAdded;
  property OnCallTipClick;
  property OnMacroRecord;
  property OnAutoCSelection;
end;

TCharAddedProc = class(TObject)
private
  fCharAddedProc : TSCEvent_charadded;
public
  constructor Create (aCharAddedProc : TSCEvent_charadded);
  property OnCharAdded : TSCEvent_charadded read fCharAddedProc write fCharAddedProc;
end;

TMacroRecordProc = class(TObject)
private
  fMacroRecordProc : TSCEvent_macrorecord;
public
  constructor Create (aMacroRecordProc : TSCEvent_macrorecord);
  property OnMacroRecord : TSCEvent_macrorecord read fMacroRecordProc write fMacroRecordProc;
end;

TCallTipClickProc = class(TObject)
private
  fCallTipClickProc : TSCEvent_calltipclick;
public
  constructor Create (aCallTipClickProc : TSCEvent_calltipclick);
  property OnCallTipClick : TSCEvent_calltipclick read fCallTipClickProc write fCallTipClickProc;
end;

TAutoCSelectionProc = class(TObject)
private
  fAutoCSelectionProc : TSCEvent_autocselection;
public
  constructor Create (aAutoCSelectionProc : TSCEvent_autocselection);
  property OnAutoCSelection : TSCEvent_autocselection read fAutoCSelectionProc write fAutoCSelectionProc;
end;

TSciController = class (TObject)
  private
    fControl : TControllerControl;
    fInCharAdded,FConnected : Boolean;
    fOldCharAdded : TSCEvent_charadded;
    fOldCallTipClick : TSCEvent_calltipclick;
    fOldMacroRecord : TSCEvent_macrorecord;
    fOldAutoCSelection : TSCEvent_autocselection;
    fCharAddedChain,
    fCallTipClickChain,
    fMacroRecordChain,
    fAutoCSelectionChain : TList;
    procedure SetOnCharAdded (const Value: TSCEvent_charadded);
    procedure SetOnCallTipClick (const Value: TSCEvent_calltipclick);
    procedure SetOnMacroRecord (const Value: TSCEvent_macrorecord);
    procedure SetOnAutoCSelection (const Value: TSCEvent_autocselection);
  protected
    {The replacement events}
    procedure EditorCharAdded (Sender : TObject; const ch : LongInt);
    procedure EditorCallTipClick (Sender : TObject; const position : LongInt);
    procedure EditorAutoCSelection (Sender : TObject; text : PChar);
    procedure EditorMacroRecord (Sender : TObject; const message : LongInt; const wParam : LongInt; const lParam : LongInt);
  public
    constructor Create (aControl : TScintillaBase);
    destructor Destroy; override;

    {Connect all eventhandlers}
    procedure Connect;
    {Disconnect all eventhandlers}
    procedure Disconnect;
    {Add a eventhandler}
    procedure AddHandler(aHandler : TObject);
    {Remove a eventhandler}
    procedure RemoveHandler(aHandler : TObject);

    procedure ExecuteCharAdded (Sender: TObject; const ch : LongInt);
    procedure ExecuteMacroRecord (Sender: TObject;const message : LongInt; const wParam : LongInt; const lParam : LongInt);
    procedure ExecuteCallTipClick (Sender: TObject; const position : LongInt);
    procedure ExecuteAutoCSelection (Sender: TObject; text : PChar);

    property  OnCharAdded : TSCEvent_charadded read fOldCharAdded write SetOnCharAdded;
    property  OnCallTipClick : TSCEvent_calltipclick read fOldCallTipClick write SetOnCallTipClick;
    property  OnMacroRecord : TSCEvent_macrorecord read fOldMacroRecord write SetOnMacroRecord;
    property  OnAutoCSelection : TSCEvent_autocselection read fOldAutoCSelection write SetOnAutoCSelection;
end;


implementation
{ TSciController }
uses SciLexerMemo,SysUtils;

constructor TSciController.Create (aControl : TScintillaBase);
begin
  inherited Create;
  FConnected:=False;
  fControl := TControllerControl (aControl);
  fInCharAdded := false;
  fCharAddedChain := TList.Create;
  fCallTipClickChain := TList.Create;
  fMacroRecordChain := TList.Create;
  fAutoCSelectionChain := TList.Create;
end;

destructor TSciController.Destroy;
begin
  Disconnect;
  if assigned(fCharAddedChain) then FreeAndNil(fCharAddedChain);
  if assigned(fCallTipClickChain) then FreeAndNil(fCallTipClickChain);
  if assigned(fMacroRecordChain) then FreeAndNil(fMacroRecordChain);
  if assigned(fAutoCSelectionChain) then FreeAndNil(fAutoCSelectionChain);
  inherited Destroy;
end;

procedure TSciController.AddHandler(aHandler : TObject);
begin
  if aHandler is TMacroRecordProc then //OnMacroRecord
    fMacroRecordChain.Add(TMacroRecordProc(aHandler))
  else
  if aHandler is TAutoCSelectionProc then //OnAutoCSelection
    fAutoCSelectionChain.Add(TAutoCSelectionProc(aHandler))
  else
  if aHandler is TCharAddedProc then //OnCharAdded
    fCharAddedChain.Add(TCharAddedProc(aHandler))
  else
  if aHandler is TCallTipClickProc then //OnCallTipClick
    fCallTipClickChain.Add(TCallTipClickProc(aHandler));
end;
procedure TSciController.RemoveHandler(aHandler : TObject);
begin
  if aHandler is TMacroRecordProc then //OnMacroRecord
    fMacroRecordChain.Remove(TMacroRecordProc(aHandler))
  else
  if aHandler is TAutoCSelectionProc then //OnAutoCSelection
    fAutoCSelectionChain.Remove(TAutoCSelectionProc(aHandler))
  else
  if aHandler is TCharAddedProc then //OnCharAdded
    fCharAddedChain.Remove(TCharAddedProc(aHandler))
  else
  if aHandler is TCallTipClickProc then //OnCallTipClick
    fCallTipClickChain.Remove(TCallTipClickProc(aHandler));
end;

procedure TSciController.Connect;
begin
  fOldCharAdded := nil;
  fOldCallTipClick := nil;
  fOldMacroRecord:=nil;
  fOldAutoCSelection:=nil;
  if FConnected=False then
  begin
    //Store the old events
    if assigned(fControl.OnCharAdded) then fOldCharAdded := fControl.OnCharAdded;
    if assigned(fControl.OnCallTipClick) then fOldCallTipClick := fControl.OnCallTipClick;
    if assigned(fControl.OnMacroRecord) then fOldMacroRecord := fControl.OnMacroRecord;
    if assigned(fControl.OnAutoCSelection) then fOldAutoCSelection := fControl.OnAutoCSelection;
    //Assign the new ones..
    fControl.OnCharAdded := EditorCharAdded;
    fControl.OnCallTipClick := EditorCallTipClick;
    fControl.OnMacroRecord := EditorMacroRecord;
    fControl.OnAutoCSelection := EditorAutoCSelection;
    FConnected:=True;
  end;
end;

procedure TSciController.Disconnect;
begin
  if assigned(fControl) then
  begin
    fControl.OnCharAdded := fOldCharAdded;
    fControl.OnCallTipClick := fOldCallTipClick;
    fControl.OnMacroRecord := fOldMacroRecord;
    fControl.OnAutoCSelection := fOldAutoCSelection;
  end;
  FConnected:=False;
end;

procedure TSciController.EditorMacroRecord (Sender : TObject; const message : LongInt; const wParam : LongInt; const lParam : LongInt);
var
  idx : Integer;
begin
  with fMacroRecordChain do
  begin
    for idx := Count - 1 downto 0 do
    begin
      with TMacroRecordProc(Items[idx]) do
        if Assigned (OnMacroRecord) then
        begin
          OnMacroRecord (Sender,message,wParam,lParam);
        end;
    end;
  end;
  if Assigned (fOldMacroRecord) then
    fOldMacroRecord (Sender,message,wParam,lParam);
end;

procedure TSciController.EditorAutoCSelection (Sender : TObject; text : PChar);
var
  idx : Integer;
begin
  if not (Sender is TScintillaMemo) then Exit;
  with fAutoCSelectionChain do
  begin
    for idx := Count - 1 downto 0 do
    begin
      with TAutoCSelectionProc (Items[idx]) do
        if Assigned (OnAutoCSelection) then
        begin
          OnAutoCSelection (Sender,text);
        end;
    end;
  end;
  if Assigned (fOldAutoCSelection) then
    fOldAutoCSelection (Sender,text);
end;

procedure TSciController.EditorCharAdded (Sender: TObject; const ch : LongInt);
var
  idx : Integer;
begin
  if fInCharAdded then Exit;
  fInCharAdded := true;
  try
    with fCharAddedChain do
    begin
      for idx := Count - 1 downto 0 do
      begin
        with TCharAddedProc (Items[idx]) do
          if Assigned (OnCharAdded) then
          begin
            OnCharAdded (Sender,ch);
            if (ch = 0) then
            begin
              fInCharAdded := false;
              exit;
            end;
          end;
      end;
    end;
    if Assigned (fOldCharAdded) then
      fOldCharAdded (Sender,ch);
  finally
    fInCharAdded := false;
  end;
end;

procedure TSciController.EditorCallTipClick (Sender: TObject; const position : LongInt);
var
  idx : Integer;
begin
  with fCallTipClickChain do
  begin
    for idx := Count - 1 downto 0 do
    begin
      with TCallTipClickProc (Items[idx]) do
        if Assigned (OnCallTipClick) then
        begin
          OnCallTipClick(Sender,position);
        end;
    end;
  end;
  if Assigned (fOldCallTipClick) then
    fOldCallTipClick(Sender,position);
end;

procedure TSciController.ExecuteAutoCSelection (Sender: TObject;text : PChar);
begin
  EditorAutoCSelection(Sender,text);
end;

procedure TSciController.ExecuteMacroRecord (Sender: TObject;const message : LongInt; const wParam : LongInt; const lParam : LongInt);
begin
  EditorMacroRecord(Sender,message,wParam,lParam);
end;

procedure TSciController.ExecuteCharAdded (Sender: TObject; const ch: Integer);
begin
  EditorCharAdded(Sender,ch);
end;

procedure TSciController.ExecuteCallTipClick (Sender: TObject; const position: Integer);
begin
  EditorCallTipClick(Sender,position);
end;

procedure TSciController.SetOnMacroRecord (const Value: TSCEvent_macrorecord);
begin
  fOldMacroRecord := Value;
  fControl.OnMacroRecord := EditorMacroRecord;
end;

procedure TSciController.SetOnCharAdded (const Value: TSCEvent_charadded);
begin
  fOldCharAdded := Value;
  fControl.OnCharAdded := EditorCharAdded;
end;

procedure TSciController.SetOnAutoCSelection (const Value: TSCEvent_autocselection);
begin
  fOldAutoCSelection := Value;
  fControl.OnAutoCSelection := EditorAutoCSelection;
end;

procedure TSciController.SetOnCallTipClick(const Value: TSCEvent_calltipclick);
begin
  fOldCallTipClick := Value;
  fControl.OnCallTipClick := EditorCallTipClick;
end;

constructor TCharAddedProc.Create (aCharAddedProc : TSCEvent_charadded);
begin
  inherited Create;
  fCharAddedProc := aCharAddedProc;
end;

constructor TCallTipClickProc.Create (aCallTipClickProc : TSCEvent_calltipclick);
begin
  inherited Create;
  fCallTipClickProc := aCallTipClickProc;
end;

constructor TMacroRecordProc.Create (aMacroRecordProc : TSCEvent_macrorecord);
begin
  inherited Create;
  fMacroRecordProc := aMacroRecordProc;
end;
constructor TAutoCSelectionProc.Create (aAutoCSelectionProc : TSCEvent_autocselection);
begin
  inherited Create;
  fAutoCSelectionProc := aAutoCSelectionProc;
end;

end.
Added src/delphisci/SciDetectUtils.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
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author  : hdalis (hdalis@users.sourceforge.net)
       $Id: SciDetectUtils.pas,v 1.5 2004/11/13 04:29:50 hdalis Exp $
  History : 29/09/2004 Initial Release
            13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                       generate the help.
                       The TExtensionMapper is moved to SciPropertyMgr.pas
            24/10/2004 Removed the TLexerNamesMap class, and the LexerMapper function
                       these are now part of the TSciLanguageManager class (functions AddLanguage,
                       DupLanguage,RemoveLanguage,FillListWithLanguages)

}
{.$WEAKPACKAGEUNIT ON}
{$Include SciCommonDef.Inc}
unit SciDetectUtils;
interface
function GetWordChars(const highlighter : String) : String;
implementation
uses SciLexer,SysUtils,Windows;

function GetWordChars(const highlighter : String) : String;
begin
  if highlighter='' then Result:=sci_alphachars+sci_numericchars+sci_accentedchars+'_'
  else if (AnsiCompareText('PERL',highlighter)=0) or (AnsiCompareText('BASH',highlighter)=0) then
    Result:=sci_alphachars+sci_numericchars+'_$@%&'
  else if (AnsiCompareText('PHP',highlighter)=0) then
    Result:=sci_alphachars+sci_numericchars+'_-$'
  else if (AnsiCompareText('CSS',highlighter)=0) or (AnsiCompareText('HTML',highlighter)=0) or (AnsiCompareText('HTML',highlighter)=0) then
    Result:=sci_alphachars+sci_numericchars+'_-'
  else if (AnsiCompareText('XML',highlighter)=0) or (AnsiCompareText('WML',highlighter)=0) then
    Result:=sci_alphachars+sci_numericchars+'_-'
  else if AnsiCompareText('LUA',highlighter)=0 then
    Result:=sci_alphachars+sci_numericchars+'_%'
  else if (AnsiCompareText('Ave',highlighter)=0) or (AnsiCompareText('C++/C',highlighter)=0) or
          (AnsiCompareText('Resource',highlighter)=0) or (AnsiCompareText('IDL',highlighter)=0) or
          (AnsiCompareText('Java',highlighter)=0) or (AnsiCompareText('JavaScript',highlighter)=0) or
          (AnsiCompareText('C#',highlighter)=0) or (AnsiCompareText('POV',highlighter)=0) or
          (AnsiCompareText('Specman',highlighter)=0) then
    Result:=sci_alphachars+sci_numericchars+'_#'
  else if AnsiCompareText('Baan',highlighter)=0 then
    Result:=sci_alphachars+sci_numericchars+'_#.$'
  else if AnsiCompareText('Forth',highlighter)=0 then
    Result:=sci_alphachars+sci_numericchars+'%-'
  else if (AnsiCompareText('Lisp',highlighter)=0) or (AnsiCompareText('Scheme',highlighter)=0) then
    Result:=sci_alphachars+sci_numericchars+'_-<>.#+@$%^&=*!?'
  else if AnsiCompareText('lot',highlighter)=0 then
    Result:=sci_alphachars+sci_numericchars
  else if AnsiCompareText('nnCronTab',highlighter)=0 then
    Result:=sci_alphachars+sci_numericchars+'%-'
  else if AnsiCompareText('Verilog',highlighter)=0 then
    Result:=sci_alphachars+sci_numericchars+'_`$#'
  else
    Result:='_'+sci_alphachars+sci_numericchars;
end;

end.
Added src/delphisci/SciDocuments.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
 Author : hdalis (hdalis@users.sourceforge.net)
 Created: 30/09/2004, 04:24:38
     $Id: SciDocuments.pas,v 1.4 2004/11/13 04:29:50 hdalis Exp $
 Purpose: Tabbed scintilla component.
 Usage: Drop the TScintilla derived control and a TSciDocumentTabControl
        on a form, select the TScintillaBase derived control in the Editor property of TSciDocumentTabControl
        and viola.. Tabbed scintilla control.

 History 30/09/2004 Initial Release
         13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                    generate the help.
         11/11/2004 Added per tab hinting. Displays the full pathname of the file when ShowHint is True.
         14/11/2004 At last the TSciDoc saves foldingstates.
         26/11/2004 Added the property DefaultExt for setting the default file extension..
                    Added calls to the OnDetectHighlighter when we're attached to
                    a TScintilla component, and we're attaching ourself.
         05/01/2005 Changed some of the calling to FOnDetectHighlighter, tried to minimize number of calls.
                    Added the OnOpenedAndInited event, this is fired only when Open is called, and is called just
                    before the function exits when successful.. May be the ideal place to add updatingcode which
                    is dependent on the current highlighter, as it's not completely loaded until just at this time.
         24/01/2005 Fixed the Close function so that when the last document is closed, the OnChange is called correctly and,
                    in Remove the Modified is sat to False when we're closing the last document..
         26/01/2005 Found a somewhat serious bug. When the character '\' is the last in the file,
                    and there's no following line, then an exception was thrown 'cause a while statement
                    did the walkin one too many times. Fixed.
         01/02/2005 Somewhat fixed a little problem with the documents not storing properties/folding when changing
                    the page programmaticly via the Activate functions..
                    The TSciDoc class has been extended with a pair of new functions.
         05/02/2005 Quite messy code in this component really, but it does work however.. Some restructuring
                    sorely needed.. TODO: Restructure this component, and use TCollection,TCollectionItems
                    for storing the document settings..
         22/02/2005 A bug in TSciDoc.SetTabWidth caused the that the TabWidth wasn't set correctly.
                    It set the value stored in fIndentWidth instead.
         09/03/2005 Changed the way Remove removes the document. It seems more stable now..
         07/09/2005 Added the event OnTabHint, it is fired when the cursor is above any of the tabs.
                    The HintText is prefilled with the current highlighter for the document if it is a TScintilla
                    editor.
         18/05/2006 Fixed some memoryleaks.

}
{$Include SciCommonDef.Inc}
unit SciDocuments;
interface
Uses
  Windows, Classes, Controls,Contnrs,ComCtrls,Messages,SciLexer,SciLexerMemo;

type
  TSciDoc=class;
  TSCEvent_onclosing = procedure(Sender : TObject; const TabIndex : Integer;var AllowClose : Boolean) of object;
  TSCEvent_detecthighlighter = procedure(Sender : TObject; const Extension : String;var Language : String) of object;
  TSCEvent_removeextradata = procedure(Sender : TObject) of object;
  TSCEvent_openedandinited = procedure(Sender : TObject; const TabIndex : Integer;doc : TSciDoc) of object;
  TSCEvent_onhint = procedure(Sender : TObject; const TabIndex : Integer;var HintText : String;doc : TSciDoc) of object;
  TSciFoldStateRec=record
    Line : Integer;
    Expanded : Boolean;
  end;
  TSciDocumentTabControl=class;
  TSciDoc = class(TObject)
  private
    fEditor : TScintillaBase;
    fTabCtrl : TCustomTabControl;
    FTabName,
    fHighlighter,
    FFileName,
    FWordChars,
    FAutoStartChars,
    FAutoStopChars : string;
    documentid,
    FSelStart,
    FSelLength,
    FFirstLineInView,
    FCodePage : LongInt;
    FIndex,FTabWidth,FIndentWidth : Integer;
    FReadOnly,
    FModified,
    FAutoIgnoreCase,
    FUseTabs : Boolean;
    FIndentation : TIndentationOptions;
    FFoldStates : array of TSciFoldStateRec;
    FOnChanged : TNotifyEvent;
    FExtraData : Pointer;
    FStreamClass : TSciStreamClass;
    FStreamExtra : Integer;
    FStreamExtraStr : String;
    FLastChanged : Integer;
    FOnRemoveExtraData : TSCEvent_removeextradata;
    procedure SetTabName(const Value : string);
    procedure SetHighlighter(const Value : String);
    procedure SetFileName(const Value : string);
    procedure Changed;
    procedure AddRef;
    procedure Release;
    procedure SetWordChars(const Value : String);
    procedure AssignFromEditor;
    procedure AssignToEditor;
    procedure StoreFoldStates;
    procedure RestoreFoldStates;
    procedure SetIndentWidth(const Value : Integer);
    procedure SetTabWidth(const Value : Integer);
    procedure SetIndentation(const Value : TIndentationOptions);
    procedure SetModified(const Value : Boolean);
    procedure SetUseTabs(const Value : Boolean);
    procedure SetCodePage(const Value : LongInt);
    procedure SetStreamClass(Value : TSciStreamClass);
    procedure SetStreamExtra(const Value : Integer);
    procedure SetStreamExtraStr(const Value : String);
    property  OnChanged : TNotifyEvent read FOnChanged write FOnChanged; // Used by TSciDocumentTabControl, internal
  public
    constructor Create(pp : TScintillaBase;ttabctrl : TSciDocumentTabControl;const getcurrent : Boolean=false);
    destructor Destroy;override;
    procedure Activate;
    function IsUntitled : Boolean;
    function IsActive : Boolean;
    procedure Close;
    property TabName : string read FTabName Write SetTabName;
    property ExtraData : Pointer read FExtraData write FExtraData;
    property OnRemoveExtraData : TSCEvent_removeextradata read FOnRemoveExtraData write FOnRemoveExtraData;
    property StreamClass : TSciStreamClass read FStreamClass write SetStreamClass;
    property StreamExtra : Integer read FStreamExtra write SetStreamExtra;
    property StreamExtraStr : String read FStreamExtraStr write SetStreamExtraStr;
  published
    //Get or set indentation options: - KeepIndent, - TabIndents, - BackSpaceUnIndents, - IndentationGuides
    property Indentation : TIndentationOptions read FIndentation write SetIndentation;
    //Number of characters for code (un)indending.  If set to zero then the TabWidth is used instead
    property IndentWidth : Integer read FIndentWidth write SetIndentWidth;
    property TabWidth : Integer read FTabWidth write SetTabWidth;
    // If the current editor is a TScintilla derived class then this property are automatically saved and used
    property Highlighter : String read fHighlighter Write SetHighlighter;
    property FileName : String read FFileName write SetFileName;
    property Index : Integer read FIndex write FIndex;
    property Modified : Boolean read FModified write SetModified;
    property WordChars : String read FWordChars write SetWordChars;
    property AutoIgnoreCase : Boolean read FAutoIgnoreCase write FAutoIgnoreCase;
    property AutoStartChars : String read FAutoStartChars write FAutoStartChars;
    property AutoStopChars  : String read FAutoStopChars write FAutoStopChars;
    property UseTabs : Boolean read FUseTabs write SetUseTabs;
    property CodePage : LongInt read FCodePage write SetCodePage;
    property LastChanged : Integer read FLastChanged write FLastChanged;
  end;

  TSciDocumentTabControl = class(TCustomTabControl)
    private
      docs : TObjectList;
      fEditor : TScintillaBase;
      FOnClosing : TSCEvent_onclosing;
      FOnDetectHighlighter : TSCEvent_detecthighlighter;
      FOnOpenedAndInited : TSCEvent_openedandinited;
      FOnTabHint : TSCEvent_onhint;
      FDefaultExt : String;
      inactivate : Boolean;
      FDefaultTabName : String;

      procedure EvttabChanged(Sender : TObject);
      function getCount : Integer;
      function GetDocItm(const Index : Integer) : TSciDoc;
      procedure SetEditor(Value : TScintillaBase);
      function GetActiveDocument : TSciDoc;

      procedure SetDefaultExt(const Value : String);
      procedure ChgTab(const newtab : Integer);
      procedure Remove(const index : Integer);           // Remove the tab 'index'

    protected
      procedure DoLoadFromFile(const FileName : String);virtual;
      function CanChange : Boolean; override;
      procedure Notification(AComponent: TComponent; Operation: TOperation); override;
      procedure Attach; // Attaches the editor to this tabcontrol
      procedure RefreshTabs; // Refreshes the tablist
      procedure DoTabHint(const TabIndex : Integer;var HintText : String;doc : TSciDoc);virtual;
      procedure CMHintShow(var Message: TMessage);message CM_HINTSHOW;
      procedure Change; override;
    public
      constructor Create(AOwner : TComponent);override;
      destructor Destroy;override;

      function Open(const filename : String;MayBeUnicode : Boolean=False) : Boolean; // Open a file
      procedure Close(const index : Integer=-1;const askifneeded : Boolean=True);         // If 'index' is -1 then close the currently selected Tab, else close the selected index.
      function  NewDocument : Integer;                   // Init a new document, return tabindex
      procedure Activate(const docno : LongInt);         // Activate the tab 'docno'
      function  Add(const tabname : String;const thefilename : String) : Integer;   // Add a tab, set the tabname to 'tabname'

      property Count : Integer read getCount;           // Returns number of tabs/documents
      property Document [const Index : Integer] : TSciDoc read GetDocItm; // Returns the document item for the specified tabindex
      property DisplayRect;
      property Tabs;
      property TabIndex;  // must be after Tabs
      property ActiveDocument : TSciDoc read GetActiveDocument;
    published
      // The current editor used.
      property Editor : TScintillaBase read fEditor write SetEditor;
      property Align;
      property Anchors;
      property BiDiMode;
      property Constraints;
      property DragCursor;
      property DragMode;
      property Enabled;
      property Font;
      property HotTrack default True;
      property MultiLine;
      property OwnerDraw;
      property ParentBiDiMode;
      property ParentShowHint default False;
      property PopupMenu;
      property RaggedRight;
      property ScrollOpposite;
      property ShowHint default True;
      property Style;
      property TabHeight;
      property TabOrder;
      property TabPosition;
      property TabWidth;
      property Visible;
      property OnChange;
      property OnChanging;
      property OnContextPopup;
      property OnDrawTab;
      property OnEndDock;
      property OnEndDrag;
      property OnEnter;
      property OnExit;
      property OnMouseDown;
      property OnMouseMove;
      property OnMouseUp;
      property OnResize;
      property OnStartDock;
      property OnUnDock;
      property ParentFont default False;
      property TabStop default False;
      property DefaultExt : String read FDefaultExt write SetDefaultExt;
      // Fired when a Tab is about to be removed etc. Good place for confirmation dialogs etc.
      property OnClosing : TSCEvent_onclosing read FOnClosing write FOnClosing;
      // This event is only active when a descentant of TScintilla is used
      property OnDetectHighlighter : TSCEvent_detecthighlighter read FOnDetectHighlighter write FOnDetectHighlighter;
      property OnOpenedAndInited : TSCEvent_openedandinited read FOnOpenedAndInited write FOnOpenedAndInited;
      property OnTabHint : TSCEvent_onhint read FOnTabHint write FOnTabHint;
  end;

implementation
uses SysUtils,sciUtils,SciLexerMod,Graphics,Shellapi,Forms,sciSupport,SciResLang,ImgList;//,RTLConsts;
var
  ci : CHARSETINFO  = ( ciCharset: 0; ciACP:0; fs : ( fsUsb:( 0, 0, 0, 0 ); fsCsb: ( 0, 0 ); ) );

function CodePageFromCharSet(CharSet : DWORD;documentCodePage : UINT) : LongWord;
var
  bci : Boolean;
  cp : UINT;
  cpi : CPINFO;
begin
  bci:=TranslateCharsetInfo(charSet,ci, TCI_SRCCHARSET);
  if bci then
    cp:=ci.ciACP
  else
    cp:=documentCodePage;
  if ((not IsValidCodePage(cp)) and (not GetCPInfo(cp,cpi))) then
    cp:=CP_ACP;
  Result:=cp;
end;

function GetFileExt(const fname : String) : String;
begin
  Result :=LowerCase(ExtractFileExt(fname));
end;

constructor TSciDocumentTabControl.Create(AOwner : TComponent);
begin
  fEditor:=nil;
  docs:=nil;
  inactivate:=False;
  inherited Create(AOwner);
  DragKind:=dkDock;
  MultiSelect:=False;
  ParentFont:=False;
  TabStop:=False;
  ShowHint:=True;
  FDefaultExt:='.txt';
  FDefaultTabName:='<'+sUntitled+FDefaultExt+'>';
  ControlStyle:=ControlStyle-[csAcceptsControls];
end;

destructor TSciDocumentTabControl.Destroy;
var
  i : Integer;
  cnt : Integer;
 begin
  if (assigned(docs)) and (assigned(fEditor)) then
  begin
    cnt:=docs.Count;
    for i:=(cnt-1) downto 0 do
    begin
      TSciDoc(docs.Items[i]).OnChanged:=nil;
    end;
  end;
  if assigned(docs) then
  begin
{
    cnt:=docs.Count;
    for i:=(cnt-1) downto 0 do
    begin
      itm:=TSciDoc(docs.Items[i]);
      if Assigned(itm) then
      begin
        docs.Items[i]:=nil;
        FreeAndNil(itm);
      end;
    end;
}
    FreeAndNil(docs);
  end;
  inherited;
end;

procedure TSciDocumentTabControl.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited;
  if Operation=opRemove then
  begin
    if AComponent=fEditor then
    begin
      if assigned(docs) then FreeAndNil(docs);
      if assigned(Tabs) then Tabs.Clear;
      fEditor:=nil;
    end;
  end;
end;

procedure TSciDocumentTabControl.Attach;
var
  sci : TSciDoc;
  highl,theext : String;

begin
  if assigned(docs) then
  begin
    try
      Tabs.BeginUpdate;
      if (assigned(Tabs)) and (Tabs.Count>0) then
        Tabs.Clear;
      if (docs.Count>0) then docs.Clear;
      if assigned(fEditor) then
      begin
        sci:=TSciDoc.Create(fEditor,Self,true);
        sci.Index:=0;
        sci.TabName:=FDefaultTabName;
        sci.OnChanged:=EvttabChanged;
        if fEditor is TScintilla then
        begin
          highl:=nullHighlighter;
          theext :=LowerCase(ExtractFileExt(FDefaultExt));
          if assigned(FOnDetectHighlighter) then
          begin
            FOnDetectHighlighter(self,theext,highl);
          end;
          sci.Highlighter:=highl;

        end;
        docs.Add(sci);
        Tabs.Add(sci.TabName);
        if assigned(FOnOpenedAndInited) then FOnOpenedAndInited(Self,sci.Index,sci);
      end;
    finally
      Tabs.EndUpdate;
    end;
  end;
end;

procedure TSciDocumentTabControl.DoLoadFromFile(const FileName : String);
begin
  FEditor.LoadFromFile(FileName);
end;

function TSciDocumentTabControl.NewDocument : Integer;
begin
  result:=Add(FDefaultTabName,sUntitled+FDefaultExt);
  if result<>-1 then
  TSciDoc(docs.Items[result]).Changed;
  if assigned(FOnOpenedAndInited) then FOnOpenedAndInited(Self,result,TSciDoc(docs.Items[result]));

end;

function TSciDocumentTabControl.Open(const filename : String;MayBeUnicode : Boolean) : Boolean;
var
  itm,nitm : TSciDoc;
  highl,theext : String;
  doccnt : Integer;
  i,newitemindex : Integer;
  efname : String;
  fullfilename : String;
  confirmed : Integer;
begin
  fullfilename:=filename;
  if FExists(fullfilename) then
  begin
    doccnt:=docs.Count;
    for i:=0 to (doccnt-1) do
    begin
      itm:=TSciDoc(docs.Items[i]);
      if assigned(itm) and (CompareText(itm.FileName,fullfilename)=0) then
      begin
        ChgTab(i);
        if (itm.LastChanged<=FileAge(fullfilename)) then
        begin
          if itm.Modified then
            confirmed:=MessageBox(Handle,PChar(Format(sReload,[fullfilename])),PChar(sConfirmation),MB_YESNO)
          else
            confirmed:=IDYES;
          if confirmed=IDYES then
          begin
            DoLoadFromFile(filename);
            itm.LastChanged:=FileAge(fullfilename);
          end;
        end;
        Result:=True;
        Exit;
      end;
    end;
    nitm:=TSciDoc(docs.Items[0]);
    if (doccnt>1) or (fEditor.Modified) or (StrLIComp(PChar(nitm.TabName),PChar(FDefaultTabName),Length(FDefaultTabName))<>0) then
    begin
      efname:=ExtractFileName(filename);
      newitemindex:=Add(efname,fullfilename);
      itm:=TSciDoc(docs.Items[newitemindex]);
      doccnt:=doccnt+1;
    end else
    begin
      itm:=TSciDoc(docs.Items[0]);
      itm.FileName:=fullfilename;
      if fEditor is TScintilla then
      begin
        highl:=nullHighlighter;
        theext :=GetFileExt(filename);
        if assigned(FOnDetectHighlighter) then
        begin
          FOnDetectHighlighter(self,theext,highl);
        end;
        itm.Highlighter:=highl;
      end;
    end;
    DoLoadFromFile(filename);
    if assigned(FEditor.Streamer) then
    begin
      itm.StreamExtra:=fEditor.Streamer.GetData;
      itm.StreamExtraStr:=fEditor.Streamer.GetDataStr;
    end else
    begin
      itm.StreamExtra:=0;
      itm.StreamExtraStr:='';
    end;
    if doccnt=1 then ChgTab(0);
    if assigned(FOnOpenedAndInited) then FOnOpenedAndInited(Self,itm.Index,itm);
    result:=true;
  end else
  begin
    doccnt:=docs.Count;
    if (doccnt>1) or (fEditor.Modified) or (StrLIComp(PChar(TSciDoc(docs.Items[0]).TabName),PChar(FDefaultTabName),Length(FDefaultTabName))<>0) then
    begin
      efname:=ExtractFileName(filename);
      newitemindex:=Add(efname,fullfilename);
      itm:=TSciDoc(docs.Items[newitemindex]);
      doccnt:=doccnt+1;
    end else
    begin
      itm:=TSciDoc(docs.Items[0]);
      itm.FileName:=fullfilename;
      if fEditor is TScintilla then
      begin
        highl:=nullHighlighter;
        theext:=GetFileExt(filename);
        if assigned(FOnDetectHighlighter) then
        begin
          FOnDetectHighlighter(self,theext,highl);
        end;
        itm.Highlighter:=highl;
      end;
    end;
    if doccnt=1 then ChgTab(0);
    if assigned(FOnOpenedAndInited) then FOnOpenedAndInited(Self,itm.Index,itm);
    result:=true;
  end;
end;

procedure  TSciDocumentTabControl.Close(const index : Integer;const askifneeded : Boolean);
var
  allowclose : Boolean;
  idx : Integer;
begin
  allowclose:=true;
  if index=-1 then
    idx:=TabIndex
  else
    idx:=Index;
  if (askifneeded) and (assigned(FOnClosing)) then
  begin
    if TSciDoc(docs[idx]).IsActive<>True then
    begin
      Activate(idx);
    end;
    FOnClosing(self,idx,allowclose)
  end;
  if allowclose then
    Remove(idx);
end;

function TSciDocumentTabControl.Add(const tabname : string;const thefilename : String) : Integer;
var
  sci,itm : TSciDoc;
  atidx : Integer;
  theext,highl : String;
begin
  if assigned(fEditor) and (assigned(docs)) then
  begin
    try
      Tabs.BeginUpdate;
      itm:=ActiveDocument;
      itm.AssignFromEditor;
      sci:=TSciDoc.Create(fEditor,Self,false);
      if tabname<>'' then
        sci.TabName:=tabname;
      if thefilename<>'' then
        sci.FileName:=thefilename;
      atidx:=docs.Add(sci);
      sci.Index:=atidx;
      Tabs.Insert(atidx,tabname);
      sci.OnChanged:=EvttabChanged;
      if thefilename<>'' then sci.Changed;
      if fEditor is TScintilla then
      begin
        highl:=nullHighlighter;
        if thefilename<>'' then
          theext :=GetFileExt(thefilename);
        if assigned(FOnDetectHighlighter) then
        begin
          FOnDetectHighlighter(self,theext,highl);
        end;
        sci.Highlighter:=highl;
      end;
      ChgTab(atidx);
      Result :=atidx;
    finally
      Tabs.EndUpdate;
    end;
  end else
    result:=-1;
end;

procedure TSciDocumentTabControl.ChgTab(const newtab : Integer);
begin
  TabIndex:=newtab;
  Change;
end;

procedure TSciDocumentTabControl.Remove(const index : Integer);
var
  sci : TSciDoc;
  id,cur,i : Integer;
  idxtoremove : Integer;
  highl,theext : String;
begin
  if (assigned(fEditor)) and (assigned(docs)) then
  begin
    try
      Tabs.BeginUpdate;
      sci:=TSciDoc(docs.Items[index]);
      idxtoremove:=sci.Index;
      if docs.Count=1 then
      begin
        fEditor.ClearAll;
      end else
      begin
        docs.Remove(sci);
        docs.Pack;
      end;

      if Tabs.Count>1 then
      begin
        cur:=idxtoremove;
        Tabs.Delete(idxtoremove);
        id:=Tabs.Count;
        if(id>cur+1) then
          Inc(cur)
        else if cur=0 then
        begin
        end else
          Dec(cur);
        for i:=idxtoremove to (docs.Count-1) do //this is moved here to adjust the indexes BEFORE changing tabs.. It got Activate confused it seemd.
        begin
          TSciDoc(docs.Items[i]).Index:=i;
        end;
        ChgTab(cur);
      end else
      begin
        sci:=TSciDoc(docs.Items[0]);
        sci.FileName:=sUntitled+FDefaultExt;
        fEditor.ClearDocument;
        sci.Modified:=false;
        sci.FStreamExtra:=0;
        sci.FStreamExtraStr:='';
        if fEditor is TScintilla then
        begin
          highl:=nullHighlighter;
          theext :=FDefaultExt;
          if assigned(FOnDetectHighlighter) then
          begin
            FOnDetectHighlighter(self,theext,highl);
          end;
          sci.Highlighter:=highl;
        end;
        ChgTab(0);
      end;
    finally
      Tabs.EndUpdate;
    end;
  end;
end;

function TSciDocumentTabControl.CanChange : Boolean;
var
  itm : TSciDoc;
begin
  if (assigned(fEditor)) and (assigned(docs)) then
  begin
    itm :=ActiveDocument;
    if assigned(itm) then  itm.AssignFromEditor;
    result:=Inherited CanChange;
  end else
    result:=false;
end;

procedure TSciDocumentTabControl.Change;
begin
  if assigned(docs) then
  begin
    TSciDoc(docs.Items[TabIndex]).Activate;
  end;
  inherited;
end;

procedure TSciDocumentTabControl.DoTabHint(const TabIndex : Integer;var HintText : String;doc : TSciDoc);
begin
  if assigned(FOnTabHint) then
    FOnTabHint(Self,TabIndex,HintText,doc);
end;

procedure TSciDocumentTabControl.CMHintShow(var Message: TMessage);
var
  Index: Integer;
begin
  with TCMHintShow(Message) do
  begin
    if not ShowHint then Message.Result := 1
    else
    begin
      with HintInfo^ do
      begin
        // show that we want a hint
        Result := 0;
        // predefined colors always get their names as tooltip
        index:=IndexOfTabAt(CursorPos.X,CursorPos.Y);
        if index<>-1 then
        begin
          if FEditor is TScintilla then
            HintStr:=sLang+TSciDoc(docs.Items[index]).Highlighter
          else
            HintStr:='';
          if assigned(FOnTabHint) then
            DoTabHint(index,HintStr,TSciDoc(docs.Items[index]));
          CursorRect:=TabRect(index);
        end else
        begin
          HintStr:=Hint;
        end;
      end;
    end;
  end;
end;

procedure TSciDocumentTabControl.Activate(const docno : LongInt);
begin
  if TabIndex<>docno then
  begin
  if (CanChange) then
  begin
    TabIndex:=docno;
    if assigned(docs) then
    begin
      TSciDoc(docs.Items[docno]).Activate;
    end;
  end;
  end;
end;

procedure TSciDocumentTabControl.RefreshTabs;
var
  cnt : Integer;
  i : Integer;
  ist : String;
begin
  try
    Tabs.BeginUpdate;
    Tabs.Clear;
    if assigned(docs) then
    begin
      cnt:=docs.Count;
      for i:=0 to (cnt-1) do
      begin
        str(i+1,ist);
        if (i+1)<10 then
          Tabs.Add('&'+ist+' '+TSciDoc(docs.Items[i]).TabName)
        else
          Tabs.Add(ist+' '+TSciDoc(docs.Items[i]).TabName);
      end;
    end;
  finally
    Tabs.EndUpdate;
  end;
end;

procedure TSciDocumentTabControl.SetEditor(Value : TScintillaBase);
var
  tp: TPoint;
  r : TRect;
begin
  if (Value<>fEditor) then
  begin
    if assigned(Value) then
    begin
      fEditor:=Value;
      if (not (csWriting in ComponentState)) and (not(csDestroying in ComponentState)) then
      begin
        fEditor.Parent:=self;
        fEditor.Visible:=true;
        fEditor.Align:=alClient;
        docs:=TObjectList.Create(true);
        Attach;
        RefreshTabs;
      end;
    end else
    begin
      if assigned(docs) then
      begin
        FreeAndNil(docs);
      end;
      if assigned(Tabs) and (Tabs.Count>0) then
        Tabs.Clear;
      if fEditor.HandleAllocated then
      begin
        if assigned(Parent) then
        begin
          fEditor.Align:=alNone;
          r :=ClientRect;
          tp.x:=r.Left;
          tp.y:=r.Top;
          tp:=fEditor.ClientToParent(tp);
          fEditor.Parent:=Parent;
          fEditor.Left:=tp.x;
          fEditor.Top:=tp.y;
        end;
      end;
      fEditor:=nil;
    end;
  end;
end;

function TSciDocumentTabControl.getCount : Integer;
begin
  if assigned(docs) then
    result:=docs.Count
  else
    result:=0;
end;

function TSciDocumentTabControl.GetDocItm(const Index : Integer) : TSciDoc;
begin
  if assigned(docs) then
    result :=TSciDoc(docs.Items[Index])
  else
    result:=nil;
end;

function TSciDocumentTabControl.GetActiveDocument : TSciDoc;
begin
  Result :=TSciDoc(docs.Items[TabIndex]);
end;

procedure TSciDocumentTabControl.SetDefaultExt(const Value : String);
var
  oldtab : String;
  i,cnt : Integer;
  itm : TSciDoc;
  theext,highl : String;
begin
  oldtab:=FDefaultTabName;
  FDefaultExt:=Value;
  if Pos('.',FDefaultExt)=0 then
    Insert('.',FDefaultExt,1);
  FDefaultTabName:='<'+sUntitled+FDefaultExt+'>';
  cnt:=Tabs.Count;
  for i:=0 to (cnt-1) do
  begin
    itm:=TSciDoc(docs.Items[i]);
    if StrLIComp(PChar(itm.TabName),PChar(oldtab),Length(oldtab))=0 then
    begin
      itm.TabName:=FDefaultTabName;
      itm.FileName:=sUntitled+FDefaultExt;

      if fEditor is TScintilla then
      begin
        theext :=FDefaultExt;
        highl:=itm.Highlighter;
        if assigned(FOnDetectHighlighter) then
        begin
          FOnDetectHighlighter(self,theext,highl);
        end;
        if itm.Highlighter<>highl then
          itm.Highlighter:=highl;
      end;
    end;
  end;
end;

procedure TSciDocumentTabControl.EvttabChanged(Sender : TObject);
var
  tmp : TSciDoc;
  ist : String;
begin
  tmp:=TSciDoc(Sender);
  if tmp.Index<Tabs.Count then
  begin
    Str(tmp.Index+1,ist);
    if (tmp.Index+1)<10 then
      Tabs.Strings[tmp.Index]:='&'+ist+' '+tmp.TabName
    else
      Tabs.Strings[tmp.Index]:=ist+' '+tmp.TabName;
  end;
end;

procedure TSciDoc.SetFileName(const Value : string);
var
  anExt : string;
  function GetExt : String;
  var
    tmp : String;
    Len : Integer;
  begin
    len:=Length(Value);
    tmp:=ExtractFileExt(Copy(Value,2,len-2));
    Result:=tmp;
  end;
begin
  if Value<>FFileName then
  begin
    FFileName:=Value;
    if Pos('<'+sUntitled,Value)=1 then
    begin
      anExt:=GetExt;
      FTabName:='<'+sUntitled+anExt+'>';
      FFileName:=sUntitled+anExt;
      FLastChanged:=-1;
    end else
    begin
      FTabName:=ExtractFileName(Value);
      FLastChanged:=FileAge(Value);
    end;
    Changed;
  end;
end;

procedure TSciDoc.SetWordChars(const Value : String);
begin
  if FWordChars<>Value then
  begin
    FWordChars:=Value;
    if IsActive then
      TScintillaBase(fEditor).WordChars:=FWordChars;
  end;
end;

procedure TSciDoc.Changed;
begin
  if assigned(FOnChanged) then FOnChanged(self);
end;

procedure TSciDoc.SetTabName(const Value : string);
begin
  if Value<>FTabName then
  begin
    FTabName:=Value;
    Changed;
  end;
end;

function TSciDoc.IsActive : Boolean;
var
  ptr : LongInt;
begin
  if fEditor=nil then
  begin
    Result:=false;
    Exit;
  end;
  ptr :=fEditor.GetDocPointer;
  if ptr=documentid then
    result :=true
  else
    result :=false;
end;

constructor TSciDoc.Create(pp : TScintillaBase;ttabctrl : TSciDocumentTabControl;const getcurrent : Boolean);
begin
  FStreamExtra:=0;
  FStreamExtraStr:='';
  inherited Create;
  fTabCtrl:=ttabctrl;
  fEditor :=pp;
  FCodePage:=pp.GetCodePage;
  FUseTabs:=False;
  FTabName:='<'+sUntitled+TSciDocumentTabControl(fTabCtrl).FDefaultExt+'>';
  FModified:=false;
  FWordChars :='_'+sci_alphachars+sci_numericchars;
  FHighlighter:=nullHighlighter;
  FAutoIgnoreCase:=False;
  FAutoStartChars:='';
  FAutoStopChars:='';
  FLastChanged:=-1;
  FExtraData :=nil;
  FFileName :=sUntitled+TSciDocumentTabControl(fTabCtrl).FDefaultExt;
  if getcurrent=false then
  begin
    documentid:=fEditor.CreateDocument;
    AddRef;
  end  else
  begin
    documentid:=fEditor.GetDocPointer;
    AddRef;
  end;
  AssignFromEditor;
end;

destructor TSciDoc.Destroy;
begin
  FFoldStates:=nil;
  if assigned(FOnRemoveExtraData) then
  begin
    FOnRemoveExtraData(Self);
  end;
  Release;
  inherited;
end;

procedure TSciDoc.StoreFoldStates;
var
  maxLine : LongInt;
  foldPoints : LongInt;
  line : LongInt;
  level : LongInt;
  expanded : Boolean;
  atpos : Integer;
begin
  FFoldStates:=nil;
  if Highlighter=nullHighlighter then Exit;
  foldPoints:=0;
  maxline:=fEditor.GetLineCount;
  for line := 0 to (maxLine-1) do
  begin
    level := fEditor.GetFoldLevel(line);
    if ((level and SC_FOLDLEVELHEADERFLAG)<>0) then Inc(foldPoints);
  end;
  if foldPoints>0 then
  begin
    SetLength(FFoldStates,foldPoints);
    atpos:=0;
    for line := 0 to  (maxLine-1) do
    begin
      level := fEditor.GetFoldLevel(line);
      if ((level and SC_FOLDLEVELHEADERFLAG)<>0) then
      begin
        expanded:=fEditor.GetFoldExpanded(line);
        FFoldStates[atpos].Line:=line;
        FFoldStates[atpos].Expanded:=expanded;
        Inc(atpos);
      end;
    end;
  end;
end;

procedure TSciDoc.RestoreFoldStates;
var
  i : LongInt;
  expanded : Boolean;
begin
  if (not assigned(FFoldStates)) or (Highlighter=nullHighlighter) then Exit;
  for i:=Low(FFoldStates) to High(FFoldStates) do
  begin
    expanded:=fEditor.GetFoldExpanded(FFoldStates[i].Line);
    if (FFoldStates[i].Expanded=False) and (expanded=True) then
    begin
      fEditor.ToggleFold(FFoldStates[i].Line);
    end;
    if (FFoldStates[i].Expanded=True) and (expanded=False) then
    begin
      fEditor.ToggleFold(FFoldStates[i].Line);
    end;
  end;
end;

procedure TSciDoc.AssignFromEditor;
begin
  with fEditor as TScintillaBase do
  begin
    StoreFoldStates;
    FFirstLineInView:=GetCurrentScrollPosition;
    FSelStart:=SelStart;
    FSelLength:=SelLength;
    FModified:=fEditor.Modified;
    FReadOnly :=ReadOnly;
    FWordChars :=WordChars;
    if FEditor is TScintillaMemo then
    begin
      FIndentWidth:=IndentWidth;
      FTabWidth:=TabWidth;
      FIndentation:=Indentation;
      FUseTabs:=UseTabs;
    end;
    FCodePage:=GetCodePage;
    FStreamClass:=StreamClass;
  end;
  if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager)) then
  begin
    fHighlighter:=TScintilla(fEditor).LanguageManager.SelectedLanguage;
  end;
end;

procedure TSciDoc.AssignToEditor;
var
  curtop : LongInt;
  xlinestart : LongInt;
  xlineend : LongInt;
  xlinetop : LongInt;
  hadwordwrap : TWordWrapType;
begin
  hadwordwrap:=fEditor.WordWrap;
  if hadwordwrap<>sciNoWrap then fEditor.WordWrap:=sciNoWrap;
  if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager))
  //and (TScintilla(fEditor).LanguageManager.SelectedLanguage<>self.fHighlighter)
  //Removed to fix a bug which caused not setting correct number of stylebits
  //for languages such as HTML/PHP on new pages if already using the same language.
  //Temporary fix, until a more speedy one can be done.
  then
    TScintilla(fEditor).LanguageManager.SelectedLanguage:=self.fHighlighter;
  with fEditor as TScintillaBase do
  begin
    RestoreFoldStates;
    xlinestart:=LineFromPosition(FSelStart);
    xlineend:=LineFromPosition(FSelStart+FSelLength);
    EnsureVisibleEnforcePolicy(xlinestart);
    EnsureVisibleEnforcePolicy(xlineend);
    SelStart:=FSelStart;
    SelLength:=FSelLength;
    fEditor.Modified:=FModified;
    ReadOnly:=FReadOnly;
    WordChars :=FWordChars;
    StreamClass:=FStreamClass;
    if assigned(Streamer) then
    begin
      Streamer.SetData(FStreamExtra);
      Streamer.SetDataStr(FStreamExtraStr);
    end;
    if FEditor is TScintillaMemo then
    begin
      Indentation:=FIndentation;
      TabWidth:=FTabWidth;
      IndentWidth:=FIndentWidth;
      UseTabs:=FUseTabs;
    end;
    if FEditor.GetCodePage<>FCodePage then
      FEditor.SetCodePage(FCodePage);
    //Position the cursor back where it was
    curtop:=GetFirstVisibleLine;
    xlinetop:=VisibleFromDocLine(FFirstLineInView);
    LineScroll(0,xlinetop-curtop);
    if hadwordwrap<>sciNoWrap then
      WordWrap:=hadwordwrap;
    if Visible and Showing then
    SetFocus;
  end;
end;

procedure TSciDoc.Activate;
begin
  if not IsActive then
  begin
    if (TSciDocumentTabControl(fTabCtrl).TabIndex<>Index) and (TSciDocumentTabControl(fTabCtrl).CanChange) then
    begin
      TSciDocumentTabControl(fTabCtrl).TabIndex:=Index;
    end;
    fEditor.SetDocPointer(documentid);
    AssignToEditor;
  end;
end;

procedure TSciDoc.AddRef;
begin
  if (assigned(fEditor)) and (documentid<>0) then
  begin
    fEditor.AddRefDocument(documentid);
  end;
end;

procedure TSciDoc.Release;
begin
  if (assigned(fEditor)) and (documentid<>0) then
  begin
    if fEditor.HandleAllocated then
      fEditor.ReleaseDocument(documentid);
  end;
  documentid:=0;
end;

function TSciDoc.IsUntitled  : Boolean;
begin
  if (Pos('<'+sUntitled,TabName)<>0) and (Pos('>',TabName)<>0) then
    Result:=True
  else
    Result:=False;
end;

procedure TSciDoc.SetModified(const Value : Boolean);
begin
  FModified:=Value;
  if assigned(fEditor) and (IsActive=True) then
  begin
    fEditor.Modified:=Value;
  end;
end;
procedure TSciDoc.Close;
begin
  if assigned(fTabCtrl) then
  TSciDocumentTabControl(fTabCtrl).Close(Index);
end;

procedure TSciDoc.SetHighlighter(const Value : String);
begin
  fHighlighter:=Value;
  if IsActive then
  begin
    if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager)) then
    begin
      if Value<>TScintilla(fEditor).LanguageManager.SelectedLanguage then
      begin
        TScintilla(fEditor).LanguageManager.SelectedLanguage:=fHighlighter;
      end;
    end;
  end;
end;

procedure TSciDoc.SetIndentWidth(const Value : Integer);
begin
  fIndentWidth:=Value;
  if IsActive then
  begin
    if fEditor is TScintillaMemo then
    begin
      if Value<>TScintillaMemo(fEditor).IndentWidth then
      begin
        TScintillaMemo(fEditor).IndentWidth:=fIndentWidth;
      end;
    end;
  end;
end;

procedure TSciDoc.SetTabWidth(const Value : Integer);
begin
  fTabWidth:=Value;
  if IsActive then
  begin
    if Value<>TScintillaMemo(fEditor).TabWidth then
    begin
      TScintillaMemo(fEditor).TabWidth:=fTabWidth;
    end;
  end;
end;

procedure TSciDoc.SetIndentation(const Value : TIndentationOptions);
begin
  fIndentation:=Value;
  if IsActive then
  begin
    if Value<>TScintillaMemo(fEditor).Indentation then
    begin
      TScintillaMemo(fEditor).Indentation:=fIndentation;
    end;
  end;
end;

procedure TSciDoc.SetUseTabs(const Value : Boolean);
begin
  FUseTabs:=Value;
  if IsActive then
  begin
    if Value<>TScintillaMemo(fEditor).UseTabs then
    begin
      TScintillaMemo(fEditor).UseTabs:=Value;
    end;
  end;
end;

procedure TSciDoc.SetCodePage(const Value : LongInt);
begin
  FCodePage:=Value;
  if IsActive then
  begin
    if Value<>fEditor.GetCodePage then
    begin
      fEditor.SetCodePage(Value);
    end;
  end;
end;

procedure TSciDoc.SetStreamClass(Value : TSciStreamClass);
begin
  FStreamClass:=Value;
  if IsActive then
  begin
    if Value<>fEditor.StreamClass then
    begin
      fEditor.StreamClass:=Value;
    end;
  end;
end;

procedure TSciDoc.SetStreamExtra(const Value : Integer);
begin
  FStreamExtra:=Value;
  if IsActive then
  begin
    if assigned(fEditor.Streamer) then
      fEditor.Streamer.SetData(Value);
  end;
end;

procedure TSciDoc.SetStreamExtraStr(const Value : String);
begin
  FStreamExtraStr:=Value;
  if IsActive then
  begin
    if assigned(fEditor.Streamer) then
      fEditor.Streamer.SetDataStr(Value);
  end;
end;

end.
Added src/delphisci/SciFileExtensionsManager.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis (Jan Martin Pettersen)
  Created: 18/04/2005
      $Id: SciFileExtensionsManager.pas,v 1.0 $
  Purpose: Manages file extensions

    Usage: Mostly internally used. Access the class via the ExtMapper function

  History: 18/04/2005 First release
                      Moved the ExtMapper from SciPropertyMgr to SciFileExtensionsManager.Pas, and
                      changed the way the extensions are stored.. Now it's a collection of items,
                      with two properties. Language, and Extensions. Use ExtMapper.Add to add new extensions.
           09/06/2005 Added the GetFileSpec function to the TExtensionItem. This function transforms the
                      filespecs defined (.foo1;.foo2) to filespecs usable for the file dialogs e.g: Description (filespec)|filespec

  Differences from the original ExtensionMapper:
    - Renamed the DetectLexer function to the more logical DetectLanguage
    - Added the possibility to remove a extension/language from the extensionmapping.
    - Added direct access to the extensions via the property ExtensionsList.
    - FillExtensionsMap is not called automatically because if the language isn't
    in the languagemanager, then it's possible it is created on the fly (with the NULL
    settings), and that may not be what you wished for.
    - FillExtensionsMap can now verify that a language exists before adding the extensions
    pertaining to that language.


}
{$Include SciCommonDef.Inc}
unit SciFileExtensionsManager;
interface
uses Classes,ScintillaLanguageManager;
type
  TExtensionItem=class(TCollectionItem)
  private
    FLanguage : String;
    FExtensions : String;
    procedure SetLanguage(const Value : String);
    procedure SetExtensions(const Value : String);
  public
    procedure Assign(Source: TPersistent);override;
  published
    property Language : String read FLanguage write SetLanguage;
    property Extensions : String read FExtensions write SetExtensions;
  end;

  TExtensionsToLanguageList=class(TCollection)
  private
    FExtensionSeparator : AnsiChar;
    lastAccessed : TExtensionItem;
    procedure SetItem(Index:Integer; Value: TExtensionItem);
    function GetItem(Index:Integer): TExtensionItem;
    function LanguageFromExt(const ExtensionToFind : String;const Separator : AnsiChar) : String;
    function RemoveFromList(const ExtensionToFind : String;const Separator : AnsiChar) : Boolean;
    function AddIfNotSame(const MapFromWhatExtension : String;const ToWhatLanguage : String;const Separator : AnsiChar) : Boolean;
  public
    constructor Create(ItemClass: TCollectionItemClass);
    procedure Assign(Source: TPersistent);override;
    property Items[Index : Integer] : TExtensionItem read GetItem write SetItem;default;
    function Add: TExtensionItem;
    procedure Delete(Index: Integer);
    procedure MapLanguageToExts(const WhatLanguage : String;const AllExtensions : String;CheckWith : TSciLanguageManager=nil);
    function GetLangItem(const WhatLanguage : String) : TExtensionItem;
  published
    property ExtensionSeparator : AnsiChar read FExtensionSeparator write FExtensionSeparator default ';';
  end;

  TExtensionMapper=class(TObject)
  private
    FExtensionItems : TExtensionsToLanguageList;
    procedure SetExtensionItems(Value : TExtensionsToLanguageList);
  public
    constructor Create;
    destructor  Destroy;override;
    procedure Add(const MapFromWhatExtension : String;const ToWhatLanguage : String);
    function DetectLanguage(const ExtensionToFind : string) : String;
    procedure Remove(const ExtensionToRemove : String);
    procedure RemoveAllWithLang(const MappedToWhatLang : String);
    procedure FillExtensionMap(LanguageManager : TSciLanguageManager=nil);
    property ExtensionsList : TExtensionsToLanguageList read FExtensionItems write SetExtensionItems;
  end;

function ExtMapper : TExtensionMapper;
implementation
uses SciResLang,sciUtils,SysUtils;
var
  FExtMap : TExtensionMapper;

function ExtMapper : TExtensionMapper;
begin
  if FExtMap=nil then
  FExtMap:=TExtensionMapper.Create;
  Result:=FExtMap;
end;

constructor TExtensionMapper.Create;
begin
  inherited;
  FExtensionItems:=TExtensionsToLanguageList.Create(TExtensionItem);
end;
destructor TExtensionMapper.Destroy;
begin
  if assigned(FExtensionItems) then FreeAndNil(FExtensionItems);
  inherited;
end;

{Fill the list with default extensionmappings.}
procedure TExtensionMapper.FillExtensionMap(LanguageManager : TSciLanguageManager);
begin
  with FExtensionItems do
  begin
    MapLanguageToExts('C++/C','.c;.cc;.cpp;.cxx;.h;.hh;.hxx;.hpp',LanguageManager);
    MapLanguageToExts('C#','.cs',LanguageManager);
    MapLanguageToExts('Resource','.rc;.rc2;.dlg',LanguageManager);
    MapLanguageToExts('HTML','.htm;.html;.asp=;.shtml;.htd;.htt;.cfm;.tpl;.hta',LanguageManager);
    MapLanguageToExts('PHP','.php;.php3;.phtml',LanguageManager);
    MapLanguageToExts('XML','.xml;.xsl;.xslt;.svg;.xul;.xsd;.dtd;.axl;.xrc;.bpk;.bpr;.ant',LanguageManager);
    MapLanguageToExts('WML','.wml',LanguageManager);
    MapLanguageToExts('PERL','.pl;.pm;.cgi;.pod',LanguageManager);
    MapLanguageToExts('CSS','.css',LanguageManager);
    MapLanguageToExts('Pascal','.pas;.inc;.dpk;.dpr',LanguageManager);
    MapLanguageToExts('SQL','.sql',LanguageManager);
    MapLanguageToExts('VB','.vb;.bas;.frm;.cls;.ctl;.pag;.dsr;.dob',LanguageManager);
    MapLanguageToExts('VBScript','.vbs;.dsm',LanguageManager);
    MapLanguageToExts('Java','.java',LanguageManager);
    MapLanguageToExts('JavaScript','.js',LanguageManager);
    MapLanguageToExts('IDL','.idl;.odl',LanguageManager);
    MapLanguageToExts('Python','.py;.pyw',LanguageManager);
    MapLanguageToExts('TCL/TK','.tcl',LanguageManager);
    MapLanguageToExts('LUA','.lua',LanguageManager);
    MapLanguageToExts('ASN1','.mib',LanguageManager);
    MapLanguageToExts('VHDL','.vhdl',LanguageManager);
    MapLanguageToExts('Diff','.diff;.patch',LanguageManager);
    MapLanguageToExts('Makefile','.mak;makefile;.make;.iface=Makefile',LanguageManager);
    MapLanguageToExts('Batch','.bat;.cmd;.nt',LanguageManager);
    MapLanguageToExts('Apache Config','.conf',LanguageManager);
    MapLanguageToExts('Properties','.properties;.ini;.inf;.reg;.url;.cfg;.cnf',LanguageManager);
    MapLanguageToExts('ADA','.ads;.adb',LanguageManager);
    MapLanguageToExts('nnCronTab','.spf;.tab',LanguageManager);
    MapLanguageToExts('Lisp','.lsp;.lisp',LanguageManager);
    MapLanguageToExts('Scheme','.scm;.smd;.ss',LanguageManager);
    MapLanguageToExts('AutoIt_3','.au3',LanguageManager);
    MapLanguageToExts('TEX','.tex;.sty',LanguageManager);
    MapLanguageToExts('BASH','.sh;.bsh',LanguageManager);
    MapLanguageToExts('Fortran','.f90;.f95;.f2k',LanguageManager);
    MapLanguageToExts('Fortran77','.f;.for',LanguageManager);
    MapLanguageToExts('EScript','.em;.src',LanguageManager);
    MapLanguageToExts('Eiffel','.e',LanguageManager);
    MapLanguageToExts('Baan','.bc;.cln',LanguageManager);
    MapLanguageToExts('Avenue','.ave',LanguageManager);
    MapLanguageToExts('ASM','.asm',LanguageManager);
    MapLanguageToExts('KIX','.kix',LanguageManager);
    MapLanguageToExts('Objective_Caml','.ml;.mli',LanguageManager);
    MapLanguageToExts('BlitzBasic','.bb',LanguageManager);
    MapLanguageToExts('PureBasic','.pb',LanguageManager);
  end;
end;

// Add a language mapping.. New mappings removes eventual previous existence.
procedure TExtensionMapper.Add(const MapFromWhatExtension : String;const ToWhatLanguage : String);
var
  restOfString,CurrentWord : String;
begin
  if FExtensionItems=nil then Exit;
  restOfString:=MapFromWhatExtension;
  repeat
    CurrentWord:=WordBefore(restOfString,FExtensionItems.ExtensionSeparator);
    if CurrentWord<>'' then
      FExtensionItems.AddIfNotSame(CurrentWord,ToWhatLanguage,FExtensionItems.ExtensionSeparator);
  until restOfString='';
end;

function TExtensionsToLanguageList.RemoveFromList(const ExtensionToFind : String;const Separator : AnsiChar) : Boolean;
var
  itemCount,i : Integer;
  extensionItem : TExtensionItem;
begin
  Result:=False;
  itemCount:=Count;
  for i:=0 to (itemCount-1) do
  begin
    extensionItem:=Items[i];
    if IsWordInString(extensionItem.FExtensions,ExtensionToFind,True,separator) then
    begin
      extensionItem.Extensions:=BuildWordlistExcept(extensionItem.Extensions,ExtensionToFind,True,separator);
      lastAccessed:=extensionItem;
    end;
  end;
end;

procedure TExtensionMapper.RemoveAllWithLang(const MappedToWhatLang : String);
var
  i,itemCount : Integer;
begin
  itemCount:=FExtensionItems.Count;
  for i:=0 to (itemCount-1) do
  begin
    if FExtensionItems.Items[i].FLanguage=MappedToWhatLang then
    begin
      FExtensionItems.Delete(i);
      Exit;
    end;
  end;
end;

function TExtensionsToLanguageList.AddIfNotSame(const MapFromWhatExtension : String;const ToWhatLanguage : String;const Separator : AnsiChar) : Boolean;
var
  itemCount,i : Integer;
  foundPos : Integer;
  extensionItem : TExtensionItem;
begin
  Result:=False;
  if (MapFromWhatExtension='') or (ToWhatLanguage='') then Exit;
  itemCount:=Count;
  if assigned(lastAccessed) and (lastAccessed.FLanguage=ToWhatLanguage) then
  begin
    if (IsWordInString(lastAccessed.FExtensions,MapFromWhatExtension,True,separator)) then
    begin
      Result:=True;
      Exit;
    end;
  end;

  for i:=0 to (itemCount-1) do
  begin
    extensionItem:=Items[i];
    if IsWordInString(extensionItem.FExtensions,MapFromWhatExtension,True,separator) then
    begin
      if extensionItem.FLanguage=ToWhatLanguage then
      begin
        lastAccessed:=extensionItem;
        Result:=False;
        Exit;
      end;
      foundPos:=Pos(MapFromWhatExtension,extensionItem.FExtensions);
      if(foundPos>0) then
      begin
        extensionItem.Extensions:=BuildWordlistExcept(extensionItem.Extensions,MapFromWhatExtension,True,separator);
      end;
    end;
    if extensionItem.FLanguage=ToWhatLanguage then
    begin
      if Trim(extensionItem.FExtensions)<>'' then
        extensionItem.Extensions:=extensionItem.FExtensions+Separator+MapFromWhatExtension
      else extensionItem.Extensions:=MapFromWhatExtension;
      Result:=True;
      lastAccessed:=extensionItem;
      Exit;
    end;
  end;
  extensionItem:=Add;
  extensionItem.Language:=ToWhatLanguage;
  extensionItem.Extensions:=MapFromWhatExtension;
  lastAccessed:=extensionItem;
  Result:=True;
end;

procedure TExtensionMapper.Remove(const ExtensionToRemove : String);
begin
  FExtensionItems.RemoveFromList(ExtensionToRemove,FExtensionItems.ExtensionSeparator);
end;

function TExtensionsToLanguageList.LanguageFromExt(const ExtensionToFind : String;const Separator : AnsiChar) : String;
var
  itemCount,i : Integer;
  extensionItem : TExtensionItem;
begin
  Result:='null';
  if assigned(lastAccessed) then
  begin
    if IsWordInString(lastAccessed.FExtensions,ExtensionToFind,True,separator) then
    begin
      Result:=lastAccessed.FLanguage;
      Exit;
    end;
  end;
  itemCount:=Count;
  for i:=0 to (itemCount-1) do
  begin
    extensionItem:=Items[i];
    if IsWordInString(extensionItem.FExtensions,ExtensionToFind,True,separator) then
    begin
      Result:=extensionItem.FLanguage;
      lastAccessed:=extensionItem;
      Exit;
    end;
  end;
end;

function TExtensionsToLanguageList.GetLangItem(const WhatLanguage : String) : TExtensionItem;
var
  extensionItem : TExtensionItem;
  i,itemCount : Integer;
begin
  if assigned(lastAccessed) then
  begin
    if lastAccessed.FLanguage=WhatLanguage then
    begin
      Result:=lastAccessed;
      Exit;
    end;
  end;
  Result:=nil;
  itemCount:=Count;
  for i:=0 to (itemCount-1) do
  begin
    extensionItem:=Items[i];
    if extensionItem.FLanguage=WhatLanguage then
    begin
      Result:=extensionItem;
      lastAccessed:=extensionItem;
      Exit;
    end;
  end;
end;

procedure TExtensionsToLanguageList.MapLanguageToExts(const WhatLanguage : String;const AllExtensions : String;CheckWith : TSciLanguageManager);
var
  extensionItem : TExtensionItem;
begin
  if assigned(CheckWith) then
    if CheckWith.HasLanguage(WhatLanguage)=False then
      Exit;
  extensionItem:=GetLangItem(WhatLanguage);
  if not assigned(extensionItem) then
  begin
    extensionItem:=Add;
    extensionItem.Language:=WhatLanguage;
    lastAccessed:=extensionItem;
  end;
  extensionItem.Extensions:=AllExtensions;
end;

function TExtensionMapper.DetectLanguage(const ExtensionToFind : string) : String;
begin
  if FExtensionItems=nil then
  begin
    Result:='null';
    Exit;
  end;
  Result:=FExtensionItems.LanguageFromExt(ExtensionToFind,FExtensionItems.ExtensionSeparator);
end;

procedure TExtensionMapper.SetExtensionItems(Value : TExtensionsToLanguageList);
begin
  FExtensionItems.Assign(Value);
end;

procedure TExtensionItem.Assign(Source: TPersistent);
begin
  if Source is TExtensionItem then
  begin
    FLanguage:=TExtensionItem(Source).Language;
    FExtensions:=TExtensionItem(Source).Extensions;
  end else
  Inherited;
end;

procedure TExtensionItem.SetLanguage(const Value : String);
begin
  FLanguage:=Value;
  Changed(False);
end;

procedure TExtensionItem.SetExtensions(const Value : String);
begin
  FExtensions:=Value;
  Changed(False);
end;

constructor TExtensionsToLanguageList.Create(ItemClass: TCollectionItemClass);
begin
  inherited Create(ItemClass);
  FExtensionSeparator:=';';
end;

procedure TExtensionsToLanguageList.Assign(Source: TPersistent);
begin
  inherited;
  lastAccessed:=nil;
end;

procedure TExtensionsToLanguageList.SetItem(Index:Integer; Value: TExtensionItem);
begin
  inherited SetItem(Index,Value);
end;

function TExtensionsToLanguageList.GetItem(Index:Integer): TExtensionItem;
begin
  Result:=TExtensionItem(inherited GetItem(Index));
end;

function TExtensionsToLanguageList.Add: TExtensionItem;
begin
  Result:=TExtensionItem(inherited Add);
end;

procedure TExtensionsToLanguageList.Delete(Index: Integer);
begin
  lastAccessed:=nil;
  inherited Delete(Index);
end;

initialization

finalization
  FreeAndNil(FExtMap);//added to avoid a memoryleak after a tip by mak
end.
Added src/delphisci/SciKeyBindings.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
{
 Adopted from the DelphiWrapper at http://www.pnotepad.com/scintilla
     $Id: SciKeyBindings.pas,v 1.4 2004/11/13 04:29:50 hdalis Exp $
 History:   29/09/2004 Initial Release with Delphi Scintilla Interface Components
            13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                       generate the help.
            29/10/2004 Changed the shortcuts for Paraup/Paradown/Wordpartleft/wordpartright * commands 'cause it didn't work with
                       []/\ in all languages. Seemed more logical also.
                       removed the commenting of the stuttered commands.. Don't know if these work, but..
                       (hdalis@users.sourceforge.net)
            19/04/2005 Added the TSciCommandRecHeader, TSciCommandRec records.
                       Added the StickyCaret to the command list. (v1.63)
                       Added VCStyle property..
            20/05/2005 Added LoadKeyCommands and SaveKeyCommands (both stream and file).
            09/06/2005 Changed TSciKeyCommandCollection so the Items property and Add returns/sets
                       the corresponding item class, not just TCollectionItem.. No need to cast those anymore.
            12/09/2006 Added the new mappings from scintilla (SCK_WIN,SCK_RWIN,SCK_MENU).
}
{$Include SciCommonDef.Inc}
unit SciKeyBindings;

interface
Uses
  Windows, Classes, Controls, SciSupport,SciResLang;

const KeyFileHeaderSignature =$EDEDED;

Type
  TSciKey = Cardinal;

  //This is the header structure you could use when saving the keys to
  //a file..
  TSciCommandRecHeader=record
    Signature : Integer;
    NumberOfKeys : Integer;
  end;

  //This is the actual key/command.
  TSciCommandRec = record
    ShortCut : TShortCut;
    Command : Integer;
  end;

  function KeyToSciKey(keyIn : word) : word;
  function SciKeyToKey(keyIn : word) : word;
  function ShiftStateToSciMode(Shift : TShiftState) : word;
  function SciModeToShiftState(SciMode : word) : TShiftState;
  function SciKey(Key, Mode : word): TSciKey;
  function SciKeyToShortCut(Key : TSciKey) : TShortCut;
  function ShortCutToSciKey(ShortCut : TShortCut) : TSciKey;

const
  SCI_NORM : word = 0;
  SCI_SHIFT : word = SCMOD_SHIFT;
  SCI_CTRL : word  = SCMOD_CTRL;
  SCI_ALT : word  = SCMOD_ALT;
  SCI_ASHIFT : word = SCMOD_ALT or SCMOD_SHIFT;
  SCI_ACTRL : word = SCMOD_ALT or SCMOD_CTRL;
  SCI_CSHIFT : word = SCMOD_CTRL or SCMOD_SHIFT;
  SCI_ACSHIFT : word = SCMOD_ALT or SCMOD_CTRL or SCMOD_SHIFT;

  Sci_KeyboardCommandMap: array[0..95] of TIdentMapEntry = (
    (Value: SCI_Null; Name: sKeyNoCommand),
    (Value: SCI_CLEAR; Name: sKeyClear),
    (Value: SCI_COPY; Name: sKeyCopy),
    (Value: SCI_CUT; Name: sKeyCut),
    (Value: SCI_PASTE; Name: sKeyPaste),
    (Value: SCI_ZOOMIN; Name: sKeyZoomIn),
    (Value: SCI_ZOOMOUT; Name: sKeyZoomOut),
    (Value: SCI_SETZOOM; Name: sKeyZoomReset),
    (Value: SCI_SELECTALL; Name: sKeySelectAll),
    (Value: SCI_UNDO; Name: sKeyUndo),
    (Value: SCI_REDO; Name: sKeyRedo),
    (Value: SCI_LINEDOWN; Name: sKeyLineDown),
    (Value: SCI_LINEDOWNEXTEND; Name: sKeyLineDownExtend),
    (Value: SCI_LINEDOWNRECTEXTEND; Name: sKeyLineDownRectExtend),
    (Value: SCI_LINESCROLLDOWN; Name: sKeyLineScrollDown),
    (Value: SCI_LINEUP; Name: sKeyLineUp),
    (Value: SCI_LINEUPEXTEND; Name: sKeyLineUpExtend),
    (Value: SCI_LINEUPRECTEXTEND; Name: sKeyLineUpRectExtend),
    (Value: SCI_LINESCROLLUP; Name: sKeyLineScrollUp),
    (Value: SCI_PARADOWN; Name: sKeyLineParaDown),
    (Value: SCI_PARADOWNEXTEND; Name: sKeyLineParaDownExtend),
    (Value: SCI_PARAUP; Name: sKeyLineParaUp),
    (Value: SCI_PARAUPEXTEND; Name: sKeyLineParaUpExtend),
    (Value: SCI_CHARLEFT; Name: sKeyCharLeft),
    (Value: SCI_CHARLEFTEXTEND; Name: sKeyCharLeftExtend),
    (Value: SCI_CHARLEFTRECTEXTEND; Name: sKeyCharLeftRectExtend),
    (Value: SCI_CHARRIGHT; Name: sKeyCharRight),
    (Value: SCI_CHARRIGHTEXTEND; Name: sKeyCharRightExtend),
    (Value: SCI_CHARRIGHTRECTEXTEND; Name: sKeyCharRightRectExtend),
    (Value: SCI_WORDLEFT; Name: sKeyWordLeft),
    (Value: SCI_WORDLEFTEXTEND; Name: sKeyWordLeftExtend),
    (Value: SCI_WORDRIGHT; Name: sKeyWordRight),
    (Value: SCI_WORDRIGHTEXTEND; Name: sKeyWordRightExtend),
    (Value: SCI_WORDLEFTEND; Name: sKeyWordLeftEnd),
    (Value: SCI_WORDLEFTENDEXTEND; Name: sKeyWordLeftEndExtend),
    (Value: SCI_WORDRIGHTEND; Name: sKeyWordRightEnd),
    (Value: SCI_WORDRIGHTENDEXTEND; Name: sKeyWordRightEndExtend),
    (Value: SCI_WORDPARTLEFT; Name: sKeyWordPartLeft),
    (Value: SCI_WORDPARTLEFTEXTEND; Name: sKeyWordPartLeftExtend),
    (Value: SCI_WORDPARTRIGHT; Name: sKeyWordPartRight),
    (Value: SCI_WORDPARTRIGHTEXTEND; Name: sKeyWordPartRightExtend),
    (Value: SCI_HOME; Name: sKeyHome),
    (Value: SCI_HOMEEXTEND; Name: sKeyHomeExtend),
    (Value: SCI_HOMERECTEXTEND; Name: sKeyHomeRectExtend),
    (Value: SCI_HOMEDISPLAY; Name: sKeyHomeDisplay),
    (Value: SCI_HOMEDISPLAYEXTEND; Name: sKeyHomeDisplayExtend),
    (Value: SCI_HOMEWRAP; Name: sKeyHomeWrap),
    (Value: SCI_HOMEWRAPEXTEND; Name: sKeyHomeWrapExtend),
    (Value: SCI_VCHOME; Name: sKeyVCHome),
    (Value: SCI_VCHOMEEXTEND; Name: sKeyVCHomeExtend),
    (Value: SCI_VCHOMERECTEXTEND; Name: sKeyVCHomeRectExtend),
    (Value: SCI_VCHOMEWRAP; Name: sKeyVCHomeWrap),
    (Value: SCI_VCHOMEWRAPEXTEND; Name: sKeyVCHomeWrapExtend),
    (Value: SCI_LINEEND; Name: sKeyLineEnd),
    (Value: SCI_LINEENDEXTEND; Name: sKeyLineEndExtend),
    (Value: SCI_LINEENDRECTEXTEND; Name: sKeyLineEndRectExtend),
    (Value: SCI_LINEENDDISPLAY; Name: sKeyLineEndDisplay),
    (Value: SCI_LINEENDDISPLAYEXTEND; Name: sKeyLineEndDisplayExtend),
    (Value: SCI_LINEENDWRAP; Name: sKeyLineEndWrap),
    (Value: SCI_LINEENDWRAPEXTEND; Name: sKeyLineEndWrapExtend),
    (Value: SCI_DOCUMENTSTART; Name: sKeyDocumentStart),
    (Value: SCI_DOCUMENTSTARTEXTEND; Name: sKeyDocumentStartExtend),
    (Value: SCI_DOCUMENTEND; Name: sKeyDocumentEnd),
    (Value: SCI_DOCUMENTENDEXTEND; Name: sKeyDocumentEndExtend),
    (Value: SCI_PAGEUP; Name: sKeyPageUp),
    (Value: SCI_PAGEUPEXTEND; Name: sKeyPageUpExtend),
    (Value: SCI_PAGEUPRECTEXTEND; Name: sKeyPageUpRectExtend),
    (Value: SCI_PAGEDOWN; Name: sKeyPageDown),
    (Value: SCI_PAGEDOWNEXTEND; Name: sKeyPageDownExtend),
    (Value: SCI_PAGEDOWNRECTEXTEND; Name: sKeyPageDownRectExtend),
    (Value: SCI_STUTTEREDPAGEUP; Name: sKeyStutteredPageUp),
    (Value: SCI_STUTTEREDPAGEUPEXTEND; Name: sKeyStutteredPageUpExtend),
    (Value: SCI_STUTTEREDPAGEDOWN; Name: sKeyStutteredPageDown),
    (Value: SCI_STUTTEREDPAGEDOWNEXTEND; Name: sKeyStutteredPageDownExtend),
    (Value: SCI_DELETEBACK; Name: sKeyDeleteBack),
    (Value: SCI_DELETEBACKNOTLINE; Name: sKeyDeleteBackNotLine),
    (Value: SCI_DELWORDLEFT; Name: sKeyDeleteWordLeft),
    (Value: SCI_DELWORDRIGHT; Name: sKeyDeleteWordRight),
    (Value: SCI_DELLINELEFT; Name: sKeyDeleteLineLeft),
    (Value: SCI_DELLINERIGHT; Name: sKeyDeleteLineRight),
    (Value: SCI_LINEDELETE; Name: sKeyDeleteLine),
    (Value: SCI_DELWORDRIGHT; Name: sKeyDeleteWordRight),
    (Value: SCI_LINECUT; Name: sKeyLineCut),
    (Value: SCI_LINECOPY; Name: sKeyLineCopy),
    (Value: SCI_LINETRANSPOSE; Name: sKeyLineTranspose),
    (Value: SCI_LINEDUPLICATE; Name: sKeyLineDuplicate),
    (Value: SCI_LOWERCASE; Name: sKeyLowerCase),
    (Value: SCI_UPPERCASE; Name: sKeyUpperCase),
    (Value: SCI_CANCEL; Name: sKeyCancel),
    (Value: SCI_EDITTOGGLEOVERTYPE; Name: sKeyToggleOvertype),
    (Value: SCI_NEWLINE; Name: sKeyNewLine),
    (Value: SCI_FORMFEED; Name: sKeyFormFeed),
    (Value: SCI_TAB; Name: sKeyTab),
    (Value: SCI_BACKTAB; Name: sKeyBackTab),
    (Value: SCI_TOGGLECARETSTICKY; Name: sKeyToggleSticky),
    (Value: SCI_SELECTIONDUPLICATE; Name: sSelectionDuplicate)
    );

Type

  TSciKeyCommand = class(TCollectionItem)
  private
    FCommand: Integer;
    FShortCut : TShortCut;
    procedure SetCommand(const Value: Integer);
    procedure SetShortCut(const Value: TShortCut);
  protected
    function GetDisplayName: string; override;
  public
    constructor Create(Collection: TCollection); override;
    procedure Assign(Source: TPersistent); override;
  published
    property Command: Integer read FCommand write SetCommand;
    property ShortCut: TShortCut read FShortCut write SetShortCut;
  end;

  TSciKeyCommandCollection = class(TCollection)
  private
    fEditor : TWinControl; //TScintilla
    fVCStyle : Boolean;
    procedure SetEditor(Editor : TWinControl);
    procedure SetVCStyle(const Value : Boolean);
    function GetItem(Index:Integer): TSciKeyCommand;
    procedure SetItem(Index:Integer; Value: TSciKeyCommand);
  protected
  public
    constructor Create(Editor : TWinControl);
    procedure Assign(Source: TPersistent); override;
    procedure Update(Item: TCollectionItem); override;
    function Add: TSciKeyCommand;
    procedure AddCommandKey(Key, Mode : word; Command : Integer);
    procedure AddRec(const Rec : TSciCommandRec);
    procedure ResetDefaultCommands;
    function FindShortCut(ShortCut: TShortCut) : TSciKeyCommand;
    property Editor : TWinControl read FEditor write SetEditor;
    property VCStyle : Boolean read fVCStyle write SetVCStyle;
    property Items[Index : Integer] : TSciKeyCommand read GetItem write SetItem;default;
  end;

function LoadKeyCommands(Collection : TSciKeyCommandCollection;const filename : String) : Boolean;overload;
function LoadKeyCommands(Collection : TSciKeyCommandCollection;stream : TStream) : Boolean;overload;
function SaveKeyCommands(Collection : TSciKeyCommandCollection;stream : TStream) : Boolean;overload;
function SaveKeyCommands(Collection : TSciKeyCommandCollection;const filename : String) : Boolean;overload;
implementation

Uses
  SciLexerMemo,Menus,SysUtils,sciUtils;

const
  VK_OEM_1 : word = $BA;
  VK_OEM_2 : word = $BF;
  VK_OEM_3 : word = $C0;
  VK_OEM_4 : word = $DB;
  VK_OEM_5 : word = $DC;
  VK_OEM_6 : word = $DD;
function KeyToSciKey(keyIn : word) : word;
begin
  case keyIn of
    VK_DOWN: Result:=SCK_DOWN;
    VK_UP: Result:=SCK_UP;
    VK_LEFT: Result:=SCK_LEFT;
    VK_RIGHT: Result:=SCK_RIGHT;
    VK_HOME: Result:=SCK_HOME;
    VK_END: Result:=SCK_END;
    VK_PRIOR: Result:=SCK_PRIOR;
    VK_NEXT: Result:=SCK_NEXT;
    VK_DELETE: Result:=SCK_DELETE;
    VK_INSERT: Result:=SCK_INSERT;
    VK_ESCAPE: Result:=SCK_ESCAPE;
    VK_BACK: Result:=SCK_BACK;
    VK_TAB: Result:=SCK_TAB;
    VK_Return: Result:=SCK_RETURN;
    VK_ADD: Result:=SCK_ADD;
    VK_SUBTRACT: Result:=SCK_SUBTRACT;
    VK_DIVIDE: Result:=SCK_DIVIDE;
    VK_LWIN: Result:=SCK_WIN;
    VK_RWIN: Result:=SCK_RWIN;
    VK_APPS: Result:=SCK_MENU;
    else
      Result := keyIn;
  end;
end;

function SciKeyToKey(keyIn : word) : word;
begin
  case keyIn of
    SCK_DOWN: Result:=VK_DOWN;
    SCK_UP: Result:=VK_UP;
    SCK_LEFT: Result:=VK_LEFT;
    SCK_RIGHT: Result:=VK_RIGHT;
    SCK_HOME: Result:=VK_HOME;
    SCK_END: Result:=VK_END;
    SCK_PRIOR: Result:=VK_PRIOR;
    SCK_NEXT: Result:=VK_NEXT;
    SCK_DELETE: Result:=VK_DELETE;
    SCK_INSERT: Result:=VK_INSERT;
    SCK_ESCAPE: Result:=VK_ESCAPE;
    SCK_BACK: Result:=VK_BACK;
    SCK_TAB: Result:=VK_TAB;
    SCK_Return: Result:=VK_RETURN;
    SCK_ADD: Result:=VK_ADD;
    SCK_SUBTRACT: Result:=VK_SUBTRACT;
    SCK_DIVIDE: Result:=VK_DIVIDE;
    SCK_WIN: Result:=VK_LWIN;
    SCK_RWIN: Result:=VK_RWIN;
    SCK_MENU: Result:=VK_APPS;
    Ord(';'): Result:=VK_OEM_1;
    Ord('/'): Result:=VK_OEM_2;
    Ord('`'): Result:=VK_OEM_3;
    Ord('['): Result:=VK_OEM_4;
    Ord('\'): Result:=VK_OEM_5;
    Ord(']'): Result:=VK_OEM_6;
    else
      Result := keyIn;
  end;
end;

function ShiftStateToSciMode(Shift : TShiftState) : word;
begin
  Result := 0;
  if ssShift in Shift then Result := Result or SCMOD_SHIFT;
  if ssCtrl  in Shift then Result := Result or SCMOD_CTRL;
  if ssAlt in Shift then Result := Result or SCMOD_ALT;
end;

function SciKey(Key, Mode : word): TSciKey;
begin
  Result := (Cardinal(Mode) shl 16) or Cardinal(Key);
end;

function SciModeToShiftState(SciMode : word) : TShiftState;
begin
  Result := [];
  if SciMode and SCMOD_SHIFT <> 0 then Include(Result, ssShift);
  if SciMode and SCMOD_CTRL <> 0 then Include(Result, ssCtrl);
  if SciMode and SCMOD_ALT <> 0 then Include(Result, ssAlt);
end;

function SciKeyToShortCut(Key : TSciKey) : TShortCut;
begin
  Result := ShortCut(SciKeyToKey(LoWord(Key)), SciModeToShiftState(HiWord(Key)));
end;

function ShortCutToSciKey(ShortCut : TShortCut) : TSciKey;
var
  Key: Word;
  Shift: TShiftState;
begin
  ShortCutToKey(ShortCut, Key, Shift);
  Result := (Cardinal(ShiftStateToSciMode(Shift)) shl 16) or Cardinal(KeyToSciKey(Key));
end;


{ TSciKeyCommandCollection }
constructor TSciKeyCommandCollection.Create(Editor: TWinControl);
begin
  fVCStyle:=True;
  inherited Create(TSciKeyCommand);
  FEditor := Editor;
  ResetDefaultCommands;
end;

procedure TSciKeyCommandCollection.Assign(Source: TPersistent);
begin
  if Source is TSciKeyCommandCollection then
  begin
    fVCStyle:=TSciKeyCommandCollection(Source).VCStyle;
  end;
  inherited Assign(Source);
end;

procedure TSciKeyCommandCollection.Update(Item: TCollectionItem);
Var
  i : Integer;
begin
  inherited;
  if (not Assigned(fEditor)) or (not FEditor.HandleAllocated) then Exit;
  if Assigned(Item) then
  with (Item as TSciKeyCommand) do
    TScintillaMemo(fEditor).AssignCmdKey(ShortCutToSciKey(FShortCut), FCommand)
  else
  begin
    TScintillaMemo(fEditor).ClearAllCmdKeys;
    for i := 0 to Count - 1 do with (Items[i] as TSciKeyCommand) do
      TScintillaMemo(fEditor).AssignCmdKey(ShortCutToSciKey(FShortCut), FCommand);
  end;
end;

function TSciKeyCommandCollection.GetItem(Index:Integer): TSciKeyCommand;
begin
  Result:=TSciKeyCommand(inherited GetItem(Index));
end;

procedure TSciKeyCommandCollection.SetItem(Index:Integer; Value: TSciKeyCommand);
begin
  inherited SetItem(Index,Value);
end;

function TSciKeyCommandCollection.Add: TSciKeyCommand;
begin
  Result:=TSciKeyCommand(inherited Add);
end;

procedure TSciKeyCommandCollection.AddCommandKey(Key, Mode: word;
  Command: Integer);
Var
  KeyCommand : TSciKeyCommand;
begin
  KeyCommand := Add as TSciKeyCommand;
  KeyCommand.FCommand := Command;
  KeyCommand.FShortCut := SciKeyToShortCut(SciKey(Key, Mode));
end;

procedure TSciKeyCommandCollection.AddRec(const Rec : TSciCommandRec);
Var
  KeyCommand : TSciKeyCommand;
begin
  KeyCommand := Add as TSciKeyCommand;
  KeyCommand.FCommand := Rec.Command;
  KeyCommand.FShortCut := Rec.ShortCut;
end;

procedure TSciKeyCommandCollection.SetVCStyle(const Value : Boolean);
var
  i,cnt : Integer;
  cmd : TSciKeyCommand;
begin
  fVCStyle:=Value;
  cnt:=Count;
  for i:=0 to (cnt-1) do
  begin
    cmd :=Items[i];
    if fVCStyle=False then
    begin
      case cmd.FCommand of
        SCI_VCHOME: cmd.Command:=SCI_HOME;
        SCI_VCHOMEEXTEND: cmd.Command:=SCI_HOMEEXTEND;
        SCI_VCHOMEWRAP: cmd.Command:=SCI_HOMEWRAP;
        SCI_VCHOMEWRAPEXTEND: cmd.Command:=SCI_HOMEWRAPEXTEND;
        SCI_VCHOMERECTEXTEND: cmd.Command:=SCI_HOMERECTEXTEND;
      end;
    end else
    begin
      case cmd.FCommand of
        SCI_HOME: cmd.Command:=SCI_VCHOME;
        SCI_HOMEEXTEND: cmd.Command:=SCI_VCHOMEEXTEND;
        SCI_HOMEWRAP: cmd.Command:=SCI_VCHOMEWRAP;
        SCI_HOMEWRAPEXTEND: cmd.Command:=SCI_VCHOMEWRAPEXTEND;
        SCI_HOMERECTEXTEND: cmd.Command:=SCI_VCHOMERECTEXTEND;
      end;
    end;
  end;
end;

function TSciKeyCommandCollection.FindShortCut(ShortCut: TShortCut): TSciKeyCommand;
var
  i : Integer;
  KeyCommand : TSciKeyCommand;
begin
  Result := nil;
  for i := 0 to Count - 1 do begin
    KeyCommand := Items[i] as TSciKeyCommand;
    if KeyCommand.ShortCut = ShortCut then
    begin
      Result := KeyCommand;
      Exit;
    end;
  end;
end;

procedure TSciKeyCommandCollection.ResetDefaultCommands;
begin
  // Set Default Commands
  BeginUpdate;
  try
    Clear;
    AddCommandKey(SCK_DOWN,SCI_NORM,SCI_LINEDOWN);
    AddCommandKey(SCK_DOWN,SCI_SHIFT,SCI_LINEDOWNEXTEND);
    AddCommandKey(SCK_DOWN,SCI_CTRL,SCI_LINESCROLLDOWN);
    AddCommandKey(SCK_DOWN,SCI_ASHIFT,SCI_LINEDOWNRECTEXTEND);
    AddCommandKey(SCK_UP,SCI_NORM,SCI_LINEUP);
    AddCommandKey(SCK_UP,SCI_SHIFT,SCI_LINEUPEXTEND);
    AddCommandKey(SCK_UP,SCI_CTRL,SCI_LINESCROLLUP);
    AddCommandKey(SCK_UP,SCI_ASHIFT,SCI_LINEUPRECTEXTEND);
    AddCommandKey(SCK_UP,SCI_ACTRL, SCI_PARAUP);
    AddCommandKey(SCK_UP,SCI_ACSHIFT,SCI_PARAUPEXTEND);
    AddCommandKey(SCK_DOWN,SCI_ACTRL,SCI_PARADOWN);
    AddCommandKey(SCK_DOWN,SCI_ACSHIFT,SCI_PARADOWNEXTEND);
    AddCommandKey(SCK_LEFT,SCI_NORM,SCI_CHARLEFT);
    AddCommandKey(SCK_LEFT,SCI_SHIFT,SCI_CHARLEFTEXTEND);
    AddCommandKey(SCK_LEFT,SCI_CTRL,SCI_WORDLEFT);
    AddCommandKey(SCK_LEFT,SCI_CSHIFT,SCI_WORDLEFTEXTEND);
    AddCommandKey(SCK_LEFT,SCI_ASHIFT,SCI_CHARLEFTRECTEXTEND);
    AddCommandKey(SCK_RIGHT,SCI_NORM,SCI_CHARRIGHT);
    AddCommandKey(SCK_RIGHT,SCI_SHIFT,SCI_CHARRIGHTEXTEND);
    AddCommandKey(SCK_RIGHT,SCI_CTRL,SCI_WORDRIGHT);
    AddCommandKey(SCK_RIGHT,SCI_CSHIFT,SCI_WORDRIGHTEXTEND);
    AddCommandKey(SCK_RIGHT,SCI_ASHIFT,SCI_CHARRIGHTRECTEXTEND);
    AddCommandKey(SCK_LEFT,SCI_ACTRL,SCI_WORDPARTLEFT);
    AddCommandKey(SCK_LEFT,SCI_ACSHIFT,SCI_WORDPARTLEFTEXTEND);
    AddCommandKey(SCK_RIGHT,SCI_ACTRL,SCI_WORDPARTRIGHT);
    AddCommandKey(SCK_RIGHT,SCI_ACSHIFT,SCI_WORDPARTRIGHTEXTEND);
    if fVCStyle=True then
    begin
      AddCommandKey(SCK_HOME,SCI_NORM,SCI_VCHOME);
      AddCommandKey(SCK_HOME, SCI_SHIFT, SCI_VCHOMEEXTEND);
      AddCommandKey(SCK_HOME,SCI_ASHIFT,SCI_VCHOMERECTEXTEND);
    end else
    begin
      AddCommandKey(SCK_HOME,SCI_NORM,SCI_HOME);
      AddCommandKey(SCK_HOME, SCI_SHIFT, SCI_HOMEEXTEND);
      AddCommandKey(SCK_HOME,SCI_ASHIFT,SCI_HOMERECTEXTEND);
    end;
    AddCommandKey(SCK_HOME, SCI_CTRL, SCI_DOCUMENTSTART);
    AddCommandKey(SCK_HOME, SCI_CSHIFT, SCI_DOCUMENTSTARTEXTEND);
    AddCommandKey(SCK_HOME, SCI_ALT, SCI_HOMEDISPLAY);
    AddCommandKey(SCK_END,SCI_NORM,SCI_LINEEND);
    AddCommandKey(SCK_END,SCI_SHIFT,SCI_LINEENDEXTEND);
    AddCommandKey(SCK_END,SCI_CTRL,SCI_DOCUMENTEND);
    AddCommandKey(SCK_END,SCI_CSHIFT,SCI_DOCUMENTENDEXTEND);
    AddCommandKey(SCK_END,SCI_ALT,SCI_LINEENDDISPLAY);
    AddCommandKey(SCK_END,SCI_ASHIFT,SCI_LINEENDRECTEXTEND);
    AddCommandKey(SCK_PRIOR,SCI_NORM,SCI_PAGEUP);
    AddCommandKey(SCK_PRIOR,SCI_SHIFT,SCI_PAGEUPEXTEND);
    AddCommandKey(SCK_PRIOR,SCI_ASHIFT,SCI_PAGEUPRECTEXTEND);
    AddCommandKey(SCK_NEXT,SCI_NORM,SCI_PAGEDOWN);
    AddCommandKey(SCK_NEXT,SCI_SHIFT,SCI_PAGEDOWNEXTEND);
    AddCommandKey(SCK_NEXT,SCI_ASHIFT,SCI_PAGEDOWNRECTEXTEND);
    AddCommandKey(SCK_DELETE,SCI_NORM,SCI_CLEAR);
    AddCommandKey(SCK_DELETE,SCI_SHIFT,SCI_CUT);
    AddCommandKey(SCK_DELETE,SCI_CTRL,SCI_DELWORDRIGHT);
    AddCommandKey(SCK_DELETE,SCI_CSHIFT,SCI_DELLINERIGHT);
    AddCommandKey(SCK_INSERT,SCI_NORM,SCI_EDITTOGGLEOVERTYPE);
    AddCommandKey(SCK_INSERT,SCI_SHIFT,SCI_PASTE);
    AddCommandKey(SCK_INSERT,SCI_CTRL,SCI_COPY);
    AddCommandKey(SCK_ESCAPE,SCI_NORM,SCI_CANCEL);
    AddCommandKey(SCK_BACK,SCI_NORM,SCI_DELETEBACK);
    AddCommandKey(SCK_BACK,SCI_SHIFT,SCI_DELETEBACK);
    AddCommandKey(SCK_BACK,SCI_CTRL,SCI_DELWORDLEFT);
    AddCommandKey(SCK_BACK,SCI_ALT,SCI_UNDO);
    AddCommandKey(SCK_BACK,SCI_CSHIFT,SCI_DELLINELEFT);
    AddCommandKey(Ord('Z'),SCI_CTRL,SCI_UNDO);
    AddCommandKey(Ord('Y'),SCI_CTRL,SCI_REDO);
    AddCommandKey(Ord('X'),SCI_CTRL,SCI_CUT);
    AddCommandKey(Ord('C'),SCI_CTRL,SCI_COPY);
    AddCommandKey(Ord('V'),SCI_CTRL,SCI_PASTE);
    AddCommandKey(Ord('A'),SCI_CTRL,SCI_SELECTALL);
    AddCommandKey(SCK_TAB,SCI_NORM,SCI_TAB);
    AddCommandKey(SCK_TAB,SCI_SHIFT,SCI_BACKTAB);
    AddCommandKey(SCK_RETURN,SCI_NORM,SCI_NEWLINE);
    AddCommandKey(SCK_RETURN,SCI_SHIFT,SCI_NEWLINE);
    AddCommandKey(SCK_ADD,SCI_CTRL,SCI_ZOOMIN);
    AddCommandKey(SCK_SUBTRACT,SCI_CTRL,SCI_ZOOMOUT);
    AddCommandKey(SCK_DIVIDE,SCI_CTRL,SCI_SETZOOM);
    AddCommandKey(Ord('L'),SCI_CTRL,SCI_LINECUT);
    AddCommandKey(Ord('L'),SCI_CSHIFT,SCI_LINEDELETE);
    AddCommandKey(Ord('T'),SCI_CSHIFT,SCI_LINECOPY);
    AddCommandKey(Ord('T'),SCI_CTRL,SCI_LINETRANSPOSE);
    AddCommandKey(Ord('D'),SCI_CTRL,SCI_SELECTIONDUPLICATE);
    //AddCommandKey(Ord('D'),SCI_CTRL,SCI_LINEDUPLICATE);
    AddCommandKey(Ord('U'),SCI_CTRL,SCI_LOWERCASE);
    AddCommandKey(Ord('U'),SCI_CSHIFT,SCI_UPPERCASE);
  finally
    EndUpdate;
  end;
end;

procedure TSciKeyCommandCollection.SetEditor(Editor: TWinControl);
begin
  FEditor := Editor;
end;

{TSciKeyCommand}
constructor TSciKeyCommand.Create(Collection: TCollection);
begin
  inherited;
  FCommand := SCI_NULL;
end;

procedure TSciKeyCommand.Assign(Source: TPersistent);
begin
  if Source is TSciKeyCommand then
  begin
    FShortCut := TSciKeyCommand(Source).FShortCut;
    FCommand := TSciKeyCommand(Source).FCommand;
  end else
    inherited;
end;

function TSciKeyCommand.GetDisplayName: string;
begin
  if ShortCut = 0 then
    Result := sNoKey
  else
    Result := ShortCutToText(FShortCut);
end;

procedure TSciKeyCommand.SetCommand(const Value: Integer);
begin
  FCommand := Value;
  Changed(False);
end;

procedure TSciKeyCommand.SetShortCut(const Value: TShortCut);
begin
  FShortCut := Value;
  Changed(False);
end;

function SaveKeyCommands(Collection : TSciKeyCommandCollection;stream : TStream) : Boolean;
var
  cmd : TSciKeyCommand;
  rec : TSciCommandRec;
  rechdr : TSciCommandRecHeader;
  i,cnt : Integer;
begin
  Result:=False;
  if assigned(stream) then
  begin
    cnt:=Collection.Count;
    rechdr.Signature:=KeyFileHeaderSignature;
    rechdr.NumberOfKeys:=cnt;
    stream.Write(rechdr,SizeOf(rechdr));
    for i:=0 to (cnt-1) do
    begin
      cmd:=Collection.Items[i];
      rec.ShortCut:=cmd.ShortCut;
      rec.Command:=cmd.Command;
      stream.Write(rec,SizeOf(rec));
    end;
    Result:=true;
  end;
end;

function SaveKeyCommands(Collection : TSciKeyCommandCollection;const filename : String) : Boolean;
var
  fs : TFileStream;
begin
  fs:=nil;
  try
    fs:=TFileStream.Create(filename,fmCreate);
    Result:=SaveKeyCommands(Collection,fs);
    FreeAndNil(fs);
  except
    on Exception do
      begin
        Result:=false;
      end;
  end;
end;

function LoadKeyCommands(Collection : TSciKeyCommandCollection;stream : TStream) : Boolean;
var
  i,cnt : Integer;
  rec : TSciCommandRec;
  rechdr : TSciCommandRecHeader;
begin
    Result:=false;
    try
      if assigned(stream) then
      begin
        Collection.Clear;
        stream.Read(rechdr,SizeOf(rechdr));
        if rechdr.Signature=KeyFileHeaderSignature then
        begin
          cnt:=rechdr.NumberOfKeys;
          for i:=0 to (cnt-1) do
          begin
            stream.Read(rec,SizeOf(rec));
            Collection.AddRec(rec);
          end;
          Result:=true;
        end else
          Result:=False;
      end;
    except
      on Exception do
        begin
          Result:=false;
        end;
    end;
end;

function LoadKeyCommands(Collection : TSciKeyCommandCollection;const filename : String) : Boolean;
var
  fs : TFileStream;
begin
  Result:=false;
  fs:=nil;
  if FExists(filename) then
  begin
    try
      fs:=TFileStream.Create(filename,fmOpenRead);
      Result:=LoadKeyCommands(Collection,fs);
      FreeAndNil(fs);
    except
      on Exception do
        begin
          Result:=false;
        end;
    end;
  end;
end;

end.
Added src/delphisci/SciKeyEditForm.ddp.

cannot compute difference between binary files

Added src/delphisci/SciKeyEditForm.dfm.




















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
object KeyEditForm: TKeyEditForm
  Left = 337
  Top = 176
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  Caption = 'Edit Key Assignment'
  ClientHeight = 114
  ClientWidth = 287
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBtnText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poOwnerFormCenter
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object basePanel: TPanel
    Left = 0
    Top = 0
    Width = 287
    Height = 114
    Align = alClient
    BevelOuter = bvNone
    TabOrder = 0
    object Label1: TLabel
      Left = 9
      Top = 44
      Width = 50
      Height = 13
      Caption = 'Command:'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
    end
    object Label2: TLabel
      Left = 15
      Top = 14
      Width = 44
      Height = 13
      Caption = 'ShortCut:'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
    end
    object cmbCommand: TComboBox
      Left = 66
      Top = 40
      Width = 208
      Height = 21
      Hint = 'Select the command to be executed when this shortcut is entered'
      Style = csDropDownList
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ItemHeight = 13
      ParentFont = False
      ParentShowHint = False
      ShowHint = True
      Sorted = True
      TabOrder = 0
    end
    object btnOK: TBitBtn
      Left = 16
      Top = 74
      Width = 75
      Height = 25
      TabOrder = 1
      Kind = bkOK
    end
    object btnCancel: TBitBtn
      Left = 196
      Top = 74
      Width = 75
      Height = 25
      TabOrder = 2
      Kind = bkCancel
    end
  end
end
Added src/delphisci/SciKeyEditForm.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
{
 Adopted from the DelphiWrapper at http://www.pnotepad.com/scintilla
     $Id: SciKeyEditForm.pas,v 1.4 2004/11/13 04:29:50 hdalis Exp $
 History:   29/09/2004 Initial Release with Delphi Scintilla Interface Components
            13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                       generate the help.
}
{$Include SciCommonDef.Inc}
unit SciKeyEditForm;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  ComCtrls, StdCtrls, ExtCtrls, Buttons;

type
  TSciAssignKeyEvent = procedure (Sender: TObject;Key : TShortCut;var Allow : Boolean) of object;

  TSciHotKeyControl=class(TCustomEdit)
    private
      FHotKeyChange : TNotifyEvent;
      function GetHotKey : TShortCut;
      procedure SetHotKey(Value : TShortCut);
      function NoState(KeyString : string): string;
    protected
      procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
      procedure KeyDown(var Key: Word; Shift: TShiftState); override;
      procedure KeyUp(var Key: Word; Shift: TShiftState); override;
      procedure KeyPress(var Key: Char); override;
      procedure DoExit; override;
    public
    published
      property HotKey : TShortCut read GetHotKey write SetHotKey;
      property OnHotKeyChange : TNotifyEvent read FHotKeyChange write FHotKeyChange;
      property Color;
      property Font;
  end;

  TKeyEditForm = class(TForm)
    basePanel: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    cmbCommand: TComboBox;
    btnOK: TBitBtn;
    btnCancel: TBitBtn;
    procedure FormCreate(Sender: TObject);

  private
    FOnTryAssign : TSciAssignKeyEvent;
    FInitialKey : TShortCut;
    procedure HotKeyChange(Sender: TObject);
    { Private declarations }
    procedure SetInitialKey(Value : TShortCut);
  public
    HotKey: TSciHotKeyControl;
    { Public declarations }
    constructor Create(AOwner : TComponent);override;
    property InitialKey : TShortCut read FInitialKey write SetInitialKey;
    property OnTryAssign : TSciAssignKeyEvent read FOnTryAssign write FOnTryAssign;
  end;

implementation
{$R *.dfm}

Uses
  SciKeyBindings,Menus;

const
  cNoKey='None';
  cShiftKey='Shift+';
  cAltKey='Alt+';
  cCtrlKey='Ctrl+';

procedure TKeyEditForm.SetInitialKey(Value : TShortCut);
begin
  FInitialKey:=Value;
  HotKey.HotKey:=FInitialKey;
end;
constructor TKeyEditForm.Create(AOwner : TComponent);
begin
  inherited;
  HotKey := TSciHotKeyControl.Create(Self);

  with HotKey do
  begin
    Name := 'HotKey';
    Parent := basePanel;
    //Left := 67;
    Top := 11;
    //Width := 143;
    Left:=cmbCommand.Left;
    Width:=cmbCommand.Width;
    Height := 19;
    Color:=clWindow;
    Font.Color := clWindowText;

    Hint := 'Press the keystroke you''d like to assign to the command';
    HotKey := 0;
    ParentShowHint := False;
    ShowHint := True;
    Visible:=True;
  end;
  HotKey.OnHotKeyChange:=HotKeyChange;
end;

procedure TKeyEditForm.FormCreate(Sender: TObject);
var
  i : Integer;
begin
  cmbCommand.Clear;
  cmbCommand.Items.BeginUpdate;
  try
    for i := 0 to High(Sci_KeyboardCommandMap) do
      cmbCommand.AddItem(Sci_KeyboardCommandMap[i].Name, TObject(Sci_KeyboardCommandMap[i].Value));
    cmbCommand.ItemIndex := -1;
  finally
    cmbCommand.Items.EndUpdate;
  end;
end;

procedure TKeyEditForm.HotKeyChange(Sender: TObject);
var
  Allow : Boolean;
begin
  if (HotKey.HotKey<>FInitialKey) then
  begin
    Allow:=True;
    if assigned(FOnTryAssign) then
    begin
      FOnTryAssign(Self,HotKey.HotKey,Allow);
    end;
    if Allow=False then
      HotKey.HotKey:=FInitialKey;
  end;
end;

procedure TSciHotKeyControl.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
  inherited;
  Message.Result := Message.Result or DLGC_WANTCHARS or DLGC_WANTARROWS or DLGC_WANTALLKEYS or DLGC_WANTTAB or DLGC_WANTMESSAGE;
end;
procedure TSciHotKeyControl.KeyDown(var Key: Word; Shift: TShiftState);
var
  tmp : String;
begin
  tmp:='';
  if ssShift in Shift then tmp:=tmp+cShiftKey;
  if ssCtrl in Shift then tmp:=tmp+cCtrlKey;
  if ssAlt in Shift then tmp:=tmp+cAltKey;
  if not((Key=VK_CONTROL) or (Key=VK_SHIFT) or (Key=VK_MENU)) then
    tmp:=tmp+Menus.ShortCutToText(Key);
  if (Length(tmp)=1) then
    tmp:=cNoKey;
  if AnsiCompareStr(Text,tmp)<>0 then
    Text:=tmp;
  Key:=0;
  SelStart:=Length(Text);
end;

procedure TSciHotKeyControl.KeyPress(var Key: Char);
begin
  if (Text=cNoKey) or (NoState(Text)='') then Key:=#0;
  if (Length(Text)>0) and (NoState(Text)<>'') then Key := #0;
end;

procedure TSciHotKeyControl.KeyUp(var Key: Word;Shift: TShiftState);
begin
  if (Length(Text)>0) and (NoState(Text)='') then
  begin
    Text := cNoKey;
    SelStart := Length(Text);
  end else
  begin
    if assigned(FHotKeyChange) then FHotKeyChange(Self);
  end;
  Key:=0;
end;

function TSciHotKeyControl.GetHotKey : TShortCut;
begin
  Result:=Menus.TextToShortCut(Text);
end;
procedure TSciHotKeyControl.SetHotKey(Value : TShortCut);
begin
  if Value=0 then
    Text:=cNoKey
  else
    Text:=Menus.ShortCutToText(Value);
end;

procedure TSciHotKeyControl.DoExit;
begin
  inherited;
  if (Length(Text)>0) and (NoState(Text) = '') then
  begin
    Text := cNoKey;
    SelStart := length(Text);
    if assigned(FHotKeyChange) then FHotKeyChange(Self);
  end;
end;

function TSciHotKeyControl.NoState(KeyString : string): string;
begin
  if Copy(KeyString,1,5) = cCtrlKey then Delete(KeyString,1,5);
  if Copy(KeyString,1,4) = cAltKey then Delete(KeyString,1,4);
  if Copy(KeyString,1,6) = cShiftKey then Delete(KeyString,1,6);
  Result := KeyString;
end;

end.
Added src/delphisci/SciLexer.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
{
Unit    : SciLexer
Purpose : Interface for Scintilla Lexer DLL
Created : 05/03/2001
Original Author  : Simon Steele (ss@pnotepad.org)
Author: Jan Martin Pettersen (hdalis@users.sourceforge.net) (starting from 29/09/2004)
      $Id: SciLexer.pas,v 1.5 2004/11/13 04:29:50 hdalis Exp $
History :  05/03/2001 Turned this into a proper VCL wrapper for Scintilla
                      class window controls. SetFocus is not entirely right,
                      and is overridden by the scintilla thing. To set focus do:
                      Scintilla1.SetFocus(True);
                      Windows.SetFocus(Scintilla1.Handle);
                      There's no error checking yet, so make sure the DLL is
                      present!
                      Daytime :): Added Event handling generation stuff, and
                      some ported types from scintilla.h so that event handling can work!
           19/03/2001 Added FindText stuff, needs updating in the python...
           25/03/2001 Changed SCI_REPLACESEL Wrapper variable order - it was wrong!
           27/05/2001 Re-Wrote the python generator, and changed the structure of the
                      control.
           09/06/2001 Removed some function-less functions.
           03/12/2001 Added WM_ERASEBKGND function to remove scroll-flicker. Thanks
                      to Gertjan Schuurmans and Jeff Cogswell.
           15/02/2003 Extensive changes to make the control active at design time and
                      expose a large number of properties (see KV comments)
                      (kvlahos@london.edu)
           15/03/2003 LoadFromStream and SaveToStream added which now
                      properly handle Unicode.  Property CodeFolding added
                      (kvlahos@london.edu)
           05/11/2003 Workaround for Scintilla bug in GetSelText
                      Updated for Scintilla 1.56 (works with later versions)
                      Other improvements and bug fixes
                      (kvlahos@london.edu)
           01/03/2004 Python and Ruby Keywords and Styles added
                      Keyboard customisation
                      Help file added
           29/09/2004 Updated for Scintilla 1.61
                      Changed the component into a baseclass for other components.
                      Removed some properties, and placed them in the derived
                      TScintilla component. Added some select functions etc.
                      Added WordChars property to allow use by autocomplete etc.
                      Most properties are protected now, to be exposed in derived
                      in derived subclasses.
                      Changed the notificationinterface to call virtual functions
                      so they can be overridden in derived classes.
                      Adopted and translated to delphi some functions from SciTE
                      for use with the components.
                      Added option to clear undo after save.
                      Changed propertynames to resemble other edit controls such
                      as TRichEdit etc. (SelText,SelStart,SelLength etc)

                      All styledefinitions moved to ScintillaSynLexer.inc
                      and scilangfiller.pas. No longer used anywhere but at designtime.
                      Many more language keywords/styles added.
                      These are only used at designtime via the 'Fill with default Languages'
                      menu option.
                      Changed the enumerated lexerselection to strings (more flexibility)
                      (hdalis@users.sourceforge.net)
           13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                      generate the help.
                      hdalis@users.sourceforge.net
           02/11/2004 Refreshed against version 1.62 of scintilla.iface
           09/11/2004 SelectionFileName added two extra bytes (nullbytes), Fixed.
                      A bug was found in RangeIsAllWhiteSpace. It did exactly the opposite
                      of what it should do.
                      hdalis@users.sourceforge.net
           11/11/2004 Removed the IsDirty property. Modified did just the same actually.
                      hdalis@users.sourceforge.net
           22/11/2004 The scintilla control wouldn't let go of the mouse when the
                      mouse was clicked inside a selection and you then moved the mouse
                      outside the control (to another control)
                      Fixed it with a small hack, added the MouseMove procedure to
                      detect if we are outside the control when both the left and right
                      mousebutton wasn't down.
                      There is still a little problem in the designer, doubleclick on the
                      scintilla control sends only mousedown so the componenteditor isn't
                      executed on a doubleclick , don't know why..
                      It all works at runtime however..
                      hdalis@users.sourceforge.net
           11/12/2004 Changed all LongBool to Boolean 'cause the LongBool style wasn't very appreciated
                      by Scintilla when the .dll was optimized for Pentium, and all optimizations enabled.
                      If fired the same assert in scintillas code all the time. Fixed.
                      hdalis@users.sourceforge.net
           12/03/2005 Added GetDelphiSciVersion and GetDelphiSciVersionStr
                      hdalis@users.sourceforge.net
           04/05/2005 BUGFIX 01:
                      Fixed a bug which caused that if any char keys pressed triggered
                      the mnemoniced control when the key matched the mnemonics without ALT.
                      hdalis@users.sourceforge.net
           04/05/2005 Added the GetDelphiSciVersion,GetDelphiSciVersionStr,GetDelphiSciURL,
                      for easy use in an aboutbox.
           01/08/2005 Refreshed against version 1.65 of scintilla.iface

           01/08/2005 You can now override LoadFromStream and SaveToStream very easily,
                      without deriving a class just for that purpose.
                      Now you derive a class from TSciStreamBase, and add your own
                      implementation, then set the StreamClass property to the specific
                      class. Every call to TScintillaBase's SaveTo* and LoadFrom* will then
                      use that class..

                      NOTE: Just read & save the text, the SetSavePoint calling
                      and others are called from within the TScintillaBase.SaveToStream/
                      TScintillaBase.LoadFromStream, which also is those which calls the
                      class's implementation of the functions.

                      NOTE: It is the TScintillaBase functions that CREATES the class specified
                      in the TScintillaBase.StreamClass property, so make sure that the default settings
                      of the class is what you want.. i.e if you have a class which can save
                      in multiple encodings, derive a class for each of them, and set the
                      proper variables/properties in the constructor, and remember to call inherited.
                      hdalis@users.sourceforge.net
                      
           24.08.2005 Refreshed against version 1.66 (CVS)
                      hdalis@users.sourceforge.net

           24.08.2005 YOU MUST set the StreamClass property to a class of your choosing to
                      use the Save* or Load* functions.

                      If you want you can set it to TSciStreamDefault to use the behavior below,
                      or write your own implementation.

                      In the TSciStreamDefault class, in the implementation of SaveToStream and LoadFromStream
                      the CodePage property are still temporarily changed to cpDefault, loads any file (as an ansi file), and
                      then is set to cpUTF8 again.

                      The StreamClass does enable whoever to write a derived class of TSciStreamBase
                      and assign the classname to StreamClass, and as such just replace the Load* and Save*
                      functions.

                      I'm working on the proper reading/writing of unicode when detected, and still
                      also accept loading/saving ansi text.

           23.03.2006 Now you can define USEDEFAULTSTREAMBYDEFAULT inside SciCommonDef.Inc to automatically
                      assign TSciStreamDefault when creating TScintilla*. This is optional because not everyone
                      would be interested in adding this code, such as when using their own StreamClass.

           ......     Assorted changes.
           12.09.2006 Added LinkTo and Unlink procedures.
                      These allow one scintilla component to link to another, so you can have multiple views
                      of the same document (Make note: If you change the document pointer yourself (SETDOCPOINTER),
                      or use the TSciDocTabCtrl make sure you relink them when changing, as it is not done automatically.
                      Also note: The linked components do not share styling (you can however use CopyFrom to copy styles
                      and assorted settings from another, not including positional properties etc).
}
{$Include SciCommonDef.Inc}
{$UNDEF USEWMERASE}
{ Most of this file is automatically generated from the Scintilla.iface interface definition
  file which contains any comments about the definitions. PasGen.py does the generation.
  Please use the corresponding scintilla.iface file when you regenerate the code.
}

unit SciLexer;
interface
uses Classes, Windows, Controls, Forms, Messages, SysUtils, Graphics,  StdActns, SciSupport;

const
  BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);
  SCITE_MARKER_BOOKMARK=1; //The marker number for the bookmark functions.

//These constants are defined to easily assign to the WordChars property.
sci_alphachars='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
sci_numericchars='0123456789';
sci_accentedchars='ŠšŒœŸÿÀàÁáÂâÃãÄäÅ寿ÇçÈèÉéÊêËëÌìÍíÎîÏïÐðÑñÒòÓóÔôÕõÖØøÙùÚúÛûÜüÝýÞþßö';
nullHighlighter='null';

type
    CodePageType=0..$7ffffff;
    TTestingFunction=function (const ch : LongInt) : boolean;
  //++EventTypes
    TSCEvent_styleneeded = procedure(Sender : TObject; const position : LongInt) of object;
    TSCEvent_charadded = procedure(Sender : TObject; const ch : LongInt) of object;
    TSCEvent_savepointreached = procedure(Sender : TObject) of object;
    TSCEvent_savepointleft = procedure(Sender : TObject) of object;
    TSCEvent_modifyattemptro = procedure(Sender : TObject) of object;
    TSCEvent_doubleclick = procedure(Sender : TObject) of object;
    TSCEvent_updateui = procedure(Sender : TObject) of object;
    TSCEvent_modified = procedure(Sender : TObject; const position : LongInt; const modificationType : LongInt; text : PChar; const len : LongInt; const linesAdded : LongInt; const line : LongInt; const foldLevelNow : LongInt; const foldLevelPrev : LongInt) of object;
    TSCEvent_macrorecord = procedure(Sender : TObject; const message : LongInt; const wParam : LongInt; const lParam : LongInt) of object;
    TSCEvent_marginclick = procedure(Sender : TObject; const modifiers : LongInt; const position : LongInt; const margin : LongInt) of object;
    TSCEvent_needshown = procedure(Sender : TObject; const position : LongInt; const len : LongInt) of object;
    TSCEvent_painted = procedure(Sender : TObject) of object;
    TSCEvent_userlistselection = procedure(Sender : TObject; const listType : LongInt; text : PChar) of object;
    TSCEvent_dwellstart = procedure(Sender : TObject; const position : LongInt) of object;
    TSCEvent_dwellend = procedure(Sender : TObject; const position : LongInt) of object;
    TSCEvent_zoom = procedure(Sender : TObject) of object;
    TSCEvent_hotspotclick = procedure(Sender : TObject; const modifiers : LongInt; const position : LongInt) of object;
    TSCEvent_hotspotdoubleclick = procedure(Sender : TObject; const modifiers : LongInt; const position : LongInt) of object;
    TSCEvent_calltipclick = procedure(Sender : TObject; const position : LongInt) of object;
    TSCEvent_autocselection = procedure(Sender : TObject; text : PChar) of object;
//--EventTypes
    TSCEventMsgSent = procedure(Sender : TObject; Msg : Integer; wParam, lParam : LongInt) of object;
  //Lex
  ExtLexerFn=procedure(lexernum,startPos : Cardinal;length,initStyle : Integer;words : array of PChar;window : THandle;props : PChar);stdcall;
  //Fold
  ExtFoldFn=procedure(lexernum,startPos : Cardinal;length,initStyle : Integer;words : array of PChar;window : THandle;props : PChar);stdcall;
  ////Not used yet it seems.
  GetLexerFn=function (Index : Integer) : Pointer;stdcall;
  //GetLexerCount
  GetLexerCountFn=function : Integer;stdcall;
  //GetLexerName
  GetlexerNameFn=procedure(Index : Cardinal;name : PChar;buflen : Integer);stdcall;
  TWordWrapType=(sciNoWrap,sciWrap,sciWrapChar);
  TScintillaBase=class;
  ESciException=class(Exception);
  

  { This class is the baseclass for saving and loading from streams.
    This is separated into a separate class to allow others
    to override the SaveToStream and LoadFromStream procedures
    easily without deriving a new component, to support proper
    saving of Unicode,UTF8,Ansi etc..

    Usage: Do NOT use directly.. Derive from this class, and
    set the property StreamClass to the the name of the class
    (C++ Builder users: Use the __classid(ClassName) function).

    The created class is used each time the SaveToStream, LoadFromStream,
    SaveToFile or LoadFromFile is called, but an instantiation of
    the class is created only when the StreamClass changes,
    otherwise it uses the currently instantiated class (if any)..

    TSciStreamBase is an abstract class.

    TScintillaBase and derivatives do not set any StreamClass itself,
    so if you want to use Save* and Load*, then you need to assign
    a class to StreamClass yourself..

    For basic saving and loading you can use the
    class TSciStreamDefault found in SciStreamDefault.pas
  }

  TSciStreamBase=class(TObject)
  protected
    FEditor : TScintillaBase;
  public
    constructor Create(Editor : TScintillaBase);virtual;
    {This is called from TScintillaBase.SaveToStream}
    procedure SaveToStream(Stream : TStream);virtual;abstract;
    {This is called from TScintillaBase.LoadFromStream}
    procedure LoadFromStream(Stream : TStream);virtual;abstract;
    {This can optionally return some integer data, such as the encodingmode for the last file loaded.}
    function GetData : Integer;virtual;abstract;
    {This can optionally set some integer data, such as the encodingmode to use when saving.}
    procedure SetData(Value : Integer);virtual;abstract;
    {This can optionally return some string data, such as the encodingmode for the last file loaded.}
    function GetDataStr : String;virtual;abstract;
    {This can optionally set some string data, such as the encodingmode to use when saving.}
    procedure SetDataStr(const Value : String);virtual;abstract;
  end;

  TSciStreamClass=class of TSciStreamBase;
  TScintillaBase = class(TWinControl)
  private
    FBorderStyle : TBorderStyle;
    SCPerform : TScintillaMessageFnc;
    sccmdctr : Pointer;
    initing,FCreating,FWantReturns,FWantTabs,
    FDirty,FDummy,FClearUndoAfterSave, FForceMouseRelease : Boolean;
    FOnMsgSent : TSCEventMsgSent;
    FWordChars : String;
    oldmodeventmask : LongInt;
    fStateStream : TMemoryStream;
    FStreamer : TSciStreamBase;
    FStreamClass : TSciStreamClass;
    FCodePage : CodePageType;
//++EventPrivates
        FOnstyleneeded : TSCEvent_styleneeded;
        FOncharadded : TSCEvent_charadded;
        FOnsavepointreached : TSCEvent_savepointreached;
        FOnsavepointleft : TSCEvent_savepointleft;
        FOnmodifyattemptro : TSCEvent_modifyattemptro;
        FOndoubleclick : TSCEvent_doubleclick;
        FOnupdateui : TSCEvent_updateui;
        FOnmodified : TSCEvent_modified;
        FOnmacrorecord : TSCEvent_macrorecord;
        FOnmarginclick : TSCEvent_marginclick;
        FOnneedshown : TSCEvent_needshown;
        FOnpainted : TSCEvent_painted;
        FOnuserlistselection : TSCEvent_userlistselection;
        FOndwellstart : TSCEvent_dwellstart;
        FOndwellend : TSCEvent_dwellend;
        FOnzoom : TSCEvent_zoom;
        FOnhotspotclick : TSCEvent_hotspotclick;
        FOnhotspotdoubleclick : TSCEvent_hotspotdoubleclick;
        FOncalltipclick : TSCEvent_calltipclick;
        FOnautocselection : TSCEvent_autocselection;
//--EventPrivates
    procedure SetBorderStyle(Value: TBorderStyle);
    procedure CMCtl3DChanged(var Message: TMessage); message CM_CTL3DCHANGED;
    procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
    procedure WMNCDestroy(var Message: TWMNCDestroy); message WM_NCDESTROY;
    procedure WMNotify(var Message: TWMNotify); message CN_NOTIFY;
{$Ifdef USEWMERASE}
    procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
{$Endif}
    procedure inSetWordChars(const Value : String);
    procedure SetDummy(Value : Boolean);
    procedure inSetCodePage(const Value : CodePageType);
    function inGetCodePage : CodePageType;
    function GetWordWrap: TWordWrapType;
    procedure SetWordWrap(const Value: TWordWrapType);
    function GetSelection: string;
    procedure SetSelection(const Value: string);
    procedure SetSelStart(const value : LongInt);
    function GetSelectionLength : LongInt;                // Returns length of selection
    procedure SetSelectionLength(const Value : LongInt);
    procedure SetStreamClass(Value : TSciStreamClass);
    function GetStreamer : TSciStreamBase;
  protected
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; //handles the case when scintilla wont let go of the mouse.
    procedure WndDestroy;virtual;
    procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
    procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
    procedure Loaded; override;
    procedure CreateParams(var Params: TCreateParams); override;
    procedure CreateWnd; override;
    procedure DestroyWnd; override;
    // Scintilla Eventwrappers
    procedure doSciCharAdded(const ch : Integer); virtual;
    procedure doSciUserListSelection(const listType : LongInt; text : PChar); virtual;
    procedure doSciUpdateUI;virtual;
    procedure doSciModified(const position : LongInt; const modificationType : LongInt;text : PChar; const len : LongInt; const linesAdded : LongInt; const line : LongInt;const foldLevelNow : LongInt; const foldLevelPrev : LongInt);virtual;
    procedure doSciMarginClick(const modifiers : LongInt; const position : LongInt; const margin : LongInt);virtual;
    procedure doSciSavePointReached;virtual;
    procedure doSciSavePointLeft;virtual;
    procedure doSciStyleNeeded(const position : Integer);virtual;
    procedure doSciModifyAttemptRO;virtual;
    procedure doSciDoubleClick;virtual;
    procedure doSciNeedShown(const position : Integer;const len : Integer);virtual;
    procedure doSciPainted;virtual;
    procedure doSciDwellStart(const position : Integer);virtual;
    procedure doSciDwellEnd(const position : Integer);virtual;
    procedure doSciZoom;virtual;
    procedure doSciHotspotClick(const modifiers : Integer;const position : Integer);virtual;
    procedure doSciHotspotDoubleClick(const modifiers : Integer;const position : Integer);virtual;
    procedure doSciMacroRecord(const msg : Integer;const wParam : uptr_t;const lParam : sptr_t);virtual;
    procedure doSciCalltipClick(const position : Integer);virtual;
    procedure doSciAutoCSelection(const text : PChar);virtual;
    // End of Scintilla Eventwrappers
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure DefaultHandler(var Message); override;
    function SPerform(Msg : LongInt; wParam : LongInt=0; lParam : LongInt=0) : LongInt;
    procedure DisableAllEvents(disable : Boolean);
    procedure AddTextStr(const Text : String);
    procedure InsertTextStr(const pos : LongInt;Text : String);
    procedure DeleteWordRightAndSkip;

//++FuncDef
    procedure AddText(length : LongInt; text : PChar);
    procedure AddStyledText(length : LongInt; c : PChar);
    procedure InsertText(pos : LongInt; text : PChar);
    procedure ClearAll;
    procedure ClearDocumentStyle;
    function GetLength : LongInt;
    function GetCharAt(pos : LongInt) : LongInt;
    function GetCurrentPos : LongInt;
    function GetAnchor : LongInt;
    function GetStyleAt(pos : LongInt) : LongInt;
    procedure Redo;
    procedure SetUndoCollection(collectUndo : Boolean);
    procedure SelectAll;
    procedure SetSavePoint;
    function GetStyledText(tr : PTextRange) : LongInt;
    function CanRedo : Boolean;
    function MarkerLineFromHandle(handle : LongInt) : LongInt;
    procedure MarkerDeleteHandle(handle : LongInt);
    function GetUndoCollection : Boolean;
    function GetViewWS : LongInt;
    procedure SetViewWS(viewWS : LongInt);
    function PositionFromPoint(x : LongInt; y : LongInt) : LongInt;
    function PositionFromPointClose(x : LongInt; y : LongInt) : LongInt;
    procedure GotoLine(line : LongInt);
    procedure GotoPos(pos : LongInt);
    procedure SetAnchor(posAnchor : LongInt);
    function GetCurLine(length : LongInt; text : PChar) : LongInt;
    function GetEndStyled : LongInt;
    procedure ConvertEOLs(eolMode : LongInt);
    function GetEOLMode : LongInt;
    procedure SetEOLMode(eolMode : LongInt);
    procedure StartStyling(pos : LongInt; mask : LongInt);
    procedure SetStyling(length : LongInt; style : LongInt);
    function GetBufferedDraw : Boolean;
    procedure SetBufferedDraw(buffered : Boolean);
    procedure SetTabWidth(tabWidth : LongInt);
    function GetTabWidth : LongInt;
    procedure SetCodePage(codePage : LongInt);
    procedure SetUsePalette(usePalette : Boolean);
    procedure MarkerDefine(markerNumber : LongInt; markerSymbol : LongInt);
    procedure MarkerSetFore(markerNumber : LongInt; fore : TColor);
    procedure MarkerSetBack(markerNumber : LongInt; back : TColor);
    function MarkerAdd(line : LongInt; markerNumber : LongInt) : LongInt;
    procedure MarkerDelete(line : LongInt; markerNumber : LongInt);
    procedure MarkerDeleteAll(markerNumber : LongInt);
    function MarkerGet(line : LongInt) : LongInt;
    function MarkerNext(lineStart : LongInt; markerMask : LongInt) : LongInt;
    function MarkerPrevious(lineStart : LongInt; markerMask : LongInt) : LongInt;
    procedure MarkerDefinePixmap(markerNumber : LongInt; pixmap : PChar);
    procedure MarkerAddSet(line : LongInt; Mask : LongInt);
    procedure MarkerSetAlpha(markerNumber : LongInt; alpha : LongInt);
    procedure SetMarginTypeN(margin : LongInt; marginType : LongInt);
    function GetMarginTypeN(margin : LongInt) : LongInt;
    procedure SetMarginWidthN(margin : LongInt; pixelWidth : LongInt);
    function GetMarginWidthN(margin : LongInt) : LongInt;
    procedure SetMarginMaskN(margin : LongInt; mask : LongInt);
    function GetMarginMaskN(margin : LongInt) : LongInt;
    procedure SetMarginSensitiveN(margin : LongInt; sensitive : Boolean);
    function GetMarginSensitiveN(margin : LongInt) : Boolean;
    procedure StyleClearAll;
    procedure StyleSetFore(style : LongInt; fore : TColor);
    procedure StyleSetBack(style : LongInt; back : TColor);
    procedure StyleSetBold(style : LongInt; bold : Boolean);
    procedure StyleSetItalic(style : LongInt; italic : Boolean);
    procedure StyleSetSize(style : LongInt; sizePoints : LongInt);
    procedure StyleSetFont(style : LongInt; fontName : PChar);
    procedure StyleSetEOLFilled(style : LongInt; filled : Boolean);
    procedure StyleResetDefault;
    procedure StyleSetUnderline(style : LongInt; underline : Boolean);
    procedure StyleSetCase(style : LongInt; caseForce : LongInt);
    procedure StyleSetCharacterSet(style : LongInt; characterSet : LongInt);
    procedure StyleSetHotSpot(style : LongInt; hotspot : Boolean);
    procedure SetSelFore(useSetting : Boolean; fore : TColor);
    procedure SetSelBack(useSetting : Boolean; back : TColor);
    function GetSelAlpha : LongInt;
    procedure SetSelAlpha(alpha : LongInt);
    procedure SetCaretFore(fore : TColor);
    procedure AssignCmdKey(km : LongInt; msg : LongInt);
    procedure ClearCmdKey(km : LongInt);
    procedure ClearAllCmdKeys;
    procedure SetStylingEx(length : LongInt; styles : PChar);
    procedure StyleSetVisible(style : LongInt; visible : Boolean);
    function GetCaretPeriod : LongInt;
    procedure SetCaretPeriod(periodMilliseconds : LongInt);
    procedure SetWordChars(characters : PChar);
    procedure BeginUndoAction;
    procedure EndUndoAction;
    procedure IndicSetStyle(indic : LongInt; style : LongInt);
    function IndicGetStyle(indic : LongInt) : LongInt;
    procedure IndicSetFore(indic : LongInt; fore : TColor);
    function IndicGetFore(indic : LongInt) : TColor;
    procedure SetWhitespaceFore(useSetting : Boolean; fore : TColor);
    procedure SetWhitespaceBack(useSetting : Boolean; back : TColor);
    procedure SetStyleBits(bits : LongInt);
    function GetStyleBits : LongInt;
    procedure SetLineState(line : LongInt; state : LongInt);
    function GetLineState(line : LongInt) : LongInt;
    function GetMaxLineState : LongInt;
    function GetCaretLineVisible : Boolean;
    procedure SetCaretLineVisible(show : Boolean);
    function GetCaretLineBack : TColor;
    procedure SetCaretLineBack(back : TColor);
    procedure StyleSetChangeable(style : LongInt; changeable : Boolean);
    procedure AutoCShow(lenEntered : LongInt; itemList : PChar);
    procedure AutoCCancel;
    function AutoCActive : Boolean;
    function AutoCPosStart : LongInt;
    procedure AutoCComplete;
    procedure AutoCStops(characterSet : PChar);
    procedure AutoCSetSeparator(separatorCharacter : LongInt);
    function AutoCGetSeparator : LongInt;
    procedure AutoCSelect(text : PChar);
    procedure AutoCSetCancelAtStart(cancel : Boolean);
    function AutoCGetCancelAtStart : Boolean;
    procedure AutoCSetFillUps(characterSet : PChar);
    procedure AutoCSetChooseSingle(chooseSingle : Boolean);
    function AutoCGetChooseSingle : Boolean;
    procedure AutoCSetIgnoreCase(ignoreCase : Boolean);
    function AutoCGetIgnoreCase : Boolean;
    procedure UserListShow(listType : LongInt; itemList : PChar);
    procedure AutoCSetAutoHide(autoHide : Boolean);
    function AutoCGetAutoHide : Boolean;
    procedure AutoCSetDropRestOfWord(dropRestOfWord : Boolean);
    function AutoCGetDropRestOfWord : Boolean;
    procedure RegisterImage(type_ : LongInt; xpmData : PChar);
    procedure ClearRegisteredImages;
    function AutoCGetTypeSeparator : LongInt;
    procedure AutoCSetTypeSeparator(separatorCharacter : LongInt);
    procedure AutoCSetMaxWidth(characterCount : LongInt);
    function AutoCGetMaxWidth : LongInt;
    procedure AutoCSetMaxHeight(rowCount : LongInt);
    function AutoCGetMaxHeight : LongInt;
    procedure SetIndent(indentSize : LongInt);
    function GetIndent : LongInt;
    procedure SetUseTabs(useTabs : Boolean);
    function GetUseTabs : Boolean;
    procedure SetLineIndentation(line : LongInt; indentSize : LongInt);
    function GetLineIndentation(line : LongInt) : LongInt;
    function GetLineIndentPosition(line : LongInt) : LongInt;
    function GetColumn(pos : LongInt) : LongInt;
    procedure SetHScrollBar(show : Boolean);
    function GetHScrollBar : Boolean;
    procedure SetIndentationGuides(show : Boolean);
    function GetIndentationGuides : Boolean;
    procedure SetHighlightGuide(column : LongInt);
    function GetHighlightGuide : LongInt;
    function GetLineEndPosition(line : LongInt) : LongInt;
    function GetCodePage : LongInt;
    function GetCaretFore : TColor;
    function GetUsePalette : Boolean;
    function GetReadOnly : Boolean;
    procedure SetCurrentPos(pos : LongInt);
    procedure SetSelectionStart(pos : LongInt);
    function GetSelectionStart : LongInt;
    procedure SetSelectionEnd(pos : LongInt);
    function GetSelectionEnd : LongInt;
    procedure SetPrintMagnification(magnification : LongInt);
    function GetPrintMagnification : LongInt;
    procedure SetPrintColourMode(mode : LongInt);
    function GetPrintColourMode : LongInt;
    function FindTextX(flags : LongInt; ft : PTextToFind) : LongInt;
    function FormatRange(draw : Boolean; fr : PRangeToFormat) : LongInt;
    function GetFirstVisibleLine : LongInt;
    function GetLine(line : LongInt; text : PChar) : LongInt;
    function GetLineCount : LongInt;
    procedure SetMarginLeft(pixelWidth : LongInt);
    function GetMarginLeft : LongInt;
    procedure SetMarginRight(pixelWidth : LongInt);
    function GetMarginRight : LongInt;
    function GetModify : Boolean;
    procedure SetSel(start : LongInt; end_ : LongInt);
    function GetSelText(text : PChar) : LongInt;
    function GetTextRange(tr : PTextRange) : LongInt;
    procedure HideSelection(normal : Boolean);
    function PointXFromPosition(pos : LongInt) : LongInt;
    function PointYFromPosition(pos : LongInt) : LongInt;
    function LineFromPosition(pos : LongInt) : LongInt;
    function PositionFromLine(line : LongInt) : LongInt;
    procedure LineScroll(columns : LongInt; lines : LongInt);
    procedure ScrollCaret;
    procedure ReplaceSel(text : PChar);
    procedure SetReadOnly(readOnly : Boolean);
    procedure Null;
    function CanPaste : Boolean;
    function CanUndo : Boolean;
    procedure EmptyUndoBuffer;
    procedure Undo;
    procedure Cut;
    procedure Copy;
    procedure Paste;
    procedure Clear;
    procedure SetText(text : PChar);
    function GetText(length : LongInt; text : PChar) : LongInt;
    function GetTextLength : LongInt;
    function GetDirectFunction : LongInt;
    function GetDirectPointer : LongInt;
    procedure SetOvertype(overtype : Boolean);
    function GetOvertype : Boolean;
    procedure SetCaretWidth(pixelWidth : LongInt);
    function GetCaretWidth : LongInt;
    procedure SetTargetStart(pos : LongInt);
    function GetTargetStart : LongInt;
    procedure SetTargetEnd(pos : LongInt);
    function GetTargetEnd : LongInt;
    function ReplaceTarget(length : LongInt; text : PChar) : LongInt;
    function ReplaceTargetRE(length : LongInt; text : PChar) : LongInt;
    function SearchInTarget(length : LongInt; text : PChar) : LongInt;
    procedure SetSearchFlags(flags : LongInt);
    function GetSearchFlags : LongInt;
    procedure CallTipShow(pos : LongInt; definition : PChar);
    procedure CallTipCancel;
    function CallTipActive : Boolean;
    function CallTipPosStart : LongInt;
    procedure CallTipSetHlt(start : LongInt; end_ : LongInt);
    procedure CallTipSetBack(back : TColor);
    procedure CallTipSetFore(fore : TColor);
    procedure CallTipSetForeHlt(fore : TColor);
    procedure CallTipUseStyle(tabSize : LongInt);
    function VisibleFromDocLine(line : LongInt) : LongInt;
    function DocLineFromVisible(lineDisplay : LongInt) : LongInt;
    function WrapCount(line : LongInt) : LongInt;
    procedure SetFoldLevel(line : LongInt; level : LongInt);
    function GetFoldLevel(line : LongInt) : LongInt;
    function GetLastChild(line : LongInt; level : LongInt) : LongInt;
    function GetFoldParent(line : LongInt) : LongInt;
    procedure ShowLines(lineStart : LongInt; lineEnd : LongInt);
    procedure HideLines(lineStart : LongInt; lineEnd : LongInt);
    function GetLineVisible(line : LongInt) : Boolean;
    procedure SetFoldExpanded(line : LongInt; expanded : Boolean);
    function GetFoldExpanded(line : LongInt) : Boolean;
    procedure ToggleFold(line : LongInt);
    procedure EnsureVisible(line : LongInt);
    procedure SetFoldFlags(flags : LongInt);
    procedure EnsureVisibleEnforcePolicy(line : LongInt);
    procedure SetTabIndents(tabIndents : Boolean);
    function GetTabIndents : Boolean;
    procedure SetBackSpaceUnIndents(bsUnIndents : Boolean);
    function GetBackSpaceUnIndents : Boolean;
    procedure SetMouseDwellTime(periodMilliseconds : LongInt);
    function GetMouseDwellTime : LongInt;
    function WordStartPosition(pos : LongInt; onlyWordCharacters : Boolean) : LongInt;
    function WordEndPosition(pos : LongInt; onlyWordCharacters : Boolean) : LongInt;
    procedure SetWrapMode(mode : LongInt);
    function GetWrapMode : LongInt;
    procedure SetWrapVisualFlags(wrapVisualFlags : LongInt);
    function GetWrapVisualFlags : LongInt;
    procedure SetWrapVisualFlagsLocation(wrapVisualFlagsLocation : LongInt);
    function GetWrapVisualFlagsLocation : LongInt;
    procedure SetWrapStartIndent(indent : LongInt);
    function GetWrapStartIndent : LongInt;
    procedure SetLayoutCache(mode : LongInt);
    function GetLayoutCache : LongInt;
    procedure SetScrollWidth(pixelWidth : LongInt);
    function GetScrollWidth : LongInt;
    function TextWidth(style : LongInt; text : PChar) : LongInt;
    procedure SetEndAtLastLine(endAtLastLine : Boolean);
    function GetEndAtLastLine : Boolean;
    function TextHeight(line : LongInt) : LongInt;
    procedure SetVScrollBar(show : Boolean);
    function GetVScrollBar : Boolean;
    procedure AppendText(length : LongInt; text : PChar);
    function GetTwoPhaseDraw : Boolean;
    procedure SetTwoPhaseDraw(twoPhase : Boolean);
    procedure TargetFromSelection;
    procedure LinesJoin;
    procedure LinesSplit(pixelWidth : LongInt);
    procedure SetFoldMarginColour(useSetting : Boolean; back : TColor);
    procedure SetFoldMarginHiColour(useSetting : Boolean; fore : TColor);
    procedure LineDown;
    procedure LineDownExtend;
    procedure LineUp;
    procedure LineUpExtend;
    procedure CharLeft;
    procedure CharLeftExtend;
    procedure CharRight;
    procedure CharRightExtend;
    procedure WordLeft;
    procedure WordLeftExtend;
    procedure WordRight;
    procedure WordRightExtend;
    procedure Home;
    procedure HomeExtend;
    procedure LineEnd;
    procedure LineEndExtend;
    procedure DocumentStart;
    procedure DocumentStartExtend;
    procedure DocumentEnd;
    procedure DocumentEndExtend;
    procedure PageUp;
    procedure PageUpExtend;
    procedure PageDown;
    procedure PageDownExtend;
    procedure EditToggleOvertype;
    procedure Cancel;
    procedure DeleteBack;
    procedure Tab;
    procedure BackTab;
    procedure NewLine;
    procedure FormFeed;
    procedure VCHome;
    procedure VCHomeExtend;
    procedure ZoomIn;
    procedure ZoomOut;
    procedure DelWordLeft;
    procedure DelWordRight;
    procedure LineCut;
    procedure LineDelete;
    procedure LineTranspose;
    procedure LineDuplicate;
    procedure LowerCase;
    procedure UpperCase;
    procedure LineScrollDown;
    procedure LineScrollUp;
    procedure DeleteBackNotLine;
    procedure HomeDisplay;
    procedure HomeDisplayExtend;
    procedure LineEndDisplay;
    procedure LineEndDisplayExtend;
    procedure HomeWrap;
    procedure HomeWrapExtend;
    procedure LineEndWrap;
    procedure LineEndWrapExtend;
    procedure VCHomeWrap;
    procedure VCHomeWrapExtend;
    procedure LineCopy;
    procedure MoveCaretInsideView;
    function LineLength(line : LongInt) : LongInt;
    procedure BraceHighlight(pos1 : LongInt; pos2 : LongInt);
    procedure BraceBadLight(pos : LongInt);
    function BraceMatch(pos : LongInt) : LongInt;
    function GetViewEOL : Boolean;
    procedure SetViewEOL(visible : Boolean);
    function GetDocPointer : LongInt;
    procedure SetDocPointer(pointer : LongInt);
    procedure SetModEventMask(mask : LongInt);
    function GetEdgeColumn : LongInt;
    procedure SetEdgeColumn(column : LongInt);
    function GetEdgeMode : LongInt;
    procedure SetEdgeMode(mode : LongInt);
    function GetEdgeColour : TColor;
    procedure SetEdgeColour(edgeColour : TColor);
    procedure SearchAnchor;
    function SearchNext(flags : LongInt; text : PChar) : LongInt;
    function SearchPrev(flags : LongInt; text : PChar) : LongInt;
    function LinesOnScreen : LongInt;
    procedure UsePopUp(allowPopUp : Boolean);
    function SelectionIsRectangle : Boolean;
    procedure SetZoom(zoom : LongInt);
    function GetZoom : LongInt;
    function CreateDocument : LongInt;
    procedure AddRefDocument(doc : LongInt);
    procedure ReleaseDocument(doc : LongInt);
    function GetModEventMask : LongInt;
    procedure SetFocusEx(focus : Boolean);
    function GetFocus : Boolean;
    procedure SetStatus(statusCode : LongInt);
    function GetStatus : LongInt;
    procedure SetMouseDownCaptures(captures : Boolean);
    function GetMouseDownCaptures : Boolean;
    procedure SetCursor(cursorType : LongInt);
    function GetCursor : LongInt;
    procedure SetControlCharSymbol(symbol : LongInt);
    function GetControlCharSymbol : LongInt;
    procedure WordPartLeft;
    procedure WordPartLeftExtend;
    procedure WordPartRight;
    procedure WordPartRightExtend;
    procedure SetVisiblePolicy(visiblePolicy : LongInt; visibleSlop : LongInt);
    procedure DelLineLeft;
    procedure DelLineRight;
    procedure SetXOffset(newOffset : LongInt);
    function GetXOffset : LongInt;
    procedure ChooseCaretX;
    procedure GrabFocus;
    procedure SetXCaretPolicy(caretPolicy : LongInt; caretSlop : LongInt);
    procedure SetYCaretPolicy(caretPolicy : LongInt; caretSlop : LongInt);
    procedure SetPrintWrapMode(mode : LongInt);
    function GetPrintWrapMode : LongInt;
    procedure SetHotspotActiveFore(useSetting : Boolean; fore : TColor);
    procedure SetHotspotActiveBack(useSetting : Boolean; back : TColor);
    procedure SetHotspotActiveUnderline(underline : Boolean);
    procedure SetHotspotSingleLine(singleLine : Boolean);
    procedure ParaDown;
    procedure ParaDownExtend;
    procedure ParaUp;
    procedure ParaUpExtend;
    function PositionBefore(pos : LongInt) : LongInt;
    function PositionAfter(pos : LongInt) : LongInt;
    procedure CopyRange(start : LongInt; end_ : LongInt);
    procedure CopyText(length : LongInt; text : PChar);
    procedure SetSelectionMode(mode : LongInt);
    function GetSelectionMode : LongInt;
    function GetLineSelStartPosition(line : LongInt) : LongInt;
    function GetLineSelEndPosition(line : LongInt) : LongInt;
    procedure LineDownRectExtend;
    procedure LineUpRectExtend;
    procedure CharLeftRectExtend;
    procedure CharRightRectExtend;
    procedure HomeRectExtend;
    procedure VCHomeRectExtend;
    procedure LineEndRectExtend;
    procedure PageUpRectExtend;
    procedure PageDownRectExtend;
    procedure StutteredPageUp;
    procedure StutteredPageUpExtend;
    procedure StutteredPageDown;
    procedure StutteredPageDownExtend;
    procedure WordLeftEnd;
    procedure WordLeftEndExtend;
    procedure WordRightEnd;
    procedure WordRightEndExtend;
    procedure SetWhitespaceChars(characters : PChar);
    procedure SetCharsDefault;
    function AutoCGetCurrent : LongInt;
    procedure Allocate(bytes : LongInt);
    function FindColumn(line : LongInt; column : LongInt) : LongInt;
    function GetCaretSticky : Boolean;
    procedure SetCaretSticky(useCaretStickyBehaviour : Boolean);
    procedure ToggleCaretSticky;
    procedure SetPasteConvertEndings(convert : Boolean);
    function GetPasteConvertEndings : Boolean;
    procedure SelectionDuplicate;
    procedure SetCaretLineBackAlpha(alpha : LongInt);
    function GetCaretLineBackAlpha : LongInt;
    procedure StartRecord;
    procedure StopRecord;
    procedure SetLexer(lexer : LongInt);
    function GetLexer : LongInt;
    procedure Colourise(start : LongInt; end_ : LongInt);
    procedure SetProperty(key : PChar; value : PChar);
    procedure SetKeyWords(keywordSet : LongInt; keyWords : PChar);
    procedure SetLexerLanguage(language : PChar);
    procedure LoadLexerLibrary(path : PChar);
    function GetProperty(key : PChar; buf : PChar) : LongInt;
    function GetPropertyExpanded(key : PChar; buf : PChar) : LongInt;
    function GetPropertyInt(key : PChar) : LongInt;
    function GetStyleBitsNeeded : LongInt;
//--FuncDef
  protected
//++EventProperties
    property OnStyleNeeded : TSCEvent_styleneeded read FOnstyleneeded write FOnstyleneeded;
    property OnCharAdded : TSCEvent_charadded read FOncharadded write FOncharadded;
    property OnSavePointReached : TSCEvent_savepointreached read FOnsavepointreached write FOnsavepointreached;
    property OnSavePointLeft : TSCEvent_savepointleft read FOnsavepointleft write FOnsavepointleft;
    property OnModifyAttemptRO : TSCEvent_modifyattemptro read FOnmodifyattemptro write FOnmodifyattemptro;
    property OnDoubleClick : TSCEvent_doubleclick read FOndoubleclick write FOndoubleclick;
    property OnUpdateUI : TSCEvent_updateui read FOnupdateui write FOnupdateui;
    property OnModified : TSCEvent_modified read FOnmodified write FOnmodified;
    property OnMacroRecord : TSCEvent_macrorecord read FOnmacrorecord write FOnmacrorecord;
    property OnMarginClick : TSCEvent_marginclick read FOnmarginclick write FOnmarginclick;
    property OnNeedShown : TSCEvent_needshown read FOnneedshown write FOnneedshown;
    property OnPainted : TSCEvent_painted read FOnpainted write FOnpainted;
    property OnUserListSelection : TSCEvent_userlistselection read FOnuserlistselection write FOnuserlistselection;
    property OnDwellStart : TSCEvent_dwellstart read FOndwellstart write FOndwellstart;
    property OnDwellEnd : TSCEvent_dwellend read FOndwellend write FOndwellend;
    property OnZoom : TSCEvent_zoom read FOnzoom write FOnzoom;
    property OnHotSpotClick : TSCEvent_hotspotclick read FOnhotspotclick write FOnhotspotclick;
    property OnHotSpotDoubleClick : TSCEvent_hotspotdoubleclick read FOnhotspotdoubleclick write FOnhotspotdoubleclick;
    property OnCallTipClick : TSCEvent_calltipclick read FOncalltipclick write FOncalltipclick;
    property OnAutoCSelection : TSCEvent_autocselection read FOnautocselection write FOnautocselection;
//--EventProperties
    property OnMsgSent : TSCEventMsgSent read FOnMsgSent Write FOnMsgSent;
  public
    procedure CopyFrom(Source: TScintillaBase); virtual;
    procedure LoadFromStream(Stream : TStream);
    procedure LoadFromFile(const FileName : TFileName);
    procedure SaveToStream(Stream : TStream);
    procedure SaveToFile(const FileName : TFileName);

    // Get the range from 'start' to 'end_' into the buffer 'text'
    procedure GetRange(const start, end_ : LongInt; text : PChar);
    // Get the line 'linenum' into the buffer 'textbuf' of size 'sizeText'
    procedure GetLineInBuf(textbuf : PChar; const sizeText : LongInt; linenum : LongInt=-1);
    // Get the line as a AnsiString
    function GetLineS(const Index: LongInt=-1): string;

    // Returns start and end position for selection
    function GetSelectionRng : TCharacterRange;
    // Returns start and end_ positions for the current word.
    procedure FindWordAtCaret(var start : LongInt;var end_ : LongInt);
      // Extend selection both ways while ischarforsel function returns true
    function RangeExtendAndGrab(var selStart,selEnd : LongInt;ischarforsel : TTestingFunction;const stripEol : Boolean=true) : String;
      // Extend selection both ways while ischarforsel function returns true
    function SelectionExtend(ischarforsel : TTestingFunction;const stripEol : Boolean =true) : String;
    procedure SetSelectionS(const anchor, end_ : LongInt);      // Set selection start and end

    // Selects the word under the cursor.
    function SelectWordAtCaret : boolean;
    // Selects the word under the cursor determined by IsWordChar.
    function SelectionWord(const stripEol : Boolean =true) : String;
    // Retrieved text by style 'styleNum'
    function SelectByStyle(const styleNum : Integer;const xpos : Integer=-1;const mask : Integer=$1f) : String;
    // Sets selection by style 'styleNum'
    function SetSelectionByStyle(const styleNum : Integer;const xpos : Integer=-1;const mask : Integer=$1f) : Boolean;
    // Selects the filename under the cursor determined by IsFilenameChar.
    function SelectionFileName : String;

    // Get length of line, -1 is current line
    function GetLineLength(const line : LongInt=-1) : LongInt;
    function GetCurrentScrollPosition : LongInt;
    // Get Caret Position in current line
    function GetCaretInLine : LongInt;
    // Returns the current linenumber
    function GetCurrentLineNumber : LongInt;
    // Test if the range are only whitespace
    function RangeIsAllWhiteSpace(const start, end_ : LongInt) : boolean;
    //Ensure that the range is visible
    procedure EnsureRangeVisible(const PosStart, PosEnd: LongInt);
    // Goto line and ensure it's visible
    procedure GotoLineEnsureVisible(const line : LongInt);
      { Ensure a text range is visible - make visible if necessary }
    function ExecuteAction(Action: TBasicAction): boolean; override;
      { Standard Delphi edit action support }
    function UpdateAction(Action: TBasicAction): boolean; override;
      { Standard Delphi edit action support }
    procedure SetModified(const Value: Boolean);
    procedure ClearDocument;
    procedure LinkTo(otherSciDoc : TScintillaBase);
    procedure UnLink;

    //Make the text buffer read-only. Can't change the text of the control in any way when readonly, even by code.
    property ReadOnly : Boolean read GetReadOnly write SetReadOnly default false;
    property SelLength : LongInt read GetSelectionLength write SetSelectionLength;
    property SelStart : LongInt read GetSelectionStart write SetSelStart;
    property SelText : string read GetSelection write SetSelection;
    property WordWrap : TWordWrapType read GetWordWrap write SetWordWrap;
    property ClearUndoAfterSave  : boolean read FClearUndoAfterSave write FClearUndoAfterSave default False;
    property Dummy : Boolean read FDummy Write SetDummy; //  Added by KV
    property Modified : Boolean read GetModify write SetModified;
    property WordChars : String read FWordChars write inSetWordChars;
    property StreamClass : TSciStreamClass read FStreamClass write SetStreamClass;
    property Streamer : TSciStreamBase read GetStreamer;
    property CodePage : CodePageType read inGetCodePage write inSetCodePage;

  published
    property Color;
    property Font;
    property PopupMenu;
    property Align;
    property Hint;
    property ShowHint;
    property ParentShowHint;
    property ParentFont default False;
    property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
    property Visible;
    property ForceMouseRelease : Boolean read FForceMouseRelease write FForceMouseRelease default True;
  end;
  {TScintillaProt is for use with TScintilla when creating it dynamically
   as Loaded doesnt seem to be called automatically.
   Use it like this (Scintilla1 is the TScintilla component):
   TScintillaProt(Scintilla1).Loaded;
  }
  TScintillaProt=class(TScintillaBase)
    public
    procedure Loaded;override;
  end;

  {The below functions are the preferred way to include the info about this component in an
   About box or similar. You are welcome to style/wrap the produced text as you wish}

  //Returns the current version number of DelphiSci
  function GetDelphiSciVersion : Integer;
  //Returns the Copyright string for DelphiSci
  function GetDelphiSciVersionStr : String;
  //Returns the URL where you can obtain a copy of DelphiSci
  function GetDelphiSciURL : String;

  {The codepage enum/string conversion}
  procedure GetCodePageValues(Proc: TGetStrProc);
  function CodePageToIdent(CodePage: Longint; var Ident: string): Boolean;
  function IdentToCodePage(const Ident: string; var CodePage: Longint): Boolean;

const
  cpUTF8=CodePageType(SC_CP_UTF8);
  cpAnsi=CodePageType(SC_CHARSET_ANSI);
  cpDefault=CodePageType(SC_CHARSET_DEFAULT);
  cpBaltic=CodePageType(SC_CHARSET_BALTIC);
  cpChineseBig5=CodePageType(SC_CHARSET_CHINESEBIG5);
  cpEastEurope=CodePageType(SC_CHARSET_EASTEUROPE);
  cpGB2312=CodePageType(SC_CHARSET_GB2312);
  cpGreek=CodePageType(SC_CHARSET_GREEK);
  cpHangul=CodePageType(SC_CHARSET_HANGUL);
  cpMac=CodePageType(SC_CHARSET_MAC);
  cpOEM=CodePageType(SC_CHARSET_OEM);
  cpRussian=CodePageType(SC_CHARSET_RUSSIAN);
  cpCyrillic=CodePageType(SC_CHARSET_CYRILLIC);
  cpShiftJIS=CodePageType(SC_CHARSET_SHIFTJIS);
  cpSymbol=CodePageType(SC_CHARSET_SYMBOL);
  cpTurkish=CodePageType(SC_CHARSET_TURKISH);
  cpJohab=CodePageType(SC_CHARSET_JOHAB);
  cpHebrew=CodePageType(SC_CHARSET_HEBREW);
  cpArabic=CodePageType(SC_CHARSET_ARABIC);
  cpVietnamese=CodePageType(SC_CHARSET_VIETNAMESE);
  cpThai=CodePageType(SC_CHARSET_THAI);
  cp8859_15=CodePageType(SC_CHARSET_8859_15);
var
  fMsgSentDummyProc : TSCEventMsgSent;
implementation
Uses
  Math,sciUtils,SciResLang
  {$Ifdef USEDEFAULTSTREAMBYDEFAULT}
  ,SciStreamDefault
  {$Endif}
  ;
var
  scmod : HMODULE;

//Include the file with the current versionnumber.
{$Include SciVer.inc}

const DelphiSciVersionStr='Delphi Scintilla Interface Components';

function GetDelphiSciVersion : Integer;
begin
  Result:=DelphiSciVersion;
end;
function GetDelphiSciVersionStr : String;
var
  NowYear : String;
begin
  try
    NowYear:=FormatDateTime('yyyy',Date());
  except
    NowYear:='';
  end;
  if NowYear='' then NowYear:='2006';
  Result:=Format(DelphiSciVersionStr+' v%d.%d © 2004-%s, Jan Martin Pettersen',[HIWORD(DelphiSciVersion),LOWORD(DelphiSciVersion),NowYear]);
end;

function GetDelphiSciURL : String;
begin
  Result:='http://delphisci.sourceforge.net';
end;

//Define the identifiers to use for codepages.
const
  CodePages: array[0..21] of TIdentMapEntry = (
    (Value: cpDefault; Name: 'cpDefault'),
    (Value: cpAnsi; Name: 'cpAnsi'),
    (Value: cpUTF8; Name: 'cpUTF8'),
    (Value: cpBaltic; Name: 'cpBaltic'),
    (Value: cpChineseBig5; Name: 'cpChineseBig5'),
    (Value: cpEastEurope; Name: 'cpEastEurope'),
    (Value: cpGB2312; Name: 'cpGB2312'),
    (Value: cpGreek; Name: 'cpGreek'),
    (Value: cpHangul; Name: 'cpHangul'),
    (Value: cpMac; Name: 'cpMac'),
    (Value: cpOEM; Name: 'cpOEM'),
    (Value: cpRussian; Name: 'cpRussian'),
    (Value: cpCyrillic; Name: 'cpCyrillic'),
    (Value: cpShiftJIS; Name: 'cpShiftJIS'),
    (Value: cpSymbol; Name: 'cpSymbol'),
    (Value: cpTurkish; Name: 'cpTurkish'),
    (Value: cpJohab; Name: 'cpJohab'),
    (Value: cpHebrew; Name: 'cpHebrew'),
    (Value: cpArabic; Name: 'cpArabic'),
    (Value: cpVietnamese; Name: 'cpVietnamese'),
    (Value: cpThai; Name: 'cpThai'),
    (Value: cp8859_15; Name: 'cp8859_15')
  );

procedure GetCodePageValues(Proc: TGetStrProc);
var
  I: Integer;
begin
  for I := Low(CodePages) to High(CodePages) do Proc(CodePages[I].Name);
end;

function CodePageToIdent(CodePage: Longint; var Ident: string): Boolean;
begin
  Result := IntToIdent(CodePage, Ident, CodePages);
end;

function IdentToCodePage(const Ident: string; var CodePage: Longint): Boolean;
begin
  Result := IdentToInt(Ident, CodePage, CodePages);
end;

procedure TScintillaProt.Loaded;
begin
  inherited;
end;

constructor TSciStreamBase.Create(Editor : TScintillaBase);
begin
  inherited Create;
  FEditor :=Editor;
end;

// TScintillaBase
constructor TScintillaBase.Create(AOwner : TComponent);
begin
  if scmod = 0 then
    raise Exception.CreateRes(@eSciLexerNotFound);
  inherited;
  initing:=false;
  Width := 185;
  Height := 89;
  AutoSize := False;
  FStreamClass:=nil;
  FStreamer:=nil;
  TabStop := True;
  FDirty :=False;
  FBorderStyle := bsSingle;
  FWantTabs := True;
  FWantReturns := True;
  ParentFont := False;
  ParentColor := False;
  ParentShowHint := True;
  ParentBiDiMode := False;
  FWordChars :='_'+sci_alphachars+sci_numericchars;
  FClearUndoAfterSave:=False;
  FForceMouseRelease:=True;
  ControlStyle:=ControlStyle+[csClickEvents,csDoubleClicks,csCaptureMouse,csReflector];
{$Ifdef USEDEFAULTSTREAMBYDEFAULT}
  StreamClass:=TSciStreamDefault;
{$Endif}  
end;

destructor TScintillaBase.Destroy;
begin
  FreeAndNil(FStateStream);
  if assigned(FStreamer) then
    FreeAndNil(FStreamer);
  inherited;
end;

procedure TScintillaBase.Loaded;
begin
  inherited Loaded;
  SetBufferedDraw(True);
  Self.SetSavePoint;
  SetMouseDownCaptures(False);
end;

procedure TScintillaBase.CreateWnd;
begin
  FCreating := True;
  try
    inherited CreateWnd;
  finally
    FCreating := False;
  end;
    @SCPerform := Pointer( SendMessage(WindowHandle, SCI_GETDIRECTFUNCTION,0,0) );
    sccmdctr := Pointer( SendMessage(WindowHandle, SCI_GETDIRECTPOINTER,0,0) );
  if (ComponentState * [csLoading, csReading] = []) and assigned(FStateStream) then
  begin
    fStateStream.Position := 0;
    fStateStream.ReadComponent(Self);
    FreeAndNil(fStateStream);
  end;
    Perform(CM_FONTCHANGED, 0, 0);
    Perform(CM_COLORCHANGED, 0, 0);
end;

procedure TScintillaBase.WndDestroy;
begin
  if not (csDestroying in ComponentState) then
  begin
    if Assigned(FStateStream) then
      FStateStream.Position := 0
    else
      FStateStream := TMemoryStream.Create;
    FStateStream.WriteComponent(Self);
  end;
end;

procedure TScintillaBase.DestroyWnd;
begin
  WndDestroy;
  inherited DestroyWnd;
end;

procedure TScintillaBase.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  CreateSubClass(Params, 'Scintilla');
  with Params do
  begin
    Style := WS_CHILD or WS_VSCROLL or WS_HSCROLL or WS_CLIPCHILDREN or WS_CLIPSIBLINGS;
    if NewStyleControls and Ctl3D and (FBorderStyle = bsSingle) then
    begin
      Style := Style and not WS_BORDER;
      ExStyle := ExStyle or WS_EX_CLIENTEDGE;
    end;
  end;
end;

procedure TScintillaBase.SetStreamClass(Value : TSciStreamClass);
begin
  if (Value<>FStreamClass) then
  begin
    if assigned(FStreamer) then FreeAndNil(FStreamer);
    FStreamClass:=Value;
    if assigned(FStreamClass) then
      FStreamer:=FStreamClass.Create(Self);
  end;
end;

procedure TScintillaBase.CopyFrom(Source: TScintillaBase);
begin
  if Assigned(Source) then
  begin
    AutoSize := False;
    TabStop := TScintillaBase(Source).TabStop;
    ParentShowHint := TScintillaBase(Source).ParentShowHint;
    ParentBiDiMode := TScintillaBase(Source).ParentBiDiMode;
    ClearUndoAfterSave:=TScintillaBase(Source).ClearUndoAfterSave;
    Color :=TScintillaBase(Source).Color;
    WordChars:=TScintillaBase(Source).WordChars;
    Font.Assign(TScintillaBase(Source).Font);
    CodePage:=TScintillaBase(Source).CodePage;
  end;
end;

procedure TScintillaBase.CMFontChanged(var Message: TMessage);
begin
  inherited;
  StyleSetFont(STYLE_DEFAULT, PChar(Font.Name));
  StyleSetSize(STYLE_DEFAULT, Font.Size);
  StyleSetCharacterSet(STYLE_DEFAULT, Font.Charset);
  StyleSetItalic(STYLE_DEFAULT, fsItalic in Font.Style);
  StyleSetBold(STYLE_DEFAULT, fsBold in Font.Style);
  StyleSetUnderline(STYLE_DEFAULT, fsUnderline in Font.Style);
  StyleSetFore(STYLE_DEFAULT, ColorToRGB(Font.Color));
  StyleClearAll;
end;

procedure TScintillaBase.CMColorChanged(var Message: TMessage);
begin
  inherited;
  Self.StyleSetBack(STYLE_DEFAULT, ColorToRGB(Color));
  StyleClearAll;
end;

procedure TScintillaBase.WMNotify(var Message: TWMNotify);
var nmh : PNMHdr;
  scn : PSCNotification;
begin
  nmh := Message.NMHdr;
  if (nmh^.hwndFrom = Handle) then
  begin
    scn := PSCNotification(TMessage(Message).LParam);
    case nmh^.code of
      0 : ;
//++EventImpl
      2000 : doSciStyleNeeded(scn^.position);
      2001 : doSciCharAdded(scn^.ch);
      2002 : doSciSavePointReached;
      2003 : doSciSavePointLeft;
      2004 : doSciModifyAttemptRO;
      2006 : doSciDoubleClick;
      2007 : doSciUpdateUI;
      2008 : doSciModified(scn^.position, scn^.modificationType, scn^.text, scn^.length, scn^.linesAdded, scn^.line, scn^.foldLevelNow, scn^.foldLevelPrev);
      2009 : doSciMacroRecord(scn^.message, scn^.wParam, scn^.lParam);
      2010 : doSciMarginClick(scn^.modifiers, scn^.position, scn^.margin);
      2011 : doSciNeedShown(scn^.position, scn^.length);
      2013 : doSciPainted;
      2014 : doSciUserListSelection(scn^.listType, scn^.text);
      2016 : doSciDwellStart(scn^.position);
      2017 : doSciDwellEnd(scn^.position);
      2018 : doSciZoom;
      2019 : doSciHotSpotClick(scn^.modifiers, scn^.position);
      2020 : doSciHotSpotDoubleClick(scn^.modifiers, scn^.position);
      2021 : doSciCallTipClick(scn^.position);
      2022 : doSciAutoCSelection(scn^.text);
//--EventImpl
    end;
  end;
  inherited;
end;

procedure TScintillaBase.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
  inherited;
  Message.Result := Message.Result or DLGC_WANTCHARS or DLGC_WANTARROWS; //BUGFIX 01
  if FWantTabs then
    Message.Result := Message.Result or DLGC_WANTTAB
  else
    Message.Result := Message.Result and not DLGC_WANTTAB;
  if not FWantReturns then
    Message.Result := Message.Result and not DLGC_WANTALLKEYS;
end;

procedure TScintillaBase.WMNCDestroy(var Message: TWMNCDestroy);
begin
  inherited;
end;

procedure TScintillaBase.CMCtl3DChanged(var Message: TMessage);
begin
  if NewStyleControls and (FBorderStyle = bsSingle) then
  begin
    RecreateWnd;
  end;
  inherited;
end;

procedure TScintillaBase.DefaultHandler(var Message);
begin
  case TMessage(Message).Msg of
    WM_SETFOCUS:
      if (Win32Platform = VER_PLATFORM_WIN32_WINDOWS) and not IsWindow(TWMSetFocus(Message).FocusedWnd) then
        TWMSetFocus(Message).FocusedWnd := 0;
  end;

  inherited;
end;

procedure TScintillaBase.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
  Inherited;
  if (FForceMouseRelease) then
  if (Shift * [ssLeft,ssRight]=[]) and
    ((X<0) or (Y<0) or (Y>Height) or (X>Width)) then // If we are outside of the control
    SetCaptureControl(nil); // Release capture
end;

procedure TScintillaBase.DisableAllEvents(disable : Boolean);
begin
  if disable then
  begin
    oldmodeventmask:=GetModEventMask;
    SetModEventMask(0);
  end else
  begin
    if oldmodeventmask<>0 then
      SetModEventMask(oldmodeventmask);
    oldmodeventmask:=0;
  end;
end;

function TScintillaBase.GetStreamer : TSciStreamBase;
begin
  if not assigned(FStreamer) then
  begin
    if not assigned(FStreamClass) then
      raise ESciException.CreateRes(@eStreamClassUnassigned)
    else
      FStreamer:=FStreamClass.Create(Self);
  end;
  Result:=FStreamer;
end;
procedure TScintillaBase.GotoLineEnsureVisible(const line : LongInt);
begin
  EnsureVisibleEnforcePolicy(line);
  GotoLine(line);
end;

function TScintillaBase.GetLineS(const Index: LongInt): string;
var
  S : string;
  Len,linenum : LongInt;
begin
  if(Index<0) then
    linenum:=GetCurrentLineNumber
  else
    linenum :=Index;
  Len := GetLineLength(linenum);
  if Len > 0 then
  begin
    SetLength(S, Len+2);
    GetLine(linenum, PChar(S));
    Result := System.Copy(S, 1, Len);
  end else
    Result := '';
end;

procedure TScintillaBase.GetLineInBuf(textbuf : PChar; const sizeText : LongInt; linenum : LongInt);
var
  lineStart,lineEnd,lineMax: LongInt;
begin
  if linenum < 0 then
    linenum := GetCurrentLineNumber;
  lineStart := PositionFromLine(linenum);
  lineEnd := GetLineEndPosition(linenum);
  lineMax := lineStart + sizeText - 1;
  if lineEnd > lineMax then
    lineEnd := lineMax;
  GetRange(lineStart, lineEnd, textbuf);
  textbuf[lineEnd - lineStart] := Char(0);
end;

function TScintillaBase.GetCurrentLineNumber : LongInt;
begin
  Result :=LineFromPosition(GetCurrentPos);
end;

function TScintillaBase.GetCaretInLine : LongInt;
var
  caret,line,lineStart : LongInt;
begin
  caret := GetCurrentPos;
  line := LineFromPosition(caret);
  lineStart := PositionFromLine(line);
  Result :=caret - lineStart;
end;

procedure TScintillaBase.GetRange(const start, end_ : LongInt; text: PChar);
var
  tr : TTextRange;
begin
  tr.chrg.cpMin := start;
  tr.chrg.cpMax := end_;
  tr.lpstrText := text;
  GetTextRange(@tr);
end;

procedure TScintillaBase.SetSelectionS(const anchor, end_ : LongInt); // Set selection start and end
begin
  SetSel(anchor, end_);
end;

function  TScintillaBase.GetSelectionRng : TCharacterRange;
var
  crange : TCharacterRange;
begin
  crange.cpMin := GetSelectionStart;
  crange.cpMax := GetSelectionEnd;
  Result :=crange;
end;

function TScintillaBase.SelectionWord(const stripEol : boolean) : String;
begin
  Result:=SelectionExtend(IsWordChar, stripEol);
end;

function TScintillaBase.SelectionFileName : String;
begin
  Result:=SelectionExtend(IsFilenameChar, true);
end;

function IsEOL(const ch : Integer) : Boolean;
begin
  if (ch=10) or (ch=13) then
    Result:=True
  else
    Result:=False
end;

function  TScintillaBase.SetSelectionByStyle(const styleNum : Integer;const xpos : Integer;const mask : Integer) : Boolean;
var
  start,end_ : Integer;
  doclen : Integer;
  sstyl : Integer;
begin
  doclen :=GetTextLength;
  if xpos=-1 then
  begin
    start:=GetSelectionStart;
    end_:=GetSelectionEnd;
    if(end_-start<=0) then
    begin
      start:=GetCurrentPos;
      end_:=start;
    end;
  end else
  begin
    start:=xpos;
    end_:=start;
  end;
  Result:=False;
  if(start>0) then
  begin
    repeat
      sstyl:=GetStyleAt(start);
      if sstyl=styleNum then
        start:=start-1
      else
        start:=start+1;
    until (start<=0) or (sstyl<>styleNum);
  end;
  if(end_<(doclen-1)) then
  begin
    repeat
      sstyl:=GetStyleAt(end_);
      if sstyl=styleNum then
        end_:=end_+1;
    until (end_>=(doclen-1)) or (sstyl<>styleNum);
  end;
  if (end_-start>0) then
  begin
    SetSel(start,end_);
    Result:=True;
  end;
end;

function  TScintillaBase.SelectByStyle(const styleNum : Integer;const xpos : Integer;const mask : Integer) : String;
var
  sellen : Integer;
  selected : String;
  start,end_ : Integer;
  doclen : Integer;
  sstyl : Integer;
begin
  doclen :=GetTextLength;
  if xpos=-1 then
  begin
    start:=GetSelectionStart;
    end_:=GetSelectionEnd;
    if(end_-start<=0) then
    begin
      start:=GetCurrentPos;
      end_:=start;
    end;
  end else
  begin
    start:=xpos;
    end_:=start;
  end; 
  Result:='';
  if(start>0) then
  begin
    repeat
      sstyl:=GetStyleAt(start);
      if sstyl=styleNum then
        start:=start-1
      else
        start:=start+1;
    until (start<=0) or (sstyl<>styleNum);
  end;
  if(end_<(doclen-1)) then
  begin
    repeat
      sstyl:=GetStyleAt(end_);
      if sstyl=styleNum then
        end_:=end_+1;
    until (end_>=(doclen-1)) or (sstyl<>styleNum);
  end;
  sellen:=end_-start;
  if (sellen)>0 then
  begin
    SetLength(selected,sellen);
    GetRange(start,end_,PChar(selected));
  end;
  sellen :=Length(selected);
  if (sellen>=2) and (selected[sellen-2]=#13) and (selected[sellen-1]=#10) then
  begin
    Delete(selected,sellen-2,sellen+2);
  end else if (sellen>=1) and ((selected[sellen-1]=#13) or (selected[sellen-1]=#10)) then
  begin
    Delete(selected,sellen-1,sellen+2);
  end;
  Result:=selected;
end;

function TScintillaBase.SelectionExtend(ischarforsel : TTestingFunction;const stripEol : boolean) : String;
var
  selStart,selEnd : LongInt;
begin
  selStart := GetSelectionStart;
  selEnd := GetSelectionEnd;
  result :=RangeExtendAndGrab(selStart, selEnd, ischarforsel, stripEol);
end;

procedure TScintillaBase.FindWordAtCaret(var start : LongInt;var end_ : LongInt);
begin
  start := GetSelectionStart;
  end_ := GetSelectionEnd;
  // Call just to update start & end
  RangeExtendAndGrab(start, end_, IsWordChar, false);
end;

function TScintillaBase.SelectWordAtCaret : boolean;
var
  selStart,selEnd : LongInt;
begin
  selStart :=0;
  selEnd :=0;
  FindWordAtCaret(selStart, selEnd);
  SetSelectionS(selStart, selEnd);
  result :=boolean(selStart <> selEnd);
end;

function TScintillaBase.RangeExtendAndGrab(var selStart,selEnd : LongInt;ischarforsel : TTestingFunction;const stripEol : Boolean) : String;
var
  lengthDoc,len,sellen : LongInt;
  selected,sel : String;
begin
  if (selStart = selEnd) and assigned(ischarforsel) then
  begin
    lengthDoc :=GetLength;
    while ((selStart > 0) and (ischarforsel(GetCharAt(selStart - 1)))) do
    begin
      selStart:=selStart-1;
    end;
    while ((selEnd < lengthDoc) and (ischarforsel(GetCharAt(selEnd)))) do
    begin
      selEnd:=selEnd+1;
    end;
    len:=selEnd-selStart;
    if len>0 then
    begin
      SetLength(sel,len);
      GetRange(selStart, selEnd, PChar(sel));
      selected := sel;
    end;
    if stripEol then
    begin
      sellen :=Length(selected);
      if (sellen>=2) and (selected[sellen-2]=#13) and (selected[sellen-1]=#10) then
      begin
        Delete(selected,sellen-2,sellen+2);
      end else if (sellen>=1) and ((selected[sellen-1]=#13) or (selected[sellen-1]=#10)) then
      begin
        Delete(selected,sellen-1,sellen+2);
      end;
    end;
  end;
  result :=selected;
end;

function TScintillaBase.RangeIsAllWhiteSpace(const start, end_ : LongInt) : boolean;
var
  i : LongInt;
begin
  for i:=start to (end_-1) do
  begin
    if not ((Char(GetCharAt(i)) in [' ',#9])) then
    begin
      result :=false;
      Exit;
    end;
  end;
  result :=true;
end;

function TScintillaBase.GetLineLength(const line : LongInt) : LongInt;
var
  linenum : LongInt;
begin
  if line=-1 then
    linenum:=GetCurrentLineNumber
  else linenum:=line;
  result :=GetLineEndPosition(linenum)-PositionFromLine(linenum);
end;

procedure TScintillaBase.EnsureRangeVisible(const PosStart, PosEnd: LongInt);
Var
  LineStart, LineEnd, i : LongInt;
begin
  LineStart := LineFromPosition(PosStart);
  LineEnd := LineFromPosition(PosEnd);
  for i := Min(LineStart, LineEnd) to Max(LineStart, LineEnd) do
    EnsureVisible(i);
end;

function TScintillaBase.SPerform(Msg, wParam, lParam: Integer) : LongInt;
begin
  HandleNeeded;  // KV
  Result := SCPerform(sccmdctr, Msg, wParam, lParam);
end;

{$Ifdef USEWMERASE}
procedure TScintillaBase.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
  // If we don't do this, then in design mode we'll look really ugly...
  if ((csDesigning in ComponentState) and not (TMessage(Message).wParam = TMessage(Message).lParam)) then
    FillRect(Message.DC, ClientRect, GetStockObject(WHITE_BRUSH));

  Message.Result := 1;
end;
{$Endif}
// The following code is used to allow an external object to receive all the
// calls to the scintilla control - instead of calling scintilla we just pass
// on the messages. To enable this, set up a OnMsgSent handler _FIRST_, and then
// set Dummy to true. This cannot be un-toggled!

function dummySCPerform(ptr: Pointer; Msg, wParam,lParam: Integer): LongInt; cdecl;
begin
  if Assigned(fMsgSentDummyProc) then
    fMsgSentDummyProc(nil, Msg, wParam, lParam);
  Result := 0;
end;

procedure TScintillaBase.SetDummy(Value: Boolean);
begin
  SCPerform := @dummySCPerform;
  fMsgSentDummyProc := FOnMsgSent;
  FDummy := True;
end;

function TScintillaBase.ExecuteAction(Action: TBasicAction): boolean;
begin
  if Action is TEditAction then
  begin
    Result := TRUE;
    if Action is TEditCut then
      Cut
    else if Action is TEditCopy then
      Copy
    else if Action is TEditPaste then
      Paste
    else if Action is TEditDelete then
      Clear
    else if Action is TEditUndo then
      Undo
    else if Action is TEditSelectAll then
      SelectAll;
  end else
    Result := inherited ExecuteAction(Action);
end;

function TScintillaBase.UpdateAction(Action: TBasicAction): boolean;
begin
  if Action is TEditAction then
  begin
    Result := Focused;
    if Result then
    begin
      if (Action is TEditCut) or (Action is TEditCopy) then
        TEditAction(Action).Enabled := (GetSelectionStart-GetSelectionEnd) <> 0
      else if Action is TEditPaste then
        TEditAction(Action).Enabled := (ReadOnly=False) and (CanPaste)
      else if Action is TEditDelete then
        TEditAction(Action).Enabled := not ReadOnly
      else if Action is TEditUndo then
        TEditAction(Action).Enabled := (CanUndo) and (ReadOnly=False)
      else if Action is TEditSelectAll then
        TEditAction(Action).Enabled := TRUE;
    end;
  end else
    Result := inherited UpdateAction(Action);
end;

procedure TScintillaBase.LoadFromStream(Stream : TStream);
begin
  if not assigned(FStreamer) then
  begin
    if assigned(FStreamClass) then
      FStreamer:=FStreamClass.Create(Self)
    else
      raise ESciException.CreateRes(@eStreamClassUnassigned);
  end;
  if assigned(FStreamer) then
  begin
    ClearAll;
    FStreamer.LoadFromStream(Stream);
    EmptyUndoBuffer;
    SetSavePoint;
    GotoPos(0);
  end else
  begin
    raise ESciException.CreateRes(@eNoStreamer);
  end;
end;

procedure TScintillaBase.SaveToStream(Stream : TStream);
begin
  if not assigned(FStreamer) then
  begin
    if assigned(FStreamClass) then
      FStreamer:=FStreamClass.Create(Self)
    else
      raise ESciException.CreateRes(@eStreamClassUnassigned);
  end;
  if assigned(FStreamer) then
  begin
    FStreamer.SaveToStream(Stream);
    SetSavePoint;
    if FClearUndoAfterSave then
    begin
      EmptyUndoBuffer;
    end;
  end else
  begin
    raise ESciException.CreateRes(@eNoStreamer);
  end;
end;

procedure TScintillaBase.LoadFromFile(const FileName: TFileName);
var
  op : TFileStream;
begin
  ClearAll;
  op:=nil;
  try
    op := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
    DisableAllEvents(True);
    LoadFromStream(op);
    SetSavePoint;
    DisableAllEvents(False);
  finally
    FreeAndNil(op);
  end;
end;

procedure TScintillaBase.SaveToFile(const FileName: TFileName);
var
  sv : TFileStream;
begin
  sv:=nil;
  try
    sv := TFileStream.Create(FileName, fmCreate or fmShareExclusive);
    SaveToStream(sv);
  finally
    FreeAndNil(sv);
  end;
end;

procedure TScintillaBase.AddTextStr(const Text : String);
begin
  AddText(Length(Text),PChar(Text));
end;

procedure TScintillaBase.InsertTextStr(const pos : LongInt;Text : String);
begin
  InsertText(pos,PChar(Text));
end;

procedure TScintillaBase.DeleteWordRightAndSkip;
var
  len : Integer;
  start,end_ : Integer;
  c : Integer;
begin
  BeginUndoAction;
  DelWordRight;
  start:=GetCurrentPos;
  end_:=start;
  len:=GetLength;
  c:=GetCharAt(end_);
  while (len>end_) and isspace(c) do
  begin
    Inc(end_);
    c:=GetCharAt(end_);
  end;
  if (end_-start)>0 then
  begin
    SetTargetStart(start);
    SetTargetEnd(end_);
    ReplaceTarget(0,'');
    InsertText(start,' ');
  end;
  EndUndoAction;
end;

function TScintillaBase.GetCurrentScrollPosition : LongInt;
var
  lineDisplayTop : LongInt;
begin
  lineDisplayTop := GetFirstVisibleLine;
  result:=DocLineFromVisible(lineDisplayTop);
end;

procedure TScintillaBase.ClearDocument;
begin
  ClearAll;
  EmptyUndoBuffer;
  SetSavePoint;
end;

procedure TScintillaBase.inSetWordChars(const Value : String);
begin
  FWordChars:=Value;
  if(FWordChars='') then
    FWordChars:='_'+sci_alphachars;
  SetWordChars(PChar(FWordChars));
end;

function TScintillaBase.GetSelectionLength : LongInt;
var
  startPos,endPos,startLine,endLine,charCount,line : Integer;
begin
  startPos := GetSelectionStart;
  endPos := GetSelectionEnd;
  if SelectionIsRectangle then
  begin
    startLine := LineFromPosition(startPos);
    endLine := LineFromPosition(endPos);
    charCount:=0;
    for line:=startLine to endLine do
    begin
      startPos:=GetLineSelStartPosition(line);
      endPos:=GetLineSelEndPosition(line);
      Inc(charCount,endPos-startPos);
    end;
    Result:=charCount;
  end else
    result:=endPos-startPos;
end;

procedure TScintillaBase.SetSelectionLength(const Value : LongInt);
var
  start : LongInt;
begin
  start :=GetSelectionStart;
  SetSelectionEnd(start+Value);
end;

procedure TScintillaBase.SetSelStart(const value : LongInt);
begin
  SetSel(Value,value);
end;

function TScintillaBase.GetSelection: string;
Var
  L : LongInt;
begin
  L := GetSelectionEnd - GetSelectionStart;
  if L > 0 then
  begin
    //SetLength(Result, L);
    // bug in Scintilla >= 1.54
    // was introduced sometime after v1.49
    SetLength(Result, L+1);
    GetSelText(Pchar(Result));
    Result := System.Copy(Result, 1, L);
  end else
    Result := '';
end;

procedure TScintillaBase.SetSelection(const Value: string);
begin
  ReplaceSel(PChar(Value));
end;

procedure TScintillaBase.SetBorderStyle(Value: TBorderStyle);
begin
  If FBorderStyle <> Value then
  begin
    FBorderStyle := Value;
    RecreateWnd;
  end;
end;

function TScintillaBase.GetWordWrap: TWordWrapType;
begin
  Result := TWordWrapType(Self.GetWrapMode);
end;

procedure TScintillaBase.SetWordWrap(const Value: TWordWrapType);
begin
  SetWrapMode(LongInt(Value));
end;

procedure TScintillaBase.SetModified(const Value: Boolean);
begin
  if not Value then SetSavePoint;  // is there a way to tell Scintilla the buffer is modified?
end;

procedure TScintillaBase.inSetCodePage(const Value : CodePageType);
begin
  FCodePage:=Value;
  if HandleAllocated then
    SetCodePage(LongInt(Value));
end;

function TScintillaBase.inGetCodePage : CodePageType;
begin
  if HandleAllocated then
    Result:=CodePageType(GetCodePage)
  else
    Result:=FCodePage;
end;

procedure TScintillaBase.doSciCharAdded(const ch : Integer);
begin
  if Assigned(FOncharadded) then FOncharadded(Self,ch);
end;

procedure TScintillaBase.doSciMarginClick(const modifiers : LongInt; const position : LongInt; const margin : LongInt);
begin
  if assigned(FOnmarginclick) then
    FOnmarginclick(Self, modifiers, position, margin);
end;

procedure TScintillaBase.doSciModified(const position : LongInt; const modificationType : LongInt; text : PChar; const len : LongInt; const linesAdded : LongInt; const line : LongInt; const foldLevelNow : LongInt; const foldLevelPrev : LongInt);
begin
  if assigned(FOnmodified) then
    FOnmodified(Self, position, modificationType, text, len, linesAdded, line, foldLevelNow, foldLevelPrev);
end;

procedure TScintillaBase.doSciUserListSelection(const listType : LongInt; text : PChar);
begin
  if assigned(FOnuserlistselection) then
    FOnuserlistselection(Self, listType, text);
end;

procedure TScintillaBase.doSciUpdateUI;
begin
  if assigned(FOnupdateui) then
    FOnupdateui(Self);
end;

procedure TScintillaBase.doSciStyleNeeded(const position : Integer);
begin
  if assigned(FOnstyleneeded) then
    FOnstyleneeded(Self, position);
end;
procedure TScintillaBase.doSciModifyAttemptRO;
begin
  if assigned(FOnmodifyattemptro) then
    FOnmodifyattemptro(Self);
end;
procedure TScintillaBase.doSciDoubleClick;
begin
  if assigned(FOndoubleclick) then
    FOndoubleclick(Self);
end;

procedure TScintillaBase.doSciNeedShown(const position : Integer;const len : Integer);
begin
  if assigned(FOnneedshown) then
    FOnneedshown(Self,position, len);
end;

procedure TScintillaBase.doSciPainted;
begin
  if assigned(FOnpainted) then
    FOnpainted(Self);
end;

procedure TScintillaBase.doSciDwellStart(const position : Integer);
begin
  if assigned(FOndwellstart) then
    FOndwellstart(Self, position);
end;

procedure TScintillaBase.doSciDwellEnd(const position : Integer);
begin
  if assigned(FOndwellend) then
    FOndwellend(Self, position);
end;

procedure TScintillaBase.doSciZoom;
begin
  if assigned(FOnzoom) then
    FOnzoom(Self);
end;

procedure TScintillaBase.doSciHotspotClick(const modifiers : Integer;const position : Integer);
begin
  if assigned(FOnhotspotclick) then
    FOnhotspotclick(Self, modifiers, position);
end;

procedure TScintillaBase.doSciHotspotDoubleClick(const modifiers : Integer;const position : Integer);
begin
  if assigned(FOnhotspotdoubleclick) then
    FOnhotspotdoubleclick(Self, modifiers, position);
end;
procedure TScintillaBase.doSciAutoCSelection(const text : PChar);
begin
  if assigned(FOnAutoCSelection) then
    FOnAutoCSelection(Self, text);
end;

procedure TScintillaBase.doSciCalltipClick(const position : Integer);
begin
  if assigned(FOncalltipclick) then
    FOncalltipclick(Self, position);
end;

procedure TScintillaBase.doSciMacroRecord(const msg : Integer;const wParam : uptr_t;const lParam : sptr_t);
begin
  if assigned(FOnmacrorecord) then
    FOnmacrorecord(Self, msg, wParam, lParam);
end;

procedure TScintillaBase.doSciSavePointReached;
begin
  FDirty :=false;
  if assigned(FOnsavepointreached) then
    FOnsavepointreached(Self);
end;

procedure TScintillaBase.doSciSavePointLeft;
begin
  FDirty:=true;
  if assigned(FOnsavepointleft) then
    FOnsavepointleft(Self);
end;

procedure TScintillaBase.LinkTo(otherSciDoc : TScintillaBase);
var
  aNewDoc : Integer;
begin
  if Assigned(otherSciDoc) then
  begin
    aNewDoc:=otherSciDoc.GetDocPointer;
    SetDocPointer(aNewDoc);
  end;
end;

procedure TScintillaBase.UnLink;
begin
  SetDocPointer(0);
end;

//++FuncImp
procedure TScintillaBase.AddText(length : LongInt; text : PChar);
begin
  SPerform(SCI_ADDTEXT, length, LongInt(text));
end;

procedure TScintillaBase.AddStyledText(length : LongInt; c : PChar);
begin
  SPerform(SCI_ADDSTYLEDTEXT, length, LongInt(c));
end;

procedure TScintillaBase.InsertText(pos : LongInt; text : PChar);
begin
  SPerform(SCI_INSERTTEXT, pos, LongInt(text));
end;

procedure TScintillaBase.ClearAll;
begin
  SPerform(SCI_CLEARALL, 0, 0);
end;

procedure TScintillaBase.ClearDocumentStyle;
begin
  SPerform(SCI_CLEARDOCUMENTSTYLE, 0, 0);
end;

function TScintillaBase.GetLength : LongInt;
begin
  result := SPerform(SCI_GETLENGTH, 0, 0);
end;

function TScintillaBase.GetCharAt(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETCHARAT, pos, 0);
end;

function TScintillaBase.GetCurrentPos : LongInt;
begin
  result := SPerform(SCI_GETCURRENTPOS, 0, 0);
end;

function TScintillaBase.GetAnchor : LongInt;
begin
  result := SPerform(SCI_GETANCHOR, 0, 0);
end;

function TScintillaBase.GetStyleAt(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETSTYLEAT, pos, 0);
end;

procedure TScintillaBase.Redo;
begin
  SPerform(SCI_REDO, 0, 0);
end;

procedure TScintillaBase.SetUndoCollection(collectUndo : Boolean);
begin
  SPerform(SCI_SETUNDOCOLLECTION, LongInt(collectUndo), 0);
end;

procedure TScintillaBase.SelectAll;
begin
  SPerform(SCI_SELECTALL, 0, 0);
end;

procedure TScintillaBase.SetSavePoint;
begin
  SPerform(SCI_SETSAVEPOINT, 0, 0);
end;

function TScintillaBase.GetStyledText(tr : PTextRange) : LongInt;
begin
  result := SPerform(SCI_GETSTYLEDTEXT, 0, LongInt(tr));
end;

function TScintillaBase.CanRedo : Boolean;
begin
  result := Boolean(SPerform(SCI_CANREDO, 0, 0));
end;

function TScintillaBase.MarkerLineFromHandle(handle : LongInt) : LongInt;
begin
  result := SPerform(SCI_MARKERLINEFROMHANDLE, handle, 0);
end;

procedure TScintillaBase.MarkerDeleteHandle(handle : LongInt);
begin
  SPerform(SCI_MARKERDELETEHANDLE, handle, 0);
end;

function TScintillaBase.GetUndoCollection : Boolean;
begin
  result := Boolean(SPerform(SCI_GETUNDOCOLLECTION, 0, 0));
end;

function TScintillaBase.GetViewWS : LongInt;
begin
  result := SPerform(SCI_GETVIEWWS, 0, 0);
end;

procedure TScintillaBase.SetViewWS(viewWS : LongInt);
begin
  SPerform(SCI_SETVIEWWS, viewWS, 0);
end;

function TScintillaBase.PositionFromPoint(x : LongInt; y : LongInt) : LongInt;
begin
  result := SPerform(SCI_POSITIONFROMPOINT, x, y);
end;

function TScintillaBase.PositionFromPointClose(x : LongInt; y : LongInt) : LongInt;
begin
  result := SPerform(SCI_POSITIONFROMPOINTCLOSE, x, y);
end;

procedure TScintillaBase.GotoLine(line : LongInt);
begin
  SPerform(SCI_GOTOLINE, line, 0);
end;

procedure TScintillaBase.GotoPos(pos : LongInt);
begin
  SPerform(SCI_GOTOPOS, pos, 0);
end;

procedure TScintillaBase.SetAnchor(posAnchor : LongInt);
begin
  SPerform(SCI_SETANCHOR, posAnchor, 0);
end;

function TScintillaBase.GetCurLine(length : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_GETCURLINE, length, LongInt(text));
end;

function TScintillaBase.GetEndStyled : LongInt;
begin
  result := SPerform(SCI_GETENDSTYLED, 0, 0);
end;

procedure TScintillaBase.ConvertEOLs(eolMode : LongInt);
begin
  SPerform(SCI_CONVERTEOLS, eolMode, 0);
end;

function TScintillaBase.GetEOLMode : LongInt;
begin
  result := SPerform(SCI_GETEOLMODE, 0, 0);
end;

procedure TScintillaBase.SetEOLMode(eolMode : LongInt);
begin
  SPerform(SCI_SETEOLMODE, eolMode, 0);
end;

procedure TScintillaBase.StartStyling(pos : LongInt; mask : LongInt);
begin
  SPerform(SCI_STARTSTYLING, pos, mask);
end;

procedure TScintillaBase.SetStyling(length : LongInt; style : LongInt);
begin
  SPerform(SCI_SETSTYLING, length, style);
end;

function TScintillaBase.GetBufferedDraw : Boolean;
begin
  result := Boolean(SPerform(SCI_GETBUFFEREDDRAW, 0, 0));
end;

procedure TScintillaBase.SetBufferedDraw(buffered : Boolean);
begin
  SPerform(SCI_SETBUFFEREDDRAW, LongInt(buffered), 0);
end;

procedure TScintillaBase.SetTabWidth(tabWidth : LongInt);
begin
  SPerform(SCI_SETTABWIDTH, tabWidth, 0);
end;

function TScintillaBase.GetTabWidth : LongInt;
begin
  result := SPerform(SCI_GETTABWIDTH, 0, 0);
end;

procedure TScintillaBase.SetCodePage(codePage : LongInt);
begin
  SPerform(SCI_SETCODEPAGE, codePage, 0);
end;

procedure TScintillaBase.SetUsePalette(usePalette : Boolean);
begin
  SPerform(SCI_SETUSEPALETTE, LongInt(usePalette), 0);
end;

procedure TScintillaBase.MarkerDefine(markerNumber : LongInt; markerSymbol : LongInt);
begin
  SPerform(SCI_MARKERDEFINE, markerNumber, markerSymbol);
end;

procedure TScintillaBase.MarkerSetFore(markerNumber : LongInt; fore : TColor);
begin
  SPerform(SCI_MARKERSETFORE, markerNumber, ColorToRGB(fore));
end;

procedure TScintillaBase.MarkerSetBack(markerNumber : LongInt; back : TColor);
begin
  SPerform(SCI_MARKERSETBACK, markerNumber, ColorToRGB(back));
end;

function TScintillaBase.MarkerAdd(line : LongInt; markerNumber : LongInt) : LongInt;
begin
  result := SPerform(SCI_MARKERADD, line, markerNumber);
end;

procedure TScintillaBase.MarkerDelete(line : LongInt; markerNumber : LongInt);
begin
  SPerform(SCI_MARKERDELETE, line, markerNumber);
end;

procedure TScintillaBase.MarkerDeleteAll(markerNumber : LongInt);
begin
  SPerform(SCI_MARKERDELETEALL, markerNumber, 0);
end;

function TScintillaBase.MarkerGet(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_MARKERGET, line, 0);
end;

function TScintillaBase.MarkerNext(lineStart : LongInt; markerMask : LongInt) : LongInt;
begin
  result := SPerform(SCI_MARKERNEXT, lineStart, markerMask);
end;

function TScintillaBase.MarkerPrevious(lineStart : LongInt; markerMask : LongInt) : LongInt;
begin
  result := SPerform(SCI_MARKERPREVIOUS, lineStart, markerMask);
end;

procedure TScintillaBase.MarkerDefinePixmap(markerNumber : LongInt; pixmap : PChar);
begin
  SPerform(SCI_MARKERDEFINEPIXMAP, markerNumber, LongInt(pixmap));
end;

procedure TScintillaBase.MarkerAddSet(line : LongInt; Mask : LongInt);
begin
  SPerform(SCI_MARKERADDSET, line, Mask);
end;

procedure TScintillaBase.MarkerSetAlpha(markerNumber : LongInt; alpha : LongInt);
begin
  SPerform(SCI_MARKERSETALPHA, markerNumber, alpha);
end;

procedure TScintillaBase.SetMarginTypeN(margin : LongInt; marginType : LongInt);
begin
  SPerform(SCI_SETMARGINTYPEN, margin, marginType);
end;

function TScintillaBase.GetMarginTypeN(margin : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETMARGINTYPEN, margin, 0);
end;

procedure TScintillaBase.SetMarginWidthN(margin : LongInt; pixelWidth : LongInt);
begin
  SPerform(SCI_SETMARGINWIDTHN, margin, pixelWidth);
end;

function TScintillaBase.GetMarginWidthN(margin : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETMARGINWIDTHN, margin, 0);
end;

procedure TScintillaBase.SetMarginMaskN(margin : LongInt; mask : LongInt);
begin
  SPerform(SCI_SETMARGINMASKN, margin, mask);
end;

function TScintillaBase.GetMarginMaskN(margin : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETMARGINMASKN, margin, 0);
end;

procedure TScintillaBase.SetMarginSensitiveN(margin : LongInt; sensitive : Boolean);
begin
  SPerform(SCI_SETMARGINSENSITIVEN, margin, LongInt(sensitive));
end;

function TScintillaBase.GetMarginSensitiveN(margin : LongInt) : Boolean;
begin
  result := Boolean(SPerform(SCI_GETMARGINSENSITIVEN, margin, 0));
end;

procedure TScintillaBase.StyleClearAll;
begin
  SPerform(SCI_STYLECLEARALL, 0, 0);
end;

procedure TScintillaBase.StyleSetFore(style : LongInt; fore : TColor);
begin
  SPerform(SCI_STYLESETFORE, style, ColorToRGB(fore));
end;

procedure TScintillaBase.StyleSetBack(style : LongInt; back : TColor);
begin
  SPerform(SCI_STYLESETBACK, style, ColorToRGB(back));
end;

procedure TScintillaBase.StyleSetBold(style : LongInt; bold : Boolean);
begin
  SPerform(SCI_STYLESETBOLD, style, LongInt(bold));
end;

procedure TScintillaBase.StyleSetItalic(style : LongInt; italic : Boolean);
begin
  SPerform(SCI_STYLESETITALIC, style, LongInt(italic));
end;

procedure TScintillaBase.StyleSetSize(style : LongInt; sizePoints : LongInt);
begin
  SPerform(SCI_STYLESETSIZE, style, sizePoints);
end;

procedure TScintillaBase.StyleSetFont(style : LongInt; fontName : PChar);
begin
  SPerform(SCI_STYLESETFONT, style, LongInt(fontName));
end;

procedure TScintillaBase.StyleSetEOLFilled(style : LongInt; filled : Boolean);
begin
  SPerform(SCI_STYLESETEOLFILLED, style, LongInt(filled));
end;

procedure TScintillaBase.StyleResetDefault;
begin
  SPerform(SCI_STYLERESETDEFAULT, 0, 0);
end;

procedure TScintillaBase.StyleSetUnderline(style : LongInt; underline : Boolean);
begin
  SPerform(SCI_STYLESETUNDERLINE, style, LongInt(underline));
end;

procedure TScintillaBase.StyleSetCase(style : LongInt; caseForce : LongInt);
begin
  SPerform(SCI_STYLESETCASE, style, caseForce);
end;

procedure TScintillaBase.StyleSetCharacterSet(style : LongInt; characterSet : LongInt);
begin
  SPerform(SCI_STYLESETCHARACTERSET, style, characterSet);
end;

procedure TScintillaBase.StyleSetHotSpot(style : LongInt; hotspot : Boolean);
begin
  SPerform(SCI_STYLESETHOTSPOT, style, LongInt(hotspot));
end;

procedure TScintillaBase.SetSelFore(useSetting : Boolean; fore : TColor);
begin
  SPerform(SCI_SETSELFORE, LongInt(useSetting), ColorToRGB(fore));
end;

procedure TScintillaBase.SetSelBack(useSetting : Boolean; back : TColor);
begin
  SPerform(SCI_SETSELBACK, LongInt(useSetting), ColorToRGB(back));
end;

function TScintillaBase.GetSelAlpha : LongInt;
begin
  result := SPerform(SCI_GETSELALPHA, 0, 0);
end;

procedure TScintillaBase.SetSelAlpha(alpha : LongInt);
begin
  SPerform(SCI_SETSELALPHA, alpha, 0);
end;

procedure TScintillaBase.SetCaretFore(fore : TColor);
begin
  SPerform(SCI_SETCARETFORE, ColorToRGB(fore), 0);
end;

procedure TScintillaBase.AssignCmdKey(km : LongInt; msg : LongInt);
begin
  SPerform(SCI_ASSIGNCMDKEY, km, msg);
end;

procedure TScintillaBase.ClearCmdKey(km : LongInt);
begin
  SPerform(SCI_CLEARCMDKEY, km, 0);
end;

procedure TScintillaBase.ClearAllCmdKeys;
begin
  SPerform(SCI_CLEARALLCMDKEYS, 0, 0);
end;

procedure TScintillaBase.SetStylingEx(length : LongInt; styles : PChar);
begin
  SPerform(SCI_SETSTYLINGEX, length, LongInt(styles));
end;

procedure TScintillaBase.StyleSetVisible(style : LongInt; visible : Boolean);
begin
  SPerform(SCI_STYLESETVISIBLE, style, LongInt(visible));
end;

function TScintillaBase.GetCaretPeriod : LongInt;
begin
  result := SPerform(SCI_GETCARETPERIOD, 0, 0);
end;

procedure TScintillaBase.SetCaretPeriod(periodMilliseconds : LongInt);
begin
  SPerform(SCI_SETCARETPERIOD, periodMilliseconds, 0);
end;

procedure TScintillaBase.SetWordChars(characters : PChar);
begin
  SPerform(SCI_SETWORDCHARS, 0, LongInt(characters));
end;

procedure TScintillaBase.BeginUndoAction;
begin
  SPerform(SCI_BEGINUNDOACTION, 0, 0);
end;

procedure TScintillaBase.EndUndoAction;
begin
  SPerform(SCI_ENDUNDOACTION, 0, 0);
end;

procedure TScintillaBase.IndicSetStyle(indic : LongInt; style : LongInt);
begin
  SPerform(SCI_INDICSETSTYLE, indic, style);
end;

function TScintillaBase.IndicGetStyle(indic : LongInt) : LongInt;
begin
  result := SPerform(SCI_INDICGETSTYLE, indic, 0);
end;

procedure TScintillaBase.IndicSetFore(indic : LongInt; fore : TColor);
begin
  SPerform(SCI_INDICSETFORE, indic, ColorToRGB(fore));
end;

function TScintillaBase.IndicGetFore(indic : LongInt) : TColor;
begin
  result := TColor(SPerform(SCI_INDICGETFORE, indic, 0));
end;

procedure TScintillaBase.SetWhitespaceFore(useSetting : Boolean; fore : TColor);
begin
  SPerform(SCI_SETWHITESPACEFORE, LongInt(useSetting), ColorToRGB(fore));
end;

procedure TScintillaBase.SetWhitespaceBack(useSetting : Boolean; back : TColor);
begin
  SPerform(SCI_SETWHITESPACEBACK, LongInt(useSetting), ColorToRGB(back));
end;

procedure TScintillaBase.SetStyleBits(bits : LongInt);
begin
  SPerform(SCI_SETSTYLEBITS, bits, 0);
end;

function TScintillaBase.GetStyleBits : LongInt;
begin
  result := SPerform(SCI_GETSTYLEBITS, 0, 0);
end;

procedure TScintillaBase.SetLineState(line : LongInt; state : LongInt);
begin
  SPerform(SCI_SETLINESTATE, line, state);
end;

function TScintillaBase.GetLineState(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETLINESTATE, line, 0);
end;

function TScintillaBase.GetMaxLineState : LongInt;
begin
  result := SPerform(SCI_GETMAXLINESTATE, 0, 0);
end;

function TScintillaBase.GetCaretLineVisible : Boolean;
begin
  result := Boolean(SPerform(SCI_GETCARETLINEVISIBLE, 0, 0));
end;

procedure TScintillaBase.SetCaretLineVisible(show : Boolean);
begin
  SPerform(SCI_SETCARETLINEVISIBLE, LongInt(show), 0);
end;

function TScintillaBase.GetCaretLineBack : TColor;
begin
  result := TColor(SPerform(SCI_GETCARETLINEBACK, 0, 0));
end;

procedure TScintillaBase.SetCaretLineBack(back : TColor);
begin
  SPerform(SCI_SETCARETLINEBACK, ColorToRGB(back), 0);
end;

procedure TScintillaBase.StyleSetChangeable(style : LongInt; changeable : Boolean);
begin
  SPerform(SCI_STYLESETCHANGEABLE, style, LongInt(changeable));
end;

procedure TScintillaBase.AutoCShow(lenEntered : LongInt; itemList : PChar);
begin
  SPerform(SCI_AUTOCSHOW, lenEntered, LongInt(itemList));
end;

procedure TScintillaBase.AutoCCancel;
begin
  SPerform(SCI_AUTOCCANCEL, 0, 0);
end;

function TScintillaBase.AutoCActive : Boolean;
begin
  result := Boolean(SPerform(SCI_AUTOCACTIVE, 0, 0));
end;

function TScintillaBase.AutoCPosStart : LongInt;
begin
  result := SPerform(SCI_AUTOCPOSSTART, 0, 0);
end;

procedure TScintillaBase.AutoCComplete;
begin
  SPerform(SCI_AUTOCCOMPLETE, 0, 0);
end;

procedure TScintillaBase.AutoCStops(characterSet : PChar);
begin
  SPerform(SCI_AUTOCSTOPS, 0, LongInt(characterSet));
end;

procedure TScintillaBase.AutoCSetSeparator(separatorCharacter : LongInt);
begin
  SPerform(SCI_AUTOCSETSEPARATOR, separatorCharacter, 0);
end;

function TScintillaBase.AutoCGetSeparator : LongInt;
begin
  result := SPerform(SCI_AUTOCGETSEPARATOR, 0, 0);
end;

procedure TScintillaBase.AutoCSelect(text : PChar);
begin
  SPerform(SCI_AUTOCSELECT, 0, LongInt(text));
end;

procedure TScintillaBase.AutoCSetCancelAtStart(cancel : Boolean);
begin
  SPerform(SCI_AUTOCSETCANCELATSTART, LongInt(cancel), 0);
end;

function TScintillaBase.AutoCGetCancelAtStart : Boolean;
begin
  result := Boolean(SPerform(SCI_AUTOCGETCANCELATSTART, 0, 0));
end;

procedure TScintillaBase.AutoCSetFillUps(characterSet : PChar);
begin
  SPerform(SCI_AUTOCSETFILLUPS, 0, LongInt(characterSet));
end;

procedure TScintillaBase.AutoCSetChooseSingle(chooseSingle : Boolean);
begin
  SPerform(SCI_AUTOCSETCHOOSESINGLE, LongInt(chooseSingle), 0);
end;

function TScintillaBase.AutoCGetChooseSingle : Boolean;
begin
  result := Boolean(SPerform(SCI_AUTOCGETCHOOSESINGLE, 0, 0));
end;

procedure TScintillaBase.AutoCSetIgnoreCase(ignoreCase : Boolean);
begin
  SPerform(SCI_AUTOCSETIGNORECASE, LongInt(ignoreCase), 0);
end;

function TScintillaBase.AutoCGetIgnoreCase : Boolean;
begin
  result := Boolean(SPerform(SCI_AUTOCGETIGNORECASE, 0, 0));
end;

procedure TScintillaBase.UserListShow(listType : LongInt; itemList : PChar);
begin
  SPerform(SCI_USERLISTSHOW, listType, LongInt(itemList));
end;

procedure TScintillaBase.AutoCSetAutoHide(autoHide : Boolean);
begin
  SPerform(SCI_AUTOCSETAUTOHIDE, LongInt(autoHide), 0);
end;

function TScintillaBase.AutoCGetAutoHide : Boolean;
begin
  result := Boolean(SPerform(SCI_AUTOCGETAUTOHIDE, 0, 0));
end;

procedure TScintillaBase.AutoCSetDropRestOfWord(dropRestOfWord : Boolean);
begin
  SPerform(SCI_AUTOCSETDROPRESTOFWORD, LongInt(dropRestOfWord), 0);
end;

function TScintillaBase.AutoCGetDropRestOfWord : Boolean;
begin
  result := Boolean(SPerform(SCI_AUTOCGETDROPRESTOFWORD, 0, 0));
end;

procedure TScintillaBase.RegisterImage(type_ : LongInt; xpmData : PChar);
begin
  SPerform(SCI_REGISTERIMAGE, type_, LongInt(xpmData));
end;

procedure TScintillaBase.ClearRegisteredImages;
begin
  SPerform(SCI_CLEARREGISTEREDIMAGES, 0, 0);
end;

function TScintillaBase.AutoCGetTypeSeparator : LongInt;
begin
  result := SPerform(SCI_AUTOCGETTYPESEPARATOR, 0, 0);
end;

procedure TScintillaBase.AutoCSetTypeSeparator(separatorCharacter : LongInt);
begin
  SPerform(SCI_AUTOCSETTYPESEPARATOR, separatorCharacter, 0);
end;

procedure TScintillaBase.AutoCSetMaxWidth(characterCount : LongInt);
begin
  SPerform(SCI_AUTOCSETMAXWIDTH, characterCount, 0);
end;

function TScintillaBase.AutoCGetMaxWidth : LongInt;
begin
  result := SPerform(SCI_AUTOCGETMAXWIDTH, 0, 0);
end;

procedure TScintillaBase.AutoCSetMaxHeight(rowCount : LongInt);
begin
  SPerform(SCI_AUTOCSETMAXHEIGHT, rowCount, 0);
end;

function TScintillaBase.AutoCGetMaxHeight : LongInt;
begin
  result := SPerform(SCI_AUTOCGETMAXHEIGHT, 0, 0);
end;

procedure TScintillaBase.SetIndent(indentSize : LongInt);
begin
  SPerform(SCI_SETINDENT, indentSize, 0);
end;

function TScintillaBase.GetIndent : LongInt;
begin
  result := SPerform(SCI_GETINDENT, 0, 0);
end;

procedure TScintillaBase.SetUseTabs(useTabs : Boolean);
begin
  SPerform(SCI_SETUSETABS, LongInt(useTabs), 0);
end;

function TScintillaBase.GetUseTabs : Boolean;
begin
  result := Boolean(SPerform(SCI_GETUSETABS, 0, 0));
end;

procedure TScintillaBase.SetLineIndentation(line : LongInt; indentSize : LongInt);
begin
  SPerform(SCI_SETLINEINDENTATION, line, indentSize);
end;

function TScintillaBase.GetLineIndentation(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETLINEINDENTATION, line, 0);
end;

function TScintillaBase.GetLineIndentPosition(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETLINEINDENTPOSITION, line, 0);
end;

function TScintillaBase.GetColumn(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETCOLUMN, pos, 0);
end;

procedure TScintillaBase.SetHScrollBar(show : Boolean);
begin
  SPerform(SCI_SETHSCROLLBAR, LongInt(show), 0);
end;

function TScintillaBase.GetHScrollBar : Boolean;
begin
  result := Boolean(SPerform(SCI_GETHSCROLLBAR, 0, 0));
end;

procedure TScintillaBase.SetIndentationGuides(show : Boolean);
begin
  SPerform(SCI_SETINDENTATIONGUIDES, LongInt(show), 0);
end;

function TScintillaBase.GetIndentationGuides : Boolean;
begin
  result := Boolean(SPerform(SCI_GETINDENTATIONGUIDES, 0, 0));
end;

procedure TScintillaBase.SetHighlightGuide(column : LongInt);
begin
  SPerform(SCI_SETHIGHLIGHTGUIDE, column, 0);
end;

function TScintillaBase.GetHighlightGuide : LongInt;
begin
  result := SPerform(SCI_GETHIGHLIGHTGUIDE, 0, 0);
end;

function TScintillaBase.GetLineEndPosition(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETLINEENDPOSITION, line, 0);
end;

function TScintillaBase.GetCodePage : LongInt;
begin
  result := SPerform(SCI_GETCODEPAGE, 0, 0);
end;

function TScintillaBase.GetCaretFore : TColor;
begin
  result := TColor(SPerform(SCI_GETCARETFORE, 0, 0));
end;

function TScintillaBase.GetUsePalette : Boolean;
begin
  result := Boolean(SPerform(SCI_GETUSEPALETTE, 0, 0));
end;

function TScintillaBase.GetReadOnly : Boolean;
begin
  result := Boolean(SPerform(SCI_GETREADONLY, 0, 0));
end;

procedure TScintillaBase.SetCurrentPos(pos : LongInt);
begin
  SPerform(SCI_SETCURRENTPOS, pos, 0);
end;

procedure TScintillaBase.SetSelectionStart(pos : LongInt);
begin
  SPerform(SCI_SETSELECTIONSTART, pos, 0);
end;

function TScintillaBase.GetSelectionStart : LongInt;
begin
  result := SPerform(SCI_GETSELECTIONSTART, 0, 0);
end;

procedure TScintillaBase.SetSelectionEnd(pos : LongInt);
begin
  SPerform(SCI_SETSELECTIONEND, pos, 0);
end;

function TScintillaBase.GetSelectionEnd : LongInt;
begin
  result := SPerform(SCI_GETSELECTIONEND, 0, 0);
end;

procedure TScintillaBase.SetPrintMagnification(magnification : LongInt);
begin
  SPerform(SCI_SETPRINTMAGNIFICATION, magnification, 0);
end;

function TScintillaBase.GetPrintMagnification : LongInt;
begin
  result := SPerform(SCI_GETPRINTMAGNIFICATION, 0, 0);
end;

procedure TScintillaBase.SetPrintColourMode(mode : LongInt);
begin
  SPerform(SCI_SETPRINTCOLOURMODE, mode, 0);
end;

function TScintillaBase.GetPrintColourMode : LongInt;
begin
  result := SPerform(SCI_GETPRINTCOLOURMODE, 0, 0);
end;

function TScintillaBase.FindTextX(flags : LongInt; ft : PTextToFind) : LongInt;
begin
  result := SPerform(SCI_FINDTEXT, flags, LongInt(ft));
end;

function TScintillaBase.FormatRange(draw : Boolean; fr : PRangeToFormat) : LongInt;
begin
  result := SPerform(SCI_FORMATRANGE, LongInt(draw), LongInt(fr));
end;

function TScintillaBase.GetFirstVisibleLine : LongInt;
begin
  result := SPerform(SCI_GETFIRSTVISIBLELINE, 0, 0);
end;

function TScintillaBase.GetLine(line : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_GETLINE, line, LongInt(text));
end;

function TScintillaBase.GetLineCount : LongInt;
begin
  result := SPerform(SCI_GETLINECOUNT, 0, 0);
end;

procedure TScintillaBase.SetMarginLeft(pixelWidth : LongInt);
begin
  SPerform(SCI_SETMARGINLEFT, 0, pixelWidth);
end;

function TScintillaBase.GetMarginLeft : LongInt;
begin
  result := SPerform(SCI_GETMARGINLEFT, 0, 0);
end;

procedure TScintillaBase.SetMarginRight(pixelWidth : LongInt);
begin
  SPerform(SCI_SETMARGINRIGHT, 0, pixelWidth);
end;

function TScintillaBase.GetMarginRight : LongInt;
begin
  result := SPerform(SCI_GETMARGINRIGHT, 0, 0);
end;

function TScintillaBase.GetModify : Boolean;
begin
  result := Boolean(SPerform(SCI_GETMODIFY, 0, 0));
end;

procedure TScintillaBase.SetSel(start : LongInt; end_ : LongInt);
begin
  SPerform(SCI_SETSEL, start, end_);
end;

function TScintillaBase.GetSelText(text : PChar) : LongInt;
begin
  result := SPerform(SCI_GETSELTEXT, 0, LongInt(text));
end;

function TScintillaBase.GetTextRange(tr : PTextRange) : LongInt;
begin
  result := SPerform(SCI_GETTEXTRANGE, 0, LongInt(tr));
end;

procedure TScintillaBase.HideSelection(normal : Boolean);
begin
  SPerform(SCI_HIDESELECTION, LongInt(normal), 0);
end;

function TScintillaBase.PointXFromPosition(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_POINTXFROMPOSITION, 0, pos);
end;

function TScintillaBase.PointYFromPosition(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_POINTYFROMPOSITION, 0, pos);
end;

function TScintillaBase.LineFromPosition(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_LINEFROMPOSITION, pos, 0);
end;

function TScintillaBase.PositionFromLine(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_POSITIONFROMLINE, line, 0);
end;

procedure TScintillaBase.LineScroll(columns : LongInt; lines : LongInt);
begin
  SPerform(SCI_LINESCROLL, columns, lines);
end;

procedure TScintillaBase.ScrollCaret;
begin
  SPerform(SCI_SCROLLCARET, 0, 0);
end;

procedure TScintillaBase.ReplaceSel(text : PChar);
begin
  SPerform(SCI_REPLACESEL, 0, LongInt(text));
end;

procedure TScintillaBase.SetReadOnly(readOnly : Boolean);
begin
  SPerform(SCI_SETREADONLY, LongInt(readOnly), 0);
end;

procedure TScintillaBase.Null;
begin
  SPerform(SCI_NULL, 0, 0);
end;

function TScintillaBase.CanPaste : Boolean;
begin
  result := Boolean(SPerform(SCI_CANPASTE, 0, 0));
end;

function TScintillaBase.CanUndo : Boolean;
begin
  result := Boolean(SPerform(SCI_CANUNDO, 0, 0));
end;

procedure TScintillaBase.EmptyUndoBuffer;
begin
  SPerform(SCI_EMPTYUNDOBUFFER, 0, 0);
end;

procedure TScintillaBase.Undo;
begin
  SPerform(SCI_UNDO, 0, 0);
end;

procedure TScintillaBase.Cut;
begin
  SPerform(SCI_CUT, 0, 0);
end;

procedure TScintillaBase.Copy;
begin
  SPerform(SCI_COPY, 0, 0);
end;

procedure TScintillaBase.Paste;
begin
  SPerform(SCI_PASTE, 0, 0);
end;

procedure TScintillaBase.Clear;
begin
  SPerform(SCI_CLEAR, 0, 0);
end;

procedure TScintillaBase.SetText(text : PChar);
begin
  SPerform(SCI_SETTEXT, 0, LongInt(text));
end;

function TScintillaBase.GetText(length : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_GETTEXT, length, LongInt(text));
end;

function TScintillaBase.GetTextLength : LongInt;
begin
  result := SPerform(SCI_GETTEXTLENGTH, 0, 0);
end;

function TScintillaBase.GetDirectFunction : LongInt;
begin
  result := SPerform(SCI_GETDIRECTFUNCTION, 0, 0);
end;

function TScintillaBase.GetDirectPointer : LongInt;
begin
  result := SPerform(SCI_GETDIRECTPOINTER, 0, 0);
end;

procedure TScintillaBase.SetOvertype(overtype : Boolean);
begin
  SPerform(SCI_SETOVERTYPE, LongInt(overtype), 0);
end;

function TScintillaBase.GetOvertype : Boolean;
begin
  result := Boolean(SPerform(SCI_GETOVERTYPE, 0, 0));
end;

procedure TScintillaBase.SetCaretWidth(pixelWidth : LongInt);
begin
  SPerform(SCI_SETCARETWIDTH, pixelWidth, 0);
end;

function TScintillaBase.GetCaretWidth : LongInt;
begin
  result := SPerform(SCI_GETCARETWIDTH, 0, 0);
end;

procedure TScintillaBase.SetTargetStart(pos : LongInt);
begin
  SPerform(SCI_SETTARGETSTART, pos, 0);
end;

function TScintillaBase.GetTargetStart : LongInt;
begin
  result := SPerform(SCI_GETTARGETSTART, 0, 0);
end;

procedure TScintillaBase.SetTargetEnd(pos : LongInt);
begin
  SPerform(SCI_SETTARGETEND, pos, 0);
end;

function TScintillaBase.GetTargetEnd : LongInt;
begin
  result := SPerform(SCI_GETTARGETEND, 0, 0);
end;

function TScintillaBase.ReplaceTarget(length : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_REPLACETARGET, length, LongInt(text));
end;

function TScintillaBase.ReplaceTargetRE(length : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_REPLACETARGETRE, length, LongInt(text));
end;

function TScintillaBase.SearchInTarget(length : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_SEARCHINTARGET, length, LongInt(text));
end;

procedure TScintillaBase.SetSearchFlags(flags : LongInt);
begin
  SPerform(SCI_SETSEARCHFLAGS, flags, 0);
end;

function TScintillaBase.GetSearchFlags : LongInt;
begin
  result := SPerform(SCI_GETSEARCHFLAGS, 0, 0);
end;

procedure TScintillaBase.CallTipShow(pos : LongInt; definition : PChar);
begin
  SPerform(SCI_CALLTIPSHOW, pos, LongInt(definition));
end;

procedure TScintillaBase.CallTipCancel;
begin
  SPerform(SCI_CALLTIPCANCEL, 0, 0);
end;

function TScintillaBase.CallTipActive : Boolean;
begin
  result := Boolean(SPerform(SCI_CALLTIPACTIVE, 0, 0));
end;

function TScintillaBase.CallTipPosStart : LongInt;
begin
  result := SPerform(SCI_CALLTIPPOSSTART, 0, 0);
end;

procedure TScintillaBase.CallTipSetHlt(start : LongInt; end_ : LongInt);
begin
  SPerform(SCI_CALLTIPSETHLT, start, end_);
end;

procedure TScintillaBase.CallTipSetBack(back : TColor);
begin
  SPerform(SCI_CALLTIPSETBACK, ColorToRGB(back), 0);
end;

procedure TScintillaBase.CallTipSetFore(fore : TColor);
begin
  SPerform(SCI_CALLTIPSETFORE, ColorToRGB(fore), 0);
end;

procedure TScintillaBase.CallTipSetForeHlt(fore : TColor);
begin
  SPerform(SCI_CALLTIPSETFOREHLT, ColorToRGB(fore), 0);
end;

procedure TScintillaBase.CallTipUseStyle(tabSize : LongInt);
begin
  SPerform(SCI_CALLTIPUSESTYLE, tabSize, 0);
end;

function TScintillaBase.VisibleFromDocLine(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_VISIBLEFROMDOCLINE, line, 0);
end;

function TScintillaBase.DocLineFromVisible(lineDisplay : LongInt) : LongInt;
begin
  result := SPerform(SCI_DOCLINEFROMVISIBLE, lineDisplay, 0);
end;

function TScintillaBase.WrapCount(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_WRAPCOUNT, line, 0);
end;

procedure TScintillaBase.SetFoldLevel(line : LongInt; level : LongInt);
begin
  SPerform(SCI_SETFOLDLEVEL, line, level);
end;

function TScintillaBase.GetFoldLevel(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETFOLDLEVEL, line, 0);
end;

function TScintillaBase.GetLastChild(line : LongInt; level : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETLASTCHILD, line, level);
end;

function TScintillaBase.GetFoldParent(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETFOLDPARENT, line, 0);
end;

procedure TScintillaBase.ShowLines(lineStart : LongInt; lineEnd : LongInt);
begin
  SPerform(SCI_SHOWLINES, lineStart, lineEnd);
end;

procedure TScintillaBase.HideLines(lineStart : LongInt; lineEnd : LongInt);
begin
  SPerform(SCI_HIDELINES, lineStart, lineEnd);
end;

function TScintillaBase.GetLineVisible(line : LongInt) : Boolean;
begin
  result := Boolean(SPerform(SCI_GETLINEVISIBLE, line, 0));
end;

procedure TScintillaBase.SetFoldExpanded(line : LongInt; expanded : Boolean);
begin
  SPerform(SCI_SETFOLDEXPANDED, line, LongInt(expanded));
end;

function TScintillaBase.GetFoldExpanded(line : LongInt) : Boolean;
begin
  result := Boolean(SPerform(SCI_GETFOLDEXPANDED, line, 0));
end;

procedure TScintillaBase.ToggleFold(line : LongInt);
begin
  SPerform(SCI_TOGGLEFOLD, line, 0);
end;

procedure TScintillaBase.EnsureVisible(line : LongInt);
begin
  SPerform(SCI_ENSUREVISIBLE, line, 0);
end;

procedure TScintillaBase.SetFoldFlags(flags : LongInt);
begin
  SPerform(SCI_SETFOLDFLAGS, flags, 0);
end;

procedure TScintillaBase.EnsureVisibleEnforcePolicy(line : LongInt);
begin
  SPerform(SCI_ENSUREVISIBLEENFORCEPOLICY, line, 0);
end;

procedure TScintillaBase.SetTabIndents(tabIndents : Boolean);
begin
  SPerform(SCI_SETTABINDENTS, LongInt(tabIndents), 0);
end;

function TScintillaBase.GetTabIndents : Boolean;
begin
  result := Boolean(SPerform(SCI_GETTABINDENTS, 0, 0));
end;

procedure TScintillaBase.SetBackSpaceUnIndents(bsUnIndents : Boolean);
begin
  SPerform(SCI_SETBACKSPACEUNINDENTS, LongInt(bsUnIndents), 0);
end;

function TScintillaBase.GetBackSpaceUnIndents : Boolean;
begin
  result := Boolean(SPerform(SCI_GETBACKSPACEUNINDENTS, 0, 0));
end;

procedure TScintillaBase.SetMouseDwellTime(periodMilliseconds : LongInt);
begin
  SPerform(SCI_SETMOUSEDWELLTIME, periodMilliseconds, 0);
end;

function TScintillaBase.GetMouseDwellTime : LongInt;
begin
  result := SPerform(SCI_GETMOUSEDWELLTIME, 0, 0);
end;

function TScintillaBase.WordStartPosition(pos : LongInt; onlyWordCharacters : Boolean) : LongInt;
begin
  result := SPerform(SCI_WORDSTARTPOSITION, pos, LongInt(onlyWordCharacters));
end;

function TScintillaBase.WordEndPosition(pos : LongInt; onlyWordCharacters : Boolean) : LongInt;
begin
  result := SPerform(SCI_WORDENDPOSITION, pos, LongInt(onlyWordCharacters));
end;

procedure TScintillaBase.SetWrapMode(mode : LongInt);
begin
  SPerform(SCI_SETWRAPMODE, mode, 0);
end;

function TScintillaBase.GetWrapMode : LongInt;
begin
  result := SPerform(SCI_GETWRAPMODE, 0, 0);
end;

procedure TScintillaBase.SetWrapVisualFlags(wrapVisualFlags : LongInt);
begin
  SPerform(SCI_SETWRAPVISUALFLAGS, wrapVisualFlags, 0);
end;

function TScintillaBase.GetWrapVisualFlags : LongInt;
begin
  result := SPerform(SCI_GETWRAPVISUALFLAGS, 0, 0);
end;

procedure TScintillaBase.SetWrapVisualFlagsLocation(wrapVisualFlagsLocation : LongInt);
begin
  SPerform(SCI_SETWRAPVISUALFLAGSLOCATION, wrapVisualFlagsLocation, 0);
end;

function TScintillaBase.GetWrapVisualFlagsLocation : LongInt;
begin
  result := SPerform(SCI_GETWRAPVISUALFLAGSLOCATION, 0, 0);
end;

procedure TScintillaBase.SetWrapStartIndent(indent : LongInt);
begin
  SPerform(SCI_SETWRAPSTARTINDENT, indent, 0);
end;

function TScintillaBase.GetWrapStartIndent : LongInt;
begin
  result := SPerform(SCI_GETWRAPSTARTINDENT, 0, 0);
end;

procedure TScintillaBase.SetLayoutCache(mode : LongInt);
begin
  SPerform(SCI_SETLAYOUTCACHE, mode, 0);
end;

function TScintillaBase.GetLayoutCache : LongInt;
begin
  result := SPerform(SCI_GETLAYOUTCACHE, 0, 0);
end;

procedure TScintillaBase.SetScrollWidth(pixelWidth : LongInt);
begin
  SPerform(SCI_SETSCROLLWIDTH, pixelWidth, 0);
end;

function TScintillaBase.GetScrollWidth : LongInt;
begin
  result := SPerform(SCI_GETSCROLLWIDTH, 0, 0);
end;

function TScintillaBase.TextWidth(style : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_TEXTWIDTH, style, LongInt(text));
end;

procedure TScintillaBase.SetEndAtLastLine(endAtLastLine : Boolean);
begin
  SPerform(SCI_SETENDATLASTLINE, LongInt(endAtLastLine), 0);
end;

function TScintillaBase.GetEndAtLastLine : Boolean;
begin
  result := Boolean(SPerform(SCI_GETENDATLASTLINE, 0, 0));
end;

function TScintillaBase.TextHeight(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_TEXTHEIGHT, line, 0);
end;

procedure TScintillaBase.SetVScrollBar(show : Boolean);
begin
  SPerform(SCI_SETVSCROLLBAR, LongInt(show), 0);
end;

function TScintillaBase.GetVScrollBar : Boolean;
begin
  result := Boolean(SPerform(SCI_GETVSCROLLBAR, 0, 0));
end;

procedure TScintillaBase.AppendText(length : LongInt; text : PChar);
begin
  SPerform(SCI_APPENDTEXT, length, LongInt(text));
end;

function TScintillaBase.GetTwoPhaseDraw : Boolean;
begin
  result := Boolean(SPerform(SCI_GETTWOPHASEDRAW, 0, 0));
end;

procedure TScintillaBase.SetTwoPhaseDraw(twoPhase : Boolean);
begin
  SPerform(SCI_SETTWOPHASEDRAW, LongInt(twoPhase), 0);
end;

procedure TScintillaBase.TargetFromSelection;
begin
  SPerform(SCI_TARGETFROMSELECTION, 0, 0);
end;

procedure TScintillaBase.LinesJoin;
begin
  SPerform(SCI_LINESJOIN, 0, 0);
end;

procedure TScintillaBase.LinesSplit(pixelWidth : LongInt);
begin
  SPerform(SCI_LINESSPLIT, pixelWidth, 0);
end;

procedure TScintillaBase.SetFoldMarginColour(useSetting : Boolean; back : TColor);
begin
  SPerform(SCI_SETFOLDMARGINCOLOUR, LongInt(useSetting), ColorToRGB(back));
end;

procedure TScintillaBase.SetFoldMarginHiColour(useSetting : Boolean; fore : TColor);
begin
  SPerform(SCI_SETFOLDMARGINHICOLOUR, LongInt(useSetting), ColorToRGB(fore));
end;

procedure TScintillaBase.LineDown;
begin
  SPerform(SCI_LINEDOWN, 0, 0);
end;

procedure TScintillaBase.LineDownExtend;
begin
  SPerform(SCI_LINEDOWNEXTEND, 0, 0);
end;

procedure TScintillaBase.LineUp;
begin
  SPerform(SCI_LINEUP, 0, 0);
end;

procedure TScintillaBase.LineUpExtend;
begin
  SPerform(SCI_LINEUPEXTEND, 0, 0);
end;

procedure TScintillaBase.CharLeft;
begin
  SPerform(SCI_CHARLEFT, 0, 0);
end;

procedure TScintillaBase.CharLeftExtend;
begin
  SPerform(SCI_CHARLEFTEXTEND, 0, 0);
end;

procedure TScintillaBase.CharRight;
begin
  SPerform(SCI_CHARRIGHT, 0, 0);
end;

procedure TScintillaBase.CharRightExtend;
begin
  SPerform(SCI_CHARRIGHTEXTEND, 0, 0);
end;

procedure TScintillaBase.WordLeft;
begin
  SPerform(SCI_WORDLEFT, 0, 0);
end;

procedure TScintillaBase.WordLeftExtend;
begin
  SPerform(SCI_WORDLEFTEXTEND, 0, 0);
end;

procedure TScintillaBase.WordRight;
begin
  SPerform(SCI_WORDRIGHT, 0, 0);
end;

procedure TScintillaBase.WordRightExtend;
begin
  SPerform(SCI_WORDRIGHTEXTEND, 0, 0);
end;

procedure TScintillaBase.Home;
begin
  SPerform(SCI_HOME, 0, 0);
end;

procedure TScintillaBase.HomeExtend;
begin
  SPerform(SCI_HOMEEXTEND, 0, 0);
end;

procedure TScintillaBase.LineEnd;
begin
  SPerform(SCI_LINEEND, 0, 0);
end;

procedure TScintillaBase.LineEndExtend;
begin
  SPerform(SCI_LINEENDEXTEND, 0, 0);
end;

procedure TScintillaBase.DocumentStart;
begin
  SPerform(SCI_DOCUMENTSTART, 0, 0);
end;

procedure TScintillaBase.DocumentStartExtend;
begin
  SPerform(SCI_DOCUMENTSTARTEXTEND, 0, 0);
end;

procedure TScintillaBase.DocumentEnd;
begin
  SPerform(SCI_DOCUMENTEND, 0, 0);
end;

procedure TScintillaBase.DocumentEndExtend;
begin
  SPerform(SCI_DOCUMENTENDEXTEND, 0, 0);
end;

procedure TScintillaBase.PageUp;
begin
  SPerform(SCI_PAGEUP, 0, 0);
end;

procedure TScintillaBase.PageUpExtend;
begin
  SPerform(SCI_PAGEUPEXTEND, 0, 0);
end;

procedure TScintillaBase.PageDown;
begin
  SPerform(SCI_PAGEDOWN, 0, 0);
end;

procedure TScintillaBase.PageDownExtend;
begin
  SPerform(SCI_PAGEDOWNEXTEND, 0, 0);
end;

procedure TScintillaBase.EditToggleOvertype;
begin
  SPerform(SCI_EDITTOGGLEOVERTYPE, 0, 0);
end;

procedure TScintillaBase.Cancel;
begin
  SPerform(SCI_CANCEL, 0, 0);
end;

procedure TScintillaBase.DeleteBack;
begin
  SPerform(SCI_DELETEBACK, 0, 0);
end;

procedure TScintillaBase.Tab;
begin
  SPerform(SCI_TAB, 0, 0);
end;

procedure TScintillaBase.BackTab;
begin
  SPerform(SCI_BACKTAB, 0, 0);
end;

procedure TScintillaBase.NewLine;
begin
  SPerform(SCI_NEWLINE, 0, 0);
end;

procedure TScintillaBase.FormFeed;
begin
  SPerform(SCI_FORMFEED, 0, 0);
end;

procedure TScintillaBase.VCHome;
begin
  SPerform(SCI_VCHOME, 0, 0);
end;

procedure TScintillaBase.VCHomeExtend;
begin
  SPerform(SCI_VCHOMEEXTEND, 0, 0);
end;

procedure TScintillaBase.ZoomIn;
begin
  SPerform(SCI_ZOOMIN, 0, 0);
end;

procedure TScintillaBase.ZoomOut;
begin
  SPerform(SCI_ZOOMOUT, 0, 0);
end;

procedure TScintillaBase.DelWordLeft;
begin
  SPerform(SCI_DELWORDLEFT, 0, 0);
end;

procedure TScintillaBase.DelWordRight;
begin
  SPerform(SCI_DELWORDRIGHT, 0, 0);
end;

procedure TScintillaBase.LineCut;
begin
  SPerform(SCI_LINECUT, 0, 0);
end;

procedure TScintillaBase.LineDelete;
begin
  SPerform(SCI_LINEDELETE, 0, 0);
end;

procedure TScintillaBase.LineTranspose;
begin
  SPerform(SCI_LINETRANSPOSE, 0, 0);
end;

procedure TScintillaBase.LineDuplicate;
begin
  SPerform(SCI_LINEDUPLICATE, 0, 0);
end;

procedure TScintillaBase.LowerCase;
begin
  SPerform(SCI_LOWERCASE, 0, 0);
end;

procedure TScintillaBase.UpperCase;
begin
  SPerform(SCI_UPPERCASE, 0, 0);
end;

procedure TScintillaBase.LineScrollDown;
begin
  SPerform(SCI_LINESCROLLDOWN, 0, 0);
end;

procedure TScintillaBase.LineScrollUp;
begin
  SPerform(SCI_LINESCROLLUP, 0, 0);
end;

procedure TScintillaBase.DeleteBackNotLine;
begin
  SPerform(SCI_DELETEBACKNOTLINE, 0, 0);
end;

procedure TScintillaBase.HomeDisplay;
begin
  SPerform(SCI_HOMEDISPLAY, 0, 0);
end;

procedure TScintillaBase.HomeDisplayExtend;
begin
  SPerform(SCI_HOMEDISPLAYEXTEND, 0, 0);
end;

procedure TScintillaBase.LineEndDisplay;
begin
  SPerform(SCI_LINEENDDISPLAY, 0, 0);
end;

procedure TScintillaBase.LineEndDisplayExtend;
begin
  SPerform(SCI_LINEENDDISPLAYEXTEND, 0, 0);
end;

procedure TScintillaBase.HomeWrap;
begin
  SPerform(SCI_HOMEWRAP, 0, 0);
end;

procedure TScintillaBase.HomeWrapExtend;
begin
  SPerform(SCI_HOMEWRAPEXTEND, 0, 0);
end;

procedure TScintillaBase.LineEndWrap;
begin
  SPerform(SCI_LINEENDWRAP, 0, 0);
end;

procedure TScintillaBase.LineEndWrapExtend;
begin
  SPerform(SCI_LINEENDWRAPEXTEND, 0, 0);
end;

procedure TScintillaBase.VCHomeWrap;
begin
  SPerform(SCI_VCHOMEWRAP, 0, 0);
end;

procedure TScintillaBase.VCHomeWrapExtend;
begin
  SPerform(SCI_VCHOMEWRAPEXTEND, 0, 0);
end;

procedure TScintillaBase.LineCopy;
begin
  SPerform(SCI_LINECOPY, 0, 0);
end;

procedure TScintillaBase.MoveCaretInsideView;
begin
  SPerform(SCI_MOVECARETINSIDEVIEW, 0, 0);
end;

function TScintillaBase.LineLength(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_LINELENGTH, line, 0);
end;

procedure TScintillaBase.BraceHighlight(pos1 : LongInt; pos2 : LongInt);
begin
  SPerform(SCI_BRACEHIGHLIGHT, pos1, pos2);
end;

procedure TScintillaBase.BraceBadLight(pos : LongInt);
begin
  SPerform(SCI_BRACEBADLIGHT, pos, 0);
end;

function TScintillaBase.BraceMatch(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_BRACEMATCH, pos, 0);
end;

function TScintillaBase.GetViewEOL : Boolean;
begin
  result := Boolean(SPerform(SCI_GETVIEWEOL, 0, 0));
end;

procedure TScintillaBase.SetViewEOL(visible : Boolean);
begin
  SPerform(SCI_SETVIEWEOL, LongInt(visible), 0);
end;

function TScintillaBase.GetDocPointer : LongInt;
begin
  result := SPerform(SCI_GETDOCPOINTER, 0, 0);
end;

procedure TScintillaBase.SetDocPointer(pointer : LongInt);
begin
  SPerform(SCI_SETDOCPOINTER, 0, pointer);
end;

procedure TScintillaBase.SetModEventMask(mask : LongInt);
begin
  SPerform(SCI_SETMODEVENTMASK, mask, 0);
end;

function TScintillaBase.GetEdgeColumn : LongInt;
begin
  result := SPerform(SCI_GETEDGECOLUMN, 0, 0);
end;

procedure TScintillaBase.SetEdgeColumn(column : LongInt);
begin
  SPerform(SCI_SETEDGECOLUMN, column, 0);
end;

function TScintillaBase.GetEdgeMode : LongInt;
begin
  result := SPerform(SCI_GETEDGEMODE, 0, 0);
end;

procedure TScintillaBase.SetEdgeMode(mode : LongInt);
begin
  SPerform(SCI_SETEDGEMODE, mode, 0);
end;

function TScintillaBase.GetEdgeColour : TColor;
begin
  result := TColor(SPerform(SCI_GETEDGECOLOUR, 0, 0));
end;

procedure TScintillaBase.SetEdgeColour(edgeColour : TColor);
begin
  SPerform(SCI_SETEDGECOLOUR, ColorToRGB(edgeColour), 0);
end;

procedure TScintillaBase.SearchAnchor;
begin
  SPerform(SCI_SEARCHANCHOR, 0, 0);
end;

function TScintillaBase.SearchNext(flags : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_SEARCHNEXT, flags, LongInt(text));
end;

function TScintillaBase.SearchPrev(flags : LongInt; text : PChar) : LongInt;
begin
  result := SPerform(SCI_SEARCHPREV, flags, LongInt(text));
end;

function TScintillaBase.LinesOnScreen : LongInt;
begin
  result := SPerform(SCI_LINESONSCREEN, 0, 0);
end;

procedure TScintillaBase.UsePopUp(allowPopUp : Boolean);
begin
  SPerform(SCI_USEPOPUP, LongInt(allowPopUp), 0);
end;

function TScintillaBase.SelectionIsRectangle : Boolean;
begin
  result := Boolean(SPerform(SCI_SELECTIONISRECTANGLE, 0, 0));
end;

procedure TScintillaBase.SetZoom(zoom : LongInt);
begin
  SPerform(SCI_SETZOOM, zoom, 0);
end;

function TScintillaBase.GetZoom : LongInt;
begin
  result := SPerform(SCI_GETZOOM, 0, 0);
end;

function TScintillaBase.CreateDocument : LongInt;
begin
  result := SPerform(SCI_CREATEDOCUMENT, 0, 0);
end;

procedure TScintillaBase.AddRefDocument(doc : LongInt);
begin
  SPerform(SCI_ADDREFDOCUMENT, 0, doc);
end;

procedure TScintillaBase.ReleaseDocument(doc : LongInt);
begin
  SPerform(SCI_RELEASEDOCUMENT, 0, doc);
end;

function TScintillaBase.GetModEventMask : LongInt;
begin
  result := SPerform(SCI_GETMODEVENTMASK, 0, 0);
end;

procedure TScintillaBase.SetFocusEx(focus : Boolean);
begin
  SPerform(SCI_SETFOCUSEX, LongInt(focus), 0);
end;

function TScintillaBase.GetFocus : Boolean;
begin
  result := Boolean(SPerform(SCI_GETFOCUS, 0, 0));
end;

procedure TScintillaBase.SetStatus(statusCode : LongInt);
begin
  SPerform(SCI_SETSTATUS, statusCode, 0);
end;

function TScintillaBase.GetStatus : LongInt;
begin
  result := SPerform(SCI_GETSTATUS, 0, 0);
end;

procedure TScintillaBase.SetMouseDownCaptures(captures : Boolean);
begin
  SPerform(SCI_SETMOUSEDOWNCAPTURES, LongInt(captures), 0);
end;

function TScintillaBase.GetMouseDownCaptures : Boolean;
begin
  result := Boolean(SPerform(SCI_GETMOUSEDOWNCAPTURES, 0, 0));
end;

procedure TScintillaBase.SetCursor(cursorType : LongInt);
begin
  SPerform(SCI_SETCURSOR, cursorType, 0);
end;

function TScintillaBase.GetCursor : LongInt;
begin
  result := SPerform(SCI_GETCURSOR, 0, 0);
end;

procedure TScintillaBase.SetControlCharSymbol(symbol : LongInt);
begin
  SPerform(SCI_SETCONTROLCHARSYMBOL, symbol, 0);
end;

function TScintillaBase.GetControlCharSymbol : LongInt;
begin
  result := SPerform(SCI_GETCONTROLCHARSYMBOL, 0, 0);
end;

procedure TScintillaBase.WordPartLeft;
begin
  SPerform(SCI_WORDPARTLEFT, 0, 0);
end;

procedure TScintillaBase.WordPartLeftExtend;
begin
  SPerform(SCI_WORDPARTLEFTEXTEND, 0, 0);
end;

procedure TScintillaBase.WordPartRight;
begin
  SPerform(SCI_WORDPARTRIGHT, 0, 0);
end;

procedure TScintillaBase.WordPartRightExtend;
begin
  SPerform(SCI_WORDPARTRIGHTEXTEND, 0, 0);
end;

procedure TScintillaBase.SetVisiblePolicy(visiblePolicy : LongInt; visibleSlop : LongInt);
begin
  SPerform(SCI_SETVISIBLEPOLICY, visiblePolicy, visibleSlop);
end;

procedure TScintillaBase.DelLineLeft;
begin
  SPerform(SCI_DELLINELEFT, 0, 0);
end;

procedure TScintillaBase.DelLineRight;
begin
  SPerform(SCI_DELLINERIGHT, 0, 0);
end;

procedure TScintillaBase.SetXOffset(newOffset : LongInt);
begin
  SPerform(SCI_SETXOFFSET, newOffset, 0);
end;

function TScintillaBase.GetXOffset : LongInt;
begin
  result := SPerform(SCI_GETXOFFSET, 0, 0);
end;

procedure TScintillaBase.ChooseCaretX;
begin
  SPerform(SCI_CHOOSECARETX, 0, 0);
end;

procedure TScintillaBase.GrabFocus;
begin
  SPerform(SCI_GRABFOCUS, 0, 0);
end;

procedure TScintillaBase.SetXCaretPolicy(caretPolicy : LongInt; caretSlop : LongInt);
begin
  SPerform(SCI_SETXCARETPOLICY, caretPolicy, caretSlop);
end;

procedure TScintillaBase.SetYCaretPolicy(caretPolicy : LongInt; caretSlop : LongInt);
begin
  SPerform(SCI_SETYCARETPOLICY, caretPolicy, caretSlop);
end;

procedure TScintillaBase.SetPrintWrapMode(mode : LongInt);
begin
  SPerform(SCI_SETPRINTWRAPMODE, mode, 0);
end;

function TScintillaBase.GetPrintWrapMode : LongInt;
begin
  result := SPerform(SCI_GETPRINTWRAPMODE, 0, 0);
end;

procedure TScintillaBase.SetHotspotActiveFore(useSetting : Boolean; fore : TColor);
begin
  SPerform(SCI_SETHOTSPOTACTIVEFORE, LongInt(useSetting), ColorToRGB(fore));
end;

procedure TScintillaBase.SetHotspotActiveBack(useSetting : Boolean; back : TColor);
begin
  SPerform(SCI_SETHOTSPOTACTIVEBACK, LongInt(useSetting), ColorToRGB(back));
end;

procedure TScintillaBase.SetHotspotActiveUnderline(underline : Boolean);
begin
  SPerform(SCI_SETHOTSPOTACTIVEUNDERLINE, LongInt(underline), 0);
end;

procedure TScintillaBase.SetHotspotSingleLine(singleLine : Boolean);
begin
  SPerform(SCI_SETHOTSPOTSINGLELINE, LongInt(singleLine), 0);
end;

procedure TScintillaBase.ParaDown;
begin
  SPerform(SCI_PARADOWN, 0, 0);
end;

procedure TScintillaBase.ParaDownExtend;
begin
  SPerform(SCI_PARADOWNEXTEND, 0, 0);
end;

procedure TScintillaBase.ParaUp;
begin
  SPerform(SCI_PARAUP, 0, 0);
end;

procedure TScintillaBase.ParaUpExtend;
begin
  SPerform(SCI_PARAUPEXTEND, 0, 0);
end;

function TScintillaBase.PositionBefore(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_POSITIONBEFORE, pos, 0);
end;

function TScintillaBase.PositionAfter(pos : LongInt) : LongInt;
begin
  result := SPerform(SCI_POSITIONAFTER, pos, 0);
end;

procedure TScintillaBase.CopyRange(start : LongInt; end_ : LongInt);
begin
  SPerform(SCI_COPYRANGE, start, end_);
end;

procedure TScintillaBase.CopyText(length : LongInt; text : PChar);
begin
  SPerform(SCI_COPYTEXT, length, LongInt(text));
end;

procedure TScintillaBase.SetSelectionMode(mode : LongInt);
begin
  SPerform(SCI_SETSELECTIONMODE, mode, 0);
end;

function TScintillaBase.GetSelectionMode : LongInt;
begin
  result := SPerform(SCI_GETSELECTIONMODE, 0, 0);
end;

function TScintillaBase.GetLineSelStartPosition(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETLINESELSTARTPOSITION, line, 0);
end;

function TScintillaBase.GetLineSelEndPosition(line : LongInt) : LongInt;
begin
  result := SPerform(SCI_GETLINESELENDPOSITION, line, 0);
end;

procedure TScintillaBase.LineDownRectExtend;
begin
  SPerform(SCI_LINEDOWNRECTEXTEND, 0, 0);
end;

procedure TScintillaBase.LineUpRectExtend;
begin
  SPerform(SCI_LINEUPRECTEXTEND, 0, 0);
end;

procedure TScintillaBase.CharLeftRectExtend;
begin
  SPerform(SCI_CHARLEFTRECTEXTEND, 0, 0);
end;

procedure TScintillaBase.CharRightRectExtend;
begin
  SPerform(SCI_CHARRIGHTRECTEXTEND, 0, 0);
end;

procedure TScintillaBase.HomeRectExtend;
begin
  SPerform(SCI_HOMERECTEXTEND, 0, 0);
end;

procedure TScintillaBase.VCHomeRectExtend;
begin
  SPerform(SCI_VCHOMERECTEXTEND, 0, 0);
end;

procedure TScintillaBase.LineEndRectExtend;
begin
  SPerform(SCI_LINEENDRECTEXTEND, 0, 0);
end;

procedure TScintillaBase.PageUpRectExtend;
begin
  SPerform(SCI_PAGEUPRECTEXTEND, 0, 0);
end;

procedure TScintillaBase.PageDownRectExtend;
begin
  SPerform(SCI_PAGEDOWNRECTEXTEND, 0, 0);
end;

procedure TScintillaBase.StutteredPageUp;
begin
  SPerform(SCI_STUTTEREDPAGEUP, 0, 0);
end;

procedure TScintillaBase.StutteredPageUpExtend;
begin
  SPerform(SCI_STUTTEREDPAGEUPEXTEND, 0, 0);
end;

procedure TScintillaBase.StutteredPageDown;
begin
  SPerform(SCI_STUTTEREDPAGEDOWN, 0, 0);
end;

procedure TScintillaBase.StutteredPageDownExtend;
begin
  SPerform(SCI_STUTTEREDPAGEDOWNEXTEND, 0, 0);
end;

procedure TScintillaBase.WordLeftEnd;
begin
  SPerform(SCI_WORDLEFTEND, 0, 0);
end;

procedure TScintillaBase.WordLeftEndExtend;
begin
  SPerform(SCI_WORDLEFTENDEXTEND, 0, 0);
end;

procedure TScintillaBase.WordRightEnd;
begin
  SPerform(SCI_WORDRIGHTEND, 0, 0);
end;

procedure TScintillaBase.WordRightEndExtend;
begin
  SPerform(SCI_WORDRIGHTENDEXTEND, 0, 0);
end;

procedure TScintillaBase.SetWhitespaceChars(characters : PChar);
begin
  SPerform(SCI_SETWHITESPACECHARS, 0, LongInt(characters));
end;

procedure TScintillaBase.SetCharsDefault;
begin
  SPerform(SCI_SETCHARSDEFAULT, 0, 0);
end;

function TScintillaBase.AutoCGetCurrent : LongInt;
begin
  result := SPerform(SCI_AUTOCGETCURRENT, 0, 0);
end;

procedure TScintillaBase.Allocate(bytes : LongInt);
begin
  SPerform(SCI_ALLOCATE, bytes, 0);
end;

function TScintillaBase.FindColumn(line : LongInt; column : LongInt) : LongInt;
begin
  result := SPerform(SCI_FINDCOLUMN, line, column);
end;

function TScintillaBase.GetCaretSticky : Boolean;
begin
  result := Boolean(SPerform(SCI_GETCARETSTICKY, 0, 0));
end;

procedure TScintillaBase.SetCaretSticky(useCaretStickyBehaviour : Boolean);
begin
  SPerform(SCI_SETCARETSTICKY, LongInt(useCaretStickyBehaviour), 0);
end;

procedure TScintillaBase.ToggleCaretSticky;
begin
  SPerform(SCI_TOGGLECARETSTICKY, 0, 0);
end;

procedure TScintillaBase.SetPasteConvertEndings(convert : Boolean);
begin
  SPerform(SCI_SETPASTECONVERTENDINGS, LongInt(convert), 0);
end;

function TScintillaBase.GetPasteConvertEndings : Boolean;
begin
  result := Boolean(SPerform(SCI_GETPASTECONVERTENDINGS, 0, 0));
end;

procedure TScintillaBase.SelectionDuplicate;
begin
  SPerform(SCI_SELECTIONDUPLICATE, 0, 0);
end;

procedure TScintillaBase.SetCaretLineBackAlpha(alpha : LongInt);
begin
  SPerform(SCI_SETCARETLINEBACKALPHA, alpha, 0);
end;

function TScintillaBase.GetCaretLineBackAlpha : LongInt;
begin
  result := SPerform(SCI_GETCARETLINEBACKALPHA, 0, 0);
end;

procedure TScintillaBase.StartRecord;
begin
  SPerform(SCI_STARTRECORD, 0, 0);
end;

procedure TScintillaBase.StopRecord;
begin
  SPerform(SCI_STOPRECORD, 0, 0);
end;

procedure TScintillaBase.SetLexer(lexer : LongInt);
begin
  SPerform(SCI_SETLEXER, lexer, 0);
end;

function TScintillaBase.GetLexer : LongInt;
begin
  result := SPerform(SCI_GETLEXER, 0, 0);
end;

procedure TScintillaBase.Colourise(start : LongInt; end_ : LongInt);
begin
  SPerform(SCI_COLOURISE, start, end_);
end;

procedure TScintillaBase.SetProperty(key : PChar; value : PChar);
begin
  SPerform(SCI_SETPROPERTY, LongInt(key), LongInt(value));
end;

procedure TScintillaBase.SetKeyWords(keywordSet : LongInt; keyWords : PChar);
begin
  SPerform(SCI_SETKEYWORDS, keywordSet, LongInt(keyWords));
end;

procedure TScintillaBase.SetLexerLanguage(language : PChar);
begin
  SPerform(SCI_SETLEXERLANGUAGE, 0, LongInt(language));
end;

procedure TScintillaBase.LoadLexerLibrary(path : PChar);
begin
  SPerform(SCI_LOADLEXERLIBRARY, 0, LongInt(path));
end;

function TScintillaBase.GetProperty(key : PChar; buf : PChar) : LongInt;
begin
  result := SPerform(SCI_GETPROPERTY, LongInt(key), LongInt(buf));
end;

function TScintillaBase.GetPropertyExpanded(key : PChar; buf : PChar) : LongInt;
begin
  result := SPerform(SCI_GETPROPERTYEXPANDED, LongInt(key), LongInt(buf));
end;

function TScintillaBase.GetPropertyInt(key : PChar) : LongInt;
begin
  result := SPerform(SCI_GETPROPERTYINT, LongInt(key), 0);
end;

function TScintillaBase.GetStyleBitsNeeded : LongInt;
begin
  result := SPerform(SCI_GETSTYLEBITSNEEDED, 0, 0);
end;

//--FuncImp

//Do the unit initialization by loading the scilexer.dll, and register constants
initialization
  scmod := LoadLibrary('scilexer.dll');
  RegisterIntegerConsts(TypeInfo(CodePageType), IdentToCodePage, CodePageToIdent);
finalization
  UnregisterIntegerConsts(TypeInfo(CodePageType), IdentToCodePage, CodePageToIdent);
  if scmod > 0 then FreeLibrary(scmod);
end.


Added src/delphisci/SciLexerMemo.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
      $Id: scilexermemo.pas,v 1.5 2004/11/13 04:29:51 hdalis Exp $
  History: See SciLexerMod.Pas for the initial history
           19/11/2004 Initial Release
           08/01/2005 Removed CharAddedAutocomplete.. no longer used.
                      Added AutoCloseBraces,AutoCloseQuotes.
           04/03/2005 HasPrefix was changed to use AnsiCompare* instead of
                      StrL[I]Comp as the other caused some errors
           15/04/2005 Removed the Add*Handler and Remove*Handler, and replaced them
                      with AddHandler and RemoveHandler wich takes a enum parameter
                      to tell which type handler it is.

                      Fixed the doSci* functions to no longer call Execute*Handler
                      as the inherited TScintillaBase calls it via the events..
                      Earlier it caused the handlers to be called twice (or more), if there
                      was any handlers assigned via TSciController. A bug..
           20/04/2005 Added LocateIndicator, LengthOfIndicator, RemoveIndicator,ShowIndicatorAt.
           16/08/2005 Added TSciMarker class which handles markers..
                      All Bookmark* functions is moved (and renamed, i.e removed Bookmark prefix)
                      to TSciMarker.
                      Added the property Bookmark to TScintillaMemo..
           09/11/2005 Added a TSciMarker class to handle markers.
           09/01/2006 Added a Sensitive property to TMargin
           11/01/2006 Exposed the Anchors and Constraints properties as suggested by N.Metsovo
           .....      Assorted changes
           12/09/2006 Removed the old foldmarker code (the define NEWFOLDING).
}
{$Include SciCommonDef.Inc}
unit SciLexerMemo;
interface
uses Classes, Windows, Controls, Messages, SysUtils, Graphics,SciLexer,SciKeyBindings,
SciSupport,SciControllerHandler;

type
  sciWordWrapVisualFlag = (sciWWEnd,sciWWStart);
  sciWordWrapVisualFlags = set of sciWordWrapVisualFlag;
  sciWordWrapVisualFlagLocation = (sciEndByText,sciStartByText);
  sciWordWrapVisualFlagLocations = set of sciWordWrapVisualFlagLocation;
  TMarginType = (gutSymbol, gutLineNumber,gutMarginBack,gutMarginFore);
  MarkerIntType=0..$7ffffff;

  // Display whitespace?
  sciWSMode = (sciWsInvisible,sciWsVisibleAlways,sciWsVisibleAfterIndent);
  sciCacheType =(sciCacheNone,sciCacheCaret,sciCachePage,sciCacheDocument);
  sciEdgeType =(sciEdgeNone,sciEdgeLine,sciEdgeBackground);
  TIndentationOption = (KeepIndent, TabIndents, BackSpaceUnIndents, IndentationGuides);
  TIndentationOptions = Set of TIndentationOption;
  TEOLStyle = (eolCRLF, eolCR, eolLF);
  TScintillaMemo =class;

  TMargin = class(TPersistent)
  private
    fScintilla : TScintillaBase;
    fNumber : Integer;
    function  GetWidth: Integer;
    procedure SetWidth(const Value: Integer);
    function  GetMarginType: TMarginType;
    procedure SetMarginType(const Value: TMarginType);
    function GetSensitive : Boolean;
    procedure SetSensitive(const Value : Boolean);
  public
    constructor Create(Scintilla : TScintillaBase; Number : Integer);
    procedure Assign(Source: TPersistent); override;
  published
    property Width : Integer read GetWidth write SetWidth;
    property MarginType : TMarginType read GetMarginType write SetMarginType;
    property Sensitive : Boolean read GetSensitive write SetSensitive;
  end;

  TCaret = class(TPersistent)
  private
    fScintilla : TScintillaBase;
    function GetCaretFore: TColor;
    procedure SetCaretFore(const Value: TColor);
    function GetCaretLineBack: TColor;
    procedure SetCaretLineBack(const Value: TColor);
    function GetCaretLineBackAlpha: Integer;
    procedure SetCaretLineBackAlpha(const Value: Integer);
    function GetCaretLineVisible : Boolean;
    procedure SetCaretLineVisible(const Value : Boolean);
    function GetCaretWidth : LongInt;
    procedure SetCaretWidth(const Value : LongInt);
    procedure SetCaretPeriod(const Value : LongInt);
    function GetCaretPeriod : LongInt;
  public
    constructor Create(Scintilla : TScintillaBase);
    procedure Assign(Source: TPersistent); override;
  published
    property ForeColor : TColor read GetCaretFore write SetCaretFore;
    property LineBackColor : TColor read GetCaretLineBack write SetCaretLineBack;
    property LineVisible : Boolean read GetCaretLineVisible write SetCaretLineVisible;
    property Width : LongInt read GetCaretWidth write SetCaretWidth;
    property Period : LongInt read GetCaretPeriod write SetCaretPeriod;
    property LineBackAlpha : Integer read GetCaretLineBackAlpha write SetCaretLineBackAlpha;
  end;

  TSciHotSpot = class(TPersistent)
  private
    fScintilla : TScintillaBase;
    FHotActiveFore : TColor;
    FHotActiveBack : TColor;
    FHotActiveUnderline,
    FHotActiveSingleLine : Boolean;
    procedure SetHotActiveFore(const Value : TColor);
    procedure SetHotActiveBack(const Value : TColor);
    procedure SetHotActiveUnderline(Value : Boolean);
    procedure SetHotActiveSingleLine(Value : Boolean);
  public
    constructor Create(Scintilla : TScintillaBase);
    procedure Assign(Source: TPersistent); override;
  published
    property BackColor : TColor read FHotActiveBack Write SetHotActiveBack nodefault;
    property ForeColor : TColor read FHotActiveFore Write SetHotActiveFore nodefault;
    property Underlined : Boolean read FHotActiveUnderline write SetHotActiveUnderline;
    property SingleLine : Boolean read FHotActiveSingleLine write SetHotActiveSingleLine;
  end;

  TSciMarker = class(TPersistent)
  private
    fScintilla : TScintillaBase;
    FBackColor : TColor;
    FForeColor : TColor;
    FAlpha : Integer;
    FPixmap : String;
    FPixmapFile : String;
    FMarkerID : Integer;
    FMarkerType : MarkerIntType;
    FAssigning : Boolean;
    procedure SetForeColor(const Value : TColor);
    procedure SetBackColor(const Value : TColor);
    procedure SetPixmap(const Value : String);
    procedure SetPixmapFile(const Value : String);
    procedure SetMarkerType(const Value : MarkerIntType);
    procedure SetAlpha(const Value : Integer);
    procedure Refresh;
  public
    constructor Create(Scintilla : TScintillaBase;MarkerId : Integer;aMarkerType : MarkerIntType=SC_MARK_CIRCLE);
    {Assign does NOT change the MarkerId, it just assigns everything else}
    procedure Assign(Source: TPersistent); override;
    {Add a new marker at line 'Line'}
    function Add(Line : Integer=-1) : Integer;
    {Delete marker with this MarkerId at line 'Line'}
    procedure Delete(Line : Integer=-1);
    {Go forward/backward to the next marker with this MarkerId}
    function Next(forwardScan : Boolean=True) : Boolean;
    {Returns true if the marker with this MarkerId is present at line 'Line'}
    function Present(Line : Integer=-1) : Boolean;
    {Toggles the marker with this MarkerId at line 'Line'}
    procedure Toggle(Line : Integer=-1);
    {Clear all markers with this MarkerId}
    procedure ClearAll;
    property Pixmap : String read FPixmap Write SetPixmap nodefault;
  published
    property BackColor : TColor read FBackColor Write SetBackColor nodefault;
    property ForeColor : TColor read FForeColor Write SetForeColor nodefault;
    property PixmapFile : String read FPixmapFile Write SetPixmapFile nodefault;
    property Alpha : Integer read FAlpha write SetAlpha default 256; //New in 1.69
    property MarkerType : MarkerIntType read FMarkerType write SetMarkerType nodefault;
  end;

  TSciColors = class(TPersistent)
  private
    fScintilla : TScintillaBase;
    FForeSelColor : TColor;
    FBackSelColor : TColor;
    FSelAlpha : Integer;
    FMarkerFore : TColor;
    FMarkerBack : TColor;
    FFoldHiColor : TColor;
    FFoldLoColor : TColor;
    FWhiteSpaceFore : TColor;
    FWhiteSpaceBack : TColor;

    procedure SetForeSel(const Value : TColor);
    procedure SetBackSel(const Value : TColor);
    procedure SetSelAlpha(const alpha : Integer);
    procedure SetMarkerFore(const Value : TColor);
    procedure SetMarkerBack(const Value : TColor);
    procedure SetFoldHi(const Value : TColor);
    procedure SetFoldLo(const Value : TColor);
    procedure SetWhiteSpaceFore(const Value : TColor);
    procedure SetWhiteSpaceBack(const Value : TColor);
  public
    constructor Create(Scintilla : TScintillaBase);
    procedure Assign(Source: TPersistent); override;
  published
    property SelFore : TColor read FForeSelColor write SetForeSel nodefault;
    property SelBack : TColor read FBackSelColor write SetBackSel nodefault;
    property SelAlpha : Integer read FSelAlpha write SetSelAlpha default 256;
    property MarkerFore : TColor read FMarkerFore write SetMarkerFore nodefault;
    property MarkerBack : TColor read FMarkerBack write SetMarkerBack nodefault;
    property FoldHi : TColor read FFoldHiColor write SetFoldHi nodefault;
    property FoldLo : TColor read FFoldLoColor write SetFoldLo nodefault;
    property WhiteSpaceFore : TColor read FWhiteSpaceFore write SetWhiteSpaceFore nodefault;
    property WhiteSpaceBack : TColor read FWhiteSpaceBack write SetWhiteSpaceBack nodefault;
  end;

  TDivOptions = class(TPersistent)
  private
    fScintilla : TScintillaBase;
    function GetBool(const Index : Integer) : Boolean;
    procedure SetBool(const Index : Integer;const Value : Boolean);
    function GetWSMode : sciWSMode;
    procedure SetWSMode(value : sciWSMode);
  public
    constructor Create(Scintilla : TScintillaBase);
    procedure Assign(Source: TPersistent); override;
  published
    property ViewWSpace : sciWSMode read GetWSMode write SetWSMode;
    property UsePalette : Boolean index 0 read GetBool write SetBool;
    property OverType : Boolean index 1 read GetBool write SetBool;
    property ViewEOL : Boolean index 2 read GetBool write SetBool;
    property EndAtLastLine : Boolean index 3 read GetBool write SetBool;
    property ScrollBarH : Boolean index 4 read GetBool write SetBool;
    property ScrollBarV : Boolean index 5 read GetBool write SetBool;
  end;

TScintillaMemo = class(TScintillaBase)
  private
    FLines : TStrings;
    fKeepIndent : Boolean;
    fCaret : TCaret;
    fColors : TSciColors;
    fBookMark : TSciMarker;
    fDivOptions : TDivOptions;
    fHotSpot : TSciHotSpot;
    fKeyCommands : TSciKeyCommandCollection;
    FHideSelect : Boolean;
    fMargin0 : TMargin;
    fMargin1 : TMargin;
    fMargin2 : TMargin;
    fMargin3 : TMargin;
    fMargin4 : TMargin;
    FAutoCloseQuotes,FAutoCloseBraces : Boolean;
    FController : TSciController;
    // Property getters/setters
    procedure SetKeyCommands(const Value : TSciKeyCommandCollection);
    procedure SetLines(Const Value : TStrings);
    function GetEOLStyle: TEOLStyle;
    procedure SetEOLStyle(const Value: TEOLStyle);
    function GetIndentation: TIndentationOptions;
    procedure SetIndentation(const Value: TIndentationOptions);
    function GetWordWrapVisual : sciWordWrapVisualFlags;
    procedure SetWordWrapVisual(const flags : sciWordWrapVisualFlags);
    function GetWordWrapVisualLoc : sciWordWrapVisualFlagLocations;
    procedure SetWordWrapVisualLoc(const flags : sciWordWrapVisualFlagLocations);
    procedure SetLCache(const value : sciCacheType);
    function GetLCache : sciCacheType;
    procedure SetHideSelect(const value : Boolean);
    procedure inSetEdgeMode(const value : sciEdgeType);
    function inGetEdgeMode : sciEdgeType;
    procedure SetMargins(const Index: Integer; const Value: TMargin);
    procedure InSetControlCharSymbol(const Value : Char);
    function InGetControlCharSymbol : Char;
protected
    procedure MaintainIndentation(ch : Integer);
    procedure doSciCharAdded(const ch : Integer); override;
    procedure doSciCalltipClick(const position : Integer);override;
    procedure doSciMacroRecord(const msg : Integer;const wParam : uptr_t;const lParam : sptr_t);override;
    procedure doSciAutoCSelection(const text : PChar);override;
    procedure Loaded; override;
public

    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    //To be used when creating controls dynamically, and you want to
    //use components which use the TSciController,
    //or automatically called in the Loaded virtual if precreated in a
    //form.
    procedure AttachController;
    procedure CopyFrom(Source: TScintillaBase); override;
    // Define a marker
    procedure DefineMarker(MarkNum, Marker : Integer;ForeColor : TColor=clDefault;BackColor : TColor=clDefault);
    procedure AutoAdjustLineNumberWidth;
    procedure StripTrailingSpaces;
    {These functions attach/detach other components that needs to detect keys,click on calltips or macrorecording.}
    procedure AddHandler(aHandler : TObject);
    procedure RemoveHandler(aHandler : TObject);
    {Indicator functions}
    function LocateIndicator(indicatorNumber,startSearchAtPos : Integer): Integer;
    function LengthOfIndicator(indicatorNumber,atPos: Integer): Integer;
    procedure RemoveIndicator(indicatorNumber,atPos : Integer);
    procedure ShowIndicatorAt(indicatorNumber,atPos,Length: Integer;Visible: Boolean=True);
    //Property for customising and saving the keyboard commands
    property KeyCommands : TSciKeyCommandCollection read FKeyCommands write SetKeyCommands;

published
    property OnStyleNeeded;
    property OnCharAdded;
    property OnSavePointReached;
    property OnSavePointLeft;
    property OnModifyAttemptRO;
{Don't know if this is really needed, since the standard OnDblClick also fires whenever the
control is doubleclicked at runtime, so it's commented out.}
//    property OnDoubleClick;
    property OnUpdateUI;
    property OnModified;
    property OnMacroRecord;
    property OnMarginClick;
    property OnNeedShown;
    property OnPainted;
    property OnDblClick;
    property OnUserListSelection;
    property OnDwellStart;
    property OnDwellEnd;
    property OnZoom;
    property OnHotSpotClick;
    property OnHotSpotDoubleClick;
    property OnCallTipClick;
    property OnMsgSent;
    property OnKeyUp;
    property OnKeyDown;
    property OnKeyPress;
    property OnEnter;
    property OnExit;
    property OnClick;
    property OnMouseDown;
    property OnMouseUp;
    property OnMouseMove;
    property OnAutoCSelection;
    // Events End
{$Ifdef COMPILER6_UP}
    property Anchors;
    property Constraints;
{$Endif}
    property Lines : TStrings read FLines write SetLines;
    //Get or set the EOF style: EOL_CRLF, EOL_CR, EOL_LF
    property EOLStyle : TEOLStyle read GetEOLStyle write SetEOLStyle;
    //Get or set indentation options: - KeepIndent, - TabIndents, - BackSpaceUnIndents, - IndentationGuides
    property Indentation : TIndentationOptions read GetIndentation write SetIndentation;
    //Number of characters for code (un)indending.  If set to zero then the TabWidth is used instead
    property IndentWidth : Integer read GetIndent write SetIndent;
    //Left Margin in pixels
    property MarginLeft : LongInt read GetMarginLeft write SetMarginLeft;
    //Right Margin in pixels
    property MarginRight : LongInt read GetMarginRight write SetMarginRight;
    //Tab width in characters
    property TabWidth : Integer read GetTabWidth write SetTabWidth default 8;
    property ReadOnly;
    //If false tab characters are replaced by spaces
    property UseTabs : Boolean read GetUseTabs write SetUseTabs default True;
    //Setting to true allows the use of multiple language in the same document.If true all text in and out of the control is interpreted as UTF8
    property CodePage;
    property Caret : TCaret read fCaret Write fCaret;
    property DivOptions : TDivOptions read fDivOptions write fDivOptions;
    property ActiveHotSpot : TSciHotSpot read fHotSpot write fHotSpot;
    property Colors : TSciColors read fColors write fColors;
    property Bookmark : TSciMarker read FBookmark write FBookmark;
    property MouseDwellTime : LongInt read GetMouseDwellTime write SetMouseDwellTime default SC_TIME_FOREVER;
    property ClearUndoAfterSave;
    property Gutter0 : TMargin  index 0 read fMargin0 write SetMargins;
    property Gutter1 : TMargin index 1 read fMargin1 write SetMargins;
    property Gutter2 : TMargin index 2 read fMargin2 write SetMargins;
    property Gutter3 : TMargin index 3 read fMargin3 write SetMargins;
    property Gutter4 : TMargin index 4 read fMargin4 write SetMargins;
    property WordWrapVisualFlags : sciWordWrapVisualFlags read GetWordWrapVisual write SetWordWrapVisual;
    property WordWrapVisualFlagsLocation : sciWordWrapVisualFlagLocations read GetWordWrapVisualLoc write SetWordWrapVisualLoc;
    property LayoutCache : sciCacheType read GetLCache write SetLCache;
    property HideSelect : Boolean read FHideSelect write SetHideSelect;
    property WordWrap;
    property EdgeMode : sciEdgeType read inGetEdgeMode write inSetEdgeMode default sciEdgeNone;
    property EdgeColumn : LongInt read GetEdgeColumn write SetEdgeColumn default 0;
    property EdgeColor : TColor read GetEdgeColour write SetEdgeColour default clDefault;
    property WordChars;
    property AutoCloseQuotes : Boolean read FAutoCloseQuotes write FAutoCloseQuotes default False;
    property AutoCloseBraces : Boolean read FAutoCloseBraces write FAutoCloseBraces default False;
    property ControlCharSymbol : Char read InGetControlCharSymbol write InSetControlCharSymbol;
end;


procedure FillMatching(const startwith : String;var deststr : String;fromlist : TStrings;const ignorecase : Boolean);
function HasPrefix(const s : AnsiString;const prefix : AnsiString;const ignorecase : Boolean) : Boolean;

procedure GetMarkerNoValues(Proc: TGetStrProc);
function MarkerNoToIdent(MarkerNo: Longint; var Ident: string): Boolean;
function IdentToMarkerNo(const Ident: string; var MarkerNo: Longint): Boolean;

const
  sciMCircle = MarkerIntType(SC_MARK_CIRCLE);
  sciMRoundRect = MarkerIntType(SC_MARK_ROUNDRECT);
  sciMArrow = MarkerIntType(SC_MARK_ARROW);
  sciMSmallRect= MarkerIntType(SC_MARK_SMALLRECT);
  sciMShortArrow= MarkerIntType(SC_MARK_SHORTARROW);
  sciMEmpty = MarkerIntType(SC_MARK_EMPTY);
  sciMArrowDown = MarkerIntType(SC_MARK_ARROWDOWN);
  sciMMinus = MarkerIntType(SC_MARK_MINUS);
  sciMPlus= MarkerIntType(SC_MARK_PLUS);
  sciMVLine= MarkerIntType(SC_MARK_VLINE);
  sciMLCorner = MarkerIntType(SC_MARK_LCORNER);
  sciMTCorner = MarkerIntType(SC_MARK_TCORNER);
  sciMBoxPlus = MarkerIntType(SC_MARK_BOXPLUS);
  sciMBoxPlusConnected = MarkerIntType(SC_MARK_BOXPLUSCONNECTED);
  sciMBoxMinus = MarkerIntType(SC_MARK_BOXMINUS);
  sciMBoxMinusConnected = MarkerIntType(SC_MARK_BOXMINUSCONNECTED);
  sciMLCornerCurve = MarkerIntType(SC_MARK_LCORNERCURVE);
  sciMTCornerCurve = MarkerIntType(SC_MARK_TCORNERCURVE);
  sciMCirclePlus = MarkerIntType(SC_MARK_CIRCLEPLUS);
  sciMCirclePlusConnected = MarkerIntType(SC_MARK_CIRCLEPLUSCONNECTED);
  sciMCircleMinus = MarkerIntType(SC_MARK_CIRCLEMINUS);
  sciMCircleMinusConnected = MarkerIntType(SC_MARK_CIRCLEMINUSCONNECTED);
  sciMBackground = MarkerIntType(SC_MARK_BACKGROUND);
  sciMDotDotDot = MarkerIntType(SC_MARK_DOTDOTDOT);
  sciMArrows = MarkerIntType(SC_MARK_ARROWS);
  sciMPixMap = MarkerIntType(SC_MARK_PIXMAP);
  sciMFullRect = MarkerIntType(SC_MARK_FULLRECT);

implementation
uses Math,sciUtils,SciResLang;

type
  TScintillaStrings = class(TStrings)
  private
    Memo: TScintillaMemo;
  protected
    function Get(Index: Integer): string; override;
    function GetCount: Integer; override;
    function GetTextStr: string; override;
    procedure Put(Index: Integer; const S: string); override;
    procedure SetTextStr(const Value: string); override;
    procedure SetUpdateState(Updating: Boolean); override;
  public
    procedure Clear; override;
    procedure Delete(Index: Integer); override;
    procedure Insert(Index: Integer; const S: string); override;
    //Make these call the methods from the TScintilla* component.
    procedure LoadFromStream(Stream: TStream); override;
    procedure SaveToStream(Stream: TStream); override;
  end;

const
  DefaultLinenumbersWidth = 4;

{Marker Number defines/matches a enum value to a integer}
MarkerNumbers: array[0..26] of TIdentMapEntry = (
  (Value: sciMCircle; Name: 'sciMCircle'),
  (Value: sciMRoundRect; Name: 'sciMRoundRect'),
  (Value: sciMArrow; Name: 'sciMArrow'),
  (Value: sciMSmallRect; Name: 'sciMSmallRect'),
  (Value: sciMShortArrow; Name: 'sciMShortArrow'),
  (Value: sciMEmpty; Name: 'sciMEmpty'),
  (Value: sciMArrowDown; Name: 'sciMArrowDown'),
  (Value: sciMMinus; Name: 'sciMMinus'),
  (Value: sciMPlus; Name: 'sciMPlus'),
  (Value: sciMVLine; Name: 'sciMVLine'),
  (Value: sciMLCorner; Name: 'sciMLCorner'),
  (Value: sciMTCorner; Name: 'sciMTCorner'),
  (Value: sciMBoxPlus; Name: 'sciMBoxPlus'),
  (Value: sciMBoxPlusConnected; Name: 'sciMBoxPlusConnected'),
  (Value: sciMBoxMinus; Name: 'sciMBoxMinus'),
  (Value: sciMBoxMinusConnected; Name: 'sciMBoxMinusConnected'),
  (Value: sciMLCornerCurve; Name: 'sciMLCornerCurve'),
  (Value: sciMTCornerCurve; Name: 'sciMTCornerCurve'),
  (Value: sciMCirclePlus; Name: 'sciMCirclePlus'),
  (Value: sciMCirclePlusConnected; Name: 'sciMCirclePlusConnected'),
  (Value: sciMCircleMinus; Name: 'sciMCircleMinus'),
  (Value: sciMCircleMinusConnected; Name: 'sciMCircleMinusConnected'),
  (Value: sciMBackground; Name: 'sciMBackground'),
  (Value: sciMDotDotDot; Name: 'sciMDotDotDot'),
  (Value: sciMArrows; Name: 'sciMArrows'),
  (Value: sciMPixMap; Name: 'sciMPixMap'),
  (Value: sciMFullRect; Name: 'sciMFullRect')
);

procedure GetMarkerNoValues(Proc: TGetStrProc);
var
  I: Integer;
begin
  for I := Low(MarkerNumbers) to High(MarkerNumbers) do Proc(MarkerNumbers[I].Name);
end;

function MarkerNoToIdent(MarkerNo: Longint; var Ident: string): Boolean;
begin
  Result := IntToIdent(MarkerNo, Ident, MarkerNumbers);
end;

function IdentToMarkerNo(const Ident: string; var MarkerNo: Longint): Boolean;
begin
  Result := IdentToInt(Ident, MarkerNo, MarkerNumbers);
end;

function HasPrefix(const s : AnsiString;const prefix : AnsiString;const ignorecase : Boolean) : Boolean;
begin
  if ignorecase then
    Result:=(StrLIComp(PChar(prefix),PChar(s),Min(Length(prefix),Length(s)))=0)
  else
    Result:=(StrLComp(PChar(prefix),PChar(s),Min(Length(prefix),Length(s)))=0);
end;

procedure FillMatching(const startwith : String;var deststr : String;fromlist : TStrings;const ignorecase : Boolean);
var
  cnt,i,numadded : LongInt;
  tmp : String;
begin
  deststr:='';
  numadded:=0;
  cnt:=fromlist.Count;
  for i:=0 to (cnt-1) do
  begin
    tmp:=fromlist.Strings[i];
    if HasPrefix(tmp,startwith,ignorecase)=true then
    begin
      if numadded>0 then deststr:=deststr+' ';
      deststr:=deststr+tmp;
      numadded:=numadded+1;
    end;
  end;
end;

function TScintillaStrings.GetCount: Integer;
begin
  Result := 0;
  if Memo.HandleAllocated then
  begin
    Result := Memo.GetLineCount;
    if Memo.GetLineEndPosition(Result-1) - Memo.PositionFromLine(Result-1) = 0 then Dec(Result);
  end;
end;

procedure TScintillaStrings.LoadFromStream(Stream: TStream);
begin
  if assigned(Memo) then
    Memo.LoadFromStream(Stream);
end;
procedure TScintillaStrings.SaveToStream(Stream: TStream);
begin
  if assigned(Memo) then
    Memo.SaveToStream(Stream);
end;

function TScintillaStrings.Get(Index: Integer): string;
var
  S : string;
  Len : Integer;
begin
  Len := Memo.GetLineEndPosition(Index)-Memo.PositionFromLine(Index);
  if Len > 0 then
  begin
    SetLength(S, Len+2);
    Memo.GetLine(Index, PChar(S));
    Result := Copy(S, 1, Len);
  end else
    Result := '';
end;

procedure TScintillaStrings.Put(Index: Integer; const S: string);
var
  SelStart: Integer;
begin
  SelStart := Memo.PositionFromLine(Index);
  if SelStart >= 0 then
  begin
    Memo.SetTargetStart(SelStart);
    Memo.SetTargetEnd(Memo.GetLineEndPosition(Index));
    Memo.ReplaceTarget(-1, PChar(S));
  end;
end;

procedure TScintillaStrings.Insert(Index: Integer; const S: string);
var
  SelStart, LineLen: Integer;
  Line: string;
  EndOfLine : string;
begin
  if Index >= 0 then
  begin
    Case Memo.GetEOLMode of
      SC_EOL_CRLF : EndOfLine := CrLf;
      SC_EOL_CR   : EndOfLine := #13;
      SC_EOL_LF : EndOfLine := #10;
    end;
    SelStart := Memo.PositionFromLine(Index);
    if SelStart >= 0 then 
      Line := S + EndOfLine 
    else
    begin
      SelStart := Memo.PositionFromLine(Index-1);
      if SelStart < 0 then 
        Exit;
      LineLen := Memo.GetLineEndPosition(Index-1) - SelStart;
      if LineLen = 0 then 
        Exit;
      Inc(SelStart, LineLen);
      Line := EndOfLine + s;
    end;
    Memo.SetTargetStart(SelStart);
    Memo.SetTargetEnd(SelStart);
    Memo.ReplaceTarget(-1, PChar(Line));
  end;
end;

procedure TScintillaStrings.Delete(Index: Integer);
const
  Empty: PChar = '';
var
  SelStart, SelEnd: Integer;
begin
  SelStart := Memo.PositionFromLine(Index);
  if SelStart >= 0 then
  begin
    SelEnd := Memo.PositionFromLine(Index+1);
    if SelEnd < 0 then SelEnd := SelStart + Memo.LineLength(Index);
    Memo.SetTargetStart(SelStart);
    Memo.SetTargetEnd(SelEnd);
    Memo.ReplaceTarget(-1, Empty);
  end;
end;

procedure TScintillaStrings.Clear;
begin
  Memo.ClearAll;
end;

procedure TScintillaStrings.SetUpdateState(Updating: Boolean);
begin
  if Memo.HandleAllocated then
  begin
    SendMessage(Memo.Handle, WM_SETREDRAW, Ord(not Updating), 0);
    if not Updating then
    begin   // WM_SETREDRAW causes visibility side effects in memo controls
      Memo.Perform(CM_SHOWINGCHANGED,0,0); // This reasserts the visibility we want
      Memo.Refresh;
    end;
  end;
end;

function TScintillaStrings.GetTextStr: string;
begin
  Result := Memo.Text;
end;

procedure TScintillaStrings.SetTextStr(const Value: string);
var
  NewText: string;
{$Ifndef COMPILE_BCB5}
  Style: TTextLineBreakStyle;
{$Endif}
begin
{$Ifndef COMPILE_BCB5}
  Case Memo.GetEOLMode of
    SC_EOL_CRLF : Style := tlbsCRLF;
    SC_EOL_LF : Style := tlbsLF;
  else
    Style := tlbsCRLF;   // no other line break style available
  end;
  NewText := AdjustLineBreaks(Value, Style);
{$Else}
  NewText := AdjustLineBreaks(Value);
{$Endif}
  if (Length(NewText) <> Memo.GetTextLength) or (NewText <> Memo.Text) then
  begin
    Memo.SetText(PChar(NewText));
    Memo.Perform(CM_TEXTCHANGED, 0, 0);
  end;
end;

//////  End of TScintillaStrings

{TScintillaMemo}
constructor TScintillaMemo.Create(AOwner : TComponent);
begin
  inherited Create(AOwner);
  fCaret :=TCaret.Create(Self);
  fColors :=TSciColors.Create(Self);
  fBookmark:=TSciMarker.Create(Self,SCITE_MARKER_BOOKMARK);
  fDivOptions :=TDivOptions.Create(Self);
  fHotSpot :=TSciHotSpot.Create(Self);
  fMargin0 := TMargin.Create(Self, 0);
  fMargin1:= TMargin.Create(Self, 1);
  fMargin2:= TMargin.Create(Self, 2);
  fMargin3:= TMargin.Create(Self, 3);
  fMargin4:= TMargin.Create(Self, 4);
  FLines:=TScintillaStrings.Create;
  TScintillaStrings(FLines).Memo := Self;
  fKeyCommands := TSciKeyCommandCollection.Create(Self);
  FController:=TSciController.Create(Self);
  FHideSelect:=false;
  FAutoCloseBraces:=False;
  FAutoCloseQuotes:=False;
end;

destructor TScintillaMemo.Destroy;
begin
  FreeAndNil(FLines);
  FreeAndNil(fCaret);
  FreeAndNil(fColors);
  FreeAndNil(fBookmark);
  FreeAndNil(fDivOptions);
  FreeAndNil(fHotSpot);
  FreeAndNil(fMargin0);
  FreeAndNil(fMargin1);
  FreeAndNil(fMargin2);
  FreeAndNil(fMargin3);
  FreeAndNil(fMargin4);

  FreeAndNil(fKeyCommands);
  FreeAndNil(FController);
  inherited;
end;

procedure TScintillaMemo.Loaded;
begin
  inherited;
  Bookmark.Refresh;
  if not (csDesigning in ComponentState) then
  AttachController;
end;

procedure TScintillaMemo.CopyFrom(Source: TScintillaBase);
begin
  inherited;
  if Assigned(Source) and (Source is TScintillaMemo) then
  begin
    Bookmark.Assign(Source);
    EOLStyle:=TScintillaMemo(Source).EOLStyle;
    Indentation:=TScintillaMemo(Source).Indentation;
    IndentWidth:=TScintillaMemo(Source).IndentWidth;
    KeyCommands.Assign(TScintillaMemo(Source).KeyCommands);
    MarginLeft:=TScintillaMemo(Source).MarginLeft;
    MarginRight:=TScintillaMemo(Source).MarginRight;
    TabWidth:=TScintillaMemo(Source).TabWidth;
    UseTabs:=TScintillaMemo(Source).UseTabs;
    Caret.Assign(TScintillaMemo(Source).Caret);
    DivOptions.Assign(TScintillaMemo(Source).DivOptions);
    Colors.Assign(TScintillaMemo(Source).Colors);
    MouseDwellTime:=TScintillaMemo(Source).MouseDwellTime;
    WordWrap:=TScintillaMemo(Source).WordWrap;
    WordWrapVisualFlags:=TScintillaMemo(Source).WordWrapVisualFlags;
    WordWrapVisualFlagsLocation:=TScintillaMemo(Source).WordWrapVisualFlagsLocation;
    LayoutCache:=TScintillaMemo(Source).LayoutCache;
    HideSelect:=TScintillaMemo(Source).HideSelect;
    EdgeColor:=TScintillaMemo(Source).EdgeColor;
    EdgeColumn:=TScintillaMemo(Source).EdgeColumn;
    EdgeMode:=TScintillaMemo(Source).EdgeMode;
    ActiveHotSpot.Assign(TScintillaMemo(Source).ActiveHotSpot);
    Gutter0.Assign(TScintillaMemo(Source).Gutter0);
    Gutter1.Assign(TScintillaMemo(Source).Gutter1);
    Gutter2.Assign(TScintillaMemo(Source).Gutter2);
    Gutter3.Assign(TScintillaMemo(Source).Gutter2);
    Gutter4.Assign(TScintillaMemo(Source).Gutter2);
  end;
end;

procedure TScintillaMemo.AddHandler(aHandler : TObject);
begin
  if assigned(FController) then
    FController.AddHandler(aHandler);
end;
procedure TScintillaMemo.RemoveHandler(aHandler : TObject);
begin
  if assigned(FController) then
    FController.RemoveHandler(aHandler);
end;

procedure TScintillaMemo.AutoAdjustLineNumberWidth;
var
  lineCount,lineNumWidth,pixelWidth : Integer;
begin
  lineNumWidth := 1;
  lineCount:=GetLineCount;
  while (lineCount >= 10) do
  begin
    lineCount := lineCount div 10;
    Inc(lineNumWidth);
  end;
  if (lineNumWidth < DefaultLinenumbersWidth) then
    lineNumWidth := DefaultLinenumbersWidth;

  pixelWidth := 4 + lineNumWidth * TextWidth(STYLE_LINENUMBER, '9');
  Gutter0.Width:=pixelWidth;
end;

procedure TScintillaMemo.MaintainIndentation(ch : Integer);
Var
  eolMode,
  curLine,
  lastLine,
  indentAmount : LongInt;
begin
  eolMode := GetEOLMode;
  curLine := LineFromPosition(GetCurrentPos);
  lastLine := curLine - 1;
  indentAmount := 0;

  if (((eolMode = SC_EOL_CRLF) or (eolMode = SC_EOL_LF)) and (ch = 10)) or ((eolMode = SC_EOL_CR) and (ch = 13)) then
  begin
    while (lastLine >= 0) and  (GetLineEndPosition(lastLine) - PositionFromLine(lastline) = 0) do
      Dec(lastLine);
    if (lastLine >= 0) then
      indentAmount := GetLineIndentation(lastLine);
    if (indentAmount > 0) then
    begin
      SetLineIndentation(curLine, indentAmount);
      SetCurrentPos(Self.GetLineIndentPosition(curLine));
      Self.SetSel(GetCurrentPos, GetCurrentPos);
    end;
  end;
end;

procedure TScintillaMemo.StripTrailingSpaces;
var
  maxLines,line,lineStart,lineEnd,i,ch : Integer;
begin
  maxLines:=GetLineCount;
  for line:=0 to (maxLines-1) do
  begin
    lineStart:=PositionFromLine(line);
    lineEnd:=GetLineEndPosition(line);
    i:=lineEnd-1;
    ch:=GetCharAt(i);
    while (i>=lineStart) and (IsSpace(ch)=True) do
    begin
      Dec(i);
      ch:=GetCharAt(i);
    end;
    if (i<lineEnd-1) then
    begin
      SetTargetStart(i+1);
      SetTargetEnd(lineEnd);
      ReplaceTarget(0,'');
    end;
  end;
end;

procedure TScintillaMemo.inSetEdgeMode(const value : sciEdgeType);
begin
  SetEdgeMode(LongInt(value));
end;
function  TScintillaMemo.inGetEdgeMode : sciEdgeType;
begin
  Result:=sciEdgeType(GetEdgeMode);
end;

procedure TScintillaMemo.SetHideSelect(const value : Boolean);
begin
  FHideSelect:=value;
  inherited HideSelection(value);
end;

procedure TScintillaMemo.SetLCache(const value : sciCacheType);
begin
  SetLayoutCache(LongInt(value));
end;
function  TScintillaMemo.GetLCache : sciCacheType;
begin
  result :=sciCacheType(GetLayoutCache);
end;

function TScintillaMemo.GetWordWrapVisual : sciWordWrapVisualFlags;
var
  tmp : sciWordWrapVisualFlags;
  x : LongInt;
begin
  tmp:=[];
  x:=GetWrapVisualFlags;
  if (Boolean(x and SC_WRAPVISUALFLAG_END)) then Include(tmp,sciWWEnd)
    else Exclude(tmp,sciWWEnd);
  if (Boolean(x and SC_WRAPVISUALFLAG_START)) then Include(tmp,sciWWStart)
    else Exclude(tmp,sciWWStart);
  result :=tmp;
end;

procedure TScintillaMemo.SetWordWrapVisual(const flags : sciWordWrapVisualFlags);
var
  lflags : LongInt;
begin
  lflags:=0;
  if sciWWEnd in flags then lflags:=lflags+SC_WRAPVISUALFLAG_END;
  if sciWWStart in flags then lflags:=lflags+SC_WRAPVISUALFLAG_START;
  SetWrapVisualFlags(lflags);
end;

function TScintillaMemo.GetWordWrapVisualLoc : sciWordWrapVisualFlagLocations;
var
  tmp : sciWordWrapVisualFlagLocations;
  lflags : LongInt;
begin
  tmp:=[];
  lflags:=GetWrapVisualFlagsLocation;
  if (Boolean(lflags and SC_WRAPVISUALFLAGLOC_END_BY_TEXT)) then
    Include(tmp,sciEndByText)
  else
    Exclude(tmp,sciEndByText);
  if (Boolean(lflags and SC_WRAPVISUALFLAGLOC_START_BY_TEXT)) then
    Include(tmp,sciStartByText)
  else
    Exclude(tmp,sciStartByText);
  result :=tmp;
end;

procedure TScintillaMemo.SetWordWrapVisualLoc(const flags : sciWordWrapVisualFlagLocations);
var
  lflags : LongInt;
begin
  lflags:=0;
  if sciEndByText in flags then lflags:=lflags+SC_WRAPVISUALFLAGLOC_END_BY_TEXT;
  if sciStartByText in flags then lflags:=lflags+SC_WRAPVISUALFLAGLOC_START_BY_TEXT;
  SetWrapVisualFlagsLocation(lflags);
end;

function TScintillaMemo.GetIndentation: TIndentationOptions;
begin
  Result := [];
  if fKeepIndent then Result := [KeepIndent];
  if GetTabIndents then Result := Result + [TabIndents];
  if GetBackSpaceUnIndents then Result := Result + [BackSpaceUnIndents];
  if GetIndentationGuides then Result := Result + [IndentationGuides];
end;

procedure TScintillaMemo.SetIndentation(const Value: TIndentationOptions);
begin
  fKeepIndent := KeepIndent in Value;
  SetTabIndents(TabIndents in Value);
  SetBackSpaceUnIndents(BackSpaceUnIndents in Value);
  SetIndentationGuides(IndentationGuides in Value);
end;

function TScintillaMemo.GetEOLStyle: TEOLStyle;
begin
  Result := TEOLStyle(GETEOLMode);
end;

procedure TScintillaMemo.SetEOLStyle(const Value: TEOLStyle);
begin
  SetEOLMode(Ord(Value));
  Self.ConvertEOLs(Ord(Value));
end;

procedure TScintillaMemo.SetKeyCommands(const Value: TSciKeyCommandCollection);
begin
  fKeyCommands.Assign(Value);
end;

procedure TScintillaMemo.SetLines(Const Value : TStrings);
begin
  //if not assigned(FLines) then GetLinesProp;
  FLines.Assign(Value);
end;

procedure TScintillaMemo.InSetControlCharSymbol(const Value : Char);
begin
  SetControlCharSymbol(Integer(Value));
end;
function  TScintillaMemo.InGetControlCharSymbol : Char;
begin
  Result:=Char(GetControlCharSymbol);
end;

function TMargin.GetSensitive : Boolean;
begin
  Result:=fScintilla.GetMarginSensitiveN(fNumber);
end;
procedure TMargin.SetSensitive(const Value : Boolean);
begin
  fScintilla.SetMarginSensitiveN(fNumber,Value);
end;

procedure TScintillaMemo.SetMargins(const Index: Integer; const Value: TMargin);
begin
  case Index of
    0 : fMargin0.Assign(Value);
    1 : fMargin1.Assign(Value);
    2 : fMargin2.Assign(Value);
    3 : fMargin3.Assign(Value);
    4 : fMargin4.Assign(Value);
  end;
end;

procedure TScintillaMemo.doSciAutoCSelection(const text : PChar);
begin
  //FController.ExecuteAutoCSelection(Self,text);
  inherited doSciAutoCSelection(text);
end;

procedure TScintillaMemo.doSciCharAdded(const ch : Integer);
var
  cpos: Integer;
begin
  if fKeepIndent then MaintainIndentation(ch);
  //FController.ExecuteCharAdded(Self,ch);

  if FAutoCloseBraces=True then
  begin
    if Char(ch) in ['(','{','['] then
    begin
      cpos:=GetCurrentPos;
      case Char(ch) of
        '(': begin AddText(1,')');SetAnchor(cpos);SetCurrentPos(cpos);end;
        '{': begin AddText(1,'}');SetAnchor(cpos);SetCurrentPos(cpos);end;
        '[': begin AddText(1,']');SetAnchor(cpos);SetCurrentPos(cpos);end;
      end;
    end;
  end;
  if FAutoCloseQuotes then
  begin
    cpos:=GetCurrentPos;
    case Char(ch) of
      '"': begin AddText(1,'"');SetAnchor(cpos);SetCurrentPos(cpos);end;
      '''': begin AddText(1,'''');SetAnchor(cpos);SetCurrentPos(cpos);end;
    end;
  end;
  inherited doSciCharAdded(ch);
end;

function TScintillaMemo.LocateIndicator(indicatorNumber,startSearchAtPos: Integer): Integer;
var
  i,len : Integer;
  mask : Integer;
begin
  Result:=-1;
  len:=GetLength;
  case indicatorNumber of
    0: mask:=INDIC0_MASK;
    1: mask:=INDIC1_MASK;
    2: mask:=INDIC2_MASK;
    else
      mask:=indicatorNumber;
  end;

  for i:=startSearchAtPos to len do
  begin
    if (GetStyleAt(i) and mask)<>0 then
    begin
      Result:=i;
      Exit;
    end;
  end;
end;

function TScintillaMemo.LengthOfIndicator(indicatorNumber,atPos: Integer): Integer;
var
  i,len : Integer;
  mask : Integer;
begin
  Result:=-1;
  len:=GetLength;
  case indicatorNumber of
    0: mask:=INDIC0_MASK;
    1: mask:=INDIC1_MASK;
    2: mask:=INDIC2_MASK;
    else
      mask:=indicatorNumber;
  end;
  for i:=atPos to len do
  begin
    if (GetStyleAt(i) and mask)=0 then
    begin
      Result:=i-atPos;
      Exit;
    end;
  end;
end;

procedure TScintillaMemo.RemoveIndicator(indicatorNumber, atPos : Integer);
var
  len : Integer;
begin
  if atPos=-1 then
  begin
    ShowIndicatorAt(-1,0,GetLength,False);
  end else
  begin
    len:=LengthOfIndicator(indicatorNumber,atPos);
    if len>0 then
    begin
      ShowIndicatorAt(indicatorNumber,atPos,len,False);
    end;
  end;
end;

procedure TScintillaMemo.ShowIndicatorAt(indicatorNumber,atPos, Length: Integer;Visible: Boolean);
var
  oldPos : Integer;
  mask : Integer;
  oldMask : Integer;
  nbits : Integer;
  ilen : Integer;
begin
  nbits :=GetStyleBits;
  case indicatorNumber of
    -1: mask:=OppositeMask(nbits);
    0: mask:=INDIC0_MASK;
    1: mask:=INDIC1_MASK;
    2: mask:=INDIC2_MASK;
    else
      mask:=indicatorNumber;
  end;
  if length<>-1 then
    ilen:=length
  else
    ilen:=LengthOfIndicator(indicatorNumber,atPos);
  if ilen>0 then
  begin
    oldMask:=BitsToMask(nbits);
    oldPos:=GetEndStyled;
    StartStyling(atPos,mask);
    if (Visible) and (indicatorNumber<>-1) then
      SetStyling(ilen,mask)
    else
      SetStyling(ilen,0);
    StartStyling(oldPos,oldMask);
  end;
end;

procedure TScintillaMemo.DefineMarker(MarkNum, Marker : Integer;ForeColor,BackColor : TColor);
begin
  MarkerDefine(MarkNum, Marker);
  if(ForeColor=clDefault) then
    MarkerSetFore(MarkNum, Colors.MarkerFore)
  else
    MarkerSetFore(MarkNum, ForeColor);

  if(BackColor=clDefault) then
    MarkerSetBack(MarkNum, Colors.MarkerBack)
  else
    MarkerSetBack(MarkNum, BackColor)
end;

procedure TScintillaMemo.doSciCalltipClick(const position : Integer);
begin
  //FController.ExecuteCallTipClick(Self,position);
  inherited;
end;

{$Ifndef NOMACRORECORD}
procedure TScintillaMemo.doSciMacroRecord(const msg : Integer;const wParam : uptr_t;const lParam : sptr_t);
begin
  //FController.ExecuteMacroRecord(Self,msg,LongInt(wParam),LongInt(lParam));
  inherited;
end;
{$Endif}

procedure TScintillaMemo.AttachController;
begin
  if assigned(FController) then
    FController.Connect;
end;

{TDivOptions}
constructor TDivOptions.Create(Scintilla: TScintillaBase);
begin
  inherited Create;
  fScintilla := Scintilla;
end;

procedure TDivOptions.Assign(Source: TPersistent);
begin
  if Source is TDivOptions then
  begin
    ScrollBarV := TDivOptions(Source).ScrollBarV;
    ScrollBarH := TDivOptions(Source).ScrollBarH;
    UsePalette:= TDivOptions(Source).UsePalette;
    OverType:= TDivOptions(Source).OverType;
    ViewEOL:= TDivOptions(Source).ViewEOL;
    EndAtLastLine:= TDivOptions(Source).EndAtLastLine;
    ViewWSpace:=TDivOptions(Source).ViewWSpace;
  end else
    inherited;
end;

function  TDivOptions.GetWSMode : sciWSMode;
var
  wsm : LongInt;
begin
  wsm:=fScintilla.GetViewWS;
  Result:=sciWSMode(wsm);
end;

procedure TDivOptions.SetWSMode(value : sciWSMode);
begin
  fScintilla.SetViewWS(LongInt(value));
end;

function  TDivOptions.GetBool(const Index : Integer) : Boolean;
begin
  case Index of
  0:result :=fScintilla.GetUsePalette;
  1:result :=fScintilla.GetOverType;
  2:result :=fScintilla.GetViewEOL;
  3:result :=Boolean(fScintilla.GetEndAtLastLine);
  4:result :=fScintilla.GetHScrollBar;
  5:result :=fScintilla.GetVScrollBar;
  else Result:=false;
  end;
end;

procedure  TDivOptions.SetBool(const Index : Integer;const Value : Boolean);
begin
  case Index of
  0:fScintilla.SetUsePalette(Value);
  1:fScintilla.SetOverType(Value);
  2:fScintilla.SetViewEOL(Value);
  3:fScintilla.SetEndAtLastLine(Value=True);
  4:fScintilla.SetHScrollBar(Value);
  5:fScintilla.SetVScrollBar(Value);
  end;
end;

{TSciHotSpot}
constructor TSciHotSpot.Create(Scintilla: TScintillaBase);
begin
  inherited Create;
  fScintilla := Scintilla;
  FHotActiveFore:=clBlue;
  FHotActiveBack:=clDefault;
  FHotActiveUnderline:=True;
  FHotActiveSingleLine:=False;
end;

procedure TSciHotSpot.Assign(Source: TPersistent);
begin
  if Source is TSciHotSpot then
  begin
    FHotActiveBack := TSciHotSpot(Source).BackColor;
    FHotActiveFore:=TSciHotSpot(Source).ForeColor;
    FHotActiveUnderline:=TSciHotSpot(Source).Underlined;
    FHotActiveSingleLine:=TSciHotSpot(Source).SingleLine;
  end else
    inherited;
end;

procedure TSciHotSpot.SetHotActiveFore(const Value : TColor);
begin
  FHotActiveFore:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetHotspotActiveFore(true,Value);
  end else
  begin
    fScintilla.SetHotspotActiveFore(false,Value);
  end;
end;

procedure TSciHotSpot.SetHotActiveBack(const Value : TColor);
begin
  FHotActiveBack:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetHotspotActiveBack(true,Value);
  end else
  begin
    fScintilla.SetHotspotActiveBack(false,Value);
  end;
end;

procedure TSciHotSpot.SetHotActiveUnderline(Value : Boolean);
begin
  FHotActiveUnderline:=Value;
  fScintilla.SetHotspotActiveUnderline(Value);
end;

procedure TSciHotSpot.SetHotActiveSingleLine(Value : Boolean);
begin
  FHotActiveSingleLine:=Value;
  fScintilla.SetHotspotSingleLine(Value);
end;

{TSciMarker}
constructor TSciMarker.Create(Scintilla: TScintillaBase;MarkerId : Integer;aMarkerType : MarkerIntType);
begin
  inherited Create;
  fScintilla := Scintilla;
  FPixmap:='';
  FAssigning:=False;
  FPixmapFile:='';
  FAlpha:=256;
  FMarkerType:=aMarkerType;
  FMarkerID :=MarkerId;
  FForeColor:=clDefault;
  FBackColor:=clDefault;
  if assigned(fScintilla) and not (fScintilla is TScintillaMemo) then
  begin
    FForeColor :=clWhite;
    FBackColor :=clGray;
  end;
end;

function TSciMarker.Add(Line : Integer) : Integer;
begin
  if Line = -1 then
    Line := fScintilla.GetCurrentLineNumber();
  Result:=fScintilla.MarkerAdd(Line,FMarkerID);
end;

procedure TSciMarker.Delete(Line : Integer);
begin
  if Line = -1 then
    Line := fScintilla.GetCurrentLineNumber();
  fScintilla.MarkerDelete(Line,FMarkerID);
end;

procedure TSciMarker.Toggle(Line : Integer);
begin
  if Line = -1 then
    Line := fScintilla.GetCurrentLineNumber();
  if Present(Line) then
    Delete(Line)
  else
    Add(Line);
end;

function TSciMarker.Present(Line : Integer) : Boolean;
var
  state : LongInt;
begin
  if Line = -1 then
    Line := fScintilla.GetCurrentLineNumber();
  state := fScintilla.MarkerGet(Line);
  result :=Boolean(state and (1 shl FMarkerID));
end;

function TSciMarker.Next(forwardScan : Boolean) : Boolean;
var
  lineno,
  sci_marker,
  lineStart,
  lineRetry,
  nextLine : LongInt;
begin
  with fScintilla do
  begin
    lineno := GetCurrentLineNumber();
    sci_marker := SCI_MARKERNEXT;
    lineStart := lineno + 1;  //Scan starting from next line
    lineRetry := 0;        //If not found, try from the beginning
    if not forwardScan then
    begin
      lineStart := lineno - 1;    //Scan starting from previous line
      lineRetry := GetLineCount;  //If not found, try from the end
      sci_marker := SCI_MARKERPREVIOUS;
    end;
    nextLine := SPerform(sci_marker, lineStart, (1 shl FMarkerID));
    if nextLine < 0 then
      nextLine := SPerform(sci_marker, lineRetry, (1 shl FMarkerID));
    if (nextLine < 0) or (nextLine = lineno) then // No bookmark (of the given type) or only one, and already on it
    begin
      result :=false;
      Exit;
    end else
    begin
      GotoLineEnsureVisible(nextLine);
      result :=true;
      Exit;
    end;
  end;
  result :=false;
end;

procedure TSciMarker.ClearAll;
begin
  fScintilla.MarkerDeleteAll(FMarkerID);
end;

procedure TSciMarker.Refresh;
begin
  FAssigning:=False;
  try
    MarkerType:=FMarkerType;
    PixmapFile:=FPixmapFile;
    Pixmap:=FPixmap;
    BackColor:=FBackColor;
    ForeColor:=FForeColor;
    Alpha:=FAlpha;
  finally
    FAssigning:=False;
    MarkerType:=FMarkerType;
  end;
end;
procedure TSciMarker.SetAlpha(const Value : Integer);
begin
  FAlpha:=Value;
  if Assigned(fScintilla) then
  begin
    if not FAssigning then
      fScintilla.MarkerSetAlpha(FMarkerID,FAlpha);
  end;
end;

procedure TSciMarker.SetMarkerType(const Value : MarkerIntType);
begin
  FMarkerType:=Value;
  if Assigned(fScintilla) then
  begin
    if not FAssigning then
      fScintilla.MarkerDefine(FMarkerID,FMarkerType);
  end;
end;

procedure TSciMarker.Assign(Source: TPersistent);
begin
  if Source is TSciMarker then
  begin
    FAssigning:=True;
    try
      FMarkerID:=TSciMarker(Source).FMarkerID;
      PixmapFile:=TSciMarker(Source).PixmapFile;
      Pixmap:=TSciMarker(Source).Pixmap;
      BackColor:=TSciMarker(Source).BackColor;
      ForeColor:=TSciMarker(Source).ForeColor;
      MarkerType:=TSciMarker(Source).MarkerType;
      Alpha:=TSciMarker(Source).Alpha;
    finally
      FAssigning:=False;
      MarkerType:=FMarkerType;
    end;
  end else
    inherited;
end;

procedure TSciMarker.SetPixmap(const Value : String);
begin
  FPixmap:=Value;
  if (FPixmap<>'') and ((FPixmapFile='') or (not FExists(FPixmapFile))) then
  begin
    if Assigned(fScintilla) then
      fScintilla.MarkerDefinePixmap(FMarkerID,PChar(FPixmap));
    MarkerType:=SC_MARK_PIXMAP;
  end;
end;

procedure TSciMarker.SetPixmapFile(const Value : String);
var
  ms : TMemoryStream;
  nullch : Char;
begin
  FPixmapFile:=Value;
  ms:=nil;
  if (FPixmapFile<>'') and (FExists(FPixmapFile)) then
  begin
    FPixmap:='';
    try
      ms:=TMemoryStream.Create;
      ms.LoadFromFile(Value);
      nullch:=#0;
      ms.Seek(0,soFromEnd);
      ms.Write(nullch,SizeOf(nullch));
      if Assigned(fScintilla) then
        fScintilla.MarkerDefinePixmap(FMarkerID,PChar(ms.Memory));
      MarkerType:=SC_MARK_PIXMAP;
    finally
      if assigned(ms) then FreeAndNil(ms);
    end;
  end;
end;

procedure TSciMarker.SetForeColor(const Value : TColor);
begin
  FForeColor :=Value;
  if Assigned(fScintilla) then
  begin
    if (FForeColor=clDefault) and (fScintilla is TScintillaMemo) then
      fScintilla.MarkerSetFore(FMarkerID, TScintillaMemo(fScintilla).Colors.MarkerFore)
    else
      fScintilla.MarkerSetFore(FMarkerID, Value);
  end;
end;

procedure TSciMarker.SetBackColor(const Value : TColor);
begin
  FBackColor :=Value;
  if Assigned(fScintilla) then
  begin
    if (FBackColor=clDefault) and (fScintilla is TScintillaMemo) then
      fScintilla.MarkerSetBack(FMarkerID, TScintillaMemo(fScintilla).Colors.MarkerBack)
    else
      fScintilla.MarkerSetBack(FMarkerID, Value);
  end;
end;

{TSciColors}
constructor TSciColors.Create(Scintilla: TScintillaBase);
begin
  inherited Create;
  fScintilla := Scintilla;
  FFoldHiColor :=clBtnFace;
  FFoldLoColor :=clBtnFace;
  FMarkerFore :=clBlue;
  FMarkerBack :=clAqua;
  FForeSelColor :=clHighLightText;
  FBackSelColor :=clHighLight;
  FSelAlpha:=256;
  if assigned(fScintilla) and (fScintilla.HandleAllocated) then
  begin
    FWhiteSpaceBack:=Scintilla.Color;
    FWhiteSpaceFore:=Scintilla.Font.Color;
  end else
  begin
    FWhiteSpaceBack:=clDefault;
    FWhiteSpaceFore:=clDefault;
  end;
end;

procedure TSciColors.Assign(Source: TPersistent);
begin
  if Source is TSciColors then
  begin
    SelFore := TSciColors(Source).SelFore;
    SelBack:=TSciColors(Source).SelBack;
    SelAlpha:=TSciColors(Source).SelAlpha;
    MarkerFore:= TSciColors(Source).MarkerFore;
    MarkerBack:= TSciColors(Source).MarkerBack;
    FoldHi:=TSciColors(Source).FoldHi;
    FoldLo:=TSciColors(Source).FoldLo;
    WhiteSpaceFore:=TSciColors(Source).WhiteSpaceFore;
    WhiteSpaceBack:=TSciColors(Source).WhiteSpaceBack;
  end else
    inherited;
end;

procedure TSciColors.SetFoldHi(const Value : TColor);
begin
  FFoldHiColor:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetFoldMarginHiColour(true,Value);
  end else
  begin
    fScintilla.SetFoldMarginHiColour(false,Value);
  end;
end;

procedure TSciColors.SetFoldLo(const Value : TColor);
begin
  FFoldLoColor:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetFoldMarginColour(true,Value);
  end else
  begin
    fScintilla.SetFoldMarginColour(false,Value);
  end;
end;

procedure TSciColors.SetWhiteSpaceFore(const Value : TColor);
begin
  FWhiteSpaceFore:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetWhitespaceFore(true,Value);
  end else
  begin
    fScintilla.SetWhitespaceFore(false,Value);
  end;
end;

procedure TSciColors.SetWhiteSpaceBack(const Value : TColor);
begin
  FWhiteSpaceBack:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetWhitespaceBack(true,Value);
  end else
  begin
    fScintilla.SetWhitespaceBack(false,Value);
  end;
end;

procedure TSciColors.SetMarkerFore(const Value : TColor);
  procedure MarkFore(MarkNum, BackCol : TColor);
  begin
    fScintilla.MarkerSetFore(MarkNum, BackCol);
  end;
begin
  FMarkerFore :=Value;
  if(Value<>clDefault) then
  begin
    MarkFore(SC_MARKNUM_FOLDEROPEN,Value);
    MarkFore(SC_MARKNUM_FOLDER,Value);
    MarkFore(SC_MARKNUM_FOLDERSUB,Value);
    MarkFore(SC_MARKNUM_FOLDERTAIL,Value);
    MarkFore(SC_MARKNUM_FOLDEREND,Value);
    MarkFore(SC_MARKNUM_FOLDEROPENMID, Value);
    MarkFore(SC_MARKNUM_FOLDERMIDTAIL, Value);
  end;
end;

procedure TSciColors.SetMarkerBack(const Value : TColor);
  procedure MarkBack(MarkNum, BackCol : TColor);
  begin
    fScintilla.MarkerSetBack(MarkNum, BackCol);
  end;
begin
  FMarkerBack :=Value;
  if(Value<>clDefault) then
  begin
    MarkBack(SC_MARKNUM_FOLDEROPEN,Value);
    MarkBack(SC_MARKNUM_FOLDER,Value);
    MarkBack(SC_MARKNUM_FOLDERSUB,Value);
    MarkBack(SC_MARKNUM_FOLDERTAIL,Value);
    MarkBack(SC_MARKNUM_FOLDEREND,Value);
    MarkBack(SC_MARKNUM_FOLDEROPENMID, Value);
    MarkBack(SC_MARKNUM_FOLDERMIDTAIL, Value);
  end;
end;

procedure TSciColors.SetForeSel(const Value : TColor);
begin
  FForeSelColor:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetSelFore(true,Value);
  end else
  begin
    fScintilla.SetSelFore(false,Value);
  end;
end;

procedure TSciColors.SetSelAlpha(const alpha : Integer);
begin
  FSelAlpha:=alpha;
  if FSelAlpha>256 then FSelAlpha:=256;
  fScintilla.SetSelAlpha(FSelAlpha);
end;

procedure TSciColors.SetBackSel(const Value : TColor);
begin
  FBackSelColor:=Value;
  if Value<>clDefault then
  begin
    fScintilla.SetSelBack(true,Value);
  end else
  begin
    fScintilla.SetSelBack(false,Value);
  end;
end;

{TCaret}
constructor TCaret.Create(Scintilla: TScintillaBase);
begin
  inherited Create;
  fScintilla := Scintilla;
end;

procedure TCaret.Assign(Source: TPersistent);
begin
  if Source is TCaret then
  begin
    LineBackColor := TCaret(Source).LineBackColor;
    ForeColor:=TCaret(Source).ForeColor;
    LineVisible := TCaret(Source).LineVisible;
    Period :=TCaret(Source).Period;
    Width :=TCaret(Source).Width;
    LineBackAlpha:=TCaret(Source).LineBackAlpha;
  end else
    inherited;
end;

procedure TCaret.SetCaretPeriod(const Value : LongInt);
begin
  fScintilla.SetCaretPeriod(Value);
end;

function  TCaret.GetCaretPeriod : LongInt;
begin
  result :=fScintilla.GetCaretPeriod;
end;

function TCaret.GetCaretWidth : LongInt;
begin
  Result:=fScintilla.GetCaretWidth;
end;

procedure TCaret.SetCaretWidth(const Value : LongInt);
begin
  fScintilla.SetCaretWidth(Value);
end;

function TCaret.GetCaretFore: TColor;
begin
  Result:=fScintilla.GetCaretFore;
end;

procedure TCaret.SetCaretFore(const Value: TColor);
begin
  fScintilla.SetCaretFore(Value);
end;

function TCaret.GetCaretLineBack: TColor;
begin
  Result:=fScintilla.GetCaretLineBack;
end;

procedure TCaret.SetCaretLineBack(const Value: TColor);
begin
  fScintilla.SetCaretLineBack(Value);
end;

function TCaret.GetCaretLineBackAlpha: Integer;
begin
  Result:=fScintilla.GetCaretLineBackAlpha;
end;

procedure TCaret.SetCaretLineBackAlpha(const Value: Integer);
begin
  fScintilla.SetCaretLineBackAlpha(Value);
end;

function TCaret.GetCaretLineVisible : Boolean;
begin
  Result:=fScintilla.GetCaretLineVisible;
end;

procedure TCaret.SetCaretLineVisible(const Value : Boolean);
begin
  fScintilla.SetCaretLineVisible(Value);
end;


{TMargin}
constructor TMargin.Create(Scintilla: TScintillaBase; Number : Integer);
begin
  inherited Create;
  fScintilla := Scintilla;
  fNumber := Number;
end;

procedure TMargin.Assign(Source: TPersistent);
begin
  if Source is TMargin then
  begin
    MarginType := TMargin(Source).MarginType;
    Width := TMargin(Source).Width;
  end else
    inherited;
end;

function TMargin.GetMarginType: TMarginType;
begin
  Result := TMarginType(fScintilla.GetMarginTypeN(fNumber))
end;

function TMargin.GetWidth: Integer;
begin
  Result := fScintilla.GetMarginWidthN(fNumber)
end;

procedure TMargin.SetMarginType(const Value: TMarginType);
begin
  fScintilla.SetMarginTypeN(fNumber, Ord(Value));
end;

procedure TMargin.SetWidth(const Value: Integer);
begin
  fScintilla.SetMarginWidthN(fNumber, Value)
end;


initialization
  RegisterIntegerConsts(TypeInfo(MarkerIntType), IdentToMarkerNo, MarkerNoToIdent);
finalization
  UnregisterIntegerConsts(TypeInfo(MarkerIntType), IdentToMarkerNo, MarkerNoToIdent);
end.
Added src/delphisci/SciLexerOptionsDlg.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
{$Include SciCommonDef.Inc}
{ 
 Unit    : SciLexerOptionsDlg
 Purpose : Component encapsulating the Options Dialog for Scintilla editors
 Created : 20/03/2003
      $Id: SciLexerOptionsDlg.pas,v 1.5 2004/11/13 04:29:50 hdalis Exp $
 Author  : Kiriakos Vlahos (kvlahos@london.edu)

 History:
 05/12/2003 Customized and extended by hdalis for use with the
            TScintilla and TScintillaAuto components.
            Added Options2Page
            (hdalis@users.sourceforge.net)
 29/09/2004 Initial Release with Delphi Scintilla Interface Components
 13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
            generate the help.
            Renamed the Scintilla properties to Editor
            (hdalis@users.sourceforge.net)
 29/10/2004 Removed the opKeywords from the TSciOptionPage enum. No longer needed.
            Renamed the opOptions2 to opColors
}
unit SciLexerOptionsDlg;
interface
Uses
  SysUtils, Classes, Controls, Forms, SciLexerMod,EdOptionsWin;

Type
  TSciOptionPage = (opOptions, opColors,opHighlighter, opKeyboard);
  TSciOptionPages = set of TSciOptionPage;

  TScintillaOptionsDlg = class(TComponent)
  private
    FEditor: TScintilla;
    FActivePage: TSciOptionPage;
    FPages: TSciOptionPages;
  protected
    procedure Notification(AComponent: TComponent;
              Operation: TOperation);  override;
  public
    constructor Create(AOwner: TComponent); override;
    function Execute: Boolean;
  published
    property Editor: TScintilla read FEditor write FEditor;
    property ActivePage: TSciOptionPage read FActivePage write FActivePage default opOptions;
    property Pages: TSciOptionPages read FPages write FPages default [opOptions, opHighlighter, opKeyboard];
  end;


implementation
uses sciResLang;

{ TScintillaOptionsDlg }

constructor TScintillaOptionsDlg.Create(AOwner: TComponent);
begin
  inherited;
  FPages := [opOptions, opHighlighter, opKeyboard,opColors];
  FActivePage := opOptions;
end;

function TScintillaOptionsDlg.Execute: Boolean;
begin
  if FEditor = nil then
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TScintillaOptionsDlg']);
  with TEdOptionsWindow.Create(Self) do begin
    if not (FActivePage in FPages) then Include(FPages, FActivePage);
    ColorsPage.TabVisible := opColors in FPages;
    HighlighterPage.TabVisible := opHighlighter in FPages;
    OptionsPage.TabVisible := opOptions in FPages;
    KeyCommandsPage.TabVisible := opKeyboard in FPages;
    case FActivePage of
      opOptions : OptionPages.ActivePage := OptionsPage;
      opHighlighter : OptionPages.ActivePage := HighlighterPage;
      opKeyboard : OptionPages.ActivePage := KeyCommandsPage;
      opColors : OptionPages.ActivePage := colorsPage;
    end;
    Editor := FEditor;
    Result := ShowModal = mrOK;
    Free;
  end;
end;

procedure TScintillaOptionsDlg.Notification(AComponent: TComponent;Operation: TOperation);
begin
  inherited;
  if (AComponent = FEditor) and (Operation = opRemove) then FEditor := nil;
end;

end.
Added src/delphisci/SciLexerReg.dcr.

cannot compute difference between binary files

Added src/delphisci/SciLexerReg.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
   Author: hdalis (hdalis@users.sourceforge.net)
      $Id: SciLexerReg.pas,v 1.5 2004/11/13 04:29:50 hdalis Exp $
  Purpose: Register components and component editors.
  History: 29/09/2004 Initial Release
           17/10/2004 Added property editor for the Lexer property of
                      TSciLangItem

                      A lot has been added and changed in this file
                      since the last entry..

           14/10/2005 Fixed a small bug as suggested by jAmEs_
           31/01/2006 Made some preparations for TSciLanguageManager standalone component
                      NOTE!! NOT COMPLETE.
}
{$Include SciCommonDef.Inc}
unit SciLexerReg;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

procedure Register;
implementation
Uses
{$Ifdef COMPILER5}DsgnIntf,{$Else}DesignIntf, DesignEditors, {$Endif}
  SciSupport,SciLexerMemo,SciAutoComplete,SciCallTips,EdOptionsWin, SciLexerOptionsDlg, SciSearchReplace,
  SciKeyBindings,SciLexerMod,ScintillaLanguageManager,sciWhatToFillUnit,SciPropertyMgr,SciDetectUtils
  ,SciDocuments,SciMacroRecording,SciResLangDcl,sciResLang,SciAbbrevationManager,tcFontComboBox,SciLexer,
  SciPrint,SciActions,ActnList,SciActionsRes,sciUtils,sciStyleLoader;
Type
  TScintillaComponentEditor = class(TDefaultEditor)
  public
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
    procedure Edit;override;
  end;

  TSciKeyCommandsPropertyEditor = class(TPropertyEditor)
  public
    procedure Edit; override;
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
  end;

  TSciLexerPropertyEditor=class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValueList(List: TStrings);
    procedure GetValues(Proc: TGetStrProc);override;
  end;

  TSciSelectedLanguagePropertyEditor=class(TStringProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure GetValueList(List: TStrings);
    procedure GetValues(Proc: TGetStrProc);override;
  end;
  TSciCodePagePropertyEditor=class(TIntegerProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string;override;
    procedure SetValue(const Value: string); override;
    procedure GetValues(Proc: TGetStrProc);override;
  end;
  TSciMarkerNoPropertyEditor=class(TIntegerProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string;override;
    procedure SetValue(const Value: string); override;
    procedure GetValues(Proc: TGetStrProc);override;
  end;
  TSciHighlighterPropertyEditor=class(TClassProperty)
  public
    function GetAttributes: TPropertyAttributes; override;
    procedure Edit;override;
  end;

procedure Register;
begin
  RegisterComponents( 'Scintilla', [ TScintilla,TScintillaMemo, TSciAutoComplete,TSciCallTips,
  {$Ifndef NOMACRORECORD}
  TSciMacroRecorder,
  {$Endif}
  TScintillaOptionsDlg, TSciSearchReplace,TSciDocumentTabControl,TSciPropertyLoader,TSciAbbrevManager,TSciPrinter
{$Ifdef LMSTANDALONE}
  ,TSciLanguageManager
{$Endif}
  ]);
  RegisterClass(TSciLanguageManager);
  RegisterClass(TScintillaMemo);
  RegisterClass(TScintilla);
{$Ifndef LMSTANDALONE}
  RegisterPropertyEditor(TypeInfo(TSciLanguageManager), TScintilla, 'LanguageManager', TSciHighlighterPropertyEditor);
{$Endif}

  RegisterComponentEditor(TScintilla, TScintillaComponentEditor);
  RegisterPropertyEditor(TypeInfo(TSciKeyCommandCollection), TScintilla, '', TSciKeyCommandsPropertyEditor);
  RegisterPropertyEditor(TypeInfo(String), TSciLangItem, 'Lexer', TSciLexerPropertyEditor);
  RegisterPropertyEditor(TypeInfo(String), TSciLanguageManager, 'SelectedLanguage', TSciSelectedLanguagePropertyEditor);
  RegisterPropertyEditor(TypeInfo(CodePageType), TScintillaBase, 'CodePage', TSciCodePagePropertyEditor);
  RegisterPropertyEditor(TypeInfo(MarkerIntType), TSciMarker, 'MarkerType', TSciMarkerNoPropertyEditor);

{$Ifndef COMPILER5}
  RegisterPropertiesInCategory('Visual',TScintillaMemo,['Gutter0','Gutter1','Gutter2','EdgeColor','EdgeMode','EdgeColumn','Indentation','IndentWidth','MarginLeft','MarginRight','MarkerType','WordWrapVisualFlags','WordWrapVisualFlagsLocation','EOLStyle','KeyCommands','Colors','ActiveHotSpot','HideSelect','Caret']);
  RegisterPropertiesInCategory('Input',TScintillaMemo,['UseTabs','CodePage','WordChars','WordWrap','ClearUndoAfterSave','Lines','TabWidth','MouseDwellTime']);
  RegisterPropertiesInCategory('Visual',TScintilla,['LanguageManager','BraceHilite','CodeFolding','FoldMarkers']);
{$Endif}
  RegisterComponents('Additional', [TtcFontComboBox]);

  RegisterActions('Edit',[TSciRedo],TSciActionsData);

end;
{ TScintillaComponentEditor }
procedure TScintillaComponentEditor.Edit;
begin
  with TEdOptionsWindow.Create(nil) do
  begin
    Editor := Component as TScintilla;
    ShowModal;
    Free;
    if Self.Designer<>nil then Self.Designer.Modified;
  end;

end;

procedure TScintillaComponentEditor.ExecuteVerb(Index: Integer);
var
  odia : TOpenDialog;
  sdia : TSaveDialog;
  StylesLdr : TSciStylesLoader;
  WasExecuted : Boolean;
  ed : TScintilla;
begin
  if Assigned(Component) and (Component is TScintilla) then
    ed:=TScintilla(Component)
  else
    Exit;
  case Index of
    0 : Edit;
    1:;
    2 : begin
            if Assigned(ed.LanguageManager) then
            begin
              FillLanguages(ed,false);
              ed.LanguageManager.Update;
              if Self.Designer<>nil then Self.Designer.Modified;
            end else
              raise Exception.CreateRes(@eNoLanguageManager);
        end;
    3 : begin
            if Assigned(ed.LanguageManager) then
            begin
              FillLanguages(ed,true);
              ed.LanguageManager.SelectedLanguage:='null';
              if Self.Designer<>nil then Self.Designer.Modified;
              MessageBox(ed.Handle,PChar(scithelanguagelistofcontrol+ed.Name+sciiscleared),PChar(sciinformationheader),MB_OK);
            end else
              raise Exception.CreateRes(@eNoLanguageManager);
        end;
    4:;
    5: begin
            if Assigned(ed.LanguageManager) then
            begin
              with ed do
              begin
                odia:=TOpenDialog.Create(nil);
                if odia<>nil then
                begin
                  odia.Filter:=scipropertyfilesfilter;
                  odia.DefaultExt:=scipropertyfiledefaultextension;
                  odia.Title:=scipropertyfileloadtitle;
                  odia.Options:=[ofPathMustExist,ofFileMustExist,ofEnableSizing];
                  WasExecuted:=odia.Execute;
                  if WasExecuted then
                  begin
                    StylesLdr:=TSciStylesLoader.Create;
                    StylesLdr.LanguageManager:=ed.LanguageManager;
                    //StylesLdr.Editor:=TScintilla(Component);
                    StylesLdr.LoadStyles(odia.FileName);
                    FreeAndNil(StylesLdr);
                    LanguageManager.Update;
                  end;
                  FreeAndNil(odia);
                  if (WasExecuted) and (Self.Designer<>nil) then Self.Designer.Modified;
                end;
              end;
            end else
              raise Exception.CreateRes(@eNoLanguageManager);
       end;
    6: begin
          with ed do
          begin
            if Assigned(ed.LanguageManager) then
            begin
              sdia:=TSaveDialog.Create(nil);
              if sdia<>nil then
              begin
                sdia.Filter:=scipropertyfilesfilter;
                sdia.DefaultExt:=scipropertyfiledefaultextension;
                sdia.Title:=scipropertyfilesavetitle;
                sdia.Options:=[ofEnableSizing];
                WasExecuted:=sdia.Execute;
                if (WasExecuted) then
                begin
                  StylesLdr:=TSciStylesLoader.Create;
                  StylesLdr.LanguageManager:=ed.LanguageManager;
                  //StylesLdr.Editor:=TScintilla(Component);
                  StylesLdr.SaveStyles(sdia.FileName);
                  FreeAndNil(StylesLdr);
                end;
                FreeAndNil(sdia);
                if (WasExecuted) and (Self.Designer<>nil) then Self.Designer.Modified;
              end;
            end else
              raise Exception.CreateRes(@eNoLanguageManager);
          end;
       end;
    else
      inherited ExecuteVerb(Index);
  end;
end;

function TScintillaComponentEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0 : Result :=ssciOptions;
    1 : Result :='-';
    2 : Result :=ssciSelectPredefinedLanguage;
    3 : Result :=ssciClearLanguageList;
    4:  Result :='-';
    5:  Result := ssciLoadStylesFromPropertyFile;
    6:  Result := ssciSaveStylesToPropertyFile;
  else
    Result:=inherited GetVerb(Index);
  end;
end;

function TScintillaComponentEditor.GetVerbCount: Integer;
begin
  Result := 7;
end;

{ TSciCodePagePropertyEditor }
function TSciCodePagePropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paMultiSelect];
end;

procedure TSciCodePagePropertyEditor.GetValues(Proc: TGetStrProc);
begin
  GetCodePageValues(Proc);
end;

function TSciCodePagePropertyEditor.GetValue: string;
begin
  if not CodePageToIdent(GetOrdValue,Result) then
    Result:=ToStr(GetOrdValue);
end;

procedure TSciCodePagePropertyEditor.SetValue(const Value: string);
var
  id : LongInt;
begin
  if not IdentToCodePage(Value,id) then
  begin
    id:=ToInt(Value);
  end;
  SetOrdValue(id);
  Modified;
end;


{ TSciMarkerNoPropertyEditor }
function TSciMarkerNoPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paMultiSelect];
end;

procedure TSciMarkerNoPropertyEditor.GetValues(Proc: TGetStrProc);
begin
  GetMarkerNoValues(Proc);
end;

function TSciMarkerNoPropertyEditor.GetValue: string;
begin
  if not MarkerNoToIdent(GetOrdValue,Result) then
    Result:=ToStr(GetOrdValue);
end;

procedure TSciMarkerNoPropertyEditor.SetValue(const Value: string);
var
  id : LongInt;
begin
  if not IdentToMarkerNo(Value,id) then
  begin
    id:=ToInt(Value);
  end;
  SetOrdValue(id);
  Modified;
end;

{ TSciKeyCommandsPropertyEditor }


procedure TSciKeyCommandsPropertyEditor.Edit;
begin
  with TScintillaOptionsDlg.Create(nil) do
  begin
    Editor := GetComponent(0) as TScintilla;
    if Assigned(Editor) then
    begin
      Pages := [opKeyboard];
      ActivePage := opKeyboard;
      Execute;
    end;
    Free;
  end;
end;

function TSciKeyCommandsPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;

function TSciKeyCommandsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [sscikeycommands]);
end;

{ TSciLexerPropertyEditor }

function TSciLexerPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paSortList, paMultiSelect];
end;

procedure TSciLexerPropertyEditor.GetValues(Proc: TGetStrProc);
var
  I: Integer;
  Values: TStringList;
begin
  Values := TStringList.Create;
  try
    GetValueList(Values);
    for I := 0 to Values.Count - 1 do Proc(Values[I]);
  finally
    FreeAndNil(Values);
  end;
end;

procedure TSciLexerPropertyEditor.GetValueList(List: TStrings);
var
  FLangman : TSciLanguageManager;
  langitm : TSciLangItem;
begin
  FLangman:=nil;
  langitm:=GetComponent(0) as TSciLangItem; //Get the first selected TSciLangItem, no need to walk them since they're all identical.
  if Assigned(langitm) then
  begin
    if assigned(langitm.Collection) and (langitm.Collection is TSciLangList) then // Test if the parent is a TSciLangList, and it isn't nil.
    begin
      if (langitm.Collection.Owner<>nil) and (langitm.Collection.Owner is TSciLanguageManager) then // Test if the parent is a TSciLanguageManager, and it isn't nil.
      begin
        FLangman:=TSciLanguageManager(langitm.Collection.Owner);
      end;
    end;
  end;
  if FLangman=nil then // Test if a TSciLanguageManager belonging to the current component was found, and if not, create a temporary object.
  begin
    FLangman:=TSciLanguageManager.Create(nil);
    FLangman.FillListWithLanguages(List,[sciLexers]);
    List.Add(cContainerLexer);
    FreeAndNil(FLangman);
  end else
  begin
    FLangman.FillListWithLanguages(List,[sciLexers]);
    List.Add(cContainerLexer);
  end;
end;

{ TSciSelectedLanguagePropertyEditor }
function TSciSelectedLanguagePropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paValueList, paSortList, paMultiSelect];
end;

procedure TSciSelectedLanguagePropertyEditor.GetValues(Proc: TGetStrProc);
var
  I: Integer;
  Values: TStringList;
begin
  Values := TStringList.Create;
  try
    GetValueList(Values);
    for I := 0 to Values.Count - 1 do Proc(Values[I]);
  finally
    FreeAndNil(Values);
  end;
end;

procedure TSciSelectedLanguagePropertyEditor.GetValueList(List: TStrings);
var
  FLangman : TSciLanguageManager;
begin
  FLangman :=GetComponent(0) as TSciLanguageManager;
  if not Assigned(FLangman) then Exit;
  FLangman.FillListWithLanguages(List,[sciLanguages]);
  if (List.IndexOf(cContainerLexer)=-1) then
  begin
    List.Add(cContainerLexer);
  end;
end;

function TSciHighlighterPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog,paSubProperties];
end;

procedure TSciHighlighterPropertyEditor.Edit;
var
  FScintilla : TScintilla;
begin
  FScintilla:=GetComponent(0) as TScintilla;
  with TEdOptionsWindow.Create(nil) do
  begin
    Editor := FScintilla;
    ShowModal;
    Free;
    if Assigned(Self.Designer) then
      Self.Designer.Modified; //Modified as suggested by jAmEs_.. Avoid comparing with the TCustomForm property.
  end;
end;
end.
Added src/delphisci/SciLexerReg.rc.






















>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
TSCIABBREVMANAGER	BITMAP	"images\TSCIABBREVMANAGER.BMP"
TSCIAUTOCOMPLETE	BITMAP	"images\TSCIAUTOCOMPLETE.BMP"
TSCICALLTIPS	BITMAP	"images\TSCICALLTIPS.BMP"
TSCIDOCUMENTTABCONTROL	BITMAP	"images\TSCIDOCUMENTTABCONTROL.BMP"
TSCIMACRORECORDER	BITMAP	"images\TSCIMACRORECORDER.BMP"
TSCINTILLA	BITMAP	"images\TSCINTILLA.BMP"
TSCINTILLAMEMO	BITMAP	"images\TSCINTILLAMEMO.BMP"
TSCINTILLAOPTIONSDLG	BITMAP	"images\TSCINTILLAOPTIONSDLG.BMP"
TSCIPROPERTYLOADER	BITMAP	"images\TSCIPROPERTYLOADER.BMP"
TSCISEARCHREPLACE	BITMAP	"images\TSCISEARCHREPLACE.BMP"
TSCIPRINTER	BITMAP	"images\TSCIPRINTER.BMP"
Added src/delphisci/SciMacroRecording.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
  Created: 18/11/2004, 19:51:14
  History: 18/11/2004 Initial Release
      $Id:  $

  Very basic macro recording. It could be used as a kind of 'how to'
  to linking components to the TScintilla component.
}
{$Include SciCommonDef.Inc}
unit SciMacroRecording;
interface
uses Classes, SciLexerMemo,SciControllerHandler;
type

TSciMacroEvent=record
  message,wParam,lParam : LongInt;
  TxtLen : LongInt;
  Txt : String;
end;

TSciMacroItem=record
Title : String;
macroevents : array of TSciMacroEvent;
end;

PSciMacroEvent=^TSciMacroEvent;
TSCEvent_macroitemevent = procedure(Sender : TObject; MacroItem : PSciMacroEvent) of object;

TSciMacroRecorder = class(TComponent)
  private
    fMacro  : TList;
    fMacroRecordProc : TMacroRecordProc;
    FEditor : TScintillaMemo;
    FIsRecording,FMacroLoaded,FMacroRunning : Boolean;
    procedure SetIsRecording(value : Boolean);
    procedure SetScintilla(Value : TScintillaMemo);
    procedure DetachScintilla;
protected
    procedure EvtMacroRecord (Sender : TObject; const message : LongInt; const wParam : LongInt; const lParam : LongInt);virtual;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  public
    constructor Create(AOwner : TComponent);override;
    destructor  Destroy; override;
    procedure Clear;
    procedure SaveToStream(stream : TStream);
    procedure LoadFromStream(stream : TStream);
    procedure Execute;
    procedure StartRecord;
    procedure StopRecord;
    property IsRecording : Boolean read FIsRecording write SetIsRecording;
    property MacroLoaded : Boolean read FMacroLoaded;
    property MacroRunning : Boolean read FMacroRunning;
  published
    property Editor : TScintillaMemo read FEditor write SetScintilla;
end;


implementation
uses SciSupport,SysUtils;

// TSciMacroRecorder
constructor TSciMacroRecorder.Create(AOwner : TComponent);
begin
  FEditor:=nil;
  inherited Create(AOwner);
  FMacro:=TList.Create;
  FIsRecording:=False;
  FMacroLoaded:=False;
  FMacroRunning:=False;
  FMacroRecordProc:=TMacroRecordProc.Create(EvtMacroRecord);
end;

destructor TSciMacroRecorder.Destroy;
begin
  FreeAndNil(fMacroRecordProc);
  FreeAndNil(FMacro);
  Inherited Destroy;
end;

procedure TSciMacroRecorder.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent,Operation);
  if Operation=opRemove then
  begin
    if AComponent=FEditor then
    begin
      DetachScintilla;
    end;
  end;
end;

procedure TSciMacroRecorder.DetachScintilla;
begin
  if FEditor<>nil then
  begin
    FEditor.RemoveHandler(fMacroRecordProc);
  end;
  FEditor:=nil;
end;

procedure TSciMacroRecorder.SetIsRecording(value : Boolean);
begin
  if Value=True then
    StartRecord
  else
    StopRecord;
end;

procedure TSciMacroRecorder.SetScintilla(Value : TScintillaMemo);
begin
  if Value<>nil then
  begin
    DetachScintilla;
    FEditor:=Value;
    FEditor.AddHandler(fMacroRecordProc);
  end else
  begin
    DetachScintilla;
  end;
end;

procedure TSciMacroRecorder.Clear;
var
 i,cnt : Integer;
begin
  cnt :=FMacro.Count;
  for i:=0 to (cnt-1) do
  begin
    Dispose(FMacro.Items[i]);
  end;
  FMacro.Clear;
  FMacro.Capacity:=0;
  FMacroLoaded:=False;
end;

procedure TSciMacroRecorder.LoadFromStream(stream : TStream);
var
  i,cnt : LongInt;
  m : PSciMacroEvent;
begin
  cnt :=FMacro.Count;
  stream.ReadBuffer(cnt,SizeOf(LongInt));
  for i:=0 to (cnt-1) do
  begin
    New(m);
    stream.ReadBuffer(m^.message,SizeOf(LongInt));
    stream.ReadBuffer(m^.wParam,SizeOf(LongInt));
    stream.ReadBuffer(m^.lParam,SizeOf(LongInt));
    stream.ReadBuffer(m^.TxtLen,SizeOf(LongInt));
    SetLength(m^.Txt,m^.TxtLen);
    stream.ReadBuffer(m^.Txt[1],m^.TxtLen);
    FMacro.Add(m);
  end;
  FMacroLoaded:=(FMacro.Count>0);
end;

procedure TSciMacroRecorder.SaveToStream(stream : TStream);
var
  i,cnt : LongInt;
  m : PSciMacroEvent;
begin
  cnt :=FMacro.Count;
  if cnt>0 then
  begin
    stream.WriteBuffer(cnt,SizeOf(LongInt));
    for i:=0 to (cnt-1) do
    begin
      m:=FMacro.Items[i];
      stream.WriteBuffer(m^.message,SizeOf(LongInt));
      stream.WriteBuffer(m^.wParam,SizeOf(LongInt));
      stream.WriteBuffer(m^.lParam,SizeOf(LongInt));
      stream.WriteBuffer(m^.TxtLen,SizeOf(LongInt));
      stream.WriteBuffer(m^.Txt[1],m^.TxtLen);
    end;
  end;
end;

procedure TSciMacroRecorder.Execute;
var
i,cnt : Integer;
m : PSciMacroEvent;
begin
  cnt :=FMacro.Count;
  if cnt>0 then
  begin
    try
      FMacroRunning:=True;
      for i:=0 to (cnt-1) do
      begin
        m:=FMacro.Items[i];
        case m^.message of
          SCI_ADDTEXT,
          SCI_INSERTTEXT,
          SCI_REPLACESEL,
          SCI_SETTEXT,
          SCI_APPENDTEXT,
          SCI_REPLACETARGET,
          SCI_SEARCHINTARGET,
          SCI_REPLACETARGETRE
          ,SCI_COPYTEXT,
          SCI_SEARCHNEXT,
          SCI_SEARCHPREV:
          begin
            m^.lParam:=LongInt(PChar(m^.Txt));
          end;
        end;
        FEditor.Perform(m^.message,m^.wParam,m^.lParam);
      end;
    finally
      FMacroRunning:=False;
    end;
  end;
end;

procedure TSciMacroRecorder.StartRecord;
begin
  Clear;
  FIsRecording:=True;
  FEditor.StartRecord;
end;
procedure TSciMacroRecorder.StopRecord;
begin
  FIsRecording:=False;
  FEditor.StopRecord;
end;

procedure TSciMacroRecorder.EvtMacroRecord(Sender : TObject; const message : LongInt; const wParam : LongInt; const lParam : LongInt);
var
  m : PSciMacroEvent;
begin
  New(m);
  m^.message:=message;
  m^.wParam:=wParam;
  m^.lParam:=lParam;
  case m^.message of
    SCI_ADDTEXT,
    SCI_INSERTTEXT,
    SCI_REPLACESEL,
    SCI_SETTEXT,
    SCI_APPENDTEXT,
    SCI_REPLACETARGET,
    SCI_SEARCHINTARGET,
    SCI_REPLACETARGETRE
    ,SCI_COPYTEXT,
    SCI_SEARCHNEXT,
    SCI_SEARCHPREV:
     begin
       m^.Txt:=PChar(lParam);
       m^.TxtLen:=Length(m^.Txt);
     end;
  end;
  FMacro.Add(m);
  FMacroLoaded:=True;
end;

end.
Added src/delphisci/SciPropertyMgr.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis (Jan Martin Pettersen)
  Created: 01/08/2004
      $Id: SciPropertyMgr.pas,v 1.5 2004/11/13 04:29:50 hdalis Exp $
  Purpose: Load/Save properties from a TScintilla/TScintillaAuto derived component

    Usage: Drop this component on the form, select the editor it should save and load properties
           from. Set the FileName property to the file it should read/write, and call Save or Load.

  History: 29/09/2004 First release
           13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                      generate the help.
           26/10/2004 Moved the GetLexerMapperProps function to TSciLanguageManager.GetLexerProps (ScintillaSynLexer.Pas)
           14/11/2004 Changed the TSciPropertyLoader component to allow use with all classes descending from
                      TScintillaBase. A little 'feature' has also been fixed.. It searched for the '.' section.name divider
                      first, and if there wasn't a '.' in the propertyline before '=' then it would search the value for it,
                      and couldn't get a valid match for the line, and still contain the correct value.
                      Now it searches for the '=' first, and then matches properties within the left part,
                      and the right part of it is the value.
           02/12/2004 Moved all standalone functions to sciUtils.pas. They can, and probably will be used
                      by other units also.
                      Changed the format of the expected properties file.. The new one somewhat resembles
                      ini files, but with at least one distinction: You can continue the line with the '\' character,
                      as in C++/C..
           25/01/2005 Added the functions AddBool,AddInt,GetBool,GetInt.
                      Renamed the GetOtherSetting to GetOther, and the SetOtherSetting to SetOther.
           05/02/2005 Changed the TSCEvent_propsaveitem to TSCEvent_propsaveitems, and let the programmer
                      add all their settings in one go with OnSaveItems..
                      Some restructuring needed in this component.

           12/04/2005 Corrected the .dpk and .dpr to map to the Pascal language.
           18/04/2005 Changed the implementation of ExtensionManager, and moved it to SciFileExtensionsManager.pas,
                      and deprecated the old version which still is here when you uncomment
                      USENEWEXTENSIONMAPPER in SciCommonDef.Inc
           15/05/2005 Removed all references to ValueExtract, as it was unneccesary.
           18/05/2005 The property StoreMinimal was added. When true, the propertyloaded
                      saves only the miniumum. i.e extensions,styles,keywords etc.
                      but only the style property under the [default] tag.
                      This is to ease the use if most of the config is saved
                      to the registry.
           18/08/2005 Removed the StoreMinimal property, and replaced it with the enum
                      property StoreWhat.
                      Added SaveStylesToStream,SaveStyles,LoadStylesFromStream, and LoadStyles.

                      These functions stores and loads stylefiles, i.e a stream containing
                      languagedefinitions and styles..

                      The default is to NOT store styles in the main propertiesfile, but
                      to have them loaded/saved from a separate file..

                      One way to load them is to call TSciPropertyLoader.LoadStyles(fname) from
                      inside the OnPropertiesLoaded event, or anywhere else
                      where the Scintilla component is initialized..
                      a tip: Check with Scintilla.HandleAllocated or Scintilla.HandleNeeded.
           23/08/2005 Removed the deprecated TExtensionMapper, and now using the only the new.
           11/01/2006 Changed the way the bookmark properties are stored, and added storage for
                      all fold markers, this is to allow storing of customized markers.

          TODO: Separate the functions/operations similar between TSciStylesLoader, and TSciPropertyLoader
                into a separate class. As it is now, quite a few of the operations is
                equal, or nearly equal in operation.

                The TSciStylesLoader is found in SciStyleLoader.pas, and is not a component,
                just a class used by the designtime.
}
{$Include SciCommonDef.Inc}
unit SciPropertyMgr;
interface
uses  Classes,SciLexer,SciLexerMemo,SciLexerMod,Graphics,ScintillaLanguageManager;

Type
  TSCEvent_proploaditem = procedure(Sender : TObject; var CategoryName,PropName : String;var Num : Integer;var aValue : String;var Handled : Boolean) of object;
  TSCEvent_propsaveitems = procedure(Sender : TObject; settinglist : TStrings) of object;

  TStoreWhat=(stDefaults,
  stColors,
  stStyles,
  stOther,
  stLexerProperties,
  stExtensions);
  TStoreWhats=set of TStoreWhat;
  { Loads and saves properties for a TScintilladescending component.
    OnLoadItem and OnSaveItem may be used to save,parse additional properties
    if needed}
  TSciPropertyLoader=class(TComponent)
    private
      fLoadingErrors : TStrings;
      fDefaultStyle : TSciLangStyle;
      fFileName : String;
      fEditor : TScintillaBase;
      fLexerProperties : TStrings;
      fOnPropLoadItem : TSCEvent_proploaditem;
      fOnPropSaveItems : TSCEvent_propsaveitems;
      fOnPropertiesLoaded : TNotifyEvent;
      fOtherSettings  : TStrings;
      FStoreWhat : TStoreWhats;
      function  CommonProcessStyles(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
      function  CommonProcessProps(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
      procedure StoreStyles(lst : TStrings);
      procedure StoreProps(lst : TStrings);

    protected
      procedure SetLexerProperties;
      procedure FillWithDefaultStyle(var sty : TSciLangStyle);
      procedure GenerateDefaultPropLine(var dest : String;component : TScintillaBase);
      function GenerateMarkerLine(Marker : TSciMarker) : String;
      procedure GenerateStylePropLine(var dest : String;const prefix : String;const styl : TSciStyle);
      procedure GenerateKwdPropLine(var dest : String;const prefix : String;const kwd : TSciKeywords);
      function  PropLineSplit(const s: String;var stylenum : Integer;var prop : String;var value : String) : Boolean;
      function  ParseStyleDefinition(const definition : PChar;var sty : TSciLangStyle;defstyle : Boolean=False) : Boolean;
      function  ParseMarkerDefinition(const definition : PChar;Marker : TSciMarker) : Boolean;
      function  ProcessDataStart(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
      function  ProcessDataEnd(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
      procedure Notification(AComponent: TComponent;Operation: TOperation);  override;
      procedure DoPropSave(lst : TStrings);virtual;
      procedure DoPropertiesLoaded;virtual;
    public
      constructor Create(AOwner : TComponent);override;
      destructor Destroy;override;
      function LoadFromStream(fs : TStream) : Boolean;
      function SaveToStream(fs : TStream) : Boolean;
      function Load : Boolean; //Loads the propertyfile specified in 'FileName'
      function Save : Boolean; //Saves to the propertyfile specified in 'FileName'
      function LoadStylesFromStream(fs : TStream) : Boolean;
      function SaveStylesToStream(fs : TStream) : Boolean;
      function SaveStyles(const filename : String) : Boolean;
      function LoadStyles(const filename : String): Boolean;

      function GetOther(const SettingName : String;const DefaultValue : String='';const AddIfNonExistent : Boolean=False) : String;
      procedure AddOther(const SettingName : String;const value : String);
      function GetInt(const SettingName : String;const DefaultValue : Integer=0;const AddIfNonExistent : Boolean=False) : Integer;
      function GetBool(const SettingName : String;const DefaultValue : Boolean=False;const AddIfNonExistent : Boolean=False) : Boolean;
      procedure AddInt(const SettingName : String;const value : Integer);
      procedure AddBool(const SettingName : String;const value : Boolean);
      property LoadingErrors : TStrings read fLoadingErrors;

    published
      property FileName : String read fFileName write fFileName;
      property Editor : TScintillaBase read FEditor write fEditor;
      property OnLoadItem : TSCEvent_proploaditem read fOnPropLoadItem write fOnPropLoadItem;
      property OnSaveItems : TSCEvent_propsaveitems read fOnPropSaveItems write fOnPropSaveItems;
      property OnPropertiesLoaded : TNotifyEvent read fOnPropertiesLoaded write fOnPropertiesLoaded;
      property StoreWhat : TStoreWhats read FStoreWhat write FStoreWhat;
  end;

implementation
uses
  Windows,SysUtils,SciResLang,sciUtils,SciFileExtensionsManager,SciSupport;

function GetFileExtensionProps : String;
var
  tmp : String;
  i,cnt : Integer;
  itm : TExtensionItem;
  FExtensionItems : TExtensionsToLanguageList;
  exts : String;
begin
  FExtensionItems :=ExtMapper.ExtensionsList;
  tmp:='';
  if FExtensionItems=nil then
  begin
    Result:=tmp;
    Exit;
  end;
    tmp:=CrLf+'['+spropExtension+']'+CrLf;
    cnt:=FExtensionItems.Count;
    for i:=0 to (cnt-1) do
    begin
      itm:=FExtensionItems.Items[i];
      exts:=Trim(itm.Extensions);
      if exts<>'' then
        tmp:=tmp+itm.Language+'='+exts+CrLf;
    end;
    tmp:=tmp+CrLf;
  Result:=tmp;
end;


constructor TSciPropertyLoader.Create(AOwner : TComponent);
begin
  inherited;
  fFileName:='';
  FStoreWhat:=[stStyles,stOther,stLexerProperties,stExtensions,stDefaults,stColors];
  fDefaultStyle.EOLFilled:=False;
  fDefaultStyle.Visible:=True;
  fDefaultStyle.CharCase:=CASE_MIXED;
  fDefaultStyle.Changeable:=True;
  fDefaultStyle.Hotspot:=False;
  fDefaultStyle.FontStyles:=[];
  fDefaultStyle.FontName:='';
  fDefaultStyle.FontSize:=0;
  fDefaultStyle.ForeColor:=clDefault;
  fDefaultStyle.BackColor:=clDefault;
  fLoadingErrors:=TMyStringList.Create;
  fOtherSettings:=TMyStringList.Create;
  TMyStringList(fOtherSettings).CaseSensitive:=False;
  TMyStringList(fOtherSettings).Duplicates:=dupIgnore;
  TMyStringList(fOtherSettings).Sorted:=True;
  fLexerProperties:=TMyStringList.Create;
  TMyStringList(fLexerProperties).CaseSensitive:=False;
  TMyStringList(fLexerProperties).Duplicates:=dupIgnore;
  TMyStringList(fLexerProperties).Sorted:=True;
end;

destructor  TSciPropertyLoader.Destroy;
begin
  if assigned(fOtherSettings) then FreeAndNil(fOtherSettings);
  if assigned(fLexerProperties) then FreeAndNil(fLexerProperties);
  if assigned(fLoadingErrors) then FreeAndNil(fLoadingErrors);
  inherited;
end;

procedure TSciPropertyLoader.Notification(AComponent: TComponent;Operation: TOperation);
begin
  inherited;
  if (AComponent = FEditor) and (Operation = opRemove) then FEditor := nil;
end;

procedure TSciPropertyLoader.DoPropertiesLoaded;
begin
  if assigned(fOnPropertiesLoaded) then fOnPropertiesLoaded(Self);
end;

procedure TSciPropertyLoader.SetLexerProperties;
var
  i,cnt : Integer;
  v,n : String;
begin
  if not assigned(FEditor) then Exit;
  cnt:=fLexerProperties.Count;
  if cnt=0 then Exit;
  for i:=0 to (cnt-1) do
  begin
    n:=fLexerProperties.Names[i];
    if n<>'' then
    begin
      v:=fLexerProperties.Values[n];
      if(v<>'') then
      begin
        fEditor.SetProperty(PChar(n),PChar(v));
      end;
    end;
  end;
end;

// Quite a bit of multiple instances of the same code maybe, but temporary
// Generates a string with the default color and font settings.
// Does NOT support the EOLFilled etc attributes.
procedure TSciPropertyLoader.GenerateDefaultPropLine(var dest : String;component : TScintillaBase);
var
  tmpstr : String;

begin
  tmpstr:=spropStyle+'=';
  tmpstr:=tmpstr+spropFore+':'+ColourToString(component.Font.Color)+',';//fore
  tmpstr:=tmpstr+spropBack+':'+ColourToString(component.Color)+',';//back
  tmpstr:=tmpstr+Format('%s:%d',[spropsize,component.Font.Size])+',';//size
  tmpstr:=tmpstr+spropFont+':'+component.Font.Name+',';//font
  if fsBold in component.Font.Style then
    tmpstr:=tmpstr+spropBold+','//bold
  else
    tmpstr:=tmpstr+spropNot+spropBold+',';//notbold
  if fsItalic in component.Font.Style then
    tmpstr:=tmpstr+spropItalics+',' //italics
  else
    tmpstr:=tmpstr+spropNot+spropItalics+',';//notitalics

  if fsUnderline in component.Font.Style then
    tmpstr:=tmpstr+spropUnderlined+','//underlined
  else
    tmpstr:=tmpstr+spropNot+spropUnderlined+',';//notunderlined
  if fDefaultStyle.Visible=false  then
    tmpstr:=tmpstr+spropNot+spropVisible+',' //notvisible
  else
    tmpstr:=tmpstr+spropVisible+',';//visible
  if fDefaultStyle.EOLFilled  then
    tmpstr:=tmpstr+spropEolFilled+','//eolfilled
  else
    tmpstr:=tmpstr+spropNot+spropEolFilled+',';//noteolfilled
  if fDefaultStyle.Changeable  then
    tmpstr:=tmpstr+spropChangeable+','//changeable
  else
    tmpstr:=tmpstr+spropNot+spropChangeable+',';//notchangeable
  if fDefaultStyle.Hotspot  then
    tmpstr:=tmpstr+spropHotspot+','//hotspot
  else
    tmpstr:=tmpstr+spropNot+spropHotspot+',';//nothotspot
  case fDefaultStyle.CharCase of
    CASE_UPPER: tmpstr:=tmpstr+spropCase+':u,';
    CASE_LOWER: tmpstr:=tmpstr+spropCase+':l,';
  end;

  dest :=tmpstr;
  if dest[Length(dest)]=',' then Delete(dest,Length(dest),1);
end;


function TSciPropertyLoader.GenerateMarkerLine(Marker : TSciMarker) : String;
var
  markerstr : String;
begin
  Result:='';
  if not assigned(Marker) then Exit;
  if MarkerNoToIdent(Marker.MarkerType,markerstr) then
    Result:=Format(spropMarkerType+':%s',[markerstr])
  else
    Result:=Format(spropMarkerType+':%d',[Integer(Marker.MarkerType)]);

  if Marker.PixmapFile<>'' then
  begin
    Result:=Result+','+Format(spropPixMapFile+':%s',[Marker.PixmapFile]);
  end;
  Result:=Result+','+Format(spropMarkerAlpha+':%d',[Marker.Alpha]);
  Result:=Result+','+Format(spropFore+':%s',[ColourToString(Marker.ForeColor)]);
  Result:=Result+','+Format(spropBack+':%s',[ColourToString(Marker.BackColor)]);
end;

// Generates a string with the properties of a single style.
procedure TSciPropertyLoader.GenerateStylePropLine(var dest : String;const prefix : String;const styl : TSciStyle);
var
  tmpstr : String;
  tmpdescr : String;
begin
  tmpstr:=Format('%s%d=',[prefix,styl.StyleNumber]);
  tmpdescr:=styl.Name;
  tmpdescr:=ReplaceAChar(tmpdescr,',','|');
  tmpstr:=tmpstr+spropName+':'+tmpdescr+','; //name
  if (styl.ForeColor<>clDefault) and ((styl.ForeColor<>fDefaultStyle.ForeColor) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+spropFore+':'+ColourToString(styl.ForeColor)+',';//fore

  if (styl.BackColor<>clDefault) and ((styl.BackColor<>fDefaultStyle.BackColor) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+spropBack+':'+ColourToString(styl.BackColor)+',';//back

  if (styl.FontSize<>0) and ((styl.FontSize<>fDefaultStyle.FontSize) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+Format('%s:%d',[spropSize,styl.FontSize])+',';//size

  if (styl.FontName<>'') and ((styl.FontName<>fDefaultStyle.FontName) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+spropFont+':'+styl.FontName+',';//font

  if (styl.FontStyles<>fDefaultStyle.FontStyles) then
  begin
    if (((fsBold in styl.FontStyles) <> (fsBold in fDefaultStyle.FontStyles)) or (styl.StyleNumber=33)) then
    begin
      if fsBold in styl.FontStyles then
        tmpstr:=tmpstr+spropBold+','//bold
      else
        tmpstr:=tmpstr+spropNot+spropBold+',';//notbold
    end;
    if (((fsItalic in styl.FontStyles) <> (fsItalic in fDefaultStyle.FontStyles)) or (styl.StyleNumber=33)) then
    begin
      if fsItalic in styl.FontStyles then
        tmpstr:=tmpstr+spropItalics+',' //italics
      else
        tmpstr:=tmpstr+spropNot+spropItalics+',';//notitalics
    end;
    if (((fsUnderline in styl.FontStyles) <> (fsUnderline in fDefaultStyle.FontStyles)) or (styl.StyleNumber=33)) then
    begin
      if fsUnderline in styl.FontStyles then
        tmpstr:=tmpstr+spropUnderlined+','//underlined
      else
        tmpstr:=tmpstr+spropNot+spropUnderlined+',';//notunderlined
    end;
  end;//<>fontstyles

  if (styl.Visible<>fDefaultStyle.Visible) then
  begin
    if styl.Visible=false  then
      tmpstr:=tmpstr+spropNot+spropVisible+',' //notvisible
    else
      tmpstr:=tmpstr+spropVisible+',';//visible
  end;

  if (styl.EOLFilled<>fDefaultStyle.EOLFilled) then
  begin
    if styl.EOLFilled  then
      tmpstr:=tmpstr+spropEolFilled+','//eolfilled
    else
      tmpstr:=tmpstr+spropNot+spropEolFilled+',';//noteolfilled
  end;
  if (styl.Changeable<>fDefaultStyle.Changeable) then
  begin
    if styl.Changeable  then
      tmpstr:=tmpstr+spropChangeable+','//changeable
    else
      tmpstr:=tmpstr+spropNot+spropChangeable+',';//notchangeable
  end;
  if (styl.Hotspot<>fDefaultStyle.Hotspot) then
  begin
    if styl.Hotspot  then
      tmpstr:=tmpstr+spropHotspot+','//hotspot
    else
      tmpstr:=tmpstr+spropNot+spropHotspot+',';//nothotspot
  end;
  if (styl.CharCase<>fDefaultStyle.CharCase) then
  begin
    case styl.CharCase of
      CASE_UPPER: tmpstr:=tmpstr+spropCase+':u,';
      CASE_LOWER: tmpstr:=tmpstr+spropCase+':l,';
    end;
  end;
  dest :=tmpstr;
  if dest[Length(dest)]=',' then Delete(dest,Length(dest),1);
end;

// Generates a propertyline with the specified keywords. May split in multiple lines if
// more than 8 in the list.
procedure TSciPropertyLoader.GenerateKwdPropLine(var dest : String;const prefix : String;const kwd : TSciKeywords);
var
  tmpstr,tmpdescr : String;
  i,cnt,kwdonline : Integer;
  isfirst : Boolean;
begin
  tmpstr:=Format('%s%d=',[prefix,kwd.KeywordListNumber]);
  tmpdescr:=kwd.Name;
  tmpdescr :=ReplaceAChar(tmpdescr,',','|');

  tmpstr:=tmpstr+spropName+':'+tmpdescr+'::';//name
  cnt:=kwd.Keywords.Count;
  if cnt>0 then
  begin
    kwdonline:=0;
    isfirst:=true;
    for i:=0 to (cnt-1) do
    begin
      if (kwdonline>16) then
      begin
        tmpstr:=tmpstr+'\'+CrLf;
        kwdonline:=0;
        tmpstr:=tmpstr+kwd.Keywords.Strings[i];
      end else
      begin
        if isfirst then
        begin
          tmpstr:=tmpstr+kwd.Keywords.Strings[i];
          isfirst:=false;
        end else
          tmpstr:=tmpstr+' '+kwd.Keywords.Strings[i];
      end;
      Inc(kwdonline);
    end;
    if tmpstr[Length(tmpstr)]='\' then Delete(tmpstr,Length(tmpstr),1);
  end;
  dest :=tmpstr;
end;


//Splits a propertyline in 'Lang',stylenum and prop.
//Lines like
// prop.lang.stylenum=value or
// prop.lang=value
// are accepted
function TSciPropertyLoader.PropLineSplit(const s: String;var stylenum : Integer;var prop : String;var value : String) : Boolean;
var
  tmp : String;
  propnamepart : String;
  code : Integer;
  i,cnt,dotstart : Integer;
begin
  tmp:=s;
  propnamepart:=WordBefore(tmp,'=');
  value:=tmp;
  cnt:=Length(propnamepart);
  dotstart:=-1;
  for i:=cnt downto 0 do
  begin
    if i>0 then
    case propnamepart[i] of
    '0'..'9':;
    else
    begin
      if i<>cnt then dotstart:=i;
      break;
    end;
    end;
  end;
  if dotstart=-1 then
    Prop:=propnamepart
  else
    begin
      if (dotstart>0) and (propnamepart[dotstart]='.') then
      begin
        Prop:=Copy(propnamepart,1,dotstart-1);
      end else
        Prop:=propnamepart;
        //Copy(propnamepart,1,dotstart);
      Delete(propnamepart,1,dotstart);
    end;
  if propnamepart='' then
  begin
    Result:=False;
    stylenum:=0;
    Exit;
  end;
  if propnamepart<>'' then
    val(propnamepart,stylenum,code);
  Result:=true;
end;


// Parses a string with a markerdefinition
function TSciPropertyLoader.ParseMarkerDefinition(const definition : PChar;Marker : TSciMarker) : Boolean;
var
  vxal,opt,cpComma,colon : PChar;
  MarkerNo : Integer;
begin
  if (definition = nil) or (definition^ = #0) then
  begin
    Result:=false;
    Exit;
  end;
  if not Assigned(Marker) then
  begin
    Result:=False;
    Exit;
  end;
  GetMem(vxal,Length(definition)+1);
  StrCopy(vxal,definition);
  opt:=vxal;

  while (opt<>nil) do
  begin
    // Find attribute separator
    cpComma := AnsiStrScan(opt, ',');
    if assigned(cpComma) then  // If found, we terminate the current attribute (opt) string
      cpComma^ := #0;

    // Find attribute name/value separator
    colon := AnsiStrScan(opt, ':');
    if assigned(colon) then
    begin
      // If found, we terminate the current attribute name and point on the value
      colon^:=#0;
      Inc(colon);
    end;
    if (0 = CompStr(opt, spropMarkerType)) then //notchangeable
    begin
      IdentToMarkerNo(colon,MarkerNo);
      Marker.MarkerType:=MarkerNo;
    end else
    if (0 = CompStr(opt, spropFore)) then //'fore'
    begin
      Marker.ForeColor:=ColourFromString(Trim(colon),clSilver);
    end else
    if (0 = CompStr(opt, spropBack)) then //back
    begin
      Marker.BackColor:=ColourFromString(Trim(colon),clWhite);
    end else
    if (0 = CompStr(opt, spropPixMapFile)) then //size
    begin
      Marker.PixmapFile:=colon;
    end else
    if (0 = CompStr(opt, spropMarkerAlpha)) then //size
    begin
      Marker.Alpha:=ToInt(colon,SC_ALPHA_NOALPHA);
      if Marker.Alpha>SC_ALPHA_NOALPHA then
        Marker.Alpha:=SC_ALPHA_NOALPHA;
    end;
    if assigned(cpComma) then
      opt := cpComma + 1
    else
      opt := nil;
  end;
  if assigned(vxal) then
  begin
    FreeMem(vxal);
  end;
  Result:=true;
end;

// Parses a string with a styledefinition into a TSciLangStyle
function TSciPropertyLoader.ParseStyleDefinition(const definition : PChar;var sty : TSciLangStyle;defstyle : Boolean) : Boolean;
var
  vxal,opt,cpComma,colon : PChar;
  i : Integer;
  Changeable,EOLFilled,Hotspot : Boolean;
  wasset : array [0..6] of Boolean;
  ccase : TSciCase;
  vis : Boolean;
  name : String;
begin
  if (definition = nil) or (definition^ = #0) then
  begin
    Result:=false;
    Exit;
  end;
  GetMem(vxal,Length(definition)+1);
  StrCopy(vxal,definition);
  opt:=vxal;

  Changeable:=true;
  Hotspot:=false;
  EOLFilled:=false;
  vis:=True;
  ccase:=CASE_MIXED;
  for i:=Low(wasset) to High(wasset) do wasset[i]:=False;
  while (opt<>nil) do
  begin
    // Find attribute separator
    cpComma := AnsiStrScan(opt, ',');
    if assigned(cpComma) then  // If found, we terminate the current attribute (opt) string
      cpComma^ := #0;

    // Find attribute name/value separator
    colon := AnsiStrScan(opt, ':');
    if assigned(colon) then
    begin
      // If found, we terminate the current attribute name and point on the value
      colon^:=#0;
      Inc(colon);
    end;
    if (0 = CompStr(opt, spropItalics,True)) then //'italics'
    begin
      Include(sty.FontStyles,fsItalic);
    end else
    if (0 = CompStr(opt, spropNot+spropItalics)) then //notitalics
    begin
      Exclude(sty.FontStyles,fsItalic);
    end else
    if (0 = CompStr(opt, spropBold)) then //bold
    begin
      Include(sty.FontStyles,fsBold);
    end else
    if (0 = CompStr(opt, spropNot+spropBold)) then //notbold
    begin
      Exclude(sty.FontStyles,fsBold);
    end else
    if (0 = CompStr(opt, spropFont)) then //font
    begin
      sty.FontName:=colon;
    end else
    if (0 = CompStr(opt, spropName)) then
    begin
      name:=colon;
      name:=ReplaceAChar(name,'|',',');
      wasset[5]:=true;
    end else
    if (0 = CompStr(opt, spropFore)) then //'fore'
    begin
      sty.ForeColor:=ColourFromString(Trim(colon),cDefaultForeColor);
    end else
    if (0 = CompStr(opt, spropBack)) then //back
    begin
      sty.BackColor:=ColourFromString(Trim(colon),cDefaultBackColor);
    end else
    if (0 = CompStr(opt, spropSize)) then //size
    begin
      sty.FontSize:=ToInt(colon);
    end else
    if (0 = CompStr(opt, spropEolFilled)) then //eolfilled
    begin
      EOLFilled:=true;
      wasset[4]:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropEolFilled)) then //noteolfilled
    begin
      EOLFilled:=false;
      wasset[4]:=true;
    end else
    if (0 = CompStr(opt, spropUnderlined)) then //underlined
    begin
      Include(sty.FontStyles,fsUnderline);
    end else
    if (0 = CompStr(opt, spropNot+spropUnderlined)) then //notunderlined
    begin
      Exclude(sty.FontStyles,fsUnderline);
    end else
    if (0 = CompStr(opt, spropCase)) then //case
    begin
      wasset[0]:=true;
      ccase:= CASE_MIXED;
      if assigned(colon) then
      begin
        if (colon^ = 'u') then
          ccase:= CASE_UPPER
        else if (colon^ = 'l') then
          ccase:= CASE_LOWER;
      end;
    end else
    if (0 = CompStr(opt, spropVisible)) then //visible
    begin
      wasset[1]:=true;
      Vis:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropVisible)) then //notvisible
    begin
      wasset[1]:=true;
      Vis:=false;
    end else
    if (0 = CompStr(opt, spropChangeable)) then //changeable
    begin
      wasset[2]:=true;
      Changeable:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropChangeable)) then //notchangeable
    begin
      wasset[2]:=true;
      Changeable:=false;
    end else
    if (0 = CompStr(opt, spropHotspot)) then //hotspot
    begin
      wasset[3]:=true;
      Hotspot:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropHotspot)) then //nothotspot
    begin
      wasset[3]:=true;
      Hotspot:=false;
    end;

    if assigned(cpComma) then
      opt := cpComma + 1
    else
      opt := nil;
  end;
  if assigned(vxal) then
  begin
    FreeMem(vxal);
  end;
  if defstyle=False then
  begin
    if (FDefaultStyle.FontSize<>0) and (sty.FontSize=FDefaultStyle.FontSize) then
      sty.FontSize:=0;
    if (FDefaultStyle.FontName<>'') and (CompStr(FDefaultStyle.FontName,sty.FontName)=0) then
      sty.FontName:='';
  end;
  if wasset[0] then sty.CharCase:=ccase;
  if wasset[1] then sty.Visible:=vis;
  if wasset[2] then sty.Changeable:=Changeable;
  if wasset[3] then sty.Hotspot:=Hotspot;
  if wasset[4] then sty.EOLFilled:=EOLFilled;
  if wasset[5] then sty.Name:=name;

  Result:=true;
end;

procedure TSciPropertyLoader.FillWithDefaultStyle(var sty : TSciLangStyle);
begin
  sty.EOLFilled :=fDefaultStyle.EOLFilled;
  sty.Visible   :=fDefaultStyle.Visible;
  sty.CharCase  :=fDefaultStyle.CharCase;
  sty.Changeable:=fDefaultStyle.Changeable;
  sty.Hotspot   :=fDefaultStyle.Hotspot;
  sty.FontStyles:=fDefaultStyle.FontStyles;
  sty.FontName  :='';
  sty.FontSize  :=fDefaultStyle.FontSize;
  sty.ForeColor :=clDefault;
  sty.BackColor :=clDefault;
end;

function    TSciPropertyLoader.LoadFromStream(fs : TStream) : Boolean;
var
  lst : TMyStringList;
  cnt,i,aStyle,speedcnt,ignorelines : Integer;
  aSection,aLanguage,aProp,aValue,tmpstr : String;
  Handled : Boolean;
  ps : Integer;
begin
  lst:=nil;
  if fEditor=nil then
  begin
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TSciPropertyLoader']);
    Result:=false;
    Exit;
  end;
  try

  try
    if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager)) then
      TScintilla(fEditor).LanguageManager.BeginUpdate;
    fLoadingErrors.Clear;
    fOtherSettings.Clear;
    fLexerProperties.Clear;
    lst:=TMyStringList.Create;
    lst.LoadFromStream(fs);
    cnt :=lst.Count;
    ignorelines:=0;
    for i:=0 to (cnt-1) do
    begin
      try
        speedcnt:=0;
        if ignorelines>0 then
        begin
          Dec(ignorelines);
          Continue;
        end;
        tmpstr:=Trim(lst.Strings[i]);
        if tmpstr='' then Continue;

        if Pos('#',tmpstr)=1 then Continue;
        ps:=Pos('[',tmpstr);
        if ps=1 then
        begin
          if Pos(']',tmpstr)>0 then
            Delete(tmpstr,Pos(']',tmpstr),1);
            Delete(tmpstr,1,1);
            aSection:=tmpstr;
            continue;
        end;
        while (tmpstr[Length(tmpstr)]='\') and ((i+speedcnt+1)<=(cnt-1)) do
        begin
          Inc(speedcnt);
          Delete(tmpstr,Length(tmpstr),1);
            tmpstr:=Trim(tmpstr)+' '+Trim(lst.Strings[i+speedcnt]);
        end;
        if speedcnt<>0 then ignorelines:=speedcnt;
        if PropLineSplit(tmpstr,aStyle,aProp,aValue) then
        begin
          aLanguage:=aSection;
          if ProcessDataStart(aLanguage,aProp,aStyle,aValue)=false then
          begin
            Handled:=false;
            if assigned(fOnPropLoadItem) then
              fOnPropLoadItem(self,aLanguage,aProp,aStyle,aValue,Handled);
            if Handled=False then
              if ProcessDataEnd(aLanguage,aProp,aStyle,aValue)=False then
              begin
                if tmpstr<>'' then
                begin
                  fOtherSettings.Add(Trim(tmpstr));
                end;
              end;
          end;
        end;//proplinesplit
      except
        on EConvertError do
        begin
          fLoadingErrors.Add(Format('Conversion error on line %d. Ignoring.',[i]));
        end;
      end;

    end;//for
    Self.SetLexerProperties;
    finally
      if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager)) then
        TScintilla(fEditor).LanguageManager.EndUpdate;
    end;
    DoPropertiesLoaded;
  finally
    if assigned(lst) then FreeAndNil(lst);
  end;
  Result:=true;
end;

function TSciPropertyLoader.Load : Boolean;
var
  fs : TFileStream;
begin
  fs:=nil;
  try
    try
      fs:=TFileStream.Create(fFileName,fmOpenRead or fmShareDenyWrite);
      LoadFromStream(fs);
      Result:=true;
    except
      on EStreamError do
      begin
        Result:=false;
        raise Exception.CreateResFmt(@eCouldntLoadFromFile,[fFileName]);
      end;
    end;
  finally
    if assigned(fs) then FreeAndNil(fs);
  end;
end;



procedure TSciPropertyLoader.DoPropSave(lst : TStrings);
begin
  if assigned(fOnPropSaveItems) then
  begin
    fOnPropSaveItems(Self,lst);
  end;
end;

function TSciPropertyLoader.SaveToStream(fs : TStream) : Boolean;
var
  lst : TMyStringList;
{$Ifdef USENEWLOADLEXER}
  cnt : Integer;
{$Endif}
  tmpstr : String;
  aSection : String;
begin
  lst:=nil;
  if fEditor=nil then
  begin
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,[TSciPropertyLoader]);
    Result:=false;
    Exit;
  end;
  try
    fDefaultStyle.ForeColor:=fEditor.Font.Color;
    fDefaultStyle.BackColor:=fEditor.Color;
    fDefaultStyle.FontName:=fEditor.Font.Name;
    fDefaultStyle.FontSize:=fEditor.Font.Size;
    fDefaultStyle.FontStyles:=fEditor.Font.Style;
    lst:=TMyStringList.Create;
    tmpstr:='';
    DoPropSave(lst);

    lst.Add('['+spropDefault+']');
    aSection:=spropDefault;
    if (stStyles in FStoreWhat) then
    begin
      GenerateDefaultPropLine(tmpstr,fEditor);
      lst.Add(tmpstr);
    end;
    if (stDefaults in FStoreWhat) then
    begin
      lst.Add(spropWordWrap+'='+ToStr(Integer(fEditor.WordWrap)));
      lst.Add(spropWordChars+'='+FEditor.WordChars);
      lst.Add(spropClearUndoAfterSave+'='+BoolToString(fEditor.ClearUndoAfterSave));
      lst.Add(Format('%s=%d',[spropEOLMode,fEditor.GetEOLMode]));
      if fEditor is TScintillaMemo then
      begin
        lst.Add(spropLineNumbers+'='+BoolToString(TScintillaMemo(fEditor).Gutter0.Width<>0));
        lst.Add(spropGutter+'='+BoolToString(TScintillaMemo(fEditor).Gutter1.Width<>0));
      end;
    end;
    if (stColors in FStoreWhat) then
    begin
      StoreProps(lst);
    end;
    if fEditor is TScintilla then
    begin
      if (stDefaults in FStoreWhat) then
      begin
        lst.Add(spropCodeFolding+'='+BoolToString(foldFold in TScintilla(fEditor).Folding));
        lst.Add(spropBraceHighlight+'='+BoolToString(TScintilla(fEditor).BraceHilite));
      end;
      if (stLexerProperties in FStoreWhat) and (fLexerProperties.Count<>0) then
      begin
        lst.Add('['+spropLexerPropertiesCategory+']');
        lst.AddStrings(fLexerProperties);
      end;
      if (stExtensions in FStoreWhat) then
      begin
        lst.Add(GetFileExtensionProps);
      end;
{$Ifdef USENEWLOADLEXER}
      if assigned(TScintilla(fEditor).LibrariesLoaded) then
      begin
        lst.Add('['+spropLexerLibraryCategory+']');
        cnt:=TScintilla(fEditor).LibrariesLoaded.Count;
        for i:=0 to (cnt-1) do
          lst.Add(spropLexerLib+'.'+ToStr(i)+'='+TScintilla(fEditor).LibrariesLoaded.Strings[i]);
      end;
{$Endif}
      if stStyles in FStoreWhat then
      begin
        StoreStyles(lst);
      end;
    end;
    if stOther in FStoreWhat then
    begin
      if assigned(fOtherSettings) and (fOtherSettings.Count>0) then
      begin
        lst.Add('['+spropOther+']');
        lst.AddStrings(fOtherSettings);
      end;
    end;
    lst.SaveToStream(fs);
    Result:=true;
    Exit;
  finally
    if assigned(lst) then FreeAndNil(lst);
  end;
  Result:=false;
end;

function TSciPropertyLoader.Save : Boolean;
var
  tmpstrm : TMemoryStream;
  fs : TFileStream;
begin
  fs:=nil;
  tmpstrm:=nil;
  try
    try
      tmpstrm:=TMemoryStream.Create;
      SaveToStream(tmpstrm);
      if tmpstrm.Size>2 then
      begin
        fs:=TFileStream.Create(fFileName,fmCreate);
        fs.CopyFrom(tmpstrm,0);
      end;
      Result:=true;
    except
      on EStreamError do
      begin
        Result:=false;
        raise Exception.CreateResFmt(@eCouldntWriteToFile,[fFileName]);
      end;
    end;
  finally
    if assigned(fs) then FreeAndNil(fs);
    if assigned(tmpstrm) then FreeAndNil(tmpstrm);
  end;
end;

function  TSciPropertyLoader.CommonProcessStyles(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
var
  tmpsty : TSciLangStyle;
  kwdcnt,stycnt,srchend,j : Integer;
  wasdone : Boolean;
  stytmp  : TSciStyle;
  itm     : TSciLangItem;
  tmpkwd : TSciLangKeywords;
  kwdtmp : TSciKeywords;
  kwdname : String;
begin
  Result:=False;
  if (AnsiCompareText(PropName,spropStyle)=0) or
  (AnsiCompareText(PropName,spropKeywords)=0) or
  (AnsiCompareText(PropName,spropCommentBoxStart)=0) or
  (AnsiCompareText(PropName,spropCommentBoxEnd)=0) or
  (AnsiCompareText(PropName,spropCommentBoxMiddle)=0) or
  (AnsiCompareText(PropName,spropCommentBlock)=0) or
  (AnsiCompareText(PropName,spropCommentStreamStart)=0) or
  (AnsiCompareText(PropName,spropCommentStreamEnd)=0) or
  (AnsiCompareText(PropName,spropAssignmentOperator)=0) or
  (AnsiCompareText(PropName,spropEndOfStatementOperator)=0) or
  (AnsiCompareText(PropName,spropLexer)=0) or
  (AnsiCompareText(PropName,spropNumStyleBits)=0) then
  begin
    if (AnsiCompareText(PropName,spropLexer)=0) then  // If it is a language definition
    begin
      TScintilla(Editor).LanguageManager.AddLanguage(CategoryName,aValue);
      Result:=True;
      Exit;
    end;

    itm:=TScintilla(fEditor).LanguageManager.LanguageList.Find(CategoryName);
    if itm=nil then
    begin
      itm:=TScintilla(fEditor).LanguageManager.LanguageList.Add;
      itm.Name:=CategoryName;
      itm.Lexer:=CategoryName;
    end;

    if assigned(itm) then
    begin
      if (AnsiCompareText(PropName,spropStyle)=0) then // If it is a style definition
      begin
        stycnt:=itm.Styles.Count;
        wasdone:=false;
        for j:=0 to (stycnt-1) do //Check if the style is in the list, and if so, just modify it.
        begin
          if itm.Styles.Items[j].StyleNumber=Num then
          begin
            itm.Styles.Items[j].AssignToRec(tmpsty);
            ParseStyleDefinition(PChar(aValue),tmpsty);
            itm.Styles.Items[j].AssignRec(tmpsty);
            wasdone:=true;
            Break;
          end;
        end;
        if wasdone=false then // If the style wasn't found
        begin
          stytmp:=itm.Styles.Add;
          stytmp.AssignToRec(tmpsty);
          FillWithDefaultStyle(tmpsty);
          tmpsty.StyleNumber:=Num;
          ParseStyleDefinition(PChar(aValue),tmpsty);
          stytmp.AssignRec(tmpsty);
        end;
        Result:=True;
      end else
      if AnsiCompareText(PropName,spropKeywords)=0 then // If it is a keyword definition
      begin
        kwdcnt:=itm.Keywords.Count;
        wasdone:=false;
        if (AnsiStrLIComp(PChar(spropName+':'),PChar(aValue),5)=0) then // If it's a keywordlist description
        begin
          srchend:=Pos('::',AValue);
          if srchend<>0 then
          begin
            kwdname:=Copy(aValue,6,srchend-6);
            Delete(aValue,1,srchend+1);
            kwdname:=ReplaceAChar(kwdname,'|',',');
          end else kwdname:='';
        end else kwdname:=''; //has'nt a keywordlist description

        for j:=0 to (kwdcnt-1) do //Check if the style is in the list, and if so, just modify it.
        begin
          if itm.Keywords.Items[j].KeywordListNumber=Num then
          begin
            itm.Keywords.Items[j].AssignToRec(tmpkwd);
            tmpkwd.KeyWords:=aValue;
            if kwdname<>'' then tmpkwd.Name:=kwdname;
            itm.Keywords.Items[j].AssignRec(tmpkwd);
            wasdone:=true;
            Break;
          end;
        end;
        if wasdone=false then // If the keywordlist wasn't found
        begin
          kwdtmp:=itm.Keywords.Add;
          kwdtmp.AssignToRec(tmpkwd);
          if kwdname<>'' then tmpkwd.Name:=kwdname;
          tmpkwd.KeywordListNumber:=Num;
          tmpkwd.KeyWords:=aValue;
          kwdtmp.AssignRec(tmpkwd);
        end;//wasdone
        Result:=True;
      end else
      if (AnsiCompareText(PropName,spropCommentBoxStart)=0) then
      begin
        itm.CommentBoxStart:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropCommentBoxEnd)=0) then
      begin
        itm.CommentBoxEnd:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropCommentBoxMiddle)=0) then
      begin
        itm.CommentBoxMiddle:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropCommentBlock)=0) then
      begin
        itm.CommentBlock:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropCommentStreamStart)=0) then
      begin
        itm.CommentStreamStart:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropCommentStreamEnd)=0) then
      begin
        itm.CommentStreamEnd:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropAssignmentOperator)=0) then
      begin
        itm.AssignmentOperator:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropEndOfStatementOperator)=0) then
      begin
        itm.EndOfStatementOperator:=UnSlash(aValue);
        Result:=True;
      end else if (AnsiCompareText(PropName,spropNumStyleBits)=0) then
      begin
        itm.NumStyleBits:=ToInt(aValue);
        Result:=True;
      end;
    end;//itm<>nil
  end;
end;
function  TSciPropertyLoader.CommonProcessProps(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
begin
  Result:=False;
  if AnsiCompareText(spropCaretFore,PropName)=0 then //caretfore
  begin
    fEditor.SetCaretFore(ColorToRGB(ColourFromString(aValue,cDefaultCaretFore)));
    Result:=True;
  end else if AnsiCompareText(spropCaretBack,PropName)=0 then //caretlineback
  begin
    fEditor.SetCaretLineBack(ColorToRGB(ColourFromString(aValue,cDefaultCaretBack)));
    Result:=True;
  end else if AnsiCompareText(spropCaretPeriod,PropName)=0 then
  begin
    fEditor.SetCaretPeriod(ToInt(aValue));
    Result:=True;
  end else if AnsiCompareText(spropCaretWidth,PropName)=0 then
  begin
    fEditor.SetCaretWidth(ToInt(aValue));
    Result:=True;
  end else if AnsiCompareText(spropCaretLineVisible,PropName)=0 then
  begin
      fEditor.SetCaretLineVisible(StringToBool(aValue));
    Result:=True;
  end else if AnsiCompareText(spropCaretBackAlpha,PropName)=0 then //caretlineback
  begin
    if ToInt(aValue,SC_ALPHA_NOALPHA)>SC_ALPHA_NOALPHA then
      fEditor.SetCaretLineBackAlpha(SC_ALPHA_NOALPHA)
    else
      fEditor.SetCaretLineBackAlpha(ToInt(aValue,SC_ALPHA_NOALPHA));
    Result:=True;
  end else if (AnsiCompareText(PropName,spropEdgeColumn)=0) then //EdgeColumn
  begin
    fEditor.SetEdgeColumn(ToInt(aValue));
    Result:=True;
  end else if (AnsiCompareText(PropName,spropEdgeColor)=0) then  //EdgeColor
  begin
    fEditor.SetEdgeColour(ColourFromString(aValue,cDefaultEdgeColor));
    Result:=True;
  end else if (AnsiCompareText(PropName,spropEdgeMode)=0) then  //EdgeMode
  begin
    fEditor.SetEdgeMode(ToInt(aValue));
    Result:=True;
  end;
  if fEditor is TScintilla then
  begin
    if (AnsiCompareText(PropName,spropFoldMarkerType)=0) then
    begin
      TScintilla(fEditor).FoldMarkers.MarkerType:=sciMarkerType(ToInt(aValue));
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerFoldOpen)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldOpen);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerFoldClosed)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldClosed);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerFoldSub)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldSub);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerFoldTail)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldTail);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerFoldEnd)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldEnd);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerFoldOpenMid)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldOpenMid);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerFoldMidTail)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldMidTail);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropMarkerBookMark)=0) then   //SelFore
    begin
      ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).BookMark);
      Result:=True;
    end;
  end;

  if fEditor is TScintillaMemo then
  begin
    if (AnsiCompareText(PropName,spropSelectForeColor)=0) then   //SelFore
    begin
      TScintillaMemo(fEditor).Colors.SelFore:=ColourFromString(aValue,cDefaultSelectFore);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropSelectBackColor)=0) then   //SelBack
    begin
      TScintillaMemo(fEditor).Colors.SelBack:=ColourFromString(aValue,cDefaultSelectBack);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropSelectAlpha)=0) then   //SelBack
    begin
      if ToInt(aValue,SC_ALPHA_NOALPHA)>SC_ALPHA_NOALPHA then
        TScintillaMemo(fEditor).Colors.SelAlpha:=SC_ALPHA_NOALPHA
      else
        TScintillaMemo(fEditor).Colors.SelAlpha:=ToInt(aValue,SC_ALPHA_NOALPHA);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropMarkerForeColor)=0) then
    begin
      TScintillaMemo(fEditor).Colors.MarkerFore:=ColourFromString(aValue,cDefaultMarkerFore);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropMarkerBackColor)=0) then
    begin
      TScintillaMemo(fEditor).Colors.MarkerBack:=ColourFromString(aValue,cDefaultMarkerBack);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropFoldMarginHighlightColor)=0) then
    begin
      TScintillaMemo(fEditor).Colors.FoldHi:=ColourFromString(aValue,cDefaultFoldMarginHighlightColor);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropWhiteSpaceFore)=0) then
    begin
      TScintillaMemo(fEditor).Colors.WhiteSpaceFore:=ColourFromString(aValue,fEditor.Font.Color);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropWhiteSpaceBack)=0) then
    begin
      TScintillaMemo(fEditor).Colors.WhiteSpaceBack:=ColourFromString(aValue,fEditor.Color);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropFoldMarginColor)=0) then
    begin
      TScintillaMemo(fEditor).Colors.FoldLo:=ColourFromString(aValue,cDefaultFoldMarginColor);
      Result:=True;
    end else
    if (AnsiCompareText(PropName,spropActiveHotspotForeColor)=0) then      //SelBack
    begin
      TScintillaMemo(fEditor).ActiveHotSpot.ForeColor:=ColourFromString(aValue,cDefaultHotspotFore);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropActiveHotspotBackColor)=0) then      //SelBack
    begin
      TScintillaMemo(fEditor).ActiveHotSpot.BackColor:=ColourFromString(aValue,cDefaultHotspotBack);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropActiveHotspotUnderlined)=0) then      //SelBack
    begin
      TScintillaMemo(fEditor).ActiveHotSpot.Underlined:=StringToBool(aValue);
      Result:=True;
    end else if (AnsiCompareText(PropName,spropActiveHotspotSingleLine)=0) then      //SelBack
    begin
      TScintillaMemo(fEditor).ActiveHotSpot.SingleLine:=StringToBool(aValue);
      Result:=True;
    end;
  end;
end;

{
  Loads only the default style AND all styles/keywords from a stream.
  Ignores everything else.
}
function TSciPropertyLoader.LoadStylesFromStream(fs : TStream) : Boolean;
var
  lst : TMyStringList;
  cnt,i,aStyle,speedcnt,ignorelines : Integer;
  aSection,aLanguage,aProp,aValue,tmpstr : String;
  ps : Integer;
  oldlang : String;
  procedure ClearLangList;
  var
    cnt,i : Integer;
    clang : String;
    inlist : Boolean;
  begin
    cnt:=TScintilla(fEditor).LanguageManager.LanguageList.Count;
    for i:=(cnt-1) downto 0 do
    begin
      clang:=TScintilla(fEditor).LanguageManager.LanguageList.Items[i].Name;
      TScintilla(fEditor).LanguageManager.RemoveLanguage(clang,inlist);
    end;
  end;

  function  ProcessStylesOnly(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
  var
    tmpsty : TSciLangStyle;
  begin
    if (AnsiCompareText(CategoryName,spropDefault)=0)  then //If it is the default style
    begin
      if (AnsiCompareText(PropName,spropStyle)=0) then
      begin
        tmpsty.EOLFilled:=false;
        tmpsty.Visible:=True;
        tmpsty.CharCase:=CASE_MIXED;
        tmpsty.Changeable:=True;
        tmpsty.Hotspot:=False;
        tmpsty.FontStyles:=[];
        tmpsty.FontName:='';
        tmpsty.FontSize:=0;
        tmpsty.ForeColor:=clDefault;
        tmpsty.BackColor:=clDefault;
        ParseStyleDefinition(PChar(aValue),tmpsty,true);
        fDefaultStyle.FontName:=tmpsty.FontName;
        fDefaultStyle.FontSize:=tmpsty.FontSize;
        fDefaultStyle.FontStyles:=tmpsty.FontStyles;
        fDefaultStyle.ForeColor:=tmpsty.ForeColor;
        fDefaultStyle.BackColor:=tmpsty.BackColor;
        fDefaultStyle.CharCase:=tmpsty.CharCase;
        fDefaultStyle.Visible:=tmpsty.Visible;
        fDefaultStyle.Changeable:=tmpsty.Changeable;
        fDefaultStyle.Hotspot:=tmpsty.Hotspot;
        fDefaultStyle.EOLFilled:=tmpsty.EOLFilled;
        fEditor.Color:=tmpsty.BackColor;
        fEditor.Font.Color:=tmpsty.ForeColor;
        fEditor.Font.Name:=tmpsty.FontName;
        fEditor.Font.Size:=tmpsty.FontSize;
        fEditor.Font.Style:=tmpsty.FontStyles;
        Result:=True;
      end else
        Result:=CommonProcessProps(CategoryName,PropName,Num,aValue);
    end else
      Result:=CommonProcessStyles(CategoryName,PropName,Num,aValue);
  end;
begin
  lst:=nil;
  Result:=false;
  if (not assigned(fEditor)) then
  begin
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TSciPropertyLoader']);
    Result:=false;
    Exit;
  end;
  if not (fEditor is TScintilla) then
  begin
    raise Exception.CreateRes(@eEditorIsNotTScintilla);
    Result:=false;
    Exit;
  end;
  try
    if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager)) then
      TScintilla(fEditor).LanguageManager.BeginUpdate;
    fLoadingErrors.Clear;
    if (not(fEditor is TScintilla)) or (not assigned(TScintilla(fEditor).LanguageManager)) then Exit;
    oldlang:=TScintilla(fEditor).LanguageManager.SelectedLanguage;

    TScintilla(fEditor).LanguageManager.SelectedLanguage:='null';
    ClearLangList;
    try
      lst:=TMyStringList.Create;
      lst.LoadFromStream(fs);
      cnt :=lst.Count;
      ignorelines:=0;
      for i:=0 to (cnt-1) do
      begin
        try
          speedcnt:=0;
          if ignorelines>0 then
          begin
            Dec(ignorelines);
            Continue;
          end;
          tmpstr:=Trim(lst.Strings[i]);
          if tmpstr='' then Continue;

          if Pos('#',tmpstr)=1 then Continue;
          ps:=Pos('[',tmpstr);
          if ps=1 then
          begin
            if Pos(']',tmpstr)>0 then
              Delete(tmpstr,Pos(']',tmpstr),1);
              Delete(tmpstr,1,1);
              aSection:=tmpstr;
              continue;
          end;
          while (tmpstr[Length(tmpstr)]='\') and ((i+speedcnt+1)<=(cnt-1)) do
          begin
            Inc(speedcnt);
            Delete(tmpstr,Length(tmpstr),1);
              tmpstr:=Trim(tmpstr)+' '+Trim(lst.Strings[i+speedcnt]);
          end;
          if speedcnt<>0 then ignorelines:=speedcnt;
          if PropLineSplit(tmpstr,aStyle,aProp,aValue) then
          begin
            aLanguage:=aSection;
            ProcessStylesOnly(aLanguage,aProp,aStyle,aValue);
          end;//proplinesplit
        except
          on EConvertError do
          begin
            fLoadingErrors.Add(Format(eConversionErrorMsg,[i]));
          end;
          on E : Exception do
          begin
            fLoadingErrors.Add(E.Message);
          end;
        end;
      end;//for
      if (TScintilla(fEditor).LanguageManager.SelectedLanguage<>oldlang) and (assigned(TScintilla(fEditor).LanguageManager.LanguageList.Find(oldlang))) then
        TScintilla(fEditor).LanguageManager.SelectedLanguage:=oldlang;
{      if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager)) then
        TScintilla(fEditor).LanguageManager.Update;}
    finally
      //
    end;
  finally
    if (fEditor is TScintilla) and (assigned(TScintilla(fEditor).LanguageManager)) then
      TScintilla(fEditor).LanguageManager.EndUpdate;
    if assigned(lst) then FreeAndNil(lst);
  end;
  Result:=true;
end;

function TSciPropertyLoader.LoadStyles(const filename : String) : Boolean;
var
  fs : TFileStream;
begin
  fs:=nil;
  try
    try
      fs:=TFileStream.Create(filename,fmOpenRead or fmShareDenyWrite);
      LoadStylesFromStream(fs);
      Result:=true;
    except
      on EStreamError do
      begin
        Result:=false;
        raise Exception.CreateResFmt(@eCouldntLoadFromFile,[filename]);
      end;
    end;
  finally
    if assigned(fs) then FreeAndNil(fs);
  end;
end;

procedure TSciPropertyLoader.StoreStyles(lst : TStrings);
var
  langcnt,stylcnt,kwdcnt,i,j : Integer;
{$Ifdef USENEWLOADLEXER}
  cnt : Integer;
{$Endif}

  itm : TSciLangItem;
  tmpstr,prefix,langname : String;
begin
  if (not(fEditor is TScintilla)) then Exit;
  if not (assigned(TScintilla(fEditor).LanguageManager)) then Exit;
  langcnt:=TScintilla(fEditor).LanguageManager.LanguageList.Count;

  for i:=0 to (langcnt-1) do
  begin
    itm:=TScintilla(fEditor).LanguageManager.LanguageList.Items[i];
    langname :=itm.Name;
    if langname='' then langname:=IntToStr(i);
    prefix :=langname+'.';
    lst.Add('['+langname+']');
    with itm do
    begin
      lst.Add(spropLexer+'='+itm.Lexer);
      if itm.NumStyleBits<>5 then
      lst.Add(spropNumStyleBits+'='+ToStr(itm.NumStyleBits));
      kwdcnt:=itm.Keywords.Count;
      for j:=0 to (kwdcnt-1) do
      begin
        GenerateKwdPropLine(tmpstr,spropKeywords+'.',itm.Keywords.Items[j]);
        if tmpstr<>'' then
        begin
          lst.Add(tmpstr);
          if j<(kwdcnt-1) then
          lst.Add('');
        end;
      end;
      stylcnt:=itm.Styles.Count;
      if (stylcnt>0) then
      begin
        lst.Add('');
      end;
      for j:=0 to (stylcnt-1) do
      begin
        GenerateStylePropLine(tmpstr,spropStyle+'.',TSciStyle(itm.Styles.Items[j]));
        if tmpstr<>'' then lst.Add(tmpstr);
      end;
      lst.Add('');
    end;
    lst.Add(spropCommentBoxStart+'='+itm.CommentBoxStart);
    lst.Add(spropCommentBoxEnd+'='+itm.CommentBoxEnd);
    lst.Add(spropCommentBoxMiddle+'='+itm.CommentBoxMiddle);
    lst.Add(spropCommentBlock+'='+itm.CommentBlock);
    lst.Add(spropCommentStreamStart+'='+itm.CommentStreamStart);
    lst.Add(spropCommentStreamEnd+'='+itm.CommentStreamEnd);
    lst.Add(spropAssignmentOperator+'='+itm.AssignmentOperator);
    lst.Add(spropEndOfStatementOperator+'='+itm.EndOfStatementOperator);
  end;
end;

procedure TSciPropertyLoader.StoreProps(lst : TStrings);
var
  tmpclr : TColor;
begin
  lst.Add(Format('%s=%d',[spropCaretPeriod,fEditor.GetCaretPeriod]));
  lst.Add(Format('%s=%d',[spropCaretWidth,fEditor.GetCaretWidth]));
  lst.Add(spropCaretLineVisible+'='+BoolToString(fEditor.GetCaretLineVisible));
  tmpclr:=fEditor.GetCaretFore;
  lst.Add(spropCaretFore+'='+ColourToString(tmpclr)); //caretfore
  tmpclr:=fEditor.GetCaretLineBack;
  lst.Add(spropCaretBack+'='+ColourToString(tmpclr)); //caretback
  lst.Add(spropCaretBackAlpha+'='+ToStr(fEditor.GetCaretLineBackAlpha)); //caretbackalpha

  if fEditor is TScintillaMemo then
  begin
    lst.Add(spropSelectForeColor+'='+ColourToString(TScintillaMemo(fEditor).Colors.SelFore));
    lst.Add(spropSelectBackColor+'='+ColourToString(TScintillaMemo(fEditor).Colors.SelBack));
    lst.Add(spropSelectAlpha+'='+ToStr(TScintillaMemo(fEditor).Colors.SelAlpha));
    lst.Add(spropMarkerForeColor+'='+ColourToString(TScintillaMemo(fEditor).Colors.MarkerFore));
    lst.Add(spropMarkerBackColor+'='+ColourToString(TScintillaMemo(fEditor).Colors.MarkerBack));
    lst.Add(spropFoldMarginHighlightColor+'='+ColourToString(TScintillaMemo(fEditor).Colors.FoldHi));
    lst.Add(spropFoldMarginColor+'='+ColourToString(TScintillaMemo(fEditor).Colors.FoldLo));
    lst.Add(spropWhiteSpaceFore+'='+ColourToString(TScintillaMemo(fEditor).Colors.WhiteSpaceFore));
    lst.Add(spropWhiteSpaceBack+'='+ColourToString(TScintillaMemo(fEditor).Colors.WhiteSpaceBack));
    lst.Add(spropActiveHotspotForeColor+'='+ColourToString(TScintillaMemo(fEditor).ActiveHotSpot.ForeColor));
    lst.Add(spropActiveHotspotBackColor+'='+ColourToString(TScintillaMemo(fEditor).ActiveHotSpot.BackColor));
    lst.Add(spropActiveHotspotUnderlined+'='+BoolToString(TScintillaMemo(fEditor).ActiveHotSpot.Underlined));
    lst.Add(spropActiveHotspotSingleLine+'='+BoolToString(TScintillaMemo(fEditor).ActiveHotSpot.SingleLine));
    if fEditor is TScintilla then
    begin
      try
      lst.Add(Format('%s=%d',[spropFoldMarkerType,Integer(TScintilla(fEditor).FoldMarkers.MarkerType)]));
      if TScintilla(fEditor).FoldMarkers.MarkerType=sciMarkCustom then
      begin
        lst.Add(Format('%s=%s',[spropMarkerFoldOpen,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldOpen)]));
        lst.Add(Format('%s=%s',[spropMarkerFoldClosed,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldClosed)]));
        lst.Add(Format('%s=%s',[spropMarkerFoldSub,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldSub)]));
        lst.Add(Format('%s=%s',[spropMarkerFoldTail,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldTail)]));
        lst.Add(Format('%s=%s',[spropMarkerFoldEnd,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldEnd)]));
        lst.Add(Format('%s=%s',[spropMarkerFoldOpenMid,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldOpenMid)]));
        lst.Add(Format('%s=%s',[spropMarkerFoldMidTail,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldMidTail)]));
      end;
      except
        on E : Exception do MessageBox(0,PChar(E.Message),'',MB_OK);
      end;
    end;
    lst.Add(Format('%s=%s',[spropMarkerBookMark,GenerateMarkerLine(TScintilla(fEditor).Bookmark)]));
  end;
  lst.Add(Format('%s=%d',[spropEdgeColumn,fEditor.GetEdgeColumn]));
  lst.Add(Format('%s=%d',[spropEdgeMode,fEditor.GetEdgeMode]));
  lst.Add(spropEdgeColor+'='+ColourToString(fEditor.GetEdgeColour));
end;
{
  Save only the default style AND all styles/keywords to a stream
}
function TSciPropertyLoader.SaveStylesToStream(fs : TStream) : Boolean;
var
  lst : TMyStringList;
  tmpstr : String;
begin
  lst:=nil;
  if (not assigned(fEditor)) then
  begin
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TSciPropertyLoader']);
    Result:=false;
    Exit;
  end;
  if not (fEditor is TScintilla) then
  begin
    raise Exception.CreateRes(@eEditorIsNotTScintilla);
    Result:=false;
    Exit;
  end;
  if not Assigned(TScintilla(fEditor).LanguageManager) then
  begin
    raise Exception.CreateRes(@eNoLanguageManager);
    Result:=false;
    Exit;
  end;

  try
    lst:=TMyStringList.Create;
    if assigned(TScintilla(fEditor).LanguageManager) then
    begin
      fDefaultStyle.FontName:=TScintilla(fEditor).Font.Name;
      fDefaultStyle.FontSize:=TScintilla(fEditor).Font.Size;
      fDefaultStyle.FontStyles:=TScintilla(fEditor).Font.Style;
      fDefaultStyle.ForeColor:=TScintilla(fEditor).Font.Color;
      fDefaultStyle.BackColor:=TScintilla(fEditor).Color;
      lst.Add('['+spropDefault+']');
      GenerateDefaultPropLine(tmpstr,fEditor);
      lst.Add(tmpstr);
      StoreProps(lst);
      StoreStyles(lst);
    end;
    lst.SaveToStream(fs);
    Result:=true;
    Exit;
  finally
    if assigned(lst) then FreeAndNil(lst);
  end;
  Result:=false;
end;

function TSciPropertyLoader.SaveStyles(const filename : String) : Boolean;
var
  fs : TFileStream;
begin
  fs:=nil;
  try
    try
      fs:=TFileStream.Create(filename,fmCreate or fmShareDenyWrite);
      SaveStylesToStream(fs);
      Result:=true;
    except
      on EStreamError do
      begin
        Result:=false;
        raise Exception.CreateResFmt(@eCouldntLoadFromFile,[filename]);
      end;
    end;
  finally
    if assigned(fs) then FreeAndNil(fs);
  end;
end;

// Parses the Categorynames: lexer, extension,default
function TSciPropertyLoader.ProcessDataStart(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
var
  tmpsty : TSciLangStyle;
begin
  Result:=False;
  if (AnsiCompareText(PropName,spropLexer)=0) then  // If it is a language definition
  begin
    if (Editor is TScintilla) and (assigned(TScintilla(Editor).LanguageManager)) then
      TScintilla(Editor).LanguageManager.AddLanguage(CategoryName,aValue);
    Result:=True;
  end else
  if AnsiCompareText(CategoryName,spropExtension)=0 then // If it is a extension definition
  begin
    if PropName[1]='.' then
    begin
      ExtMapper.Add(PropName,aValue);
    end else
      ExtMapper.Add(aValue,PropName);
    Result:=True;
  end else
  if AnsiCompareText(CategoryName,spropLexerPropertiesCategory)=0 then // If it is a extension definition
  begin
    fLexerProperties.Add(PropName+'='+aValue);
    Result:=True;
  end else
  if (AnsiCompareText(CategoryName,spropDefault)=0)  then //If it is the default style
  begin
    if (AnsiCompareText(PropName,spropStyle)=0) then
    begin
      tmpsty.EOLFilled:=false;
      tmpsty.Visible:=True;
      tmpsty.CharCase:=CASE_MIXED;
      tmpsty.Changeable:=True;
      tmpsty.Hotspot:=False;
      tmpsty.FontStyles:=[];
      tmpsty.FontName:='';
      tmpsty.FontSize:=0;
      tmpsty.ForeColor:=clDefault;
      tmpsty.BackColor:=clDefault;
      ParseStyleDefinition(PChar(aValue),tmpsty,true);
      fDefaultStyle.FontName:=tmpsty.FontName;
      fDefaultStyle.FontSize:=tmpsty.FontSize;
      fDefaultStyle.FontStyles:=tmpsty.FontStyles;
      fDefaultStyle.ForeColor:=tmpsty.ForeColor;
      fDefaultStyle.BackColor:=tmpsty.BackColor;
      fDefaultStyle.CharCase:=tmpsty.CharCase;
      fDefaultStyle.Visible:=tmpsty.Visible;
      fDefaultStyle.Changeable:=tmpsty.Changeable;
      fDefaultStyle.Hotspot:=tmpsty.Hotspot;
      fDefaultStyle.EOLFilled:=tmpsty.EOLFilled;
      fEditor.Color:=tmpsty.BackColor;
      fEditor.Font.Color:=tmpsty.ForeColor;
      fEditor.Font.Name:=tmpsty.FontName;
      fEditor.Font.Size:=tmpsty.FontSize;
      fEditor.Font.Style:=tmpsty.FontStyles;
      Result:=True;
    end else if (AnsiCompareText(PropName,spropWordWrap)=0) then //WordWrap
    begin
      fEditor.WordWrap:=TWordWrapType(ToInt(aValue));
      Result:=True;
    end else if (AnsiCompareText(PropName,spropWordChars)=0) then //WordChars
    begin
      fEditor.WordChars:=aValue;
      Result:=True;
    end else if (AnsiCompareText(PropName,spropEOLMode)=0) then  //EOLMode
    begin
      fEditor.SetEOLMode(ToInt(aValue));
      Result:=True;
    end else if (AnsiCompareText(PropName,spropClearUndoAfterSave)=0) then //ClearUndoAfterSave
    begin
      fEditor.ClearUndoAfterSave:=StringToBool(aValue);
      Result:=True;
    end  else if (fEditor is TScintillaMemo) then
    begin
      if (AnsiCompareText(PropName,spropLineNumbers)=0) then //LineNumbers
      begin
        if StringToBool(aValue)=True then
        begin
          TScintillaMemo(fEditor).Gutter0.Width:=32;
          TScintillaMemo(fEditor).Gutter0.MarginType:=gutLineNumber;
        end else
        begin
          TScintillaMemo(fEditor).Gutter0.Width:=0;
        end;
        Result:=True;
      end else if (AnsiCompareText(PropName,spropGutter)=0) then //Gutter
      begin
        if StringToBool(aValue)=True then
        begin
          TScintillaMemo(fEditor).Gutter1.Width:=16;
          TScintillaMemo(fEditor).Gutter1.MarginType:=gutSymbol;
        end else
        begin
          TScintillaMemo(fEditor).Gutter1.Width:=0;
        end;
        Result:=True;
      end else
        Result:=CommonProcessProps(CategoryName,PropName,Num,aValue);
      if Result then Exit;
      if fEditor is TScintilla then
      begin
        if (AnsiCompareText(PropName,spropCodeFolding)=0) then      //CodeFolding
        begin
          if StringToBool(aValue)=True then
            TScintilla(fEditor).Folding:=TScintilla(fEditor).Folding+[foldFold]
          else
            TScintilla(fEditor).Folding:=TScintilla(fEditor).Folding-[foldFold];
          Result:=True;
        end else if (AnsiCompareText(PropName,spropBraceHighlight)=0) then      //SelBack
        begin
          TScintilla(fEditor).BraceHilite:=StringToBool(aValue);
          Result:=True;
        end;
      end;
    end; //scintillamemo
  end
{$Ifdef USENEWLOADLEXER}
  else if (Editor is TScintilla) and (AnsiCompareText(CategoryName,spropLexerLibraryCategory)=0) then // If it is a library
  begin
    if AnsiCompareText(PropName,spropLexerLib)=0 then
      TScintilla(Editor).LoadLexerLibrary(aValue);
    Result:=True;
  end;
{$Else}
;
{$Endif}

end;

const
dataendset =['s','S','k','K','c','C','A','a','e','E','n','N'];

// Parses the Propnames: style,keywords and more..
function TSciPropertyLoader.ProcessDataEnd(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
var
  c:Char;
begin
  c:=PropName[1];
  if not (c in dataendset) then
  begin
    Result:=False;
    Exit;
  end;
  Result:=CommonProcessStyles(CategoryName,PropName,Num,aValue);
end;

function TSciPropertyLoader.GetInt(const SettingName : String;const DefaultValue : Integer=0;const AddIfNonExistent : Boolean=False) : Integer;
begin
  Result:=ToInt(GetOther(SettingName,ToStr(DefaultValue),AddIfNonExistent));
end;
function TSciPropertyLoader.GetBool(const SettingName : String;const DefaultValue : Boolean=False;const AddIfNonExistent : Boolean=False) : Boolean;
begin
  Result :=StringToBool(GetOther(SettingName,BoolToString(DefaultValue),AddIfNonExistent));
end;

procedure TSciPropertyLoader.AddInt(const SettingName : String;const value : Integer);
begin
  AddOther(SettingName,ToStr(value));
end;

procedure TSciPropertyLoader.AddBool(const SettingName : String;const value : Boolean);
begin
  AddOther(SettingName,BoolToString(value));
end;

procedure TSciPropertyLoader.AddOther(const SettingName : String;const value : String);
var
idx : Integer;
begin
  idx:=fOtherSettings.IndexOfName(SettingName);
  if idx<>-1 then
  begin
    fOtherSettings.Delete(idx);
    fOtherSettings.Add(SettingName+'='+value);
  end
  else
    fOtherSettings.Add(SettingName+'='+value);
end;

function TSciPropertyLoader.GetOther(const SettingName : String;const DefaultValue : String;const AddIfNonExistent : Boolean) : String;
begin
  if fOtherSettings.IndexOfName(SettingName)<>-1 then
  begin
    Result:=fOtherSettings.Values[SettingName];
  end else
  begin
    if AddIfNonExistent=True then AddOther(SettingName,DefaultValue);
    Result:=DefaultValue;
  end;
end;

end.
Added src/delphisci/SciReplaceTextDlg.ddp.

cannot compute difference between binary files

Added src/delphisci/SciReplaceTextDlg.dfm.






















































































































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
object TextReplaceDialog: TTextReplaceDialog
  Left = 521
  Top = 592
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  Caption = 'Search and Replace Text'
  ClientHeight = 203
  ClientWidth = 338
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBtnText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poOwnerFormCenter
  OnCloseQuery = FormCloseQuery
  PixelsPerInch = 96
  TextHeight = 13
  object BasePanel: TPanel
    Left = 0
    Top = 0
    Width = 338
    Height = 203
    Align = alClient
    BevelOuter = bvNone
    TabOrder = 0
    object Label1: TLabel
      Left = 16
      Top = 11
      Width = 52
      Height = 13
      Caption = '&Search for:'
    end
    object Label2: TLabel
      Left = 8
      Top = 36
      Width = 65
      Height = 13
      Caption = '&Replace with:'
    end
    object gbSearchOptions: TGroupBox
      Left = 4
      Top = 54
      Width = 154
      Height = 129
      Caption = 'Options'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ParentFont = False
      TabOrder = 2
      object cbSearchCaseSensitive: TCheckBox
        Left = 6
        Top = 16
        Width = 140
        Height = 17
        Caption = 'C&ase sensitivity'
        TabOrder = 0
      end
      object cbSearchWholeWords: TCheckBox
        Left = 6
        Top = 36
        Width = 140
        Height = 17
        Caption = '&Whole words only'
        TabOrder = 1
      end
      object cbSearchFromCursor: TCheckBox
        Left = 6
        Top = 57
        Width = 140
        Height = 17
        Caption = 'Searc&h from caret'
        Checked = True
        State = cbChecked
        TabOrder = 2
      end
      object cbSearchSelectedOnly: TCheckBox
        Left = 6
        Top = 78
        Width = 140
        Height = 17
        Caption = '&Selected text only'
        TabOrder = 3
      end
      object cbRegularExpression: TCheckBox
        Left = 6
        Top = 99
        Width = 140
        Height = 17
        Caption = 'R&egular expression'
        TabOrder = 4
        OnClick = cbRegularExpressionClick
      end
    end
    object rgSearchDirection: TRadioGroup
      Left = 170
      Top = 54
      Width = 154
      Height = 65
      Caption = 'Direction'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      Items.Strings = (
        'F&orward'
        '&Backward')
      ParentFont = False
      TabOrder = 3
    end
    object btnOK: TBitBtn
      Left = 170
      Top = 160
      Width = 75
      Height = 24
      Hint = 'Start search and replace'
      Caption = '&Replace'
      ModalResult = 1
      ParentShowHint = False
      ShowHint = True
      TabOrder = 4
      Glyph.Data = {
        36040000424D3604000000000000360000002800000010000000100000000100
        2000000000000004000000000000000000000000000000000000FF00FF000000
        0000FF00FF00FF00FF0000000000FF00FF00FF00FF0000000000FF00FF00FF00
        FF00FF00FF000000000000000000FF00FF00FF00FF00FF00FF00FF00FF000000
        0000FF00FF00FF00FF0000000000FF00FF00FF00FF00FF00FF0000000000FF00
        FF00FF00FF0000000000FF00FF0000000000FF00FF00FF00FF00FF00FF000000
        0000000000000000000000000000FF00FF000000000000000000000000000000
        0000FF00FF000000000000000000FF00FF00FF00FF00FF00FF00FF00FF000000
        0000FF00FF00FF00FF0000000000FF00FF00FF00FF00FF00FF0000000000FF00
        FF00FF00FF0000000000FF00FF0000000000FF00FF00FF00FF00FF00FF00FF00
        FF000000000000000000FF00FF00FF00FF00FF00FF0000000000FF00FF00FF00
        FF00FF00FF000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF0000000000C6C6C60000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF0000000000C6C6C60000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF0000000000000000000000000084848400FF00FF00FF00FF00FF00FF008484
        8400000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF0000000000C6C6C60000000000000000000000000000000000C6C6C6000000
        0000000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF0000000000C6C6C60000000000000000000000000000000000C6C6C6000000
        0000000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00000000000000000000000000000000000000000000000000000000000000
        0000000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00000000000000000000000000000000000000000084848400000000000000
        0000000000000000000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00FF00FF00FF00FF000000000000000000FF00FF00FF00FF00FF00FF000000
        000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00
        FF00FF00FF00FF00FF000000000000000000FF00FF00FF00FF00FF00FF000000
        000000000000FF00FF00FF00FF00FF00FF00FF00FF00FF00FF00}
    end
    object btnCancel: TBitBtn
      Left = 249
      Top = 160
      Width = 75
      Height = 24
      Hint = 'Cancel search and replace'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 5
      Kind = bkCancel
    end
    object cbSearchText: TComboBox
      Left = 73
      Top = 8
      Width = 260
      Height = 21
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ItemHeight = 13
      ParentFont = False
      TabOrder = 0
    end
    object cbReplaceText: TComboBox
      Left = 73
      Top = 32
      Width = 260
      Height = 21
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ItemHeight = 13
      ParentFont = False
      TabOrder = 1
    end
  end
end
Added src/delphisci/SciReplaceTextDlg.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
{-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is: dlgSearchText.pas, released 2000-06-23.

The Original Code is part of the SearchReplaceDemo project, written by
Michael Hieke for the SynEdit component suite.
All Rights Reserved.

Contributors to the SynEdit project are listed in the Contributors.txt file.

Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.

$Id: SciSearchTextDlg.pas,v 1.4 2004/11/13 04:29:50 hdalis Exp $

You may retrieve the latest version of this file at the SynEdit home page,
located at http://SynEdit.SourceForge.net

Known Issues:
-------------------------------------------------------------------------------}
{
  History:   29/09/2004 Initial Release with Delphi Scintilla Interface Components
                        Removed Dialogs and Graphics from the uses list.
}

{$Include SciCommonDef.Inc}
unit SciReplaceTextDlg;
interface
uses
  Windows, Messages, SysUtils, Classes, Controls, Forms,
  StdCtrls, ExtCtrls, Buttons;//Dialogs,Graphics,

type
  TTextReplaceDialog = class(TForm)
    BasePanel: TPanel;
    gbSearchOptions: TGroupBox;
    cbSearchCaseSensitive: TCheckBox;
    cbSearchWholeWords: TCheckBox;
    cbSearchFromCursor: TCheckBox;
    cbSearchSelectedOnly: TCheckBox;
    cbRegularExpression: TCheckBox;
    rgSearchDirection: TRadioGroup;
    btnOK: TBitBtn;
    btnCancel: TBitBtn;
    cbSearchText: TComboBox;
    Label1: TLabel;
    Label2: TLabel;
    cbReplaceText: TComboBox;
    procedure cbRegularExpressionClick(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    function GetSearchBackwards: boolean;
    function GetSearchCaseSensitive: boolean;
    function GetSearchFromCursor: boolean;
    function GetSearchInSelection: boolean;
    function GetSearchText: string;
    function GetSearchTextHistory: string;
    function GetSearchWholeWords: boolean;
    procedure SetSearchBackwards(Value: boolean);
    procedure SetSearchCaseSensitive(Value: boolean);
    procedure SetSearchFromCursor(Value: boolean);
    procedure SetSearchInSelection(Value: boolean);
    procedure SetSearchText(Value: string);
    procedure SetSearchTextHistory(Value: string);
    procedure SetSearchWholeWords(Value: boolean);
    procedure SetSearchRegularExpression(const Value: boolean);
    function GetSearchRegularExpression: boolean;
    function GetReplaceText: string;
    function GetReplaceTextHistory: string;
    procedure SetReplaceText(Value: string);
    procedure SetReplaceTextHistory(Value: string);
    
  public
    property SearchBackwards: boolean read GetSearchBackwards
      write SetSearchBackwards;
    property SearchCaseSensitive: boolean read GetSearchCaseSensitive
      write SetSearchCaseSensitive;
    property SearchFromCursor: boolean read GetSearchFromCursor
      write SetSearchFromCursor;
    property SearchInSelectionOnly: boolean read GetSearchInSelection
      write SetSearchInSelection;
    property SearchText: string read GetSearchText write SetSearchText;
    property SearchTextHistory: string read GetSearchTextHistory
      write SetSearchTextHistory;
    property SearchWholeWords: boolean read GetSearchWholeWords
      write SetSearchWholeWords;
    property SearchRegularExpression: boolean read GetSearchRegularExpression
      write SetSearchRegularExpression;
    property ReplaceText: string read GetReplaceText write SetReplaceText;
    property ReplaceTextHistory: string read GetReplaceTextHistory
      write SetReplaceTextHistory;     
  end;

implementation

{$R *.DFM}
uses SciResLang;
{ TTextReplaceDialog }

function TTextReplaceDialog.GetSearchBackwards: boolean;
begin
  Result := rgSearchDirection.ItemIndex = 1;
end;

function TTextReplaceDialog.GetSearchCaseSensitive: boolean;
begin
  Result := cbSearchCaseSensitive.Checked;
end;

function TTextReplaceDialog.GetSearchFromCursor: boolean;
begin
  Result := cbSearchFromCursor.Checked;
end;

function TTextReplaceDialog.GetSearchInSelection: boolean;
begin
  Result := cbSearchSelectedOnly.Checked;
end;

function TTextReplaceDialog.GetSearchRegularExpression: boolean;
begin
  Result := cbRegularExpression.Checked;
end;

function TTextReplaceDialog.GetSearchText: string;
begin
  Result := cbSearchText.Text;
end;

function TTextReplaceDialog.GetSearchTextHistory: string;
var
  i: Integer;
begin
  Result := '';
  for i := 0 to cbSearchText.Items.Count - 1 do begin
    if i >= 10 then
      break;
    if i > 0 then
      Result := Result + CrLf;
    Result := Result + cbSearchText.Items[i];
  end;
end;

function TTextReplaceDialog.GetSearchWholeWords: boolean;
begin
  Result := cbSearchWholeWords.Checked;
end;

procedure TTextReplaceDialog.SetSearchBackwards(Value: boolean);
begin
  rgSearchDirection.ItemIndex := Ord(Value);
end;

procedure TTextReplaceDialog.SetSearchCaseSensitive(Value: boolean);
begin
  cbSearchCaseSensitive.Checked := Value;
end;

procedure TTextReplaceDialog.SetSearchFromCursor(Value: boolean);
begin
  cbSearchFromCursor.Checked := Value;
end;

procedure TTextReplaceDialog.SetSearchInSelection(Value: boolean);
begin
  cbSearchSelectedOnly.Checked := Value;
end;

procedure TTextReplaceDialog.SetSearchText(Value: string);
begin
  cbSearchText.Text := Value;
end;

procedure TTextReplaceDialog.SetSearchTextHistory(Value: string);
begin
  cbSearchText.Items.Text := Value;
end;

procedure TTextReplaceDialog.SetSearchWholeWords(Value: boolean);
begin
  cbSearchWholeWords.Checked := Value;
end;

procedure TTextReplaceDialog.SetSearchRegularExpression(
  const Value: boolean);
begin
  cbRegularExpression.Checked := Value;
end;

{ event handlers }

procedure TTextReplaceDialog.cbRegularExpressionClick(Sender: TObject);
begin
  if cbRegularExpression.Checked then rgSearchDirection.ItemIndex := 0;
end;

function TTextReplaceDialog.GetReplaceText: string;
begin
  Result := cbReplaceText.Text;
end;

function TTextReplaceDialog.GetReplaceTextHistory: string;
var
  i: Integer;
begin
  Result := '';
  for i := 0 to cbReplaceText.Items.Count - 1 do begin
    if i >= 10 then
      break;
    if i > 0 then
      Result := Result + CrLf;
    Result := Result + cbReplaceText.Items[i];
  end;
end;

procedure TTextReplaceDialog.SetReplaceText(Value: string);
begin
  cbReplaceText.Text := Value;
end;

procedure TTextReplaceDialog.SetReplaceTextHistory(Value: string);
begin
  cbReplaceText.Items.Text := Value;
end;

procedure TTextReplaceDialog.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
var
  s: string;
  i: Integer;
begin
  if ModalResult = mrOK then
  begin
    s := cbSearchText.Text;
    if s <> '' then
    begin
      i := cbSearchText.Items.IndexOf(s);
      if i > -1 then
      begin
        cbSearchText.Items.Delete(i);
        cbSearchText.Items.Insert(0, s);
        cbSearchText.Text := s;
      end else
        cbSearchText.Items.Insert(0, s);
    end;
    s := cbReplaceText.Text;
    if s <> '' then
    begin
      i := cbReplaceText.Items.IndexOf(s);
      if i > -1 then
      begin
        cbReplaceText.Items.Delete(i);
        cbReplaceText.Items.Insert(0, s);
        cbReplaceText.Text := s;
      end else
        cbReplaceText.Items.Insert(0, s);
    end;
  end;
end;

end.

Added src/delphisci/SciResLang.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author: hdalis (hdalis@users.sourceforge.net)
     $Id: $
  Purpose: Languageresources for the runtime package.
  History: 23/11/2004 Initial Release

           Quite a lot of changes since then 
}
{$Include SciCommonDef.Inc}
unit SciResLang;
interface
uses Graphics;
const
  CrLf=#13#10;
  CrLf2=#13#10#13#10;
  //Default colors
  cDefaultHotspotFore=clBlue;
  cDefaultHotspotBack=clDefault;
  cDefaultCaretFore=clBlack;
  cDefaultCaretBack=$eeeeee;
  cDefaultEdgeColor=clSilver;
  cDefaultSelectFore=clHighlightText;
  cDefaultSelectBack=clHighlight;
  cDefaultForeColor=clWindowText;
  cDefaultBackColor=clWindow;
  cDefaultMarkerFore=clBlue;
  cDefaultMarkerBack=clAqua;
  cDefaultFoldMarginHighlightColor=clBtnFace;
  cDefaultFoldMarginColor=clBtnFace;

resourcestring
//Errors
  eEditorPropertyNotAssigned='Editor property is not assigned for %s';
  eEditorIsNotTScintilla='Editor isn''t TScintilla or derived.';
  eConversionErrorMsg='Conversion error on line %d. Ignoring.';
  eCouldntLoadFromFile='Could''nt load from the file "%s"';
  eCouldntWriteToFile='Could''nt write to the file "%s"';
  eSciLexerNotFound='"SciLexer.DLL" wasn''t found. Please make sure is located on the System Path.'+CrLf+CrLf+'If you don''t have the file, you can obtain it precompiled at http://delphisci.sourceforge.net'+CrLf+'or you can go to http://www.scintilla.org and obtain the source there, and compile it yourself.';
  eObjectsNotSupportedForLines='Object handling functions/properties are not supported by the Lines property.'#13#10'It is merely an easy interface for setting/getting text from the scintilla control,'#13#10'and not a full TStrings object.';
  eNoStartOrEndCommentDefined='No Start or End comment style defined. See the Comment* properties for this language.';
  eNoStartMiddleOrEndCommentDefined='No Start/Middle or End comment style defined. See the Comment* properties for this language.';
  eNoOneLineCommentDefined='No one line comment style defined. See the Comment* properties for this language.';
  eCouldntCopyLangTo='Couldn''t copy %s to %s';
  eCouldntAddTheLanguage='Couldn''t add the language.';
  eCantRemoveLanguage='Can''t remove the container lexer/language';
  eCantCopyLanguage='Can''t copy the container lexer/language!';
  eErrorLineNotFollowed='Line %d ends with a ''\'' but isn''t followed by any line.';
  eTheseWhereTheErrors='These errors was found while processing "%s":'+CrLf2;
  eStreamClassUnassigned='No class is assigned to StreamClass.'+CrLf+'Assign a class derived from TSciStreamBase,'+CrLf+'or use the TSciStreamDefault class in SciStreamDefault.Pas.';
  eNoStreamer='The Streamer is nil.. Unassigned StreamClass property or Can''t create the class.'+CrLf+'Can''t use the Save* or Load* functions!';
  eNoLanguageManager='No LanguageManager is assigned. Aborted.';
// Common
  sError='Error';
  sConfirmation='Confirm';
  sTrue='True';
  sFalse='False';
  sYes='Yes';
  sUntitled = 'Untitled';
  sReload='The file has been changed by an external program, but you have unsaved changed.. '+CrLf+'Really reload "%s"?';
// ScintillaLanguageManager
  sLMKeywords='Keywords';
  sLMStyle='Style';
  sLMStyles='Styles';

// ScintillaLanguageManager, TSciPropertyMgr
  sLMLanguage='Language';

// SciConfirmReplaceDlg
  SAskReplaceText = 'Replace this occurence of "%s"?';


// EdOptionsWin
  sSetByCodeOnly='SET BY CODE ONLY!';
  sSeeTheHelp='See the help.';
  sNewStyle='New Style';
  sNewKeyList='New Key List';
  sCopyLanguageQueryTitle='Copy Language ''%s''';
  sNameOfNewLanguage='Name of the new language';

// sciKeyBindings

  sKeyNoCommand='No Command';
  sKeyClear='Clear';
  sKeyCopy='Copy';
  sKeyCut='Cut';
  sKeyPaste='Paste';
  sKeyZoomIn='Zoom in';
  sKeyZoomOut='Zoom out';
  sKeyZoomReset='Reset Zoom';
  sKeySelectAll='Select All';
  sKeyUndo='Undo';
  sKeyRedo='Redo';
  sKeyLineDown='Line Down';
  sKeyLineUp='Line Up';
  sKeyLineDownExtend='Line Down Extend';
  sKeyLineUpExtend='Line Up Extend';
  sKeyLineDownRectExtend='Line Down Rect Extend';
  sKeyLineUpRectExtend='Line Up Rect Extend';
  sKeyLineScrollDown='Line Scroll Down';
  sKeyLineScrollUp='Line Scroll Up';
  sKeyLineParaDown='Line Para Down';
  sKeyLineParaUp='Line Para Up';
  sKeyLineParaDownExtend='Line Para Down Extend';
  sKeyLineParaUpExtend='Line Para Up Extend';
  sKeyCharLeft='Char Left';
  sKeyCharRight='Char Right';
  sKeyCharLeftExtend='Char Left Extend';
  sKeyCharRightExtend='Char Right Extend';
  sKeyCharLeftRectExtend='Char Left Rect Extend';
  sKeyCharRightRectExtend='Char Right Rect Extend';
  sKeyWordLeft='Word Left';
  sKeyWordRight='Word Right';
  sKeyWordLeftExtend='Word Left Extend';
  sKeyWordRightExtend='Word Right Extend';
  sKeyWordLeftEnd='Word Left End';
  sKeyWordRightEnd='Word Right End';
  sKeyWordLeftEndExtend='Word Left End Extend';
  sKeyWordRightEndExtend='Word Right End Extend';
  sKeyWordPartLeft='Word Part Left';
  sKeyWordPartRight='Word Part Right';
  sKeyWordPartLeftExtend='Word Part Left Extend';
  sKeyWordPartRightExtend='Word Part Right Extend';
  sKeyHome='Home';
  sKeyHomeExtend='Home Extend';
  sKeyHomeRectExtend='Home Rect Extend';
  sKeyHomeDisplay='Home Display';
  sKeyHomeDisplayExtend='Home Display Extend';
  sKeyHomeWrap='Home Wrap';
  sKeyHomeWrapExtend='Home Wrap Extend';
  sKeyVCHome='VC Home';
  sKeyVCHomeExtend='VC Home Extend';
  sKeyVCHomeRectExtend='VC Home Rect Extend';
  sKeyVCHomeWrap='VC Home Wrap';
  sKeyVCHomeWrapExtend='VC Home Wrap Extend';
  sKeyLineEnd='Line End';
  sKeyLineEndExtend='Line End Extend';
  sKeyLineEndRectExtend='Line End Rect Extend';
  sKeyLineEndDisplay='Line End Display';
  sKeyLineEndDisplayExtend='Line End Display Extend';
  sKeyLineEndWrap='Line End Wrap';
  sKeyLineEndWrapExtend='Line End Wrap Extend';
  sKeyDocumentStart='Document Start';
  sKeyDocumentEnd='Document End';
  sKeyDocumentStartExtend='Document Start Extend';
  sKeyDocumentEndExtend='Document End Extend';
  sKeyPageUp='Page Up';
  sKeyPageUpExtend='Page Up Extend';
  sKeyPageUpRectExtend='Page Up Rect Extend';
  sKeyPageDown='Page Down';
  sKeyPageDownExtend='Page Down Extend';
  sKeyPageDownRectExtend='Page Down Rect Extend';
  sKeyStutteredPageUp='Stuttered Page Up';
  sKeyStutteredPageUpExtend='Stuttered Page Up Extend';
  sKeyStutteredPageDown='Stuttered Page Down';
  sKeyStutteredPageDownExtend='Stuttered Page Down Extend';
  sKeyDeleteBack='Delete Back';
  sKeyDeleteBackNotLine='Delete Back Not Line';
  sKeyDeleteWordLeft='Delete Word Left';
  sKeyDeleteWordRight='Delete Word Right';
  sKeyDeleteLineLeft='Delete Line Left';
  sKeyDeleteLineRight='Delete Line Right';
  sKeyDeleteLine='Delete Line';
  sKeyToggleSticky='Toggle Sticky Caret';
  sKeyLineCut='Line Cut';
  sKeyLineCopy='Line Copy';
  sKeyLineTranspose='Line Transpose';
  sKeyLineDuplicate='Line Duplicate';
  sKeyUpperCase='Upper Case';
  sKeyLowerCase='Lower Case';
  sKeyCancel='Cancel';
  sKeyToggleOvertype='Toggle Overtype';
  sKeyNewLine='New Line';
  sKeyFormFeed='Form Feed';
  sKeyTab='Tab';
  sKeyBackTab='Back Tab';
  sSelectionDuplicate='Duplicate Selection';
  sNoKey='No Key';

// sciPrint.pas
  sPageNo='Page %d';

//Properties
//spropLexerLibraryCategory='LexerLibraries';
  spropLexerLib='Lib';
  spropNot='not';
  spropStyle='style';
  spropFore='fore';
  spropBack='back';
  spropSize='size';
  spropFont='font';
  spropBold='bold';
  spropItalics='italics';
  spropUnderlined='underlined';
  spropVisible='visible';
  spropEolFilled='eolfilled';
  spropChangeable='changeable';
  spropHotspot='hotspot';
  spropCase='case';
  spropName='name';
  spropCommentBoxStart='CommentBoxStart';
  spropCommentBoxEnd='CommentBoxEnd';
  spropCommentBoxMiddle='CommentBoxMiddle';
  spropCommentBlock='CommentBlock';
  spropCommentStreamStart='CommentStreamStart';
  spropCommentStreamEnd='CommentStreamEnd';
  spropNumStyleBits='NumStyleBits';
  spropAssignmentOperator='AssignmentOperator';
  spropEndOfStatementOperator='EndOfStatementOperator';
  spropDefault='default';
  spropWordWrap='WordWrap';
  spropWordChars='WordChars';
  spropClearUndoAfterSave='ClearUndoAfterSave';
  spropCaretFore='CaretFore';
  spropCaretBack='CaretBack';
  spropCaretLineVisible='CaretLineVisible';
  spropCaretPeriod='CaretPeriod';
  spropCaretWidth='CaretWidth';
  spropCaretBackAlpha='CaretAlpha';
  spropEOLMode='EOLMode';
  spropSelectForeColor='SelectForeColor';
  spropSelectBackColor='SelectBackColor';
  spropMarkerForeColor='MarkerForeColor';
  spropMarkerBackColor='MarkerBackColor';
  spropFoldMarginHighlightColor='FoldMarginHighlightColor';
  spropFoldMarginColor='FoldMarginColor';
  spropActiveHotspotForeColor='ActiveHotspotForeColor';
  spropActiveHotspotBackColor='ActiveHotspotBackColor';
  spropActiveHotspotUnderlined='ActiveHotspotUnderlined';
  spropActiveHotspotSingleLine='ActiveHotspotSingleLine';
  spropGutter='Gutter';
  spropLineNumbers='LineNumbers';
  spropEdgeColumn='EdgeColumn';
  spropEdgeMode='EdgeMode';
  spropEdgeColor='EdgeColor';
  spropCodeFolding='CodeFolding';
  spropFoldMarkerType='FoldMarkerType';
  spropLexer='lexer';
  spropKeywords='keywords';
  spropOther='other';
  spropExtension='extension';
  spropEOLStyle='EOLStyle';
  spropWhiteSpaceFore='WhitespaceForeColor';
  spropWhiteSpaceBack='WhitespaceBackColor';
  sLang='Language: ';
  spropStyleBits='StyleBits';
  spropBraceHighlight='BraceHighlight';
  spropLexerPropertiesCategory='LexerProperties';
  spropSelectAlpha='SelectAlpha';
  spropPixMapFile='pixmapfile';
  spropMarkerType='markertype';
  spropMarkerAlpha='Alpha';
  spropMarkerFoldOpen='MarkerFoldOpen';
  spropMarkerFoldClosed='MarkerFoldClosed';
  spropMarkerFoldSub='MarkerFoldSub';
  spropMarkerFoldTail='MarkerFoldTail';
  spropMarkerFoldEnd='MarkerFoldEnd';
  spropMarkerFoldOpenMid='MarkerFoldOpenMid';
  spropMarkerFoldMidTail='MarkerFoldMidTail';
  spropMarkerBookMark='MarkerBookmark';
implementation
end.
Added src/delphisci/SciResLangDcl.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
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author: hdalis (hdalis@users.sourceforge.net)
     $Id: $
  Purpose: Languageresources for the designtime package.
  History: 23/11/2004 Initial Release

                      A lot has been added and changed in this file
                      since the last entry..

}
{$Include SciCommonDef.Inc}
unit SciResLangDcl;
interface

resourcestring
  //Errors
  eFailedToLoadStyles='Failed to load styles from %s. Using builtins..';
  eFailedToSaveStyles='Failed to save styles to %s.';
  //Messages
  scipropertyfilesfilter='Scintilla Style Files (*.Styles)|*.Styles';
  scipropertyfileloadtitle='Select Propertyfile to load';
  scipropertyfilesavetitle='Save to what Propertyfile?';
  scipropertyfiledefaultextension='properties';

  sciinformationheader='Information';
  scithelanguagelistofcontrol='The languagelist of the control [';
  sciiscleared='] is cleared.';

  ssciOptions='Options...';
  ssciSelectPredefinedLanguage='Select predefined Languages...';
  ssciClearLanguageList='Clear Languagelist';
  ssciLoadStylesFromPropertyFile='Load styles...';
  ssciSaveStylesToPropertyFile='Save styles...';
  sscikeycommands='KeyCommands';
  
implementation
end.
Added src/delphisci/SciSearchReplace.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
{$Include SciCommonDef.Inc}
unit SciSearchReplace;
{
 Unit    : SciSearchReplace
 Purpose : Search and Replace for TScintilla based on Synedit Dialogs
 Created : 20/03/2003
 Original Author  : Kiriakos Vlahos (kvlahos@london.edu)
 History : 29/09/2004 Initial Release with Delphi Scintilla Interface Components
                      Changed Editor property from TScintilla to TScintillaBase class.
                      Wasn't any need for the extra properties to use this dialog.
                      hdalis (hdalis@users.sourceforge.net)
           06/02/2005 Fixed a bug that caused the beginundoaction to be started,
                      but not finished.. i.e it treated all changes after a replace all
                      to belonging to the same undo operation..
                      hdalis (hdalis@users.sourceforge.net)
           15/02/2005 Somewhat fixed a bug which caused the component to hang when
                      search/replace for the regular expression '$'..
                      it became an endless loop..
                      if SelWord is true, we get the word under the caret as the searchword
                      instead of the need to select the word first.. If there isn't a word
                      under the caret, uses the previous searchtext if any..
                      hdalis (hdalis@users.sourceforge.net)
           27/06/2005 Moved most of the TSciSearchReplace class to the baseclass named TSciSearchReplaceBase
                      in the file SciSearchReplaceBase.
                      This is to add some flexibility when deriving new search components,
                      e.g if you want TBX dialogs instead of the usual, and so on.

}

interface
Uses
  Types, Classes, Controls, Forms, SciLexer,SciSearchReplaceBase;

Type
  TSciSearchReplace = class(TSciSearchReplaceBase)
  protected
    function ConfirmReplace(editorRect: TRect; X, Y1, Y2: Integer;AReplaceText: string) : TModalResult;override;
  public
    procedure ShowSearchDialog;override;
    procedure ShowReplaceDialog;override;
  end;

implementation

Uses
 SciSearchTextDlg, SciConfirmReplaceDlg, SciReplaceTextDlg, SciSupport,sciUtils,SysUtils;

{ TSciSearchReplace }
function TSciSearchReplace.ConfirmReplace(editorRect: TRect; X, Y1, Y2: Integer;AReplaceText: string) : TModalResult;
var
  ConfirmReplaceDlg : TConfirmReplaceDialog;
begin
  ConfirmReplaceDlg:=TConfirmReplaceDialog.Create(Application);
  if assigned(ConfirmReplaceDlg) then
  begin
    try
      ConfirmReplaceDlg.PrepareShow(editorRect, X, Y1,Y2, AReplaceText);
      Result:=ConfirmReplaceDlg.ShowModal;
    finally
      FreeAndNil(ConfirmReplaceDlg);
    end;
  end else
    Result:=mrCancel;
end;

procedure TSciSearchReplace.ShowSearchDialog;
var
  dlg: TTextSearchDialog;
  SelectedText : string;
begin
  if not Assigned(Editor) then Exit;
  dlg := TTextSearchDialog.Create(Self);
  FCurrentForm:=dlg;
  with dlg do
  try
    // assign search options
    SearchBackwards := Self.SearchBackwards;
    SearchCaseSensitive := Self.SearchCaseSensitive;
    SearchFromCursor := Self.SearchFromCaret;
    SearchInSelectionOnly := Self.SearchSelectionOnly;
    SelectedText := Editor.SelText;
    if (SelectedText <> '') and (Pos(#10, SelectedText) > 0) or (Pos(#13, SelectedText) > 0) then
      SearchInSelectionOnly := True
    else
      SearchInSelectionOnly := False;

    // start with last search text

    if SearchForSelWord and not SearchInSelectionOnly
    then
    begin
      if Editor.SelectionWord(True)<>'' then
        SearchText:=Editor.SelectionWord(True)
      else
        SearchText := Self.SearchText;
    end else
      SearchText := Self.SearchText;
    SearchTextHistory := Self.SearchTextHistory;
    SearchWholeWords := Self.SearchWholeWords;
    SearchRegularExpression:=Self.SearchRegex;
{$Ifdef ALLOWSEARCHPOPUPMENUS}
    if assigned(SearchPopupMenu) then
      dlg.cbSearchText.PopupMenu:=SearchPopupMenu;
{$Endif}
    DoBeforeShow;
    if ShowModal = mrOK then
    begin
      DoAfterShow;
      Self.SearchBackwards := SearchBackwards;
      Self.SearchCaseSensitive := SearchCaseSensitive;
      Self.SearchFromCaret := SearchFromCursor;
      Self.SearchSelectionOnly := SearchInSelectionOnly;
      Self.SearchWholeWords := SearchWholeWords;
      Self.SearchRegex := SearchRegularExpression;
      Self.SearchText := SearchText;
      Self.SearchTextHistory := SearchTextHistory;
      fSearchFromCaretInt := Self.SearchFromCaret;
      if SearchText <> '' then
      begin
        DoSearchReplaceText(False, Self.SearchBackwards);
        fSearchFromCaretInt := True;
      end;
      Self.SearchSelectionOnly := False;
    end;
  finally
    FCurrentForm:=nil;
    FreeAndNil(dlg);
  end;
end;

procedure TSciSearchReplace.ShowReplaceDialog;
var
  dlg: TTextReplaceDialog;
  SelectedText : string;
begin
  if not Assigned(Editor) then Exit;
    dlg := TTextReplaceDialog.Create(Self);
    FCurrentForm:=dlg;
  with dlg do
    try
      // assign search options
      SearchBackwards := Self.SearchBackwards;
      SearchCaseSensitive := Self.SearchCaseSensitive;
      SearchFromCursor := Self.SearchFromCaret;
      SearchInSelectionOnly := Self.SearchSelectionOnly;
      SelectedText := Editor.SelText;
      if (SelectedText <> '') and (Pos(#10, SelectedText) > 0) or (Pos(#13, SelectedText) > 0) then
        SearchInSelectionOnly := True
      else
        SearchInSelectionOnly := False;

      // start with last search text

      if SearchForSelWord and not SearchInSelectionOnly
      then
      begin
        if Editor.SelectionWord(True)<>'' then
          SearchText:=Editor.SelectionWord(True)
        else
          SearchText := Self.SearchText;
      end else
        SearchText := Self.SearchText;
      SearchTextHistory := Self.SearchTextHistory;
      ReplaceText := Self.ReplaceText;
      ReplaceTextHistory := Self.ReplaceTextHistory;
      SearchWholeWords := Self.SearchWholeWords;
      SearchRegularExpression:=Self.SearchRegex;
{$Ifdef ALLOWSEARCHPOPUPMENUS}
      if assigned(SearchPopupMenu) then
        dlg.cbSearchText.PopupMenu:=SearchPopupMenu;
      if assigned(ReplacePopupMenu) then
        dlg.cbReplaceText.PopupMenu:=ReplacePopupMenu;
{$Endif}
      DoBeforeShow;
      if ShowModal = mrOK then
      begin
        DoAfterShow;
        Self.SearchBackwards := SearchBackwards;
        Self.SearchCaseSensitive := SearchCaseSensitive;
        Self.SearchFromCaret := SearchFromCursor;
        Self.SearchSelectionOnly := SearchInSelectionOnly;
        Self.SearchWholeWords := SearchWholeWords;
        Self.SearchRegex := SearchRegularExpression;
        Self.SearchText := SearchText;
        Self.SearchTextHistory := SearchTextHistory;

        Self.ReplaceText := ReplaceText;
        Self.ReplaceTextHistory := ReplaceTextHistory;
        fSearchFromCaretInt := Self.SearchFromCaret;
        if SearchText <> '' then
        begin
          DoSearchReplaceText(True, Self.SearchBackwards);
          fSearchFromCaretInt := True;
        end;
        Self.SearchSelectionOnly := False;
      end;
    finally
      FCurrentForm:=nil;
      FreeAndNil(dlg);
    end;
end;

end.
Added src/delphisci/SciSearchReplaceBase.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
{$Include SciCommonDef.Inc}
unit SciSearchReplaceBase;
{
 Unit    : SciSearchReplaceBase
 Purpose : Baseclass for Search and Replace for TScintilla based on Synedit Dialogs
 Created : 20/03/2003
 Author  : hdalis
 History : 27/06/2005 Moved most of the TSciSearchReplace class to the baseclass named TSciSearchReplaceBase.
                      This is to add some flexibility when deriving new search components,
                      e.g if you want TBX dialogs instead of the usual, and so on.
           23/07/2005 Added support for UTF8, so the dialog handles the scintilla's
                      SC_CP_UTF8 correctly.. or so it seems anyway..
                      Don't know which version introduced the support for UTF8Encode/Decode etc, but I
                      have set it dependant on the HASUTFFUNCS define in SciCommonDef.Inc
           11/01/2006 Added the parameter 'Confirmation' to the DoSearchReplaceText as suggested by N.Metsovo

}

interface
Uses
  Types, Classes, Controls, Forms, SciLexer,Menus;

Type
  TReplaceConfirmType = (rctConfirm, rctReplace, rctReplaceAll);
  TSciSearchReplaceBase=class(TComponent)
  private
    FSearchForSelWord : boolean;
    FEditor : TScintillaBase;
    FFoundText : String;
    FOnTextFound : TNotifyEvent;
    FOnTextNotFound : TNotifyEvent;
    FOnTextReplaced : TNotifyEvent;
    FOnBeforeShow : TNotifyEvent;
    FOnAfterShow : TNotifyEvent;
{$Ifdef ALLOWSEARCHPOPUPMENUS}
    FReplacePopupMenu : TPopupMenu;
    FSearchPopupMenu : TPopupMenu;
{$Endif}
  protected
    FSearchFromCaretInt: boolean;
    FCurrentForm : TForm;

    procedure Notification(AComponent: TComponent;
                Operation: TOperation);  override;
    function ConfirmReplace(editorRect: TRect; X, Y1, Y2: Integer;AReplaceText: string) : TModalResult;virtual;abstract;
    procedure DoBeforeShow;virtual;
    procedure DoAfterShow;virtual;
  public
    // Search Options
    SearchBackwards: boolean;
    SearchCaseSensitive: boolean;
    SearchFromCaret: boolean;
    SearchSelectionOnly: boolean;
    SearchWholeWords: boolean;
    SearchRegex: boolean;
    SearchText: string;
    SearchTextHistory: string;
    ReplaceText: string;
    ReplaceTextHistory: string;
    ReplacedCount : Integer;

    constructor Create(AOwner : TComponent);override;
    procedure DoSearchReplaceText(AReplace, ABackwards: boolean;Confirmation : TReplaceConfirmType=rctConfirm);virtual;
    procedure ShowSearchDialog;virtual;
    procedure ShowReplaceDialog;virtual;
    property FoundText : string read fFoundText;
    property CurrentForm : TForm read FCurrentForm;
  published
    property SearchForSelWord : boolean read FSearchForSelWord write FSearchForSelWord;
    property Editor : TScintillaBase read FEditor write FEditor;
    property OnTextFound : TNotifyEvent read FOnTextFound write FOnTextFound;
    property OnTextNotFound : TNotifyEvent read FOnTextNotFound write FOnTextNotFound;
    property OnTextReplaced : TNotifyEvent read FOnTextReplaced write FOnTextReplaced;
    property BeforeShow : TNotifyEvent read FOnBeforeShow write FOnBeforeShow;
    property AfterShow : TNotifyEvent read FOnAfterShow write FOnAfterShow;
{$Ifdef ALLOWSEARCHPOPUPMENUS}
    property ReplacePopupMenu : TPopupMenu read FReplacePopupMenu write FReplacePopupMenu;
    property SearchPopupMenu : TPopupMenu read FSearchPopupMenu write FSearchPopupMenu;
{$Endif}
  end;

implementation

Uses
 SciSupport,sciUtils,SysUtils;

{ TSciSearchReplace }
constructor TSciSearchReplaceBase.Create(AOwner : TComponent);
begin
  ReplacedCount:=0;
  SearchFromCaret:=True;
  FCurrentForm:=nil;
  Inherited;
end;

procedure TSciSearchReplaceBase.Notification(AComponent: TComponent;
  Operation: TOperation);
begin
  inherited;
  if Operation=opRemove then
  begin
    if (AComponent = FEditor) then FEditor := nil;
{$Ifdef ALLOWSEARCHPOPUPMENUS}
    if (AComponent = FReplacePopupMenu) then FReplacePopupMenu := nil;
    if (AComponent = FSearchPopupMenu) then FSearchPopupMenu := nil;
{$Endif}
  end;
end;

procedure TSciSearchReplaceBase.ShowSearchDialog;
begin
  //
end;
procedure TSciSearchReplaceBase.ShowReplaceDialog;
begin
  //
end;

procedure TSciSearchReplaceBase.DoBeforeShow;
begin
  if assigned(FOnBeforeShow) then
    FOnBeforeShow(Self);
end;
procedure TSciSearchReplaceBase.DoAfterShow;
begin
  if assigned(FOnAfterShow) then
    FOnAfterShow(Self);
end;

procedure TSciSearchReplaceBase.DoSearchReplaceText(AReplace, ABackwards: boolean;Confirmation : TReplaceConfirmType);
var
  Options: Integer;
  StartPosition, EndPosition : Integer;
  TargetStart, TargetEnd, posFind : Integer;
  APos: TPoint;
  EditRect: TRect;
  DlgRes : Integer;
  lastMatch,lenTarget,MovePastEOL : Integer;
  chNext : Integer;
  findLen : Integer;
  LenFound, LenReplaced : Integer;
  doendundo : Boolean;
{$ifdef HASUTFFUNCS}
  UsesUtf8 : Boolean;
  UtfReplaceText,UtfSearchText : String;
{$Endif}
begin
  doendundo:=false;
  if not Assigned(FEditor) then Exit;
  Options := 0;
  if SearchCaseSensitive then
    Options := Options or SCFIND_MATCHCASE;
  if SearchWholeWords then
    Options := Options or SCFIND_WHOLEWORD;
  if SearchRegex then
    Options := Options or SCFIND_REGEXP;
  if SearchText='' then Exit;
{$ifdef HASUTFFUNCS}
  UsesUtf8:=(FEditor.GetCodePage=SC_CP_UTF8);
  if UsesUtf8 then
  begin
    UtfSearchText:=AnsiToUTF8(SearchText);
    UtfReplaceText:=AnsiToUTF8(ReplaceText);
  end;
{$Endif}
  if ABackwards then
  begin
    if fSearchFromCaretInt and not SearchSelectionOnly then
      StartPosition := FEditor.GetSelectionStart - 1
    else if SearchSelectionOnly then
      StartPosition := FEditor.GetSelectionEnd
    else
      StartPosition := FEditor.GetLength;
    if SearchSelectionOnly then
      EndPosition := FEditor.GetSelectionStart
    else
      EndPosition := 0;
  end else
  begin
    if fSearchFromCaretInt and not SearchSelectionOnly then
      StartPosition := FEditor.GetSelectionEnd + 1
    else if SearchSelectionOnly then
      StartPosition := FEditor.GetSelectionStart
    else
      StartPosition := 0;
    if SearchSelectionOnly then
      EndPosition := FEditor.GetSelectionEnd
    else
      EndPosition := FEditor.GetLength;
  end;
{$ifdef HASUTFFUNCS}
  if UsesUtf8 then
    findLen:=Length(UtfSearchText)
  else
{$Endif}
  findLen:=Length(SearchText);

  with FEditor do
  begin
    SetTargetStart(StartPosition);
    SetTargetEnd(EndPosition);
    SetSearchFlags(Options);
{$ifdef HASUTFFUNCS}
    if UsesUtf8 then
      posFind := SearchInTarget(findLen, PChar(UtfSearchText))
    else
{$Endif}
      posFind := SearchInTarget(findLen, PChar(SearchText));
    if (posFind < 0) then
    begin
      if Assigned(FOnTextNotFound) then
        FOnTextNotFound(Self);
    end else
    begin
      lastMatch:=posFind;
      TargetStart := GetTargetStart;
      TargetEnd := GetTargetEnd;
      LenFound := TargetEnd - TargetStart;
      LenReplaced := LenFound;
      EnsureRangeVisible(TargetStart, TargetEnd);
      SetSel(TargetStart, TargetEnd);
{$ifdef HASUTFFUNCS}
    if UsesUtf8 then
      FFoundText := UTF8ToAnsi(FEditor.SelText)
    else
{$Endif}
      FFoundText := FEditor.SelText;
      if Assigned(FOnTextFound) then
        FOnTextFound(Self);

      // Replace code
      if AReplace then
      begin
        DlgRes := mrYes;

        ReplacedCount:=0;
        while (posFind >= 0) and (DlgRes <> mrCancel) do
        begin
          lenTarget:=GetTargetEnd-GetTargetStart;
          movePastEOL:=0;
          if lenTarget<=0 then
          begin
            chNext:=GetCharAt(GetTargetEnd);
            if (chNext=10) or (chNext=13) then MovePastEOL:=1;
          end;
          if not (DlgRes = mrYesToAll) then
          begin
            if Confirmation=rctConfirm then
            begin
              APos := Point(PointXFromPosition(TargetStart), PointYFromPosition(TargetStart));
              APos := ClientToScreen(APos);
              EditRect := FEditor.ClientRect;
              EditRect.TopLeft := ClientToScreen(EditRect.TopLeft);
              EditRect.BottomRight := ClientToScreen(EditRect.BottomRight);
              DlgRes:=ConfirmReplace(EditRect, APos.X, APos.Y,APos.Y + 2 * FEditor.TextHeight(LineFromPosition(TargetStart)), SearchText);
            end else
            case Confirmation of
              rctReplace: DlgRes:=mrYes;
              rctReplaceAll: DlgRes:=mrYesToAll;
            end;
            if (DlgRes = mrYesToAll) and (doendundo=false) then
            begin
              FEditor.BeginUndoAction;
              doendundo:=True;
            end;
          end;


          if DlgRes in [mrYes, mrYesToAll] then
          begin
            // Replace
{$ifdef HASUTFFUNCS}
            if UsesUtf8 then
            begin
              if SearchRegex then
                LenReplaced := ReplaceTargetRE(Length(UtfReplaceText), PChar(UtfReplaceText))
              else
                LenReplaced := ReplaceTarget(Length(UtfReplaceText), PChar(UtfReplaceText));
            end else
            begin
{$Endif}
            if SearchRegex then
              LenReplaced := ReplaceTargetRE(Length(ReplaceText), PChar(ReplaceText))
            else
              LenReplaced := ReplaceTarget(Length(ReplaceText), PChar(ReplaceText));
{$ifdef HASUTFFUNCS}
end;
{$Endif}
            Inc(ReplacedCount);

            lastMatch:=posFind + lenReplaced + movepastEOL;
            if lenTarget=0 then
            lastMatch:=PositionAfter(lastMatch);

            TargetEnd := TargetStart + LenReplaced -1+movePastEOL;
            if Assigned(FOnTextReplaced) then FOnTextReplaced(Self);
          end;
          if DlgRes in [mrYes, mrNo, mrYesToAll] then
          begin
            // carry on
            if lastMatch>=endPosition then
            begin
              posFind:=-1;
            end else
            begin
              if ABackwards then
              begin
                SetTargetStart(TargetStart - 1);
                SetTargetEnd(EndPosition);
              end else
              begin
                SetTargetStart(TargetEnd + 1);
                EndPosition := EndPosition + LenReplaced - LenFound;
                SetTargetEnd(EndPosition);
              end;
              SetTargetEnd(EndPosition);
              SetSearchFlags(Options);
{$ifdef HASUTFFUNCS}
            if UsesUtf8 then
              posFind := SearchInTarget(Length(UtfSearchText), PChar(UtfSearchText))
            else
{$Endif}
              posFind := SearchInTarget(Length(SearchText), PChar(SearchText));
            end;
            if posFind >= 0 then
            begin
              TargetStart := GetTargetStart;
              TargetEnd := GetTargetEnd;
              lastMatch:=TargetStart;
              LenFound := TargetEnd - TargetStart;
              LenReplaced := LenFound;
              EnsureRangeVisible(TargetStart, TargetEnd);
              SetSel(TargetStart, TargetEnd);
            end;
          end else
            break;
        end;   // While
        if doendundo then
          FEditor.EndUndoAction;

        // Restore original selection if Searching in Selection
        if SearchSelectionOnly then
        begin
          if ABackwards then
            SetSel(EndPosition, StartPosition)
          else
            SetSel(StartPosition, EndPosition);
          EnsureRangeVisible(GetSelectionStart, GetSelectionEnd);
        end;
      end;  // if AReplace
    end;  //if (posFind < 0)
  end; // with FEditor
end;

end.
Added src/delphisci/SciSearchTextDlg.ddp.

cannot compute difference between binary files

Added src/delphisci/SciSearchTextDlg.dfm.






































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
object TextSearchDialog: TTextSearchDialog
  Left = 563
  Top = 550
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  Caption = 'Search for Text'
  ClientHeight = 180
  ClientWidth = 338
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBtnText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  Position = poOwnerFormCenter
  OnCloseQuery = FormCloseQuery
  PixelsPerInch = 96
  TextHeight = 13
  object BasePanel: TPanel
    Left = 0
    Top = 0
    Width = 338
    Height = 180
    Align = alClient
    BevelOuter = bvNone
    TabOrder = 0
    object Label1: TLabel
      Left = 21
      Top = 12
      Width = 52
      Height = 13
      Caption = '&Search for:'
    end
    object cbSearchText: TComboBox
      Left = 73
      Top = 8
      Width = 260
      Height = 21
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Sans Serif'
      Font.Style = []
      ItemHeight = 13
      ParentFont = False
      TabOrder = 0
    end
    object gbSearchOptions: TGroupBox
      Left = 8
      Top = 40
      Width = 154
      Height = 129
      Caption = 'Options'
      TabOrder = 1
      object cbSearchCaseSensitive: TCheckBox
        Left = 8
        Top = 17
        Width = 140
        Height = 17
        Caption = 'C&ase sensitivity'
        TabOrder = 0
      end
      object cbSearchWholeWords: TCheckBox
        Left = 8
        Top = 39
        Width = 140
        Height = 17
        Caption = '&Whole words only'
        TabOrder = 1
      end
      object cbSearchFromCursor: TCheckBox
        Left = 8
        Top = 61
        Width = 140
        Height = 17
        Caption = 'Searc&h from caret'
        Checked = True
        State = cbChecked
        TabOrder = 2
      end
      object cbSearchSelectedOnly: TCheckBox
        Left = 8
        Top = 83
        Width = 140
        Height = 17
        Caption = '&Selected text only'
        TabOrder = 3
      end
      object cbRegularExpression: TCheckBox
        Left = 8
        Top = 104
        Width = 140
        Height = 17
        Caption = 'R&egular expression'
        TabOrder = 4
        OnClick = cbRegularExpressionClick
      end
    end
    object rgSearchDirection: TRadioGroup
      Left = 170
      Top = 40
      Width = 154
      Height = 65
      Caption = 'Direction'
      ItemIndex = 0
      Items.Strings = (
        'F&orward'
        '&Backward')
      TabOrder = 2
    end
    object btnOK: TBitBtn
      Left = 170
      Top = 146
      Width = 75
      Height = 23
      Hint = 'Start search'
      Caption = '&Find'
      Default = True
      ModalResult = 1
      ParentShowHint = False
      ShowHint = True
      TabOrder = 3
      Glyph.Data = {
        F6000000424DF600000000000000760000002800000010000000100000000100
        04000000000080000000CE0E0000C40E00001000000000000000000000000000
        80000080000000808000800000008000800080800000C0C0C000808080000000
        FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00777777777777
        7777777777777777777700000777770000070F000777770F00070F000777770F
        0007000000070000000700F000000F00000700F000700F00000700F000700F00
        00077000000000000077770F00070F0007777700000700000777777000777000
        77777770F07770F0777777700077700077777777777777777777}
    end
    object btnCancel: TBitBtn
      Left = 249
      Top = 146
      Width = 75
      Height = 23
      Hint = 'Cancel search'
      Caption = '&Cancel'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 4
      Kind = bkCancel
    end
  end
end
Added src/delphisci/SciSearchTextDlg.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
{-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is: dlgSearchText.pas, released 2000-06-23.

The Original Code is part of the SearchReplaceDemo project, written by
Michael Hieke for the SynEdit component suite.
All Rights Reserved.

Contributors to the SynEdit project are listed in the Contributors.txt file.

Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.

$Id: SciSearchTextDlg.pas,v 1.4 2004/11/13 04:29:50 hdalis Exp $

You may retrieve the latest version of this file at the SynEdit home page,
located at http://SynEdit.SourceForge.net

Known Issues:
-------------------------------------------------------------------------------}
{
  History:   29/09/2004 Initial Release with Delphi Scintilla Interface Components
                        Removed Dialogs and Graphics from the uses list.
}

{$Include SciCommonDef.Inc}
unit SciSearchTextDlg;
interface
uses
  Windows, Messages, SysUtils, Classes, Controls, Forms,
  StdCtrls, ExtCtrls, Buttons;//Dialogs,Graphics,

type
  TTextSearchDialog = class(TForm)
    BasePanel: TPanel;
    Label1: TLabel;
    cbSearchText: TComboBox;
    gbSearchOptions: TGroupBox;
    cbSearchCaseSensitive: TCheckBox;
    cbSearchWholeWords: TCheckBox;
    cbSearchFromCursor: TCheckBox;
    cbSearchSelectedOnly: TCheckBox;
    cbRegularExpression: TCheckBox;
    rgSearchDirection: TRadioGroup;
    btnOK: TBitBtn;
    btnCancel: TBitBtn;
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
    procedure cbRegularExpressionClick(Sender: TObject);
  private
    function GetSearchBackwards: boolean;
    function GetSearchCaseSensitive: boolean;
    function GetSearchFromCursor: boolean;
    function GetSearchInSelection: boolean;
    function GetSearchText: string;
    function GetSearchTextHistory: string;
    function GetSearchWholeWords: boolean;
    procedure SetSearchBackwards(Value: boolean);
    procedure SetSearchCaseSensitive(Value: boolean);
    procedure SetSearchFromCursor(Value: boolean);
    procedure SetSearchInSelection(Value: boolean);
    procedure SetSearchText(Value: string);
    procedure SetSearchTextHistory(Value: string);
    procedure SetSearchWholeWords(Value: boolean);
    procedure SetSearchRegularExpression(const Value: boolean);
    function GetSearchRegularExpression: boolean;
  public
    property SearchBackwards: boolean read GetSearchBackwards
      write SetSearchBackwards;
    property SearchCaseSensitive: boolean read GetSearchCaseSensitive
      write SetSearchCaseSensitive;
    property SearchFromCursor: boolean read GetSearchFromCursor
      write SetSearchFromCursor;
    property SearchInSelectionOnly: boolean read GetSearchInSelection
      write SetSearchInSelection;
    property SearchText: string read GetSearchText write SetSearchText;
    property SearchTextHistory: string read GetSearchTextHistory
      write SetSearchTextHistory;
    property SearchWholeWords: boolean read GetSearchWholeWords
      write SetSearchWholeWords;
    property SearchRegularExpression: boolean read GetSearchRegularExpression
      write SetSearchRegularExpression;
  end;

implementation

{$R *.DFM}
uses SciResLang;
{ TTextSearchDialog }

function TTextSearchDialog.GetSearchBackwards: boolean;
begin
  Result := rgSearchDirection.ItemIndex = 1;
end;

function TTextSearchDialog.GetSearchCaseSensitive: boolean;
begin
  Result := cbSearchCaseSensitive.Checked;
end;

function TTextSearchDialog.GetSearchFromCursor: boolean;
begin
  Result := cbSearchFromCursor.Checked;
end;

function TTextSearchDialog.GetSearchInSelection: boolean;
begin
  Result := cbSearchSelectedOnly.Checked;
end;

function TTextSearchDialog.GetSearchRegularExpression: boolean;
begin
  Result := cbRegularExpression.Checked;
end;

function TTextSearchDialog.GetSearchText: string;
begin
  Result := cbSearchText.Text;
end;

function TTextSearchDialog.GetSearchTextHistory: string;
var
  i: Integer;
begin
  Result := '';
  for i := 0 to cbSearchText.Items.Count - 1 do begin
    if i >= 10 then
      break;
    if i > 0 then
      Result := Result + CrLf;
    Result := Result + cbSearchText.Items[i];
  end;
end;

function TTextSearchDialog.GetSearchWholeWords: boolean;
begin
  Result := cbSearchWholeWords.Checked;
end;

procedure TTextSearchDialog.SetSearchBackwards(Value: boolean);
begin
  rgSearchDirection.ItemIndex := Ord(Value);
end;

procedure TTextSearchDialog.SetSearchCaseSensitive(Value: boolean);
begin
  cbSearchCaseSensitive.Checked := Value;
end;

procedure TTextSearchDialog.SetSearchFromCursor(Value: boolean);
begin
  cbSearchFromCursor.Checked := Value;
end;

procedure TTextSearchDialog.SetSearchInSelection(Value: boolean);
begin
  cbSearchSelectedOnly.Checked := Value;
end;

procedure TTextSearchDialog.SetSearchText(Value: string);
begin
  cbSearchText.Text := Value;
end;

procedure TTextSearchDialog.SetSearchTextHistory(Value: string);
begin
  cbSearchText.Items.Text := Value;
end;

procedure TTextSearchDialog.SetSearchWholeWords(Value: boolean);
begin
  cbSearchWholeWords.Checked := Value;
end;

procedure TTextSearchDialog.SetSearchRegularExpression(
  const Value: boolean);
begin
  cbRegularExpression.Checked := Value;
end;

{ event handlers }

procedure TTextSearchDialog.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
var
  s: string;
  i: Integer;
begin
  if ModalResult = mrOK then
  begin
    s := cbSearchText.Text;
    if s <> '' then
    begin
      i := cbSearchText.Items.IndexOf(s);
      if i > -1 then
      begin
        cbSearchText.Items.Delete(i);
        cbSearchText.Items.Insert(0, s);
        cbSearchText.Text := s;
      end else
        cbSearchText.Items.Insert(0, s);
    end;
  end;
end;

procedure TTextSearchDialog.cbRegularExpressionClick(Sender: TObject);
begin
  if cbRegularExpression.Checked then rgSearchDirection.ItemIndex := 0;
end;

end.

Added src/delphisci/SciStreamDefault.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
126
127
128
129
unit SciStreamDefault;
interface
uses Classes,SciLexer;
type
  TSciStreamDefault=class(TSciStreamBase)
  public
    {
     This is called from TScintillaBase.SaveToStream
    }
    procedure SaveToStream(Stream : TStream);override;
    {
     This is called from TScintillaBase.LoadFromStream
    }
    procedure LoadFromStream(Stream : TStream);override;
    {
     This can optionally return some integer data, such as the encodingmode for the last file loaded.
    }
    function GetData : Integer;override;
    {
     This can optionally set some integer data, such as the encodingmode to use when saving.
     Returns 0 in this implementation.
    }
    procedure SetData(Value : Integer);override;
    {
     This can optionally return some string data, such as the encodingmode for the last file loaded.
     Returns an empty string in this implementation.
    }
    function GetDataStr : String;override;
    {
     This can optionally set some string data, such as the encodingmode to use when saving.
     NOOP in this implementation.
    }
    procedure SetDataStr(const Value : String);override;
  end;

implementation
uses SciSupport,Math;

const bufSize = 524288;

procedure TSciStreamDefault.SaveToStream(Stream : TStream);
var
  OldCodePage : Integer;
  buf : array[0..bufSize+1] of Char;
  docLen,i : LongInt;
  grabSize : LongInt;
  rng : TTextRange;
begin
  if not assigned(Stream) then Exit;
  with FEditor do
  begin
    OldCodePage := CodePage;
    if OldCodePage=SC_CP_UTF8 then
    begin
      CodePage:=SC_CHARSET_ANSI;
    end;
      i:=0;
      docLen:=GetLength;
      if docLen=0 then Exit;
      while i<docLen do
      begin
        grabSize:=docLen-i;
        if grabSize>bufSize then
          grabSize:=bufSize;
        rng.chrg.cpMin:=i;
        rng.chrg.cpMax:=i+grabSize;
        rng.lpstrText:=@buf;
        GetTextRange(@rng);
        Stream.Write(buf,grabSize);
        Inc(i,grabSize);
      end;
    if OldCodePage=SC_CP_UTF8 then CodePage:=SC_CP_UTF8;
  end;
end;

procedure TSciStreamDefault.LoadFromStream(Stream : TStream);
var
  buf : array[0..bufSize+1] of Char;
  OldCodePage : Integer;
  numrd : Integer;
  siz : LongInt;
begin
  if not assigned(Stream) then Exit;
  with FEditor do
  begin
    OldCodePage :=CodePage;
    if OldCodePage=SC_CP_UTF8 then
    begin
      CodePage:=SC_CHARSET_ANSI;
    end;
    siz:=Stream.Size;
    numrd:=Stream.Read(buf,Min(siz,bufSize));
    while (numrd>0) do
    begin
      AddText(numrd,buf);
      numrd:=Stream.Read(buf,Min(siz,bufSize));
      Dec(siz,numrd);
    end;
    if OldCodePage=SC_CP_UTF8 then CodePage := SC_CP_UTF8;
  end;
end;

function TSciStreamDefault.GetData : Integer;
begin
  //This function can (in derived classes) optionally be
  //used to return any data you want stored into
  //TSciDoc.StreamExtra, or wherever else if you wish..
  //example: the loaded fileformat, utf16le?
  //Remember to cast whatever type you have to an integer
  Result:=0;
end;
procedure TSciStreamDefault.SetData(Value : Integer);
begin
  //This function can (in derived classes) optionally be
  //used to set some data you want to pass to the class.
  //example: Change the encodingmode we should store a file in,
  //if the class supports multiple storageformats.
end;
function TSciStreamDefault.GetDataStr : String;
begin
  //Same as above, just for strings.
end;
procedure TSciStreamDefault.SetDataStr(const Value : String);
begin
  //Same as above, just for strings.
end;

end.
 
Added src/delphisci/SciStyleLoader.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
  Created: 04/08/2005
  History: 04/08/2005 Initial Release

     TODO:Separate the functions/operations similar between TSciStyleLoader, and TSciPropertyLoader
          into a separate class. As it is now, quite a few of the operations is
          equal, or nearly equal in operation. This just consentrates on the
          styles and nothing else.
}
{$Include SciCommonDef.Inc}
unit SciStyleLoader;
interface
uses  Classes,SciLexer,SciLexerMemo,SciLexerMod,Graphics,ScintillaLanguageManager;

type
  //Maintains colors and such when we only have a LanguageManager, and not any Editor.
  TSciColorsRec=class(TPersistent)
  public
    CaretForeColor : TColor;
    CaretLineBackColor : TColor;
    CaretLineBackAlpha : Integer;
    CaretLineVisible : Boolean;
    CaretWidth : LongInt;
    CaretPeriod : LongInt;
    HotSpotBackColor : TColor;
    HotSpotForeColor : TColor;
    HotSpotUnderlined : Boolean;
    HotSpotSingleLine : Boolean;
    SelFore : TColor;
    SelBack : TColor;
    SelAlpha : Integer;
    MarkerFore : TColor;
    MarkerBack : TColor;
    FoldHi : TColor;
    FoldLo : TColor;
    EdgeMode : sciEdgeType;
    EdgeColumn : LongInt;
    EdgeColor : TColor;

    procedure Assign(Source: TPersistent); override;
    procedure AssignTo(Dest: TPersistent); override;
  end;

  TSciStylesLoader=class(TObject)
    private
      fLoadingErrors : TStrings;
      fDefaultStyle : TSciLangStyle;
      fEditor : TScintilla;
      fEditorSetManually : Boolean;
      fManager : TSciLanguageManager;
      fOnStylesLoaded : TNotifyEvent;
      FColors : TSciColorsRec;
      procedure SetEditor(Value : TScintilla);
      procedure SetManager(Value : TSciLanguageManager);
      function  GetDefaultStyle : TSciLangStyle;
    protected
      procedure FillWithDefaultStyle(var sty : TSciLangStyle);
      procedure GenerateDefaultPropLine(var dest : String;component : TScintillaBase);
      function GenerateMarkerLine(Marker : TSciMarker) : String;
      procedure GenerateStylePropLine(var dest : String;const prefix : String;const styl : TSciStyle);
      procedure GenerateKwdPropLine(var dest : String;const prefix : String;const kwd : TSciKeywords);
      function  PropLineSplit(const s: String;var stylenum : Integer;var prop : String;var value : String) : Boolean;
      function  ParseStyleDefinition(const definition : PChar;var sty : TSciLangStyle;defstyle : Boolean=False) : Boolean;
      function  ParseMarkerDefinition(const definition : PChar;Marker : TSciMarker) : Boolean;
    public
      constructor Create;
      destructor Destroy;override;
      function LoadStylesFromStream(fs : TStream) : Boolean;
      function SaveStylesToStream(fs : TStream) : Boolean;
      function SaveStyles(const filename : String) : Boolean;
      function LoadStyles(const filename : String): Boolean;

      property LoadingErrors : TStrings read fLoadingErrors;
      property DefaultStyle : TSciLangStyle read GetDefaultStyle;
      property Editor : TScintilla read FEditor write SetEditor;
      property LanguageManager : TSciLanguageManager read FManager write SetManager;
      property Colors : TSciColorsRec read FColors;
      property OnStylesLoaded : TNotifyEvent read fOnStylesLoaded write fOnStylesLoaded;
  end;

implementation
uses
  Windows,SysUtils,SciResLang,sciUtils,SciSupport;

procedure TSciColorsRec.AssignTo(Dest: TPersistent);
var
  dst : TScintilla;
begin
  if Dest is TScintilla then
  begin
    dst:=TScintilla(Dest);
    dst.Caret.ForeColor:=CaretForeColor;
    dst.Caret.LineBackColor:=CaretLineBackColor;
    dst.Caret.LineBackAlpha:=CaretLineBackAlpha;
    dst.Caret.LineVisible:=CaretLineVisible;
    dst.Caret.Width:=CaretWidth;
    dst.Caret.Period:=CaretPeriod;
    dst.ActiveHotSpot.BackColor:=HotSpotBackColor;
    dst.ActiveHotSpot.ForeColor:=HotSpotForeColor;
    dst.ActiveHotSpot.Underlined:=HotSpotUnderlined;
    dst.ActiveHotSpot.SingleLine:=HotSpotSingleLine;
    dst.Colors.SelFore:=SelFore;
    dst.Colors.SelBack:=SelBack;
    dst.Colors.SelAlpha:=SelAlpha;
    dst.Colors.MarkerFore:=MarkerFore;
    dst.Colors.MarkerBack:=MarkerBack;
    dst.Colors.FoldHi:=FoldHi;
    dst.Colors.FoldLo:=FoldLo;
    dst.EdgeMode:=EdgeMode;
    dst.EdgeColumn:=EdgeColumn;
    dst.EdgeColor:=EdgeColor;
  end else
    inherited;
end;
procedure TSciColorsRec.Assign(Source: TPersistent);
begin
  if Source is TSciColorsRec then
  begin
    CaretForeColor:=TSciColorsRec(Source).CaretForeColor;
    CaretLineBackColor:=TSciColorsRec(Source).CaretLineBackColor;
    CaretLineBackAlpha:=TSciColorsRec(Source).CaretLineBackAlpha;
    CaretLineVisible:=TSciColorsRec(Source).CaretLineVisible;
    CaretWidth:=TSciColorsRec(Source).CaretWidth;
    CaretPeriod:=TSciColorsRec(Source).CaretPeriod;
    HotSpotBackColor:=TSciColorsRec(Source).HotSpotBackColor;
    HotSpotForeColor:=TSciColorsRec(Source).HotSpotForeColor;
    HotSpotUnderlined:=TSciColorsRec(Source).HotSpotUnderlined;
    HotSpotSingleLine:=TSciColorsRec(Source).HotSpotSingleLine;
    SelFore:=TSciColorsRec(Source).SelFore;
    SelBack:=TSciColorsRec(Source).SelBack;
    SelAlpha:=TSciColorsRec(Source).SelAlpha;
    MarkerFore:=TSciColorsRec(Source).MarkerFore;
    MarkerBack:=TSciColorsRec(Source).MarkerBack;
    FoldHi:=TSciColorsRec(Source).FoldHi;
    FoldLo:=TSciColorsRec(Source).FoldLo;
    EdgeMode:=TSciColorsRec(Source).EdgeMode;
    EdgeColumn:=TSciColorsRec(Source).EdgeColumn;
    EdgeColor:=TSciColorsRec(Source).EdgeColor;
  end;
  inherited;
end;

constructor TSciStylesLoader.Create;
begin
  inherited;
  fEditor:=nil;
  fEditorSetManually:=False;
  fManager:=nil;
  fDefaultStyle.EOLFilled:=False;
  fDefaultStyle.Visible:=True;
  fDefaultStyle.CharCase:=CASE_MIXED;
  fDefaultStyle.Changeable:=True;
  fDefaultStyle.Hotspot:=False;
  fDefaultStyle.FontStyles:=[];
  fDefaultStyle.FontName:='';
  fDefaultStyle.FontSize:=0;
  fDefaultStyle.ForeColor:=clDefault;
  fDefaultStyle.BackColor:=clDefault;
  fColors:=TSciColorsRec.Create;
  fLoadingErrors:=TMyStringList.Create;
end;

function  TSciStylesLoader.GetDefaultStyle : TSciLangStyle;
begin
  Result:=fDefaultStyle;
end;
destructor  TSciStylesLoader.Destroy;
begin
  if assigned(fLoadingErrors) then FreeAndNil(fLoadingErrors);
  if assigned(fColors) then FreeAndNil(fColors);
  inherited;
end;
procedure TSciStylesLoader.SetEditor(Value : TScintilla);
begin
  fEditor:=Value;
  fEditorSetManually:=True;
end;
procedure TSciStylesLoader.SetManager(Value : TSciLanguageManager);
begin
  FManager:=Value;
  //Set the editor property if the languagemanager has a TScintilla owner, and
  //the Editor property wasn't set by other.
  if ((not assigned(fEditor)) or (fEditorSetManually=False)) and (FManager.Owner is TScintilla) then
  begin
    fEditor:=TScintilla(FManager.Owner);
    fEditorSetManually:=False;
  end;
end;

// Quite a bit of multiple instances of the same code maybe, but temporary
// Generates a string with the default color and font settings.
// Does NOT support the EOLFilled etc attributes.
procedure TSciStylesLoader.GenerateDefaultPropLine(var dest : String;component : TScintillaBase);
var
  tmpstr : String;
begin
  tmpstr:=spropStyle+'=';
  tmpstr:=tmpstr+spropFore+':'+ColourToString(component.Font.Color)+',';//fore
  tmpstr:=tmpstr+spropBack+':'+ColourToString(component.Color)+',';//back
  tmpstr:=tmpstr+Format('%s:%d',[spropsize,component.Font.Size])+',';//size
  tmpstr:=tmpstr+spropFont+':'+component.Font.Name+',';//font
  if fsBold in component.Font.Style then
    tmpstr:=tmpstr+spropBold+','//bold
  else
    tmpstr:=tmpstr+spropNot+spropBold+',';//notbold
  if fsItalic in component.Font.Style then
    tmpstr:=tmpstr+spropItalics+',' //italics
  else
    tmpstr:=tmpstr+spropNot+spropItalics+',';//notitalics

  if fsUnderline in component.Font.Style then
    tmpstr:=tmpstr+spropUnderlined+','//underlined
  else
    tmpstr:=tmpstr+spropNot+spropUnderlined+',';//notunderlined
  if fDefaultStyle.Visible=false  then
    tmpstr:=tmpstr+spropNot+spropVisible+',' //notvisible
  else
    tmpstr:=tmpstr+spropVisible+',';//visible
  if fDefaultStyle.EOLFilled  then
    tmpstr:=tmpstr+spropEolFilled+','//eolfilled
  else
    tmpstr:=tmpstr+spropNot+spropEolFilled+',';//noteolfilled
  if fDefaultStyle.Changeable  then
    tmpstr:=tmpstr+spropChangeable+','//changeable
  else
    tmpstr:=tmpstr+spropNot+spropChangeable+',';//notchangeable
  if fDefaultStyle.Hotspot  then
    tmpstr:=tmpstr+spropHotspot+','//hotspot
  else
    tmpstr:=tmpstr+spropNot+spropHotspot+',';//nothotspot
  case fDefaultStyle.CharCase of
    CASE_UPPER: tmpstr:=tmpstr+spropCase+':u,';
    CASE_LOWER: tmpstr:=tmpstr+spropCase+':l,';
  end;

  dest :=tmpstr;
  if dest[Length(dest)]=',' then Delete(dest,Length(dest),1);
end;

// Generates a string with the properties of a single style.
procedure TSciStylesLoader.GenerateStylePropLine(var dest : String;const prefix : String;const styl : TSciStyle);
var
  tmpstr : String;
  tmpdescr : String;
begin
  tmpstr:=Format('%s%d=',[prefix,styl.StyleNumber]);
  tmpdescr:=styl.Name;
  tmpdescr:=ReplaceAChar(tmpdescr,',','|');
  tmpstr:=tmpstr+spropName+':'+tmpdescr+','; //name
  if (styl.ForeColor<>clDefault) and ((styl.ForeColor<>fDefaultStyle.ForeColor) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+spropFore+':'+ColourToString(styl.ForeColor)+',';//fore

  if (styl.BackColor<>clDefault) and ((styl.BackColor<>fDefaultStyle.BackColor) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+spropBack+':'+ColourToString(styl.BackColor)+',';//back

  if (styl.FontSize<>0) and ((styl.FontSize<>fDefaultStyle.FontSize) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+Format('%s:%d',[spropSize,styl.FontSize])+',';//size

  if (styl.FontName<>'') and ((styl.FontName<>fDefaultStyle.FontName) or (styl.StyleNumber=33)) then
    tmpstr:=tmpstr+spropFont+':'+styl.FontName+',';//font

  if (styl.FontStyles<>fDefaultStyle.FontStyles) then
  begin
    if (((fsBold in styl.FontStyles) <> (fsBold in fDefaultStyle.FontStyles)) or (styl.StyleNumber=33)) then
    begin
      if fsBold in styl.FontStyles then
        tmpstr:=tmpstr+spropBold+','//bold
      else
        tmpstr:=tmpstr+spropNot+spropBold+',';//notbold
    end;
    if (((fsItalic in styl.FontStyles) <> (fsItalic in fDefaultStyle.FontStyles)) or (styl.StyleNumber=33)) then
    begin
      if fsItalic in styl.FontStyles then
        tmpstr:=tmpstr+spropItalics+',' //italics
      else
        tmpstr:=tmpstr+spropNot+spropItalics+',';//notitalics
    end;
    if (((fsUnderline in styl.FontStyles) <> (fsUnderline in fDefaultStyle.FontStyles)) or (styl.StyleNumber=33)) then
    begin
      if fsUnderline in styl.FontStyles then
        tmpstr:=tmpstr+spropUnderlined+','//underlined
      else
        tmpstr:=tmpstr+spropNot+spropUnderlined+',';//notunderlined
    end;
  end;//<>fontstyles

  if (styl.Visible<>fDefaultStyle.Visible) then
  begin
    if styl.Visible=false  then
      tmpstr:=tmpstr+spropNot+spropVisible+',' //notvisible
    else
      tmpstr:=tmpstr+spropVisible+',';//visible
  end;

  if (styl.EOLFilled<>fDefaultStyle.EOLFilled) then
  begin
    if styl.EOLFilled  then
      tmpstr:=tmpstr+spropEolFilled+','//eolfilled
    else
      tmpstr:=tmpstr+spropNot+spropEolFilled+',';//noteolfilled
  end;
  if (styl.Changeable<>fDefaultStyle.Changeable) then
  begin
    if styl.Changeable  then
      tmpstr:=tmpstr+spropChangeable+','//changeable
    else
      tmpstr:=tmpstr+spropNot+spropChangeable+',';//notchangeable
  end;
  if (styl.Hotspot<>fDefaultStyle.Hotspot) then
  begin
    if styl.Hotspot  then
      tmpstr:=tmpstr+spropHotspot+','//hotspot
    else
      tmpstr:=tmpstr+spropNot+spropHotspot+',';//nothotspot
  end;
  if (styl.CharCase<>fDefaultStyle.CharCase) then
  begin
    case styl.CharCase of
      CASE_UPPER: tmpstr:=tmpstr+spropCase+':u,';
      CASE_LOWER: tmpstr:=tmpstr+spropCase+':l,';
    end;
  end;
  dest :=tmpstr;
  if dest[Length(dest)]=',' then Delete(dest,Length(dest),1);
end;

// Generates a propertyline with the specified keywords. May split in multiple lines if
// more than 8 in the list.
procedure TSciStylesLoader.GenerateKwdPropLine(var dest : String;const prefix : String;const kwd : TSciKeywords);
var
  tmpstr,tmpdescr : String;
  i,cnt,kwdonline : Integer;
  isfirst : Boolean;
begin
  tmpstr:=Format('%s%d=',[prefix,kwd.KeywordListNumber]);
  tmpdescr:=kwd.Name;
  tmpdescr :=ReplaceAChar(tmpdescr,',','|');

  tmpstr:=tmpstr+spropName+':'+tmpdescr+'::';//name
  cnt:=kwd.Keywords.Count;
  if cnt>0 then
  begin
    kwdonline:=0;
    isfirst:=true;
    for i:=0 to (cnt-1) do
    begin
      if (kwdonline>16) then
      begin
        tmpstr:=tmpstr+'\'+CrLf;
        kwdonline:=0;
        tmpstr:=tmpstr+kwd.Keywords.Strings[i];
      end else
      begin
        if isfirst then
        begin
          tmpstr:=tmpstr+kwd.Keywords.Strings[i];
          isfirst:=false;
        end else
          tmpstr:=tmpstr+' '+kwd.Keywords.Strings[i];
      end;
      Inc(kwdonline);
    end;
    if tmpstr[Length(tmpstr)]='\' then Delete(tmpstr,Length(tmpstr),1);
  end;
  dest :=tmpstr;
end;


//Splits a propertyline in 'Lang',stylenum and prop.
//Lines like
// prop.lang.stylenum=value or
// prop.lang=value
// are accepted
function TSciStylesLoader.PropLineSplit(const s: String;var stylenum : Integer;var prop : String;var value : String) : Boolean;
var
  tmp : String;
  propnamepart : String;
  code : Integer;
  i,cnt,dotstart : Integer;
begin
  tmp:=s;
  propnamepart:=WordBefore(tmp,'=');
  value:=tmp;
  cnt:=Length(propnamepart);
  dotstart:=-1;
  for i:=cnt downto 0 do
  begin
    if i>0 then
    case propnamepart[i] of
    '0'..'9':;
    else
    begin
      if i<>cnt then dotstart:=i;
      break;
    end;
    end;
  end;
  if dotstart=-1 then
    Prop:=propnamepart
  else
    begin
      if (dotstart>0) and (propnamepart[dotstart]='.') then
      begin
        Prop:=Copy(propnamepart,1,dotstart-1);
      end else
        Prop:=propnamepart;
        //Copy(propnamepart,1,dotstart);
      Delete(propnamepart,1,dotstart);
    end;
  if propnamepart='' then
  begin
    Result:=False;
    stylenum:=0;
    Exit;
  end;
  if propnamepart<>'' then
    val(propnamepart,stylenum,code);
  Result:=true;
end;

// Parses a string with a styledefinition into a TSciLangStyle
function TSciStylesLoader.ParseStyleDefinition(const definition : PChar;var sty : TSciLangStyle;defstyle : Boolean) : Boolean;
var
  vxal,opt,cpComma,colon : PChar;
  i : Integer;
  Changeable,EOLFilled,Hotspot : Boolean;
  wasset : array [0..6] of Boolean;
  ccase : TSciCase;
  vis : Boolean;
  name : String;
begin
  if (definition = nil) or (definition^ = #0) then
  begin
    Result:=false;
    Exit;
  end;
  GetMem(vxal,Length(definition)+1);
  StrCopy(vxal,definition);
  opt:=vxal;
  Changeable:=true;
  Hotspot:=false;
  EOLFilled:=false;
  vis:=True;
  ccase:=CASE_MIXED;
  for i:=Low(wasset) to High(wasset) do wasset[i]:=False;
  while (opt<>nil) do
  begin
    // Find attribute separator
    cpComma := AnsiStrScan(opt, ',');
    if assigned(cpComma) then  // If found, we terminate the current attribute (opt) string
      cpComma^ := #0;

    // Find attribute name/value separator
    colon := AnsiStrScan(opt, ':');
    if assigned(colon) then
    begin
      // If found, we terminate the current attribute name and point on the value
      colon^:=#0;
      Inc(colon);
    end;
    if (0 = CompStr(opt, spropItalics,True)) then //'italics'
    begin
      Include(sty.FontStyles,fsItalic);
    end else
    if (0 = CompStr(opt, spropNot+spropItalics)) then //notitalics
    begin
      Exclude(sty.FontStyles,fsItalic);
    end else
    if (0 = CompStr(opt, spropBold)) then //bold
    begin
      Include(sty.FontStyles,fsBold);
    end else
    if (0 = CompStr(opt, spropNot+spropBold)) then //notbold
    begin
      Exclude(sty.FontStyles,fsBold);
    end else
    if (0 = CompStr(opt, spropFont)) then //font
    begin
      sty.FontName:=colon;
    end else
    if (0 = CompStr(opt, spropName)) then
    begin
      name:=colon;
      name:=ReplaceAChar(name,'|',',');
      wasset[5]:=true;
    end else
    if (0 = CompStr(opt, spropFore)) then //'fore'
    begin
      sty.ForeColor:=ColourFromString(Trim(colon),cDefaultForeColor);
    end else
    if (0 = CompStr(opt, spropBack)) then //back
    begin
      sty.BackColor:=ColourFromString(Trim(colon),cDefaultBackColor);
    end else
    if (0 = CompStr(opt, spropSize)) then //size
    begin
      sty.FontSize:=ToInt(colon);
    end else
    if (0 = CompStr(opt, spropEolFilled)) then //eolfilled
    begin
      EOLFilled:=true;
      wasset[4]:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropEolFilled)) then //noteolfilled
    begin
      EOLFilled:=false;
      wasset[4]:=true;
    end else
    if (0 = CompStr(opt, spropUnderlined)) then //underlined
    begin
      Include(sty.FontStyles,fsUnderline);
    end else
    if (0 = CompStr(opt, spropNot+spropUnderlined)) then //notunderlined
    begin
      Exclude(sty.FontStyles,fsUnderline);
    end else
    if (0 = CompStr(opt, spropCase)) then //case
    begin
      wasset[0]:=true;
      ccase:= CASE_MIXED;
      if assigned(colon) then
      begin
        if (colon^ = 'u') then
          ccase:= CASE_UPPER
        else if (colon^ = 'l') then
          ccase:= CASE_LOWER;
      end;
    end else
    if (0 = CompStr(opt, spropVisible)) then //visible
    begin
      wasset[1]:=true;
      Vis:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropVisible)) then //notvisible
    begin
      wasset[1]:=true;
      Vis:=false;
    end else
    if (0 = CompStr(opt, spropChangeable)) then //changeable
    begin
      wasset[2]:=true;
      Changeable:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropChangeable)) then //notchangeable
    begin
      wasset[2]:=true;
      Changeable:=false;
    end else
    if (0 = CompStr(opt, spropHotspot)) then //hotspot
    begin
      wasset[3]:=true;
      Hotspot:=true;
    end else
    if (0 = CompStr(opt, spropNot+spropHotspot)) then //nothotspot
    begin
      wasset[3]:=true;
      Hotspot:=false;
    end;

    if assigned(cpComma) then
      opt := cpComma + 1
    else
      opt := nil;
  end;
  if assigned(vxal) then
  begin
    FreeMem(vxal);
  end;
  if defstyle=False then
  begin
    if (FDefaultStyle.FontSize<>0) and (sty.FontSize=FDefaultStyle.FontSize) then
      sty.FontSize:=0;
    if (FDefaultStyle.FontName<>'') and (CompStr(FDefaultStyle.FontName,sty.FontName)=0) then
      sty.FontName:='';
  end;
  if wasset[0] then sty.CharCase:=ccase;
  if wasset[1] then sty.Visible:=vis;
  if wasset[2] then sty.Changeable:=Changeable;
  if wasset[3] then sty.Hotspot:=Hotspot;
  if wasset[4] then sty.EOLFilled:=EOLFilled;
  if wasset[5] then sty.Name:=name;

  Result:=true;
end;

procedure TSciStylesLoader.FillWithDefaultStyle(var sty : TSciLangStyle);
begin
  sty.EOLFilled :=fDefaultStyle.EOLFilled;
  sty.Visible   :=fDefaultStyle.Visible;
  sty.CharCase  :=fDefaultStyle.CharCase;
  sty.Changeable:=fDefaultStyle.Changeable;
  sty.Hotspot   :=fDefaultStyle.Hotspot;
  sty.FontStyles:=fDefaultStyle.FontStyles;
  sty.FontName  :='';
  sty.FontSize  :=fDefaultStyle.FontSize;
  sty.ForeColor :=clDefault;
  sty.BackColor :=clDefault;
end;



{
  Loads only the default style AND all styles/keywords from a stream.
  Ignores everything else.
}
function TSciStylesLoader.LoadStylesFromStream(fs : TStream) : Boolean;
var
  lst : TMyStringList;
  cnt,i,aStyle,speedcnt,ignorelines : Integer;
  aSection,aLanguage,aProp,aValue,tmpstr : String;
  ps : Integer;
  oldlang : String;
  procedure ClearLangList;
  var
    cnt,i : Integer;
    clang : String;
    inlist : Boolean;
  begin
    cnt:=fManager.LanguageList.Count;
    for i:=(cnt-1) downto 0 do
    begin
      clang:=fManager.LanguageList.Items[i].Name;
      fManager.RemoveLanguage(clang,inlist);
    end;
  end;

  function  ProcessStylesOnly(var CategoryName,PropName : String;var Num : Integer;var aValue : String) : Boolean;
  var
    tmpsty : TSciLangStyle;
    kwdcnt,stycnt,srchend,j : Integer;
    wasdone : Boolean;
    stytmp  : TSciStyle;
    itm     : TSciLangItem;
    tmpkwd : TSciLangKeywords;
    kwdtmp : TSciKeywords;
    kwdname : String;
  begin
    Result:=False;
    if (AnsiCompareText(CategoryName,spropDefault)=0)  then //If it is the default style
    begin
      if (AnsiCompareText(PropName,spropStyle)=0) then
      begin
        tmpsty.EOLFilled:=false;
        tmpsty.Visible:=True;
        tmpsty.CharCase:=CASE_MIXED;
        tmpsty.Changeable:=True;
        tmpsty.Hotspot:=False;
        tmpsty.FontStyles:=[];
        tmpsty.FontName:='';
        tmpsty.FontSize:=0;
        tmpsty.ForeColor:=clDefault;
        tmpsty.BackColor:=clDefault;
        ParseStyleDefinition(PChar(aValue),tmpsty,true);
        fDefaultStyle.FontName:=tmpsty.FontName;
        fDefaultStyle.FontSize:=tmpsty.FontSize;
        fDefaultStyle.FontStyles:=tmpsty.FontStyles;
        fDefaultStyle.ForeColor:=tmpsty.ForeColor;
        fDefaultStyle.BackColor:=tmpsty.BackColor;
        fDefaultStyle.CharCase:=tmpsty.CharCase;
        fDefaultStyle.Visible:=tmpsty.Visible;
        fDefaultStyle.Changeable:=tmpsty.Changeable;
        fDefaultStyle.Hotspot:=tmpsty.Hotspot;
        fDefaultStyle.EOLFilled:=tmpsty.EOLFilled;
        if assigned(fEditor) then
        begin
          fEditor.Color:=tmpsty.BackColor;
          fEditor.Font.Color:=tmpsty.ForeColor;
          fEditor.Font.Name:=tmpsty.FontName;
          fEditor.Font.Size:=tmpsty.FontSize;
          fEditor.Font.Style:=tmpsty.FontStyles;
        end;
        Result:=True;
      end else
        if (AnsiCompareText(PropName,spropSelectForeColor)=0) then   //SelFore
        begin
          fColors.SelFore:=ColourFromString(aValue,cDefaultSelectFore);
          if assigned(fEditor) then fEditor.Colors.SelFore:=fColors.SelFore;
          Result:=True;
        end  else
        if (AnsiCompareText(PropName,spropSelectBackColor)=0) then   //SelBack
        begin
          fColors.SelBack:=ColourFromString(aValue,cDefaultSelectBack);
          if assigned(fEditor) then fEditor.Colors.SelBack:=fColors.SelBack;
          Result:=True;
        end
        else if (AnsiCompareText(PropName,spropSelectAlpha)=0) then   //SelBack
        begin
          fColors.SelAlpha:=ToInt(aValue,SC_ALPHA_NOALPHA);
          if fColors.SelAlpha>SC_ALPHA_NOALPHA then
            fColors.SelAlpha:=SC_ALPHA_NOALPHA;
          if assigned(fEditor) then TScintillaMemo(fEditor).Colors.SelAlpha:=fColors.SelAlpha;
          Result:=True;
        end else if (AnsiCompareText(PropName,spropMarkerForeColor)=0) then
        begin
          fColors.MarkerFore:=ColourFromString(aValue,cDefaultMarkerFore);
          if assigned(fEditor) then fEditor.Colors.MarkerFore:=fColors.MarkerFore;
          Result:=True;
        end  else if (AnsiCompareText(PropName,spropMarkerBackColor)=0) then
        begin
          fColors.MarkerBack:=ColourFromString(aValue,cDefaultMarkerBack);
          if assigned(fEditor) then fEditor.Colors.MarkerBack:=fColors.MarkerBack;
          Result:=True;
        end else if (AnsiCompareText(PropName,spropFoldMarginHighlightColor)=0) then
        begin
          fColors.FoldHi:=ColourFromString(aValue,cDefaultFoldMarginHighlightColor);
          if assigned(fEditor) then fEditor.Colors.FoldHi:=fColors.FoldHi;
          Result:=True;
        end else if (AnsiCompareText(PropName,spropFoldMarginColor)=0) then
        begin
          fColors.FoldLo:=ColourFromString(aValue,cDefaultFoldMarginColor);
          if assigned(fEditor) then fEditor.Colors.FoldLo:=fColors.FoldLo;
          Result:=True;
        end else if (AnsiCompareText(PropName,spropWhiteSpaceFore)=0) then
        begin
          TScintillaMemo(fEditor).Colors.WhiteSpaceFore:=ColourFromString(aValue,fEditor.Font.Color);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropWhiteSpaceBack)=0) then
        begin
          TScintillaMemo(fEditor).Colors.WhiteSpaceBack:=ColourFromString(aValue,fEditor.Color);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropActiveHotspotForeColor)=0) then      //SelBack
        begin
          fColors.HotSpotForeColor:=ColourFromString(aValue,cDefaultHotspotFore);
          if assigned(fEditor) then fEditor.ActiveHotSpot.ForeColor:=fColors.HotSpotForeColor;
          Result:=True;
        end else if (AnsiCompareText(PropName,spropActiveHotspotBackColor)=0) then      //SelBack
        begin
          fColors.HotSpotBackColor:=ColourFromString(aValue,cDefaultHotspotBack);
          if assigned(fEditor) then fEditor.ActiveHotSpot.BackColor:=fColors.HotSpotBackColor;
          Result:=True;
        end else if (AnsiCompareText(PropName,spropActiveHotspotUnderlined)=0) then      //SelBack
        begin
          fColors.HotSpotUnderlined:=StringToBool(aValue);
          if assigned(fEditor) then fEditor.ActiveHotSpot.Underlined:=fColors.HotSpotUnderlined;
          Result:=True;
        end else if (AnsiCompareText(PropName,spropActiveHotspotSingleLine)=0) then      //SelBack
        begin
          fColors.HotSpotSingleLine:=StringToBool(aValue);
          if assigned(fEditor) then fEditor.ActiveHotSpot.SingleLine:=fColors.HotSpotSingleLine;
          Result:=True;
        end else if AnsiCompareText(spropCaretFore,PropName)=0 then //caretfore
        begin
          fColors.CaretForeColor:=ColorToRGB(ColourFromString(aValue,cDefaultCaretFore));
          if assigned(fEditor) then fEditor.SetCaretFore(fColors.CaretForeColor);
          Result:=True;
        end else if AnsiCompareText(spropCaretBack,PropName)=0 then //caretlineback
        begin
          fColors.CaretLineBackColor:=ColorToRGB(ColourFromString(aValue,cDefaultCaretBack));
          if assigned(fEditor) then fEditor.SetCaretLineBack(fColors.CaretLineBackColor);
          Result:=True;
        end else if AnsiCompareText(spropCaretBackAlpha,PropName)=0 then //caretlinebackalpha
        begin
          fColors.CaretLineBackAlpha:=ToInt(aValue,SC_ALPHA_NOALPHA);
          if fColors.CaretLineBackAlpha>SC_ALPHA_NOALPHA then
            fColors.CaretLineBackAlpha:=SC_ALPHA_NOALPHA;
          if assigned(fEditor) then fEditor.SetCaretLineBackAlpha(fColors.CaretLineBackAlpha);
          Result:=True;
        end else if AnsiCompareText(spropCaretPeriod,PropName)=0 then
        begin
          fColors.CaretPeriod:=ToInt(aValue);
          if assigned(fEditor) then fEditor.SetCaretPeriod(fColors.CaretPeriod);
          Result:=True;
        end else if AnsiCompareText(spropCaretWidth,PropName)=0 then
        begin
          fColors.CaretWidth:=ToInt(aValue);
          if assigned(fEditor) then fEditor.SetCaretWidth(fColors.CaretWidth);
          Result:=True;
        end else if AnsiCompareText(spropCaretLineVisible,PropName)=0 then
        begin
          fColors.CaretLineVisible:=StringToBool(aValue);
          if assigned(fEditor) then fEditor.SetCaretLineVisible(fColors.CaretLineVisible);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropEdgeColumn)=0) then //EdgeColumn
        begin
          fColors.EdgeColumn:=ToInt(aValue);
          if assigned(fEditor) then fEditor.SetEdgeColumn(fColors.EdgeColumn);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropEdgeColor)=0) then  //EdgeColor
        begin
          fColors.EdgeColor:=ColourFromString(aValue,cDefaultEdgeColor);
          if assigned(fEditor) then fEditor.SetEdgeColour(fColors.EdgeColor);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropEdgeMode)=0) then  //EdgeMode
        begin
          fColors.EdgeMode:=sciEdgeType(ToInt(aValue));
          if assigned(fEditor) then fEditor.SetEdgeMode(Integer(fColors.EdgeMode));
          Result:=True;
        end;
      if fEditor is TScintilla then
      begin
        if (AnsiCompareText(PropName,spropFoldMarkerType)=0) then
        begin
          TScintilla(fEditor).FoldMarkers.MarkerType:=sciMarkerType(ToInt(aValue));
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropMarkerFoldOpen)=0) then   //SelFore
        begin
          ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldOpen);
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropMarkerFoldClosed)=0) then   //SelFore
        begin
          ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldClosed);
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropMarkerFoldSub)=0) then   //SelFore
        begin
          ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldSub);
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropMarkerFoldTail)=0) then   //SelFore
        begin
          ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldTail);
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropMarkerFoldEnd)=0) then   //SelFore
        begin
          ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldEnd);
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropMarkerFoldOpenMid)=0) then   //SelFore
        begin
          ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldOpenMid);
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropMarkerFoldMidTail)=0) then   //SelFore
        begin
          ParseMarkerDefinition(PChar(aValue),TScintilla(fEditor).FoldMarkers.FoldMidTail);
          Result:=True;
        end;
      end;
    end else //not default
    if (AnsiCompareText(PropName,spropStyle)=0) or
    (AnsiCompareText(PropName,spropKeywords)=0) or
    (AnsiCompareText(PropName,spropCommentBoxStart)=0) or
    (AnsiCompareText(PropName,spropCommentBoxEnd)=0) or
    (AnsiCompareText(PropName,spropCommentBoxMiddle)=0) or
    (AnsiCompareText(PropName,spropCommentBlock)=0) or
    (AnsiCompareText(PropName,spropCommentStreamStart)=0) or
    (AnsiCompareText(PropName,spropCommentStreamEnd)=0) or
    (AnsiCompareText(PropName,spropAssignmentOperator)=0) or
    (AnsiCompareText(PropName,spropEndOfStatementOperator)=0) or
    (AnsiCompareText(PropName,spropLexer)=0) or
    (AnsiCompareText(PropName,spropNumStyleBits)=0) then
    begin
      if (AnsiCompareText(PropName,spropLexer)=0) then  // If it is a language definition
      begin
        FManager.AddLanguage(CategoryName,aValue);
        Result:=True;
        Exit;
      end;

      itm:=fManager.LanguageList.Find(CategoryName);
      if itm=nil then
      begin
        itm:=fManager.LanguageList.Add;
        itm.Name:=CategoryName;
        itm.Lexer:=CategoryName;
      end;

      if assigned(itm) then
      begin
        if (AnsiCompareText(PropName,spropStyle)=0) then // If it is a style definition
        begin
          stycnt:=itm.Styles.Count;
          wasdone:=false;
          for j:=0 to (stycnt-1) do //Check if the style is in the list, and if so, just modify it.
          begin
            if itm.Styles.Items[j].StyleNumber=Num then
            begin
              itm.Styles.Items[j].AssignToRec(tmpsty);
              ParseStyleDefinition(PChar(aValue),tmpsty);
              itm.Styles.Items[j].AssignRec(tmpsty);
              wasdone:=true;
              Break;
            end;
          end;
          if wasdone=false then // If the style wasn't found
          begin
            stytmp:=itm.Styles.Add;
            stytmp.AssignToRec(tmpsty);
            FillWithDefaultStyle(tmpsty);
            tmpsty.StyleNumber:=Num;
            ParseStyleDefinition(PChar(aValue),tmpsty);
            stytmp.AssignRec(tmpsty);
          end;
          Result:=True;
        end else
        if AnsiCompareText(PropName,spropKeywords)=0 then // If it is a keyword definition
        begin
          kwdcnt:=itm.Keywords.Count;
          wasdone:=false;
          if (AnsiStrLIComp(PChar(spropName+':'),PChar(aValue),5)=0) then // If it's a keywordlist description
          begin
            srchend:=Pos('::',AValue);
            if srchend<>0 then
            begin
              kwdname:=Copy(aValue,6,srchend-6);
              Delete(aValue,1,srchend+1);
              kwdname:=ReplaceAChar(kwdname,'|',',');
            end else kwdname:='';
          end else kwdname:=''; //has'nt a keywordlist description

          for j:=0 to (kwdcnt-1) do //Check if the style is in the list, and if so, just modify it.
          begin
            if itm.Keywords.Items[j].KeywordListNumber=Num then
            begin
              itm.Keywords.Items[j].AssignToRec(tmpkwd);
              tmpkwd.KeyWords:=aValue;
              if kwdname<>'' then tmpkwd.Name:=kwdname;
              itm.Keywords.Items[j].AssignRec(tmpkwd);
              wasdone:=true;
              Break;
            end;
          end;
          if wasdone=false then // If the keywordlist wasn't found
          begin
            kwdtmp:=itm.Keywords.Add;
            kwdtmp.AssignToRec(tmpkwd);
            if kwdname<>'' then tmpkwd.Name:=kwdname;
            tmpkwd.KeywordListNumber:=Num;
            tmpkwd.KeyWords:=aValue;
            kwdtmp.AssignRec(tmpkwd);
          end;//wasdone
          Result:=True;
        end else
        if (AnsiCompareText(PropName,spropCommentBoxStart)=0) then
        begin
          itm.CommentBoxStart:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropCommentBoxEnd)=0) then
        begin
          itm.CommentBoxEnd:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropCommentBoxMiddle)=0) then
        begin
          itm.CommentBoxMiddle:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropCommentBlock)=0) then
        begin
          itm.CommentBlock:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropCommentStreamStart)=0) then
        begin
          itm.CommentStreamStart:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropCommentStreamEnd)=0) then
        begin
          itm.CommentStreamEnd:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropAssignmentOperator)=0) then
        begin
          itm.AssignmentOperator:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropEndOfStatementOperator)=0) then
        begin
          itm.EndOfStatementOperator:=UnSlash(aValue);
          Result:=True;
        end else if (AnsiCompareText(PropName,spropNumStyleBits)=0) then
        begin
          itm.NumStyleBits:=ToInt(aValue);
          Result:=True;
        end;
      end;//itm<>nil
    end;
  end;
begin
  lst:=nil;
  Result:=False;
  if not assigned(fManager) then
  begin
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TSciStylesLoader']);
    Result:=false;
    Exit;
  end;
  fLoadingErrors.Clear;
  oldlang:=fManager.SelectedLanguage;
  fManager.SelectedLanguage:='null';
  ClearLangList;
  try
    try
      lst:=TMyStringList.Create;
      lst.LoadFromStream(fs);
      cnt :=lst.Count;
      ignorelines:=0;
      for i:=0 to (cnt-1) do
      begin
        try
          speedcnt:=0;
          if ignorelines>0 then
          begin
            Dec(ignorelines);
            Continue;
          end;
          tmpstr:=Trim(lst.Strings[i]);
          if tmpstr='' then Continue;

          if Pos('#',tmpstr)=1 then Continue;
          ps:=Pos('[',tmpstr);
          if ps=1 then
          begin
            if Pos(']',tmpstr)>0 then
              Delete(tmpstr,Pos(']',tmpstr),1);
              Delete(tmpstr,1,1);
              aSection:=tmpstr;
              continue;
          end;
          while (tmpstr[Length(tmpstr)]='\') and ((i+speedcnt+1)<=(cnt-1)) do
          begin
            Inc(speedcnt);
            Delete(tmpstr,Length(tmpstr),1);
              tmpstr:=Trim(tmpstr)+' '+Trim(lst.Strings[i+speedcnt]);
          end;
          if speedcnt<>0 then ignorelines:=speedcnt;
          if PropLineSplit(tmpstr,aStyle,aProp,aValue) then
          begin
            aLanguage:=aSection;
            ProcessStylesOnly(aLanguage,aProp,aStyle,aValue);
          end;//proplinesplit
        except
          on EConvertError do
          begin
            fLoadingErrors.Add(Format(eConversionErrorMsg,[i]));
          end;
          on E : Exception do
          begin
            fLoadingErrors.Add(E.Message);
          end;
        end;
      end;//for
      if fManager.SelectedLanguage<>oldlang then
        fManager.SelectedLanguage:=oldlang;
    if (fManager.SelectedLanguage<>oldlang) and (assigned(fManager.LanguageList.Find(oldlang))) then
      fManager.SelectedLanguage:=oldlang;
      if assigned(fManager) and (assigned(fManager.Owner)) then fManager.Update;
      Result:=True;
    except
      on E : Exception do
        fLoadingErrors.Add(E.Message);
    end;
  finally
    if assigned(lst) then FreeAndNil(lst);
  end;

end;

function TSciStylesLoader.LoadStyles(const filename : String) : Boolean;
var
  fs : TFileStream;
begin
  fs:=nil;
  try
    try
      fs:=TFileStream.Create(filename,fmOpenRead or fmShareDenyWrite);
      Result:=LoadStylesFromStream(fs);
    except
      on EStreamError do
      begin
        Result:=false;
        raise Exception.CreateResFmt(@eCouldntLoadFromFile,[filename]);
      end;
    end;
  finally
    if assigned(fs) then FreeAndNil(fs);
  end;
end;

{
  Save only the default style AND all styles/keywords to a stream
}
function TSciStylesLoader.SaveStylesToStream(fs : TStream) : Boolean;
var
  lst : TMyStringList;
  langcnt,stylcnt,kwdcnt,i,j : Integer;
  itm : TSciLangItem;
  tmpstr,prefix,langname : String;
  tmpclr : TColor;
begin
  lst:=nil;
  if (not assigned(fManager)) and (not assigned(fEditor)) then
  try
    try
      lst:=TMyStringList.Create;
      if assigned(fEditor) then
      begin
        fDefaultStyle.FontName:=fEditor.Font.Name;
        fDefaultStyle.FontSize:=fEditor.Font.Size;
        fDefaultStyle.FontStyles:=fEditor.Font.Style;
        fDefaultStyle.ForeColor:=fEditor.Font.Color;
        fDefaultStyle.BackColor:=fEditor.Color;
        //Add all properties which should be in [default] section.
        lst.Add('['+spropDefault+']');
        GenerateDefaultPropLine(tmpstr,fEditor);
        lst.Add(tmpstr);
        tmpclr:=fEditor.GetCaretFore;
        lst.Add(spropCaretFore+'='+ColourToString(tmpclr)); //caretfore
        tmpclr:=fEditor.GetCaretLineBack;
        lst.Add(spropCaretBack+'='+ColourToString(tmpclr)); //caretback
        lst.Add(spropCaretLineVisible+'='+BoolToString(fEditor.GetCaretLineVisible));
        lst.Add(Format('%s=%d',[spropCaretPeriod,fEditor.GetCaretPeriod]));
        lst.Add(Format('%s=%d',[spropCaretWidth,fEditor.GetCaretWidth]));
        lst.Add(spropCaretBackAlpha+'='+ToStr(fEditor.GetCaretLineBackAlpha)); //caretbackalpha
        lst.Add(spropSelectForeColor+'='+ColourToString(fEditor.Colors.SelFore));
        lst.Add(spropSelectBackColor+'='+ColourToString(fEditor.Colors.SelBack));
        lst.Add(spropSelectAlpha+'='+ToStr(fEditor.Colors.SelAlpha));
        lst.Add(spropMarkerForeColor+'='+ColourToString(fEditor.Colors.MarkerFore));
        lst.Add(spropMarkerBackColor+'='+ColourToString(fEditor.Colors.MarkerBack));
        lst.Add(spropFoldMarginHighlightColor+'='+ColourToString(fEditor.Colors.FoldHi));
        lst.Add(spropFoldMarginColor+'='+ColourToString(fEditor.Colors.FoldLo));
        lst.Add(spropWhiteSpaceFore+'='+ColourToString(TScintillaMemo(fEditor).Colors.WhiteSpaceFore));
        lst.Add(spropWhiteSpaceBack+'='+ColourToString(TScintillaMemo(fEditor).Colors.WhiteSpaceBack));
        lst.Add(spropActiveHotspotForeColor+'='+ColourToString(fEditor.ActiveHotSpot.ForeColor));
        lst.Add(spropActiveHotspotBackColor+'='+ColourToString(fEditor.ActiveHotSpot.BackColor));
        lst.Add(spropActiveHotspotUnderlined+'='+BoolToString(fEditor.ActiveHotSpot.Underlined));
        lst.Add(spropActiveHotspotSingleLine+'='+BoolToString(fEditor.ActiveHotSpot.SingleLine));
        if fEditor is TScintilla then
        begin
          try
          lst.Add(Format('%s=%d',[spropFoldMarkerType,Integer(TScintilla(fEditor).FoldMarkers.MarkerType)]));
          if TScintilla(fEditor).FoldMarkers.MarkerType=sciMarkCustom then
          begin
            lst.Add(Format('%s=%s',[spropMarkerFoldOpen,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldOpen)]));
            lst.Add(Format('%s=%s',[spropMarkerFoldClosed,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldClosed)]));
            lst.Add(Format('%s=%s',[spropMarkerFoldSub,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldSub)]));
            lst.Add(Format('%s=%s',[spropMarkerFoldTail,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldTail)]));
            lst.Add(Format('%s=%s',[spropMarkerFoldEnd,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldEnd)]));
            lst.Add(Format('%s=%s',[spropMarkerFoldOpenMid,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldOpenMid)]));
            lst.Add(Format('%s=%s',[spropMarkerFoldMidTail,GenerateMarkerLine(TScintilla(fEditor).FoldMarkers.FoldMidTail)]));
          end;
          except
            on E : Exception do MessageBox(0,PChar(E.Message),'',MB_OK);
          end;
        end;
        lst.Add(Format('%s=%s',[spropMarkerBookMark,GenerateMarkerLine(TScintilla(fEditor).Bookmark)]));
        lst.Add(Format('%s=%d',[spropEdgeColumn,fEditor.GetEdgeColumn]));
        lst.Add(Format('%s=%d',[spropEdgeMode,fEditor.GetEdgeMode]));
        lst.Add(spropEdgeColor+'='+ColourToString(fEditor.GetEdgeColour));
      end;
      if assigned(fManager) then //If we have a LanguageManager, add styles and keywords.
      begin
        langcnt:=fManager.LanguageList.Count;
        for i:=0 to (langcnt-1) do
        begin
          itm:=fManager.LanguageList.Items[i];
          langname :=itm.Name;
          if langname='' then langname:=IntToStr(i);
          prefix :=langname+'.';
          lst.Add('['+langname+']');
          with itm do
          begin
            lst.Add(spropLexer+'='+itm.Lexer);
            if itm.NumStyleBits<>5 then
            lst.Add(spropNumStyleBits+'='+ToStr(itm.NumStyleBits));
            kwdcnt:=itm.Keywords.Count;
            for j:=0 to (kwdcnt-1) do
            begin
              GenerateKwdPropLine(tmpstr,spropKeywords+'.',itm.Keywords.Items[j]);
              if tmpstr<>'' then
              begin
                lst.Add(tmpstr);
                if j<(kwdcnt-1) then
                lst.Add('');
              end;
            end;
            stylcnt:=itm.Styles.Count;
            if (stylcnt>0) then
            begin
              lst.Add('');
            end;
            for j:=0 to (stylcnt-1) do
            begin
              GenerateStylePropLine(tmpstr,spropStyle+'.',TSciStyle(itm.Styles.Items[j]));
              if tmpstr<>'' then lst.Add(tmpstr);
            end;
            lst.Add('');
          end;
          lst.Add(spropCommentBoxStart+'='+itm.CommentBoxStart);
          lst.Add(spropCommentBoxEnd+'='+itm.CommentBoxEnd);
          lst.Add(spropCommentBoxMiddle+'='+itm.CommentBoxMiddle);
          lst.Add(spropCommentBlock+'='+itm.CommentBlock);
          lst.Add(spropCommentStreamStart+'='+itm.CommentStreamStart);
          lst.Add(spropCommentStreamEnd+'='+itm.CommentStreamEnd);
          lst.Add(spropAssignmentOperator+'='+itm.AssignmentOperator);
          lst.Add(spropEndOfStatementOperator+'='+itm.EndOfStatementOperator);
        end;
      end;
      lst.SaveToStream(fs);
      Result:=true;
      Exit;
    except
      raise;
    end;
  finally
    if assigned(lst) then FreeAndNil(lst);
  end;
  Result:=false;
end;

function TSciStylesLoader.SaveStyles(const filename : String) : Boolean;
var
  fs : TFileStream;
begin
  fs:=nil;
  try
    try
      fs:=TFileStream.Create(filename,fmCreate or fmShareDenyWrite);
      SaveStylesToStream(fs);
      Result:=true;
    except
      on EStreamError do
      begin
        Result:=false;
        raise Exception.CreateResFmt(@eCouldntLoadFromFile,[filename]);
      end;
    end;
  finally
    if assigned(fs) then FreeAndNil(fs);
  end;
end;


function TSciStylesLoader.GenerateMarkerLine(Marker : TSciMarker) : String;
var
  markerstr : String;
begin
  Result:='';
  if not assigned(Marker) then Exit;
  if MarkerNoToIdent(Marker.MarkerType,markerstr) then
    Result:=Format(spropMarkerType+':%s',[markerstr])
  else
    Result:=Format(spropMarkerType+':%d',[Integer(Marker.MarkerType)]);

  if Marker.PixmapFile<>'' then
  begin
    Result:=Result+','+Format(spropPixMapFile+':%s',[Marker.PixmapFile]);
  end;
  Result:=Result+','+Format(spropMarkerAlpha+':%d',[Marker.Alpha]);
  Result:=Result+','+Format(spropFore+':%s',[ColourToString(Marker.ForeColor)]);
  Result:=Result+','+Format(spropBack+':%s',[ColourToString(Marker.BackColor)]);
end;

// Parses a string with a markerdefinition
function TSciStylesLoader.ParseMarkerDefinition(const definition : PChar;Marker : TSciMarker) : Boolean;
var
  vxal,opt,cpComma,colon : PChar;
  MarkerNo : Integer;
begin
  if (definition = nil) or (definition^ = #0) then
  begin
    Result:=false;
    Exit;
  end;
  if not Assigned(Marker) then
  begin
    Result:=False;
    Exit;
  end;
  GetMem(vxal,Length(definition)+1);
  StrCopy(vxal,definition);
  opt:=vxal;

  while (opt<>nil) do
  begin
    // Find attribute separator
    cpComma := AnsiStrScan(opt, ',');
    if assigned(cpComma) then  // If found, we terminate the current attribute (opt) string
      cpComma^ := #0;

    // Find attribute name/value separator
    colon := AnsiStrScan(opt, ':');
    if assigned(colon) then
    begin
      // If found, we terminate the current attribute name and point on the value
      colon^:=#0;
      Inc(colon);
    end;
    if (0 = CompStr(opt, spropMarkerType)) then //notchangeable
    begin
      IdentToMarkerNo(colon,MarkerNo);
      Marker.MarkerType:=MarkerNo;
    end else
    if (0 = CompStr(opt, spropFore)) then //'fore'
    begin
      Marker.ForeColor:=ColourFromString(Trim(colon),clSilver);
    end else
    if (0 = CompStr(opt, spropBack)) then //back
    begin
      Marker.BackColor:=ColourFromString(Trim(colon),clWhite);
    end else
    if (0 = CompStr(opt, spropPixMapFile)) then //size
    begin
      Marker.PixmapFile:=colon;
    end else
    if (0 = CompStr(opt, spropMarkerAlpha)) then //size
    begin
      Marker.Alpha:=ToInt(colon,256);
    end;

    if assigned(cpComma) then
      opt := cpComma + 1
    else
      opt := nil;
  end;
  if assigned(vxal) then
  begin
    FreeMem(vxal);
  end;
  Result:=true;
end;
end.
Added src/delphisci/SciSupport.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
3601
3602
3603
3604
3605
3606
3607
3608
3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
3643
3644
3645
3646
3647
3648
3649
3650
3651
3652
3653
3654
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
3726
3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
3740
3741
3742
3743
3744
3745
3746
3747
3748
3749
3750
3751
3752
3753
3754
3755
3756
3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
3775
3776
3777
3778
3779
3780
3781
3782
3783
3784
3785
3786
3787
3788
3789
3790
3791
3792
3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
3849
3850
3851
3852
3853
3854
3855
3856
3857
3858
3859
3860
3861
3862
3863
3864
3865
3866
3867
3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
3925
3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
3941
3942
3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
3984
3985
3986
3987
3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
4000
4001
4002
4003
4004
4005
4006
4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
4023
4024
4025
4026
4027
4028
4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
4065
4066
4067
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
4124
4125
4126
4127
4128
4129
4130
4131
4132
4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
4207
4208
4209
4210
4211
4212
4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
4285
4286
4287
4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
4302
4303
4304
4305
4306
4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370
4371
4372
4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
4443
4444
4445
4446
4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
4481
4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
4779
4780
4781
4782
4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
4807
4808
4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
4855
4856
4857
4858
4859
4860
4861
4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
4916
4917
4918
4919
4920
4921
4922
4923
4924
4925
4926
4927
4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
5019
5020
5021
5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
5037
5038
5039
5040
5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
5138
5139
5140
5141
5142
5143
5144
5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
5160
5161
5162
5163
5164
5165
5166
5167
5168
5169
5170
5171
5172
5173
5174
5175
5176
5177
5178
5179
5180
5181
5182
5183
5184
5185
5186
5187
5188
5189
5190
5191
5192
5193
5194
5195
5196
{
  History: 29/09/2004 Initial Release with Delphi Scintilla Interface Components
}

// Support unit for scintilla use in pascal. The constants are all created from scintilla.iface by
// a python script.
{$Include SciCommonDef.Inc}
unit SciSupport;
interface
uses Windows;
{$Define MACRO_SUPPORT}

 type

  TScintillaMessageFnc = function(ptr : Pointer; Msg, wParam, lParam : LongInt) : LongInt; cdecl;
  uptr_t = Longword;
  sptr_t = LongInt;

  TNotifyHeader = record
    hwndFrom : Pointer;
    idFrom   : Cardinal;
    code     : Cardinal;
  end;
  PSCNotification = ^TSCNotification;
  TSCNotification = record
    nmhdr             : TNotifyHeader;
    position          : Integer;    // SCN_STYLENEEDED, SCN_MODIFIED
    ch                 : Integer;    // SCN_CHARADDED, SCN_KEY
    modifiers          : Integer;    // SCN_KEY
    modificationType  : Integer;    // SCN_MODIFIED
    text              : PChar;      // SCN_MODIFIED
    length            : Integer;    // SCN_MODIFIED
    linesAdded        : Integer;    // SCN_MODIFIED
{$ifdef MACRO_SUPPORT}
    message            : Integer;    // SCN_MACRORECORD
    wParam            : uptr_t;    // SCN_MACRORECORD
    lParam            : sptr_t;      // SCN_MACRORECORD
{$endif}
    line              : Integer;    // SCN_MODIFIED
    foldLevelNow      : Integer;    // SCN_MODIFIED
    foldLevelPrev      : Integer;    // SCN_MODIFIED
    margin            : Integer;    // SCN_MARGINCLICK
    listType          : Integer;    // SCN_USERLISTSELECTION
  end;

  TCharacterRange = Record
    cpMin : LongInt;
    cpMax : LongInt;
  end;

  PTextRange = ^TTextRange;
  TTextRange = Record
    chrg      : TCharacterRange;
    lpstrText : LPSTR;
  end;

  PTextToFind = ^TTextToFind;
  TTextToFind = Record
    chrg      : TCharacterRange;
    lpstrText : LPSTR;
    chrgText  : TCharacterRange;
  end;

PRangeToFormat = ^TRangeToFormat;
TRangeToFormat = record
    hdc: HDC;
    hdcTarget: HDC;
    rc: TRect;
    rcPage: TRect;
    chrg: TCharacterRange;
  end;
const
//++Const -- start of section automatically generated from Scintilla.iface
    INVALID_POSITION = -1;
    {$EXTERNALSYM INVALID_POSITION}
    {$HPPEMIT '#define INVALID_POSITION -1'}
    SCI_START = 2000;
    {$EXTERNALSYM SCI_START}
    {$HPPEMIT '#define SCI_START 2000'}
    SCI_OPTIONAL_START = 3000;
    {$EXTERNALSYM SCI_OPTIONAL_START}
    {$HPPEMIT '#define SCI_OPTIONAL_START 3000'}
    SCI_LEXER_START = 4000;
    {$EXTERNALSYM SCI_LEXER_START}
    {$HPPEMIT '#define SCI_LEXER_START 4000'}
    SCI_ADDTEXT = 2001;
    {$EXTERNALSYM SCI_ADDTEXT}
    {$HPPEMIT '#define SCI_ADDTEXT 2001'}
    SCI_ADDSTYLEDTEXT = 2002;
    {$EXTERNALSYM SCI_ADDSTYLEDTEXT}
    {$HPPEMIT '#define SCI_ADDSTYLEDTEXT 2002'}
    SCI_INSERTTEXT = 2003;
    {$EXTERNALSYM SCI_INSERTTEXT}
    {$HPPEMIT '#define SCI_INSERTTEXT 2003'}
    SCI_CLEARALL = 2004;
    {$EXTERNALSYM SCI_CLEARALL}
    {$HPPEMIT '#define SCI_CLEARALL 2004'}
    SCI_CLEARDOCUMENTSTYLE = 2005;
    {$EXTERNALSYM SCI_CLEARDOCUMENTSTYLE}
    {$HPPEMIT '#define SCI_CLEARDOCUMENTSTYLE 2005'}
    SCI_GETLENGTH = 2006;
    {$EXTERNALSYM SCI_GETLENGTH}
    {$HPPEMIT '#define SCI_GETLENGTH 2006'}
    SCI_GETCHARAT = 2007;
    {$EXTERNALSYM SCI_GETCHARAT}
    {$HPPEMIT '#define SCI_GETCHARAT 2007'}
    SCI_GETCURRENTPOS = 2008;
    {$EXTERNALSYM SCI_GETCURRENTPOS}
    {$HPPEMIT '#define SCI_GETCURRENTPOS 2008'}
    SCI_GETANCHOR = 2009;
    {$EXTERNALSYM SCI_GETANCHOR}
    {$HPPEMIT '#define SCI_GETANCHOR 2009'}
    SCI_GETSTYLEAT = 2010;
    {$EXTERNALSYM SCI_GETSTYLEAT}
    {$HPPEMIT '#define SCI_GETSTYLEAT 2010'}
    SCI_REDO = 2011;
    {$EXTERNALSYM SCI_REDO}
    {$HPPEMIT '#define SCI_REDO 2011'}
    SCI_SETUNDOCOLLECTION = 2012;
    {$EXTERNALSYM SCI_SETUNDOCOLLECTION}
    {$HPPEMIT '#define SCI_SETUNDOCOLLECTION 2012'}
    SCI_SELECTALL = 2013;
    {$EXTERNALSYM SCI_SELECTALL}
    {$HPPEMIT '#define SCI_SELECTALL 2013'}
    SCI_SETSAVEPOINT = 2014;
    {$EXTERNALSYM SCI_SETSAVEPOINT}
    {$HPPEMIT '#define SCI_SETSAVEPOINT 2014'}
    SCI_GETSTYLEDTEXT = 2015;
    {$EXTERNALSYM SCI_GETSTYLEDTEXT}
    {$HPPEMIT '#define SCI_GETSTYLEDTEXT 2015'}
    SCI_CANREDO = 2016;
    {$EXTERNALSYM SCI_CANREDO}
    {$HPPEMIT '#define SCI_CANREDO 2016'}
    SCI_MARKERLINEFROMHANDLE = 2017;
    {$EXTERNALSYM SCI_MARKERLINEFROMHANDLE}
    {$HPPEMIT '#define SCI_MARKERLINEFROMHANDLE 2017'}
    SCI_MARKERDELETEHANDLE = 2018;
    {$EXTERNALSYM SCI_MARKERDELETEHANDLE}
    {$HPPEMIT '#define SCI_MARKERDELETEHANDLE 2018'}
    SCI_GETUNDOCOLLECTION = 2019;
    {$EXTERNALSYM SCI_GETUNDOCOLLECTION}
    {$HPPEMIT '#define SCI_GETUNDOCOLLECTION 2019'}
    SCWS_INVISIBLE = 0;
    {$EXTERNALSYM SCWS_INVISIBLE}
    {$HPPEMIT '#define SCWS_INVISIBLE 0'}
    SCWS_VISIBLEALWAYS = 1;
    {$EXTERNALSYM SCWS_VISIBLEALWAYS}
    {$HPPEMIT '#define SCWS_VISIBLEALWAYS 1'}
    SCWS_VISIBLEAFTERINDENT = 2;
    {$EXTERNALSYM SCWS_VISIBLEAFTERINDENT}
    {$HPPEMIT '#define SCWS_VISIBLEAFTERINDENT 2'}
    SCI_GETVIEWWS = 2020;
    {$EXTERNALSYM SCI_GETVIEWWS}
    {$HPPEMIT '#define SCI_GETVIEWWS 2020'}
    SCI_SETVIEWWS = 2021;
    {$EXTERNALSYM SCI_SETVIEWWS}
    {$HPPEMIT '#define SCI_SETVIEWWS 2021'}
    SCI_POSITIONFROMPOINT = 2022;
    {$EXTERNALSYM SCI_POSITIONFROMPOINT}
    {$HPPEMIT '#define SCI_POSITIONFROMPOINT 2022'}
    SCI_POSITIONFROMPOINTCLOSE = 2023;
    {$EXTERNALSYM SCI_POSITIONFROMPOINTCLOSE}
    {$HPPEMIT '#define SCI_POSITIONFROMPOINTCLOSE 2023'}
    SCI_GOTOLINE = 2024;
    {$EXTERNALSYM SCI_GOTOLINE}
    {$HPPEMIT '#define SCI_GOTOLINE 2024'}
    SCI_GOTOPOS = 2025;
    {$EXTERNALSYM SCI_GOTOPOS}
    {$HPPEMIT '#define SCI_GOTOPOS 2025'}
    SCI_SETANCHOR = 2026;
    {$EXTERNALSYM SCI_SETANCHOR}
    {$HPPEMIT '#define SCI_SETANCHOR 2026'}
    SCI_GETCURLINE = 2027;
    {$EXTERNALSYM SCI_GETCURLINE}
    {$HPPEMIT '#define SCI_GETCURLINE 2027'}
    SCI_GETENDSTYLED = 2028;
    {$EXTERNALSYM SCI_GETENDSTYLED}
    {$HPPEMIT '#define SCI_GETENDSTYLED 2028'}
    SC_EOL_CRLF = 0;
    {$EXTERNALSYM SC_EOL_CRLF}
    {$HPPEMIT '#define SC_EOL_CRLF 0'}
    SC_EOL_CR = 1;
    {$EXTERNALSYM SC_EOL_CR}
    {$HPPEMIT '#define SC_EOL_CR 1'}
    SC_EOL_LF = 2;
    {$EXTERNALSYM SC_EOL_LF}
    {$HPPEMIT '#define SC_EOL_LF 2'}
    SCI_CONVERTEOLS = 2029;
    {$EXTERNALSYM SCI_CONVERTEOLS}
    {$HPPEMIT '#define SCI_CONVERTEOLS 2029'}
    SCI_GETEOLMODE = 2030;
    {$EXTERNALSYM SCI_GETEOLMODE}
    {$HPPEMIT '#define SCI_GETEOLMODE 2030'}
    SCI_SETEOLMODE = 2031;
    {$EXTERNALSYM SCI_SETEOLMODE}
    {$HPPEMIT '#define SCI_SETEOLMODE 2031'}
    SCI_STARTSTYLING = 2032;
    {$EXTERNALSYM SCI_STARTSTYLING}
    {$HPPEMIT '#define SCI_STARTSTYLING 2032'}
    SCI_SETSTYLING = 2033;
    {$EXTERNALSYM SCI_SETSTYLING}
    {$HPPEMIT '#define SCI_SETSTYLING 2033'}
    SCI_GETBUFFEREDDRAW = 2034;
    {$EXTERNALSYM SCI_GETBUFFEREDDRAW}
    {$HPPEMIT '#define SCI_GETBUFFEREDDRAW 2034'}
    SCI_SETBUFFEREDDRAW = 2035;
    {$EXTERNALSYM SCI_SETBUFFEREDDRAW}
    {$HPPEMIT '#define SCI_SETBUFFEREDDRAW 2035'}
    SCI_SETTABWIDTH = 2036;
    {$EXTERNALSYM SCI_SETTABWIDTH}
    {$HPPEMIT '#define SCI_SETTABWIDTH 2036'}
    SCI_GETTABWIDTH = 2121;
    {$EXTERNALSYM SCI_GETTABWIDTH}
    {$HPPEMIT '#define SCI_GETTABWIDTH 2121'}
    SC_CP_UTF8 = 65001;
    {$EXTERNALSYM SC_CP_UTF8}
    {$HPPEMIT '#define SC_CP_UTF8 65001'}
    SC_CP_DBCS = 1;
    {$EXTERNALSYM SC_CP_DBCS}
    {$HPPEMIT '#define SC_CP_DBCS 1'}
    SCI_SETCODEPAGE = 2037;
    {$EXTERNALSYM SCI_SETCODEPAGE}
    {$HPPEMIT '#define SCI_SETCODEPAGE 2037'}
    SCI_SETUSEPALETTE = 2039;
    {$EXTERNALSYM SCI_SETUSEPALETTE}
    {$HPPEMIT '#define SCI_SETUSEPALETTE 2039'}
    MARKER_MAX = 31;
    {$EXTERNALSYM MARKER_MAX}
    {$HPPEMIT '#define MARKER_MAX 31'}
    SC_MARK_CIRCLE = 0;
    {$EXTERNALSYM SC_MARK_CIRCLE}
    {$HPPEMIT '#define SC_MARK_CIRCLE 0'}
    SC_MARK_ROUNDRECT = 1;
    {$EXTERNALSYM SC_MARK_ROUNDRECT}
    {$HPPEMIT '#define SC_MARK_ROUNDRECT 1'}
    SC_MARK_ARROW = 2;
    {$EXTERNALSYM SC_MARK_ARROW}
    {$HPPEMIT '#define SC_MARK_ARROW 2'}
    SC_MARK_SMALLRECT = 3;
    {$EXTERNALSYM SC_MARK_SMALLRECT}
    {$HPPEMIT '#define SC_MARK_SMALLRECT 3'}
    SC_MARK_SHORTARROW = 4;
    {$EXTERNALSYM SC_MARK_SHORTARROW}
    {$HPPEMIT '#define SC_MARK_SHORTARROW 4'}
    SC_MARK_EMPTY = 5;
    {$EXTERNALSYM SC_MARK_EMPTY}
    {$HPPEMIT '#define SC_MARK_EMPTY 5'}
    SC_MARK_ARROWDOWN = 6;
    {$EXTERNALSYM SC_MARK_ARROWDOWN}
    {$HPPEMIT '#define SC_MARK_ARROWDOWN 6'}
    SC_MARK_MINUS = 7;
    {$EXTERNALSYM SC_MARK_MINUS}
    {$HPPEMIT '#define SC_MARK_MINUS 7'}
    SC_MARK_PLUS = 8;
    {$EXTERNALSYM SC_MARK_PLUS}
    {$HPPEMIT '#define SC_MARK_PLUS 8'}
    SC_MARK_VLINE = 9;
    {$EXTERNALSYM SC_MARK_VLINE}
    {$HPPEMIT '#define SC_MARK_VLINE 9'}
    SC_MARK_LCORNER = 10;
    {$EXTERNALSYM SC_MARK_LCORNER}
    {$HPPEMIT '#define SC_MARK_LCORNER 10'}
    SC_MARK_TCORNER = 11;
    {$EXTERNALSYM SC_MARK_TCORNER}
    {$HPPEMIT '#define SC_MARK_TCORNER 11'}
    SC_MARK_BOXPLUS = 12;
    {$EXTERNALSYM SC_MARK_BOXPLUS}
    {$HPPEMIT '#define SC_MARK_BOXPLUS 12'}
    SC_MARK_BOXPLUSCONNECTED = 13;
    {$EXTERNALSYM SC_MARK_BOXPLUSCONNECTED}
    {$HPPEMIT '#define SC_MARK_BOXPLUSCONNECTED 13'}
    SC_MARK_BOXMINUS = 14;
    {$EXTERNALSYM SC_MARK_BOXMINUS}
    {$HPPEMIT '#define SC_MARK_BOXMINUS 14'}
    SC_MARK_BOXMINUSCONNECTED = 15;
    {$EXTERNALSYM SC_MARK_BOXMINUSCONNECTED}
    {$HPPEMIT '#define SC_MARK_BOXMINUSCONNECTED 15'}
    SC_MARK_LCORNERCURVE = 16;
    {$EXTERNALSYM SC_MARK_LCORNERCURVE}
    {$HPPEMIT '#define SC_MARK_LCORNERCURVE 16'}
    SC_MARK_TCORNERCURVE = 17;
    {$EXTERNALSYM SC_MARK_TCORNERCURVE}
    {$HPPEMIT '#define SC_MARK_TCORNERCURVE 17'}
    SC_MARK_CIRCLEPLUS = 18;
    {$EXTERNALSYM SC_MARK_CIRCLEPLUS}
    {$HPPEMIT '#define SC_MARK_CIRCLEPLUS 18'}
    SC_MARK_CIRCLEPLUSCONNECTED = 19;
    {$EXTERNALSYM SC_MARK_CIRCLEPLUSCONNECTED}
    {$HPPEMIT '#define SC_MARK_CIRCLEPLUSCONNECTED 19'}
    SC_MARK_CIRCLEMINUS = 20;
    {$EXTERNALSYM SC_MARK_CIRCLEMINUS}
    {$HPPEMIT '#define SC_MARK_CIRCLEMINUS 20'}
    SC_MARK_CIRCLEMINUSCONNECTED = 21;
    {$EXTERNALSYM SC_MARK_CIRCLEMINUSCONNECTED}
    {$HPPEMIT '#define SC_MARK_CIRCLEMINUSCONNECTED 21'}
    SC_MARK_BACKGROUND = 22;
    {$EXTERNALSYM SC_MARK_BACKGROUND}
    {$HPPEMIT '#define SC_MARK_BACKGROUND 22'}
    SC_MARK_DOTDOTDOT = 23;
    {$EXTERNALSYM SC_MARK_DOTDOTDOT}
    {$HPPEMIT '#define SC_MARK_DOTDOTDOT 23'}
    SC_MARK_ARROWS = 24;
    {$EXTERNALSYM SC_MARK_ARROWS}
    {$HPPEMIT '#define SC_MARK_ARROWS 24'}
    SC_MARK_PIXMAP = 25;
    {$EXTERNALSYM SC_MARK_PIXMAP}
    {$HPPEMIT '#define SC_MARK_PIXMAP 25'}
    SC_MARK_FULLRECT = 26;
    {$EXTERNALSYM SC_MARK_FULLRECT}
    {$HPPEMIT '#define SC_MARK_FULLRECT 26'}
    SC_MARK_CHARACTER = 10000;
    {$EXTERNALSYM SC_MARK_CHARACTER}
    {$HPPEMIT '#define SC_MARK_CHARACTER 10000'}
    SC_MARKNUM_FOLDEREND = 25;
    {$EXTERNALSYM SC_MARKNUM_FOLDEREND}
    {$HPPEMIT '#define SC_MARKNUM_FOLDEREND 25'}
    SC_MARKNUM_FOLDEROPENMID = 26;
    {$EXTERNALSYM SC_MARKNUM_FOLDEROPENMID}
    {$HPPEMIT '#define SC_MARKNUM_FOLDEROPENMID 26'}
    SC_MARKNUM_FOLDERMIDTAIL = 27;
    {$EXTERNALSYM SC_MARKNUM_FOLDERMIDTAIL}
    {$HPPEMIT '#define SC_MARKNUM_FOLDERMIDTAIL 27'}
    SC_MARKNUM_FOLDERTAIL = 28;
    {$EXTERNALSYM SC_MARKNUM_FOLDERTAIL}
    {$HPPEMIT '#define SC_MARKNUM_FOLDERTAIL 28'}
    SC_MARKNUM_FOLDERSUB = 29;
    {$EXTERNALSYM SC_MARKNUM_FOLDERSUB}
    {$HPPEMIT '#define SC_MARKNUM_FOLDERSUB 29'}
    SC_MARKNUM_FOLDER = 30;
    {$EXTERNALSYM SC_MARKNUM_FOLDER}
    {$HPPEMIT '#define SC_MARKNUM_FOLDER 30'}
    SC_MARKNUM_FOLDEROPEN = 31;
    {$EXTERNALSYM SC_MARKNUM_FOLDEROPEN}
    {$HPPEMIT '#define SC_MARKNUM_FOLDEROPEN 31'}
    SC_MASK_FOLDERS = $FE000000;
    {$EXTERNALSYM SC_MASK_FOLDERS}
    {$HPPEMIT '#define SC_MASK_FOLDERS 0xFE000000'}
    SCI_MARKERDEFINE = 2040;
    {$EXTERNALSYM SCI_MARKERDEFINE}
    {$HPPEMIT '#define SCI_MARKERDEFINE 2040'}
    SCI_MARKERSETFORE = 2041;
    {$EXTERNALSYM SCI_MARKERSETFORE}
    {$HPPEMIT '#define SCI_MARKERSETFORE 2041'}
    SCI_MARKERSETBACK = 2042;
    {$EXTERNALSYM SCI_MARKERSETBACK}
    {$HPPEMIT '#define SCI_MARKERSETBACK 2042'}
    SCI_MARKERADD = 2043;
    {$EXTERNALSYM SCI_MARKERADD}
    {$HPPEMIT '#define SCI_MARKERADD 2043'}
    SCI_MARKERDELETE = 2044;
    {$EXTERNALSYM SCI_MARKERDELETE}
    {$HPPEMIT '#define SCI_MARKERDELETE 2044'}
    SCI_MARKERDELETEALL = 2045;
    {$EXTERNALSYM SCI_MARKERDELETEALL}
    {$HPPEMIT '#define SCI_MARKERDELETEALL 2045'}
    SCI_MARKERGET = 2046;
    {$EXTERNALSYM SCI_MARKERGET}
    {$HPPEMIT '#define SCI_MARKERGET 2046'}
    SCI_MARKERNEXT = 2047;
    {$EXTERNALSYM SCI_MARKERNEXT}
    {$HPPEMIT '#define SCI_MARKERNEXT 2047'}
    SCI_MARKERPREVIOUS = 2048;
    {$EXTERNALSYM SCI_MARKERPREVIOUS}
    {$HPPEMIT '#define SCI_MARKERPREVIOUS 2048'}
    SCI_MARKERDEFINEPIXMAP = 2049;
    {$EXTERNALSYM SCI_MARKERDEFINEPIXMAP}
    {$HPPEMIT '#define SCI_MARKERDEFINEPIXMAP 2049'}
    SCI_MARKERADDSET = 2466;
    {$EXTERNALSYM SCI_MARKERADDSET}
    {$HPPEMIT '#define SCI_MARKERADDSET 2466'}
    SCI_MARKERSETALPHA = 2476;
    {$EXTERNALSYM SCI_MARKERSETALPHA}
    {$HPPEMIT '#define SCI_MARKERSETALPHA 2476'}
    SC_MARGIN_SYMBOL = 0;
    {$EXTERNALSYM SC_MARGIN_SYMBOL}
    {$HPPEMIT '#define SC_MARGIN_SYMBOL 0'}
    SC_MARGIN_NUMBER = 1;
    {$EXTERNALSYM SC_MARGIN_NUMBER}
    {$HPPEMIT '#define SC_MARGIN_NUMBER 1'}
    SC_MARGIN_BACK = 2;
    {$EXTERNALSYM SC_MARGIN_BACK}
    {$HPPEMIT '#define SC_MARGIN_BACK 2'}
    SC_MARGIN_FORE = 3;
    {$EXTERNALSYM SC_MARGIN_FORE}
    {$HPPEMIT '#define SC_MARGIN_FORE 3'}
    SCI_SETMARGINTYPEN = 2240;
    {$EXTERNALSYM SCI_SETMARGINTYPEN}
    {$HPPEMIT '#define SCI_SETMARGINTYPEN 2240'}
    SCI_GETMARGINTYPEN = 2241;
    {$EXTERNALSYM SCI_GETMARGINTYPEN}
    {$HPPEMIT '#define SCI_GETMARGINTYPEN 2241'}
    SCI_SETMARGINWIDTHN = 2242;
    {$EXTERNALSYM SCI_SETMARGINWIDTHN}
    {$HPPEMIT '#define SCI_SETMARGINWIDTHN 2242'}
    SCI_GETMARGINWIDTHN = 2243;
    {$EXTERNALSYM SCI_GETMARGINWIDTHN}
    {$HPPEMIT '#define SCI_GETMARGINWIDTHN 2243'}
    SCI_SETMARGINMASKN = 2244;
    {$EXTERNALSYM SCI_SETMARGINMASKN}
    {$HPPEMIT '#define SCI_SETMARGINMASKN 2244'}
    SCI_GETMARGINMASKN = 2245;
    {$EXTERNALSYM SCI_GETMARGINMASKN}
    {$HPPEMIT '#define SCI_GETMARGINMASKN 2245'}
    SCI_SETMARGINSENSITIVEN = 2246;
    {$EXTERNALSYM SCI_SETMARGINSENSITIVEN}
    {$HPPEMIT '#define SCI_SETMARGINSENSITIVEN 2246'}
    SCI_GETMARGINSENSITIVEN = 2247;
    {$EXTERNALSYM SCI_GETMARGINSENSITIVEN}
    {$HPPEMIT '#define SCI_GETMARGINSENSITIVEN 2247'}
    STYLE_DEFAULT = 32;
    {$EXTERNALSYM STYLE_DEFAULT}
    {$HPPEMIT '#define STYLE_DEFAULT 32'}
    STYLE_LINENUMBER = 33;
    {$EXTERNALSYM STYLE_LINENUMBER}
    {$HPPEMIT '#define STYLE_LINENUMBER 33'}
    STYLE_BRACELIGHT = 34;
    {$EXTERNALSYM STYLE_BRACELIGHT}
    {$HPPEMIT '#define STYLE_BRACELIGHT 34'}
    STYLE_BRACEBAD = 35;
    {$EXTERNALSYM STYLE_BRACEBAD}
    {$HPPEMIT '#define STYLE_BRACEBAD 35'}
    STYLE_CONTROLCHAR = 36;
    {$EXTERNALSYM STYLE_CONTROLCHAR}
    {$HPPEMIT '#define STYLE_CONTROLCHAR 36'}
    STYLE_INDENTGUIDE = 37;
    {$EXTERNALSYM STYLE_INDENTGUIDE}
    {$HPPEMIT '#define STYLE_INDENTGUIDE 37'}
    STYLE_CALLTIP = 38;
    {$EXTERNALSYM STYLE_CALLTIP}
    {$HPPEMIT '#define STYLE_CALLTIP 38'}
    STYLE_LASTPREDEFINED = 39;
    {$EXTERNALSYM STYLE_LASTPREDEFINED}
    {$HPPEMIT '#define STYLE_LASTPREDEFINED 39'}
    STYLE_MAX = 127;
    {$EXTERNALSYM STYLE_MAX}
    {$HPPEMIT '#define STYLE_MAX 127'}
    SC_CHARSET_ANSI = 0;
    {$EXTERNALSYM SC_CHARSET_ANSI}
    {$HPPEMIT '#define SC_CHARSET_ANSI 0'}
    SC_CHARSET_DEFAULT = 1;
    {$EXTERNALSYM SC_CHARSET_DEFAULT}
    {$HPPEMIT '#define SC_CHARSET_DEFAULT 1'}
    SC_CHARSET_BALTIC = 186;
    {$EXTERNALSYM SC_CHARSET_BALTIC}
    {$HPPEMIT '#define SC_CHARSET_BALTIC 186'}
    SC_CHARSET_CHINESEBIG5 = 136;
    {$EXTERNALSYM SC_CHARSET_CHINESEBIG5}
    {$HPPEMIT '#define SC_CHARSET_CHINESEBIG5 136'}
    SC_CHARSET_EASTEUROPE = 238;
    {$EXTERNALSYM SC_CHARSET_EASTEUROPE}
    {$HPPEMIT '#define SC_CHARSET_EASTEUROPE 238'}
    SC_CHARSET_GB2312 = 134;
    {$EXTERNALSYM SC_CHARSET_GB2312}
    {$HPPEMIT '#define SC_CHARSET_GB2312 134'}
    SC_CHARSET_GREEK = 161;
    {$EXTERNALSYM SC_CHARSET_GREEK}
    {$HPPEMIT '#define SC_CHARSET_GREEK 161'}
    SC_CHARSET_HANGUL = 129;
    {$EXTERNALSYM SC_CHARSET_HANGUL}
    {$HPPEMIT '#define SC_CHARSET_HANGUL 129'}
    SC_CHARSET_MAC = 77;
    {$EXTERNALSYM SC_CHARSET_MAC}
    {$HPPEMIT '#define SC_CHARSET_MAC 77'}
    SC_CHARSET_OEM = 255;
    {$EXTERNALSYM SC_CHARSET_OEM}
    {$HPPEMIT '#define SC_CHARSET_OEM 255'}
    SC_CHARSET_RUSSIAN = 204;
    {$EXTERNALSYM SC_CHARSET_RUSSIAN}
    {$HPPEMIT '#define SC_CHARSET_RUSSIAN 204'}
    SC_CHARSET_CYRILLIC = 1251;
    {$EXTERNALSYM SC_CHARSET_CYRILLIC}
    {$HPPEMIT '#define SC_CHARSET_CYRILLIC 1251'}
    SC_CHARSET_SHIFTJIS = 128;
    {$EXTERNALSYM SC_CHARSET_SHIFTJIS}
    {$HPPEMIT '#define SC_CHARSET_SHIFTJIS 128'}
    SC_CHARSET_SYMBOL = 2;
    {$EXTERNALSYM SC_CHARSET_SYMBOL}
    {$HPPEMIT '#define SC_CHARSET_SYMBOL 2'}
    SC_CHARSET_TURKISH = 162;
    {$EXTERNALSYM SC_CHARSET_TURKISH}
    {$HPPEMIT '#define SC_CHARSET_TURKISH 162'}
    SC_CHARSET_JOHAB = 130;
    {$EXTERNALSYM SC_CHARSET_JOHAB}
    {$HPPEMIT '#define SC_CHARSET_JOHAB 130'}
    SC_CHARSET_HEBREW = 177;
    {$EXTERNALSYM SC_CHARSET_HEBREW}
    {$HPPEMIT '#define SC_CHARSET_HEBREW 177'}
    SC_CHARSET_ARABIC = 178;
    {$EXTERNALSYM SC_CHARSET_ARABIC}
    {$HPPEMIT '#define SC_CHARSET_ARABIC 178'}
    SC_CHARSET_VIETNAMESE = 163;
    {$EXTERNALSYM SC_CHARSET_VIETNAMESE}
    {$HPPEMIT '#define SC_CHARSET_VIETNAMESE 163'}
    SC_CHARSET_THAI = 222;
    {$EXTERNALSYM SC_CHARSET_THAI}
    {$HPPEMIT '#define SC_CHARSET_THAI 222'}
    SC_CHARSET_8859_15 = 1000;
    {$EXTERNALSYM SC_CHARSET_8859_15}
    {$HPPEMIT '#define SC_CHARSET_8859_15 1000'}
    SCI_STYLECLEARALL = 2050;
    {$EXTERNALSYM SCI_STYLECLEARALL}
    {$HPPEMIT '#define SCI_STYLECLEARALL 2050'}
    SCI_STYLESETFORE = 2051;
    {$EXTERNALSYM SCI_STYLESETFORE}
    {$HPPEMIT '#define SCI_STYLESETFORE 2051'}
    SCI_STYLESETBACK = 2052;
    {$EXTERNALSYM SCI_STYLESETBACK}
    {$HPPEMIT '#define SCI_STYLESETBACK 2052'}
    SCI_STYLESETBOLD = 2053;
    {$EXTERNALSYM SCI_STYLESETBOLD}
    {$HPPEMIT '#define SCI_STYLESETBOLD 2053'}
    SCI_STYLESETITALIC = 2054;
    {$EXTERNALSYM SCI_STYLESETITALIC}
    {$HPPEMIT '#define SCI_STYLESETITALIC 2054'}
    SCI_STYLESETSIZE = 2055;
    {$EXTERNALSYM SCI_STYLESETSIZE}
    {$HPPEMIT '#define SCI_STYLESETSIZE 2055'}
    SCI_STYLESETFONT = 2056;
    {$EXTERNALSYM SCI_STYLESETFONT}
    {$HPPEMIT '#define SCI_STYLESETFONT 2056'}
    SCI_STYLESETEOLFILLED = 2057;
    {$EXTERNALSYM SCI_STYLESETEOLFILLED}
    {$HPPEMIT '#define SCI_STYLESETEOLFILLED 2057'}
    SCI_STYLERESETDEFAULT = 2058;
    {$EXTERNALSYM SCI_STYLERESETDEFAULT}
    {$HPPEMIT '#define SCI_STYLERESETDEFAULT 2058'}
    SCI_STYLESETUNDERLINE = 2059;
    {$EXTERNALSYM SCI_STYLESETUNDERLINE}
    {$HPPEMIT '#define SCI_STYLESETUNDERLINE 2059'}
    SC_CASE_MIXED = 0;
    {$EXTERNALSYM SC_CASE_MIXED}
    {$HPPEMIT '#define SC_CASE_MIXED 0'}
    SC_CASE_UPPER = 1;
    {$EXTERNALSYM SC_CASE_UPPER}
    {$HPPEMIT '#define SC_CASE_UPPER 1'}
    SC_CASE_LOWER = 2;
    {$EXTERNALSYM SC_CASE_LOWER}
    {$HPPEMIT '#define SC_CASE_LOWER 2'}
    SCI_STYLESETCASE = 2060;
    {$EXTERNALSYM SCI_STYLESETCASE}
    {$HPPEMIT '#define SCI_STYLESETCASE 2060'}
    SCI_STYLESETCHARACTERSET = 2066;
    {$EXTERNALSYM SCI_STYLESETCHARACTERSET}
    {$HPPEMIT '#define SCI_STYLESETCHARACTERSET 2066'}
    SCI_STYLESETHOTSPOT = 2409;
    {$EXTERNALSYM SCI_STYLESETHOTSPOT}
    {$HPPEMIT '#define SCI_STYLESETHOTSPOT 2409'}
    SCI_SETSELFORE = 2067;
    {$EXTERNALSYM SCI_SETSELFORE}
    {$HPPEMIT '#define SCI_SETSELFORE 2067'}
    SCI_SETSELBACK = 2068;
    {$EXTERNALSYM SCI_SETSELBACK}
    {$HPPEMIT '#define SCI_SETSELBACK 2068'}
    SCI_GETSELALPHA = 2477;
    {$EXTERNALSYM SCI_GETSELALPHA}
    {$HPPEMIT '#define SCI_GETSELALPHA 2477'}
    SCI_SETSELALPHA = 2478;
    {$EXTERNALSYM SCI_SETSELALPHA}
    {$HPPEMIT '#define SCI_SETSELALPHA 2478'}
    SCI_SETCARETFORE = 2069;
    {$EXTERNALSYM SCI_SETCARETFORE}
    {$HPPEMIT '#define SCI_SETCARETFORE 2069'}
    SCI_ASSIGNCMDKEY = 2070;
    {$EXTERNALSYM SCI_ASSIGNCMDKEY}
    {$HPPEMIT '#define SCI_ASSIGNCMDKEY 2070'}
    SCI_CLEARCMDKEY = 2071;
    {$EXTERNALSYM SCI_CLEARCMDKEY}
    {$HPPEMIT '#define SCI_CLEARCMDKEY 2071'}
    SCI_CLEARALLCMDKEYS = 2072;
    {$EXTERNALSYM SCI_CLEARALLCMDKEYS}
    {$HPPEMIT '#define SCI_CLEARALLCMDKEYS 2072'}
    SCI_SETSTYLINGEX = 2073;
    {$EXTERNALSYM SCI_SETSTYLINGEX}
    {$HPPEMIT '#define SCI_SETSTYLINGEX 2073'}
    SCI_STYLESETVISIBLE = 2074;
    {$EXTERNALSYM SCI_STYLESETVISIBLE}
    {$HPPEMIT '#define SCI_STYLESETVISIBLE 2074'}
    SCI_GETCARETPERIOD = 2075;
    {$EXTERNALSYM SCI_GETCARETPERIOD}
    {$HPPEMIT '#define SCI_GETCARETPERIOD 2075'}
    SCI_SETCARETPERIOD = 2076;
    {$EXTERNALSYM SCI_SETCARETPERIOD}
    {$HPPEMIT '#define SCI_SETCARETPERIOD 2076'}
    SCI_SETWORDCHARS = 2077;
    {$EXTERNALSYM SCI_SETWORDCHARS}
    {$HPPEMIT '#define SCI_SETWORDCHARS 2077'}
    SCI_BEGINUNDOACTION = 2078;
    {$EXTERNALSYM SCI_BEGINUNDOACTION}
    {$HPPEMIT '#define SCI_BEGINUNDOACTION 2078'}
    SCI_ENDUNDOACTION = 2079;
    {$EXTERNALSYM SCI_ENDUNDOACTION}
    {$HPPEMIT '#define SCI_ENDUNDOACTION 2079'}
    INDIC_MAX = 7;
    {$EXTERNALSYM INDIC_MAX}
    {$HPPEMIT '#define INDIC_MAX 7'}
    INDIC_PLAIN = 0;
    {$EXTERNALSYM INDIC_PLAIN}
    {$HPPEMIT '#define INDIC_PLAIN 0'}
    INDIC_SQUIGGLE = 1;
    {$EXTERNALSYM INDIC_SQUIGGLE}
    {$HPPEMIT '#define INDIC_SQUIGGLE 1'}
    INDIC_TT = 2;
    {$EXTERNALSYM INDIC_TT}
    {$HPPEMIT '#define INDIC_TT 2'}
    INDIC_DIAGONAL = 3;
    {$EXTERNALSYM INDIC_DIAGONAL}
    {$HPPEMIT '#define INDIC_DIAGONAL 3'}
    INDIC_STRIKE = 4;
    {$EXTERNALSYM INDIC_STRIKE}
    {$HPPEMIT '#define INDIC_STRIKE 4'}
    INDIC_HIDDEN = 5;
    {$EXTERNALSYM INDIC_HIDDEN}
    {$HPPEMIT '#define INDIC_HIDDEN 5'}
    INDIC_BOX = 6;
    {$EXTERNALSYM INDIC_BOX}
    {$HPPEMIT '#define INDIC_BOX 6'}
    INDIC_ROUNDBOX = 7;
    {$EXTERNALSYM INDIC_ROUNDBOX}
    {$HPPEMIT '#define INDIC_ROUNDBOX 7'}
    INDIC0_MASK = $20;
    {$EXTERNALSYM INDIC0_MASK}
    {$HPPEMIT '#define INDIC0_MASK 0x20'}
    INDIC1_MASK = $40;
    {$EXTERNALSYM INDIC1_MASK}
    {$HPPEMIT '#define INDIC1_MASK 0x40'}
    INDIC2_MASK = $80;
    {$EXTERNALSYM INDIC2_MASK}
    {$HPPEMIT '#define INDIC2_MASK 0x80'}
    INDICS_MASK = $E0;
    {$EXTERNALSYM INDICS_MASK}
    {$HPPEMIT '#define INDICS_MASK 0xE0'}
    SCI_INDICSETSTYLE = 2080;
    {$EXTERNALSYM SCI_INDICSETSTYLE}
    {$HPPEMIT '#define SCI_INDICSETSTYLE 2080'}
    SCI_INDICGETSTYLE = 2081;
    {$EXTERNALSYM SCI_INDICGETSTYLE}
    {$HPPEMIT '#define SCI_INDICGETSTYLE 2081'}
    SCI_INDICSETFORE = 2082;
    {$EXTERNALSYM SCI_INDICSETFORE}
    {$HPPEMIT '#define SCI_INDICSETFORE 2082'}
    SCI_INDICGETFORE = 2083;
    {$EXTERNALSYM SCI_INDICGETFORE}
    {$HPPEMIT '#define SCI_INDICGETFORE 2083'}
    SCI_SETWHITESPACEFORE = 2084;
    {$EXTERNALSYM SCI_SETWHITESPACEFORE}
    {$HPPEMIT '#define SCI_SETWHITESPACEFORE 2084'}
    SCI_SETWHITESPACEBACK = 2085;
    {$EXTERNALSYM SCI_SETWHITESPACEBACK}
    {$HPPEMIT '#define SCI_SETWHITESPACEBACK 2085'}
    SCI_SETSTYLEBITS = 2090;
    {$EXTERNALSYM SCI_SETSTYLEBITS}
    {$HPPEMIT '#define SCI_SETSTYLEBITS 2090'}
    SCI_GETSTYLEBITS = 2091;
    {$EXTERNALSYM SCI_GETSTYLEBITS}
    {$HPPEMIT '#define SCI_GETSTYLEBITS 2091'}
    SCI_SETLINESTATE = 2092;
    {$EXTERNALSYM SCI_SETLINESTATE}
    {$HPPEMIT '#define SCI_SETLINESTATE 2092'}
    SCI_GETLINESTATE = 2093;
    {$EXTERNALSYM SCI_GETLINESTATE}
    {$HPPEMIT '#define SCI_GETLINESTATE 2093'}
    SCI_GETMAXLINESTATE = 2094;
    {$EXTERNALSYM SCI_GETMAXLINESTATE}
    {$HPPEMIT '#define SCI_GETMAXLINESTATE 2094'}
    SCI_GETCARETLINEVISIBLE = 2095;
    {$EXTERNALSYM SCI_GETCARETLINEVISIBLE}
    {$HPPEMIT '#define SCI_GETCARETLINEVISIBLE 2095'}
    SCI_SETCARETLINEVISIBLE = 2096;
    {$EXTERNALSYM SCI_SETCARETLINEVISIBLE}
    {$HPPEMIT '#define SCI_SETCARETLINEVISIBLE 2096'}
    SCI_GETCARETLINEBACK = 2097;
    {$EXTERNALSYM SCI_GETCARETLINEBACK}
    {$HPPEMIT '#define SCI_GETCARETLINEBACK 2097'}
    SCI_SETCARETLINEBACK = 2098;
    {$EXTERNALSYM SCI_SETCARETLINEBACK}
    {$HPPEMIT '#define SCI_SETCARETLINEBACK 2098'}
    SCI_STYLESETCHANGEABLE = 2099;
    {$EXTERNALSYM SCI_STYLESETCHANGEABLE}
    {$HPPEMIT '#define SCI_STYLESETCHANGEABLE 2099'}
    SCI_AUTOCSHOW = 2100;
    {$EXTERNALSYM SCI_AUTOCSHOW}
    {$HPPEMIT '#define SCI_AUTOCSHOW 2100'}
    SCI_AUTOCCANCEL = 2101;
    {$EXTERNALSYM SCI_AUTOCCANCEL}
    {$HPPEMIT '#define SCI_AUTOCCANCEL 2101'}
    SCI_AUTOCACTIVE = 2102;
    {$EXTERNALSYM SCI_AUTOCACTIVE}
    {$HPPEMIT '#define SCI_AUTOCACTIVE 2102'}
    SCI_AUTOCPOSSTART = 2103;
    {$EXTERNALSYM SCI_AUTOCPOSSTART}
    {$HPPEMIT '#define SCI_AUTOCPOSSTART 2103'}
    SCI_AUTOCCOMPLETE = 2104;
    {$EXTERNALSYM SCI_AUTOCCOMPLETE}
    {$HPPEMIT '#define SCI_AUTOCCOMPLETE 2104'}
    SCI_AUTOCSTOPS = 2105;
    {$EXTERNALSYM SCI_AUTOCSTOPS}
    {$HPPEMIT '#define SCI_AUTOCSTOPS 2105'}
    SCI_AUTOCSETSEPARATOR = 2106;
    {$EXTERNALSYM SCI_AUTOCSETSEPARATOR}
    {$HPPEMIT '#define SCI_AUTOCSETSEPARATOR 2106'}
    SCI_AUTOCGETSEPARATOR = 2107;
    {$EXTERNALSYM SCI_AUTOCGETSEPARATOR}
    {$HPPEMIT '#define SCI_AUTOCGETSEPARATOR 2107'}
    SCI_AUTOCSELECT = 2108;
    {$EXTERNALSYM SCI_AUTOCSELECT}
    {$HPPEMIT '#define SCI_AUTOCSELECT 2108'}
    SCI_AUTOCSETCANCELATSTART = 2110;
    {$EXTERNALSYM SCI_AUTOCSETCANCELATSTART}
    {$HPPEMIT '#define SCI_AUTOCSETCANCELATSTART 2110'}
    SCI_AUTOCGETCANCELATSTART = 2111;
    {$EXTERNALSYM SCI_AUTOCGETCANCELATSTART}
    {$HPPEMIT '#define SCI_AUTOCGETCANCELATSTART 2111'}
    SCI_AUTOCSETFILLUPS = 2112;
    {$EXTERNALSYM SCI_AUTOCSETFILLUPS}
    {$HPPEMIT '#define SCI_AUTOCSETFILLUPS 2112'}
    SCI_AUTOCSETCHOOSESINGLE = 2113;
    {$EXTERNALSYM SCI_AUTOCSETCHOOSESINGLE}
    {$HPPEMIT '#define SCI_AUTOCSETCHOOSESINGLE 2113'}
    SCI_AUTOCGETCHOOSESINGLE = 2114;
    {$EXTERNALSYM SCI_AUTOCGETCHOOSESINGLE}
    {$HPPEMIT '#define SCI_AUTOCGETCHOOSESINGLE 2114'}
    SCI_AUTOCSETIGNORECASE = 2115;
    {$EXTERNALSYM SCI_AUTOCSETIGNORECASE}
    {$HPPEMIT '#define SCI_AUTOCSETIGNORECASE 2115'}
    SCI_AUTOCGETIGNORECASE = 2116;
    {$EXTERNALSYM SCI_AUTOCGETIGNORECASE}
    {$HPPEMIT '#define SCI_AUTOCGETIGNORECASE 2116'}
    SCI_USERLISTSHOW = 2117;
    {$EXTERNALSYM SCI_USERLISTSHOW}
    {$HPPEMIT '#define SCI_USERLISTSHOW 2117'}
    SCI_AUTOCSETAUTOHIDE = 2118;
    {$EXTERNALSYM SCI_AUTOCSETAUTOHIDE}
    {$HPPEMIT '#define SCI_AUTOCSETAUTOHIDE 2118'}
    SCI_AUTOCGETAUTOHIDE = 2119;
    {$EXTERNALSYM SCI_AUTOCGETAUTOHIDE}
    {$HPPEMIT '#define SCI_AUTOCGETAUTOHIDE 2119'}
    SCI_AUTOCSETDROPRESTOFWORD = 2270;
    {$EXTERNALSYM SCI_AUTOCSETDROPRESTOFWORD}
    {$HPPEMIT '#define SCI_AUTOCSETDROPRESTOFWORD 2270'}
    SCI_AUTOCGETDROPRESTOFWORD = 2271;
    {$EXTERNALSYM SCI_AUTOCGETDROPRESTOFWORD}
    {$HPPEMIT '#define SCI_AUTOCGETDROPRESTOFWORD 2271'}
    SCI_REGISTERIMAGE = 2405;
    {$EXTERNALSYM SCI_REGISTERIMAGE}
    {$HPPEMIT '#define SCI_REGISTERIMAGE 2405'}
    SCI_CLEARREGISTEREDIMAGES = 2408;
    {$EXTERNALSYM SCI_CLEARREGISTEREDIMAGES}
    {$HPPEMIT '#define SCI_CLEARREGISTEREDIMAGES 2408'}
    SCI_AUTOCGETTYPESEPARATOR = 2285;
    {$EXTERNALSYM SCI_AUTOCGETTYPESEPARATOR}
    {$HPPEMIT '#define SCI_AUTOCGETTYPESEPARATOR 2285'}
    SCI_AUTOCSETTYPESEPARATOR = 2286;
    {$EXTERNALSYM SCI_AUTOCSETTYPESEPARATOR}
    {$HPPEMIT '#define SCI_AUTOCSETTYPESEPARATOR 2286'}
    SCI_AUTOCSETMAXWIDTH = 2208;
    {$EXTERNALSYM SCI_AUTOCSETMAXWIDTH}
    {$HPPEMIT '#define SCI_AUTOCSETMAXWIDTH 2208'}
    SCI_AUTOCGETMAXWIDTH = 2209;
    {$EXTERNALSYM SCI_AUTOCGETMAXWIDTH}
    {$HPPEMIT '#define SCI_AUTOCGETMAXWIDTH 2209'}
    SCI_AUTOCSETMAXHEIGHT = 2210;
    {$EXTERNALSYM SCI_AUTOCSETMAXHEIGHT}
    {$HPPEMIT '#define SCI_AUTOCSETMAXHEIGHT 2210'}
    SCI_AUTOCGETMAXHEIGHT = 2211;
    {$EXTERNALSYM SCI_AUTOCGETMAXHEIGHT}
    {$HPPEMIT '#define SCI_AUTOCGETMAXHEIGHT 2211'}
    SCI_SETINDENT = 2122;
    {$EXTERNALSYM SCI_SETINDENT}
    {$HPPEMIT '#define SCI_SETINDENT 2122'}
    SCI_GETINDENT = 2123;
    {$EXTERNALSYM SCI_GETINDENT}
    {$HPPEMIT '#define SCI_GETINDENT 2123'}
    SCI_SETUSETABS = 2124;
    {$EXTERNALSYM SCI_SETUSETABS}
    {$HPPEMIT '#define SCI_SETUSETABS 2124'}
    SCI_GETUSETABS = 2125;
    {$EXTERNALSYM SCI_GETUSETABS}
    {$HPPEMIT '#define SCI_GETUSETABS 2125'}
    SCI_SETLINEINDENTATION = 2126;
    {$EXTERNALSYM SCI_SETLINEINDENTATION}
    {$HPPEMIT '#define SCI_SETLINEINDENTATION 2126'}
    SCI_GETLINEINDENTATION = 2127;
    {$EXTERNALSYM SCI_GETLINEINDENTATION}
    {$HPPEMIT '#define SCI_GETLINEINDENTATION 2127'}
    SCI_GETLINEINDENTPOSITION = 2128;
    {$EXTERNALSYM SCI_GETLINEINDENTPOSITION}
    {$HPPEMIT '#define SCI_GETLINEINDENTPOSITION 2128'}
    SCI_GETCOLUMN = 2129;
    {$EXTERNALSYM SCI_GETCOLUMN}
    {$HPPEMIT '#define SCI_GETCOLUMN 2129'}
    SCI_SETHSCROLLBAR = 2130;
    {$EXTERNALSYM SCI_SETHSCROLLBAR}
    {$HPPEMIT '#define SCI_SETHSCROLLBAR 2130'}
    SCI_GETHSCROLLBAR = 2131;
    {$EXTERNALSYM SCI_GETHSCROLLBAR}
    {$HPPEMIT '#define SCI_GETHSCROLLBAR 2131'}
    SCI_SETINDENTATIONGUIDES = 2132;
    {$EXTERNALSYM SCI_SETINDENTATIONGUIDES}
    {$HPPEMIT '#define SCI_SETINDENTATIONGUIDES 2132'}
    SCI_GETINDENTATIONGUIDES = 2133;
    {$EXTERNALSYM SCI_GETINDENTATIONGUIDES}
    {$HPPEMIT '#define SCI_GETINDENTATIONGUIDES 2133'}
    SCI_SETHIGHLIGHTGUIDE = 2134;
    {$EXTERNALSYM SCI_SETHIGHLIGHTGUIDE}
    {$HPPEMIT '#define SCI_SETHIGHLIGHTGUIDE 2134'}
    SCI_GETHIGHLIGHTGUIDE = 2135;
    {$EXTERNALSYM SCI_GETHIGHLIGHTGUIDE}
    {$HPPEMIT '#define SCI_GETHIGHLIGHTGUIDE 2135'}
    SCI_GETLINEENDPOSITION = 2136;
    {$EXTERNALSYM SCI_GETLINEENDPOSITION}
    {$HPPEMIT '#define SCI_GETLINEENDPOSITION 2136'}
    SCI_GETCODEPAGE = 2137;
    {$EXTERNALSYM SCI_GETCODEPAGE}
    {$HPPEMIT '#define SCI_GETCODEPAGE 2137'}
    SCI_GETCARETFORE = 2138;
    {$EXTERNALSYM SCI_GETCARETFORE}
    {$HPPEMIT '#define SCI_GETCARETFORE 2138'}
    SCI_GETUSEPALETTE = 2139;
    {$EXTERNALSYM SCI_GETUSEPALETTE}
    {$HPPEMIT '#define SCI_GETUSEPALETTE 2139'}
    SCI_GETREADONLY = 2140;
    {$EXTERNALSYM SCI_GETREADONLY}
    {$HPPEMIT '#define SCI_GETREADONLY 2140'}
    SCI_SETCURRENTPOS = 2141;
    {$EXTERNALSYM SCI_SETCURRENTPOS}
    {$HPPEMIT '#define SCI_SETCURRENTPOS 2141'}
    SCI_SETSELECTIONSTART = 2142;
    {$EXTERNALSYM SCI_SETSELECTIONSTART}
    {$HPPEMIT '#define SCI_SETSELECTIONSTART 2142'}
    SCI_GETSELECTIONSTART = 2143;
    {$EXTERNALSYM SCI_GETSELECTIONSTART}
    {$HPPEMIT '#define SCI_GETSELECTIONSTART 2143'}
    SCI_SETSELECTIONEND = 2144;
    {$EXTERNALSYM SCI_SETSELECTIONEND}
    {$HPPEMIT '#define SCI_SETSELECTIONEND 2144'}
    SCI_GETSELECTIONEND = 2145;
    {$EXTERNALSYM SCI_GETSELECTIONEND}
    {$HPPEMIT '#define SCI_GETSELECTIONEND 2145'}
    SCI_SETPRINTMAGNIFICATION = 2146;
    {$EXTERNALSYM SCI_SETPRINTMAGNIFICATION}
    {$HPPEMIT '#define SCI_SETPRINTMAGNIFICATION 2146'}
    SCI_GETPRINTMAGNIFICATION = 2147;
    {$EXTERNALSYM SCI_GETPRINTMAGNIFICATION}
    {$HPPEMIT '#define SCI_GETPRINTMAGNIFICATION 2147'}
    SC_PRINT_NORMAL = 0;
    {$EXTERNALSYM SC_PRINT_NORMAL}
    {$HPPEMIT '#define SC_PRINT_NORMAL 0'}
    SC_PRINT_INVERTLIGHT = 1;
    {$EXTERNALSYM SC_PRINT_INVERTLIGHT}
    {$HPPEMIT '#define SC_PRINT_INVERTLIGHT 1'}
    SC_PRINT_BLACKONWHITE = 2;
    {$EXTERNALSYM SC_PRINT_BLACKONWHITE}
    {$HPPEMIT '#define SC_PRINT_BLACKONWHITE 2'}
    SC_PRINT_COLOURONWHITE = 3;
    {$EXTERNALSYM SC_PRINT_COLOURONWHITE}
    {$HPPEMIT '#define SC_PRINT_COLOURONWHITE 3'}
    SC_PRINT_COLOURONWHITEDEFAULTBG = 4;
    {$EXTERNALSYM SC_PRINT_COLOURONWHITEDEFAULTBG}
    {$HPPEMIT '#define SC_PRINT_COLOURONWHITEDEFAULTBG 4'}
    SCI_SETPRINTCOLOURMODE = 2148;
    {$EXTERNALSYM SCI_SETPRINTCOLOURMODE}
    {$HPPEMIT '#define SCI_SETPRINTCOLOURMODE 2148'}
    SCI_GETPRINTCOLOURMODE = 2149;
    {$EXTERNALSYM SCI_GETPRINTCOLOURMODE}
    {$HPPEMIT '#define SCI_GETPRINTCOLOURMODE 2149'}
    SCFIND_WHOLEWORD = 2;
    {$EXTERNALSYM SCFIND_WHOLEWORD}
    {$HPPEMIT '#define SCFIND_WHOLEWORD 2'}
    SCFIND_MATCHCASE = 4;
    {$EXTERNALSYM SCFIND_MATCHCASE}
    {$HPPEMIT '#define SCFIND_MATCHCASE 4'}
    SCFIND_WORDSTART = $00100000;
    {$EXTERNALSYM SCFIND_WORDSTART}
    {$HPPEMIT '#define SCFIND_WORDSTART 0x00100000'}
    SCFIND_REGEXP = $00200000;
    {$EXTERNALSYM SCFIND_REGEXP}
    {$HPPEMIT '#define SCFIND_REGEXP 0x00200000'}
    SCFIND_POSIX = $00400000;
    {$EXTERNALSYM SCFIND_POSIX}
    {$HPPEMIT '#define SCFIND_POSIX 0x00400000'}
    SCI_FINDTEXT = 2150;
    {$EXTERNALSYM SCI_FINDTEXT}
    {$HPPEMIT '#define SCI_FINDTEXT 2150'}
    SCI_FORMATRANGE = 2151;
    {$EXTERNALSYM SCI_FORMATRANGE}
    {$HPPEMIT '#define SCI_FORMATRANGE 2151'}
    SCI_GETFIRSTVISIBLELINE = 2152;
    {$EXTERNALSYM SCI_GETFIRSTVISIBLELINE}
    {$HPPEMIT '#define SCI_GETFIRSTVISIBLELINE 2152'}
    SCI_GETLINE = 2153;
    {$EXTERNALSYM SCI_GETLINE}
    {$HPPEMIT '#define SCI_GETLINE 2153'}
    SCI_GETLINECOUNT = 2154;
    {$EXTERNALSYM SCI_GETLINECOUNT}
    {$HPPEMIT '#define SCI_GETLINECOUNT 2154'}
    SCI_SETMARGINLEFT = 2155;
    {$EXTERNALSYM SCI_SETMARGINLEFT}
    {$HPPEMIT '#define SCI_SETMARGINLEFT 2155'}
    SCI_GETMARGINLEFT = 2156;
    {$EXTERNALSYM SCI_GETMARGINLEFT}
    {$HPPEMIT '#define SCI_GETMARGINLEFT 2156'}
    SCI_SETMARGINRIGHT = 2157;
    {$EXTERNALSYM SCI_SETMARGINRIGHT}
    {$HPPEMIT '#define SCI_SETMARGINRIGHT 2157'}
    SCI_GETMARGINRIGHT = 2158;
    {$EXTERNALSYM SCI_GETMARGINRIGHT}
    {$HPPEMIT '#define SCI_GETMARGINRIGHT 2158'}
    SCI_GETMODIFY = 2159;
    {$EXTERNALSYM SCI_GETMODIFY}
    {$HPPEMIT '#define SCI_GETMODIFY 2159'}
    SCI_SETSEL = 2160;
    {$EXTERNALSYM SCI_SETSEL}
    {$HPPEMIT '#define SCI_SETSEL 2160'}
    SCI_GETSELTEXT = 2161;
    {$EXTERNALSYM SCI_GETSELTEXT}
    {$HPPEMIT '#define SCI_GETSELTEXT 2161'}
    SCI_GETTEXTRANGE = 2162;
    {$EXTERNALSYM SCI_GETTEXTRANGE}
    {$HPPEMIT '#define SCI_GETTEXTRANGE 2162'}
    SCI_HIDESELECTION = 2163;
    {$EXTERNALSYM SCI_HIDESELECTION}
    {$HPPEMIT '#define SCI_HIDESELECTION 2163'}
    SCI_POINTXFROMPOSITION = 2164;
    {$EXTERNALSYM SCI_POINTXFROMPOSITION}
    {$HPPEMIT '#define SCI_POINTXFROMPOSITION 2164'}
    SCI_POINTYFROMPOSITION = 2165;
    {$EXTERNALSYM SCI_POINTYFROMPOSITION}
    {$HPPEMIT '#define SCI_POINTYFROMPOSITION 2165'}
    SCI_LINEFROMPOSITION = 2166;
    {$EXTERNALSYM SCI_LINEFROMPOSITION}
    {$HPPEMIT '#define SCI_LINEFROMPOSITION 2166'}
    SCI_POSITIONFROMLINE = 2167;
    {$EXTERNALSYM SCI_POSITIONFROMLINE}
    {$HPPEMIT '#define SCI_POSITIONFROMLINE 2167'}
    SCI_LINESCROLL = 2168;
    {$EXTERNALSYM SCI_LINESCROLL}
    {$HPPEMIT '#define SCI_LINESCROLL 2168'}
    SCI_SCROLLCARET = 2169;
    {$EXTERNALSYM SCI_SCROLLCARET}
    {$HPPEMIT '#define SCI_SCROLLCARET 2169'}
    SCI_REPLACESEL = 2170;
    {$EXTERNALSYM SCI_REPLACESEL}
    {$HPPEMIT '#define SCI_REPLACESEL 2170'}
    SCI_SETREADONLY = 2171;
    {$EXTERNALSYM SCI_SETREADONLY}
    {$HPPEMIT '#define SCI_SETREADONLY 2171'}
    SCI_NULL = 2172;
    {$EXTERNALSYM SCI_NULL}
    {$HPPEMIT '#define SCI_NULL 2172'}
    SCI_CANPASTE = 2173;
    {$EXTERNALSYM SCI_CANPASTE}
    {$HPPEMIT '#define SCI_CANPASTE 2173'}
    SCI_CANUNDO = 2174;
    {$EXTERNALSYM SCI_CANUNDO}
    {$HPPEMIT '#define SCI_CANUNDO 2174'}
    SCI_EMPTYUNDOBUFFER = 2175;
    {$EXTERNALSYM SCI_EMPTYUNDOBUFFER}
    {$HPPEMIT '#define SCI_EMPTYUNDOBUFFER 2175'}
    SCI_UNDO = 2176;
    {$EXTERNALSYM SCI_UNDO}
    {$HPPEMIT '#define SCI_UNDO 2176'}
    SCI_CUT = 2177;
    {$EXTERNALSYM SCI_CUT}
    {$HPPEMIT '#define SCI_CUT 2177'}
    SCI_COPY = 2178;
    {$EXTERNALSYM SCI_COPY}
    {$HPPEMIT '#define SCI_COPY 2178'}
    SCI_PASTE = 2179;
    {$EXTERNALSYM SCI_PASTE}
    {$HPPEMIT '#define SCI_PASTE 2179'}
    SCI_CLEAR = 2180;
    {$EXTERNALSYM SCI_CLEAR}
    {$HPPEMIT '#define SCI_CLEAR 2180'}
    SCI_SETTEXT = 2181;
    {$EXTERNALSYM SCI_SETTEXT}
    {$HPPEMIT '#define SCI_SETTEXT 2181'}
    SCI_GETTEXT = 2182;
    {$EXTERNALSYM SCI_GETTEXT}
    {$HPPEMIT '#define SCI_GETTEXT 2182'}
    SCI_GETTEXTLENGTH = 2183;
    {$EXTERNALSYM SCI_GETTEXTLENGTH}
    {$HPPEMIT '#define SCI_GETTEXTLENGTH 2183'}
    SCI_GETDIRECTFUNCTION = 2184;
    {$EXTERNALSYM SCI_GETDIRECTFUNCTION}
    {$HPPEMIT '#define SCI_GETDIRECTFUNCTION 2184'}
    SCI_GETDIRECTPOINTER = 2185;
    {$EXTERNALSYM SCI_GETDIRECTPOINTER}
    {$HPPEMIT '#define SCI_GETDIRECTPOINTER 2185'}
    SCI_SETOVERTYPE = 2186;
    {$EXTERNALSYM SCI_SETOVERTYPE}
    {$HPPEMIT '#define SCI_SETOVERTYPE 2186'}
    SCI_GETOVERTYPE = 2187;
    {$EXTERNALSYM SCI_GETOVERTYPE}
    {$HPPEMIT '#define SCI_GETOVERTYPE 2187'}
    SCI_SETCARETWIDTH = 2188;
    {$EXTERNALSYM SCI_SETCARETWIDTH}
    {$HPPEMIT '#define SCI_SETCARETWIDTH 2188'}
    SCI_GETCARETWIDTH = 2189;
    {$EXTERNALSYM SCI_GETCARETWIDTH}
    {$HPPEMIT '#define SCI_GETCARETWIDTH 2189'}
    SCI_SETTARGETSTART = 2190;
    {$EXTERNALSYM SCI_SETTARGETSTART}
    {$HPPEMIT '#define SCI_SETTARGETSTART 2190'}
    SCI_GETTARGETSTART = 2191;
    {$EXTERNALSYM SCI_GETTARGETSTART}
    {$HPPEMIT '#define SCI_GETTARGETSTART 2191'}
    SCI_SETTARGETEND = 2192;
    {$EXTERNALSYM SCI_SETTARGETEND}
    {$HPPEMIT '#define SCI_SETTARGETEND 2192'}
    SCI_GETTARGETEND = 2193;
    {$EXTERNALSYM SCI_GETTARGETEND}
    {$HPPEMIT '#define SCI_GETTARGETEND 2193'}
    SCI_REPLACETARGET = 2194;
    {$EXTERNALSYM SCI_REPLACETARGET}
    {$HPPEMIT '#define SCI_REPLACETARGET 2194'}
    SCI_REPLACETARGETRE = 2195;
    {$EXTERNALSYM SCI_REPLACETARGETRE}
    {$HPPEMIT '#define SCI_REPLACETARGETRE 2195'}
    SCI_SEARCHINTARGET = 2197;
    {$EXTERNALSYM SCI_SEARCHINTARGET}
    {$HPPEMIT '#define SCI_SEARCHINTARGET 2197'}
    SCI_SETSEARCHFLAGS = 2198;
    {$EXTERNALSYM SCI_SETSEARCHFLAGS}
    {$HPPEMIT '#define SCI_SETSEARCHFLAGS 2198'}
    SCI_GETSEARCHFLAGS = 2199;
    {$EXTERNALSYM SCI_GETSEARCHFLAGS}
    {$HPPEMIT '#define SCI_GETSEARCHFLAGS 2199'}
    SCI_CALLTIPSHOW = 2200;
    {$EXTERNALSYM SCI_CALLTIPSHOW}
    {$HPPEMIT '#define SCI_CALLTIPSHOW 2200'}
    SCI_CALLTIPCANCEL = 2201;
    {$EXTERNALSYM SCI_CALLTIPCANCEL}
    {$HPPEMIT '#define SCI_CALLTIPCANCEL 2201'}
    SCI_CALLTIPACTIVE = 2202;
    {$EXTERNALSYM SCI_CALLTIPACTIVE}
    {$HPPEMIT '#define SCI_CALLTIPACTIVE 2202'}
    SCI_CALLTIPPOSSTART = 2203;
    {$EXTERNALSYM SCI_CALLTIPPOSSTART}
    {$HPPEMIT '#define SCI_CALLTIPPOSSTART 2203'}
    SCI_CALLTIPSETHLT = 2204;
    {$EXTERNALSYM SCI_CALLTIPSETHLT}
    {$HPPEMIT '#define SCI_CALLTIPSETHLT 2204'}
    SCI_CALLTIPSETBACK = 2205;
    {$EXTERNALSYM SCI_CALLTIPSETBACK}
    {$HPPEMIT '#define SCI_CALLTIPSETBACK 2205'}
    SCI_CALLTIPSETFORE = 2206;
    {$EXTERNALSYM SCI_CALLTIPSETFORE}
    {$HPPEMIT '#define SCI_CALLTIPSETFORE 2206'}
    SCI_CALLTIPSETFOREHLT = 2207;
    {$EXTERNALSYM SCI_CALLTIPSETFOREHLT}
    {$HPPEMIT '#define SCI_CALLTIPSETFOREHLT 2207'}
    SCI_CALLTIPUSESTYLE = 2212;
    {$EXTERNALSYM SCI_CALLTIPUSESTYLE}
    {$HPPEMIT '#define SCI_CALLTIPUSESTYLE 2212'}
    SCI_VISIBLEFROMDOCLINE = 2220;
    {$EXTERNALSYM SCI_VISIBLEFROMDOCLINE}
    {$HPPEMIT '#define SCI_VISIBLEFROMDOCLINE 2220'}
    SCI_DOCLINEFROMVISIBLE = 2221;
    {$EXTERNALSYM SCI_DOCLINEFROMVISIBLE}
    {$HPPEMIT '#define SCI_DOCLINEFROMVISIBLE 2221'}
    SCI_WRAPCOUNT = 2235;
    {$EXTERNALSYM SCI_WRAPCOUNT}
    {$HPPEMIT '#define SCI_WRAPCOUNT 2235'}
    SC_FOLDLEVELBASE = $400;
    {$EXTERNALSYM SC_FOLDLEVELBASE}
    {$HPPEMIT '#define SC_FOLDLEVELBASE 0x400'}
    SC_FOLDLEVELWHITEFLAG = $1000;
    {$EXTERNALSYM SC_FOLDLEVELWHITEFLAG}
    {$HPPEMIT '#define SC_FOLDLEVELWHITEFLAG 0x1000'}
    SC_FOLDLEVELHEADERFLAG = $2000;
    {$EXTERNALSYM SC_FOLDLEVELHEADERFLAG}
    {$HPPEMIT '#define SC_FOLDLEVELHEADERFLAG 0x2000'}
    SC_FOLDLEVELBOXHEADERFLAG = $4000;
    {$EXTERNALSYM SC_FOLDLEVELBOXHEADERFLAG}
    {$HPPEMIT '#define SC_FOLDLEVELBOXHEADERFLAG 0x4000'}
    SC_FOLDLEVELBOXFOOTERFLAG = $8000;
    {$EXTERNALSYM SC_FOLDLEVELBOXFOOTERFLAG}
    {$HPPEMIT '#define SC_FOLDLEVELBOXFOOTERFLAG 0x8000'}
    SC_FOLDLEVELCONTRACTED = $10000;
    {$EXTERNALSYM SC_FOLDLEVELCONTRACTED}
    {$HPPEMIT '#define SC_FOLDLEVELCONTRACTED 0x10000'}
    SC_FOLDLEVELUNINDENT = $20000;
    {$EXTERNALSYM SC_FOLDLEVELUNINDENT}
    {$HPPEMIT '#define SC_FOLDLEVELUNINDENT 0x20000'}
    SC_FOLDLEVELNUMBERMASK = $0FFF;
    {$EXTERNALSYM SC_FOLDLEVELNUMBERMASK}
    {$HPPEMIT '#define SC_FOLDLEVELNUMBERMASK 0x0FFF'}
    SCI_SETFOLDLEVEL = 2222;
    {$EXTERNALSYM SCI_SETFOLDLEVEL}
    {$HPPEMIT '#define SCI_SETFOLDLEVEL 2222'}
    SCI_GETFOLDLEVEL = 2223;
    {$EXTERNALSYM SCI_GETFOLDLEVEL}
    {$HPPEMIT '#define SCI_GETFOLDLEVEL 2223'}
    SCI_GETLASTCHILD = 2224;
    {$EXTERNALSYM SCI_GETLASTCHILD}
    {$HPPEMIT '#define SCI_GETLASTCHILD 2224'}
    SCI_GETFOLDPARENT = 2225;
    {$EXTERNALSYM SCI_GETFOLDPARENT}
    {$HPPEMIT '#define SCI_GETFOLDPARENT 2225'}
    SCI_SHOWLINES = 2226;
    {$EXTERNALSYM SCI_SHOWLINES}
    {$HPPEMIT '#define SCI_SHOWLINES 2226'}
    SCI_HIDELINES = 2227;
    {$EXTERNALSYM SCI_HIDELINES}
    {$HPPEMIT '#define SCI_HIDELINES 2227'}
    SCI_GETLINEVISIBLE = 2228;
    {$EXTERNALSYM SCI_GETLINEVISIBLE}
    {$HPPEMIT '#define SCI_GETLINEVISIBLE 2228'}
    SCI_SETFOLDEXPANDED = 2229;
    {$EXTERNALSYM SCI_SETFOLDEXPANDED}
    {$HPPEMIT '#define SCI_SETFOLDEXPANDED 2229'}
    SCI_GETFOLDEXPANDED = 2230;
    {$EXTERNALSYM SCI_GETFOLDEXPANDED}
    {$HPPEMIT '#define SCI_GETFOLDEXPANDED 2230'}
    SCI_TOGGLEFOLD = 2231;
    {$EXTERNALSYM SCI_TOGGLEFOLD}
    {$HPPEMIT '#define SCI_TOGGLEFOLD 2231'}
    SCI_ENSUREVISIBLE = 2232;
    {$EXTERNALSYM SCI_ENSUREVISIBLE}
    {$HPPEMIT '#define SCI_ENSUREVISIBLE 2232'}
    SC_FOLDFLAG_LINEBEFORE_EXPANDED = $0002;
    {$EXTERNALSYM SC_FOLDFLAG_LINEBEFORE_EXPANDED}
    {$HPPEMIT '#define SC_FOLDFLAG_LINEBEFORE_EXPANDED 0x0002'}
    SC_FOLDFLAG_LINEBEFORE_CONTRACTED = $0004;
    {$EXTERNALSYM SC_FOLDFLAG_LINEBEFORE_CONTRACTED}
    {$HPPEMIT '#define SC_FOLDFLAG_LINEBEFORE_CONTRACTED 0x0004'}
    SC_FOLDFLAG_LINEAFTER_EXPANDED = $0008;
    {$EXTERNALSYM SC_FOLDFLAG_LINEAFTER_EXPANDED}
    {$HPPEMIT '#define SC_FOLDFLAG_LINEAFTER_EXPANDED 0x0008'}
    SC_FOLDFLAG_LINEAFTER_CONTRACTED = $0010;
    {$EXTERNALSYM SC_FOLDFLAG_LINEAFTER_CONTRACTED}
    {$HPPEMIT '#define SC_FOLDFLAG_LINEAFTER_CONTRACTED 0x0010'}
    SC_FOLDFLAG_LEVELNUMBERS = $0040;
    {$EXTERNALSYM SC_FOLDFLAG_LEVELNUMBERS}
    {$HPPEMIT '#define SC_FOLDFLAG_LEVELNUMBERS 0x0040'}
    SC_FOLDFLAG_BOX = $0001;
    {$EXTERNALSYM SC_FOLDFLAG_BOX}
    {$HPPEMIT '#define SC_FOLDFLAG_BOX 0x0001'}
    SCI_SETFOLDFLAGS = 2233;
    {$EXTERNALSYM SCI_SETFOLDFLAGS}
    {$HPPEMIT '#define SCI_SETFOLDFLAGS 2233'}
    SCI_ENSUREVISIBLEENFORCEPOLICY = 2234;
    {$EXTERNALSYM SCI_ENSUREVISIBLEENFORCEPOLICY}
    {$HPPEMIT '#define SCI_ENSUREVISIBLEENFORCEPOLICY 2234'}
    SCI_SETTABINDENTS = 2260;
    {$EXTERNALSYM SCI_SETTABINDENTS}
    {$HPPEMIT '#define SCI_SETTABINDENTS 2260'}
    SCI_GETTABINDENTS = 2261;
    {$EXTERNALSYM SCI_GETTABINDENTS}
    {$HPPEMIT '#define SCI_GETTABINDENTS 2261'}
    SCI_SETBACKSPACEUNINDENTS = 2262;
    {$EXTERNALSYM SCI_SETBACKSPACEUNINDENTS}
    {$HPPEMIT '#define SCI_SETBACKSPACEUNINDENTS 2262'}
    SCI_GETBACKSPACEUNINDENTS = 2263;
    {$EXTERNALSYM SCI_GETBACKSPACEUNINDENTS}
    {$HPPEMIT '#define SCI_GETBACKSPACEUNINDENTS 2263'}
    SC_TIME_FOREVER = 10000000;
    {$EXTERNALSYM SC_TIME_FOREVER}
    {$HPPEMIT '#define SC_TIME_FOREVER 10000000'}
    SCI_SETMOUSEDWELLTIME = 2264;
    {$EXTERNALSYM SCI_SETMOUSEDWELLTIME}
    {$HPPEMIT '#define SCI_SETMOUSEDWELLTIME 2264'}
    SCI_GETMOUSEDWELLTIME = 2265;
    {$EXTERNALSYM SCI_GETMOUSEDWELLTIME}
    {$HPPEMIT '#define SCI_GETMOUSEDWELLTIME 2265'}
    SCI_WORDSTARTPOSITION = 2266;
    {$EXTERNALSYM SCI_WORDSTARTPOSITION}
    {$HPPEMIT '#define SCI_WORDSTARTPOSITION 2266'}
    SCI_WORDENDPOSITION = 2267;
    {$EXTERNALSYM SCI_WORDENDPOSITION}
    {$HPPEMIT '#define SCI_WORDENDPOSITION 2267'}
    SC_WRAP_NONE = 0;
    {$EXTERNALSYM SC_WRAP_NONE}
    {$HPPEMIT '#define SC_WRAP_NONE 0'}
    SC_WRAP_WORD = 1;
    {$EXTERNALSYM SC_WRAP_WORD}
    {$HPPEMIT '#define SC_WRAP_WORD 1'}
    SC_WRAP_CHAR = 2;
    {$EXTERNALSYM SC_WRAP_CHAR}
    {$HPPEMIT '#define SC_WRAP_CHAR 2'}
    SCI_SETWRAPMODE = 2268;
    {$EXTERNALSYM SCI_SETWRAPMODE}
    {$HPPEMIT '#define SCI_SETWRAPMODE 2268'}
    SCI_GETWRAPMODE = 2269;
    {$EXTERNALSYM SCI_GETWRAPMODE}
    {$HPPEMIT '#define SCI_GETWRAPMODE 2269'}
    SC_WRAPVISUALFLAG_NONE = $0000;
    {$EXTERNALSYM SC_WRAPVISUALFLAG_NONE}
    {$HPPEMIT '#define SC_WRAPVISUALFLAG_NONE 0x0000'}
    SC_WRAPVISUALFLAG_END = $0001;
    {$EXTERNALSYM SC_WRAPVISUALFLAG_END}
    {$HPPEMIT '#define SC_WRAPVISUALFLAG_END 0x0001'}
    SC_WRAPVISUALFLAG_START = $0002;
    {$EXTERNALSYM SC_WRAPVISUALFLAG_START}
    {$HPPEMIT '#define SC_WRAPVISUALFLAG_START 0x0002'}
    SCI_SETWRAPVISUALFLAGS = 2460;
    {$EXTERNALSYM SCI_SETWRAPVISUALFLAGS}
    {$HPPEMIT '#define SCI_SETWRAPVISUALFLAGS 2460'}
    SCI_GETWRAPVISUALFLAGS = 2461;
    {$EXTERNALSYM SCI_GETWRAPVISUALFLAGS}
    {$HPPEMIT '#define SCI_GETWRAPVISUALFLAGS 2461'}
    SC_WRAPVISUALFLAGLOC_DEFAULT = $0000;
    {$EXTERNALSYM SC_WRAPVISUALFLAGLOC_DEFAULT}
    {$HPPEMIT '#define SC_WRAPVISUALFLAGLOC_DEFAULT 0x0000'}
    SC_WRAPVISUALFLAGLOC_END_BY_TEXT = $0001;
    {$EXTERNALSYM SC_WRAPVISUALFLAGLOC_END_BY_TEXT}
    {$HPPEMIT '#define SC_WRAPVISUALFLAGLOC_END_BY_TEXT 0x0001'}
    SC_WRAPVISUALFLAGLOC_START_BY_TEXT = $0002;
    {$EXTERNALSYM SC_WRAPVISUALFLAGLOC_START_BY_TEXT}
    {$HPPEMIT '#define SC_WRAPVISUALFLAGLOC_START_BY_TEXT 0x0002'}
    SCI_SETWRAPVISUALFLAGSLOCATION = 2462;
    {$EXTERNALSYM SCI_SETWRAPVISUALFLAGSLOCATION}
    {$HPPEMIT '#define SCI_SETWRAPVISUALFLAGSLOCATION 2462'}
    SCI_GETWRAPVISUALFLAGSLOCATION = 2463;
    {$EXTERNALSYM SCI_GETWRAPVISUALFLAGSLOCATION}
    {$HPPEMIT '#define SCI_GETWRAPVISUALFLAGSLOCATION 2463'}
    SCI_SETWRAPSTARTINDENT = 2464;
    {$EXTERNALSYM SCI_SETWRAPSTARTINDENT}
    {$HPPEMIT '#define SCI_SETWRAPSTARTINDENT 2464'}
    SCI_GETWRAPSTARTINDENT = 2465;
    {$EXTERNALSYM SCI_GETWRAPSTARTINDENT}
    {$HPPEMIT '#define SCI_GETWRAPSTARTINDENT 2465'}
    SC_CACHE_NONE = 0;
    {$EXTERNALSYM SC_CACHE_NONE}
    {$HPPEMIT '#define SC_CACHE_NONE 0'}
    SC_CACHE_CARET = 1;
    {$EXTERNALSYM SC_CACHE_CARET}
    {$HPPEMIT '#define SC_CACHE_CARET 1'}
    SC_CACHE_PAGE = 2;
    {$EXTERNALSYM SC_CACHE_PAGE}
    {$HPPEMIT '#define SC_CACHE_PAGE 2'}
    SC_CACHE_DOCUMENT = 3;
    {$EXTERNALSYM SC_CACHE_DOCUMENT}
    {$HPPEMIT '#define SC_CACHE_DOCUMENT 3'}
    SCI_SETLAYOUTCACHE = 2272;
    {$EXTERNALSYM SCI_SETLAYOUTCACHE}
    {$HPPEMIT '#define SCI_SETLAYOUTCACHE 2272'}
    SCI_GETLAYOUTCACHE = 2273;
    {$EXTERNALSYM SCI_GETLAYOUTCACHE}
    {$HPPEMIT '#define SCI_GETLAYOUTCACHE 2273'}
    SCI_SETSCROLLWIDTH = 2274;
    {$EXTERNALSYM SCI_SETSCROLLWIDTH}
    {$HPPEMIT '#define SCI_SETSCROLLWIDTH 2274'}
    SCI_GETSCROLLWIDTH = 2275;
    {$EXTERNALSYM SCI_GETSCROLLWIDTH}
    {$HPPEMIT '#define SCI_GETSCROLLWIDTH 2275'}
    SCI_TEXTWIDTH = 2276;
    {$EXTERNALSYM SCI_TEXTWIDTH}
    {$HPPEMIT '#define SCI_TEXTWIDTH 2276'}
    SCI_SETENDATLASTLINE = 2277;
    {$EXTERNALSYM SCI_SETENDATLASTLINE}
    {$HPPEMIT '#define SCI_SETENDATLASTLINE 2277'}
    SCI_GETENDATLASTLINE = 2278;
    {$EXTERNALSYM SCI_GETENDATLASTLINE}
    {$HPPEMIT '#define SCI_GETENDATLASTLINE 2278'}
    SCI_TEXTHEIGHT = 2279;
    {$EXTERNALSYM SCI_TEXTHEIGHT}
    {$HPPEMIT '#define SCI_TEXTHEIGHT 2279'}
    SCI_SETVSCROLLBAR = 2280;
    {$EXTERNALSYM SCI_SETVSCROLLBAR}
    {$HPPEMIT '#define SCI_SETVSCROLLBAR 2280'}
    SCI_GETVSCROLLBAR = 2281;
    {$EXTERNALSYM SCI_GETVSCROLLBAR}
    {$HPPEMIT '#define SCI_GETVSCROLLBAR 2281'}
    SCI_APPENDTEXT = 2282;
    {$EXTERNALSYM SCI_APPENDTEXT}
    {$HPPEMIT '#define SCI_APPENDTEXT 2282'}
    SCI_GETTWOPHASEDRAW = 2283;
    {$EXTERNALSYM SCI_GETTWOPHASEDRAW}
    {$HPPEMIT '#define SCI_GETTWOPHASEDRAW 2283'}
    SCI_SETTWOPHASEDRAW = 2284;
    {$EXTERNALSYM SCI_SETTWOPHASEDRAW}
    {$HPPEMIT '#define SCI_SETTWOPHASEDRAW 2284'}
    SCI_TARGETFROMSELECTION = 2287;
    {$EXTERNALSYM SCI_TARGETFROMSELECTION}
    {$HPPEMIT '#define SCI_TARGETFROMSELECTION 2287'}
    SCI_LINESJOIN = 2288;
    {$EXTERNALSYM SCI_LINESJOIN}
    {$HPPEMIT '#define SCI_LINESJOIN 2288'}
    SCI_LINESSPLIT = 2289;
    {$EXTERNALSYM SCI_LINESSPLIT}
    {$HPPEMIT '#define SCI_LINESSPLIT 2289'}
    SCI_SETFOLDMARGINCOLOUR = 2290;
    {$EXTERNALSYM SCI_SETFOLDMARGINCOLOUR}
    {$HPPEMIT '#define SCI_SETFOLDMARGINCOLOUR 2290'}
    SCI_SETFOLDMARGINHICOLOUR = 2291;
    {$EXTERNALSYM SCI_SETFOLDMARGINHICOLOUR}
    {$HPPEMIT '#define SCI_SETFOLDMARGINHICOLOUR 2291'}
    SCI_LINEDOWN = 2300;
    {$EXTERNALSYM SCI_LINEDOWN}
    {$HPPEMIT '#define SCI_LINEDOWN 2300'}
    SCI_LINEDOWNEXTEND = 2301;
    {$EXTERNALSYM SCI_LINEDOWNEXTEND}
    {$HPPEMIT '#define SCI_LINEDOWNEXTEND 2301'}
    SCI_LINEUP = 2302;
    {$EXTERNALSYM SCI_LINEUP}
    {$HPPEMIT '#define SCI_LINEUP 2302'}
    SCI_LINEUPEXTEND = 2303;
    {$EXTERNALSYM SCI_LINEUPEXTEND}
    {$HPPEMIT '#define SCI_LINEUPEXTEND 2303'}
    SCI_CHARLEFT = 2304;
    {$EXTERNALSYM SCI_CHARLEFT}
    {$HPPEMIT '#define SCI_CHARLEFT 2304'}
    SCI_CHARLEFTEXTEND = 2305;
    {$EXTERNALSYM SCI_CHARLEFTEXTEND}
    {$HPPEMIT '#define SCI_CHARLEFTEXTEND 2305'}
    SCI_CHARRIGHT = 2306;
    {$EXTERNALSYM SCI_CHARRIGHT}
    {$HPPEMIT '#define SCI_CHARRIGHT 2306'}
    SCI_CHARRIGHTEXTEND = 2307;
    {$EXTERNALSYM SCI_CHARRIGHTEXTEND}
    {$HPPEMIT '#define SCI_CHARRIGHTEXTEND 2307'}
    SCI_WORDLEFT = 2308;
    {$EXTERNALSYM SCI_WORDLEFT}
    {$HPPEMIT '#define SCI_WORDLEFT 2308'}
    SCI_WORDLEFTEXTEND = 2309;
    {$EXTERNALSYM SCI_WORDLEFTEXTEND}
    {$HPPEMIT '#define SCI_WORDLEFTEXTEND 2309'}
    SCI_WORDRIGHT = 2310;
    {$EXTERNALSYM SCI_WORDRIGHT}
    {$HPPEMIT '#define SCI_WORDRIGHT 2310'}
    SCI_WORDRIGHTEXTEND = 2311;
    {$EXTERNALSYM SCI_WORDRIGHTEXTEND}
    {$HPPEMIT '#define SCI_WORDRIGHTEXTEND 2311'}
    SCI_HOME = 2312;
    {$EXTERNALSYM SCI_HOME}
    {$HPPEMIT '#define SCI_HOME 2312'}
    SCI_HOMEEXTEND = 2313;
    {$EXTERNALSYM SCI_HOMEEXTEND}
    {$HPPEMIT '#define SCI_HOMEEXTEND 2313'}
    SCI_LINEEND = 2314;
    {$EXTERNALSYM SCI_LINEEND}
    {$HPPEMIT '#define SCI_LINEEND 2314'}
    SCI_LINEENDEXTEND = 2315;
    {$EXTERNALSYM SCI_LINEENDEXTEND}
    {$HPPEMIT '#define SCI_LINEENDEXTEND 2315'}
    SCI_DOCUMENTSTART = 2316;
    {$EXTERNALSYM SCI_DOCUMENTSTART}
    {$HPPEMIT '#define SCI_DOCUMENTSTART 2316'}
    SCI_DOCUMENTSTARTEXTEND = 2317;
    {$EXTERNALSYM SCI_DOCUMENTSTARTEXTEND}
    {$HPPEMIT '#define SCI_DOCUMENTSTARTEXTEND 2317'}
    SCI_DOCUMENTEND = 2318;
    {$EXTERNALSYM SCI_DOCUMENTEND}
    {$HPPEMIT '#define SCI_DOCUMENTEND 2318'}
    SCI_DOCUMENTENDEXTEND = 2319;
    {$EXTERNALSYM SCI_DOCUMENTENDEXTEND}
    {$HPPEMIT '#define SCI_DOCUMENTENDEXTEND 2319'}
    SCI_PAGEUP = 2320;
    {$EXTERNALSYM SCI_PAGEUP}
    {$HPPEMIT '#define SCI_PAGEUP 2320'}
    SCI_PAGEUPEXTEND = 2321;
    {$EXTERNALSYM SCI_PAGEUPEXTEND}
    {$HPPEMIT '#define SCI_PAGEUPEXTEND 2321'}
    SCI_PAGEDOWN = 2322;
    {$EXTERNALSYM SCI_PAGEDOWN}
    {$HPPEMIT '#define SCI_PAGEDOWN 2322'}
    SCI_PAGEDOWNEXTEND = 2323;
    {$EXTERNALSYM SCI_PAGEDOWNEXTEND}
    {$HPPEMIT '#define SCI_PAGEDOWNEXTEND 2323'}
    SCI_EDITTOGGLEOVERTYPE = 2324;
    {$EXTERNALSYM SCI_EDITTOGGLEOVERTYPE}
    {$HPPEMIT '#define SCI_EDITTOGGLEOVERTYPE 2324'}
    SCI_CANCEL = 2325;
    {$EXTERNALSYM SCI_CANCEL}
    {$HPPEMIT '#define SCI_CANCEL 2325'}
    SCI_DELETEBACK = 2326;
    {$EXTERNALSYM SCI_DELETEBACK}
    {$HPPEMIT '#define SCI_DELETEBACK 2326'}
    SCI_TAB = 2327;
    {$EXTERNALSYM SCI_TAB}
    {$HPPEMIT '#define SCI_TAB 2327'}
    SCI_BACKTAB = 2328;
    {$EXTERNALSYM SCI_BACKTAB}
    {$HPPEMIT '#define SCI_BACKTAB 2328'}
    SCI_NEWLINE = 2329;
    {$EXTERNALSYM SCI_NEWLINE}
    {$HPPEMIT '#define SCI_NEWLINE 2329'}
    SCI_FORMFEED = 2330;
    {$EXTERNALSYM SCI_FORMFEED}
    {$HPPEMIT '#define SCI_FORMFEED 2330'}
    SCI_VCHOME = 2331;
    {$EXTERNALSYM SCI_VCHOME}
    {$HPPEMIT '#define SCI_VCHOME 2331'}
    SCI_VCHOMEEXTEND = 2332;
    {$EXTERNALSYM SCI_VCHOMEEXTEND}
    {$HPPEMIT '#define SCI_VCHOMEEXTEND 2332'}
    SCI_ZOOMIN = 2333;
    {$EXTERNALSYM SCI_ZOOMIN}
    {$HPPEMIT '#define SCI_ZOOMIN 2333'}
    SCI_ZOOMOUT = 2334;
    {$EXTERNALSYM SCI_ZOOMOUT}
    {$HPPEMIT '#define SCI_ZOOMOUT 2334'}
    SCI_DELWORDLEFT = 2335;
    {$EXTERNALSYM SCI_DELWORDLEFT}
    {$HPPEMIT '#define SCI_DELWORDLEFT 2335'}
    SCI_DELWORDRIGHT = 2336;
    {$EXTERNALSYM SCI_DELWORDRIGHT}
    {$HPPEMIT '#define SCI_DELWORDRIGHT 2336'}
    SCI_LINECUT = 2337;
    {$EXTERNALSYM SCI_LINECUT}
    {$HPPEMIT '#define SCI_LINECUT 2337'}
    SCI_LINEDELETE = 2338;
    {$EXTERNALSYM SCI_LINEDELETE}
    {$HPPEMIT '#define SCI_LINEDELETE 2338'}
    SCI_LINETRANSPOSE = 2339;
    {$EXTERNALSYM SCI_LINETRANSPOSE}
    {$HPPEMIT '#define SCI_LINETRANSPOSE 2339'}
    SCI_LINEDUPLICATE = 2404;
    {$EXTERNALSYM SCI_LINEDUPLICATE}
    {$HPPEMIT '#define SCI_LINEDUPLICATE 2404'}
    SCI_LOWERCASE = 2340;
    {$EXTERNALSYM SCI_LOWERCASE}
    {$HPPEMIT '#define SCI_LOWERCASE 2340'}
    SCI_UPPERCASE = 2341;
    {$EXTERNALSYM SCI_UPPERCASE}
    {$HPPEMIT '#define SCI_UPPERCASE 2341'}
    SCI_LINESCROLLDOWN = 2342;
    {$EXTERNALSYM SCI_LINESCROLLDOWN}
    {$HPPEMIT '#define SCI_LINESCROLLDOWN 2342'}
    SCI_LINESCROLLUP = 2343;
    {$EXTERNALSYM SCI_LINESCROLLUP}
    {$HPPEMIT '#define SCI_LINESCROLLUP 2343'}
    SCI_DELETEBACKNOTLINE = 2344;
    {$EXTERNALSYM SCI_DELETEBACKNOTLINE}
    {$HPPEMIT '#define SCI_DELETEBACKNOTLINE 2344'}
    SCI_HOMEDISPLAY = 2345;
    {$EXTERNALSYM SCI_HOMEDISPLAY}
    {$HPPEMIT '#define SCI_HOMEDISPLAY 2345'}
    SCI_HOMEDISPLAYEXTEND = 2346;
    {$EXTERNALSYM SCI_HOMEDISPLAYEXTEND}
    {$HPPEMIT '#define SCI_HOMEDISPLAYEXTEND 2346'}
    SCI_LINEENDDISPLAY = 2347;
    {$EXTERNALSYM SCI_LINEENDDISPLAY}
    {$HPPEMIT '#define SCI_LINEENDDISPLAY 2347'}
    SCI_LINEENDDISPLAYEXTEND = 2348;
    {$EXTERNALSYM SCI_LINEENDDISPLAYEXTEND}
    {$HPPEMIT '#define SCI_LINEENDDISPLAYEXTEND 2348'}
    SCI_HOMEWRAP = 2349;
    {$EXTERNALSYM SCI_HOMEWRAP}
    {$HPPEMIT '#define SCI_HOMEWRAP 2349'}
    SCI_HOMEWRAPEXTEND = 2450;
    {$EXTERNALSYM SCI_HOMEWRAPEXTEND}
    {$HPPEMIT '#define SCI_HOMEWRAPEXTEND 2450'}
    SCI_LINEENDWRAP = 2451;
    {$EXTERNALSYM SCI_LINEENDWRAP}
    {$HPPEMIT '#define SCI_LINEENDWRAP 2451'}
    SCI_LINEENDWRAPEXTEND = 2452;
    {$EXTERNALSYM SCI_LINEENDWRAPEXTEND}
    {$HPPEMIT '#define SCI_LINEENDWRAPEXTEND 2452'}
    SCI_VCHOMEWRAP = 2453;
    {$EXTERNALSYM SCI_VCHOMEWRAP}
    {$HPPEMIT '#define SCI_VCHOMEWRAP 2453'}
    SCI_VCHOMEWRAPEXTEND = 2454;
    {$EXTERNALSYM SCI_VCHOMEWRAPEXTEND}
    {$HPPEMIT '#define SCI_VCHOMEWRAPEXTEND 2454'}
    SCI_LINECOPY = 2455;
    {$EXTERNALSYM SCI_LINECOPY}
    {$HPPEMIT '#define SCI_LINECOPY 2455'}
    SCI_MOVECARETINSIDEVIEW = 2401;
    {$EXTERNALSYM SCI_MOVECARETINSIDEVIEW}
    {$HPPEMIT '#define SCI_MOVECARETINSIDEVIEW 2401'}
    SCI_LINELENGTH = 2350;
    {$EXTERNALSYM SCI_LINELENGTH}
    {$HPPEMIT '#define SCI_LINELENGTH 2350'}
    SCI_BRACEHIGHLIGHT = 2351;
    {$EXTERNALSYM SCI_BRACEHIGHLIGHT}
    {$HPPEMIT '#define SCI_BRACEHIGHLIGHT 2351'}
    SCI_BRACEBADLIGHT = 2352;
    {$EXTERNALSYM SCI_BRACEBADLIGHT}
    {$HPPEMIT '#define SCI_BRACEBADLIGHT 2352'}
    SCI_BRACEMATCH = 2353;
    {$EXTERNALSYM SCI_BRACEMATCH}
    {$HPPEMIT '#define SCI_BRACEMATCH 2353'}
    SCI_GETVIEWEOL = 2355;
    {$EXTERNALSYM SCI_GETVIEWEOL}
    {$HPPEMIT '#define SCI_GETVIEWEOL 2355'}
    SCI_SETVIEWEOL = 2356;
    {$EXTERNALSYM SCI_SETVIEWEOL}
    {$HPPEMIT '#define SCI_SETVIEWEOL 2356'}
    SCI_GETDOCPOINTER = 2357;
    {$EXTERNALSYM SCI_GETDOCPOINTER}
    {$HPPEMIT '#define SCI_GETDOCPOINTER 2357'}
    SCI_SETDOCPOINTER = 2358;
    {$EXTERNALSYM SCI_SETDOCPOINTER}
    {$HPPEMIT '#define SCI_SETDOCPOINTER 2358'}
    SCI_SETMODEVENTMASK = 2359;
    {$EXTERNALSYM SCI_SETMODEVENTMASK}
    {$HPPEMIT '#define SCI_SETMODEVENTMASK 2359'}
    EDGE_NONE = 0;
    {$EXTERNALSYM EDGE_NONE}
    {$HPPEMIT '#define EDGE_NONE 0'}
    EDGE_LINE = 1;
    {$EXTERNALSYM EDGE_LINE}
    {$HPPEMIT '#define EDGE_LINE 1'}
    EDGE_BACKGROUND = 2;
    {$EXTERNALSYM EDGE_BACKGROUND}
    {$HPPEMIT '#define EDGE_BACKGROUND 2'}
    SCI_GETEDGECOLUMN = 2360;
    {$EXTERNALSYM SCI_GETEDGECOLUMN}
    {$HPPEMIT '#define SCI_GETEDGECOLUMN 2360'}
    SCI_SETEDGECOLUMN = 2361;
    {$EXTERNALSYM SCI_SETEDGECOLUMN}
    {$HPPEMIT '#define SCI_SETEDGECOLUMN 2361'}
    SCI_GETEDGEMODE = 2362;
    {$EXTERNALSYM SCI_GETEDGEMODE}
    {$HPPEMIT '#define SCI_GETEDGEMODE 2362'}
    SCI_SETEDGEMODE = 2363;
    {$EXTERNALSYM SCI_SETEDGEMODE}
    {$HPPEMIT '#define SCI_SETEDGEMODE 2363'}
    SCI_GETEDGECOLOUR = 2364;
    {$EXTERNALSYM SCI_GETEDGECOLOUR}
    {$HPPEMIT '#define SCI_GETEDGECOLOUR 2364'}
    SCI_SETEDGECOLOUR = 2365;
    {$EXTERNALSYM SCI_SETEDGECOLOUR}
    {$HPPEMIT '#define SCI_SETEDGECOLOUR 2365'}
    SCI_SEARCHANCHOR = 2366;
    {$EXTERNALSYM SCI_SEARCHANCHOR}
    {$HPPEMIT '#define SCI_SEARCHANCHOR 2366'}
    SCI_SEARCHNEXT = 2367;
    {$EXTERNALSYM SCI_SEARCHNEXT}
    {$HPPEMIT '#define SCI_SEARCHNEXT 2367'}
    SCI_SEARCHPREV = 2368;
    {$EXTERNALSYM SCI_SEARCHPREV}
    {$HPPEMIT '#define SCI_SEARCHPREV 2368'}
    SCI_LINESONSCREEN = 2370;
    {$EXTERNALSYM SCI_LINESONSCREEN}
    {$HPPEMIT '#define SCI_LINESONSCREEN 2370'}
    SCI_USEPOPUP = 2371;
    {$EXTERNALSYM SCI_USEPOPUP}
    {$HPPEMIT '#define SCI_USEPOPUP 2371'}
    SCI_SELECTIONISRECTANGLE = 2372;
    {$EXTERNALSYM SCI_SELECTIONISRECTANGLE}
    {$HPPEMIT '#define SCI_SELECTIONISRECTANGLE 2372'}
    SCI_SETZOOM = 2373;
    {$EXTERNALSYM SCI_SETZOOM}
    {$HPPEMIT '#define SCI_SETZOOM 2373'}
    SCI_GETZOOM = 2374;
    {$EXTERNALSYM SCI_GETZOOM}
    {$HPPEMIT '#define SCI_GETZOOM 2374'}
    SCI_CREATEDOCUMENT = 2375;
    {$EXTERNALSYM SCI_CREATEDOCUMENT}
    {$HPPEMIT '#define SCI_CREATEDOCUMENT 2375'}
    SCI_ADDREFDOCUMENT = 2376;
    {$EXTERNALSYM SCI_ADDREFDOCUMENT}
    {$HPPEMIT '#define SCI_ADDREFDOCUMENT 2376'}
    SCI_RELEASEDOCUMENT = 2377;
    {$EXTERNALSYM SCI_RELEASEDOCUMENT}
    {$HPPEMIT '#define SCI_RELEASEDOCUMENT 2377'}
    SCI_GETMODEVENTMASK = 2378;
    {$EXTERNALSYM SCI_GETMODEVENTMASK}
    {$HPPEMIT '#define SCI_GETMODEVENTMASK 2378'}
    SCI_SETFOCUSEX = 2380;
    {$EXTERNALSYM SCI_SETFOCUSEX}
    {$HPPEMIT '#define SCI_SETFOCUSEX 2380'}
    SCI_GETFOCUS = 2381;
    {$EXTERNALSYM SCI_GETFOCUS}
    {$HPPEMIT '#define SCI_GETFOCUS 2381'}
    SCI_SETSTATUS = 2382;
    {$EXTERNALSYM SCI_SETSTATUS}
    {$HPPEMIT '#define SCI_SETSTATUS 2382'}
    SCI_GETSTATUS = 2383;
    {$EXTERNALSYM SCI_GETSTATUS}
    {$HPPEMIT '#define SCI_GETSTATUS 2383'}
    SCI_SETMOUSEDOWNCAPTURES = 2384;
    {$EXTERNALSYM SCI_SETMOUSEDOWNCAPTURES}
    {$HPPEMIT '#define SCI_SETMOUSEDOWNCAPTURES 2384'}
    SCI_GETMOUSEDOWNCAPTURES = 2385;
    {$EXTERNALSYM SCI_GETMOUSEDOWNCAPTURES}
    {$HPPEMIT '#define SCI_GETMOUSEDOWNCAPTURES 2385'}
    SC_CURSORNORMAL = -1;
    {$EXTERNALSYM SC_CURSORNORMAL}
    {$HPPEMIT '#define SC_CURSORNORMAL -1'}
    SC_CURSORWAIT = 4;
    {$EXTERNALSYM SC_CURSORWAIT}
    {$HPPEMIT '#define SC_CURSORWAIT 4'}
    SCI_SETCURSOR = 2386;
    {$EXTERNALSYM SCI_SETCURSOR}
    {$HPPEMIT '#define SCI_SETCURSOR 2386'}
    SCI_GETCURSOR = 2387;
    {$EXTERNALSYM SCI_GETCURSOR}
    {$HPPEMIT '#define SCI_GETCURSOR 2387'}
    SCI_SETCONTROLCHARSYMBOL = 2388;
    {$EXTERNALSYM SCI_SETCONTROLCHARSYMBOL}
    {$HPPEMIT '#define SCI_SETCONTROLCHARSYMBOL 2388'}
    SCI_GETCONTROLCHARSYMBOL = 2389;
    {$EXTERNALSYM SCI_GETCONTROLCHARSYMBOL}
    {$HPPEMIT '#define SCI_GETCONTROLCHARSYMBOL 2389'}
    SCI_WORDPARTLEFT = 2390;
    {$EXTERNALSYM SCI_WORDPARTLEFT}
    {$HPPEMIT '#define SCI_WORDPARTLEFT 2390'}
    SCI_WORDPARTLEFTEXTEND = 2391;
    {$EXTERNALSYM SCI_WORDPARTLEFTEXTEND}
    {$HPPEMIT '#define SCI_WORDPARTLEFTEXTEND 2391'}
    SCI_WORDPARTRIGHT = 2392;
    {$EXTERNALSYM SCI_WORDPARTRIGHT}
    {$HPPEMIT '#define SCI_WORDPARTRIGHT 2392'}
    SCI_WORDPARTRIGHTEXTEND = 2393;
    {$EXTERNALSYM SCI_WORDPARTRIGHTEXTEND}
    {$HPPEMIT '#define SCI_WORDPARTRIGHTEXTEND 2393'}
    VISIBLE_SLOP = $01;
    {$EXTERNALSYM VISIBLE_SLOP}
    {$HPPEMIT '#define VISIBLE_SLOP 0x01'}
    VISIBLE_STRICT = $04;
    {$EXTERNALSYM VISIBLE_STRICT}
    {$HPPEMIT '#define VISIBLE_STRICT 0x04'}
    SCI_SETVISIBLEPOLICY = 2394;
    {$EXTERNALSYM SCI_SETVISIBLEPOLICY}
    {$HPPEMIT '#define SCI_SETVISIBLEPOLICY 2394'}
    SCI_DELLINELEFT = 2395;
    {$EXTERNALSYM SCI_DELLINELEFT}
    {$HPPEMIT '#define SCI_DELLINELEFT 2395'}
    SCI_DELLINERIGHT = 2396;
    {$EXTERNALSYM SCI_DELLINERIGHT}
    {$HPPEMIT '#define SCI_DELLINERIGHT 2396'}
    SCI_SETXOFFSET = 2397;
    {$EXTERNALSYM SCI_SETXOFFSET}
    {$HPPEMIT '#define SCI_SETXOFFSET 2397'}
    SCI_GETXOFFSET = 2398;
    {$EXTERNALSYM SCI_GETXOFFSET}
    {$HPPEMIT '#define SCI_GETXOFFSET 2398'}
    SCI_CHOOSECARETX = 2399;
    {$EXTERNALSYM SCI_CHOOSECARETX}
    {$HPPEMIT '#define SCI_CHOOSECARETX 2399'}
    SCI_GRABFOCUS = 2400;
    {$EXTERNALSYM SCI_GRABFOCUS}
    {$HPPEMIT '#define SCI_GRABFOCUS 2400'}
    CARET_SLOP = $01;
    {$EXTERNALSYM CARET_SLOP}
    {$HPPEMIT '#define CARET_SLOP 0x01'}
    CARET_STRICT = $04;
    {$EXTERNALSYM CARET_STRICT}
    {$HPPEMIT '#define CARET_STRICT 0x04'}
    CARET_JUMPS = $10;
    {$EXTERNALSYM CARET_JUMPS}
    {$HPPEMIT '#define CARET_JUMPS 0x10'}
    CARET_EVEN = $08;
    {$EXTERNALSYM CARET_EVEN}
    {$HPPEMIT '#define CARET_EVEN 0x08'}
    SCI_SETXCARETPOLICY = 2402;
    {$EXTERNALSYM SCI_SETXCARETPOLICY}
    {$HPPEMIT '#define SCI_SETXCARETPOLICY 2402'}
    SCI_SETYCARETPOLICY = 2403;
    {$EXTERNALSYM SCI_SETYCARETPOLICY}
    {$HPPEMIT '#define SCI_SETYCARETPOLICY 2403'}
    SCI_SETPRINTWRAPMODE = 2406;
    {$EXTERNALSYM SCI_SETPRINTWRAPMODE}
    {$HPPEMIT '#define SCI_SETPRINTWRAPMODE 2406'}
    SCI_GETPRINTWRAPMODE = 2407;
    {$EXTERNALSYM SCI_GETPRINTWRAPMODE}
    {$HPPEMIT '#define SCI_GETPRINTWRAPMODE 2407'}
    SCI_SETHOTSPOTACTIVEFORE = 2410;
    {$EXTERNALSYM SCI_SETHOTSPOTACTIVEFORE}
    {$HPPEMIT '#define SCI_SETHOTSPOTACTIVEFORE 2410'}
    SCI_SETHOTSPOTACTIVEBACK = 2411;
    {$EXTERNALSYM SCI_SETHOTSPOTACTIVEBACK}
    {$HPPEMIT '#define SCI_SETHOTSPOTACTIVEBACK 2411'}
    SCI_SETHOTSPOTACTIVEUNDERLINE = 2412;
    {$EXTERNALSYM SCI_SETHOTSPOTACTIVEUNDERLINE}
    {$HPPEMIT '#define SCI_SETHOTSPOTACTIVEUNDERLINE 2412'}
    SCI_SETHOTSPOTSINGLELINE = 2421;
    {$EXTERNALSYM SCI_SETHOTSPOTSINGLELINE}
    {$HPPEMIT '#define SCI_SETHOTSPOTSINGLELINE 2421'}
    SCI_PARADOWN = 2413;
    {$EXTERNALSYM SCI_PARADOWN}
    {$HPPEMIT '#define SCI_PARADOWN 2413'}
    SCI_PARADOWNEXTEND = 2414;
    {$EXTERNALSYM SCI_PARADOWNEXTEND}
    {$HPPEMIT '#define SCI_PARADOWNEXTEND 2414'}
    SCI_PARAUP = 2415;
    {$EXTERNALSYM SCI_PARAUP}
    {$HPPEMIT '#define SCI_PARAUP 2415'}
    SCI_PARAUPEXTEND = 2416;
    {$EXTERNALSYM SCI_PARAUPEXTEND}
    {$HPPEMIT '#define SCI_PARAUPEXTEND 2416'}
    SCI_POSITIONBEFORE = 2417;
    {$EXTERNALSYM SCI_POSITIONBEFORE}
    {$HPPEMIT '#define SCI_POSITIONBEFORE 2417'}
    SCI_POSITIONAFTER = 2418;
    {$EXTERNALSYM SCI_POSITIONAFTER}
    {$HPPEMIT '#define SCI_POSITIONAFTER 2418'}
    SCI_COPYRANGE = 2419;
    {$EXTERNALSYM SCI_COPYRANGE}
    {$HPPEMIT '#define SCI_COPYRANGE 2419'}
    SCI_COPYTEXT = 2420;
    {$EXTERNALSYM SCI_COPYTEXT}
    {$HPPEMIT '#define SCI_COPYTEXT 2420'}
    SC_SEL_STREAM = 0;
    {$EXTERNALSYM SC_SEL_STREAM}
    {$HPPEMIT '#define SC_SEL_STREAM 0'}
    SC_SEL_RECTANGLE = 1;
    {$EXTERNALSYM SC_SEL_RECTANGLE}
    {$HPPEMIT '#define SC_SEL_RECTANGLE 1'}
    SC_SEL_LINES = 2;
    {$EXTERNALSYM SC_SEL_LINES}
    {$HPPEMIT '#define SC_SEL_LINES 2'}
    SCI_SETSELECTIONMODE = 2422;
    {$EXTERNALSYM SCI_SETSELECTIONMODE}
    {$HPPEMIT '#define SCI_SETSELECTIONMODE 2422'}
    SCI_GETSELECTIONMODE = 2423;
    {$EXTERNALSYM SCI_GETSELECTIONMODE}
    {$HPPEMIT '#define SCI_GETSELECTIONMODE 2423'}
    SCI_GETLINESELSTARTPOSITION = 2424;
    {$EXTERNALSYM SCI_GETLINESELSTARTPOSITION}
    {$HPPEMIT '#define SCI_GETLINESELSTARTPOSITION 2424'}
    SCI_GETLINESELENDPOSITION = 2425;
    {$EXTERNALSYM SCI_GETLINESELENDPOSITION}
    {$HPPEMIT '#define SCI_GETLINESELENDPOSITION 2425'}
    SCI_LINEDOWNRECTEXTEND = 2426;
    {$EXTERNALSYM SCI_LINEDOWNRECTEXTEND}
    {$HPPEMIT '#define SCI_LINEDOWNRECTEXTEND 2426'}
    SCI_LINEUPRECTEXTEND = 2427;
    {$EXTERNALSYM SCI_LINEUPRECTEXTEND}
    {$HPPEMIT '#define SCI_LINEUPRECTEXTEND 2427'}
    SCI_CHARLEFTRECTEXTEND = 2428;
    {$EXTERNALSYM SCI_CHARLEFTRECTEXTEND}
    {$HPPEMIT '#define SCI_CHARLEFTRECTEXTEND 2428'}
    SCI_CHARRIGHTRECTEXTEND = 2429;
    {$EXTERNALSYM SCI_CHARRIGHTRECTEXTEND}
    {$HPPEMIT '#define SCI_CHARRIGHTRECTEXTEND 2429'}
    SCI_HOMERECTEXTEND = 2430;
    {$EXTERNALSYM SCI_HOMERECTEXTEND}
    {$HPPEMIT '#define SCI_HOMERECTEXTEND 2430'}
    SCI_VCHOMERECTEXTEND = 2431;
    {$EXTERNALSYM SCI_VCHOMERECTEXTEND}
    {$HPPEMIT '#define SCI_VCHOMERECTEXTEND 2431'}
    SCI_LINEENDRECTEXTEND = 2432;
    {$EXTERNALSYM SCI_LINEENDRECTEXTEND}
    {$HPPEMIT '#define SCI_LINEENDRECTEXTEND 2432'}
    SCI_PAGEUPRECTEXTEND = 2433;
    {$EXTERNALSYM SCI_PAGEUPRECTEXTEND}
    {$HPPEMIT '#define SCI_PAGEUPRECTEXTEND 2433'}
    SCI_PAGEDOWNRECTEXTEND = 2434;
    {$EXTERNALSYM SCI_PAGEDOWNRECTEXTEND}
    {$HPPEMIT '#define SCI_PAGEDOWNRECTEXTEND 2434'}
    SCI_STUTTEREDPAGEUP = 2435;
    {$EXTERNALSYM SCI_STUTTEREDPAGEUP}
    {$HPPEMIT '#define SCI_STUTTEREDPAGEUP 2435'}
    SCI_STUTTEREDPAGEUPEXTEND = 2436;
    {$EXTERNALSYM SCI_STUTTEREDPAGEUPEXTEND}
    {$HPPEMIT '#define SCI_STUTTEREDPAGEUPEXTEND 2436'}
    SCI_STUTTEREDPAGEDOWN = 2437;
    {$EXTERNALSYM SCI_STUTTEREDPAGEDOWN}
    {$HPPEMIT '#define SCI_STUTTEREDPAGEDOWN 2437'}
    SCI_STUTTEREDPAGEDOWNEXTEND = 2438;
    {$EXTERNALSYM SCI_STUTTEREDPAGEDOWNEXTEND}
    {$HPPEMIT '#define SCI_STUTTEREDPAGEDOWNEXTEND 2438'}
    SCI_WORDLEFTEND = 2439;
    {$EXTERNALSYM SCI_WORDLEFTEND}
    {$HPPEMIT '#define SCI_WORDLEFTEND 2439'}
    SCI_WORDLEFTENDEXTEND = 2440;
    {$EXTERNALSYM SCI_WORDLEFTENDEXTEND}
    {$HPPEMIT '#define SCI_WORDLEFTENDEXTEND 2440'}
    SCI_WORDRIGHTEND = 2441;
    {$EXTERNALSYM SCI_WORDRIGHTEND}
    {$HPPEMIT '#define SCI_WORDRIGHTEND 2441'}
    SCI_WORDRIGHTENDEXTEND = 2442;
    {$EXTERNALSYM SCI_WORDRIGHTENDEXTEND}
    {$HPPEMIT '#define SCI_WORDRIGHTENDEXTEND 2442'}
    SCI_SETWHITESPACECHARS = 2443;
    {$EXTERNALSYM SCI_SETWHITESPACECHARS}
    {$HPPEMIT '#define SCI_SETWHITESPACECHARS 2443'}
    SCI_SETCHARSDEFAULT = 2444;
    {$EXTERNALSYM SCI_SETCHARSDEFAULT}
    {$HPPEMIT '#define SCI_SETCHARSDEFAULT 2444'}
    SCI_AUTOCGETCURRENT = 2445;
    {$EXTERNALSYM SCI_AUTOCGETCURRENT}
    {$HPPEMIT '#define SCI_AUTOCGETCURRENT 2445'}
    SCI_ALLOCATE = 2446;
    {$EXTERNALSYM SCI_ALLOCATE}
    {$HPPEMIT '#define SCI_ALLOCATE 2446'}
    SCI_FINDCOLUMN = 2456;
    {$EXTERNALSYM SCI_FINDCOLUMN}
    {$HPPEMIT '#define SCI_FINDCOLUMN 2456'}
    SCI_GETCARETSTICKY = 2457;
    {$EXTERNALSYM SCI_GETCARETSTICKY}
    {$HPPEMIT '#define SCI_GETCARETSTICKY 2457'}
    SCI_SETCARETSTICKY = 2458;
    {$EXTERNALSYM SCI_SETCARETSTICKY}
    {$HPPEMIT '#define SCI_SETCARETSTICKY 2458'}
    SCI_TOGGLECARETSTICKY = 2459;
    {$EXTERNALSYM SCI_TOGGLECARETSTICKY}
    {$HPPEMIT '#define SCI_TOGGLECARETSTICKY 2459'}
    SCI_SETPASTECONVERTENDINGS = 2467;
    {$EXTERNALSYM SCI_SETPASTECONVERTENDINGS}
    {$HPPEMIT '#define SCI_SETPASTECONVERTENDINGS 2467'}
    SCI_GETPASTECONVERTENDINGS = 2468;
    {$EXTERNALSYM SCI_GETPASTECONVERTENDINGS}
    {$HPPEMIT '#define SCI_GETPASTECONVERTENDINGS 2468'}
    SCI_SELECTIONDUPLICATE = 2469;
    {$EXTERNALSYM SCI_SELECTIONDUPLICATE}
    {$HPPEMIT '#define SCI_SELECTIONDUPLICATE 2469'}
    SC_ALPHA_TRANSPARENT = 0;
    {$EXTERNALSYM SC_ALPHA_TRANSPARENT}
    {$HPPEMIT '#define SC_ALPHA_TRANSPARENT 0'}
    SC_ALPHA_OPAQUE = 255;
    {$EXTERNALSYM SC_ALPHA_OPAQUE}
    {$HPPEMIT '#define SC_ALPHA_OPAQUE 255'}
    SC_ALPHA_NOALPHA = 256;
    {$EXTERNALSYM SC_ALPHA_NOALPHA}
    {$HPPEMIT '#define SC_ALPHA_NOALPHA 256'}
    SCI_SETCARETLINEBACKALPHA = 2470;
    {$EXTERNALSYM SCI_SETCARETLINEBACKALPHA}
    {$HPPEMIT '#define SCI_SETCARETLINEBACKALPHA 2470'}
    SCI_GETCARETLINEBACKALPHA = 2471;
    {$EXTERNALSYM SCI_GETCARETLINEBACKALPHA}
    {$HPPEMIT '#define SCI_GETCARETLINEBACKALPHA 2471'}
    SCI_STARTRECORD = 3001;
    {$EXTERNALSYM SCI_STARTRECORD}
    {$HPPEMIT '#define SCI_STARTRECORD 3001'}
    SCI_STOPRECORD = 3002;
    {$EXTERNALSYM SCI_STOPRECORD}
    {$HPPEMIT '#define SCI_STOPRECORD 3002'}
    SCI_SETLEXER = 4001;
    {$EXTERNALSYM SCI_SETLEXER}
    {$HPPEMIT '#define SCI_SETLEXER 4001'}
    SCI_GETLEXER = 4002;
    {$EXTERNALSYM SCI_GETLEXER}
    {$HPPEMIT '#define SCI_GETLEXER 4002'}
    SCI_COLOURISE = 4003;
    {$EXTERNALSYM SCI_COLOURISE}
    {$HPPEMIT '#define SCI_COLOURISE 4003'}
    SCI_SETPROPERTY = 4004;
    {$EXTERNALSYM SCI_SETPROPERTY}
    {$HPPEMIT '#define SCI_SETPROPERTY 4004'}
    KEYWORDSET_MAX = 8;
    {$EXTERNALSYM KEYWORDSET_MAX}
    {$HPPEMIT '#define KEYWORDSET_MAX 8'}
    SCI_SETKEYWORDS = 4005;
    {$EXTERNALSYM SCI_SETKEYWORDS}
    {$HPPEMIT '#define SCI_SETKEYWORDS 4005'}
    SCI_SETLEXERLANGUAGE = 4006;
    {$EXTERNALSYM SCI_SETLEXERLANGUAGE}
    {$HPPEMIT '#define SCI_SETLEXERLANGUAGE 4006'}
    SCI_LOADLEXERLIBRARY = 4007;
    {$EXTERNALSYM SCI_LOADLEXERLIBRARY}
    {$HPPEMIT '#define SCI_LOADLEXERLIBRARY 4007'}
    SCI_GETPROPERTY = 4008;
    {$EXTERNALSYM SCI_GETPROPERTY}
    {$HPPEMIT '#define SCI_GETPROPERTY 4008'}
    SCI_GETPROPERTYEXPANDED = 4009;
    {$EXTERNALSYM SCI_GETPROPERTYEXPANDED}
    {$HPPEMIT '#define SCI_GETPROPERTYEXPANDED 4009'}
    SCI_GETPROPERTYINT = 4010;
    {$EXTERNALSYM SCI_GETPROPERTYINT}
    {$HPPEMIT '#define SCI_GETPROPERTYINT 4010'}
    SCI_GETSTYLEBITSNEEDED = 4011;
    {$EXTERNALSYM SCI_GETSTYLEBITSNEEDED}
    {$HPPEMIT '#define SCI_GETSTYLEBITSNEEDED 4011'}
    SC_MOD_INSERTTEXT = $1;
    {$EXTERNALSYM SC_MOD_INSERTTEXT}
    {$HPPEMIT '#define SC_MOD_INSERTTEXT 0x1'}
    SC_MOD_DELETETEXT = $2;
    {$EXTERNALSYM SC_MOD_DELETETEXT}
    {$HPPEMIT '#define SC_MOD_DELETETEXT 0x2'}
    SC_MOD_CHANGESTYLE = $4;
    {$EXTERNALSYM SC_MOD_CHANGESTYLE}
    {$HPPEMIT '#define SC_MOD_CHANGESTYLE 0x4'}
    SC_MOD_CHANGEFOLD = $8;
    {$EXTERNALSYM SC_MOD_CHANGEFOLD}
    {$HPPEMIT '#define SC_MOD_CHANGEFOLD 0x8'}
    SC_PERFORMED_USER = $10;
    {$EXTERNALSYM SC_PERFORMED_USER}
    {$HPPEMIT '#define SC_PERFORMED_USER 0x10'}
    SC_PERFORMED_UNDO = $20;
    {$EXTERNALSYM SC_PERFORMED_UNDO}
    {$HPPEMIT '#define SC_PERFORMED_UNDO 0x20'}
    SC_PERFORMED_REDO = $40;
    {$EXTERNALSYM SC_PERFORMED_REDO}
    {$HPPEMIT '#define SC_PERFORMED_REDO 0x40'}
    SC_MULTISTEPUNDOREDO = $80;
    {$EXTERNALSYM SC_MULTISTEPUNDOREDO}
    {$HPPEMIT '#define SC_MULTISTEPUNDOREDO 0x80'}
    SC_LASTSTEPINUNDOREDO = $100;
    {$EXTERNALSYM SC_LASTSTEPINUNDOREDO}
    {$HPPEMIT '#define SC_LASTSTEPINUNDOREDO 0x100'}
    SC_MOD_CHANGEMARKER = $200;
    {$EXTERNALSYM SC_MOD_CHANGEMARKER}
    {$HPPEMIT '#define SC_MOD_CHANGEMARKER 0x200'}
    SC_MOD_BEFOREINSERT = $400;
    {$EXTERNALSYM SC_MOD_BEFOREINSERT}
    {$HPPEMIT '#define SC_MOD_BEFOREINSERT 0x400'}
    SC_MOD_BEFOREDELETE = $800;
    {$EXTERNALSYM SC_MOD_BEFOREDELETE}
    {$HPPEMIT '#define SC_MOD_BEFOREDELETE 0x800'}
    SC_MULTILINEUNDOREDO = $1000;
    {$EXTERNALSYM SC_MULTILINEUNDOREDO}
    {$HPPEMIT '#define SC_MULTILINEUNDOREDO 0x1000'}
    SC_MODEVENTMASKALL = $1FFF;
    {$EXTERNALSYM SC_MODEVENTMASKALL}
    {$HPPEMIT '#define SC_MODEVENTMASKALL 0x1FFF'}
    SCEN_CHANGE = 768;
    {$EXTERNALSYM SCEN_CHANGE}
    {$HPPEMIT '#define SCEN_CHANGE 768'}
    SCEN_SETFOCUS = 512;
    {$EXTERNALSYM SCEN_SETFOCUS}
    {$HPPEMIT '#define SCEN_SETFOCUS 512'}
    SCEN_KILLFOCUS = 256;
    {$EXTERNALSYM SCEN_KILLFOCUS}
    {$HPPEMIT '#define SCEN_KILLFOCUS 256'}
    SCK_DOWN = 300;
    {$EXTERNALSYM SCK_DOWN}
    {$HPPEMIT '#define SCK_DOWN 300'}
    SCK_UP = 301;
    {$EXTERNALSYM SCK_UP}
    {$HPPEMIT '#define SCK_UP 301'}
    SCK_LEFT = 302;
    {$EXTERNALSYM SCK_LEFT}
    {$HPPEMIT '#define SCK_LEFT 302'}
    SCK_RIGHT = 303;
    {$EXTERNALSYM SCK_RIGHT}
    {$HPPEMIT '#define SCK_RIGHT 303'}
    SCK_HOME = 304;
    {$EXTERNALSYM SCK_HOME}
    {$HPPEMIT '#define SCK_HOME 304'}
    SCK_END = 305;
    {$EXTERNALSYM SCK_END}
    {$HPPEMIT '#define SCK_END 305'}
    SCK_PRIOR = 306;
    {$EXTERNALSYM SCK_PRIOR}
    {$HPPEMIT '#define SCK_PRIOR 306'}
    SCK_NEXT = 307;
    {$EXTERNALSYM SCK_NEXT}
    {$HPPEMIT '#define SCK_NEXT 307'}
    SCK_DELETE = 308;
    {$EXTERNALSYM SCK_DELETE}
    {$HPPEMIT '#define SCK_DELETE 308'}
    SCK_INSERT = 309;
    {$EXTERNALSYM SCK_INSERT}
    {$HPPEMIT '#define SCK_INSERT 309'}
    SCK_ESCAPE = 7;
    {$EXTERNALSYM SCK_ESCAPE}
    {$HPPEMIT '#define SCK_ESCAPE 7'}
    SCK_BACK = 8;
    {$EXTERNALSYM SCK_BACK}
    {$HPPEMIT '#define SCK_BACK 8'}
    SCK_TAB = 9;
    {$EXTERNALSYM SCK_TAB}
    {$HPPEMIT '#define SCK_TAB 9'}
    SCK_RETURN = 13;
    {$EXTERNALSYM SCK_RETURN}
    {$HPPEMIT '#define SCK_RETURN 13'}
    SCK_ADD = 310;
    {$EXTERNALSYM SCK_ADD}
    {$HPPEMIT '#define SCK_ADD 310'}
    SCK_SUBTRACT = 311;
    {$EXTERNALSYM SCK_SUBTRACT}
    {$HPPEMIT '#define SCK_SUBTRACT 311'}
    SCK_DIVIDE = 312;
    {$EXTERNALSYM SCK_DIVIDE}
    {$HPPEMIT '#define SCK_DIVIDE 312'}
    SCK_WIN = 313;
    {$EXTERNALSYM SCK_WIN}
    {$HPPEMIT '#define SCK_WIN 313'}
    SCK_RWIN = 314;
    {$EXTERNALSYM SCK_RWIN}
    {$HPPEMIT '#define SCK_RWIN 314'}
    SCK_MENU = 315;
    {$EXTERNALSYM SCK_MENU}
    {$HPPEMIT '#define SCK_MENU 315'}
    SCMOD_NORM = 0;
    {$EXTERNALSYM SCMOD_NORM}
    {$HPPEMIT '#define SCMOD_NORM 0'}
    SCMOD_SHIFT = 1;
    {$EXTERNALSYM SCMOD_SHIFT}
    {$HPPEMIT '#define SCMOD_SHIFT 1'}
    SCMOD_CTRL = 2;
    {$EXTERNALSYM SCMOD_CTRL}
    {$HPPEMIT '#define SCMOD_CTRL 2'}
    SCMOD_ALT = 4;
    {$EXTERNALSYM SCMOD_ALT}
    {$HPPEMIT '#define SCMOD_ALT 4'}
    SCLEX_CONTAINER = 0;
    {$EXTERNALSYM SCLEX_CONTAINER}
    {$HPPEMIT '#define SCLEX_CONTAINER 0'}
    SCLEX_NULL = 1;
    {$EXTERNALSYM SCLEX_NULL}
    {$HPPEMIT '#define SCLEX_NULL 1'}
    SCLEX_PYTHON = 2;
    {$EXTERNALSYM SCLEX_PYTHON}
    {$HPPEMIT '#define SCLEX_PYTHON 2'}
    SCLEX_CPP = 3;
    {$EXTERNALSYM SCLEX_CPP}
    {$HPPEMIT '#define SCLEX_CPP 3'}
    SCLEX_HTML = 4;
    {$EXTERNALSYM SCLEX_HTML}
    {$HPPEMIT '#define SCLEX_HTML 4'}
    SCLEX_XML = 5;
    {$EXTERNALSYM SCLEX_XML}
    {$HPPEMIT '#define SCLEX_XML 5'}
    SCLEX_PERL = 6;
    {$EXTERNALSYM SCLEX_PERL}
    {$HPPEMIT '#define SCLEX_PERL 6'}
    SCLEX_SQL = 7;
    {$EXTERNALSYM SCLEX_SQL}
    {$HPPEMIT '#define SCLEX_SQL 7'}
    SCLEX_VB = 8;
    {$EXTERNALSYM SCLEX_VB}
    {$HPPEMIT '#define SCLEX_VB 8'}
    SCLEX_PROPERTIES = 9;
    {$EXTERNALSYM SCLEX_PROPERTIES}
    {$HPPEMIT '#define SCLEX_PROPERTIES 9'}
    SCLEX_ERRORLIST = 10;
    {$EXTERNALSYM SCLEX_ERRORLIST}
    {$HPPEMIT '#define SCLEX_ERRORLIST 10'}
    SCLEX_MAKEFILE = 11;
    {$EXTERNALSYM SCLEX_MAKEFILE}
    {$HPPEMIT '#define SCLEX_MAKEFILE 11'}
    SCLEX_BATCH = 12;
    {$EXTERNALSYM SCLEX_BATCH}
    {$HPPEMIT '#define SCLEX_BATCH 12'}
    SCLEX_XCODE = 13;
    {$EXTERNALSYM SCLEX_XCODE}
    {$HPPEMIT '#define SCLEX_XCODE 13'}
    SCLEX_LATEX = 14;
    {$EXTERNALSYM SCLEX_LATEX}
    {$HPPEMIT '#define SCLEX_LATEX 14'}
    SCLEX_LUA = 15;
    {$EXTERNALSYM SCLEX_LUA}
    {$HPPEMIT '#define SCLEX_LUA 15'}
    SCLEX_DIFF = 16;
    {$EXTERNALSYM SCLEX_DIFF}
    {$HPPEMIT '#define SCLEX_DIFF 16'}
    SCLEX_CONF = 17;
    {$EXTERNALSYM SCLEX_CONF}
    {$HPPEMIT '#define SCLEX_CONF 17'}
    SCLEX_PASCAL = 18;
    {$EXTERNALSYM SCLEX_PASCAL}
    {$HPPEMIT '#define SCLEX_PASCAL 18'}
    SCLEX_AVE = 19;
    {$EXTERNALSYM SCLEX_AVE}
    {$HPPEMIT '#define SCLEX_AVE 19'}
    SCLEX_ADA = 20;
    {$EXTERNALSYM SCLEX_ADA}
    {$HPPEMIT '#define SCLEX_ADA 20'}
    SCLEX_LISP = 21;
    {$EXTERNALSYM SCLEX_LISP}
    {$HPPEMIT '#define SCLEX_LISP 21'}
    SCLEX_RUBY = 22;
    {$EXTERNALSYM SCLEX_RUBY}
    {$HPPEMIT '#define SCLEX_RUBY 22'}
    SCLEX_EIFFEL = 23;
    {$EXTERNALSYM SCLEX_EIFFEL}
    {$HPPEMIT '#define SCLEX_EIFFEL 23'}
    SCLEX_EIFFELKW = 24;
    {$EXTERNALSYM SCLEX_EIFFELKW}
    {$HPPEMIT '#define SCLEX_EIFFELKW 24'}
    SCLEX_TCL = 25;
    {$EXTERNALSYM SCLEX_TCL}
    {$HPPEMIT '#define SCLEX_TCL 25'}
    SCLEX_NNCRONTAB = 26;
    {$EXTERNALSYM SCLEX_NNCRONTAB}
    {$HPPEMIT '#define SCLEX_NNCRONTAB 26'}
    SCLEX_BULLANT = 27;
    {$EXTERNALSYM SCLEX_BULLANT}
    {$HPPEMIT '#define SCLEX_BULLANT 27'}
    SCLEX_VBSCRIPT = 28;
    {$EXTERNALSYM SCLEX_VBSCRIPT}
    {$HPPEMIT '#define SCLEX_VBSCRIPT 28'}
    SCLEX_BAAN = 31;
    {$EXTERNALSYM SCLEX_BAAN}
    {$HPPEMIT '#define SCLEX_BAAN 31'}
    SCLEX_MATLAB = 32;
    {$EXTERNALSYM SCLEX_MATLAB}
    {$HPPEMIT '#define SCLEX_MATLAB 32'}
    SCLEX_SCRIPTOL = 33;
    {$EXTERNALSYM SCLEX_SCRIPTOL}
    {$HPPEMIT '#define SCLEX_SCRIPTOL 33'}
    SCLEX_ASM = 34;
    {$EXTERNALSYM SCLEX_ASM}
    {$HPPEMIT '#define SCLEX_ASM 34'}
    SCLEX_CPPNOCASE = 35;
    {$EXTERNALSYM SCLEX_CPPNOCASE}
    {$HPPEMIT '#define SCLEX_CPPNOCASE 35'}
    SCLEX_FORTRAN = 36;
    {$EXTERNALSYM SCLEX_FORTRAN}
    {$HPPEMIT '#define SCLEX_FORTRAN 36'}
    SCLEX_F77 = 37;
    {$EXTERNALSYM SCLEX_F77}
    {$HPPEMIT '#define SCLEX_F77 37'}
    SCLEX_CSS = 38;
    {$EXTERNALSYM SCLEX_CSS}
    {$HPPEMIT '#define SCLEX_CSS 38'}
    SCLEX_POV = 39;
    {$EXTERNALSYM SCLEX_POV}
    {$HPPEMIT '#define SCLEX_POV 39'}
    SCLEX_LOUT = 40;
    {$EXTERNALSYM SCLEX_LOUT}
    {$HPPEMIT '#define SCLEX_LOUT 40'}
    SCLEX_ESCRIPT = 41;
    {$EXTERNALSYM SCLEX_ESCRIPT}
    {$HPPEMIT '#define SCLEX_ESCRIPT 41'}
    SCLEX_PS = 42;
    {$EXTERNALSYM SCLEX_PS}
    {$HPPEMIT '#define SCLEX_PS 42'}
    SCLEX_NSIS = 43;
    {$EXTERNALSYM SCLEX_NSIS}
    {$HPPEMIT '#define SCLEX_NSIS 43'}
    SCLEX_MMIXAL = 44;
    {$EXTERNALSYM SCLEX_MMIXAL}
    {$HPPEMIT '#define SCLEX_MMIXAL 44'}
    SCLEX_CLW = 45;
    {$EXTERNALSYM SCLEX_CLW}
    {$HPPEMIT '#define SCLEX_CLW 45'}
    SCLEX_CLWNOCASE = 46;
    {$EXTERNALSYM SCLEX_CLWNOCASE}
    {$HPPEMIT '#define SCLEX_CLWNOCASE 46'}
    SCLEX_LOT = 47;
    {$EXTERNALSYM SCLEX_LOT}
    {$HPPEMIT '#define SCLEX_LOT 47'}
    SCLEX_YAML = 48;
    {$EXTERNALSYM SCLEX_YAML}
    {$HPPEMIT '#define SCLEX_YAML 48'}
    SCLEX_TEX = 49;
    {$EXTERNALSYM SCLEX_TEX}
    {$HPPEMIT '#define SCLEX_TEX 49'}
    SCLEX_METAPOST = 50;
    {$EXTERNALSYM SCLEX_METAPOST}
    {$HPPEMIT '#define SCLEX_METAPOST 50'}
    SCLEX_POWERBASIC = 51;
    {$EXTERNALSYM SCLEX_POWERBASIC}
    {$HPPEMIT '#define SCLEX_POWERBASIC 51'}
    SCLEX_FORTH = 52;
    {$EXTERNALSYM SCLEX_FORTH}
    {$HPPEMIT '#define SCLEX_FORTH 52'}
    SCLEX_ERLANG = 53;
    {$EXTERNALSYM SCLEX_ERLANG}
    {$HPPEMIT '#define SCLEX_ERLANG 53'}
    SCLEX_OCTAVE = 54;
    {$EXTERNALSYM SCLEX_OCTAVE}
    {$HPPEMIT '#define SCLEX_OCTAVE 54'}
    SCLEX_MSSQL = 55;
    {$EXTERNALSYM SCLEX_MSSQL}
    {$HPPEMIT '#define SCLEX_MSSQL 55'}
    SCLEX_VERILOG = 56;
    {$EXTERNALSYM SCLEX_VERILOG}
    {$HPPEMIT '#define SCLEX_VERILOG 56'}
    SCLEX_KIX = 57;
    {$EXTERNALSYM SCLEX_KIX}
    {$HPPEMIT '#define SCLEX_KIX 57'}
    SCLEX_GUI4CLI = 58;
    {$EXTERNALSYM SCLEX_GUI4CLI}
    {$HPPEMIT '#define SCLEX_GUI4CLI 58'}
    SCLEX_SPECMAN = 59;
    {$EXTERNALSYM SCLEX_SPECMAN}
    {$HPPEMIT '#define SCLEX_SPECMAN 59'}
    SCLEX_AU3 = 60;
    {$EXTERNALSYM SCLEX_AU3}
    {$HPPEMIT '#define SCLEX_AU3 60'}
    SCLEX_APDL = 61;
    {$EXTERNALSYM SCLEX_APDL}
    {$HPPEMIT '#define SCLEX_APDL 61'}
    SCLEX_BASH = 62;
    {$EXTERNALSYM SCLEX_BASH}
    {$HPPEMIT '#define SCLEX_BASH 62'}
    SCLEX_ASN1 = 63;
    {$EXTERNALSYM SCLEX_ASN1}
    {$HPPEMIT '#define SCLEX_ASN1 63'}
    SCLEX_VHDL = 64;
    {$EXTERNALSYM SCLEX_VHDL}
    {$HPPEMIT '#define SCLEX_VHDL 64'}
    SCLEX_CAML = 65;
    {$EXTERNALSYM SCLEX_CAML}
    {$HPPEMIT '#define SCLEX_CAML 65'}
    SCLEX_BLITZBASIC = 66;
    {$EXTERNALSYM SCLEX_BLITZBASIC}
    {$HPPEMIT '#define SCLEX_BLITZBASIC 66'}
    SCLEX_PUREBASIC = 67;
    {$EXTERNALSYM SCLEX_PUREBASIC}
    {$HPPEMIT '#define SCLEX_PUREBASIC 67'}
    SCLEX_HASKELL = 68;
    {$EXTERNALSYM SCLEX_HASKELL}
    {$HPPEMIT '#define SCLEX_HASKELL 68'}
    SCLEX_PHPSCRIPT = 69;
    {$EXTERNALSYM SCLEX_PHPSCRIPT}
    {$HPPEMIT '#define SCLEX_PHPSCRIPT 69'}
    SCLEX_TADS3 = 70;
    {$EXTERNALSYM SCLEX_TADS3}
    {$HPPEMIT '#define SCLEX_TADS3 70'}
    SCLEX_REBOL = 71;
    {$EXTERNALSYM SCLEX_REBOL}
    {$HPPEMIT '#define SCLEX_REBOL 71'}
    SCLEX_SMALLTALK = 72;
    {$EXTERNALSYM SCLEX_SMALLTALK}
    {$HPPEMIT '#define SCLEX_SMALLTALK 72'}
    SCLEX_FLAGSHIP = 73;
    {$EXTERNALSYM SCLEX_FLAGSHIP}
    {$HPPEMIT '#define SCLEX_FLAGSHIP 73'}
    SCLEX_CSOUND = 74;
    {$EXTERNALSYM SCLEX_CSOUND}
    {$HPPEMIT '#define SCLEX_CSOUND 74'}
    SCLEX_FREEBASIC = 75;
    {$EXTERNALSYM SCLEX_FREEBASIC}
    {$HPPEMIT '#define SCLEX_FREEBASIC 75'}
    SCLEX_INNOSETUP = 76;
    {$EXTERNALSYM SCLEX_INNOSETUP}
    {$HPPEMIT '#define SCLEX_INNOSETUP 76'}
    SCLEX_OPAL = 77;
    {$EXTERNALSYM SCLEX_OPAL}
    {$HPPEMIT '#define SCLEX_OPAL 77'}
    SCLEX_SPICE = 78;
    {$EXTERNALSYM SCLEX_SPICE}
    {$HPPEMIT '#define SCLEX_SPICE 78'}
    SCLEX_AUTOMATIC = 1000;
    {$EXTERNALSYM SCLEX_AUTOMATIC}
    {$HPPEMIT '#define SCLEX_AUTOMATIC 1000'}
    SCE_P_DEFAULT = 0;
    {$EXTERNALSYM SCE_P_DEFAULT}
    {$HPPEMIT '#define SCE_P_DEFAULT 0'}
    SCE_P_COMMENTLINE = 1;
    {$EXTERNALSYM SCE_P_COMMENTLINE}
    {$HPPEMIT '#define SCE_P_COMMENTLINE 1'}
    SCE_P_NUMBER = 2;
    {$EXTERNALSYM SCE_P_NUMBER}
    {$HPPEMIT '#define SCE_P_NUMBER 2'}
    SCE_P_STRING = 3;
    {$EXTERNALSYM SCE_P_STRING}
    {$HPPEMIT '#define SCE_P_STRING 3'}
    SCE_P_CHARACTER = 4;
    {$EXTERNALSYM SCE_P_CHARACTER}
    {$HPPEMIT '#define SCE_P_CHARACTER 4'}
    SCE_P_WORD = 5;
    {$EXTERNALSYM SCE_P_WORD}
    {$HPPEMIT '#define SCE_P_WORD 5'}
    SCE_P_TRIPLE = 6;
    {$EXTERNALSYM SCE_P_TRIPLE}
    {$HPPEMIT '#define SCE_P_TRIPLE 6'}
    SCE_P_TRIPLEDOUBLE = 7;
    {$EXTERNALSYM SCE_P_TRIPLEDOUBLE}
    {$HPPEMIT '#define SCE_P_TRIPLEDOUBLE 7'}
    SCE_P_CLASSNAME = 8;
    {$EXTERNALSYM SCE_P_CLASSNAME}
    {$HPPEMIT '#define SCE_P_CLASSNAME 8'}
    SCE_P_DEFNAME = 9;
    {$EXTERNALSYM SCE_P_DEFNAME}
    {$HPPEMIT '#define SCE_P_DEFNAME 9'}
    SCE_P_OPERATOR = 10;
    {$EXTERNALSYM SCE_P_OPERATOR}
    {$HPPEMIT '#define SCE_P_OPERATOR 10'}
    SCE_P_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_P_IDENTIFIER}
    {$HPPEMIT '#define SCE_P_IDENTIFIER 11'}
    SCE_P_COMMENTBLOCK = 12;
    {$EXTERNALSYM SCE_P_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_P_COMMENTBLOCK 12'}
    SCE_P_STRINGEOL = 13;
    {$EXTERNALSYM SCE_P_STRINGEOL}
    {$HPPEMIT '#define SCE_P_STRINGEOL 13'}
    SCE_P_WORD2 = 14;
    {$EXTERNALSYM SCE_P_WORD2}
    {$HPPEMIT '#define SCE_P_WORD2 14'}
    SCE_P_DECORATOR = 15;
    {$EXTERNALSYM SCE_P_DECORATOR}
    {$HPPEMIT '#define SCE_P_DECORATOR 15'}
    SCE_C_DEFAULT = 0;
    {$EXTERNALSYM SCE_C_DEFAULT}
    {$HPPEMIT '#define SCE_C_DEFAULT 0'}
    SCE_C_COMMENT = 1;
    {$EXTERNALSYM SCE_C_COMMENT}
    {$HPPEMIT '#define SCE_C_COMMENT 1'}
    SCE_C_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_C_COMMENTLINE}
    {$HPPEMIT '#define SCE_C_COMMENTLINE 2'}
    SCE_C_COMMENTDOC = 3;
    {$EXTERNALSYM SCE_C_COMMENTDOC}
    {$HPPEMIT '#define SCE_C_COMMENTDOC 3'}
    SCE_C_NUMBER = 4;
    {$EXTERNALSYM SCE_C_NUMBER}
    {$HPPEMIT '#define SCE_C_NUMBER 4'}
    SCE_C_WORD = 5;
    {$EXTERNALSYM SCE_C_WORD}
    {$HPPEMIT '#define SCE_C_WORD 5'}
    SCE_C_STRING = 6;
    {$EXTERNALSYM SCE_C_STRING}
    {$HPPEMIT '#define SCE_C_STRING 6'}
    SCE_C_CHARACTER = 7;
    {$EXTERNALSYM SCE_C_CHARACTER}
    {$HPPEMIT '#define SCE_C_CHARACTER 7'}
    SCE_C_UUID = 8;
    {$EXTERNALSYM SCE_C_UUID}
    {$HPPEMIT '#define SCE_C_UUID 8'}
    SCE_C_PREPROCESSOR = 9;
    {$EXTERNALSYM SCE_C_PREPROCESSOR}
    {$HPPEMIT '#define SCE_C_PREPROCESSOR 9'}
    SCE_C_OPERATOR = 10;
    {$EXTERNALSYM SCE_C_OPERATOR}
    {$HPPEMIT '#define SCE_C_OPERATOR 10'}
    SCE_C_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_C_IDENTIFIER}
    {$HPPEMIT '#define SCE_C_IDENTIFIER 11'}
    SCE_C_STRINGEOL = 12;
    {$EXTERNALSYM SCE_C_STRINGEOL}
    {$HPPEMIT '#define SCE_C_STRINGEOL 12'}
    SCE_C_VERBATIM = 13;
    {$EXTERNALSYM SCE_C_VERBATIM}
    {$HPPEMIT '#define SCE_C_VERBATIM 13'}
    SCE_C_REGEX = 14;
    {$EXTERNALSYM SCE_C_REGEX}
    {$HPPEMIT '#define SCE_C_REGEX 14'}
    SCE_C_COMMENTLINEDOC = 15;
    {$EXTERNALSYM SCE_C_COMMENTLINEDOC}
    {$HPPEMIT '#define SCE_C_COMMENTLINEDOC 15'}
    SCE_C_WORD2 = 16;
    {$EXTERNALSYM SCE_C_WORD2}
    {$HPPEMIT '#define SCE_C_WORD2 16'}
    SCE_C_COMMENTDOCKEYWORD = 17;
    {$EXTERNALSYM SCE_C_COMMENTDOCKEYWORD}
    {$HPPEMIT '#define SCE_C_COMMENTDOCKEYWORD 17'}
    SCE_C_COMMENTDOCKEYWORDERROR = 18;
    {$EXTERNALSYM SCE_C_COMMENTDOCKEYWORDERROR}
    {$HPPEMIT '#define SCE_C_COMMENTDOCKEYWORDERROR 18'}
    SCE_C_GLOBALCLASS = 19;
    {$EXTERNALSYM SCE_C_GLOBALCLASS}
    {$HPPEMIT '#define SCE_C_GLOBALCLASS 19'}
    SCE_TCL_DEFAULT = 0;
    {$EXTERNALSYM SCE_TCL_DEFAULT}
    {$HPPEMIT '#define SCE_TCL_DEFAULT 0'}
    SCE_TCL_COMMENT = 1;
    {$EXTERNALSYM SCE_TCL_COMMENT}
    {$HPPEMIT '#define SCE_TCL_COMMENT 1'}
    SCE_TCL_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_TCL_COMMENTLINE}
    {$HPPEMIT '#define SCE_TCL_COMMENTLINE 2'}
    SCE_TCL_NUMBER = 3;
    {$EXTERNALSYM SCE_TCL_NUMBER}
    {$HPPEMIT '#define SCE_TCL_NUMBER 3'}
    SCE_TCL_WORD_IN_QUOTE = 4;
    {$EXTERNALSYM SCE_TCL_WORD_IN_QUOTE}
    {$HPPEMIT '#define SCE_TCL_WORD_IN_QUOTE 4'}
    SCE_TCL_IN_QUOTE = 5;
    {$EXTERNALSYM SCE_TCL_IN_QUOTE}
    {$HPPEMIT '#define SCE_TCL_IN_QUOTE 5'}
    SCE_TCL_OPERATOR = 6;
    {$EXTERNALSYM SCE_TCL_OPERATOR}
    {$HPPEMIT '#define SCE_TCL_OPERATOR 6'}
    SCE_TCL_IDENTIFIER = 7;
    {$EXTERNALSYM SCE_TCL_IDENTIFIER}
    {$HPPEMIT '#define SCE_TCL_IDENTIFIER 7'}
    SCE_TCL_SUBSTITUTION = 8;
    {$EXTERNALSYM SCE_TCL_SUBSTITUTION}
    {$HPPEMIT '#define SCE_TCL_SUBSTITUTION 8'}
    SCE_TCL_SUB_BRACE = 9;
    {$EXTERNALSYM SCE_TCL_SUB_BRACE}
    {$HPPEMIT '#define SCE_TCL_SUB_BRACE 9'}
    SCE_TCL_MODIFIER = 10;
    {$EXTERNALSYM SCE_TCL_MODIFIER}
    {$HPPEMIT '#define SCE_TCL_MODIFIER 10'}
    SCE_TCL_EXPAND = 11;
    {$EXTERNALSYM SCE_TCL_EXPAND}
    {$HPPEMIT '#define SCE_TCL_EXPAND 11'}
    SCE_TCL_WORD = 12;
    {$EXTERNALSYM SCE_TCL_WORD}
    {$HPPEMIT '#define SCE_TCL_WORD 12'}
    SCE_TCL_WORD2 = 13;
    {$EXTERNALSYM SCE_TCL_WORD2}
    {$HPPEMIT '#define SCE_TCL_WORD2 13'}
    SCE_TCL_WORD3 = 14;
    {$EXTERNALSYM SCE_TCL_WORD3}
    {$HPPEMIT '#define SCE_TCL_WORD3 14'}
    SCE_TCL_WORD4 = 15;
    {$EXTERNALSYM SCE_TCL_WORD4}
    {$HPPEMIT '#define SCE_TCL_WORD4 15'}
    SCE_TCL_WORD5 = 16;
    {$EXTERNALSYM SCE_TCL_WORD5}
    {$HPPEMIT '#define SCE_TCL_WORD5 16'}
    SCE_TCL_WORD6 = 17;
    {$EXTERNALSYM SCE_TCL_WORD6}
    {$HPPEMIT '#define SCE_TCL_WORD6 17'}
    SCE_TCL_WORD7 = 18;
    {$EXTERNALSYM SCE_TCL_WORD7}
    {$HPPEMIT '#define SCE_TCL_WORD7 18'}
    SCE_TCL_WORD8 = 19;
    {$EXTERNALSYM SCE_TCL_WORD8}
    {$HPPEMIT '#define SCE_TCL_WORD8 19'}
    SCE_TCL_COMMENT_BOX = 20;
    {$EXTERNALSYM SCE_TCL_COMMENT_BOX}
    {$HPPEMIT '#define SCE_TCL_COMMENT_BOX 20'}
    SCE_TCL_BLOCK_COMMENT = 21;
    {$EXTERNALSYM SCE_TCL_BLOCK_COMMENT}
    {$HPPEMIT '#define SCE_TCL_BLOCK_COMMENT 21'}
    SCE_H_DEFAULT = 0;
    {$EXTERNALSYM SCE_H_DEFAULT}
    {$HPPEMIT '#define SCE_H_DEFAULT 0'}
    SCE_H_TAG = 1;
    {$EXTERNALSYM SCE_H_TAG}
    {$HPPEMIT '#define SCE_H_TAG 1'}
    SCE_H_TAGUNKNOWN = 2;
    {$EXTERNALSYM SCE_H_TAGUNKNOWN}
    {$HPPEMIT '#define SCE_H_TAGUNKNOWN 2'}
    SCE_H_ATTRIBUTE = 3;
    {$EXTERNALSYM SCE_H_ATTRIBUTE}
    {$HPPEMIT '#define SCE_H_ATTRIBUTE 3'}
    SCE_H_ATTRIBUTEUNKNOWN = 4;
    {$EXTERNALSYM SCE_H_ATTRIBUTEUNKNOWN}
    {$HPPEMIT '#define SCE_H_ATTRIBUTEUNKNOWN 4'}
    SCE_H_NUMBER = 5;
    {$EXTERNALSYM SCE_H_NUMBER}
    {$HPPEMIT '#define SCE_H_NUMBER 5'}
    SCE_H_DOUBLESTRING = 6;
    {$EXTERNALSYM SCE_H_DOUBLESTRING}
    {$HPPEMIT '#define SCE_H_DOUBLESTRING 6'}
    SCE_H_SINGLESTRING = 7;
    {$EXTERNALSYM SCE_H_SINGLESTRING}
    {$HPPEMIT '#define SCE_H_SINGLESTRING 7'}
    SCE_H_OTHER = 8;
    {$EXTERNALSYM SCE_H_OTHER}
    {$HPPEMIT '#define SCE_H_OTHER 8'}
    SCE_H_COMMENT = 9;
    {$EXTERNALSYM SCE_H_COMMENT}
    {$HPPEMIT '#define SCE_H_COMMENT 9'}
    SCE_H_ENTITY = 10;
    {$EXTERNALSYM SCE_H_ENTITY}
    {$HPPEMIT '#define SCE_H_ENTITY 10'}
    SCE_H_TAGEND = 11;
    {$EXTERNALSYM SCE_H_TAGEND}
    {$HPPEMIT '#define SCE_H_TAGEND 11'}
    SCE_H_XMLSTART = 12;
    {$EXTERNALSYM SCE_H_XMLSTART}
    {$HPPEMIT '#define SCE_H_XMLSTART 12'}
    SCE_H_XMLEND = 13;
    {$EXTERNALSYM SCE_H_XMLEND}
    {$HPPEMIT '#define SCE_H_XMLEND 13'}
    SCE_H_SCRIPT = 14;
    {$EXTERNALSYM SCE_H_SCRIPT}
    {$HPPEMIT '#define SCE_H_SCRIPT 14'}
    SCE_H_ASP = 15;
    {$EXTERNALSYM SCE_H_ASP}
    {$HPPEMIT '#define SCE_H_ASP 15'}
    SCE_H_ASPAT = 16;
    {$EXTERNALSYM SCE_H_ASPAT}
    {$HPPEMIT '#define SCE_H_ASPAT 16'}
    SCE_H_CDATA = 17;
    {$EXTERNALSYM SCE_H_CDATA}
    {$HPPEMIT '#define SCE_H_CDATA 17'}
    SCE_H_QUESTION = 18;
    {$EXTERNALSYM SCE_H_QUESTION}
    {$HPPEMIT '#define SCE_H_QUESTION 18'}
    SCE_H_VALUE = 19;
    {$EXTERNALSYM SCE_H_VALUE}
    {$HPPEMIT '#define SCE_H_VALUE 19'}
    SCE_H_XCCOMMENT = 20;
    {$EXTERNALSYM SCE_H_XCCOMMENT}
    {$HPPEMIT '#define SCE_H_XCCOMMENT 20'}
    SCE_H_SGML_DEFAULT = 21;
    {$EXTERNALSYM SCE_H_SGML_DEFAULT}
    {$HPPEMIT '#define SCE_H_SGML_DEFAULT 21'}
    SCE_H_SGML_COMMAND = 22;
    {$EXTERNALSYM SCE_H_SGML_COMMAND}
    {$HPPEMIT '#define SCE_H_SGML_COMMAND 22'}
    SCE_H_SGML_1ST_PARAM = 23;
    {$EXTERNALSYM SCE_H_SGML_1ST_PARAM}
    {$HPPEMIT '#define SCE_H_SGML_1ST_PARAM 23'}
    SCE_H_SGML_DOUBLESTRING = 24;
    {$EXTERNALSYM SCE_H_SGML_DOUBLESTRING}
    {$HPPEMIT '#define SCE_H_SGML_DOUBLESTRING 24'}
    SCE_H_SGML_SIMPLESTRING = 25;
    {$EXTERNALSYM SCE_H_SGML_SIMPLESTRING}
    {$HPPEMIT '#define SCE_H_SGML_SIMPLESTRING 25'}
    SCE_H_SGML_ERROR = 26;
    {$EXTERNALSYM SCE_H_SGML_ERROR}
    {$HPPEMIT '#define SCE_H_SGML_ERROR 26'}
    SCE_H_SGML_SPECIAL = 27;
    {$EXTERNALSYM SCE_H_SGML_SPECIAL}
    {$HPPEMIT '#define SCE_H_SGML_SPECIAL 27'}
    SCE_H_SGML_ENTITY = 28;
    {$EXTERNALSYM SCE_H_SGML_ENTITY}
    {$HPPEMIT '#define SCE_H_SGML_ENTITY 28'}
    SCE_H_SGML_COMMENT = 29;
    {$EXTERNALSYM SCE_H_SGML_COMMENT}
    {$HPPEMIT '#define SCE_H_SGML_COMMENT 29'}
    SCE_H_SGML_1ST_PARAM_COMMENT = 30;
    {$EXTERNALSYM SCE_H_SGML_1ST_PARAM_COMMENT}
    {$HPPEMIT '#define SCE_H_SGML_1ST_PARAM_COMMENT 30'}
    SCE_H_SGML_BLOCK_DEFAULT = 31;
    {$EXTERNALSYM SCE_H_SGML_BLOCK_DEFAULT}
    {$HPPEMIT '#define SCE_H_SGML_BLOCK_DEFAULT 31'}
    SCE_HJ_START = 40;
    {$EXTERNALSYM SCE_HJ_START}
    {$HPPEMIT '#define SCE_HJ_START 40'}
    SCE_HJ_DEFAULT = 41;
    {$EXTERNALSYM SCE_HJ_DEFAULT}
    {$HPPEMIT '#define SCE_HJ_DEFAULT 41'}
    SCE_HJ_COMMENT = 42;
    {$EXTERNALSYM SCE_HJ_COMMENT}
    {$HPPEMIT '#define SCE_HJ_COMMENT 42'}
    SCE_HJ_COMMENTLINE = 43;
    {$EXTERNALSYM SCE_HJ_COMMENTLINE}
    {$HPPEMIT '#define SCE_HJ_COMMENTLINE 43'}
    SCE_HJ_COMMENTDOC = 44;
    {$EXTERNALSYM SCE_HJ_COMMENTDOC}
    {$HPPEMIT '#define SCE_HJ_COMMENTDOC 44'}
    SCE_HJ_NUMBER = 45;
    {$EXTERNALSYM SCE_HJ_NUMBER}
    {$HPPEMIT '#define SCE_HJ_NUMBER 45'}
    SCE_HJ_WORD = 46;
    {$EXTERNALSYM SCE_HJ_WORD}
    {$HPPEMIT '#define SCE_HJ_WORD 46'}
    SCE_HJ_KEYWORD = 47;
    {$EXTERNALSYM SCE_HJ_KEYWORD}
    {$HPPEMIT '#define SCE_HJ_KEYWORD 47'}
    SCE_HJ_DOUBLESTRING = 48;
    {$EXTERNALSYM SCE_HJ_DOUBLESTRING}
    {$HPPEMIT '#define SCE_HJ_DOUBLESTRING 48'}
    SCE_HJ_SINGLESTRING = 49;
    {$EXTERNALSYM SCE_HJ_SINGLESTRING}
    {$HPPEMIT '#define SCE_HJ_SINGLESTRING 49'}
    SCE_HJ_SYMBOLS = 50;
    {$EXTERNALSYM SCE_HJ_SYMBOLS}
    {$HPPEMIT '#define SCE_HJ_SYMBOLS 50'}
    SCE_HJ_STRINGEOL = 51;
    {$EXTERNALSYM SCE_HJ_STRINGEOL}
    {$HPPEMIT '#define SCE_HJ_STRINGEOL 51'}
    SCE_HJ_REGEX = 52;
    {$EXTERNALSYM SCE_HJ_REGEX}
    {$HPPEMIT '#define SCE_HJ_REGEX 52'}
    SCE_HJA_START = 55;
    {$EXTERNALSYM SCE_HJA_START}
    {$HPPEMIT '#define SCE_HJA_START 55'}
    SCE_HJA_DEFAULT = 56;
    {$EXTERNALSYM SCE_HJA_DEFAULT}
    {$HPPEMIT '#define SCE_HJA_DEFAULT 56'}
    SCE_HJA_COMMENT = 57;
    {$EXTERNALSYM SCE_HJA_COMMENT}
    {$HPPEMIT '#define SCE_HJA_COMMENT 57'}
    SCE_HJA_COMMENTLINE = 58;
    {$EXTERNALSYM SCE_HJA_COMMENTLINE}
    {$HPPEMIT '#define SCE_HJA_COMMENTLINE 58'}
    SCE_HJA_COMMENTDOC = 59;
    {$EXTERNALSYM SCE_HJA_COMMENTDOC}
    {$HPPEMIT '#define SCE_HJA_COMMENTDOC 59'}
    SCE_HJA_NUMBER = 60;
    {$EXTERNALSYM SCE_HJA_NUMBER}
    {$HPPEMIT '#define SCE_HJA_NUMBER 60'}
    SCE_HJA_WORD = 61;
    {$EXTERNALSYM SCE_HJA_WORD}
    {$HPPEMIT '#define SCE_HJA_WORD 61'}
    SCE_HJA_KEYWORD = 62;
    {$EXTERNALSYM SCE_HJA_KEYWORD}
    {$HPPEMIT '#define SCE_HJA_KEYWORD 62'}
    SCE_HJA_DOUBLESTRING = 63;
    {$EXTERNALSYM SCE_HJA_DOUBLESTRING}
    {$HPPEMIT '#define SCE_HJA_DOUBLESTRING 63'}
    SCE_HJA_SINGLESTRING = 64;
    {$EXTERNALSYM SCE_HJA_SINGLESTRING}
    {$HPPEMIT '#define SCE_HJA_SINGLESTRING 64'}
    SCE_HJA_SYMBOLS = 65;
    {$EXTERNALSYM SCE_HJA_SYMBOLS}
    {$HPPEMIT '#define SCE_HJA_SYMBOLS 65'}
    SCE_HJA_STRINGEOL = 66;
    {$EXTERNALSYM SCE_HJA_STRINGEOL}
    {$HPPEMIT '#define SCE_HJA_STRINGEOL 66'}
    SCE_HJA_REGEX = 67;
    {$EXTERNALSYM SCE_HJA_REGEX}
    {$HPPEMIT '#define SCE_HJA_REGEX 67'}
    SCE_HB_START = 70;
    {$EXTERNALSYM SCE_HB_START}
    {$HPPEMIT '#define SCE_HB_START 70'}
    SCE_HB_DEFAULT = 71;
    {$EXTERNALSYM SCE_HB_DEFAULT}
    {$HPPEMIT '#define SCE_HB_DEFAULT 71'}
    SCE_HB_COMMENTLINE = 72;
    {$EXTERNALSYM SCE_HB_COMMENTLINE}
    {$HPPEMIT '#define SCE_HB_COMMENTLINE 72'}
    SCE_HB_NUMBER = 73;
    {$EXTERNALSYM SCE_HB_NUMBER}
    {$HPPEMIT '#define SCE_HB_NUMBER 73'}
    SCE_HB_WORD = 74;
    {$EXTERNALSYM SCE_HB_WORD}
    {$HPPEMIT '#define SCE_HB_WORD 74'}
    SCE_HB_STRING = 75;
    {$EXTERNALSYM SCE_HB_STRING}
    {$HPPEMIT '#define SCE_HB_STRING 75'}
    SCE_HB_IDENTIFIER = 76;
    {$EXTERNALSYM SCE_HB_IDENTIFIER}
    {$HPPEMIT '#define SCE_HB_IDENTIFIER 76'}
    SCE_HB_STRINGEOL = 77;
    {$EXTERNALSYM SCE_HB_STRINGEOL}
    {$HPPEMIT '#define SCE_HB_STRINGEOL 77'}
    SCE_HBA_START = 80;
    {$EXTERNALSYM SCE_HBA_START}
    {$HPPEMIT '#define SCE_HBA_START 80'}
    SCE_HBA_DEFAULT = 81;
    {$EXTERNALSYM SCE_HBA_DEFAULT}
    {$HPPEMIT '#define SCE_HBA_DEFAULT 81'}
    SCE_HBA_COMMENTLINE = 82;
    {$EXTERNALSYM SCE_HBA_COMMENTLINE}
    {$HPPEMIT '#define SCE_HBA_COMMENTLINE 82'}
    SCE_HBA_NUMBER = 83;
    {$EXTERNALSYM SCE_HBA_NUMBER}
    {$HPPEMIT '#define SCE_HBA_NUMBER 83'}
    SCE_HBA_WORD = 84;
    {$EXTERNALSYM SCE_HBA_WORD}
    {$HPPEMIT '#define SCE_HBA_WORD 84'}
    SCE_HBA_STRING = 85;
    {$EXTERNALSYM SCE_HBA_STRING}
    {$HPPEMIT '#define SCE_HBA_STRING 85'}
    SCE_HBA_IDENTIFIER = 86;
    {$EXTERNALSYM SCE_HBA_IDENTIFIER}
    {$HPPEMIT '#define SCE_HBA_IDENTIFIER 86'}
    SCE_HBA_STRINGEOL = 87;
    {$EXTERNALSYM SCE_HBA_STRINGEOL}
    {$HPPEMIT '#define SCE_HBA_STRINGEOL 87'}
    SCE_HP_START = 90;
    {$EXTERNALSYM SCE_HP_START}
    {$HPPEMIT '#define SCE_HP_START 90'}
    SCE_HP_DEFAULT = 91;
    {$EXTERNALSYM SCE_HP_DEFAULT}
    {$HPPEMIT '#define SCE_HP_DEFAULT 91'}
    SCE_HP_COMMENTLINE = 92;
    {$EXTERNALSYM SCE_HP_COMMENTLINE}
    {$HPPEMIT '#define SCE_HP_COMMENTLINE 92'}
    SCE_HP_NUMBER = 93;
    {$EXTERNALSYM SCE_HP_NUMBER}
    {$HPPEMIT '#define SCE_HP_NUMBER 93'}
    SCE_HP_STRING = 94;
    {$EXTERNALSYM SCE_HP_STRING}
    {$HPPEMIT '#define SCE_HP_STRING 94'}
    SCE_HP_CHARACTER = 95;
    {$EXTERNALSYM SCE_HP_CHARACTER}
    {$HPPEMIT '#define SCE_HP_CHARACTER 95'}
    SCE_HP_WORD = 96;
    {$EXTERNALSYM SCE_HP_WORD}
    {$HPPEMIT '#define SCE_HP_WORD 96'}
    SCE_HP_TRIPLE = 97;
    {$EXTERNALSYM SCE_HP_TRIPLE}
    {$HPPEMIT '#define SCE_HP_TRIPLE 97'}
    SCE_HP_TRIPLEDOUBLE = 98;
    {$EXTERNALSYM SCE_HP_TRIPLEDOUBLE}
    {$HPPEMIT '#define SCE_HP_TRIPLEDOUBLE 98'}
    SCE_HP_CLASSNAME = 99;
    {$EXTERNALSYM SCE_HP_CLASSNAME}
    {$HPPEMIT '#define SCE_HP_CLASSNAME 99'}
    SCE_HP_DEFNAME = 100;
    {$EXTERNALSYM SCE_HP_DEFNAME}
    {$HPPEMIT '#define SCE_HP_DEFNAME 100'}
    SCE_HP_OPERATOR = 101;
    {$EXTERNALSYM SCE_HP_OPERATOR}
    {$HPPEMIT '#define SCE_HP_OPERATOR 101'}
    SCE_HP_IDENTIFIER = 102;
    {$EXTERNALSYM SCE_HP_IDENTIFIER}
    {$HPPEMIT '#define SCE_HP_IDENTIFIER 102'}
    SCE_HPHP_COMPLEX_VARIABLE = 104;
    {$EXTERNALSYM SCE_HPHP_COMPLEX_VARIABLE}
    {$HPPEMIT '#define SCE_HPHP_COMPLEX_VARIABLE 104'}
    SCE_HPA_START = 105;
    {$EXTERNALSYM SCE_HPA_START}
    {$HPPEMIT '#define SCE_HPA_START 105'}
    SCE_HPA_DEFAULT = 106;
    {$EXTERNALSYM SCE_HPA_DEFAULT}
    {$HPPEMIT '#define SCE_HPA_DEFAULT 106'}
    SCE_HPA_COMMENTLINE = 107;
    {$EXTERNALSYM SCE_HPA_COMMENTLINE}
    {$HPPEMIT '#define SCE_HPA_COMMENTLINE 107'}
    SCE_HPA_NUMBER = 108;
    {$EXTERNALSYM SCE_HPA_NUMBER}
    {$HPPEMIT '#define SCE_HPA_NUMBER 108'}
    SCE_HPA_STRING = 109;
    {$EXTERNALSYM SCE_HPA_STRING}
    {$HPPEMIT '#define SCE_HPA_STRING 109'}
    SCE_HPA_CHARACTER = 110;
    {$EXTERNALSYM SCE_HPA_CHARACTER}
    {$HPPEMIT '#define SCE_HPA_CHARACTER 110'}
    SCE_HPA_WORD = 111;
    {$EXTERNALSYM SCE_HPA_WORD}
    {$HPPEMIT '#define SCE_HPA_WORD 111'}
    SCE_HPA_TRIPLE = 112;
    {$EXTERNALSYM SCE_HPA_TRIPLE}
    {$HPPEMIT '#define SCE_HPA_TRIPLE 112'}
    SCE_HPA_TRIPLEDOUBLE = 113;
    {$EXTERNALSYM SCE_HPA_TRIPLEDOUBLE}
    {$HPPEMIT '#define SCE_HPA_TRIPLEDOUBLE 113'}
    SCE_HPA_CLASSNAME = 114;
    {$EXTERNALSYM SCE_HPA_CLASSNAME}
    {$HPPEMIT '#define SCE_HPA_CLASSNAME 114'}
    SCE_HPA_DEFNAME = 115;
    {$EXTERNALSYM SCE_HPA_DEFNAME}
    {$HPPEMIT '#define SCE_HPA_DEFNAME 115'}
    SCE_HPA_OPERATOR = 116;
    {$EXTERNALSYM SCE_HPA_OPERATOR}
    {$HPPEMIT '#define SCE_HPA_OPERATOR 116'}
    SCE_HPA_IDENTIFIER = 117;
    {$EXTERNALSYM SCE_HPA_IDENTIFIER}
    {$HPPEMIT '#define SCE_HPA_IDENTIFIER 117'}
    SCE_HPHP_DEFAULT = 118;
    {$EXTERNALSYM SCE_HPHP_DEFAULT}
    {$HPPEMIT '#define SCE_HPHP_DEFAULT 118'}
    SCE_HPHP_HSTRING = 119;
    {$EXTERNALSYM SCE_HPHP_HSTRING}
    {$HPPEMIT '#define SCE_HPHP_HSTRING 119'}
    SCE_HPHP_SIMPLESTRING = 120;
    {$EXTERNALSYM SCE_HPHP_SIMPLESTRING}
    {$HPPEMIT '#define SCE_HPHP_SIMPLESTRING 120'}
    SCE_HPHP_WORD = 121;
    {$EXTERNALSYM SCE_HPHP_WORD}
    {$HPPEMIT '#define SCE_HPHP_WORD 121'}
    SCE_HPHP_NUMBER = 122;
    {$EXTERNALSYM SCE_HPHP_NUMBER}
    {$HPPEMIT '#define SCE_HPHP_NUMBER 122'}
    SCE_HPHP_VARIABLE = 123;
    {$EXTERNALSYM SCE_HPHP_VARIABLE}
    {$HPPEMIT '#define SCE_HPHP_VARIABLE 123'}
    SCE_HPHP_COMMENT = 124;
    {$EXTERNALSYM SCE_HPHP_COMMENT}
    {$HPPEMIT '#define SCE_HPHP_COMMENT 124'}
    SCE_HPHP_COMMENTLINE = 125;
    {$EXTERNALSYM SCE_HPHP_COMMENTLINE}
    {$HPPEMIT '#define SCE_HPHP_COMMENTLINE 125'}
    SCE_HPHP_HSTRING_VARIABLE = 126;
    {$EXTERNALSYM SCE_HPHP_HSTRING_VARIABLE}
    {$HPPEMIT '#define SCE_HPHP_HSTRING_VARIABLE 126'}
    SCE_HPHP_OPERATOR = 127;
    {$EXTERNALSYM SCE_HPHP_OPERATOR}
    {$HPPEMIT '#define SCE_HPHP_OPERATOR 127'}
    SCE_PL_DEFAULT = 0;
    {$EXTERNALSYM SCE_PL_DEFAULT}
    {$HPPEMIT '#define SCE_PL_DEFAULT 0'}
    SCE_PL_ERROR = 1;
    {$EXTERNALSYM SCE_PL_ERROR}
    {$HPPEMIT '#define SCE_PL_ERROR 1'}
    SCE_PL_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_PL_COMMENTLINE}
    {$HPPEMIT '#define SCE_PL_COMMENTLINE 2'}
    SCE_PL_POD = 3;
    {$EXTERNALSYM SCE_PL_POD}
    {$HPPEMIT '#define SCE_PL_POD 3'}
    SCE_PL_NUMBER = 4;
    {$EXTERNALSYM SCE_PL_NUMBER}
    {$HPPEMIT '#define SCE_PL_NUMBER 4'}
    SCE_PL_WORD = 5;
    {$EXTERNALSYM SCE_PL_WORD}
    {$HPPEMIT '#define SCE_PL_WORD 5'}
    SCE_PL_STRING = 6;
    {$EXTERNALSYM SCE_PL_STRING}
    {$HPPEMIT '#define SCE_PL_STRING 6'}
    SCE_PL_CHARACTER = 7;
    {$EXTERNALSYM SCE_PL_CHARACTER}
    {$HPPEMIT '#define SCE_PL_CHARACTER 7'}
    SCE_PL_PUNCTUATION = 8;
    {$EXTERNALSYM SCE_PL_PUNCTUATION}
    {$HPPEMIT '#define SCE_PL_PUNCTUATION 8'}
    SCE_PL_PREPROCESSOR = 9;
    {$EXTERNALSYM SCE_PL_PREPROCESSOR}
    {$HPPEMIT '#define SCE_PL_PREPROCESSOR 9'}
    SCE_PL_OPERATOR = 10;
    {$EXTERNALSYM SCE_PL_OPERATOR}
    {$HPPEMIT '#define SCE_PL_OPERATOR 10'}
    SCE_PL_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_PL_IDENTIFIER}
    {$HPPEMIT '#define SCE_PL_IDENTIFIER 11'}
    SCE_PL_SCALAR = 12;
    {$EXTERNALSYM SCE_PL_SCALAR}
    {$HPPEMIT '#define SCE_PL_SCALAR 12'}
    SCE_PL_ARRAY = 13;
    {$EXTERNALSYM SCE_PL_ARRAY}
    {$HPPEMIT '#define SCE_PL_ARRAY 13'}
    SCE_PL_HASH = 14;
    {$EXTERNALSYM SCE_PL_HASH}
    {$HPPEMIT '#define SCE_PL_HASH 14'}
    SCE_PL_SYMBOLTABLE = 15;
    {$EXTERNALSYM SCE_PL_SYMBOLTABLE}
    {$HPPEMIT '#define SCE_PL_SYMBOLTABLE 15'}
    SCE_PL_VARIABLE_INDEXER = 16;
    {$EXTERNALSYM SCE_PL_VARIABLE_INDEXER}
    {$HPPEMIT '#define SCE_PL_VARIABLE_INDEXER 16'}
    SCE_PL_REGEX = 17;
    {$EXTERNALSYM SCE_PL_REGEX}
    {$HPPEMIT '#define SCE_PL_REGEX 17'}
    SCE_PL_REGSUBST = 18;
    {$EXTERNALSYM SCE_PL_REGSUBST}
    {$HPPEMIT '#define SCE_PL_REGSUBST 18'}
    SCE_PL_LONGQUOTE = 19;
    {$EXTERNALSYM SCE_PL_LONGQUOTE}
    {$HPPEMIT '#define SCE_PL_LONGQUOTE 19'}
    SCE_PL_BACKTICKS = 20;
    {$EXTERNALSYM SCE_PL_BACKTICKS}
    {$HPPEMIT '#define SCE_PL_BACKTICKS 20'}
    SCE_PL_DATASECTION = 21;
    {$EXTERNALSYM SCE_PL_DATASECTION}
    {$HPPEMIT '#define SCE_PL_DATASECTION 21'}
    SCE_PL_HERE_DELIM = 22;
    {$EXTERNALSYM SCE_PL_HERE_DELIM}
    {$HPPEMIT '#define SCE_PL_HERE_DELIM 22'}
    SCE_PL_HERE_Q = 23;
    {$EXTERNALSYM SCE_PL_HERE_Q}
    {$HPPEMIT '#define SCE_PL_HERE_Q 23'}
    SCE_PL_HERE_QQ = 24;
    {$EXTERNALSYM SCE_PL_HERE_QQ}
    {$HPPEMIT '#define SCE_PL_HERE_QQ 24'}
    SCE_PL_HERE_QX = 25;
    {$EXTERNALSYM SCE_PL_HERE_QX}
    {$HPPEMIT '#define SCE_PL_HERE_QX 25'}
    SCE_PL_STRING_Q = 26;
    {$EXTERNALSYM SCE_PL_STRING_Q}
    {$HPPEMIT '#define SCE_PL_STRING_Q 26'}
    SCE_PL_STRING_QQ = 27;
    {$EXTERNALSYM SCE_PL_STRING_QQ}
    {$HPPEMIT '#define SCE_PL_STRING_QQ 27'}
    SCE_PL_STRING_QX = 28;
    {$EXTERNALSYM SCE_PL_STRING_QX}
    {$HPPEMIT '#define SCE_PL_STRING_QX 28'}
    SCE_PL_STRING_QR = 29;
    {$EXTERNALSYM SCE_PL_STRING_QR}
    {$HPPEMIT '#define SCE_PL_STRING_QR 29'}
    SCE_PL_STRING_QW = 30;
    {$EXTERNALSYM SCE_PL_STRING_QW}
    {$HPPEMIT '#define SCE_PL_STRING_QW 30'}
    SCE_PL_POD_VERB = 31;
    {$EXTERNALSYM SCE_PL_POD_VERB}
    {$HPPEMIT '#define SCE_PL_POD_VERB 31'}
    SCE_RB_DEFAULT = 0;
    {$EXTERNALSYM SCE_RB_DEFAULT}
    {$HPPEMIT '#define SCE_RB_DEFAULT 0'}
    SCE_RB_ERROR = 1;
    {$EXTERNALSYM SCE_RB_ERROR}
    {$HPPEMIT '#define SCE_RB_ERROR 1'}
    SCE_RB_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_RB_COMMENTLINE}
    {$HPPEMIT '#define SCE_RB_COMMENTLINE 2'}
    SCE_RB_POD = 3;
    {$EXTERNALSYM SCE_RB_POD}
    {$HPPEMIT '#define SCE_RB_POD 3'}
    SCE_RB_NUMBER = 4;
    {$EXTERNALSYM SCE_RB_NUMBER}
    {$HPPEMIT '#define SCE_RB_NUMBER 4'}
    SCE_RB_WORD = 5;
    {$EXTERNALSYM SCE_RB_WORD}
    {$HPPEMIT '#define SCE_RB_WORD 5'}
    SCE_RB_STRING = 6;
    {$EXTERNALSYM SCE_RB_STRING}
    {$HPPEMIT '#define SCE_RB_STRING 6'}
    SCE_RB_CHARACTER = 7;
    {$EXTERNALSYM SCE_RB_CHARACTER}
    {$HPPEMIT '#define SCE_RB_CHARACTER 7'}
    SCE_RB_CLASSNAME = 8;
    {$EXTERNALSYM SCE_RB_CLASSNAME}
    {$HPPEMIT '#define SCE_RB_CLASSNAME 8'}
    SCE_RB_DEFNAME = 9;
    {$EXTERNALSYM SCE_RB_DEFNAME}
    {$HPPEMIT '#define SCE_RB_DEFNAME 9'}
    SCE_RB_OPERATOR = 10;
    {$EXTERNALSYM SCE_RB_OPERATOR}
    {$HPPEMIT '#define SCE_RB_OPERATOR 10'}
    SCE_RB_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_RB_IDENTIFIER}
    {$HPPEMIT '#define SCE_RB_IDENTIFIER 11'}
    SCE_RB_REGEX = 12;
    {$EXTERNALSYM SCE_RB_REGEX}
    {$HPPEMIT '#define SCE_RB_REGEX 12'}
    SCE_RB_GLOBAL = 13;
    {$EXTERNALSYM SCE_RB_GLOBAL}
    {$HPPEMIT '#define SCE_RB_GLOBAL 13'}
    SCE_RB_SYMBOL = 14;
    {$EXTERNALSYM SCE_RB_SYMBOL}
    {$HPPEMIT '#define SCE_RB_SYMBOL 14'}
    SCE_RB_MODULE_NAME = 15;
    {$EXTERNALSYM SCE_RB_MODULE_NAME}
    {$HPPEMIT '#define SCE_RB_MODULE_NAME 15'}
    SCE_RB_INSTANCE_VAR = 16;
    {$EXTERNALSYM SCE_RB_INSTANCE_VAR}
    {$HPPEMIT '#define SCE_RB_INSTANCE_VAR 16'}
    SCE_RB_CLASS_VAR = 17;
    {$EXTERNALSYM SCE_RB_CLASS_VAR}
    {$HPPEMIT '#define SCE_RB_CLASS_VAR 17'}
    SCE_RB_BACKTICKS = 18;
    {$EXTERNALSYM SCE_RB_BACKTICKS}
    {$HPPEMIT '#define SCE_RB_BACKTICKS 18'}
    SCE_RB_DATASECTION = 19;
    {$EXTERNALSYM SCE_RB_DATASECTION}
    {$HPPEMIT '#define SCE_RB_DATASECTION 19'}
    SCE_RB_HERE_DELIM = 20;
    {$EXTERNALSYM SCE_RB_HERE_DELIM}
    {$HPPEMIT '#define SCE_RB_HERE_DELIM 20'}
    SCE_RB_HERE_Q = 21;
    {$EXTERNALSYM SCE_RB_HERE_Q}
    {$HPPEMIT '#define SCE_RB_HERE_Q 21'}
    SCE_RB_HERE_QQ = 22;
    {$EXTERNALSYM SCE_RB_HERE_QQ}
    {$HPPEMIT '#define SCE_RB_HERE_QQ 22'}
    SCE_RB_HERE_QX = 23;
    {$EXTERNALSYM SCE_RB_HERE_QX}
    {$HPPEMIT '#define SCE_RB_HERE_QX 23'}
    SCE_RB_STRING_Q = 24;
    {$EXTERNALSYM SCE_RB_STRING_Q}
    {$HPPEMIT '#define SCE_RB_STRING_Q 24'}
    SCE_RB_STRING_QQ = 25;
    {$EXTERNALSYM SCE_RB_STRING_QQ}
    {$HPPEMIT '#define SCE_RB_STRING_QQ 25'}
    SCE_RB_STRING_QX = 26;
    {$EXTERNALSYM SCE_RB_STRING_QX}
    {$HPPEMIT '#define SCE_RB_STRING_QX 26'}
    SCE_RB_STRING_QR = 27;
    {$EXTERNALSYM SCE_RB_STRING_QR}
    {$HPPEMIT '#define SCE_RB_STRING_QR 27'}
    SCE_RB_STRING_QW = 28;
    {$EXTERNALSYM SCE_RB_STRING_QW}
    {$HPPEMIT '#define SCE_RB_STRING_QW 28'}
    SCE_RB_WORD_DEMOTED = 29;
    {$EXTERNALSYM SCE_RB_WORD_DEMOTED}
    {$HPPEMIT '#define SCE_RB_WORD_DEMOTED 29'}
    SCE_RB_STDIN = 30;
    {$EXTERNALSYM SCE_RB_STDIN}
    {$HPPEMIT '#define SCE_RB_STDIN 30'}
    SCE_RB_STDOUT = 31;
    {$EXTERNALSYM SCE_RB_STDOUT}
    {$HPPEMIT '#define SCE_RB_STDOUT 31'}
    SCE_RB_STDERR = 40;
    {$EXTERNALSYM SCE_RB_STDERR}
    {$HPPEMIT '#define SCE_RB_STDERR 40'}
    SCE_RB_UPPER_BOUND = 41;
    {$EXTERNALSYM SCE_RB_UPPER_BOUND}
    {$HPPEMIT '#define SCE_RB_UPPER_BOUND 41'}
    SCE_B_DEFAULT = 0;
    {$EXTERNALSYM SCE_B_DEFAULT}
    {$HPPEMIT '#define SCE_B_DEFAULT 0'}
    SCE_B_COMMENT = 1;
    {$EXTERNALSYM SCE_B_COMMENT}
    {$HPPEMIT '#define SCE_B_COMMENT 1'}
    SCE_B_NUMBER = 2;
    {$EXTERNALSYM SCE_B_NUMBER}
    {$HPPEMIT '#define SCE_B_NUMBER 2'}
    SCE_B_KEYWORD = 3;
    {$EXTERNALSYM SCE_B_KEYWORD}
    {$HPPEMIT '#define SCE_B_KEYWORD 3'}
    SCE_B_STRING = 4;
    {$EXTERNALSYM SCE_B_STRING}
    {$HPPEMIT '#define SCE_B_STRING 4'}
    SCE_B_PREPROCESSOR = 5;
    {$EXTERNALSYM SCE_B_PREPROCESSOR}
    {$HPPEMIT '#define SCE_B_PREPROCESSOR 5'}
    SCE_B_OPERATOR = 6;
    {$EXTERNALSYM SCE_B_OPERATOR}
    {$HPPEMIT '#define SCE_B_OPERATOR 6'}
    SCE_B_IDENTIFIER = 7;
    {$EXTERNALSYM SCE_B_IDENTIFIER}
    {$HPPEMIT '#define SCE_B_IDENTIFIER 7'}
    SCE_B_DATE = 8;
    {$EXTERNALSYM SCE_B_DATE}
    {$HPPEMIT '#define SCE_B_DATE 8'}
    SCE_B_STRINGEOL = 9;
    {$EXTERNALSYM SCE_B_STRINGEOL}
    {$HPPEMIT '#define SCE_B_STRINGEOL 9'}
    SCE_B_KEYWORD2 = 10;
    {$EXTERNALSYM SCE_B_KEYWORD2}
    {$HPPEMIT '#define SCE_B_KEYWORD2 10'}
    SCE_B_KEYWORD3 = 11;
    {$EXTERNALSYM SCE_B_KEYWORD3}
    {$HPPEMIT '#define SCE_B_KEYWORD3 11'}
    SCE_B_KEYWORD4 = 12;
    {$EXTERNALSYM SCE_B_KEYWORD4}
    {$HPPEMIT '#define SCE_B_KEYWORD4 12'}
    SCE_B_CONSTANT = 13;
    {$EXTERNALSYM SCE_B_CONSTANT}
    {$HPPEMIT '#define SCE_B_CONSTANT 13'}
    SCE_B_ASM = 14;
    {$EXTERNALSYM SCE_B_ASM}
    {$HPPEMIT '#define SCE_B_ASM 14'}
    SCE_B_LABEL = 15;
    {$EXTERNALSYM SCE_B_LABEL}
    {$HPPEMIT '#define SCE_B_LABEL 15'}
    SCE_B_ERROR = 16;
    {$EXTERNALSYM SCE_B_ERROR}
    {$HPPEMIT '#define SCE_B_ERROR 16'}
    SCE_B_HEXNUMBER = 17;
    {$EXTERNALSYM SCE_B_HEXNUMBER}
    {$HPPEMIT '#define SCE_B_HEXNUMBER 17'}
    SCE_B_BINNUMBER = 18;
    {$EXTERNALSYM SCE_B_BINNUMBER}
    {$HPPEMIT '#define SCE_B_BINNUMBER 18'}
    SCE_PROPS_DEFAULT = 0;
    {$EXTERNALSYM SCE_PROPS_DEFAULT}
    {$HPPEMIT '#define SCE_PROPS_DEFAULT 0'}
    SCE_PROPS_COMMENT = 1;
    {$EXTERNALSYM SCE_PROPS_COMMENT}
    {$HPPEMIT '#define SCE_PROPS_COMMENT 1'}
    SCE_PROPS_SECTION = 2;
    {$EXTERNALSYM SCE_PROPS_SECTION}
    {$HPPEMIT '#define SCE_PROPS_SECTION 2'}
    SCE_PROPS_ASSIGNMENT = 3;
    {$EXTERNALSYM SCE_PROPS_ASSIGNMENT}
    {$HPPEMIT '#define SCE_PROPS_ASSIGNMENT 3'}
    SCE_PROPS_DEFVAL = 4;
    {$EXTERNALSYM SCE_PROPS_DEFVAL}
    {$HPPEMIT '#define SCE_PROPS_DEFVAL 4'}
    SCE_PROPS_KEY = 5;
    {$EXTERNALSYM SCE_PROPS_KEY}
    {$HPPEMIT '#define SCE_PROPS_KEY 5'}
    SCE_L_DEFAULT = 0;
    {$EXTERNALSYM SCE_L_DEFAULT}
    {$HPPEMIT '#define SCE_L_DEFAULT 0'}
    SCE_L_COMMAND = 1;
    {$EXTERNALSYM SCE_L_COMMAND}
    {$HPPEMIT '#define SCE_L_COMMAND 1'}
    SCE_L_TAG = 2;
    {$EXTERNALSYM SCE_L_TAG}
    {$HPPEMIT '#define SCE_L_TAG 2'}
    SCE_L_MATH = 3;
    {$EXTERNALSYM SCE_L_MATH}
    {$HPPEMIT '#define SCE_L_MATH 3'}
    SCE_L_COMMENT = 4;
    {$EXTERNALSYM SCE_L_COMMENT}
    {$HPPEMIT '#define SCE_L_COMMENT 4'}
    SCE_LUA_DEFAULT = 0;
    {$EXTERNALSYM SCE_LUA_DEFAULT}
    {$HPPEMIT '#define SCE_LUA_DEFAULT 0'}
    SCE_LUA_COMMENT = 1;
    {$EXTERNALSYM SCE_LUA_COMMENT}
    {$HPPEMIT '#define SCE_LUA_COMMENT 1'}
    SCE_LUA_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_LUA_COMMENTLINE}
    {$HPPEMIT '#define SCE_LUA_COMMENTLINE 2'}
    SCE_LUA_COMMENTDOC = 3;
    {$EXTERNALSYM SCE_LUA_COMMENTDOC}
    {$HPPEMIT '#define SCE_LUA_COMMENTDOC 3'}
    SCE_LUA_NUMBER = 4;
    {$EXTERNALSYM SCE_LUA_NUMBER}
    {$HPPEMIT '#define SCE_LUA_NUMBER 4'}
    SCE_LUA_WORD = 5;
    {$EXTERNALSYM SCE_LUA_WORD}
    {$HPPEMIT '#define SCE_LUA_WORD 5'}
    SCE_LUA_STRING = 6;
    {$EXTERNALSYM SCE_LUA_STRING}
    {$HPPEMIT '#define SCE_LUA_STRING 6'}
    SCE_LUA_CHARACTER = 7;
    {$EXTERNALSYM SCE_LUA_CHARACTER}
    {$HPPEMIT '#define SCE_LUA_CHARACTER 7'}
    SCE_LUA_LITERALSTRING = 8;
    {$EXTERNALSYM SCE_LUA_LITERALSTRING}
    {$HPPEMIT '#define SCE_LUA_LITERALSTRING 8'}
    SCE_LUA_PREPROCESSOR = 9;
    {$EXTERNALSYM SCE_LUA_PREPROCESSOR}
    {$HPPEMIT '#define SCE_LUA_PREPROCESSOR 9'}
    SCE_LUA_OPERATOR = 10;
    {$EXTERNALSYM SCE_LUA_OPERATOR}
    {$HPPEMIT '#define SCE_LUA_OPERATOR 10'}
    SCE_LUA_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_LUA_IDENTIFIER}
    {$HPPEMIT '#define SCE_LUA_IDENTIFIER 11'}
    SCE_LUA_STRINGEOL = 12;
    {$EXTERNALSYM SCE_LUA_STRINGEOL}
    {$HPPEMIT '#define SCE_LUA_STRINGEOL 12'}
    SCE_LUA_WORD2 = 13;
    {$EXTERNALSYM SCE_LUA_WORD2}
    {$HPPEMIT '#define SCE_LUA_WORD2 13'}
    SCE_LUA_WORD3 = 14;
    {$EXTERNALSYM SCE_LUA_WORD3}
    {$HPPEMIT '#define SCE_LUA_WORD3 14'}
    SCE_LUA_WORD4 = 15;
    {$EXTERNALSYM SCE_LUA_WORD4}
    {$HPPEMIT '#define SCE_LUA_WORD4 15'}
    SCE_LUA_WORD5 = 16;
    {$EXTERNALSYM SCE_LUA_WORD5}
    {$HPPEMIT '#define SCE_LUA_WORD5 16'}
    SCE_LUA_WORD6 = 17;
    {$EXTERNALSYM SCE_LUA_WORD6}
    {$HPPEMIT '#define SCE_LUA_WORD6 17'}
    SCE_LUA_WORD7 = 18;
    {$EXTERNALSYM SCE_LUA_WORD7}
    {$HPPEMIT '#define SCE_LUA_WORD7 18'}
    SCE_LUA_WORD8 = 19;
    {$EXTERNALSYM SCE_LUA_WORD8}
    {$HPPEMIT '#define SCE_LUA_WORD8 19'}
    SCE_ERR_DEFAULT = 0;
    {$EXTERNALSYM SCE_ERR_DEFAULT}
    {$HPPEMIT '#define SCE_ERR_DEFAULT 0'}
    SCE_ERR_PYTHON = 1;
    {$EXTERNALSYM SCE_ERR_PYTHON}
    {$HPPEMIT '#define SCE_ERR_PYTHON 1'}
    SCE_ERR_GCC = 2;
    {$EXTERNALSYM SCE_ERR_GCC}
    {$HPPEMIT '#define SCE_ERR_GCC 2'}
    SCE_ERR_MS = 3;
    {$EXTERNALSYM SCE_ERR_MS}
    {$HPPEMIT '#define SCE_ERR_MS 3'}
    SCE_ERR_CMD = 4;
    {$EXTERNALSYM SCE_ERR_CMD}
    {$HPPEMIT '#define SCE_ERR_CMD 4'}
    SCE_ERR_BORLAND = 5;
    {$EXTERNALSYM SCE_ERR_BORLAND}
    {$HPPEMIT '#define SCE_ERR_BORLAND 5'}
    SCE_ERR_PERL = 6;
    {$EXTERNALSYM SCE_ERR_PERL}
    {$HPPEMIT '#define SCE_ERR_PERL 6'}
    SCE_ERR_NET = 7;
    {$EXTERNALSYM SCE_ERR_NET}
    {$HPPEMIT '#define SCE_ERR_NET 7'}
    SCE_ERR_LUA = 8;
    {$EXTERNALSYM SCE_ERR_LUA}
    {$HPPEMIT '#define SCE_ERR_LUA 8'}
    SCE_ERR_CTAG = 9;
    {$EXTERNALSYM SCE_ERR_CTAG}
    {$HPPEMIT '#define SCE_ERR_CTAG 9'}
    SCE_ERR_DIFF_CHANGED = 10;
    {$EXTERNALSYM SCE_ERR_DIFF_CHANGED}
    {$HPPEMIT '#define SCE_ERR_DIFF_CHANGED 10'}
    SCE_ERR_DIFF_ADDITION = 11;
    {$EXTERNALSYM SCE_ERR_DIFF_ADDITION}
    {$HPPEMIT '#define SCE_ERR_DIFF_ADDITION 11'}
    SCE_ERR_DIFF_DELETION = 12;
    {$EXTERNALSYM SCE_ERR_DIFF_DELETION}
    {$HPPEMIT '#define SCE_ERR_DIFF_DELETION 12'}
    SCE_ERR_DIFF_MESSAGE = 13;
    {$EXTERNALSYM SCE_ERR_DIFF_MESSAGE}
    {$HPPEMIT '#define SCE_ERR_DIFF_MESSAGE 13'}
    SCE_ERR_PHP = 14;
    {$EXTERNALSYM SCE_ERR_PHP}
    {$HPPEMIT '#define SCE_ERR_PHP 14'}
    SCE_ERR_ELF = 15;
    {$EXTERNALSYM SCE_ERR_ELF}
    {$HPPEMIT '#define SCE_ERR_ELF 15'}
    SCE_ERR_IFC = 16;
    {$EXTERNALSYM SCE_ERR_IFC}
    {$HPPEMIT '#define SCE_ERR_IFC 16'}
    SCE_ERR_IFORT = 17;
    {$EXTERNALSYM SCE_ERR_IFORT}
    {$HPPEMIT '#define SCE_ERR_IFORT 17'}
    SCE_ERR_ABSF = 18;
    {$EXTERNALSYM SCE_ERR_ABSF}
    {$HPPEMIT '#define SCE_ERR_ABSF 18'}
    SCE_ERR_TIDY = 19;
    {$EXTERNALSYM SCE_ERR_TIDY}
    {$HPPEMIT '#define SCE_ERR_TIDY 19'}
    SCE_ERR_JAVA_STACK = 20;
    {$EXTERNALSYM SCE_ERR_JAVA_STACK}
    {$HPPEMIT '#define SCE_ERR_JAVA_STACK 20'}
    SCE_BAT_DEFAULT = 0;
    {$EXTERNALSYM SCE_BAT_DEFAULT}
    {$HPPEMIT '#define SCE_BAT_DEFAULT 0'}
    SCE_BAT_COMMENT = 1;
    {$EXTERNALSYM SCE_BAT_COMMENT}
    {$HPPEMIT '#define SCE_BAT_COMMENT 1'}
    SCE_BAT_WORD = 2;
    {$EXTERNALSYM SCE_BAT_WORD}
    {$HPPEMIT '#define SCE_BAT_WORD 2'}
    SCE_BAT_LABEL = 3;
    {$EXTERNALSYM SCE_BAT_LABEL}
    {$HPPEMIT '#define SCE_BAT_LABEL 3'}
    SCE_BAT_HIDE = 4;
    {$EXTERNALSYM SCE_BAT_HIDE}
    {$HPPEMIT '#define SCE_BAT_HIDE 4'}
    SCE_BAT_COMMAND = 5;
    {$EXTERNALSYM SCE_BAT_COMMAND}
    {$HPPEMIT '#define SCE_BAT_COMMAND 5'}
    SCE_BAT_IDENTIFIER = 6;
    {$EXTERNALSYM SCE_BAT_IDENTIFIER}
    {$HPPEMIT '#define SCE_BAT_IDENTIFIER 6'}
    SCE_BAT_OPERATOR = 7;
    {$EXTERNALSYM SCE_BAT_OPERATOR}
    {$HPPEMIT '#define SCE_BAT_OPERATOR 7'}
    SCE_MAKE_DEFAULT = 0;
    {$EXTERNALSYM SCE_MAKE_DEFAULT}
    {$HPPEMIT '#define SCE_MAKE_DEFAULT 0'}
    SCE_MAKE_COMMENT = 1;
    {$EXTERNALSYM SCE_MAKE_COMMENT}
    {$HPPEMIT '#define SCE_MAKE_COMMENT 1'}
    SCE_MAKE_PREPROCESSOR = 2;
    {$EXTERNALSYM SCE_MAKE_PREPROCESSOR}
    {$HPPEMIT '#define SCE_MAKE_PREPROCESSOR 2'}
    SCE_MAKE_IDENTIFIER = 3;
    {$EXTERNALSYM SCE_MAKE_IDENTIFIER}
    {$HPPEMIT '#define SCE_MAKE_IDENTIFIER 3'}
    SCE_MAKE_OPERATOR = 4;
    {$EXTERNALSYM SCE_MAKE_OPERATOR}
    {$HPPEMIT '#define SCE_MAKE_OPERATOR 4'}
    SCE_MAKE_TARGET = 5;
    {$EXTERNALSYM SCE_MAKE_TARGET}
    {$HPPEMIT '#define SCE_MAKE_TARGET 5'}
    SCE_MAKE_IDEOL = 9;
    {$EXTERNALSYM SCE_MAKE_IDEOL}
    {$HPPEMIT '#define SCE_MAKE_IDEOL 9'}
    SCE_DIFF_DEFAULT = 0;
    {$EXTERNALSYM SCE_DIFF_DEFAULT}
    {$HPPEMIT '#define SCE_DIFF_DEFAULT 0'}
    SCE_DIFF_COMMENT = 1;
    {$EXTERNALSYM SCE_DIFF_COMMENT}
    {$HPPEMIT '#define SCE_DIFF_COMMENT 1'}
    SCE_DIFF_COMMAND = 2;
    {$EXTERNALSYM SCE_DIFF_COMMAND}
    {$HPPEMIT '#define SCE_DIFF_COMMAND 2'}
    SCE_DIFF_HEADER = 3;
    {$EXTERNALSYM SCE_DIFF_HEADER}
    {$HPPEMIT '#define SCE_DIFF_HEADER 3'}
    SCE_DIFF_POSITION = 4;
    {$EXTERNALSYM SCE_DIFF_POSITION}
    {$HPPEMIT '#define SCE_DIFF_POSITION 4'}
    SCE_DIFF_DELETED = 5;
    {$EXTERNALSYM SCE_DIFF_DELETED}
    {$HPPEMIT '#define SCE_DIFF_DELETED 5'}
    SCE_DIFF_ADDED = 6;
    {$EXTERNALSYM SCE_DIFF_ADDED}
    {$HPPEMIT '#define SCE_DIFF_ADDED 6'}
    SCE_CONF_DEFAULT = 0;
    {$EXTERNALSYM SCE_CONF_DEFAULT}
    {$HPPEMIT '#define SCE_CONF_DEFAULT 0'}
    SCE_CONF_COMMENT = 1;
    {$EXTERNALSYM SCE_CONF_COMMENT}
    {$HPPEMIT '#define SCE_CONF_COMMENT 1'}
    SCE_CONF_NUMBER = 2;
    {$EXTERNALSYM SCE_CONF_NUMBER}
    {$HPPEMIT '#define SCE_CONF_NUMBER 2'}
    SCE_CONF_IDENTIFIER = 3;
    {$EXTERNALSYM SCE_CONF_IDENTIFIER}
    {$HPPEMIT '#define SCE_CONF_IDENTIFIER 3'}
    SCE_CONF_EXTENSION = 4;
    {$EXTERNALSYM SCE_CONF_EXTENSION}
    {$HPPEMIT '#define SCE_CONF_EXTENSION 4'}
    SCE_CONF_PARAMETER = 5;
    {$EXTERNALSYM SCE_CONF_PARAMETER}
    {$HPPEMIT '#define SCE_CONF_PARAMETER 5'}
    SCE_CONF_STRING = 6;
    {$EXTERNALSYM SCE_CONF_STRING}
    {$HPPEMIT '#define SCE_CONF_STRING 6'}
    SCE_CONF_OPERATOR = 7;
    {$EXTERNALSYM SCE_CONF_OPERATOR}
    {$HPPEMIT '#define SCE_CONF_OPERATOR 7'}
    SCE_CONF_IP = 8;
    {$EXTERNALSYM SCE_CONF_IP}
    {$HPPEMIT '#define SCE_CONF_IP 8'}
    SCE_CONF_DIRECTIVE = 9;
    {$EXTERNALSYM SCE_CONF_DIRECTIVE}
    {$HPPEMIT '#define SCE_CONF_DIRECTIVE 9'}
    SCE_AVE_DEFAULT = 0;
    {$EXTERNALSYM SCE_AVE_DEFAULT}
    {$HPPEMIT '#define SCE_AVE_DEFAULT 0'}
    SCE_AVE_COMMENT = 1;
    {$EXTERNALSYM SCE_AVE_COMMENT}
    {$HPPEMIT '#define SCE_AVE_COMMENT 1'}
    SCE_AVE_NUMBER = 2;
    {$EXTERNALSYM SCE_AVE_NUMBER}
    {$HPPEMIT '#define SCE_AVE_NUMBER 2'}
    SCE_AVE_WORD = 3;
    {$EXTERNALSYM SCE_AVE_WORD}
    {$HPPEMIT '#define SCE_AVE_WORD 3'}
    SCE_AVE_STRING = 6;
    {$EXTERNALSYM SCE_AVE_STRING}
    {$HPPEMIT '#define SCE_AVE_STRING 6'}
    SCE_AVE_ENUM = 7;
    {$EXTERNALSYM SCE_AVE_ENUM}
    {$HPPEMIT '#define SCE_AVE_ENUM 7'}
    SCE_AVE_STRINGEOL = 8;
    {$EXTERNALSYM SCE_AVE_STRINGEOL}
    {$HPPEMIT '#define SCE_AVE_STRINGEOL 8'}
    SCE_AVE_IDENTIFIER = 9;
    {$EXTERNALSYM SCE_AVE_IDENTIFIER}
    {$HPPEMIT '#define SCE_AVE_IDENTIFIER 9'}
    SCE_AVE_OPERATOR = 10;
    {$EXTERNALSYM SCE_AVE_OPERATOR}
    {$HPPEMIT '#define SCE_AVE_OPERATOR 10'}
    SCE_AVE_WORD1 = 11;
    {$EXTERNALSYM SCE_AVE_WORD1}
    {$HPPEMIT '#define SCE_AVE_WORD1 11'}
    SCE_AVE_WORD2 = 12;
    {$EXTERNALSYM SCE_AVE_WORD2}
    {$HPPEMIT '#define SCE_AVE_WORD2 12'}
    SCE_AVE_WORD3 = 13;
    {$EXTERNALSYM SCE_AVE_WORD3}
    {$HPPEMIT '#define SCE_AVE_WORD3 13'}
    SCE_AVE_WORD4 = 14;
    {$EXTERNALSYM SCE_AVE_WORD4}
    {$HPPEMIT '#define SCE_AVE_WORD4 14'}
    SCE_AVE_WORD5 = 15;
    {$EXTERNALSYM SCE_AVE_WORD5}
    {$HPPEMIT '#define SCE_AVE_WORD5 15'}
    SCE_AVE_WORD6 = 16;
    {$EXTERNALSYM SCE_AVE_WORD6}
    {$HPPEMIT '#define SCE_AVE_WORD6 16'}
    SCE_ADA_DEFAULT = 0;
    {$EXTERNALSYM SCE_ADA_DEFAULT}
    {$HPPEMIT '#define SCE_ADA_DEFAULT 0'}
    SCE_ADA_WORD = 1;
    {$EXTERNALSYM SCE_ADA_WORD}
    {$HPPEMIT '#define SCE_ADA_WORD 1'}
    SCE_ADA_IDENTIFIER = 2;
    {$EXTERNALSYM SCE_ADA_IDENTIFIER}
    {$HPPEMIT '#define SCE_ADA_IDENTIFIER 2'}
    SCE_ADA_NUMBER = 3;
    {$EXTERNALSYM SCE_ADA_NUMBER}
    {$HPPEMIT '#define SCE_ADA_NUMBER 3'}
    SCE_ADA_DELIMITER = 4;
    {$EXTERNALSYM SCE_ADA_DELIMITER}
    {$HPPEMIT '#define SCE_ADA_DELIMITER 4'}
    SCE_ADA_CHARACTER = 5;
    {$EXTERNALSYM SCE_ADA_CHARACTER}
    {$HPPEMIT '#define SCE_ADA_CHARACTER 5'}
    SCE_ADA_CHARACTEREOL = 6;
    {$EXTERNALSYM SCE_ADA_CHARACTEREOL}
    {$HPPEMIT '#define SCE_ADA_CHARACTEREOL 6'}
    SCE_ADA_STRING = 7;
    {$EXTERNALSYM SCE_ADA_STRING}
    {$HPPEMIT '#define SCE_ADA_STRING 7'}
    SCE_ADA_STRINGEOL = 8;
    {$EXTERNALSYM SCE_ADA_STRINGEOL}
    {$HPPEMIT '#define SCE_ADA_STRINGEOL 8'}
    SCE_ADA_LABEL = 9;
    {$EXTERNALSYM SCE_ADA_LABEL}
    {$HPPEMIT '#define SCE_ADA_LABEL 9'}
    SCE_ADA_COMMENTLINE = 10;
    {$EXTERNALSYM SCE_ADA_COMMENTLINE}
    {$HPPEMIT '#define SCE_ADA_COMMENTLINE 10'}
    SCE_ADA_ILLEGAL = 11;
    {$EXTERNALSYM SCE_ADA_ILLEGAL}
    {$HPPEMIT '#define SCE_ADA_ILLEGAL 11'}
    SCE_BAAN_DEFAULT = 0;
    {$EXTERNALSYM SCE_BAAN_DEFAULT}
    {$HPPEMIT '#define SCE_BAAN_DEFAULT 0'}
    SCE_BAAN_COMMENT = 1;
    {$EXTERNALSYM SCE_BAAN_COMMENT}
    {$HPPEMIT '#define SCE_BAAN_COMMENT 1'}
    SCE_BAAN_COMMENTDOC = 2;
    {$EXTERNALSYM SCE_BAAN_COMMENTDOC}
    {$HPPEMIT '#define SCE_BAAN_COMMENTDOC 2'}
    SCE_BAAN_NUMBER = 3;
    {$EXTERNALSYM SCE_BAAN_NUMBER}
    {$HPPEMIT '#define SCE_BAAN_NUMBER 3'}
    SCE_BAAN_WORD = 4;
    {$EXTERNALSYM SCE_BAAN_WORD}
    {$HPPEMIT '#define SCE_BAAN_WORD 4'}
    SCE_BAAN_STRING = 5;
    {$EXTERNALSYM SCE_BAAN_STRING}
    {$HPPEMIT '#define SCE_BAAN_STRING 5'}
    SCE_BAAN_PREPROCESSOR = 6;
    {$EXTERNALSYM SCE_BAAN_PREPROCESSOR}
    {$HPPEMIT '#define SCE_BAAN_PREPROCESSOR 6'}
    SCE_BAAN_OPERATOR = 7;
    {$EXTERNALSYM SCE_BAAN_OPERATOR}
    {$HPPEMIT '#define SCE_BAAN_OPERATOR 7'}
    SCE_BAAN_IDENTIFIER = 8;
    {$EXTERNALSYM SCE_BAAN_IDENTIFIER}
    {$HPPEMIT '#define SCE_BAAN_IDENTIFIER 8'}
    SCE_BAAN_STRINGEOL = 9;
    {$EXTERNALSYM SCE_BAAN_STRINGEOL}
    {$HPPEMIT '#define SCE_BAAN_STRINGEOL 9'}
    SCE_BAAN_WORD2 = 10;
    {$EXTERNALSYM SCE_BAAN_WORD2}
    {$HPPEMIT '#define SCE_BAAN_WORD2 10'}
    SCE_LISP_DEFAULT = 0;
    {$EXTERNALSYM SCE_LISP_DEFAULT}
    {$HPPEMIT '#define SCE_LISP_DEFAULT 0'}
    SCE_LISP_COMMENT = 1;
    {$EXTERNALSYM SCE_LISP_COMMENT}
    {$HPPEMIT '#define SCE_LISP_COMMENT 1'}
    SCE_LISP_NUMBER = 2;
    {$EXTERNALSYM SCE_LISP_NUMBER}
    {$HPPEMIT '#define SCE_LISP_NUMBER 2'}
    SCE_LISP_KEYWORD = 3;
    {$EXTERNALSYM SCE_LISP_KEYWORD}
    {$HPPEMIT '#define SCE_LISP_KEYWORD 3'}
    SCE_LISP_KEYWORD_KW = 4;
    {$EXTERNALSYM SCE_LISP_KEYWORD_KW}
    {$HPPEMIT '#define SCE_LISP_KEYWORD_KW 4'}
    SCE_LISP_SYMBOL = 5;
    {$EXTERNALSYM SCE_LISP_SYMBOL}
    {$HPPEMIT '#define SCE_LISP_SYMBOL 5'}
    SCE_LISP_STRING = 6;
    {$EXTERNALSYM SCE_LISP_STRING}
    {$HPPEMIT '#define SCE_LISP_STRING 6'}
    SCE_LISP_STRINGEOL = 8;
    {$EXTERNALSYM SCE_LISP_STRINGEOL}
    {$HPPEMIT '#define SCE_LISP_STRINGEOL 8'}
    SCE_LISP_IDENTIFIER = 9;
    {$EXTERNALSYM SCE_LISP_IDENTIFIER}
    {$HPPEMIT '#define SCE_LISP_IDENTIFIER 9'}
    SCE_LISP_OPERATOR = 10;
    {$EXTERNALSYM SCE_LISP_OPERATOR}
    {$HPPEMIT '#define SCE_LISP_OPERATOR 10'}
    SCE_LISP_SPECIAL = 11;
    {$EXTERNALSYM SCE_LISP_SPECIAL}
    {$HPPEMIT '#define SCE_LISP_SPECIAL 11'}
    SCE_LISP_MULTI_COMMENT = 12;
    {$EXTERNALSYM SCE_LISP_MULTI_COMMENT}
    {$HPPEMIT '#define SCE_LISP_MULTI_COMMENT 12'}
    SCE_EIFFEL_DEFAULT = 0;
    {$EXTERNALSYM SCE_EIFFEL_DEFAULT}
    {$HPPEMIT '#define SCE_EIFFEL_DEFAULT 0'}
    SCE_EIFFEL_COMMENTLINE = 1;
    {$EXTERNALSYM SCE_EIFFEL_COMMENTLINE}
    {$HPPEMIT '#define SCE_EIFFEL_COMMENTLINE 1'}
    SCE_EIFFEL_NUMBER = 2;
    {$EXTERNALSYM SCE_EIFFEL_NUMBER}
    {$HPPEMIT '#define SCE_EIFFEL_NUMBER 2'}
    SCE_EIFFEL_WORD = 3;
    {$EXTERNALSYM SCE_EIFFEL_WORD}
    {$HPPEMIT '#define SCE_EIFFEL_WORD 3'}
    SCE_EIFFEL_STRING = 4;
    {$EXTERNALSYM SCE_EIFFEL_STRING}
    {$HPPEMIT '#define SCE_EIFFEL_STRING 4'}
    SCE_EIFFEL_CHARACTER = 5;
    {$EXTERNALSYM SCE_EIFFEL_CHARACTER}
    {$HPPEMIT '#define SCE_EIFFEL_CHARACTER 5'}
    SCE_EIFFEL_OPERATOR = 6;
    {$EXTERNALSYM SCE_EIFFEL_OPERATOR}
    {$HPPEMIT '#define SCE_EIFFEL_OPERATOR 6'}
    SCE_EIFFEL_IDENTIFIER = 7;
    {$EXTERNALSYM SCE_EIFFEL_IDENTIFIER}
    {$HPPEMIT '#define SCE_EIFFEL_IDENTIFIER 7'}
    SCE_EIFFEL_STRINGEOL = 8;
    {$EXTERNALSYM SCE_EIFFEL_STRINGEOL}
    {$HPPEMIT '#define SCE_EIFFEL_STRINGEOL 8'}
    SCE_NNCRONTAB_DEFAULT = 0;
    {$EXTERNALSYM SCE_NNCRONTAB_DEFAULT}
    {$HPPEMIT '#define SCE_NNCRONTAB_DEFAULT 0'}
    SCE_NNCRONTAB_COMMENT = 1;
    {$EXTERNALSYM SCE_NNCRONTAB_COMMENT}
    {$HPPEMIT '#define SCE_NNCRONTAB_COMMENT 1'}
    SCE_NNCRONTAB_TASK = 2;
    {$EXTERNALSYM SCE_NNCRONTAB_TASK}
    {$HPPEMIT '#define SCE_NNCRONTAB_TASK 2'}
    SCE_NNCRONTAB_SECTION = 3;
    {$EXTERNALSYM SCE_NNCRONTAB_SECTION}
    {$HPPEMIT '#define SCE_NNCRONTAB_SECTION 3'}
    SCE_NNCRONTAB_KEYWORD = 4;
    {$EXTERNALSYM SCE_NNCRONTAB_KEYWORD}
    {$HPPEMIT '#define SCE_NNCRONTAB_KEYWORD 4'}
    SCE_NNCRONTAB_MODIFIER = 5;
    {$EXTERNALSYM SCE_NNCRONTAB_MODIFIER}
    {$HPPEMIT '#define SCE_NNCRONTAB_MODIFIER 5'}
    SCE_NNCRONTAB_ASTERISK = 6;
    {$EXTERNALSYM SCE_NNCRONTAB_ASTERISK}
    {$HPPEMIT '#define SCE_NNCRONTAB_ASTERISK 6'}
    SCE_NNCRONTAB_NUMBER = 7;
    {$EXTERNALSYM SCE_NNCRONTAB_NUMBER}
    {$HPPEMIT '#define SCE_NNCRONTAB_NUMBER 7'}
    SCE_NNCRONTAB_STRING = 8;
    {$EXTERNALSYM SCE_NNCRONTAB_STRING}
    {$HPPEMIT '#define SCE_NNCRONTAB_STRING 8'}
    SCE_NNCRONTAB_ENVIRONMENT = 9;
    {$EXTERNALSYM SCE_NNCRONTAB_ENVIRONMENT}
    {$HPPEMIT '#define SCE_NNCRONTAB_ENVIRONMENT 9'}
    SCE_NNCRONTAB_IDENTIFIER = 10;
    {$EXTERNALSYM SCE_NNCRONTAB_IDENTIFIER}
    {$HPPEMIT '#define SCE_NNCRONTAB_IDENTIFIER 10'}
    SCE_FORTH_DEFAULT = 0;
    {$EXTERNALSYM SCE_FORTH_DEFAULT}
    {$HPPEMIT '#define SCE_FORTH_DEFAULT 0'}
    SCE_FORTH_COMMENT = 1;
    {$EXTERNALSYM SCE_FORTH_COMMENT}
    {$HPPEMIT '#define SCE_FORTH_COMMENT 1'}
    SCE_FORTH_COMMENT_ML = 2;
    {$EXTERNALSYM SCE_FORTH_COMMENT_ML}
    {$HPPEMIT '#define SCE_FORTH_COMMENT_ML 2'}
    SCE_FORTH_IDENTIFIER = 3;
    {$EXTERNALSYM SCE_FORTH_IDENTIFIER}
    {$HPPEMIT '#define SCE_FORTH_IDENTIFIER 3'}
    SCE_FORTH_CONTROL = 4;
    {$EXTERNALSYM SCE_FORTH_CONTROL}
    {$HPPEMIT '#define SCE_FORTH_CONTROL 4'}
    SCE_FORTH_KEYWORD = 5;
    {$EXTERNALSYM SCE_FORTH_KEYWORD}
    {$HPPEMIT '#define SCE_FORTH_KEYWORD 5'}
    SCE_FORTH_DEFWORD = 6;
    {$EXTERNALSYM SCE_FORTH_DEFWORD}
    {$HPPEMIT '#define SCE_FORTH_DEFWORD 6'}
    SCE_FORTH_PREWORD1 = 7;
    {$EXTERNALSYM SCE_FORTH_PREWORD1}
    {$HPPEMIT '#define SCE_FORTH_PREWORD1 7'}
    SCE_FORTH_PREWORD2 = 8;
    {$EXTERNALSYM SCE_FORTH_PREWORD2}
    {$HPPEMIT '#define SCE_FORTH_PREWORD2 8'}
    SCE_FORTH_NUMBER = 9;
    {$EXTERNALSYM SCE_FORTH_NUMBER}
    {$HPPEMIT '#define SCE_FORTH_NUMBER 9'}
    SCE_FORTH_STRING = 10;
    {$EXTERNALSYM SCE_FORTH_STRING}
    {$HPPEMIT '#define SCE_FORTH_STRING 10'}
    SCE_FORTH_LOCALE = 11;
    {$EXTERNALSYM SCE_FORTH_LOCALE}
    {$HPPEMIT '#define SCE_FORTH_LOCALE 11'}
    SCE_MATLAB_DEFAULT = 0;
    {$EXTERNALSYM SCE_MATLAB_DEFAULT}
    {$HPPEMIT '#define SCE_MATLAB_DEFAULT 0'}
    SCE_MATLAB_COMMENT = 1;
    {$EXTERNALSYM SCE_MATLAB_COMMENT}
    {$HPPEMIT '#define SCE_MATLAB_COMMENT 1'}
    SCE_MATLAB_COMMAND = 2;
    {$EXTERNALSYM SCE_MATLAB_COMMAND}
    {$HPPEMIT '#define SCE_MATLAB_COMMAND 2'}
    SCE_MATLAB_NUMBER = 3;
    {$EXTERNALSYM SCE_MATLAB_NUMBER}
    {$HPPEMIT '#define SCE_MATLAB_NUMBER 3'}
    SCE_MATLAB_KEYWORD = 4;
    {$EXTERNALSYM SCE_MATLAB_KEYWORD}
    {$HPPEMIT '#define SCE_MATLAB_KEYWORD 4'}
    SCE_MATLAB_STRING = 5;
    {$EXTERNALSYM SCE_MATLAB_STRING}
    {$HPPEMIT '#define SCE_MATLAB_STRING 5'}
    SCE_MATLAB_OPERATOR = 6;
    {$EXTERNALSYM SCE_MATLAB_OPERATOR}
    {$HPPEMIT '#define SCE_MATLAB_OPERATOR 6'}
    SCE_MATLAB_IDENTIFIER = 7;
    {$EXTERNALSYM SCE_MATLAB_IDENTIFIER}
    {$HPPEMIT '#define SCE_MATLAB_IDENTIFIER 7'}
    SCE_MATLAB_DOUBLEQUOTESTRING = 8;
    {$EXTERNALSYM SCE_MATLAB_DOUBLEQUOTESTRING}
    {$HPPEMIT '#define SCE_MATLAB_DOUBLEQUOTESTRING 8'}
    SCE_SCRIPTOL_DEFAULT = 0;
    {$EXTERNALSYM SCE_SCRIPTOL_DEFAULT}
    {$HPPEMIT '#define SCE_SCRIPTOL_DEFAULT 0'}
    SCE_SCRIPTOL_WHITE = 1;
    {$EXTERNALSYM SCE_SCRIPTOL_WHITE}
    {$HPPEMIT '#define SCE_SCRIPTOL_WHITE 1'}
    SCE_SCRIPTOL_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_SCRIPTOL_COMMENTLINE}
    {$HPPEMIT '#define SCE_SCRIPTOL_COMMENTLINE 2'}
    SCE_SCRIPTOL_PERSISTENT = 3;
    {$EXTERNALSYM SCE_SCRIPTOL_PERSISTENT}
    {$HPPEMIT '#define SCE_SCRIPTOL_PERSISTENT 3'}
    SCE_SCRIPTOL_CSTYLE = 4;
    {$EXTERNALSYM SCE_SCRIPTOL_CSTYLE}
    {$HPPEMIT '#define SCE_SCRIPTOL_CSTYLE 4'}
    SCE_SCRIPTOL_COMMENTBLOCK = 5;
    {$EXTERNALSYM SCE_SCRIPTOL_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_SCRIPTOL_COMMENTBLOCK 5'}
    SCE_SCRIPTOL_NUMBER = 6;
    {$EXTERNALSYM SCE_SCRIPTOL_NUMBER}
    {$HPPEMIT '#define SCE_SCRIPTOL_NUMBER 6'}
    SCE_SCRIPTOL_STRING = 7;
    {$EXTERNALSYM SCE_SCRIPTOL_STRING}
    {$HPPEMIT '#define SCE_SCRIPTOL_STRING 7'}
    SCE_SCRIPTOL_CHARACTER = 8;
    {$EXTERNALSYM SCE_SCRIPTOL_CHARACTER}
    {$HPPEMIT '#define SCE_SCRIPTOL_CHARACTER 8'}
    SCE_SCRIPTOL_STRINGEOL = 9;
    {$EXTERNALSYM SCE_SCRIPTOL_STRINGEOL}
    {$HPPEMIT '#define SCE_SCRIPTOL_STRINGEOL 9'}
    SCE_SCRIPTOL_KEYWORD = 10;
    {$EXTERNALSYM SCE_SCRIPTOL_KEYWORD}
    {$HPPEMIT '#define SCE_SCRIPTOL_KEYWORD 10'}
    SCE_SCRIPTOL_OPERATOR = 11;
    {$EXTERNALSYM SCE_SCRIPTOL_OPERATOR}
    {$HPPEMIT '#define SCE_SCRIPTOL_OPERATOR 11'}
    SCE_SCRIPTOL_IDENTIFIER = 12;
    {$EXTERNALSYM SCE_SCRIPTOL_IDENTIFIER}
    {$HPPEMIT '#define SCE_SCRIPTOL_IDENTIFIER 12'}
    SCE_SCRIPTOL_TRIPLE = 13;
    {$EXTERNALSYM SCE_SCRIPTOL_TRIPLE}
    {$HPPEMIT '#define SCE_SCRIPTOL_TRIPLE 13'}
    SCE_SCRIPTOL_CLASSNAME = 14;
    {$EXTERNALSYM SCE_SCRIPTOL_CLASSNAME}
    {$HPPEMIT '#define SCE_SCRIPTOL_CLASSNAME 14'}
    SCE_SCRIPTOL_PREPROCESSOR = 15;
    {$EXTERNALSYM SCE_SCRIPTOL_PREPROCESSOR}
    {$HPPEMIT '#define SCE_SCRIPTOL_PREPROCESSOR 15'}
    SCE_ASM_DEFAULT = 0;
    {$EXTERNALSYM SCE_ASM_DEFAULT}
    {$HPPEMIT '#define SCE_ASM_DEFAULT 0'}
    SCE_ASM_COMMENT = 1;
    {$EXTERNALSYM SCE_ASM_COMMENT}
    {$HPPEMIT '#define SCE_ASM_COMMENT 1'}
    SCE_ASM_NUMBER = 2;
    {$EXTERNALSYM SCE_ASM_NUMBER}
    {$HPPEMIT '#define SCE_ASM_NUMBER 2'}
    SCE_ASM_STRING = 3;
    {$EXTERNALSYM SCE_ASM_STRING}
    {$HPPEMIT '#define SCE_ASM_STRING 3'}
    SCE_ASM_OPERATOR = 4;
    {$EXTERNALSYM SCE_ASM_OPERATOR}
    {$HPPEMIT '#define SCE_ASM_OPERATOR 4'}
    SCE_ASM_IDENTIFIER = 5;
    {$EXTERNALSYM SCE_ASM_IDENTIFIER}
    {$HPPEMIT '#define SCE_ASM_IDENTIFIER 5'}
    SCE_ASM_CPUINSTRUCTION = 6;
    {$EXTERNALSYM SCE_ASM_CPUINSTRUCTION}
    {$HPPEMIT '#define SCE_ASM_CPUINSTRUCTION 6'}
    SCE_ASM_MATHINSTRUCTION = 7;
    {$EXTERNALSYM SCE_ASM_MATHINSTRUCTION}
    {$HPPEMIT '#define SCE_ASM_MATHINSTRUCTION 7'}
    SCE_ASM_REGISTER = 8;
    {$EXTERNALSYM SCE_ASM_REGISTER}
    {$HPPEMIT '#define SCE_ASM_REGISTER 8'}
    SCE_ASM_DIRECTIVE = 9;
    {$EXTERNALSYM SCE_ASM_DIRECTIVE}
    {$HPPEMIT '#define SCE_ASM_DIRECTIVE 9'}
    SCE_ASM_DIRECTIVEOPERAND = 10;
    {$EXTERNALSYM SCE_ASM_DIRECTIVEOPERAND}
    {$HPPEMIT '#define SCE_ASM_DIRECTIVEOPERAND 10'}
    SCE_ASM_COMMENTBLOCK = 11;
    {$EXTERNALSYM SCE_ASM_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_ASM_COMMENTBLOCK 11'}
    SCE_ASM_CHARACTER = 12;
    {$EXTERNALSYM SCE_ASM_CHARACTER}
    {$HPPEMIT '#define SCE_ASM_CHARACTER 12'}
    SCE_ASM_STRINGEOL = 13;
    {$EXTERNALSYM SCE_ASM_STRINGEOL}
    {$HPPEMIT '#define SCE_ASM_STRINGEOL 13'}
    SCE_ASM_EXTINSTRUCTION = 14;
    {$EXTERNALSYM SCE_ASM_EXTINSTRUCTION}
    {$HPPEMIT '#define SCE_ASM_EXTINSTRUCTION 14'}
    SCE_F_DEFAULT = 0;
    {$EXTERNALSYM SCE_F_DEFAULT}
    {$HPPEMIT '#define SCE_F_DEFAULT 0'}
    SCE_F_COMMENT = 1;
    {$EXTERNALSYM SCE_F_COMMENT}
    {$HPPEMIT '#define SCE_F_COMMENT 1'}
    SCE_F_NUMBER = 2;
    {$EXTERNALSYM SCE_F_NUMBER}
    {$HPPEMIT '#define SCE_F_NUMBER 2'}
    SCE_F_STRING1 = 3;
    {$EXTERNALSYM SCE_F_STRING1}
    {$HPPEMIT '#define SCE_F_STRING1 3'}
    SCE_F_STRING2 = 4;
    {$EXTERNALSYM SCE_F_STRING2}
    {$HPPEMIT '#define SCE_F_STRING2 4'}
    SCE_F_STRINGEOL = 5;
    {$EXTERNALSYM SCE_F_STRINGEOL}
    {$HPPEMIT '#define SCE_F_STRINGEOL 5'}
    SCE_F_OPERATOR = 6;
    {$EXTERNALSYM SCE_F_OPERATOR}
    {$HPPEMIT '#define SCE_F_OPERATOR 6'}
    SCE_F_IDENTIFIER = 7;
    {$EXTERNALSYM SCE_F_IDENTIFIER}
    {$HPPEMIT '#define SCE_F_IDENTIFIER 7'}
    SCE_F_WORD = 8;
    {$EXTERNALSYM SCE_F_WORD}
    {$HPPEMIT '#define SCE_F_WORD 8'}
    SCE_F_WORD2 = 9;
    {$EXTERNALSYM SCE_F_WORD2}
    {$HPPEMIT '#define SCE_F_WORD2 9'}
    SCE_F_WORD3 = 10;
    {$EXTERNALSYM SCE_F_WORD3}
    {$HPPEMIT '#define SCE_F_WORD3 10'}
    SCE_F_PREPROCESSOR = 11;
    {$EXTERNALSYM SCE_F_PREPROCESSOR}
    {$HPPEMIT '#define SCE_F_PREPROCESSOR 11'}
    SCE_F_OPERATOR2 = 12;
    {$EXTERNALSYM SCE_F_OPERATOR2}
    {$HPPEMIT '#define SCE_F_OPERATOR2 12'}
    SCE_F_LABEL = 13;
    {$EXTERNALSYM SCE_F_LABEL}
    {$HPPEMIT '#define SCE_F_LABEL 13'}
    SCE_F_CONTINUATION = 14;
    {$EXTERNALSYM SCE_F_CONTINUATION}
    {$HPPEMIT '#define SCE_F_CONTINUATION 14'}
    SCE_CSS_DEFAULT = 0;
    {$EXTERNALSYM SCE_CSS_DEFAULT}
    {$HPPEMIT '#define SCE_CSS_DEFAULT 0'}
    SCE_CSS_TAG = 1;
    {$EXTERNALSYM SCE_CSS_TAG}
    {$HPPEMIT '#define SCE_CSS_TAG 1'}
    SCE_CSS_CLASS = 2;
    {$EXTERNALSYM SCE_CSS_CLASS}
    {$HPPEMIT '#define SCE_CSS_CLASS 2'}
    SCE_CSS_PSEUDOCLASS = 3;
    {$EXTERNALSYM SCE_CSS_PSEUDOCLASS}
    {$HPPEMIT '#define SCE_CSS_PSEUDOCLASS 3'}
    SCE_CSS_UNKNOWN_PSEUDOCLASS = 4;
    {$EXTERNALSYM SCE_CSS_UNKNOWN_PSEUDOCLASS}
    {$HPPEMIT '#define SCE_CSS_UNKNOWN_PSEUDOCLASS 4'}
    SCE_CSS_OPERATOR = 5;
    {$EXTERNALSYM SCE_CSS_OPERATOR}
    {$HPPEMIT '#define SCE_CSS_OPERATOR 5'}
    SCE_CSS_IDENTIFIER = 6;
    {$EXTERNALSYM SCE_CSS_IDENTIFIER}
    {$HPPEMIT '#define SCE_CSS_IDENTIFIER 6'}
    SCE_CSS_UNKNOWN_IDENTIFIER = 7;
    {$EXTERNALSYM SCE_CSS_UNKNOWN_IDENTIFIER}
    {$HPPEMIT '#define SCE_CSS_UNKNOWN_IDENTIFIER 7'}
    SCE_CSS_VALUE = 8;
    {$EXTERNALSYM SCE_CSS_VALUE}
    {$HPPEMIT '#define SCE_CSS_VALUE 8'}
    SCE_CSS_COMMENT = 9;
    {$EXTERNALSYM SCE_CSS_COMMENT}
    {$HPPEMIT '#define SCE_CSS_COMMENT 9'}
    SCE_CSS_ID = 10;
    {$EXTERNALSYM SCE_CSS_ID}
    {$HPPEMIT '#define SCE_CSS_ID 10'}
    SCE_CSS_IMPORTANT = 11;
    {$EXTERNALSYM SCE_CSS_IMPORTANT}
    {$HPPEMIT '#define SCE_CSS_IMPORTANT 11'}
    SCE_CSS_DIRECTIVE = 12;
    {$EXTERNALSYM SCE_CSS_DIRECTIVE}
    {$HPPEMIT '#define SCE_CSS_DIRECTIVE 12'}
    SCE_CSS_DOUBLESTRING = 13;
    {$EXTERNALSYM SCE_CSS_DOUBLESTRING}
    {$HPPEMIT '#define SCE_CSS_DOUBLESTRING 13'}
    SCE_CSS_SINGLESTRING = 14;
    {$EXTERNALSYM SCE_CSS_SINGLESTRING}
    {$HPPEMIT '#define SCE_CSS_SINGLESTRING 14'}
    SCE_CSS_IDENTIFIER2 = 15;
    {$EXTERNALSYM SCE_CSS_IDENTIFIER2}
    {$HPPEMIT '#define SCE_CSS_IDENTIFIER2 15'}
    SCE_CSS_ATTRIBUTE = 16;
    {$EXTERNALSYM SCE_CSS_ATTRIBUTE}
    {$HPPEMIT '#define SCE_CSS_ATTRIBUTE 16'}
    SCE_POV_DEFAULT = 0;
    {$EXTERNALSYM SCE_POV_DEFAULT}
    {$HPPEMIT '#define SCE_POV_DEFAULT 0'}
    SCE_POV_COMMENT = 1;
    {$EXTERNALSYM SCE_POV_COMMENT}
    {$HPPEMIT '#define SCE_POV_COMMENT 1'}
    SCE_POV_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_POV_COMMENTLINE}
    {$HPPEMIT '#define SCE_POV_COMMENTLINE 2'}
    SCE_POV_NUMBER = 3;
    {$EXTERNALSYM SCE_POV_NUMBER}
    {$HPPEMIT '#define SCE_POV_NUMBER 3'}
    SCE_POV_OPERATOR = 4;
    {$EXTERNALSYM SCE_POV_OPERATOR}
    {$HPPEMIT '#define SCE_POV_OPERATOR 4'}
    SCE_POV_IDENTIFIER = 5;
    {$EXTERNALSYM SCE_POV_IDENTIFIER}
    {$HPPEMIT '#define SCE_POV_IDENTIFIER 5'}
    SCE_POV_STRING = 6;
    {$EXTERNALSYM SCE_POV_STRING}
    {$HPPEMIT '#define SCE_POV_STRING 6'}
    SCE_POV_STRINGEOL = 7;
    {$EXTERNALSYM SCE_POV_STRINGEOL}
    {$HPPEMIT '#define SCE_POV_STRINGEOL 7'}
    SCE_POV_DIRECTIVE = 8;
    {$EXTERNALSYM SCE_POV_DIRECTIVE}
    {$HPPEMIT '#define SCE_POV_DIRECTIVE 8'}
    SCE_POV_BADDIRECTIVE = 9;
    {$EXTERNALSYM SCE_POV_BADDIRECTIVE}
    {$HPPEMIT '#define SCE_POV_BADDIRECTIVE 9'}
    SCE_POV_WORD2 = 10;
    {$EXTERNALSYM SCE_POV_WORD2}
    {$HPPEMIT '#define SCE_POV_WORD2 10'}
    SCE_POV_WORD3 = 11;
    {$EXTERNALSYM SCE_POV_WORD3}
    {$HPPEMIT '#define SCE_POV_WORD3 11'}
    SCE_POV_WORD4 = 12;
    {$EXTERNALSYM SCE_POV_WORD4}
    {$HPPEMIT '#define SCE_POV_WORD4 12'}
    SCE_POV_WORD5 = 13;
    {$EXTERNALSYM SCE_POV_WORD5}
    {$HPPEMIT '#define SCE_POV_WORD5 13'}
    SCE_POV_WORD6 = 14;
    {$EXTERNALSYM SCE_POV_WORD6}
    {$HPPEMIT '#define SCE_POV_WORD6 14'}
    SCE_POV_WORD7 = 15;
    {$EXTERNALSYM SCE_POV_WORD7}
    {$HPPEMIT '#define SCE_POV_WORD7 15'}
    SCE_POV_WORD8 = 16;
    {$EXTERNALSYM SCE_POV_WORD8}
    {$HPPEMIT '#define SCE_POV_WORD8 16'}
    SCE_LOUT_DEFAULT = 0;
    {$EXTERNALSYM SCE_LOUT_DEFAULT}
    {$HPPEMIT '#define SCE_LOUT_DEFAULT 0'}
    SCE_LOUT_COMMENT = 1;
    {$EXTERNALSYM SCE_LOUT_COMMENT}
    {$HPPEMIT '#define SCE_LOUT_COMMENT 1'}
    SCE_LOUT_NUMBER = 2;
    {$EXTERNALSYM SCE_LOUT_NUMBER}
    {$HPPEMIT '#define SCE_LOUT_NUMBER 2'}
    SCE_LOUT_WORD = 3;
    {$EXTERNALSYM SCE_LOUT_WORD}
    {$HPPEMIT '#define SCE_LOUT_WORD 3'}
    SCE_LOUT_WORD2 = 4;
    {$EXTERNALSYM SCE_LOUT_WORD2}
    {$HPPEMIT '#define SCE_LOUT_WORD2 4'}
    SCE_LOUT_WORD3 = 5;
    {$EXTERNALSYM SCE_LOUT_WORD3}
    {$HPPEMIT '#define SCE_LOUT_WORD3 5'}
    SCE_LOUT_WORD4 = 6;
    {$EXTERNALSYM SCE_LOUT_WORD4}
    {$HPPEMIT '#define SCE_LOUT_WORD4 6'}
    SCE_LOUT_STRING = 7;
    {$EXTERNALSYM SCE_LOUT_STRING}
    {$HPPEMIT '#define SCE_LOUT_STRING 7'}
    SCE_LOUT_OPERATOR = 8;
    {$EXTERNALSYM SCE_LOUT_OPERATOR}
    {$HPPEMIT '#define SCE_LOUT_OPERATOR 8'}
    SCE_LOUT_IDENTIFIER = 9;
    {$EXTERNALSYM SCE_LOUT_IDENTIFIER}
    {$HPPEMIT '#define SCE_LOUT_IDENTIFIER 9'}
    SCE_LOUT_STRINGEOL = 10;
    {$EXTERNALSYM SCE_LOUT_STRINGEOL}
    {$HPPEMIT '#define SCE_LOUT_STRINGEOL 10'}
    SCE_ESCRIPT_DEFAULT = 0;
    {$EXTERNALSYM SCE_ESCRIPT_DEFAULT}
    {$HPPEMIT '#define SCE_ESCRIPT_DEFAULT 0'}
    SCE_ESCRIPT_COMMENT = 1;
    {$EXTERNALSYM SCE_ESCRIPT_COMMENT}
    {$HPPEMIT '#define SCE_ESCRIPT_COMMENT 1'}
    SCE_ESCRIPT_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_ESCRIPT_COMMENTLINE}
    {$HPPEMIT '#define SCE_ESCRIPT_COMMENTLINE 2'}
    SCE_ESCRIPT_COMMENTDOC = 3;
    {$EXTERNALSYM SCE_ESCRIPT_COMMENTDOC}
    {$HPPEMIT '#define SCE_ESCRIPT_COMMENTDOC 3'}
    SCE_ESCRIPT_NUMBER = 4;
    {$EXTERNALSYM SCE_ESCRIPT_NUMBER}
    {$HPPEMIT '#define SCE_ESCRIPT_NUMBER 4'}
    SCE_ESCRIPT_WORD = 5;
    {$EXTERNALSYM SCE_ESCRIPT_WORD}
    {$HPPEMIT '#define SCE_ESCRIPT_WORD 5'}
    SCE_ESCRIPT_STRING = 6;
    {$EXTERNALSYM SCE_ESCRIPT_STRING}
    {$HPPEMIT '#define SCE_ESCRIPT_STRING 6'}
    SCE_ESCRIPT_OPERATOR = 7;
    {$EXTERNALSYM SCE_ESCRIPT_OPERATOR}
    {$HPPEMIT '#define SCE_ESCRIPT_OPERATOR 7'}
    SCE_ESCRIPT_IDENTIFIER = 8;
    {$EXTERNALSYM SCE_ESCRIPT_IDENTIFIER}
    {$HPPEMIT '#define SCE_ESCRIPT_IDENTIFIER 8'}
    SCE_ESCRIPT_BRACE = 9;
    {$EXTERNALSYM SCE_ESCRIPT_BRACE}
    {$HPPEMIT '#define SCE_ESCRIPT_BRACE 9'}
    SCE_ESCRIPT_WORD2 = 10;
    {$EXTERNALSYM SCE_ESCRIPT_WORD2}
    {$HPPEMIT '#define SCE_ESCRIPT_WORD2 10'}
    SCE_ESCRIPT_WORD3 = 11;
    {$EXTERNALSYM SCE_ESCRIPT_WORD3}
    {$HPPEMIT '#define SCE_ESCRIPT_WORD3 11'}
    SCE_PS_DEFAULT = 0;
    {$EXTERNALSYM SCE_PS_DEFAULT}
    {$HPPEMIT '#define SCE_PS_DEFAULT 0'}
    SCE_PS_COMMENT = 1;
    {$EXTERNALSYM SCE_PS_COMMENT}
    {$HPPEMIT '#define SCE_PS_COMMENT 1'}
    SCE_PS_DSC_COMMENT = 2;
    {$EXTERNALSYM SCE_PS_DSC_COMMENT}
    {$HPPEMIT '#define SCE_PS_DSC_COMMENT 2'}
    SCE_PS_DSC_VALUE = 3;
    {$EXTERNALSYM SCE_PS_DSC_VALUE}
    {$HPPEMIT '#define SCE_PS_DSC_VALUE 3'}
    SCE_PS_NUMBER = 4;
    {$EXTERNALSYM SCE_PS_NUMBER}
    {$HPPEMIT '#define SCE_PS_NUMBER 4'}
    SCE_PS_NAME = 5;
    {$EXTERNALSYM SCE_PS_NAME}
    {$HPPEMIT '#define SCE_PS_NAME 5'}
    SCE_PS_KEYWORD = 6;
    {$EXTERNALSYM SCE_PS_KEYWORD}
    {$HPPEMIT '#define SCE_PS_KEYWORD 6'}
    SCE_PS_LITERAL = 7;
    {$EXTERNALSYM SCE_PS_LITERAL}
    {$HPPEMIT '#define SCE_PS_LITERAL 7'}
    SCE_PS_IMMEVAL = 8;
    {$EXTERNALSYM SCE_PS_IMMEVAL}
    {$HPPEMIT '#define SCE_PS_IMMEVAL 8'}
    SCE_PS_PAREN_ARRAY = 9;
    {$EXTERNALSYM SCE_PS_PAREN_ARRAY}
    {$HPPEMIT '#define SCE_PS_PAREN_ARRAY 9'}
    SCE_PS_PAREN_DICT = 10;
    {$EXTERNALSYM SCE_PS_PAREN_DICT}
    {$HPPEMIT '#define SCE_PS_PAREN_DICT 10'}
    SCE_PS_PAREN_PROC = 11;
    {$EXTERNALSYM SCE_PS_PAREN_PROC}
    {$HPPEMIT '#define SCE_PS_PAREN_PROC 11'}
    SCE_PS_TEXT = 12;
    {$EXTERNALSYM SCE_PS_TEXT}
    {$HPPEMIT '#define SCE_PS_TEXT 12'}
    SCE_PS_HEXSTRING = 13;
    {$EXTERNALSYM SCE_PS_HEXSTRING}
    {$HPPEMIT '#define SCE_PS_HEXSTRING 13'}
    SCE_PS_BASE85STRING = 14;
    {$EXTERNALSYM SCE_PS_BASE85STRING}
    {$HPPEMIT '#define SCE_PS_BASE85STRING 14'}
    SCE_PS_BADSTRINGCHAR = 15;
    {$EXTERNALSYM SCE_PS_BADSTRINGCHAR}
    {$HPPEMIT '#define SCE_PS_BADSTRINGCHAR 15'}
    SCE_NSIS_DEFAULT = 0;
    {$EXTERNALSYM SCE_NSIS_DEFAULT}
    {$HPPEMIT '#define SCE_NSIS_DEFAULT 0'}
    SCE_NSIS_COMMENT = 1;
    {$EXTERNALSYM SCE_NSIS_COMMENT}
    {$HPPEMIT '#define SCE_NSIS_COMMENT 1'}
    SCE_NSIS_STRINGDQ = 2;
    {$EXTERNALSYM SCE_NSIS_STRINGDQ}
    {$HPPEMIT '#define SCE_NSIS_STRINGDQ 2'}
    SCE_NSIS_STRINGLQ = 3;
    {$EXTERNALSYM SCE_NSIS_STRINGLQ}
    {$HPPEMIT '#define SCE_NSIS_STRINGLQ 3'}
    SCE_NSIS_STRINGRQ = 4;
    {$EXTERNALSYM SCE_NSIS_STRINGRQ}
    {$HPPEMIT '#define SCE_NSIS_STRINGRQ 4'}
    SCE_NSIS_FUNCTION = 5;
    {$EXTERNALSYM SCE_NSIS_FUNCTION}
    {$HPPEMIT '#define SCE_NSIS_FUNCTION 5'}
    SCE_NSIS_VARIABLE = 6;
    {$EXTERNALSYM SCE_NSIS_VARIABLE}
    {$HPPEMIT '#define SCE_NSIS_VARIABLE 6'}
    SCE_NSIS_LABEL = 7;
    {$EXTERNALSYM SCE_NSIS_LABEL}
    {$HPPEMIT '#define SCE_NSIS_LABEL 7'}
    SCE_NSIS_USERDEFINED = 8;
    {$EXTERNALSYM SCE_NSIS_USERDEFINED}
    {$HPPEMIT '#define SCE_NSIS_USERDEFINED 8'}
    SCE_NSIS_SECTIONDEF = 9;
    {$EXTERNALSYM SCE_NSIS_SECTIONDEF}
    {$HPPEMIT '#define SCE_NSIS_SECTIONDEF 9'}
    SCE_NSIS_SUBSECTIONDEF = 10;
    {$EXTERNALSYM SCE_NSIS_SUBSECTIONDEF}
    {$HPPEMIT '#define SCE_NSIS_SUBSECTIONDEF 10'}
    SCE_NSIS_IFDEFINEDEF = 11;
    {$EXTERNALSYM SCE_NSIS_IFDEFINEDEF}
    {$HPPEMIT '#define SCE_NSIS_IFDEFINEDEF 11'}
    SCE_NSIS_MACRODEF = 12;
    {$EXTERNALSYM SCE_NSIS_MACRODEF}
    {$HPPEMIT '#define SCE_NSIS_MACRODEF 12'}
    SCE_NSIS_STRINGVAR = 13;
    {$EXTERNALSYM SCE_NSIS_STRINGVAR}
    {$HPPEMIT '#define SCE_NSIS_STRINGVAR 13'}
    SCE_NSIS_NUMBER = 14;
    {$EXTERNALSYM SCE_NSIS_NUMBER}
    {$HPPEMIT '#define SCE_NSIS_NUMBER 14'}
    SCE_NSIS_SECTIONGROUP = 15;
    {$EXTERNALSYM SCE_NSIS_SECTIONGROUP}
    {$HPPEMIT '#define SCE_NSIS_SECTIONGROUP 15'}
    SCE_NSIS_PAGEEX = 16;
    {$EXTERNALSYM SCE_NSIS_PAGEEX}
    {$HPPEMIT '#define SCE_NSIS_PAGEEX 16'}
    SCE_NSIS_FUNCTIONDEF = 17;
    {$EXTERNALSYM SCE_NSIS_FUNCTIONDEF}
    {$HPPEMIT '#define SCE_NSIS_FUNCTIONDEF 17'}
    SCE_NSIS_COMMENTBOX = 18;
    {$EXTERNALSYM SCE_NSIS_COMMENTBOX}
    {$HPPEMIT '#define SCE_NSIS_COMMENTBOX 18'}
    SCE_MMIXAL_LEADWS = 0;
    {$EXTERNALSYM SCE_MMIXAL_LEADWS}
    {$HPPEMIT '#define SCE_MMIXAL_LEADWS 0'}
    SCE_MMIXAL_COMMENT = 1;
    {$EXTERNALSYM SCE_MMIXAL_COMMENT}
    {$HPPEMIT '#define SCE_MMIXAL_COMMENT 1'}
    SCE_MMIXAL_LABEL = 2;
    {$EXTERNALSYM SCE_MMIXAL_LABEL}
    {$HPPEMIT '#define SCE_MMIXAL_LABEL 2'}
    SCE_MMIXAL_OPCODE = 3;
    {$EXTERNALSYM SCE_MMIXAL_OPCODE}
    {$HPPEMIT '#define SCE_MMIXAL_OPCODE 3'}
    SCE_MMIXAL_OPCODE_PRE = 4;
    {$EXTERNALSYM SCE_MMIXAL_OPCODE_PRE}
    {$HPPEMIT '#define SCE_MMIXAL_OPCODE_PRE 4'}
    SCE_MMIXAL_OPCODE_VALID = 5;
    {$EXTERNALSYM SCE_MMIXAL_OPCODE_VALID}
    {$HPPEMIT '#define SCE_MMIXAL_OPCODE_VALID 5'}
    SCE_MMIXAL_OPCODE_UNKNOWN = 6;
    {$EXTERNALSYM SCE_MMIXAL_OPCODE_UNKNOWN}
    {$HPPEMIT '#define SCE_MMIXAL_OPCODE_UNKNOWN 6'}
    SCE_MMIXAL_OPCODE_POST = 7;
    {$EXTERNALSYM SCE_MMIXAL_OPCODE_POST}
    {$HPPEMIT '#define SCE_MMIXAL_OPCODE_POST 7'}
    SCE_MMIXAL_OPERANDS = 8;
    {$EXTERNALSYM SCE_MMIXAL_OPERANDS}
    {$HPPEMIT '#define SCE_MMIXAL_OPERANDS 8'}
    SCE_MMIXAL_NUMBER = 9;
    {$EXTERNALSYM SCE_MMIXAL_NUMBER}
    {$HPPEMIT '#define SCE_MMIXAL_NUMBER 9'}
    SCE_MMIXAL_REF = 10;
    {$EXTERNALSYM SCE_MMIXAL_REF}
    {$HPPEMIT '#define SCE_MMIXAL_REF 10'}
    SCE_MMIXAL_CHAR = 11;
    {$EXTERNALSYM SCE_MMIXAL_CHAR}
    {$HPPEMIT '#define SCE_MMIXAL_CHAR 11'}
    SCE_MMIXAL_STRING = 12;
    {$EXTERNALSYM SCE_MMIXAL_STRING}
    {$HPPEMIT '#define SCE_MMIXAL_STRING 12'}
    SCE_MMIXAL_REGISTER = 13;
    {$EXTERNALSYM SCE_MMIXAL_REGISTER}
    {$HPPEMIT '#define SCE_MMIXAL_REGISTER 13'}
    SCE_MMIXAL_HEX = 14;
    {$EXTERNALSYM SCE_MMIXAL_HEX}
    {$HPPEMIT '#define SCE_MMIXAL_HEX 14'}
    SCE_MMIXAL_OPERATOR = 15;
    {$EXTERNALSYM SCE_MMIXAL_OPERATOR}
    {$HPPEMIT '#define SCE_MMIXAL_OPERATOR 15'}
    SCE_MMIXAL_SYMBOL = 16;
    {$EXTERNALSYM SCE_MMIXAL_SYMBOL}
    {$HPPEMIT '#define SCE_MMIXAL_SYMBOL 16'}
    SCE_MMIXAL_INCLUDE = 17;
    {$EXTERNALSYM SCE_MMIXAL_INCLUDE}
    {$HPPEMIT '#define SCE_MMIXAL_INCLUDE 17'}
    SCE_CLW_DEFAULT = 0;
    {$EXTERNALSYM SCE_CLW_DEFAULT}
    {$HPPEMIT '#define SCE_CLW_DEFAULT 0'}
    SCE_CLW_LABEL = 1;
    {$EXTERNALSYM SCE_CLW_LABEL}
    {$HPPEMIT '#define SCE_CLW_LABEL 1'}
    SCE_CLW_COMMENT = 2;
    {$EXTERNALSYM SCE_CLW_COMMENT}
    {$HPPEMIT '#define SCE_CLW_COMMENT 2'}
    SCE_CLW_STRING = 3;
    {$EXTERNALSYM SCE_CLW_STRING}
    {$HPPEMIT '#define SCE_CLW_STRING 3'}
    SCE_CLW_USER_IDENTIFIER = 4;
    {$EXTERNALSYM SCE_CLW_USER_IDENTIFIER}
    {$HPPEMIT '#define SCE_CLW_USER_IDENTIFIER 4'}
    SCE_CLW_INTEGER_CONSTANT = 5;
    {$EXTERNALSYM SCE_CLW_INTEGER_CONSTANT}
    {$HPPEMIT '#define SCE_CLW_INTEGER_CONSTANT 5'}
    SCE_CLW_REAL_CONSTANT = 6;
    {$EXTERNALSYM SCE_CLW_REAL_CONSTANT}
    {$HPPEMIT '#define SCE_CLW_REAL_CONSTANT 6'}
    SCE_CLW_PICTURE_STRING = 7;
    {$EXTERNALSYM SCE_CLW_PICTURE_STRING}
    {$HPPEMIT '#define SCE_CLW_PICTURE_STRING 7'}
    SCE_CLW_KEYWORD = 8;
    {$EXTERNALSYM SCE_CLW_KEYWORD}
    {$HPPEMIT '#define SCE_CLW_KEYWORD 8'}
    SCE_CLW_COMPILER_DIRECTIVE = 9;
    {$EXTERNALSYM SCE_CLW_COMPILER_DIRECTIVE}
    {$HPPEMIT '#define SCE_CLW_COMPILER_DIRECTIVE 9'}
    SCE_CLW_RUNTIME_EXPRESSIONS = 10;
    {$EXTERNALSYM SCE_CLW_RUNTIME_EXPRESSIONS}
    {$HPPEMIT '#define SCE_CLW_RUNTIME_EXPRESSIONS 10'}
    SCE_CLW_BUILTIN_PROCEDURES_FUNCTION = 11;
    {$EXTERNALSYM SCE_CLW_BUILTIN_PROCEDURES_FUNCTION}
    {$HPPEMIT '#define SCE_CLW_BUILTIN_PROCEDURES_FUNCTION 11'}
    SCE_CLW_STRUCTURE_DATA_TYPE = 12;
    {$EXTERNALSYM SCE_CLW_STRUCTURE_DATA_TYPE}
    {$HPPEMIT '#define SCE_CLW_STRUCTURE_DATA_TYPE 12'}
    SCE_CLW_ATTRIBUTE = 13;
    {$EXTERNALSYM SCE_CLW_ATTRIBUTE}
    {$HPPEMIT '#define SCE_CLW_ATTRIBUTE 13'}
    SCE_CLW_STANDARD_EQUATE = 14;
    {$EXTERNALSYM SCE_CLW_STANDARD_EQUATE}
    {$HPPEMIT '#define SCE_CLW_STANDARD_EQUATE 14'}
    SCE_CLW_ERROR = 15;
    {$EXTERNALSYM SCE_CLW_ERROR}
    {$HPPEMIT '#define SCE_CLW_ERROR 15'}
    SCE_CLW_DEPRECATED = 16;
    {$EXTERNALSYM SCE_CLW_DEPRECATED}
    {$HPPEMIT '#define SCE_CLW_DEPRECATED 16'}
    SCE_LOT_DEFAULT = 0;
    {$EXTERNALSYM SCE_LOT_DEFAULT}
    {$HPPEMIT '#define SCE_LOT_DEFAULT 0'}
    SCE_LOT_HEADER = 1;
    {$EXTERNALSYM SCE_LOT_HEADER}
    {$HPPEMIT '#define SCE_LOT_HEADER 1'}
    SCE_LOT_BREAK = 2;
    {$EXTERNALSYM SCE_LOT_BREAK}
    {$HPPEMIT '#define SCE_LOT_BREAK 2'}
    SCE_LOT_SET = 3;
    {$EXTERNALSYM SCE_LOT_SET}
    {$HPPEMIT '#define SCE_LOT_SET 3'}
    SCE_LOT_PASS = 4;
    {$EXTERNALSYM SCE_LOT_PASS}
    {$HPPEMIT '#define SCE_LOT_PASS 4'}
    SCE_LOT_FAIL = 5;
    {$EXTERNALSYM SCE_LOT_FAIL}
    {$HPPEMIT '#define SCE_LOT_FAIL 5'}
    SCE_LOT_ABORT = 6;
    {$EXTERNALSYM SCE_LOT_ABORT}
    {$HPPEMIT '#define SCE_LOT_ABORT 6'}
    SCE_YAML_DEFAULT = 0;
    {$EXTERNALSYM SCE_YAML_DEFAULT}
    {$HPPEMIT '#define SCE_YAML_DEFAULT 0'}
    SCE_YAML_COMMENT = 1;
    {$EXTERNALSYM SCE_YAML_COMMENT}
    {$HPPEMIT '#define SCE_YAML_COMMENT 1'}
    SCE_YAML_IDENTIFIER = 2;
    {$EXTERNALSYM SCE_YAML_IDENTIFIER}
    {$HPPEMIT '#define SCE_YAML_IDENTIFIER 2'}
    SCE_YAML_KEYWORD = 3;
    {$EXTERNALSYM SCE_YAML_KEYWORD}
    {$HPPEMIT '#define SCE_YAML_KEYWORD 3'}
    SCE_YAML_NUMBER = 4;
    {$EXTERNALSYM SCE_YAML_NUMBER}
    {$HPPEMIT '#define SCE_YAML_NUMBER 4'}
    SCE_YAML_REFERENCE = 5;
    {$EXTERNALSYM SCE_YAML_REFERENCE}
    {$HPPEMIT '#define SCE_YAML_REFERENCE 5'}
    SCE_YAML_DOCUMENT = 6;
    {$EXTERNALSYM SCE_YAML_DOCUMENT}
    {$HPPEMIT '#define SCE_YAML_DOCUMENT 6'}
    SCE_YAML_TEXT = 7;
    {$EXTERNALSYM SCE_YAML_TEXT}
    {$HPPEMIT '#define SCE_YAML_TEXT 7'}
    SCE_YAML_ERROR = 8;
    {$EXTERNALSYM SCE_YAML_ERROR}
    {$HPPEMIT '#define SCE_YAML_ERROR 8'}
    SCE_TEX_DEFAULT = 0;
    {$EXTERNALSYM SCE_TEX_DEFAULT}
    {$HPPEMIT '#define SCE_TEX_DEFAULT 0'}
    SCE_TEX_SPECIAL = 1;
    {$EXTERNALSYM SCE_TEX_SPECIAL}
    {$HPPEMIT '#define SCE_TEX_SPECIAL 1'}
    SCE_TEX_GROUP = 2;
    {$EXTERNALSYM SCE_TEX_GROUP}
    {$HPPEMIT '#define SCE_TEX_GROUP 2'}
    SCE_TEX_SYMBOL = 3;
    {$EXTERNALSYM SCE_TEX_SYMBOL}
    {$HPPEMIT '#define SCE_TEX_SYMBOL 3'}
    SCE_TEX_COMMAND = 4;
    {$EXTERNALSYM SCE_TEX_COMMAND}
    {$HPPEMIT '#define SCE_TEX_COMMAND 4'}
    SCE_TEX_TEXT = 5;
    {$EXTERNALSYM SCE_TEX_TEXT}
    {$HPPEMIT '#define SCE_TEX_TEXT 5'}
    SCE_METAPOST_DEFAULT = 0;
    {$EXTERNALSYM SCE_METAPOST_DEFAULT}
    {$HPPEMIT '#define SCE_METAPOST_DEFAULT 0'}
    SCE_METAPOST_SPECIAL = 1;
    {$EXTERNALSYM SCE_METAPOST_SPECIAL}
    {$HPPEMIT '#define SCE_METAPOST_SPECIAL 1'}
    SCE_METAPOST_GROUP = 2;
    {$EXTERNALSYM SCE_METAPOST_GROUP}
    {$HPPEMIT '#define SCE_METAPOST_GROUP 2'}
    SCE_METAPOST_SYMBOL = 3;
    {$EXTERNALSYM SCE_METAPOST_SYMBOL}
    {$HPPEMIT '#define SCE_METAPOST_SYMBOL 3'}
    SCE_METAPOST_COMMAND = 4;
    {$EXTERNALSYM SCE_METAPOST_COMMAND}
    {$HPPEMIT '#define SCE_METAPOST_COMMAND 4'}
    SCE_METAPOST_TEXT = 5;
    {$EXTERNALSYM SCE_METAPOST_TEXT}
    {$HPPEMIT '#define SCE_METAPOST_TEXT 5'}
    SCE_METAPOST_EXTRA = 6;
    {$EXTERNALSYM SCE_METAPOST_EXTRA}
    {$HPPEMIT '#define SCE_METAPOST_EXTRA 6'}
    SCE_ERLANG_DEFAULT = 0;
    {$EXTERNALSYM SCE_ERLANG_DEFAULT}
    {$HPPEMIT '#define SCE_ERLANG_DEFAULT 0'}
    SCE_ERLANG_COMMENT = 1;
    {$EXTERNALSYM SCE_ERLANG_COMMENT}
    {$HPPEMIT '#define SCE_ERLANG_COMMENT 1'}
    SCE_ERLANG_VARIABLE = 2;
    {$EXTERNALSYM SCE_ERLANG_VARIABLE}
    {$HPPEMIT '#define SCE_ERLANG_VARIABLE 2'}
    SCE_ERLANG_NUMBER = 3;
    {$EXTERNALSYM SCE_ERLANG_NUMBER}
    {$HPPEMIT '#define SCE_ERLANG_NUMBER 3'}
    SCE_ERLANG_KEYWORD = 4;
    {$EXTERNALSYM SCE_ERLANG_KEYWORD}
    {$HPPEMIT '#define SCE_ERLANG_KEYWORD 4'}
    SCE_ERLANG_STRING = 5;
    {$EXTERNALSYM SCE_ERLANG_STRING}
    {$HPPEMIT '#define SCE_ERLANG_STRING 5'}
    SCE_ERLANG_OPERATOR = 6;
    {$EXTERNALSYM SCE_ERLANG_OPERATOR}
    {$HPPEMIT '#define SCE_ERLANG_OPERATOR 6'}
    SCE_ERLANG_ATOM = 7;
    {$EXTERNALSYM SCE_ERLANG_ATOM}
    {$HPPEMIT '#define SCE_ERLANG_ATOM 7'}
    SCE_ERLANG_FUNCTION_NAME = 8;
    {$EXTERNALSYM SCE_ERLANG_FUNCTION_NAME}
    {$HPPEMIT '#define SCE_ERLANG_FUNCTION_NAME 8'}
    SCE_ERLANG_CHARACTER = 9;
    {$EXTERNALSYM SCE_ERLANG_CHARACTER}
    {$HPPEMIT '#define SCE_ERLANG_CHARACTER 9'}
    SCE_ERLANG_MACRO = 10;
    {$EXTERNALSYM SCE_ERLANG_MACRO}
    {$HPPEMIT '#define SCE_ERLANG_MACRO 10'}
    SCE_ERLANG_RECORD = 11;
    {$EXTERNALSYM SCE_ERLANG_RECORD}
    {$HPPEMIT '#define SCE_ERLANG_RECORD 11'}
    SCE_ERLANG_SEPARATOR = 12;
    {$EXTERNALSYM SCE_ERLANG_SEPARATOR}
    {$HPPEMIT '#define SCE_ERLANG_SEPARATOR 12'}
    SCE_ERLANG_NODE_NAME = 13;
    {$EXTERNALSYM SCE_ERLANG_NODE_NAME}
    {$HPPEMIT '#define SCE_ERLANG_NODE_NAME 13'}
    SCE_ERLANG_UNKNOWN = 31;
    {$EXTERNALSYM SCE_ERLANG_UNKNOWN}
    {$HPPEMIT '#define SCE_ERLANG_UNKNOWN 31'}
    SCE_MSSQL_DEFAULT = 0;
    {$EXTERNALSYM SCE_MSSQL_DEFAULT}
    {$HPPEMIT '#define SCE_MSSQL_DEFAULT 0'}
    SCE_MSSQL_COMMENT = 1;
    {$EXTERNALSYM SCE_MSSQL_COMMENT}
    {$HPPEMIT '#define SCE_MSSQL_COMMENT 1'}
    SCE_MSSQL_LINE_COMMENT = 2;
    {$EXTERNALSYM SCE_MSSQL_LINE_COMMENT}
    {$HPPEMIT '#define SCE_MSSQL_LINE_COMMENT 2'}
    SCE_MSSQL_NUMBER = 3;
    {$EXTERNALSYM SCE_MSSQL_NUMBER}
    {$HPPEMIT '#define SCE_MSSQL_NUMBER 3'}
    SCE_MSSQL_STRING = 4;
    {$EXTERNALSYM SCE_MSSQL_STRING}
    {$HPPEMIT '#define SCE_MSSQL_STRING 4'}
    SCE_MSSQL_OPERATOR = 5;
    {$EXTERNALSYM SCE_MSSQL_OPERATOR}
    {$HPPEMIT '#define SCE_MSSQL_OPERATOR 5'}
    SCE_MSSQL_IDENTIFIER = 6;
    {$EXTERNALSYM SCE_MSSQL_IDENTIFIER}
    {$HPPEMIT '#define SCE_MSSQL_IDENTIFIER 6'}
    SCE_MSSQL_VARIABLE = 7;
    {$EXTERNALSYM SCE_MSSQL_VARIABLE}
    {$HPPEMIT '#define SCE_MSSQL_VARIABLE 7'}
    SCE_MSSQL_COLUMN_NAME = 8;
    {$EXTERNALSYM SCE_MSSQL_COLUMN_NAME}
    {$HPPEMIT '#define SCE_MSSQL_COLUMN_NAME 8'}
    SCE_MSSQL_STATEMENT = 9;
    {$EXTERNALSYM SCE_MSSQL_STATEMENT}
    {$HPPEMIT '#define SCE_MSSQL_STATEMENT 9'}
    SCE_MSSQL_DATATYPE = 10;
    {$EXTERNALSYM SCE_MSSQL_DATATYPE}
    {$HPPEMIT '#define SCE_MSSQL_DATATYPE 10'}
    SCE_MSSQL_SYSTABLE = 11;
    {$EXTERNALSYM SCE_MSSQL_SYSTABLE}
    {$HPPEMIT '#define SCE_MSSQL_SYSTABLE 11'}
    SCE_MSSQL_GLOBAL_VARIABLE = 12;
    {$EXTERNALSYM SCE_MSSQL_GLOBAL_VARIABLE}
    {$HPPEMIT '#define SCE_MSSQL_GLOBAL_VARIABLE 12'}
    SCE_MSSQL_FUNCTION = 13;
    {$EXTERNALSYM SCE_MSSQL_FUNCTION}
    {$HPPEMIT '#define SCE_MSSQL_FUNCTION 13'}
    SCE_MSSQL_STORED_PROCEDURE = 14;
    {$EXTERNALSYM SCE_MSSQL_STORED_PROCEDURE}
    {$HPPEMIT '#define SCE_MSSQL_STORED_PROCEDURE 14'}
    SCE_MSSQL_DEFAULT_PREF_DATATYPE = 15;
    {$EXTERNALSYM SCE_MSSQL_DEFAULT_PREF_DATATYPE}
    {$HPPEMIT '#define SCE_MSSQL_DEFAULT_PREF_DATATYPE 15'}
    SCE_MSSQL_COLUMN_NAME_2 = 16;
    {$EXTERNALSYM SCE_MSSQL_COLUMN_NAME_2}
    {$HPPEMIT '#define SCE_MSSQL_COLUMN_NAME_2 16'}
    SCE_V_DEFAULT = 0;
    {$EXTERNALSYM SCE_V_DEFAULT}
    {$HPPEMIT '#define SCE_V_DEFAULT 0'}
    SCE_V_COMMENT = 1;
    {$EXTERNALSYM SCE_V_COMMENT}
    {$HPPEMIT '#define SCE_V_COMMENT 1'}
    SCE_V_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_V_COMMENTLINE}
    {$HPPEMIT '#define SCE_V_COMMENTLINE 2'}
    SCE_V_COMMENTLINEBANG = 3;
    {$EXTERNALSYM SCE_V_COMMENTLINEBANG}
    {$HPPEMIT '#define SCE_V_COMMENTLINEBANG 3'}
    SCE_V_NUMBER = 4;
    {$EXTERNALSYM SCE_V_NUMBER}
    {$HPPEMIT '#define SCE_V_NUMBER 4'}
    SCE_V_WORD = 5;
    {$EXTERNALSYM SCE_V_WORD}
    {$HPPEMIT '#define SCE_V_WORD 5'}
    SCE_V_STRING = 6;
    {$EXTERNALSYM SCE_V_STRING}
    {$HPPEMIT '#define SCE_V_STRING 6'}
    SCE_V_WORD2 = 7;
    {$EXTERNALSYM SCE_V_WORD2}
    {$HPPEMIT '#define SCE_V_WORD2 7'}
    SCE_V_WORD3 = 8;
    {$EXTERNALSYM SCE_V_WORD3}
    {$HPPEMIT '#define SCE_V_WORD3 8'}
    SCE_V_PREPROCESSOR = 9;
    {$EXTERNALSYM SCE_V_PREPROCESSOR}
    {$HPPEMIT '#define SCE_V_PREPROCESSOR 9'}
    SCE_V_OPERATOR = 10;
    {$EXTERNALSYM SCE_V_OPERATOR}
    {$HPPEMIT '#define SCE_V_OPERATOR 10'}
    SCE_V_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_V_IDENTIFIER}
    {$HPPEMIT '#define SCE_V_IDENTIFIER 11'}
    SCE_V_STRINGEOL = 12;
    {$EXTERNALSYM SCE_V_STRINGEOL}
    {$HPPEMIT '#define SCE_V_STRINGEOL 12'}
    SCE_V_USER = 19;
    {$EXTERNALSYM SCE_V_USER}
    {$HPPEMIT '#define SCE_V_USER 19'}
    SCE_KIX_DEFAULT = 0;
    {$EXTERNALSYM SCE_KIX_DEFAULT}
    {$HPPEMIT '#define SCE_KIX_DEFAULT 0'}
    SCE_KIX_COMMENT = 1;
    {$EXTERNALSYM SCE_KIX_COMMENT}
    {$HPPEMIT '#define SCE_KIX_COMMENT 1'}
    SCE_KIX_STRING1 = 2;
    {$EXTERNALSYM SCE_KIX_STRING1}
    {$HPPEMIT '#define SCE_KIX_STRING1 2'}
    SCE_KIX_STRING2 = 3;
    {$EXTERNALSYM SCE_KIX_STRING2}
    {$HPPEMIT '#define SCE_KIX_STRING2 3'}
    SCE_KIX_NUMBER = 4;
    {$EXTERNALSYM SCE_KIX_NUMBER}
    {$HPPEMIT '#define SCE_KIX_NUMBER 4'}
    SCE_KIX_VAR = 5;
    {$EXTERNALSYM SCE_KIX_VAR}
    {$HPPEMIT '#define SCE_KIX_VAR 5'}
    SCE_KIX_MACRO = 6;
    {$EXTERNALSYM SCE_KIX_MACRO}
    {$HPPEMIT '#define SCE_KIX_MACRO 6'}
    SCE_KIX_KEYWORD = 7;
    {$EXTERNALSYM SCE_KIX_KEYWORD}
    {$HPPEMIT '#define SCE_KIX_KEYWORD 7'}
    SCE_KIX_FUNCTIONS = 8;
    {$EXTERNALSYM SCE_KIX_FUNCTIONS}
    {$HPPEMIT '#define SCE_KIX_FUNCTIONS 8'}
    SCE_KIX_OPERATOR = 9;
    {$EXTERNALSYM SCE_KIX_OPERATOR}
    {$HPPEMIT '#define SCE_KIX_OPERATOR 9'}
    SCE_KIX_IDENTIFIER = 31;
    {$EXTERNALSYM SCE_KIX_IDENTIFIER}
    {$HPPEMIT '#define SCE_KIX_IDENTIFIER 31'}
    SCE_GC_DEFAULT = 0;
    {$EXTERNALSYM SCE_GC_DEFAULT}
    {$HPPEMIT '#define SCE_GC_DEFAULT 0'}
    SCE_GC_COMMENTLINE = 1;
    {$EXTERNALSYM SCE_GC_COMMENTLINE}
    {$HPPEMIT '#define SCE_GC_COMMENTLINE 1'}
    SCE_GC_COMMENTBLOCK = 2;
    {$EXTERNALSYM SCE_GC_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_GC_COMMENTBLOCK 2'}
    SCE_GC_GLOBAL = 3;
    {$EXTERNALSYM SCE_GC_GLOBAL}
    {$HPPEMIT '#define SCE_GC_GLOBAL 3'}
    SCE_GC_EVENT = 4;
    {$EXTERNALSYM SCE_GC_EVENT}
    {$HPPEMIT '#define SCE_GC_EVENT 4'}
    SCE_GC_ATTRIBUTE = 5;
    {$EXTERNALSYM SCE_GC_ATTRIBUTE}
    {$HPPEMIT '#define SCE_GC_ATTRIBUTE 5'}
    SCE_GC_CONTROL = 6;
    {$EXTERNALSYM SCE_GC_CONTROL}
    {$HPPEMIT '#define SCE_GC_CONTROL 6'}
    SCE_GC_COMMAND = 7;
    {$EXTERNALSYM SCE_GC_COMMAND}
    {$HPPEMIT '#define SCE_GC_COMMAND 7'}
    SCE_GC_STRING = 8;
    {$EXTERNALSYM SCE_GC_STRING}
    {$HPPEMIT '#define SCE_GC_STRING 8'}
    SCE_GC_OPERATOR = 9;
    {$EXTERNALSYM SCE_GC_OPERATOR}
    {$HPPEMIT '#define SCE_GC_OPERATOR 9'}
    SCE_SN_DEFAULT = 0;
    {$EXTERNALSYM SCE_SN_DEFAULT}
    {$HPPEMIT '#define SCE_SN_DEFAULT 0'}
    SCE_SN_CODE = 1;
    {$EXTERNALSYM SCE_SN_CODE}
    {$HPPEMIT '#define SCE_SN_CODE 1'}
    SCE_SN_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_SN_COMMENTLINE}
    {$HPPEMIT '#define SCE_SN_COMMENTLINE 2'}
    SCE_SN_COMMENTLINEBANG = 3;
    {$EXTERNALSYM SCE_SN_COMMENTLINEBANG}
    {$HPPEMIT '#define SCE_SN_COMMENTLINEBANG 3'}
    SCE_SN_NUMBER = 4;
    {$EXTERNALSYM SCE_SN_NUMBER}
    {$HPPEMIT '#define SCE_SN_NUMBER 4'}
    SCE_SN_WORD = 5;
    {$EXTERNALSYM SCE_SN_WORD}
    {$HPPEMIT '#define SCE_SN_WORD 5'}
    SCE_SN_STRING = 6;
    {$EXTERNALSYM SCE_SN_STRING}
    {$HPPEMIT '#define SCE_SN_STRING 6'}
    SCE_SN_WORD2 = 7;
    {$EXTERNALSYM SCE_SN_WORD2}
    {$HPPEMIT '#define SCE_SN_WORD2 7'}
    SCE_SN_WORD3 = 8;
    {$EXTERNALSYM SCE_SN_WORD3}
    {$HPPEMIT '#define SCE_SN_WORD3 8'}
    SCE_SN_PREPROCESSOR = 9;
    {$EXTERNALSYM SCE_SN_PREPROCESSOR}
    {$HPPEMIT '#define SCE_SN_PREPROCESSOR 9'}
    SCE_SN_OPERATOR = 10;
    {$EXTERNALSYM SCE_SN_OPERATOR}
    {$HPPEMIT '#define SCE_SN_OPERATOR 10'}
    SCE_SN_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_SN_IDENTIFIER}
    {$HPPEMIT '#define SCE_SN_IDENTIFIER 11'}
    SCE_SN_STRINGEOL = 12;
    {$EXTERNALSYM SCE_SN_STRINGEOL}
    {$HPPEMIT '#define SCE_SN_STRINGEOL 12'}
    SCE_SN_REGEXTAG = 13;
    {$EXTERNALSYM SCE_SN_REGEXTAG}
    {$HPPEMIT '#define SCE_SN_REGEXTAG 13'}
    SCE_SN_SIGNAL = 14;
    {$EXTERNALSYM SCE_SN_SIGNAL}
    {$HPPEMIT '#define SCE_SN_SIGNAL 14'}
    SCE_SN_USER = 19;
    {$EXTERNALSYM SCE_SN_USER}
    {$HPPEMIT '#define SCE_SN_USER 19'}
    SCE_AU3_DEFAULT = 0;
    {$EXTERNALSYM SCE_AU3_DEFAULT}
    {$HPPEMIT '#define SCE_AU3_DEFAULT 0'}
    SCE_AU3_COMMENT = 1;
    {$EXTERNALSYM SCE_AU3_COMMENT}
    {$HPPEMIT '#define SCE_AU3_COMMENT 1'}
    SCE_AU3_COMMENTBLOCK = 2;
    {$EXTERNALSYM SCE_AU3_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_AU3_COMMENTBLOCK 2'}
    SCE_AU3_NUMBER = 3;
    {$EXTERNALSYM SCE_AU3_NUMBER}
    {$HPPEMIT '#define SCE_AU3_NUMBER 3'}
    SCE_AU3_FUNCTION = 4;
    {$EXTERNALSYM SCE_AU3_FUNCTION}
    {$HPPEMIT '#define SCE_AU3_FUNCTION 4'}
    SCE_AU3_KEYWORD = 5;
    {$EXTERNALSYM SCE_AU3_KEYWORD}
    {$HPPEMIT '#define SCE_AU3_KEYWORD 5'}
    SCE_AU3_MACRO = 6;
    {$EXTERNALSYM SCE_AU3_MACRO}
    {$HPPEMIT '#define SCE_AU3_MACRO 6'}
    SCE_AU3_STRING = 7;
    {$EXTERNALSYM SCE_AU3_STRING}
    {$HPPEMIT '#define SCE_AU3_STRING 7'}
    SCE_AU3_OPERATOR = 8;
    {$EXTERNALSYM SCE_AU3_OPERATOR}
    {$HPPEMIT '#define SCE_AU3_OPERATOR 8'}
    SCE_AU3_VARIABLE = 9;
    {$EXTERNALSYM SCE_AU3_VARIABLE}
    {$HPPEMIT '#define SCE_AU3_VARIABLE 9'}
    SCE_AU3_SENT = 10;
    {$EXTERNALSYM SCE_AU3_SENT}
    {$HPPEMIT '#define SCE_AU3_SENT 10'}
    SCE_AU3_PREPROCESSOR = 11;
    {$EXTERNALSYM SCE_AU3_PREPROCESSOR}
    {$HPPEMIT '#define SCE_AU3_PREPROCESSOR 11'}
    SCE_AU3_SPECIAL = 12;
    {$EXTERNALSYM SCE_AU3_SPECIAL}
    {$HPPEMIT '#define SCE_AU3_SPECIAL 12'}
    SCE_AU3_EXPAND = 13;
    {$EXTERNALSYM SCE_AU3_EXPAND}
    {$HPPEMIT '#define SCE_AU3_EXPAND 13'}
    SCE_AU3_COMOBJ = 14;
    {$EXTERNALSYM SCE_AU3_COMOBJ}
    {$HPPEMIT '#define SCE_AU3_COMOBJ 14'}
    SCE_AU3_UDF = 15;
    {$EXTERNALSYM SCE_AU3_UDF}
    {$HPPEMIT '#define SCE_AU3_UDF 15'}
    SCE_APDL_DEFAULT = 0;
    {$EXTERNALSYM SCE_APDL_DEFAULT}
    {$HPPEMIT '#define SCE_APDL_DEFAULT 0'}
    SCE_APDL_COMMENT = 1;
    {$EXTERNALSYM SCE_APDL_COMMENT}
    {$HPPEMIT '#define SCE_APDL_COMMENT 1'}
    SCE_APDL_COMMENTBLOCK = 2;
    {$EXTERNALSYM SCE_APDL_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_APDL_COMMENTBLOCK 2'}
    SCE_APDL_NUMBER = 3;
    {$EXTERNALSYM SCE_APDL_NUMBER}
    {$HPPEMIT '#define SCE_APDL_NUMBER 3'}
    SCE_APDL_STRING = 4;
    {$EXTERNALSYM SCE_APDL_STRING}
    {$HPPEMIT '#define SCE_APDL_STRING 4'}
    SCE_APDL_OPERATOR = 5;
    {$EXTERNALSYM SCE_APDL_OPERATOR}
    {$HPPEMIT '#define SCE_APDL_OPERATOR 5'}
    SCE_APDL_WORD = 6;
    {$EXTERNALSYM SCE_APDL_WORD}
    {$HPPEMIT '#define SCE_APDL_WORD 6'}
    SCE_APDL_PROCESSOR = 7;
    {$EXTERNALSYM SCE_APDL_PROCESSOR}
    {$HPPEMIT '#define SCE_APDL_PROCESSOR 7'}
    SCE_APDL_COMMAND = 8;
    {$EXTERNALSYM SCE_APDL_COMMAND}
    {$HPPEMIT '#define SCE_APDL_COMMAND 8'}
    SCE_APDL_SLASHCOMMAND = 9;
    {$EXTERNALSYM SCE_APDL_SLASHCOMMAND}
    {$HPPEMIT '#define SCE_APDL_SLASHCOMMAND 9'}
    SCE_APDL_STARCOMMAND = 10;
    {$EXTERNALSYM SCE_APDL_STARCOMMAND}
    {$HPPEMIT '#define SCE_APDL_STARCOMMAND 10'}
    SCE_APDL_ARGUMENT = 11;
    {$EXTERNALSYM SCE_APDL_ARGUMENT}
    {$HPPEMIT '#define SCE_APDL_ARGUMENT 11'}
    SCE_APDL_FUNCTION = 12;
    {$EXTERNALSYM SCE_APDL_FUNCTION}
    {$HPPEMIT '#define SCE_APDL_FUNCTION 12'}
    SCE_SH_DEFAULT = 0;
    {$EXTERNALSYM SCE_SH_DEFAULT}
    {$HPPEMIT '#define SCE_SH_DEFAULT 0'}
    SCE_SH_ERROR = 1;
    {$EXTERNALSYM SCE_SH_ERROR}
    {$HPPEMIT '#define SCE_SH_ERROR 1'}
    SCE_SH_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_SH_COMMENTLINE}
    {$HPPEMIT '#define SCE_SH_COMMENTLINE 2'}
    SCE_SH_NUMBER = 3;
    {$EXTERNALSYM SCE_SH_NUMBER}
    {$HPPEMIT '#define SCE_SH_NUMBER 3'}
    SCE_SH_WORD = 4;
    {$EXTERNALSYM SCE_SH_WORD}
    {$HPPEMIT '#define SCE_SH_WORD 4'}
    SCE_SH_STRING = 5;
    {$EXTERNALSYM SCE_SH_STRING}
    {$HPPEMIT '#define SCE_SH_STRING 5'}
    SCE_SH_CHARACTER = 6;
    {$EXTERNALSYM SCE_SH_CHARACTER}
    {$HPPEMIT '#define SCE_SH_CHARACTER 6'}
    SCE_SH_OPERATOR = 7;
    {$EXTERNALSYM SCE_SH_OPERATOR}
    {$HPPEMIT '#define SCE_SH_OPERATOR 7'}
    SCE_SH_IDENTIFIER = 8;
    {$EXTERNALSYM SCE_SH_IDENTIFIER}
    {$HPPEMIT '#define SCE_SH_IDENTIFIER 8'}
    SCE_SH_SCALAR = 9;
    {$EXTERNALSYM SCE_SH_SCALAR}
    {$HPPEMIT '#define SCE_SH_SCALAR 9'}
    SCE_SH_PARAM = 10;
    {$EXTERNALSYM SCE_SH_PARAM}
    {$HPPEMIT '#define SCE_SH_PARAM 10'}
    SCE_SH_BACKTICKS = 11;
    {$EXTERNALSYM SCE_SH_BACKTICKS}
    {$HPPEMIT '#define SCE_SH_BACKTICKS 11'}
    SCE_SH_HERE_DELIM = 12;
    {$EXTERNALSYM SCE_SH_HERE_DELIM}
    {$HPPEMIT '#define SCE_SH_HERE_DELIM 12'}
    SCE_SH_HERE_Q = 13;
    {$EXTERNALSYM SCE_SH_HERE_Q}
    {$HPPEMIT '#define SCE_SH_HERE_Q 13'}
    SCE_ASN1_DEFAULT = 0;
    {$EXTERNALSYM SCE_ASN1_DEFAULT}
    {$HPPEMIT '#define SCE_ASN1_DEFAULT 0'}
    SCE_ASN1_COMMENT = 1;
    {$EXTERNALSYM SCE_ASN1_COMMENT}
    {$HPPEMIT '#define SCE_ASN1_COMMENT 1'}
    SCE_ASN1_IDENTIFIER = 2;
    {$EXTERNALSYM SCE_ASN1_IDENTIFIER}
    {$HPPEMIT '#define SCE_ASN1_IDENTIFIER 2'}
    SCE_ASN1_STRING = 3;
    {$EXTERNALSYM SCE_ASN1_STRING}
    {$HPPEMIT '#define SCE_ASN1_STRING 3'}
    SCE_ASN1_OID = 4;
    {$EXTERNALSYM SCE_ASN1_OID}
    {$HPPEMIT '#define SCE_ASN1_OID 4'}
    SCE_ASN1_SCALAR = 5;
    {$EXTERNALSYM SCE_ASN1_SCALAR}
    {$HPPEMIT '#define SCE_ASN1_SCALAR 5'}
    SCE_ASN1_KEYWORD = 6;
    {$EXTERNALSYM SCE_ASN1_KEYWORD}
    {$HPPEMIT '#define SCE_ASN1_KEYWORD 6'}
    SCE_ASN1_ATTRIBUTE = 7;
    {$EXTERNALSYM SCE_ASN1_ATTRIBUTE}
    {$HPPEMIT '#define SCE_ASN1_ATTRIBUTE 7'}
    SCE_ASN1_DESCRIPTOR = 8;
    {$EXTERNALSYM SCE_ASN1_DESCRIPTOR}
    {$HPPEMIT '#define SCE_ASN1_DESCRIPTOR 8'}
    SCE_ASN1_TYPE = 9;
    {$EXTERNALSYM SCE_ASN1_TYPE}
    {$HPPEMIT '#define SCE_ASN1_TYPE 9'}
    SCE_ASN1_OPERATOR = 10;
    {$EXTERNALSYM SCE_ASN1_OPERATOR}
    {$HPPEMIT '#define SCE_ASN1_OPERATOR 10'}
    SCE_VHDL_DEFAULT = 0;
    {$EXTERNALSYM SCE_VHDL_DEFAULT}
    {$HPPEMIT '#define SCE_VHDL_DEFAULT 0'}
    SCE_VHDL_COMMENT = 1;
    {$EXTERNALSYM SCE_VHDL_COMMENT}
    {$HPPEMIT '#define SCE_VHDL_COMMENT 1'}
    SCE_VHDL_COMMENTLINEBANG = 2;
    {$EXTERNALSYM SCE_VHDL_COMMENTLINEBANG}
    {$HPPEMIT '#define SCE_VHDL_COMMENTLINEBANG 2'}
    SCE_VHDL_NUMBER = 3;
    {$EXTERNALSYM SCE_VHDL_NUMBER}
    {$HPPEMIT '#define SCE_VHDL_NUMBER 3'}
    SCE_VHDL_STRING = 4;
    {$EXTERNALSYM SCE_VHDL_STRING}
    {$HPPEMIT '#define SCE_VHDL_STRING 4'}
    SCE_VHDL_OPERATOR = 5;
    {$EXTERNALSYM SCE_VHDL_OPERATOR}
    {$HPPEMIT '#define SCE_VHDL_OPERATOR 5'}
    SCE_VHDL_IDENTIFIER = 6;
    {$EXTERNALSYM SCE_VHDL_IDENTIFIER}
    {$HPPEMIT '#define SCE_VHDL_IDENTIFIER 6'}
    SCE_VHDL_STRINGEOL = 7;
    {$EXTERNALSYM SCE_VHDL_STRINGEOL}
    {$HPPEMIT '#define SCE_VHDL_STRINGEOL 7'}
    SCE_VHDL_KEYWORD = 8;
    {$EXTERNALSYM SCE_VHDL_KEYWORD}
    {$HPPEMIT '#define SCE_VHDL_KEYWORD 8'}
    SCE_VHDL_STDOPERATOR = 9;
    {$EXTERNALSYM SCE_VHDL_STDOPERATOR}
    {$HPPEMIT '#define SCE_VHDL_STDOPERATOR 9'}
    SCE_VHDL_ATTRIBUTE = 10;
    {$EXTERNALSYM SCE_VHDL_ATTRIBUTE}
    {$HPPEMIT '#define SCE_VHDL_ATTRIBUTE 10'}
    SCE_VHDL_STDFUNCTION = 11;
    {$EXTERNALSYM SCE_VHDL_STDFUNCTION}
    {$HPPEMIT '#define SCE_VHDL_STDFUNCTION 11'}
    SCE_VHDL_STDPACKAGE = 12;
    {$EXTERNALSYM SCE_VHDL_STDPACKAGE}
    {$HPPEMIT '#define SCE_VHDL_STDPACKAGE 12'}
    SCE_VHDL_STDTYPE = 13;
    {$EXTERNALSYM SCE_VHDL_STDTYPE}
    {$HPPEMIT '#define SCE_VHDL_STDTYPE 13'}
    SCE_VHDL_USERWORD = 14;
    {$EXTERNALSYM SCE_VHDL_USERWORD}
    {$HPPEMIT '#define SCE_VHDL_USERWORD 14'}
    SCE_CAML_DEFAULT = 0;
    {$EXTERNALSYM SCE_CAML_DEFAULT}
    {$HPPEMIT '#define SCE_CAML_DEFAULT 0'}
    SCE_CAML_IDENTIFIER = 1;
    {$EXTERNALSYM SCE_CAML_IDENTIFIER}
    {$HPPEMIT '#define SCE_CAML_IDENTIFIER 1'}
    SCE_CAML_TAGNAME = 2;
    {$EXTERNALSYM SCE_CAML_TAGNAME}
    {$HPPEMIT '#define SCE_CAML_TAGNAME 2'}
    SCE_CAML_KEYWORD = 3;
    {$EXTERNALSYM SCE_CAML_KEYWORD}
    {$HPPEMIT '#define SCE_CAML_KEYWORD 3'}
    SCE_CAML_KEYWORD2 = 4;
    {$EXTERNALSYM SCE_CAML_KEYWORD2}
    {$HPPEMIT '#define SCE_CAML_KEYWORD2 4'}
    SCE_CAML_KEYWORD3 = 5;
    {$EXTERNALSYM SCE_CAML_KEYWORD3}
    {$HPPEMIT '#define SCE_CAML_KEYWORD3 5'}
    SCE_CAML_LINENUM = 6;
    {$EXTERNALSYM SCE_CAML_LINENUM}
    {$HPPEMIT '#define SCE_CAML_LINENUM 6'}
    SCE_CAML_OPERATOR = 7;
    {$EXTERNALSYM SCE_CAML_OPERATOR}
    {$HPPEMIT '#define SCE_CAML_OPERATOR 7'}
    SCE_CAML_NUMBER = 8;
    {$EXTERNALSYM SCE_CAML_NUMBER}
    {$HPPEMIT '#define SCE_CAML_NUMBER 8'}
    SCE_CAML_CHAR = 9;
    {$EXTERNALSYM SCE_CAML_CHAR}
    {$HPPEMIT '#define SCE_CAML_CHAR 9'}
    SCE_CAML_STRING = 11;
    {$EXTERNALSYM SCE_CAML_STRING}
    {$HPPEMIT '#define SCE_CAML_STRING 11'}
    SCE_CAML_COMMENT = 12;
    {$EXTERNALSYM SCE_CAML_COMMENT}
    {$HPPEMIT '#define SCE_CAML_COMMENT 12'}
    SCE_CAML_COMMENT1 = 13;
    {$EXTERNALSYM SCE_CAML_COMMENT1}
    {$HPPEMIT '#define SCE_CAML_COMMENT1 13'}
    SCE_CAML_COMMENT2 = 14;
    {$EXTERNALSYM SCE_CAML_COMMENT2}
    {$HPPEMIT '#define SCE_CAML_COMMENT2 14'}
    SCE_CAML_COMMENT3 = 15;
    {$EXTERNALSYM SCE_CAML_COMMENT3}
    {$HPPEMIT '#define SCE_CAML_COMMENT3 15'}
    SCE_HA_DEFAULT = 0;
    {$EXTERNALSYM SCE_HA_DEFAULT}
    {$HPPEMIT '#define SCE_HA_DEFAULT 0'}
    SCE_HA_IDENTIFIER = 1;
    {$EXTERNALSYM SCE_HA_IDENTIFIER}
    {$HPPEMIT '#define SCE_HA_IDENTIFIER 1'}
    SCE_HA_KEYWORD = 2;
    {$EXTERNALSYM SCE_HA_KEYWORD}
    {$HPPEMIT '#define SCE_HA_KEYWORD 2'}
    SCE_HA_NUMBER = 3;
    {$EXTERNALSYM SCE_HA_NUMBER}
    {$HPPEMIT '#define SCE_HA_NUMBER 3'}
    SCE_HA_STRING = 4;
    {$EXTERNALSYM SCE_HA_STRING}
    {$HPPEMIT '#define SCE_HA_STRING 4'}
    SCE_HA_CHARACTER = 5;
    {$EXTERNALSYM SCE_HA_CHARACTER}
    {$HPPEMIT '#define SCE_HA_CHARACTER 5'}
    SCE_HA_CLASS = 6;
    {$EXTERNALSYM SCE_HA_CLASS}
    {$HPPEMIT '#define SCE_HA_CLASS 6'}
    SCE_HA_MODULE = 7;
    {$EXTERNALSYM SCE_HA_MODULE}
    {$HPPEMIT '#define SCE_HA_MODULE 7'}
    SCE_HA_CAPITAL = 8;
    {$EXTERNALSYM SCE_HA_CAPITAL}
    {$HPPEMIT '#define SCE_HA_CAPITAL 8'}
    SCE_HA_DATA = 9;
    {$EXTERNALSYM SCE_HA_DATA}
    {$HPPEMIT '#define SCE_HA_DATA 9'}
    SCE_HA_IMPORT = 10;
    {$EXTERNALSYM SCE_HA_IMPORT}
    {$HPPEMIT '#define SCE_HA_IMPORT 10'}
    SCE_HA_OPERATOR = 11;
    {$EXTERNALSYM SCE_HA_OPERATOR}
    {$HPPEMIT '#define SCE_HA_OPERATOR 11'}
    SCE_HA_INSTANCE = 12;
    {$EXTERNALSYM SCE_HA_INSTANCE}
    {$HPPEMIT '#define SCE_HA_INSTANCE 12'}
    SCE_HA_COMMENTLINE = 13;
    {$EXTERNALSYM SCE_HA_COMMENTLINE}
    {$HPPEMIT '#define SCE_HA_COMMENTLINE 13'}
    SCE_HA_COMMENTBLOCK = 14;
    {$EXTERNALSYM SCE_HA_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_HA_COMMENTBLOCK 14'}
    SCE_HA_COMMENTBLOCK2 = 15;
    {$EXTERNALSYM SCE_HA_COMMENTBLOCK2}
    {$HPPEMIT '#define SCE_HA_COMMENTBLOCK2 15'}
    SCE_HA_COMMENTBLOCK3 = 16;
    {$EXTERNALSYM SCE_HA_COMMENTBLOCK3}
    {$HPPEMIT '#define SCE_HA_COMMENTBLOCK3 16'}
    SCE_T3_DEFAULT = 0;
    {$EXTERNALSYM SCE_T3_DEFAULT}
    {$HPPEMIT '#define SCE_T3_DEFAULT 0'}
    SCE_T3_X_DEFAULT = 1;
    {$EXTERNALSYM SCE_T3_X_DEFAULT}
    {$HPPEMIT '#define SCE_T3_X_DEFAULT 1'}
    SCE_T3_PREPROCESSOR = 2;
    {$EXTERNALSYM SCE_T3_PREPROCESSOR}
    {$HPPEMIT '#define SCE_T3_PREPROCESSOR 2'}
    SCE_T3_BLOCK_COMMENT = 3;
    {$EXTERNALSYM SCE_T3_BLOCK_COMMENT}
    {$HPPEMIT '#define SCE_T3_BLOCK_COMMENT 3'}
    SCE_T3_LINE_COMMENT = 4;
    {$EXTERNALSYM SCE_T3_LINE_COMMENT}
    {$HPPEMIT '#define SCE_T3_LINE_COMMENT 4'}
    SCE_T3_OPERATOR = 5;
    {$EXTERNALSYM SCE_T3_OPERATOR}
    {$HPPEMIT '#define SCE_T3_OPERATOR 5'}
    SCE_T3_KEYWORD = 6;
    {$EXTERNALSYM SCE_T3_KEYWORD}
    {$HPPEMIT '#define SCE_T3_KEYWORD 6'}
    SCE_T3_NUMBER = 7;
    {$EXTERNALSYM SCE_T3_NUMBER}
    {$HPPEMIT '#define SCE_T3_NUMBER 7'}
    SCE_T3_IDENTIFIER = 8;
    {$EXTERNALSYM SCE_T3_IDENTIFIER}
    {$HPPEMIT '#define SCE_T3_IDENTIFIER 8'}
    SCE_T3_S_STRING = 9;
    {$EXTERNALSYM SCE_T3_S_STRING}
    {$HPPEMIT '#define SCE_T3_S_STRING 9'}
    SCE_T3_D_STRING = 10;
    {$EXTERNALSYM SCE_T3_D_STRING}
    {$HPPEMIT '#define SCE_T3_D_STRING 10'}
    SCE_T3_X_STRING = 11;
    {$EXTERNALSYM SCE_T3_X_STRING}
    {$HPPEMIT '#define SCE_T3_X_STRING 11'}
    SCE_T3_LIB_DIRECTIVE = 12;
    {$EXTERNALSYM SCE_T3_LIB_DIRECTIVE}
    {$HPPEMIT '#define SCE_T3_LIB_DIRECTIVE 12'}
    SCE_T3_MSG_PARAM = 13;
    {$EXTERNALSYM SCE_T3_MSG_PARAM}
    {$HPPEMIT '#define SCE_T3_MSG_PARAM 13'}
    SCE_T3_HTML_TAG = 14;
    {$EXTERNALSYM SCE_T3_HTML_TAG}
    {$HPPEMIT '#define SCE_T3_HTML_TAG 14'}
    SCE_T3_HTML_DEFAULT = 15;
    {$EXTERNALSYM SCE_T3_HTML_DEFAULT}
    {$HPPEMIT '#define SCE_T3_HTML_DEFAULT 15'}
    SCE_T3_HTML_STRING = 16;
    {$EXTERNALSYM SCE_T3_HTML_STRING}
    {$HPPEMIT '#define SCE_T3_HTML_STRING 16'}
    SCE_T3_USER1 = 17;
    {$EXTERNALSYM SCE_T3_USER1}
    {$HPPEMIT '#define SCE_T3_USER1 17'}
    SCE_T3_USER2 = 18;
    {$EXTERNALSYM SCE_T3_USER2}
    {$HPPEMIT '#define SCE_T3_USER2 18'}
    SCE_T3_USER3 = 19;
    {$EXTERNALSYM SCE_T3_USER3}
    {$HPPEMIT '#define SCE_T3_USER3 19'}
    SCE_REBOL_DEFAULT = 0;
    {$EXTERNALSYM SCE_REBOL_DEFAULT}
    {$HPPEMIT '#define SCE_REBOL_DEFAULT 0'}
    SCE_REBOL_COMMENTLINE = 1;
    {$EXTERNALSYM SCE_REBOL_COMMENTLINE}
    {$HPPEMIT '#define SCE_REBOL_COMMENTLINE 1'}
    SCE_REBOL_COMMENTBLOCK = 2;
    {$EXTERNALSYM SCE_REBOL_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_REBOL_COMMENTBLOCK 2'}
    SCE_REBOL_PREFACE = 3;
    {$EXTERNALSYM SCE_REBOL_PREFACE}
    {$HPPEMIT '#define SCE_REBOL_PREFACE 3'}
    SCE_REBOL_OPERATOR = 4;
    {$EXTERNALSYM SCE_REBOL_OPERATOR}
    {$HPPEMIT '#define SCE_REBOL_OPERATOR 4'}
    SCE_REBOL_CHARACTER = 5;
    {$EXTERNALSYM SCE_REBOL_CHARACTER}
    {$HPPEMIT '#define SCE_REBOL_CHARACTER 5'}
    SCE_REBOL_QUOTEDSTRING = 6;
    {$EXTERNALSYM SCE_REBOL_QUOTEDSTRING}
    {$HPPEMIT '#define SCE_REBOL_QUOTEDSTRING 6'}
    SCE_REBOL_BRACEDSTRING = 7;
    {$EXTERNALSYM SCE_REBOL_BRACEDSTRING}
    {$HPPEMIT '#define SCE_REBOL_BRACEDSTRING 7'}
    SCE_REBOL_NUMBER = 8;
    {$EXTERNALSYM SCE_REBOL_NUMBER}
    {$HPPEMIT '#define SCE_REBOL_NUMBER 8'}
    SCE_REBOL_PAIR = 9;
    {$EXTERNALSYM SCE_REBOL_PAIR}
    {$HPPEMIT '#define SCE_REBOL_PAIR 9'}
    SCE_REBOL_TUPLE = 10;
    {$EXTERNALSYM SCE_REBOL_TUPLE}
    {$HPPEMIT '#define SCE_REBOL_TUPLE 10'}
    SCE_REBOL_BINARY = 11;
    {$EXTERNALSYM SCE_REBOL_BINARY}
    {$HPPEMIT '#define SCE_REBOL_BINARY 11'}
    SCE_REBOL_MONEY = 12;
    {$EXTERNALSYM SCE_REBOL_MONEY}
    {$HPPEMIT '#define SCE_REBOL_MONEY 12'}
    SCE_REBOL_ISSUE = 13;
    {$EXTERNALSYM SCE_REBOL_ISSUE}
    {$HPPEMIT '#define SCE_REBOL_ISSUE 13'}
    SCE_REBOL_TAG = 14;
    {$EXTERNALSYM SCE_REBOL_TAG}
    {$HPPEMIT '#define SCE_REBOL_TAG 14'}
    SCE_REBOL_FILE = 15;
    {$EXTERNALSYM SCE_REBOL_FILE}
    {$HPPEMIT '#define SCE_REBOL_FILE 15'}
    SCE_REBOL_EMAIL = 16;
    {$EXTERNALSYM SCE_REBOL_EMAIL}
    {$HPPEMIT '#define SCE_REBOL_EMAIL 16'}
    SCE_REBOL_URL = 17;
    {$EXTERNALSYM SCE_REBOL_URL}
    {$HPPEMIT '#define SCE_REBOL_URL 17'}
    SCE_REBOL_DATE = 18;
    {$EXTERNALSYM SCE_REBOL_DATE}
    {$HPPEMIT '#define SCE_REBOL_DATE 18'}
    SCE_REBOL_TIME = 19;
    {$EXTERNALSYM SCE_REBOL_TIME}
    {$HPPEMIT '#define SCE_REBOL_TIME 19'}
    SCE_REBOL_IDENTIFIER = 20;
    {$EXTERNALSYM SCE_REBOL_IDENTIFIER}
    {$HPPEMIT '#define SCE_REBOL_IDENTIFIER 20'}
    SCE_REBOL_WORD = 21;
    {$EXTERNALSYM SCE_REBOL_WORD}
    {$HPPEMIT '#define SCE_REBOL_WORD 21'}
    SCE_REBOL_WORD2 = 22;
    {$EXTERNALSYM SCE_REBOL_WORD2}
    {$HPPEMIT '#define SCE_REBOL_WORD2 22'}
    SCE_REBOL_WORD3 = 23;
    {$EXTERNALSYM SCE_REBOL_WORD3}
    {$HPPEMIT '#define SCE_REBOL_WORD3 23'}
    SCE_REBOL_WORD4 = 24;
    {$EXTERNALSYM SCE_REBOL_WORD4}
    {$HPPEMIT '#define SCE_REBOL_WORD4 24'}
    SCE_REBOL_WORD5 = 25;
    {$EXTERNALSYM SCE_REBOL_WORD5}
    {$HPPEMIT '#define SCE_REBOL_WORD5 25'}
    SCE_REBOL_WORD6 = 26;
    {$EXTERNALSYM SCE_REBOL_WORD6}
    {$HPPEMIT '#define SCE_REBOL_WORD6 26'}
    SCE_REBOL_WORD7 = 27;
    {$EXTERNALSYM SCE_REBOL_WORD7}
    {$HPPEMIT '#define SCE_REBOL_WORD7 27'}
    SCE_REBOL_WORD8 = 28;
    {$EXTERNALSYM SCE_REBOL_WORD8}
    {$HPPEMIT '#define SCE_REBOL_WORD8 28'}
    SCE_SQL_DEFAULT = 0;
    {$EXTERNALSYM SCE_SQL_DEFAULT}
    {$HPPEMIT '#define SCE_SQL_DEFAULT 0'}
    SCE_SQL_COMMENT = 1;
    {$EXTERNALSYM SCE_SQL_COMMENT}
    {$HPPEMIT '#define SCE_SQL_COMMENT 1'}
    SCE_SQL_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_SQL_COMMENTLINE}
    {$HPPEMIT '#define SCE_SQL_COMMENTLINE 2'}
    SCE_SQL_COMMENTDOC = 3;
    {$EXTERNALSYM SCE_SQL_COMMENTDOC}
    {$HPPEMIT '#define SCE_SQL_COMMENTDOC 3'}
    SCE_SQL_NUMBER = 4;
    {$EXTERNALSYM SCE_SQL_NUMBER}
    {$HPPEMIT '#define SCE_SQL_NUMBER 4'}
    SCE_SQL_WORD = 5;
    {$EXTERNALSYM SCE_SQL_WORD}
    {$HPPEMIT '#define SCE_SQL_WORD 5'}
    SCE_SQL_STRING = 6;
    {$EXTERNALSYM SCE_SQL_STRING}
    {$HPPEMIT '#define SCE_SQL_STRING 6'}
    SCE_SQL_CHARACTER = 7;
    {$EXTERNALSYM SCE_SQL_CHARACTER}
    {$HPPEMIT '#define SCE_SQL_CHARACTER 7'}
    SCE_SQL_SQLPLUS = 8;
    {$EXTERNALSYM SCE_SQL_SQLPLUS}
    {$HPPEMIT '#define SCE_SQL_SQLPLUS 8'}
    SCE_SQL_SQLPLUS_PROMPT = 9;
    {$EXTERNALSYM SCE_SQL_SQLPLUS_PROMPT}
    {$HPPEMIT '#define SCE_SQL_SQLPLUS_PROMPT 9'}
    SCE_SQL_OPERATOR = 10;
    {$EXTERNALSYM SCE_SQL_OPERATOR}
    {$HPPEMIT '#define SCE_SQL_OPERATOR 10'}
    SCE_SQL_IDENTIFIER = 11;
    {$EXTERNALSYM SCE_SQL_IDENTIFIER}
    {$HPPEMIT '#define SCE_SQL_IDENTIFIER 11'}
    SCE_SQL_SQLPLUS_COMMENT = 13;
    {$EXTERNALSYM SCE_SQL_SQLPLUS_COMMENT}
    {$HPPEMIT '#define SCE_SQL_SQLPLUS_COMMENT 13'}
    SCE_SQL_COMMENTLINEDOC = 15;
    {$EXTERNALSYM SCE_SQL_COMMENTLINEDOC}
    {$HPPEMIT '#define SCE_SQL_COMMENTLINEDOC 15'}
    SCE_SQL_WORD2 = 16;
    {$EXTERNALSYM SCE_SQL_WORD2}
    {$HPPEMIT '#define SCE_SQL_WORD2 16'}
    SCE_SQL_COMMENTDOCKEYWORD = 17;
    {$EXTERNALSYM SCE_SQL_COMMENTDOCKEYWORD}
    {$HPPEMIT '#define SCE_SQL_COMMENTDOCKEYWORD 17'}
    SCE_SQL_COMMENTDOCKEYWORDERROR = 18;
    {$EXTERNALSYM SCE_SQL_COMMENTDOCKEYWORDERROR}
    {$HPPEMIT '#define SCE_SQL_COMMENTDOCKEYWORDERROR 18'}
    SCE_SQL_USER1 = 19;
    {$EXTERNALSYM SCE_SQL_USER1}
    {$HPPEMIT '#define SCE_SQL_USER1 19'}
    SCE_SQL_USER2 = 20;
    {$EXTERNALSYM SCE_SQL_USER2}
    {$HPPEMIT '#define SCE_SQL_USER2 20'}
    SCE_SQL_USER3 = 21;
    {$EXTERNALSYM SCE_SQL_USER3}
    {$HPPEMIT '#define SCE_SQL_USER3 21'}
    SCE_SQL_USER4 = 22;
    {$EXTERNALSYM SCE_SQL_USER4}
    {$HPPEMIT '#define SCE_SQL_USER4 22'}
    SCE_SQL_QUOTEDIDENTIFIER = 23;
    {$EXTERNALSYM SCE_SQL_QUOTEDIDENTIFIER}
    {$HPPEMIT '#define SCE_SQL_QUOTEDIDENTIFIER 23'}
    SCE_ST_DEFAULT = 0;
    {$EXTERNALSYM SCE_ST_DEFAULT}
    {$HPPEMIT '#define SCE_ST_DEFAULT 0'}
    SCE_ST_STRING = 1;
    {$EXTERNALSYM SCE_ST_STRING}
    {$HPPEMIT '#define SCE_ST_STRING 1'}
    SCE_ST_NUMBER = 2;
    {$EXTERNALSYM SCE_ST_NUMBER}
    {$HPPEMIT '#define SCE_ST_NUMBER 2'}
    SCE_ST_COMMENT = 3;
    {$EXTERNALSYM SCE_ST_COMMENT}
    {$HPPEMIT '#define SCE_ST_COMMENT 3'}
    SCE_ST_SYMBOL = 4;
    {$EXTERNALSYM SCE_ST_SYMBOL}
    {$HPPEMIT '#define SCE_ST_SYMBOL 4'}
    SCE_ST_BINARY = 5;
    {$EXTERNALSYM SCE_ST_BINARY}
    {$HPPEMIT '#define SCE_ST_BINARY 5'}
    SCE_ST_BOOL = 6;
    {$EXTERNALSYM SCE_ST_BOOL}
    {$HPPEMIT '#define SCE_ST_BOOL 6'}
    SCE_ST_SELF = 7;
    {$EXTERNALSYM SCE_ST_SELF}
    {$HPPEMIT '#define SCE_ST_SELF 7'}
    SCE_ST_SUPER = 8;
    {$EXTERNALSYM SCE_ST_SUPER}
    {$HPPEMIT '#define SCE_ST_SUPER 8'}
    SCE_ST_NIL = 9;
    {$EXTERNALSYM SCE_ST_NIL}
    {$HPPEMIT '#define SCE_ST_NIL 9'}
    SCE_ST_GLOBAL = 10;
    {$EXTERNALSYM SCE_ST_GLOBAL}
    {$HPPEMIT '#define SCE_ST_GLOBAL 10'}
    SCE_ST_RETURN = 11;
    {$EXTERNALSYM SCE_ST_RETURN}
    {$HPPEMIT '#define SCE_ST_RETURN 11'}
    SCE_ST_SPECIAL = 12;
    {$EXTERNALSYM SCE_ST_SPECIAL}
    {$HPPEMIT '#define SCE_ST_SPECIAL 12'}
    SCE_ST_KWSEND = 13;
    {$EXTERNALSYM SCE_ST_KWSEND}
    {$HPPEMIT '#define SCE_ST_KWSEND 13'}
    SCE_ST_ASSIGN = 14;
    {$EXTERNALSYM SCE_ST_ASSIGN}
    {$HPPEMIT '#define SCE_ST_ASSIGN 14'}
    SCE_ST_CHARACTER = 15;
    {$EXTERNALSYM SCE_ST_CHARACTER}
    {$HPPEMIT '#define SCE_ST_CHARACTER 15'}
    SCE_ST_SPEC_SEL = 16;
    {$EXTERNALSYM SCE_ST_SPEC_SEL}
    {$HPPEMIT '#define SCE_ST_SPEC_SEL 16'}
    SCE_FS_DEFAULT = 0;
    {$EXTERNALSYM SCE_FS_DEFAULT}
    {$HPPEMIT '#define SCE_FS_DEFAULT 0'}
    SCE_FS_COMMENT = 1;
    {$EXTERNALSYM SCE_FS_COMMENT}
    {$HPPEMIT '#define SCE_FS_COMMENT 1'}
    SCE_FS_COMMENTLINE = 2;
    {$EXTERNALSYM SCE_FS_COMMENTLINE}
    {$HPPEMIT '#define SCE_FS_COMMENTLINE 2'}
    SCE_FS_COMMENTDOC = 3;
    {$EXTERNALSYM SCE_FS_COMMENTDOC}
    {$HPPEMIT '#define SCE_FS_COMMENTDOC 3'}
    SCE_FS_COMMENTLINEDOC = 4;
    {$EXTERNALSYM SCE_FS_COMMENTLINEDOC}
    {$HPPEMIT '#define SCE_FS_COMMENTLINEDOC 4'}
    SCE_FS_COMMENTDOCKEYWORD = 5;
    {$EXTERNALSYM SCE_FS_COMMENTDOCKEYWORD}
    {$HPPEMIT '#define SCE_FS_COMMENTDOCKEYWORD 5'}
    SCE_FS_COMMENTDOCKEYWORDERROR = 6;
    {$EXTERNALSYM SCE_FS_COMMENTDOCKEYWORDERROR}
    {$HPPEMIT '#define SCE_FS_COMMENTDOCKEYWORDERROR 6'}
    SCE_FS_KEYWORD = 7;
    {$EXTERNALSYM SCE_FS_KEYWORD}
    {$HPPEMIT '#define SCE_FS_KEYWORD 7'}
    SCE_FS_KEYWORD2 = 8;
    {$EXTERNALSYM SCE_FS_KEYWORD2}
    {$HPPEMIT '#define SCE_FS_KEYWORD2 8'}
    SCE_FS_KEYWORD3 = 9;
    {$EXTERNALSYM SCE_FS_KEYWORD3}
    {$HPPEMIT '#define SCE_FS_KEYWORD3 9'}
    SCE_FS_KEYWORD4 = 10;
    {$EXTERNALSYM SCE_FS_KEYWORD4}
    {$HPPEMIT '#define SCE_FS_KEYWORD4 10'}
    SCE_FS_NUMBER = 11;
    {$EXTERNALSYM SCE_FS_NUMBER}
    {$HPPEMIT '#define SCE_FS_NUMBER 11'}
    SCE_FS_STRING = 12;
    {$EXTERNALSYM SCE_FS_STRING}
    {$HPPEMIT '#define SCE_FS_STRING 12'}
    SCE_FS_PREPROCESSOR = 13;
    {$EXTERNALSYM SCE_FS_PREPROCESSOR}
    {$HPPEMIT '#define SCE_FS_PREPROCESSOR 13'}
    SCE_FS_OPERATOR = 14;
    {$EXTERNALSYM SCE_FS_OPERATOR}
    {$HPPEMIT '#define SCE_FS_OPERATOR 14'}
    SCE_FS_IDENTIFIER = 15;
    {$EXTERNALSYM SCE_FS_IDENTIFIER}
    {$HPPEMIT '#define SCE_FS_IDENTIFIER 15'}
    SCE_FS_DATE = 16;
    {$EXTERNALSYM SCE_FS_DATE}
    {$HPPEMIT '#define SCE_FS_DATE 16'}
    SCE_FS_STRINGEOL = 17;
    {$EXTERNALSYM SCE_FS_STRINGEOL}
    {$HPPEMIT '#define SCE_FS_STRINGEOL 17'}
    SCE_FS_CONSTANT = 18;
    {$EXTERNALSYM SCE_FS_CONSTANT}
    {$HPPEMIT '#define SCE_FS_CONSTANT 18'}
    SCE_FS_ASM = 19;
    {$EXTERNALSYM SCE_FS_ASM}
    {$HPPEMIT '#define SCE_FS_ASM 19'}
    SCE_FS_LABEL = 20;
    {$EXTERNALSYM SCE_FS_LABEL}
    {$HPPEMIT '#define SCE_FS_LABEL 20'}
    SCE_FS_ERROR = 21;
    {$EXTERNALSYM SCE_FS_ERROR}
    {$HPPEMIT '#define SCE_FS_ERROR 21'}
    SCE_FS_HEXNUMBER = 22;
    {$EXTERNALSYM SCE_FS_HEXNUMBER}
    {$HPPEMIT '#define SCE_FS_HEXNUMBER 22'}
    SCE_FS_BINNUMBER = 23;
    {$EXTERNALSYM SCE_FS_BINNUMBER}
    {$HPPEMIT '#define SCE_FS_BINNUMBER 23'}
    SCE_CSOUND_DEFAULT = 0;
    {$EXTERNALSYM SCE_CSOUND_DEFAULT}
    {$HPPEMIT '#define SCE_CSOUND_DEFAULT 0'}
    SCE_CSOUND_COMMENT = 1;
    {$EXTERNALSYM SCE_CSOUND_COMMENT}
    {$HPPEMIT '#define SCE_CSOUND_COMMENT 1'}
    SCE_CSOUND_NUMBER = 2;
    {$EXTERNALSYM SCE_CSOUND_NUMBER}
    {$HPPEMIT '#define SCE_CSOUND_NUMBER 2'}
    SCE_CSOUND_OPERATOR = 3;
    {$EXTERNALSYM SCE_CSOUND_OPERATOR}
    {$HPPEMIT '#define SCE_CSOUND_OPERATOR 3'}
    SCE_CSOUND_INSTR = 4;
    {$EXTERNALSYM SCE_CSOUND_INSTR}
    {$HPPEMIT '#define SCE_CSOUND_INSTR 4'}
    SCE_CSOUND_IDENTIFIER = 5;
    {$EXTERNALSYM SCE_CSOUND_IDENTIFIER}
    {$HPPEMIT '#define SCE_CSOUND_IDENTIFIER 5'}
    SCE_CSOUND_OPCODE = 6;
    {$EXTERNALSYM SCE_CSOUND_OPCODE}
    {$HPPEMIT '#define SCE_CSOUND_OPCODE 6'}
    SCE_CSOUND_HEADERSTMT = 7;
    {$EXTERNALSYM SCE_CSOUND_HEADERSTMT}
    {$HPPEMIT '#define SCE_CSOUND_HEADERSTMT 7'}
    SCE_CSOUND_USERKEYWORD = 8;
    {$EXTERNALSYM SCE_CSOUND_USERKEYWORD}
    {$HPPEMIT '#define SCE_CSOUND_USERKEYWORD 8'}
    SCE_CSOUND_COMMENTBLOCK = 9;
    {$EXTERNALSYM SCE_CSOUND_COMMENTBLOCK}
    {$HPPEMIT '#define SCE_CSOUND_COMMENTBLOCK 9'}
    SCE_CSOUND_PARAM = 10;
    {$EXTERNALSYM SCE_CSOUND_PARAM}
    {$HPPEMIT '#define SCE_CSOUND_PARAM 10'}
    SCE_CSOUND_ARATE_VAR = 11;
    {$EXTERNALSYM SCE_CSOUND_ARATE_VAR}
    {$HPPEMIT '#define SCE_CSOUND_ARATE_VAR 11'}
    SCE_CSOUND_KRATE_VAR = 12;
    {$EXTERNALSYM SCE_CSOUND_KRATE_VAR}
    {$HPPEMIT '#define SCE_CSOUND_KRATE_VAR 12'}
    SCE_CSOUND_IRATE_VAR = 13;
    {$EXTERNALSYM SCE_CSOUND_IRATE_VAR}
    {$HPPEMIT '#define SCE_CSOUND_IRATE_VAR 13'}
    SCE_CSOUND_GLOBAL_VAR = 14;
    {$EXTERNALSYM SCE_CSOUND_GLOBAL_VAR}
    {$HPPEMIT '#define SCE_CSOUND_GLOBAL_VAR 14'}
    SCE_CSOUND_STRINGEOL = 15;
    {$EXTERNALSYM SCE_CSOUND_STRINGEOL}
    {$HPPEMIT '#define SCE_CSOUND_STRINGEOL 15'}
    SCE_INNO_DEFAULT = 0;
    {$EXTERNALSYM SCE_INNO_DEFAULT}
    {$HPPEMIT '#define SCE_INNO_DEFAULT 0'}
    SCE_INNO_COMMENT = 1;
    {$EXTERNALSYM SCE_INNO_COMMENT}
    {$HPPEMIT '#define SCE_INNO_COMMENT 1'}
    SCE_INNO_KEYWORD = 2;
    {$EXTERNALSYM SCE_INNO_KEYWORD}
    {$HPPEMIT '#define SCE_INNO_KEYWORD 2'}
    SCE_INNO_PARAMETER = 3;
    {$EXTERNALSYM SCE_INNO_PARAMETER}
    {$HPPEMIT '#define SCE_INNO_PARAMETER 3'}
    SCE_INNO_SECTION = 4;
    {$EXTERNALSYM SCE_INNO_SECTION}
    {$HPPEMIT '#define SCE_INNO_SECTION 4'}
    SCE_INNO_PREPROC = 5;
    {$EXTERNALSYM SCE_INNO_PREPROC}
    {$HPPEMIT '#define SCE_INNO_PREPROC 5'}
    SCE_INNO_PREPROC_INLINE = 6;
    {$EXTERNALSYM SCE_INNO_PREPROC_INLINE}
    {$HPPEMIT '#define SCE_INNO_PREPROC_INLINE 6'}
    SCE_INNO_COMMENT_PASCAL = 7;
    {$EXTERNALSYM SCE_INNO_COMMENT_PASCAL}
    {$HPPEMIT '#define SCE_INNO_COMMENT_PASCAL 7'}
    SCE_INNO_KEYWORD_PASCAL = 8;
    {$EXTERNALSYM SCE_INNO_KEYWORD_PASCAL}
    {$HPPEMIT '#define SCE_INNO_KEYWORD_PASCAL 8'}
    SCE_INNO_KEYWORD_USER = 9;
    {$EXTERNALSYM SCE_INNO_KEYWORD_USER}
    {$HPPEMIT '#define SCE_INNO_KEYWORD_USER 9'}
    SCE_INNO_STRING_DOUBLE = 10;
    {$EXTERNALSYM SCE_INNO_STRING_DOUBLE}
    {$HPPEMIT '#define SCE_INNO_STRING_DOUBLE 10'}
    SCE_INNO_STRING_SINGLE = 11;
    {$EXTERNALSYM SCE_INNO_STRING_SINGLE}
    {$HPPEMIT '#define SCE_INNO_STRING_SINGLE 11'}
    SCE_INNO_IDENTIFIER = 12;
    {$EXTERNALSYM SCE_INNO_IDENTIFIER}
    {$HPPEMIT '#define SCE_INNO_IDENTIFIER 12'}
    SCE_OPAL_SPACE = 0;
    {$EXTERNALSYM SCE_OPAL_SPACE}
    {$HPPEMIT '#define SCE_OPAL_SPACE 0'}
    SCE_OPAL_COMMENT_BLOCK = 1;
    {$EXTERNALSYM SCE_OPAL_COMMENT_BLOCK}
    {$HPPEMIT '#define SCE_OPAL_COMMENT_BLOCK 1'}
    SCE_OPAL_COMMENT_LINE = 2;
    {$EXTERNALSYM SCE_OPAL_COMMENT_LINE}
    {$HPPEMIT '#define SCE_OPAL_COMMENT_LINE 2'}
    SCE_OPAL_INTEGER = 3;
    {$EXTERNALSYM SCE_OPAL_INTEGER}
    {$HPPEMIT '#define SCE_OPAL_INTEGER 3'}
    SCE_OPAL_KEYWORD = 4;
    {$EXTERNALSYM SCE_OPAL_KEYWORD}
    {$HPPEMIT '#define SCE_OPAL_KEYWORD 4'}
    SCE_OPAL_SORT = 5;
    {$EXTERNALSYM SCE_OPAL_SORT}
    {$HPPEMIT '#define SCE_OPAL_SORT 5'}
    SCE_OPAL_STRING = 6;
    {$EXTERNALSYM SCE_OPAL_STRING}
    {$HPPEMIT '#define SCE_OPAL_STRING 6'}
    SCE_OPAL_PAR = 7;
    {$EXTERNALSYM SCE_OPAL_PAR}
    {$HPPEMIT '#define SCE_OPAL_PAR 7'}
    SCE_OPAL_BOOL_CONST = 8;
    {$EXTERNALSYM SCE_OPAL_BOOL_CONST}
    {$HPPEMIT '#define SCE_OPAL_BOOL_CONST 8'}
    SCE_OPAL_DEFAULT = 32;
    {$EXTERNALSYM SCE_OPAL_DEFAULT}
    {$HPPEMIT '#define SCE_OPAL_DEFAULT 32'}
    SCE_SPICE_DEFAULT = 0;
    {$EXTERNALSYM SCE_SPICE_DEFAULT}
    {$HPPEMIT '#define SCE_SPICE_DEFAULT 0'}
    SCE_SPICE_IDENTIFIER = 1;
    {$EXTERNALSYM SCE_SPICE_IDENTIFIER}
    {$HPPEMIT '#define SCE_SPICE_IDENTIFIER 1'}
    SCE_SPICE_KEYWORD = 2;
    {$EXTERNALSYM SCE_SPICE_KEYWORD}
    {$HPPEMIT '#define SCE_SPICE_KEYWORD 2'}
    SCE_SPICE_KEYWORD2 = 3;
    {$EXTERNALSYM SCE_SPICE_KEYWORD2}
    {$HPPEMIT '#define SCE_SPICE_KEYWORD2 3'}
    SCE_SPICE_KEYWORD3 = 4;
    {$EXTERNALSYM SCE_SPICE_KEYWORD3}
    {$HPPEMIT '#define SCE_SPICE_KEYWORD3 4'}
    SCE_SPICE_NUMBER = 5;
    {$EXTERNALSYM SCE_SPICE_NUMBER}
    {$HPPEMIT '#define SCE_SPICE_NUMBER 5'}
    SCE_SPICE_DELIMITER = 6;
    {$EXTERNALSYM SCE_SPICE_DELIMITER}
    {$HPPEMIT '#define SCE_SPICE_DELIMITER 6'}
    SCE_SPICE_VALUE = 7;
    {$EXTERNALSYM SCE_SPICE_VALUE}
    {$HPPEMIT '#define SCE_SPICE_VALUE 7'}
    SCE_SPICE_COMMENTLINE = 8;
    {$EXTERNALSYM SCE_SPICE_COMMENTLINE}
    {$HPPEMIT '#define SCE_SPICE_COMMENTLINE 8'}
    SCN_STYLENEEDED = 2000;
    {$EXTERNALSYM SCN_STYLENEEDED}
    {$HPPEMIT '#define SCN_STYLENEEDED 2000'}
    SCN_CHARADDED = 2001;
    {$EXTERNALSYM SCN_CHARADDED}
    {$HPPEMIT '#define SCN_CHARADDED 2001'}
    SCN_SAVEPOINTREACHED = 2002;
    {$EXTERNALSYM SCN_SAVEPOINTREACHED}
    {$HPPEMIT '#define SCN_SAVEPOINTREACHED 2002'}
    SCN_SAVEPOINTLEFT = 2003;
    {$EXTERNALSYM SCN_SAVEPOINTLEFT}
    {$HPPEMIT '#define SCN_SAVEPOINTLEFT 2003'}
    SCN_MODIFYATTEMPTRO = 2004;
    {$EXTERNALSYM SCN_MODIFYATTEMPTRO}
    {$HPPEMIT '#define SCN_MODIFYATTEMPTRO 2004'}
    SCN_DOUBLECLICK = 2006;
    {$EXTERNALSYM SCN_DOUBLECLICK}
    {$HPPEMIT '#define SCN_DOUBLECLICK 2006'}
    SCN_UPDATEUI = 2007;
    {$EXTERNALSYM SCN_UPDATEUI}
    {$HPPEMIT '#define SCN_UPDATEUI 2007'}
    SCN_MODIFIED = 2008;
    {$EXTERNALSYM SCN_MODIFIED}
    {$HPPEMIT '#define SCN_MODIFIED 2008'}
    SCN_MACRORECORD = 2009;
    {$EXTERNALSYM SCN_MACRORECORD}
    {$HPPEMIT '#define SCN_MACRORECORD 2009'}
    SCN_MARGINCLICK = 2010;
    {$EXTERNALSYM SCN_MARGINCLICK}
    {$HPPEMIT '#define SCN_MARGINCLICK 2010'}
    SCN_NEEDSHOWN = 2011;
    {$EXTERNALSYM SCN_NEEDSHOWN}
    {$HPPEMIT '#define SCN_NEEDSHOWN 2011'}
    SCN_PAINTED = 2013;
    {$EXTERNALSYM SCN_PAINTED}
    {$HPPEMIT '#define SCN_PAINTED 2013'}
    SCN_USERLISTSELECTION = 2014;
    {$EXTERNALSYM SCN_USERLISTSELECTION}
    {$HPPEMIT '#define SCN_USERLISTSELECTION 2014'}
    SCN_DWELLSTART = 2016;
    {$EXTERNALSYM SCN_DWELLSTART}
    {$HPPEMIT '#define SCN_DWELLSTART 2016'}
    SCN_DWELLEND = 2017;
    {$EXTERNALSYM SCN_DWELLEND}
    {$HPPEMIT '#define SCN_DWELLEND 2017'}
    SCN_ZOOM = 2018;
    {$EXTERNALSYM SCN_ZOOM}
    {$HPPEMIT '#define SCN_ZOOM 2018'}
    SCN_HOTSPOTCLICK = 2019;
    {$EXTERNALSYM SCN_HOTSPOTCLICK}
    {$HPPEMIT '#define SCN_HOTSPOTCLICK 2019'}
    SCN_HOTSPOTDOUBLECLICK = 2020;
    {$EXTERNALSYM SCN_HOTSPOTDOUBLECLICK}
    {$HPPEMIT '#define SCN_HOTSPOTDOUBLECLICK 2020'}
    SCN_CALLTIPCLICK = 2021;
    {$EXTERNALSYM SCN_CALLTIPCLICK}
    {$HPPEMIT '#define SCN_CALLTIPCLICK 2021'}
    SCN_AUTOCSELECTION = 2022;
    {$EXTERNALSYM SCN_AUTOCSELECTION}
    {$HPPEMIT '#define SCN_AUTOCSELECTION 2022'}
//--Const

implementation

end.
Added src/delphisci/SciVer.inc.














































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}

{Version number for the Delphi Scintilla Interface Components}
const DelphiSciVersion =23;
Added src/delphisci/SciWhatToFillUnit.ddp.

cannot compute difference between binary files

Added src/delphisci/SciWhatToFillUnit.dfm.


















































































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
object TSciWhatToFillForm: TTSciWhatToFillForm
  Left = 343
  Top = 129
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  Caption = 'Select languages to insert..'
  ClientHeight = 377
  ClientWidth = 489
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBtnText
  Font.Height = -11
  Font.Name = 'MS Shell Dlg 2'
  Font.Style = []
  OldCreateOrder = False
  Position = poScreenCenter
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object buttonPanel: TPanel
    Left = 0
    Top = 339
    Width = 489
    Height = 38
    Align = alBottom
    BevelOuter = bvNone
    ParentColor = True
    TabOrder = 0
    object okButton: TBitBtn
      Left = 31
      Top = 6
      Width = 75
      Height = 25
      Hint = 'Add the selected languages'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 0
      Kind = bkOK
    end
    object cancelButton: TBitBtn
      Left = 383
      Top = 6
      Width = 75
      Height = 25
      Hint = 'Cancel this dialog'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 1
      Kind = bkCancel
    end
    object selectAllButton: TBitBtn
      Left = 148
      Top = 6
      Width = 75
      Height = 25
      Hint = 'Select all the languages'
      Caption = '&Select All'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 2
      OnClick = selectAllButtonClick
      NumGlyphs = 2
    end
    object selectNoneButton: TBitBtn
      Left = 265
      Top = 6
      Width = 75
      Height = 25
      Hint = 'Clear selections'
      Caption = 'Select &None'
      ParentShowHint = False
      ShowHint = True
      TabOrder = 3
      OnClick = selectNoneButtonClick
    end
  end
  object lvPanel: TPanel
    Left = 0
    Top = 0
    Width = 489
    Height = 339
    Align = alClient
    TabOrder = 1
    object copyrightlabel: TLabel
      Left = 1
      Top = 325
      Width = 487
      Height = 13
      Align = alBottom
      Alignment = taCenter
      Color = clHighlight
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clHighlightText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ParentColor = False
      ParentFont = False
      Layout = tlCenter
    end
    object langs: TListView
      Left = 1
      Top = 35
      Width = 487
      Height = 290
      Align = alClient
      Checkboxes = True
      Columns = <>
      ColumnClick = False
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ParentFont = False
      SortType = stText
      TabOrder = 0
      ViewStyle = vsList
    end
    object TopPanel: TPanel
      Left = 1
      Top = 1
      Width = 487
      Height = 34
      Align = alTop
      BevelOuter = bvNone
      TabOrder = 1
      DesignSize = (
        487
        34)
      object Label1: TLabel
        Left = 21
        Top = 12
        Width = 107
        Height = 13
        Caption = 'Show languages from:'
      end
      object SettingsFrom: TLabel
        Left = 134
        Top = 12
        Width = 260
        Height = 13
        AutoSize = False
        Caption = 'BuiltIn'
        Transparent = True
      end
      object loadButton: TBitBtn
        Left = 403
        Top = 5
        Width = 75
        Height = 25
        Hint = 'Load styles/languages from a file..'
        Anchors = [akTop, akRight]
        Caption = '&Load'
        ParentShowHint = False
        ShowHint = True
        TabOrder = 0
        OnClick = loadButtonClick
      end
    end
  end
  object odia: TOpenDialog
    Filter = 'Styles (*.Styles)|*.Styles|All Files (*.*)|*.*'
    Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing]
    Title = 'Load languages from'
    Left = 335
    Top = 124
  end
end
Added src/delphisci/SciWhatToFillUnit.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
  Created: 19/11/2004, 01:14:14
  History: 19/11/2004 Initial Release
           30/05/2005 Added some changes.
           04/08/2005 Changed the entire form to allow for loading the styles from
                      a file which is in .Styles/Properties format..
                      If basecolors exists in the .styles file, then those
                      will be added before the items is shown..
                      
           08/09/2005 Removed the ScintillaLanguages.Inc dependency.. Now we load
                      the builtin languages from a resource instead..
                      It was a somewhat h*llish affair to update the styles as code,
                      so this is most likely A LOT better way to maintain this..
                      No macros in the lines as in SciTE yet, but who knows. The
                      .Styles files loaded/saved with MyEdit, or from within the
                      IDE is what we use now. LangStyles.Res contains the language
                      resources.

      $Id: SciWhatToFillUnit.pas,v 1.4 2004/11/13 04:29:50 hdalis Exp $
}
{$Include SciCommonDef.Inc}
unit SciWhatToFillUnit;
interface
uses
  Forms,StdCtrls, Buttons, Classes, Controls, ExtCtrls, ComCtrls,ScintillaLanguageManager,
  Dialogs,SciLexerMod,SciStyleLoader;

type
TSciLangSettings = Record
  CommentBoxStart,CommentBoxMiddle,CommentBoxEnd,CommentBlock : String;
  CommentAtLineStart : Boolean;
  CommentStreamStart,CommentStreamEnd : String;
  AssignmentOperator,EndOfStatementOperator : String;
  NumStyleBits : Integer;
end;

PSciLangData=^TSciLangData;
TSciLangData=Record
  Name : String;
  Lexer : String;
  LangSettings : TSciLangSettings;
  Styles : array of TSciLangStyle;
  Keywords : array of TSciLangKeywords;
end;

  TTSciWhatToFillForm = class(TForm)
    buttonPanel: TPanel;
    okButton: TBitBtn;
    cancelButton: TBitBtn;
    selectAllButton: TBitBtn;
    selectNoneButton: TBitBtn;
    lvPanel: TPanel;
    langs: TListView;
    copyrightlabel: TLabel;
    TopPanel: TPanel;
    Label1: TLabel;
    loadButton: TBitBtn;
    SettingsFrom: TLabel;
    odia: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    procedure selectAllButtonClick(Sender: TObject);
    procedure selectNoneButtonClick(Sender: TObject);
    procedure loadButtonClick(Sender: TObject);
  private
    ldr : TSciStylesLoader;
    fEditor : TScintilla;
    fStyleFile : String;
    { Private declarations }
    procedure SetEditor(Value : TScintilla);
    function AddToListFromStream(Stream : TStream) : Boolean;
    function AddToListFromFile(const FileName : String) : Boolean;
    procedure AddBuiltInToList;
    procedure ReleaseLVItems;
  public
    constructor Create(AOwner : TComponent);override;
    destructor Destroy;override;
    procedure AddSelectedLanguages(const StylesOnly : Boolean=False);
    function Execute(fname : String='') : Integer;
    property Editor : TScintilla read fEditor write SetEditor;
    property StyleFile : String read fStyleFile;
  end;

var
  TSciWhatToFillForm: TTSciWhatToFillForm;
procedure AddDefaultStyles(Itm : TSciLangItem);
procedure AddNullLang(Ed : TScintilla);
procedure AddOneLanguage(Ed : TScintilla;TheData : PSciLangData;const ClearFirst : Boolean=False;const StylesOnly : Boolean=False);
procedure FillLanguages(Ed : TScintilla;const usejustnull : Boolean=false;const StylesOnly : Boolean=false);
implementation

{$R *.dfm}
uses Windows,SysUtils, Graphics, sciUtils,SciLexer,SciResLang,SciResLangDcl,Registry;
//Include the language resources.
{$R LangResources.Res}
const
  defaultlanguagesettings : TSciLangSettings=(
    CommentBoxStart:'/*';
    CommentBoxMiddle:'*';
    CommentBoxEnd:'*/';
    CommentBlock:'//';
    CommentAtLineStart:True;
    CommentStreamStart:'/*';
    CommentStreamEnd:'*/';
    AssignmentOperator:'=';
    EndOfStatementOperator:';';
    NumStyleBits:5;
  );

procedure AddNullLang(Ed : TScintilla);
var
  nullitmdta : PSciLangData;
begin
  nullitmdta:=nil;
  try
    New(nullitmdta);
    nullitmdta.Name:='null';
    nullitmdta.Lexer:='null';
    nullitmdta.Styles:=nil;
    nullitmdta.Keywords:=nil;
    nullitmdta.LangSettings:=defaultlanguagesettings;
    AddOneLanguage(Ed,nullitmdta);
  finally
    if assigned(nullitmdta) then Dispose(nullitmdta);
  end;
end;

procedure AddDefaultStyles(Itm : TSciLangItem);
var
  i : Integer;
const
  //These are the default styles which is used in every language if the style isn't already assigned.
  DefaultStyles : array [0..4] of TSciLangStyle =(
      (
        StyleNumber : 33; Name : 'LineNumbers'; FontName : 'Arial'; FontSize : 0; FontStyles : [];
        ForeColor : clSilver; BackColor : clBlack; CharCase : CASE_MIXED; Visible: True;
        Changeable : True; HotSpot : False;  EOLFilled : False;CharSet: -1
      ),
      (
        StyleNumber : 34; Name : 'Ok Braces'; FontName : ''; FontSize : 0; FontStyles : [fsBold];
        ForeColor : clYellow; BackColor : clDefault; CharCase : CASE_MIXED; Visible: True;
        Changeable : True; HotSpot : False;  EOLFilled : False;CharSet: -1
      ),
      (
        StyleNumber : 35; Name : 'Bad Braces'; FontName : ''; FontSize : 0; FontStyles : [fsBold];
        ForeColor : clRed; BackColor : clDefault; CharCase : CASE_MIXED; Visible: True;
        Changeable : True; HotSpot : False;  EOLFilled : False;CharSet: -1
      ),
      (
        StyleNumber : 36; Name : 'Control Chars'; FontName : ''; FontSize : 0; FontStyles : [];
        ForeColor : clBlack; BackColor : clSilver; CharCase : CASE_MIXED; Visible: True;
        Changeable : True; HotSpot : False;  EOLFilled : False;CharSet: -1
      ),
      (
        StyleNumber : 37; Name : 'Indent Guide'; FontName : ''; FontSize : 0; FontStyles : [];
        ForeColor : clGray; BackColor : clDefault; CharCase : CASE_MIXED; Visible: True;
        Changeable : True; HotSpot : False;  EOLFilled : False;CharSet: -1
      )
  );

begin
  for i:=Low(DefaultStyles) to High(DefaultStyles) do
  begin
    if itm.Styles.HasStyle(DefaultStyles[i].StyleNumber)=False then
      TSciStyle(itm.Styles.Add).AssignRec(DefaultStyles[i]);
  end;
end;

procedure FillLanguages(Ed : TScintilla;const usejustnull : Boolean;const StylesOnly : Boolean);
var
  frm : TTSciWhatToFillForm;
  reg : TRegistry;
  fname : String;
begin
  fname:='';
  reg:=nil;
  try
    try
      reg:=TRegistry.Create;
      //Open the registry key, and get the last stylefile we used, if any.
      if reg.OpenKey('Software\TC Productions\DelphiSci',True) then
      begin
        if reg.ValueExists('LastStyleFile') then
        begin
          fname:=reg.ReadString('LastStyleFile');
        end;
        reg.CloseKey;
      end;
      FreeAndNil(reg);
    except
      on ERegistryException do
      begin

      end;
    end;
    Ed.LanguageManager.LanguageList.BeginUpdate;
    if (usejustnull=True) then
    begin
      Ed.LanguageManager.SelectedLanguage:='null';
      Ed.LanguageManager.LanguageList.Clear;
      AddNullLang(Ed);
    end;
    if (usejustnull=False) then
    begin
      frm:=TTSciWhatToFillForm.Create(nil);
      frm.Editor:=Ed;
      if frm.Execute(fname)=mrOk then
      begin
        frm.AddSelectedLanguages(StylesOnly);
        try
          //Open registry key, and store the current name of the stylefile.
          reg:=TRegistry.Create;
          if reg.OpenKey('Software\TC Productions\DelphiSci',True) then
          begin
            reg.WriteString('LastStyleFile',frm.StyleFile);
            reg.CloseKey;
          end;
          FreeAndNil(reg);
        except
          on ERegistryException do
          begin

          end;
        end;
      end;
      if frm<>nil then FreeAndNil(frm);
    end;
  finally
    Ed.LanguageManager.LanguageList.EndUpdate;
    if assigned(reg) then FreeAndNil(reg);
  end;
end;

procedure AddOneLanguage(Ed : TScintilla;TheData : PSciLangData;const ClearFirst : Boolean;const StylesOnly : Boolean);
var
  i : Integer;
  itm : TSciLangItem;
  langlist : TSciLangList;
begin
  if not assigned(Ed) then Exit;
  langlist:=Ed.LanguageManager.LanguageList;
  itm:=langlist.Find(TheData.Name);
  if assigned(itm) then
  begin
    if (itm.Lexer='null') then
    begin
      if TheData.Lexer='' then
        itm.Lexer:=TheData.Name
      else
        itm.Lexer:=TheData.Lexer;
    end;
    if ClearFirst then
    begin
      itm.Styles.Clear;
      if StylesOnly=False then
      itm.Keywords.Clear;
    end;
  end;
  if itm=nil then
  begin
    itm :=TSciLangItem(langlist.Add);
    //tmprem itm.LanguageStr:=langname;
    itm.Name:=TheData.Name;
    if TheData.Lexer='' then itm.Lexer:=TheData.Name
    else
      itm.Lexer:=TheData.Lexer;
  end;
  itm.CommentBoxStart:=TheData.LangSettings.CommentBoxStart;
  itm.CommentBoxMiddle:=TheData.LangSettings.CommentBoxMiddle;
  itm.CommentBoxEnd:=TheData.LangSettings.CommentBoxEnd;
  itm.CommentBlock:=TheData.LangSettings.CommentBlock;
  itm.CommentStreamStart:=TheData.LangSettings.CommentStreamStart;
  itm.CommentStreamEnd:=TheData.LangSettings.CommentStreamEnd;
  itm.CommentAtLineStart:=TheData.LangSettings.CommentAtLineStart;
  itm.AssignmentOperator:=TheData.LangSettings.AssignmentOperator;
  itm.EndOfStatementOperator:=TheData.LangSettings.EndOfStatementOperator;
  itm.NumStyleBits:=TheData.LangSettings.NumStyleBits;
  try
    if stylesonly=false then
      itm.KeyWords.BeginUpdate;
    itm.Styles.BeginUpdate;
    if stylesonly=false then
    begin
      for i := Low(TheData.Keywords) to High(TheData.Keywords) do
      begin
        if (itm.Keywords.HasList(TheData.Keywords[i].KeywordListNumber)=False) then
          TSciKeyWords(itm.Keywords.Add).AssignRec(TheData.Keywords[i]);
      end;
    end;
    for i := Low(TheData.Styles) to High(TheData.Styles) do
    begin
      if (itm.Styles.HasStyle(TheData.Styles[i].StyleNumber)=False) then
        TSciStyle(itm.Styles.Add).AssignRec(TheData.Styles[i]);
    end;
    AddDefaultStyles(itm);
  finally
    itm.Styles.EndUpdate;
    if StylesOnly=false then
      itm.KeyWords.EndUpdate;
  end;
end;

procedure TTSciWhatToFillForm.AddSelectedLanguages(const StylesOnly : Boolean);
var
  i,cnt : Integer;
  itm : TListItem;
  nullitm : TSciLangItem;
  itmdta : PSciLangData;
begin
  if not assigned(fEditor) then Exit;
  try
    if assigned(fEditor) then
      fEditor.LanguageManager.LanguageList.BeginUpdate;
  cnt:=langs.Items.Count;
  for i:=0 to (cnt-1) do
  begin
    itm:=langs.Items.Item[i];
    if assigned(itm) and (itm.Checked) and (itm.Data<>nil) then
    begin
      itmdta:=PSciLangData(itm.Data);
      AddOneLanguage(fEditor,itmdta,False,StylesOnly);
    end;
  end;

  nullitm:=fEditor.LanguageManager.LanguageList.Find('null');
  if nullitm.Styles.Count=0 then
    AddNullLang(fEditor);

  finally
    if assigned(fEditor) then
      fEditor.LanguageManager.LanguageList.EndUpdate;
  end;
end;

procedure TTSciWhatToFillForm.SetEditor(Value : TScintilla);
begin
  fEditor:=Value;
  ldr.Editor:=Value;
end;

procedure TTSciWhatToFillForm.ReleaseLVItems;
var
  cnt,i : Integer;
  itm : TListItem;
  itmdta : PSciLangData;
begin
  cnt:=langs.Items.Count;
  for i:=0 to (cnt-1) do
  begin
    itm:=langs.Items.Item[i];
    if assigned(itm.Data) then
    begin
      itmdta:=PSciLangData(itm.Data);
      itm.Data:=nil;
      Dispose(itmdta);
    end;
  end;
end;

//Opens a resourcestream and load and add the styles found..
procedure TTSciWhatToFillForm.AddBuiltInToList;
var
  ResStream : TResourceStream;
begin
  ResStream:=nil;
  try
    try
      ResStream :=TResourceStream.Create(HInstance,'BuiltInLangs',RT_RCDATA);
      ResStream.Seek(0,soFromBeginning);
      AddToListFromStream(ResStream);
    except
      on EStreamError do
      ;
    end;
  finally
    if assigned(ResStream) then FreeAndNil(ResStream);
  end;
end;

//Opens a file and load and add the styles found..
function TTSciWhatToFillForm.AddToListFromFile(const FileName : String) : Boolean;
var
  fs : TFileStream;
begin
  fs:=nil;
  try
    try
    fs:=TFileStream.Create(FileName,fmOpenRead or fmShareDenyWrite);
    Result:=AddToListFromStream(fs);
    except
      on EStreamError do
        Result:=False;
    end;
  finally
    if assigned(fs) then FreeAndNil(fs);
  end;
end;

//Add the specified language to the listview
function TTSciWhatToFillForm.AddToListFromStream(Stream : TStream) : Boolean;
var
  mgr : TSciLanguageManager;
  i,cnt : Integer;
  procedure AddToList(lst : TListView;Lang : TSciLangItem);
  var
    dta : PSciLangData;
    cnt,i : Integer;
    itm : TListItem;
    wasadded : Boolean;
  begin
    wasadded:=False;
    dta:=nil;
    try
      New(dta);
      if assigned(dta) then
      begin
        dta.Name:=Lang.Name;
        dta.Lexer:=Lang.Lexer;
        dta.LangSettings.CommentBoxStart:=Lang.CommentBoxStart;
        dta.LangSettings.CommentBoxMiddle:=Lang.CommentBoxMiddle;
        dta.LangSettings.CommentBoxEnd:=Lang.CommentBoxEnd;
        dta.LangSettings.CommentBlock:=Lang.CommentBlock;
        dta.LangSettings.CommentAtLineStart:=Lang.CommentAtLineStart;
        dta.LangSettings.CommentStreamStart:=Lang.CommentStreamStart;
        dta.LangSettings.CommentStreamEnd:=Lang.CommentStreamEnd;
        dta.LangSettings.NumStyleBits:=Lang.NumStyleBits;
        dta.LangSettings.AssignmentOperator:=Lang.AssignmentOperator;
        dta.LangSettings.EndOfStatementOperator:=Lang.EndOfStatementOperator;

        cnt:=Lang.Styles.Count;
        if cnt>0 then
        begin
          SetLength(dta.Styles,cnt);
          for i:=0 to (cnt-1) do
          begin
            Lang.Styles.Items[i].AssignToRec(dta.Styles[i]);
          end;
        end else
          dta.Styles:=nil;
        cnt:=Lang.Keywords.Count;
        if cnt>0 then
        begin
          SetLength(dta.Keywords,cnt);
          for i:=0 to (cnt-1) do
          begin
            Lang.Keywords.Items[i].AssignToRec(dta.Keywords[i]);
          end;
        end else
          dta.Keywords:=nil;
        itm:=lst.Items.Add;
        if assigned(itm) then
        begin
          itm.Caption:=dta.Name;
          itm.Data:=dta;
          itm.Checked:=False;
          wasadded:=True;
        end;
      end;
    finally
      if wasadded=false then
      begin
        if assigned(dta) then
        begin
          dta.Styles:=nil;
          dta.Keywords:=nil;
          Dispose(dta);
        end;
      end;
    end;
  end;
begin
  mgr:=nil;
  Result:=False;
  try
    try
      mgr:=TSciLanguageManager.Create(nil);
      ldr.LanguageManager:=mgr;
      Result:=ldr.LoadStylesFromStream(Stream);
      cnt:=mgr.LanguageList.Count;
      for i:=0 to (cnt-1) do
      begin
        AddToList(langs,mgr.LanguageList.Items[i]);
      end;
    except
      raise;
    end;
  finally
    if assigned(mgr) then
      FreeAndNil(mgr);
  end;
end;

constructor TTSciWhatToFillForm.Create(AOwner : TComponent);
begin
  inherited;
  ldr:=TSciStylesLoader.Create;
end;

destructor TTSciWhatToFillForm.Destroy;
begin
  ReleaseLVItems;
  if assigned(ldr) then
    FreeAndNil(ldr);
  inherited;
end;

procedure TTSciWhatToFillForm.selectAllButtonClick(Sender: TObject);
var
  cnt,i : Integer;
begin
  cnt:=langs.Items.Count;
  for i:=0 to (cnt-1) do
  begin
    langs.Items.Item[i].Checked:=True;
  end;
end;

procedure TTSciWhatToFillForm.selectNoneButtonClick(Sender: TObject);
var
  cnt,i : Integer;
begin
  cnt:=langs.Items.Count;
  for i:=0 to (cnt-1) do
  begin
    langs.Items.Item[i].Checked:=False;
  end;
end;

procedure TTSciWhatToFillForm.FormCreate(Sender: TObject);
begin
  copyrightlabel.Caption:=GetDelphiSciVersionStr;
end;

function TTSciWhatToFillForm.Execute(fname : String) : Integer;
begin
  if (fname<>'') and (FExists(fname)) then
  begin
    AddToListFromFile(fname);
    SettingsFrom.Caption:=fname;
  end else
  begin
    AddBuiltInToList;
    SettingsFrom.Caption:='BuiltIn';    
  end;
  Result:=ShowModal;
end;

procedure TTSciWhatToFillForm.loadButtonClick(Sender: TObject);
var
  fname : String;
begin
  if odia.Execute then
  begin
    try
      langs.Items.BeginUpdate;
      ReleaseLVItems;
      langs.Clear;
      fname:=odia.FileName;
      if AddToListFromFile(fname)=False then
      begin
        MessageBox(Handle,PChar(Format(eFailedToLoadStyles,[fname])),PChar(sError),MB_OK);
        ReleaseLVItems;
        langs.Clear;
        AddBuiltInToList;
        SettingsFrom.Caption:='BuiltIn';
        fStyleFile:='';
      end else
      begin
        SettingsFrom.Caption:=odia.FileName;
        fStyleFile:=odia.FileName;
        if ldr.LoadingErrors.Count>0 then
        begin
          MessageBox(Handle,PChar(Format(eTheseWhereTheErrors,[fname])+ldr.LoadingErrors.Text),PChar(sError),MB_OK);
        end;
      end;
    finally
      langs.Items.EndUpdate;
    end;
  end else
  begin
    if MessageBox(Handle,'You cancelled.. Use the builtin list?',PChar(sConfirmation),MB_YESNO)=IDYES then
    begin
      try
        langs.Items.BeginUpdate;
        ReleaseLVItems;
        langs.Clear;
        AddBuiltInToList;
        SettingsFrom.Caption:='BuiltIn';
        fStyleFile:='';
      finally
        langs.Items.EndUpdate;
      end;
    end;
  end;
end;

end.
Added src/delphisci/ScintillaLanguageManager.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{$Include SciCommonDef.Inc}
{$Define DEBUGSTYLEPROP}
unit ScintillaLanguageManager;
{ 
 Unit    : ScintillaLanguageManager
 Purpose : Manages defined languages and lexers..
 Created : 05/03/2001
 Original Author  : Kiriakos Vlahos (kvlahos@london.edu)
 Author  : Jan Martin Pettersen (hdalis)
      $Id: ScintillaLanguageManager.pas,v 1.5 2004/11/13 04:29:51 hdalis Exp $
 History : 15/03/2001 Lexer sturtures and encapsulation of some common Lexers

           29/09/2004 Initial Release with Delphi Scintilla Interface Components
                      Added additional encapsulation, the possibility to
                      define your own languages based on the existing lexers.
                      No longer enumerated lexer type, changed to strings
                      Added the possibility to define languages based on
                      known lexers. Multiple languages can use the same
                      lexer. ie. resourcedefinition use the same lexer as the
                      c++ language.
                      Added function to dynamically add languages to the
                      Optionsdialog etc..
                      (hdalis@users.sourceforge.net)
           05/10/2004 Removed the typedef for TSciLangName (no longer needed)
                      Renamed the SetLLanguage procedure to SetLanguageStr
           13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                      generate the help.
                      (hdalis@users.sourceforge.net)
           27/10/2004 Renamed the TSciLanguageManager.LanguageStr to SelectedLanguage,
                      and the SetLanguageStr to SetSelectedLanguage.
                      Renamed TSciLangList.GetStyleListStr to GetStyleList.
           30/10/2004 Added Comment* properties to TSciLangItem, used by
                      CommentBox/CommentBlock functions in TScintilla.
           09/01/2005 Added the property ExtraData to TSciLangItem and TSciLanguageManager
                      to allow storing of more data with each language..
                      Added AddLexer,HasLexer,RemoveLexer to TSciLanguageManager

                      Those above was added to support adding an Automation interface for
                      each of the languages for example.. as used in the MyEditor demo..
                      or it may be called an editor now I think.. with internal scripting,
                      fully supporting automation etc..

                      Added CharSet property to TSciStyle.
                      (hdalis@users.sourceforge.net)
           14/02/2005 Changed the Comment* properties in TSciLangItem,
                      to be more corrent..
                      CommentOneliner = CommentBlock, CommentBox* = Comment*
                      Two new properties.. CommentStreamStart, CommentStreamEnd.
                      Added AssignmentOperator and EndOfStatementOperator to same..
                      Added a include for MoreLexers.inc to make it easy for developers
                      to add lexers, and to maintain it without sifting through all the
                      sourcecode.
                      (hdalis@users.sourceforge.net)
           10/03/2005 Removed php and asp from the lexerlist at it is deprecated (temporarily?)..
                      Use hypertext lexer instead.
           12/04/2005 Added TSciStyleList.HasStyle and TSciKeyWordsList.HasList
           30/05/2005 Added the SameStyle functions, and more.
 Bugfixes:
           15/10/2004 Fixed a bug in GetStyleListStr. Didn't set the LanguageStr when
                      nullitm didn't exits, and it was created. Caused
                      TScintillaOptionsDlg to throw an exception with list error
                      when you tried to add a style and no nullstyles existed.
                      (hdalis@users.sourceforge.net)
           09/06/2005 Changed TSciKeyWordsList,TSciStyleList,TSciLangList so the Items property and Add returns/sets
                      the corresponding item class, not just TCollectionItem.. No need to cast those anymore.
           09/06/2005 Renamed the SameStyle functions to IsSameStyle
           15/06/2005 Added the SortAll function.. this sorts all languages, styles, and keywordlists.
                      The styles and keywords are sorted by listnumber, and languages are sorted by name.
                      Added GetDisplayName for all TCollectionItem descendants, this provides the designer
                      with the names of the items, rather than just the class name (which is the default).
           11/01/2006 Added BeginUpdate and EndUpdate procedures to TSciLanguageManager.
                      Begun some preparation of making TSciLanguageManager a standalone component (the
                      define LMSTANDALONE)
                      This is NOT complete by a longshot.
           31/01/2006 Made some preparations for TSciLanguageManager standalone component
                      NOTE!! NOT COMPLETE.
           ........   Fixed a bug which caused the component not freeing all of it's memory.
                      Just one char was wrong in an $ifdef.
           14/09/2006 Really should get on with the item above, but I am somewhat stuck on how to do
                      it without too much restructuring of the code.
                      To me it seems like this would require quite a bit of rewriting with the following
                      breakage of code.
           14/09/2006 Some changes to the list of lexers, clw and clwnocase is replaced with clarion*
                      to concede with the SciLexer.dll (more or less a bugfix).
                      Renamed scicontainerconst to cContainerLexer to match more with what the constant
                      contains.
                      Changed all references to 'null' to cDefaultLexer.


 TODO:
       Make the TSciLanguageManager standalone because it is likely more than one editor would use
       the same set of languages instead of duplicating the entire languagemanager.. 
}
 interface
uses SysUtils, Classes, Graphics,SciLexerMemo;

Type
  TSCEvent_languagechanged = procedure(Sender : TObject; newlang : String) of object;

TSciCase = (CASE_MIXED,CASE_UPPER,CASE_LOWER);
TSciLangKeywords = Record
  Name : string;
  KeywordListNumber : Integer;
  KeyWords : string;
end;

TSciLangStyle = Record
  StyleNumber : Integer;
  Name : string;
  FontName : string;
  FontSize : Integer;
  FontStyles : TFontStyles;
  ForeColor : TColor;
  BackColor : TColor;
  CharCase : TSciCase;
  Visible: Boolean;
  Changeable : Boolean;
  Hotspot : Boolean;
  EOLFilled : Boolean;
  CharSet : Integer;
end;

TSciStyle = class(TCollectionItem)
private
  fStyleNumber : Integer;
  fName : string;
  fFontName : string;
  fFontSize : Integer;
  fFontStyles : TFontStyles;
  fForeColor : TColor;
  fBackColor : TColor;
  fCharCase : TSciCase;
  fVisible: Boolean;
  fChangeable: Boolean;
  fHotspot : boolean;
  fEOLFilled: Boolean;
  fCharSet : Integer;
  procedure SetBackColor(const Value: TColor);
  procedure SetFontName(const Value: string);
  procedure SetFontSize(const Value: Integer);
  procedure SetFontStyles(const Value: TFontStyles);
  procedure SetForeColor(const Value: TColor);
  procedure SetName(const Value: string);
  procedure SetStyleNumber(const Value: Integer);
  procedure SetCharCase(const Value: TSciCase);
  procedure SetVisible(const Value: Boolean);
  procedure SetChangeable(const Value: Boolean);
  procedure SetEOLFilled(const Value: Boolean);
  procedure SetHotspot(const Value: Boolean);
  procedure SetCharSet(const Value : Integer);
protected
  function GetDisplayName: string; override;
public
  constructor Create(Collection: TCollection); override;
  procedure Assign(Source: TPersistent); override;
  procedure AssignRec(Rec : TSciLangStyle);
  procedure AssignToRec(var Rec : TSciLangStyle);
published
  property FontName : string read fFontName write SetFontName;
  property FontSize : Integer read fFontSize write SetFontSize;
  property FontStyles : TFontStyles read FFontStyles write SetFontStyles;
  property ForeColor : TColor read fForeColor write SetForeColor;
  property BackColor : TColor read fBackColor write SetBackColor;
  property CharCase : TSciCase read fCharCase write SetCharCase;
  property Visible : Boolean read fVisible write SetVisible default true;
  property Changeable : Boolean read fChangeable write SetChangeable default true;
  property EOLFilled : Boolean read fEOLFilled write SetEOLFilled default false;
  property Hotspot : Boolean read fHotspot write SetHotspot default false;
  property Name : string read fName write SetName;
  property StyleNumber : Integer read fStyleNumber write SetStyleNumber;
  property CharSet : Integer read fCharSet write SetCharSet default -1;
end;

TSciStyleList = class(TOwnedCollection)
private
  fEditor : TPersistent; //TScintilla
  procedure SetEditor(Editor : TPersistent);
  function GetItem(Index:Integer): TSciStyle;
  procedure SetItem(Index:Integer; Value: TSciStyle);
public
  function Add: TSciStyle;
  function HasStyle(const StyleNumber : LongInt) : Boolean;
  function GetStyle(const StyleNumber : LongInt) : TSciStyle;
  procedure Update(Item: TCollectionItem); override;

  property Items[Index : Integer] : TSciStyle read GetItem write SetItem;default;
end;

TSciKeywords = class(TCollectionItem)
private
  fKeyWords : TStrings;
  fName : string;
  fKeywordListNumber : Integer;
  procedure SetKeywords(const Value: TStrings);
  procedure SetName(const Value: string);
  procedure SetKeywordListNumber(const Value: Integer);
protected
  function GetDisplayName: string; override;
public
  constructor Create(Collection: TCollection); override;
  destructor Destroy; override;
  procedure Assign(Source: TPersistent); override;
  procedure AssignRec(Rec : TSciLangKeywords);
  procedure AssignToRec(var Rec : TSciLangKeywords);
published
  property KeywordListNumber : Integer read FKeywordListNumber write SetKeywordListNumber;
  property Name : string read fName write SetName;
  property Keywords : TStrings read fKeywords write SetKeywords;
end;

TSciKeyWordsList = class(TOwnedCollection)
private
  fEditor : TPersistent; //TScintilla
  procedure SetEditor(Editor : TPersistent);
  function GetItem(Index:Integer): TSciKeywords;
  procedure SetItem(Index:Integer; Value: TSciKeywords);
public
  function Add: TSciKeywords;
  procedure Update(Item: TCollectionItem); override;
  function HasList(const KeywordListNumber : LongInt) : Boolean;
  function GetKeywordList(const KeywordListNumber : LongInt) : TSciKeywords;
  property Items[Index : Integer] : TSciKeywords read GetItem write SetItem;default;
end;


TSciLangItem = class(TCollectionItem)
private
  fLexer : String;
  fStyles : TSciStyleList;
  fKeyWords : TSciKeyWordsList;
  fLanguageName : String;
  fEditor : TPersistent; //TScintilla
  fExtraData : Pointer;
  fAssignmentOperator : String;
  fEndOfStatementOperator : String;
  FCommentBoxStart,FCommentBoxMiddle,FCommentBoxEnd,FCommentBlock,
  FCommentStreamStart,FCommentStreamEnd : String;
  FCommentAtLineStart : Boolean;
  fNumStyleBits : Integer;

  procedure SetLexer(const Value: String);
  procedure SetName(const Value: string);
  procedure SetKeywordsList(const Value: TSciKeyWordsList);
  procedure SetStyleList(const Value: TSciStyleList);
  procedure SetNumStyleBits(const Value : Integer);

  procedure SetEditor(Value : TPersistent);
  procedure Update;
protected
  function GetDisplayName: string; override;
public
  constructor Create(Collection: TCollection); override;
  destructor Destroy; override;
  procedure Assign(Source: TPersistent); override;

  property ExtraData : Pointer read fExtraData write fExtraData;
published
  // The Language name
  property Name : string read fLanguageName write SetName;
  // The lexer to use with this language.
  property Lexer : String read fLexer write SetLexer;
  property Styles : TSciStyleList read fStyles write SetStyleList;
  property Keywords : TSciKeyWordsList read fKeyWords write SetKeywordsList;
  property AssignmentOperator : String read fAssignmentOperator write fAssignmentOperator;
  property EndOfStatementOperator : String read FEndOfStatementOperator write FEndOfStatementOperator;
  property CommentBoxStart : String read FCommentBoxStart write FCommentBoxStart;
  property CommentBoxEnd : String read FCommentBoxEnd write FCommentBoxEnd;
  property CommentBoxMiddle : String read FCommentBoxMiddle write FCommentBoxMiddle;
  property CommentBlock : String read FCommentBlock write FCommentBlock;
  property CommentAtLineStart : Boolean read FCommentAtLineStart write FCommentAtLineStart;
  property CommentStreamStart : String read FCommentStreamStart write FCommentStreamStart;
  property CommentStreamEnd : String read FCommentStreamEnd write FCommentStreamEnd;
  property NumStyleBits : Integer read fNumStyleBits write SetNumStyleBits;
end;

TSciLangList = class(TOwnedCollection)
  private
    fEditor : TPersistent; //TScintilla
    procedure SetEditor(Editor : TPersistent);
    function GetItem(Index:Integer): TSciLangItem;
    procedure SetItem(Index:Integer; Value: TSciLangItem);
  public
    function Add: TSciLangItem;
    procedure Select(const fLanguage : String);
    function Find(const fLanguage : String) : TSciLangItem;
    function GetStyleList(const fLanguage : String;const fLexerName : String='';const DontCopyNullStyles : Boolean=False) : TSciLangItem;
    property Items[Index : Integer] : TSciLangItem read GetItem write SetItem;default;
  end;

  TSCEvent_lexupdate = procedure(Sender : TObject; Editor : TPersistent;lang : String;Item : TSciLangItem) of object;
  sciLexerSelectType=(sciLexers,sciLanguages);
  sciLexerSelectTypes=set of sciLexerSelectType;

  {$Ifndef LMSTANDALONE}
  TSciLanguageManager = class (TPersistent)
  {$Else}
  TSciLanguageManager = class (TComponent)
  {$Endif}
  private
    fEditor : TPersistent; //TScintilla
    fSelectedLanguage : String;
    fLanguages : TSciLangList;
    flexerlist : TStrings;
    fExtraData : Pointer;
    fOnLanguageChanged : TSCEvent_languagechanged;
    fOnLexUpdate : TSCEvent_lexupdate;
    fUpdating : Boolean;
    fUpdateCounter : Integer;
{$Ifdef LMSTANDALONE}
    fNotifyList : TList;
{$Endif}
    procedure SetLanguageList(const Value : TSciLangList);
    procedure SetSelectedLanguage(const Value : String);
    {Retrieve the lexer corresponding to the 'Lang'}
    function LangToLex(const Lang : String) : String;
    procedure FillLexerNameMap;
  protected
{$Ifndef LMSTANDALONE}
    function GetOwner: TPersistent; override;
{$Endif}
  public
{$Ifndef LMSTANDALONE}
    constructor Create(Editor: TPersistent);
{$Else}
    constructor Create(AOwner : TComponent);override;
    procedure AddNotification(Editor : TPersistent);
    procedure RemoveNotification(Editor : TPersistent);
{$Endif}
    destructor Destroy; override;
    procedure Assign(Source: TPersistent); override;
    procedure Update;
    procedure BeginUpdate;
    procedure EndUpdate;
    procedure FillListWithLanguages(lst : TStrings;const which : sciLexerSelectTypes=[sciLexers,sciLanguages]);
    procedure AddLexer(const Lexer : String);
    function  HasLexer(const Lexer : String) : Boolean;
    procedure RemoveLexer(const Lexer : String);

    function AddLanguage(const Lang,Lexer : String) : TSciLangItem;
    function DupLanguage(const Langtocopy : String;const langname : String='') : TSciLangItem;
    function RemoveLanguage(const Langtoremove : String;var notinstaticlist : Boolean) : Boolean;
    function HasLanguage(const LanguageName : String) : Boolean;

    procedure SortAll(const Ascending : Boolean=True);

    property ExtraData : Pointer read fExtraData write fExtraData;
{$Ifndef LMSTANDALONE}
    property Owner : TPersistent read fEditor;
{$Endif}
  published
    property LanguageList : TSciLangList read fLanguages write SetLanguageList;
    property SelectedLanguage : String read fSelectedLanguage write SetSelectedLanguage;
    property OnLanguageChanged : TSCEvent_languagechanged read fOnLanguageChanged write fOnLanguageChanged;
    property OnLexUpdate : TSCEvent_lexupdate read fOnLexUpdate write fOnLexUpdate;
  end;

  {Returns True if Style1 and Style2 is exactly equal, except Name and StyleNumber}
  function IsSameStyle(Style1,Style2 : TSciStyle) : Boolean; overload;
  function IsSameStyle(Style1,Style2 : TSciLangStyle) : Boolean; overload;
const
  cContainerLexer='container';
  cDefaultLexer='null';
implementation
Uses
	SciSupport,SciLexer,SciLexerMod,SciResLang,sciUtils,Windows
{$Ifdef DEBUGSTYLEPROP}
  ,TypInfo,Forms
{$Endif}
	;

{TSciLangList}

function TSciLangList.GetItem(Index:Integer): TSciLangItem;
begin
  Result:=TSciLangItem(inherited GetItem(Index));
end;

procedure TSciLangList.SetItem(Index:Integer; Value: TSciLangItem);
begin
  inherited SetItem(Index,Value);
end;

function TSciLangList.Add: TSciLangItem;
begin
  Result:=TSciLangItem(inherited Add);
end;

procedure TSciLangList.SetEditor(Editor : TPersistent);
var
  i : Integer;
begin
  try
    BeginUpdate;
    self.fEditor:=Editor;
    for i := 0 to Count - 1 do
    begin
      Items[i].SetEditor(Editor);
    end;
  finally
    EndUpdate;
  end;
end;


function TSciLangList.Find(const fLanguage : String) : TSciLangItem;
var
  i : Integer;
begin
  for i := 0 to Count - 1 do
  begin
    if AnsiCompareStr(Items[i].Name,fLanguage)=0 then
    begin
      Result :=Items[i];
      Exit;
    end;
  end;
  Result :=nil;
end;

procedure TSciLangList.Select(const fLanguage : String);
var
  itm : TSciLangItem;
begin
  if not assigned(fEditor) then Exit;
  itm:=Find(fLanguage);
  if itm<>nil then itm.Update;
end;

function TSciLangList.GetStyleList(const fLanguage : String;const fLexerName : String;const DontCopyNullStyles : Boolean) : TSciLangItem;
var
  tmp : TSciLangItem;
  nullitm : TSciLangItem;
begin
  tmp:=Find(fLanguage);
  if tmp<>nil then
  begin
    Result:=tmp;
    if (fLexerName<>'') and (tmp.Lexer<>fLexerName) then
    tmp.Lexer:=fLexerName;
    Exit;
  end;
  tmp:=Add;
  nullitm:=Find(cDefaultLexer);
  if assigned(nullitm) then
  begin
    try
      tmp.Styles.BeginUpdate;
      if fEditor<>nil then tmp.SetEditor(fEditor);
      if DontCopyNullStyles=False then
        tmp.Styles.Assign(nullitm.Styles);
      tmp.Name:=fLanguage;
      if fLexerName='' then
        tmp.Lexer:=fLanguage
      else
        tmp.Lexer:=fLexerName;
    finally
      tmp.Styles.EndUpdate;
    end;
  end else
  begin
    tmp.Name:=cDefaultLexer;
    tmp.Lexer:=cDefaultLexer;
    tmp:=GetStyleList(fLanguage);
  end;
  Result:=tmp;
end;

{TSciLangItem}
constructor TSciLangItem.Create(Collection: TCollection);
begin
  inherited;
  fStyles:=TSciStyleList.Create(Self,TSciStyle);
  fKeyWords:=TSciKeyWordsList.Create(Self,TSciKeywords);
  fLanguageName := sLMLanguage+'['+IntToStr(Index)+']';
  fLexer :=cDefaultLexer;
  fNumStyleBits:=5;
  fExtraData:=nil;
  fAssignmentOperator:='=';
  fEndOfStatementOperator:=';';
  FCommentBoxStart:='/*';
  FCommentBoxMiddle:='*';
  FCommentBoxEnd:='*/';
  FCommentBlock:='//';
  FCommentStreamStart:='/*';
  FCommentStreamEnd:='*/';
  FCommentAtLineStart:=True;
end;

destructor TSciLangItem.Destroy;
begin
  inherited;
  if assigned(fStyles) then FreeAndNil(fStyles);
  if assigned(fKeyWords) then FreeAndNil(fKeyWords);
end;

procedure TSciLangItem.Assign(Source: TPersistent);
begin
  if Source is TSciLangItem then
  begin
    fLanguageName := TSciLangItem(Source).Name;
    fStyles.Assign(TSciLangItem(Source).Styles);
    fKeywords.Assign(TSciLangItem(Source).Keywords);
    fLexer:=TSciLangItem(Source).Lexer;
    fExtraData:=TSciLangItem(Source).ExtraData;
    fAssignmentOperator:=TSciLangItem(Source).AssignmentOperator;
    fEndOfStatementOperator:=TSciLangItem(Source).EndOfStatementOperator;
    FCommentBoxStart:=TSciLangItem(Source).CommentBoxStart;
    FCommentBoxMiddle:=TSciLangItem(Source).CommentBoxMiddle;
    FCommentBoxEnd:=TSciLangItem(Source).CommentBoxEnd;
    FCommentBlock:=TSciLangItem(Source).CommentBlock;
    FCommentAtLineStart :=TSciLangItem(Source).CommentAtLineStart;
    FCommentStreamStart:=TSciLangItem(Source).CommentStreamStart;
    FCommentStreamEnd:=TSciLangItem(Source).CommentStreamEnd;
    fNumStyleBits:=TSciLangItem(Source).NumStyleBits;
  end else
    inherited;
end;

function TSciLangItem.GetDisplayName: string;
begin
  Result:=fLanguageName;
end;

procedure TSciLangItem.Update;
begin
  fKeyWords.Update(nil);
  fStyles.Update(nil);
  if fEditor<>nil then
  begin
    TScintilla(fEditor).Colourise(0, -1);
  end;
end;

procedure TSciLangItem.SetNumStyleBits(const Value : Integer);
begin
  fNumStyleBits:=Value;
  Changed(false);
end;

procedure TSciLangItem.SetEditor(Value : TPersistent);
begin
  fEditor:=Value;
  Styles.SetEditor(fEditor);
  Keywords.SetEditor(fEditor);
end;

procedure TSciLangItem.SetName(const Value: string);
begin
  fLanguageName:=Value;
  Changed(false);
end;

procedure TSciLangItem.SetLexer(const Value: String);
begin
  if(fLexer<>Value) then
  begin
    fLexer :=Value;
    Changed(false);
  end;
end;

procedure TSciLangItem.SetKeywordsList(const Value: TSciKeyWordsList);
begin
  fKeywords.Assign(Value);
  Changed(false);
end;

procedure TSciLangItem.SetStyleList(const Value: TSciStyleList);
begin
  fStyles.Assign(Value);
  Changed(false);
end;

{TSciKeywords}
constructor TSciKeywords.Create(Collection: TCollection);
begin
  fKeywords := TMyStringList.Create;
  inherited;
  fName := sLMKeywords+'['+IntToStr(Index)+']';
end;

destructor TSciKeywords.Destroy;
begin
  FreeAndNil(fKeywords);
  inherited;
end;

function TSciKeywords.GetDisplayName: string;
begin
  Result:=Name;
end;

procedure TSciKeywords.Assign(Source: TPersistent);
begin
  if Source is TSciKeywords then
  begin
    fName := TSciKeywords(Source).Name;
    fKeyWordListNumber := TSciKeywords(Source).KeywordListNumber;
    fKeywords.Assign(TSciKeywords(Source).Keywords);
  end else
    inherited;
end;

procedure TSciKeywords.AssignToRec(var Rec : TSciLangKeywords);
begin
  Rec.Name :=fName;
  Rec.KeywordListNumber:=fKeywordListNumber;
  Rec.KeyWords :=fKeywords.Text;
end;

procedure TSciKeywords.AssignRec(Rec : TSciLangKeywords);
begin
  fName := Rec.Name;
  fKeywordListNumber := Rec.KeywordListNumber;
{$Ifdef COMPILER6_UP}
  fKeywords.Delimiter := ' ';
  fKeywords.DelimitedText := Rec.KeyWords;
{$Else}
  fKeywords.Text := Rec.KeyWords;
{$Endif}
end;

procedure TSciKeywords.SetKeywordListNumber(const Value: Integer);
begin
  FKeywordListNumber := Value;
  Changed(False);
end;

procedure TSciKeywords.SetKeywords(const Value: TStrings);
begin
  fKeyWords.Assign(Value);
  Changed(False);
end;

procedure TSciKeywords.SetName(const Value: string);
begin
  fName := Value;
  Changed(False);
end;

{TSciKeyWordsList}
function TSciKeyWordsList.GetItem(Index:Integer): TSciKeywords;
begin
  Result:=TSciKeywords(inherited GetItem(Index));
end;

procedure TSciKeyWordsList.SetItem(Index:Integer; Value: TSciKeywords);
begin
  inherited SetItem(Index,Value);
end;

procedure TSciKeyWordsList.Update(Item: TCollectionItem);
Var
  i : Integer;
begin
  inherited;
  if not Assigned(fEditor) then Exit;
  if Assigned(Item) then with (Item as TSciKeywords) do
  begin
{$Ifdef COMPILER6_UP}
    Keywords.Delimiter := ' ';
    TScintilla(fEditor).SetKeywords(KeywordListNumber, PChar(Keywords.DelimitedText));
{$Else}
    TScintilla(fEditor).SetKeywords(KeywordListNumber, PChar(MergeStrings(Keywords)));
{$Endif}
  end else
  begin
    for i := 0 to Count - 1 do with (Items[i] as TSciKeywords) do
    begin
{$Ifdef COMPILER6_UP}
      Keywords.Delimiter := ' ';
      TScintilla(fEditor).SetKeywords(KeywordListNumber, PChar(Keywords.DelimitedText));
{$Else}
      TScintilla(fEditor).SetKeywords(KeywordListNumber, PChar(MergeStrings(Keywords)));
{$Endif}
    end;
  end;
end;

function TSciKeyWordsList.Add: TSciKeywords;
begin
  Result:=TSciKeywords(inherited Add);
end;

function TSciKeyWordsList.GetKeywordList(const KeywordListNumber : LongInt) : TSciKeywords;
var
  i,cnt : Integer;
begin
  Result:=nil;
  cnt:=Count;
  for i:=0 to (cnt-1) do
  begin
    if Items[i].fKeywordListNumber=KeywordListNumber then
    begin
      Result:=Items[i];
      Exit;
    end;
  end;
end;

function TSciKeyWordsList.HasList(const KeywordListNumber : LongInt) : Boolean;
var
  i,cnt : Integer;
begin
  Result:=False;
  cnt:=Count;
  for i:=0 to (cnt-1) do
  begin
    if Items[i].fKeywordListNumber=KeywordListNumber then
    begin
      Result:=True;
      Exit;
    end;
  end;
end;

procedure TSciKeyWordsList.SetEditor(Editor: TPersistent);
begin
  self.fEditor := Editor;
end;

{TSciStyle}
constructor TSciStyle.Create(Collection: TCollection);
begin
  inherited;
  fStyleNumber := Index;
  FCharSet:=-1;
  fName := sLMStyle+'['+IntToStr(Index)+']';
  fFontName := '';
  fFontSize := 0;
  fFontStyles:=[];
  fCharCase:=CASE_MIXED;
  fForeColor := clDefault;
  fBackColor := clDefault;
  fVisible := True;
  fEOLFilled := False;
  fChangeable := True;
	fHotSpot := False;
end;

procedure TSciStyle.Assign(Source: TPersistent);
begin
	if Source is TSciStyle then
	begin
{$Ifdef DEBUGSTYLEPROP}
		try
{$Endif}
		fStyleNumber := TSciStyle(Source).StyleNumber;
		fName := TSciStyle(Source).Name;
		fFontName := TSciStyle(Source).FontName;
		fFontSize := TSciStyle(Source).FontSize;
		fFontStyles := TSciStyle(Source).FontStyles;
		fForeColor :=TSciStyle(Source).ForeColor;
		fBackColor := TSciStyle(Source).BackColor;
		fCharCase := TSciStyle(Source).CharCase;
		fVisible := TSciStyle(Source).Visible;
		fChangeable := TSciStyle(Source).Changeable;
		fHotspot := TSciStyle(Source).HotSpot;
		fEOLFilled := TSciStyle(Source).EOLFilled;
		FCharSet:= TSciStyle(Source).CharSet;
{$Ifdef DEBUGSTYLEPROP}
	except
		on E: EPropertyError do
			Application.MessageBox(PChar(E.Message),'ASSIGNREC',MB_OK);
		on E: EPropertyConvertError do
			Application.MessageBox(PChar(E.Message),'CONVERTERROR - ASSIGNREC',MB_OK);
	end;
{$Endif}

	end else
		inherited;
end;

procedure TSciStyle.AssignRec(Rec: TSciLangStyle);
begin
{$Ifdef DEBUGSTYLEPROP}
	try
{$Endif}
		fStyleNumber := Rec.StyleNumber;
		fName := Rec.Name;
		fFontName := Rec.FontName;
		fFontSize := Rec.FontSize;
		fFontStyles := Rec.FontStyles;
		fForeColor :=Rec.ForeColor;
		fBackColor := Rec.BackColor;
		fCharCase := Rec.CharCase;
		fVisible := Rec.Visible;
		fChangeable := Rec.Changeable;
		fHotspot := Rec.Hotspot;
		fEOLFilled := Rec.EOLFilled;
		FCharSet:=Rec.CharSet;
{$Ifdef DEBUGSTYLEPROP}
	except
		on E: EPropertyError do
			Application.MessageBox(PChar(E.Message),'ASSIGNREC',MB_OK);
		on E: EPropertyConvertError do
			Application.MessageBox(PChar(E.Message),'CONVERTERROR - ASSIGNREC',MB_OK);

	end;
{$Endif}
end;

procedure TSciStyle.AssignToRec(var Rec : TSciLangStyle);
begin
	Rec.StyleNumber:=fStyleNumber;
	Rec.Name:=fName;
	Rec.FontName :=fFontName;
	Rec.FontSize :=fFontSize;
	Rec.FontStyles :=fFontStyles;
  Rec.ForeColor :=fForeColor;
  Rec.BackColor :=fBackColor;
  Rec.CharCase :=fCharCase;
  Rec.Visible :=fVisible;
  Rec.Changeable :=fChangeable;
  Rec.Hotspot :=fHotspot;
  Rec.EOLFilled :=fEOLFilled;
  Rec.CharSet:=FCharSet;
end;

function TSciStyle.GetDisplayName: string;
begin
  Result:=Name;
end;

procedure TSciStyle.SetCharSet(const Value : Integer);
begin
  fCharSet:=Value;
  Changed(False);
end;

procedure TSciStyle.SetBackColor(const Value: TColor);
begin
  fBackColor := Value;
  Changed(False);
end;

procedure TSciStyle.SetChangeable(const Value: Boolean);
begin
  fChangeable := Value;
  Changed(False);
end;

procedure TSciStyle.SetCharCase(const Value: TSciCase);
begin
  fCharCase := Value;
  Changed(False);
end;

procedure TSciStyle.SetEOLFilled(const Value: Boolean);
begin
  fEOLFilled := Value;
  Changed(False);
end;

procedure TSciStyle.SetFontName(const Value: string);
begin
  fFontName := Value;
  Changed(False);
end;

procedure TSciStyle.SetFontSize(const Value: Integer);
begin
  fFontSize := Value;
  Changed(False);
end;

procedure TSciStyle.SetFontStyles(const Value: TFontStyles);
begin
  FFontStyles := Value;
  Changed(False);
end;

procedure TSciStyle.SetForeColor(const Value: TColor);
begin
  fForeColor := Value;
  Changed(False);
end;

procedure TSciStyle.SetHotspot(const Value: Boolean);
begin
  fHotSpot := Value;
  Changed(False);
end;

procedure TSciStyle.SetName(const Value: string);
begin
  fName := Value;
  Changed(False);
end;

procedure TSciStyle.SetStyleNumber(const Value: Integer);
begin
  fStyleNumber := Value;
  Changed(False);
end;

procedure TSciStyle.SetVisible(const Value: Boolean);
begin
  fVisible := Value;
  Changed(False);
end;

{TSciStyleList}
function TSciStyleList.GetItem(Index:Integer): TSciStyle;
begin
  Result:=TSciStyle(inherited GetItem(Index));
end;

procedure TSciStyleList.SetItem(Index:Integer; Value: TSciStyle);
begin
  inherited SetItem(Index,Value);
end;

function TSciStyleList.Add: TSciStyle;
begin
  Result:=TSciStyle(inherited Add);
end;

procedure TSciStyleList.Update(Item: TCollectionItem);
Var
  i : Integer;
begin
  inherited;
  if not Assigned(fEditor) then Exit;
  if Assigned(Item) then with (Item as TSciStyle), TScintilla(fEditor) do
  begin
    if FCharSet<>-1 then StyleSetCharacterSet(StyleNumber, FCharSet);
    if fFontName <> '' then StyleSetFont(StyleNumber, PChar(fFontName));
    if fFontSize > 0 then StyleSetSize (StyleNumber, fFontSize);
    if fForeColor <> clDefault then StyleSetFore(StyleNumber, fForeColor);
    if fBackColor <> clDefault then StyleSetBack(StyleNumber, fBackColor);
    StyleSetBold(StyleNumber, fsBold in fFontStyles);
    StyleSetItalic(StyleNumber, fsItalic in fFontStyles);
    StyleSetUnderline(StyleNumber, fsUnderline in fFontStyles);
    StyleSetCase(StyleNumber, Ord(fCharCase));
    StyleSetVisible(StyleNumber, fVisible);
    StyleSetChangeable(StyleNumber, fChangeable);
    StyleSetHotSpot(StyleNumber, fHotSpot);
    StyleSetEOLFilled(StyleNumber, fEOLFilled);
  end else
  begin
    for i := 0 to Count - 1 do Update(Items[i]);
  end;
end;

function TSciStyleList.GetStyle(const StyleNumber : LongInt) : TSciStyle;
var
i,cnt : Integer;
begin
  Result:=nil;
  cnt:=Count;
  for i:=0 to (cnt-1) do
  begin
    if Items[i].fStyleNumber=StyleNumber then
    begin
      Result:=Items[i];
      Exit;
    end;
  end;
end;

function TSciStyleList.HasStyle(const StyleNumber : LongInt) : Boolean;
var
  i,cnt : Integer;
begin
  Result:=False;
  cnt:=Count;
  for i:=0 to (cnt-1) do
  begin
    if Items[i].fStyleNumber=StyleNumber then
    begin
      Result:=True;
      Exit;
    end;
  end;
end;

procedure TSciStyleList.SetEditor(Editor: TPersistent);
begin
  self.fEditor := Editor;
end;

{TSciLanguageManager}
{$Ifndef LMSTANDALONE}
constructor TSciLanguageManager.Create(Editor: TPersistent);
{$Else}
constructor TSciLanguageManager.Create(AOwner: TComponent);
{$Endif}
begin
  fUpdateCounter:=0;
  fUpdating:=False;
{$Ifndef LMSTANDALONE}
  inherited Create;
  fEditor := Editor;
{$Else}
  inherited Create(AOwner);
  fEditor := nil;
{$Endif}
  fExtraData:=nil;
  flexerlist:=TMyStringList.Create;
  TMyStringList(flexerlist).CaseSensitive:=True;
{$Ifdef LMSTANDALONE}
    fNotifyList:=TList.Create;
{$Endif}
  FillLexerNameMap;
  fSelectedLanguage:=cDefaultLexer;
  fLanguages:=TSciLangList.Create(self,TSciLangItem);
  fLanguages.SetEditor(fEditor);
end;

destructor TSciLanguageManager.Destroy;
begin
  FreeAndNil(fLanguages);
  FreeAndNil(flexerlist);
  inherited;
end;

procedure TSciLanguageManager.Assign(Source: TPersistent);
begin
  if (not assigned(Source)) then
  begin
    if assigned(fLanguages) then
    begin
      fLanguages.Clear;
      fLanguages.GetStyleList(cDefaultLexer,cDefaultLexer,False); //Just ask for them to recreate the nullstyles..
    end;
    FillLexerNameMap;
    fSelectedLanguage:=cDefaultLexer;
    Update;
    if assigned(fOnLanguageChanged) then
      fOnLanguageChanged(self,fSelectedLanguage);
  end else
  if (Source is TSciLanguageManager) then
  begin
    try
      BeginUpdate;
      //fLexerNamesMapper.Assign(TSciLanguageManager(Source).fLexerNamesMapper);
      flexerlist.Assign(TSciLanguageManager(Source).flexerlist);
      fLanguages.Assign(TSciLanguageManager(Source).LanguageList);
      fSelectedLanguage := TSciLanguageManager(Source).SelectedLanguage;
      //fExtraData := TSciLanguageManager(Source).fExtraData;
    finally
      EndUpdate;
    end;
    if assigned(fOnLanguageChanged) then
      fOnLanguageChanged(self,fSelectedLanguage);
  end else
    inherited;
end;

{$Ifndef LMSTANDALONE}
function TSciLanguageManager.GetOwner : TPersistent;
begin
  Result:=fEditor;
end;
{$Endif}

procedure TSciLanguageManager.BeginUpdate;
begin
  Inc(fUpdateCounter);
end;
procedure TSciLanguageManager.EndUpdate;
begin
  Dec(fUpdateCounter);
  if fUpdateCounter<0 then
    fUpdateCounter:=0;
  if fUpdateCounter=0 then
    Update;
end;

procedure TSciLanguageManager.Update;
var
  itm : TSciLangItem;
  mappedstr : String;
  sbits : Integer;
begin
  inherited;
  if (not Assigned(fEditor)) or (fUpdating=True) or (fUpdateCounter>0) then Exit;
  try
    try
      fUpdating:=True;
      with TScintilla(fEditor) do
      begin
        mappedstr:=LangToLex(fSelectedLanguage);
        if AnsiCompareText(mappedstr,cContainerLexer)=0 then
        begin
          SetLexer(SCLEX_CONTAINER);
          StyleClearAll;
          if assigned(fOnLexUpdate) then //
            fOnLexUpdate(Self,fEditor,fSelectedLanguage,nil);//
        end else
        begin
          SetLexerLanguage(PChar(mappedstr));
          if (AnsiCompareStr(mappedstr,'xml')=0) then
          begin
            SetProperty('html.tags.case.sensitive','1');
          end else if (AnsiCompareStr(mappedstr,'hypertext')=0) then
          begin
            SetProperty('html.tags.case.sensitive','0');
          end;
          fLanguages.SetEditor(fEditor);
          itm:=fLanguages.GetStyleList(fSelectedLanguage);
          ClearDocumentStyle;

          if itm.fNumStyleBits>-1 then
            SetStyleBits(itm.fNumStyleBits)
          else
          begin
            sbits:=TScintillaBase(fEditor).GetStyleBitsNeeded;
            if (sbits>0) and (sbits<=8) then
              SetStyleBits(sbits)
            else
            begin
              itm.fNumStyleBits:=5;
              SetStyleBits(5);
            end;
          end;
          StyleClearAll;

          // If assigned, perform other updates in the event.
          if assigned(fOnLexUpdate) then fOnLexUpdate(Self,fEditor,fSelectedLanguage,itm);
          itm.Update;
        end;
      end;
      if AnsiCompareText(mappedstr,cContainerLexer)<>0 then
      begin
        fLanguages.SetEditor(fEditor);
        itm:=fLanguages.GetStyleList(fSelectedLanguage);
        // If assigned, perform other updates in the event.
        if assigned(fOnLexUpdate) then fOnLexUpdate(Self,fEditor,fSelectedLanguage,itm);
        itm.Update;
      end else
        if assigned(fOnLexUpdate) then
          fOnLexUpdate(Self,fEditor,fSelectedLanguage,nil);
    finally
      fUpdating:=False;
    end;
  except
    raise;
  end;
end;


{$Ifdef LMSTANDALONE}
procedure TSciLanguageManager.AddNotification(Editor : TPersistent);
begin
  inherited;
  fNotifyList.Add(Editor);
end;
procedure TSciLanguageManager.RemoveNotification(Editor : TPersistent);
begin
  inherited;
  fNotifyList.Remove(Editor);
end;
{$Endif}

function TSciLanguageManager.LangToLex(const Lang : String) : String;
var
  i : Integer;
  cnt : Integer;
begin
  if (Lang='') or (AnsiCompareText(Lang,cContainerLexer)=0) then
  begin
    Result:=cContainerLexer;
  end;
  if fLanguages<>nil then
  begin
    cnt:=fLanguages.Count;
    for i:=0 to (cnt-1) do
    begin
      if AnsiCompareStr(fLanguages.Items[i].Name,Lang)=0 then
      begin
        Result:=fLanguages.Items[i].Lexer;
        Exit;
      end;
    end;
  end;
  Result:=Lang;
end;

procedure TSciLanguageManager.SetSelectedLanguage(const Value : String);
begin
  try
    BeginUpdate;
    fSelectedLanguage:=Value;
    if (AnsiCompareText(fSelectedLanguage,cContainerLexer)<>0) and (fSelectedLanguage<>'') then
      fLanguages.Select(Value);
  finally
    EndUpdate;
  end;
  if (assigned(fOnLanguageChanged)) then
    fOnLanguageChanged(self,Value);
end;

procedure TSciLanguageManager.FillListWithLanguages(lst : TStrings;const which : sciLexerSelectTypes);
var
  cnt : Integer;
  i : Integer;
  tmpstr : String;
begin
  if lst=nil then Exit;
  try
    lst.BeginUpdate;
    lst.Clear;
    if sciLexers in which then
    begin
      cnt:=flexerlist.Count;
      for i:=0 to (cnt-1) do
      begin
        tmpstr:=flexerlist.Strings[i];
        lst.Add(tmpstr);
      end;
    end;
    if (sciLanguages in which) then
    begin
      cnt:=fLanguages.Count;
      for i:=0 to (cnt-1) do
      begin
        tmpstr:=fLanguages.Items[i].Name;
        if lst.IndexOf(tmpstr)=-1 then
        lst.Add(tmpstr);
      end;
    end;
  finally
    lst.EndUpdate;
  end;
end;

function TSciLanguageManager.HasLexer(const Lexer : String) : Boolean;
begin
  Result:=flexerlist.IndexOf(Lexer)<>-1;
end;

procedure TSciLanguageManager.RemoveLexer(const Lexer : String);
var
  idx : Integer;
begin
  idx:=flexerlist.IndexOf(Lexer);
  if(idx<>-1) then
    flexerlist.Delete(idx);
end;

procedure TSciLanguageManager.AddLexer(const Lexer : String);
begin
  if flexerlist.IndexOf(Lexer)=-1 then
    flexerlist.Add(Lexer);
end;

procedure TSciLanguageManager.SetLanguageList(const Value : TSciLangList);
begin
  try
    BeginUpdate;
    fLanguages.Assign(Value);
  finally
    EndUpdate;
  end;
end;

function TSciLanguageManager.HasLanguage(const LanguageName : String) : Boolean;
begin
  Result:=False;
  if fLanguages.Find(LanguageName)<>nil then
    Result:=True;
  Exit;
end;

procedure TSciLanguageManager.FillLexerNameMap;
begin
{Fill the namelist with all the lexers we have}
  if assigned(flexerlist) and (flexerlist.Count>0) then
    flexerlist.Clear;
  with flexerlist do
  begin
    Add('ada');//ADA
    Add('asm');
    Add('ave');
    Add('batch');
    Add('bullant');
    Add('baan');
    {0.23 - Changed clw(nocase) to clarion(nocase)}
    Add('clarion');
    Add('clarionnocase');
    Add('conf');
    Add('cpp');
    Add('cppnocase');
    Add('css');
    Add('diff');
    Add('eiffel');
    Add('eiffelkw');
    Add('email');
    Add('erlang');
    Add('errorlist');
    Add('escript');
    Add('f77');
    Add('forth');
    Add('fortran');
    Add('freebasic');
    Add('hypertext');
    Add('latex');
    Add('lisp');
    Add('lot');
    Add('lout');
    Add('lua');
    Add('makefile');
    Add('matlab');
    Add('metapost');
    Add('mmixal');
    Add('nncrontab');
    Add('nsis');
    Add('octave');
    Add('pascal');
    Add('perl');
    Add('pov');
    Add('powerbasic');
    Add('props');
    Add('ps');
    Add('python');
    Add('ruby');
    Add('scriptol');
    Add('sql');
    Add('tcl');
    Add('tex');
    Add('vb');
    Add('vbscript');
    Add('verilog');
    Add('xml');
    Add('yaml');
    //New in v1.59
    Add('mssql');
    //New in v1.60
    Add('gui4cli');
    Add('kix');
    Add('specman');
    Add('au3');
    Add('apdl');
    Add('bash');
    //New in v1.62
    Add('asn1');
    Add('vhdl');
    Add('phpscript');
    //New in v1.63
    Add('purebasic');
    Add('blitzbasic');
    Add('caml');
    Add('haskell');
    //New in v1.64
    Add('flagship');
    Add('csound');
    Add('tads3');
    Add('smalltalk');
    Add('rebol');
    //New in v1.67 CVS
    Add('inno');
    Add('opal');
    //New in v1.68 CVS
    Add('spice');

    // Include more lexers, if there are some added by a developer
    // for easy maintaining..
    {$INCLUDE morelexers.inc}
  end;
end;

function TSciLanguageManager.AddLanguage(const Lang,Lexer : String) : TSciLangItem;
var
  itm : TSciLangItem;
begin
  itm:=fLanguages.GetStyleList(Lang,Lexer);
  Result:=itm;
end;

function TSciLanguageManager.DupLanguage(const Langtocopy : String;const langname : String) : TSciLangItem;
var
  itm : TSciLangItem;
  src : TSciLangItem;
begin
  src:=fLanguages.Find(Langtocopy);
  if src<>nil then
  begin
  itm:=fLanguages.Add;
  itm.Assign(src);
  end else itm:=nil;
  Result:=itm;
end;

function TSciLanguageManager.RemoveLanguage(const Langtoremove : String;var notinstaticlist : Boolean) : Boolean;
var
  itm : TSciLangItem;
begin
  itm:=fLanguages.Find(Langtoremove);
  if itm<>nil then
  begin
    if flexerlist.IndexOf(Langtoremove)<>-1 then
    begin
      notinstaticlist:=False;
      if (Langtoremove<>cDefaultLexer) and (Langtoremove<>'container') then
        fLanguages.Delete(itm.Index);
    end else
    begin
      fLanguages.Delete(itm.Index);
      notinstaticlist:=True;
    end;
    Result:=True;
    Exit;
  end;
  Result:=false;
end;

function LangListCompFunc(Item1, Item2: Pointer): Integer;
var
 itm1,itm2 : TCollectionItem;
begin
  itm1:=Item1;
  itm2:=Item2;
  Result:=0;
  if itm1 is TSciStyle then
  begin
    if TSciStyle(itm1).StyleNumber>TSciStyle(itm2).StyleNumber then
      Result:=1
    else if TSciStyle(itm1).StyleNumber<TSciStyle(itm2).StyleNumber then
      Result:=-1;
  end else if itm1 is TSciKeywords then
  begin
    if TSciKeywords(itm1).KeywordListNumber>TSciKeywords(itm2).KeywordListNumber then
      Result:=1
    else if TSciKeywords(itm1).KeywordListNumber<TSciKeywords(itm2).KeywordListNumber then
      Result:=-1;
  end else if itm1 is TSciLangItem then
  begin
   Result:=CompStr(TSciLangItem(itm1).Name,TSciLangItem(itm2).Name);
  end;
end;

procedure TSciLanguageManager.SortAll(const Ascending : Boolean);
var
  langitm : TSciLangItem;
  i,cnt : Integer;
begin
  try
    if Owner<>nil then
      BeginUpdate;
    fLanguages.BeginUpdate;
    SortCollection(fLanguages,LangListCompFunc,Ascending);
    cnt:=fLanguages.Count;
    for i:=0 to (cnt-1) do
    begin
      langitm:=fLanguages.Items[i];
      try
        langitm.Styles.BeginUpdate;
        langitm.Keywords.BeginUpdate;
        SortCollection(langitm.Styles,LangListCompFunc,Ascending);
        SortCollection(langitm.Keywords,LangListCompFunc,Ascending);
      finally
        langitm.Styles.EndUpdate;
        langitm.Keywords.EndUpdate;
      end;
    end;
  finally
    fLanguages.EndUpdate;
    if Owner<>nil then
      EndUpdate;
  end;
end;

function IsSameStyle(Style1,Style2 : TSciStyle) : Boolean;
begin
  Result:=((Style1.FontName=Style2.FontName) and
  (Style1.FontSize=Style2.FontSize) and
  (Style1.FontStyles=Style2.FontStyles) and
  (Style1.ForeColor=Style2.ForeColor) and
  (Style1.BackColor=Style2.BackColor) and
  (Style1.CharCase=Style2.CharCase) and
  (Style1.Visible=Style2.Visible) and
  (Style1.Changeable=Style2.Changeable) and
  (Style1.EOLFilled=Style2.EOLFilled) and
  (Style1.Hotspot=Style2.Hotspot) and
  (Style1.CharSet=Style2.CharSet));
end;

function IsSameStyle(Style1,Style2 : TSciLangStyle) : Boolean;
begin
  Result:=((Style1.FontName=Style2.FontName) and
  (Style1.FontSize=Style2.FontSize) and
  (Style1.FontStyles=Style2.FontStyles) and
  (Style1.ForeColor=Style2.ForeColor) and
  (Style1.BackColor=Style2.BackColor) and
  (Style1.CharCase=Style2.CharCase) and
  (Style1.Visible=Style2.Visible) and
  (Style1.Changeable=Style2.Changeable) and
  (Style1.EOLFilled=Style2.EOLFilled) and
  (Style1.Hotspot=Style2.Hotspot) and
  (Style1.CharSet=Style2.CharSet));
end;
end.
Added src/delphisci/morelexers.inc.










































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
{ Add more lexernames here, if there are more lexers in your version of 'SciLexer.Dll',
  i.e new version, custombuilt or other..

  All lexers which are added here is also selectable from within the IDE.

  If you wish to add those lexers at runtime, use AddLexer.
  That function checks whether a lexer already exists, and if not, adds it to the list.

  These will show up in the OptionsDialog (when you use Add language)
  when the dialog is called after they are added.

  NOTE: As the scintilla control treats the lexers casesensitive, this is also casesensitive.
  As new versions of the component is released, and new lexers are added in the main distro of
  the Scintilla project, the list of lexers will be updated in this include's parent file
  (ScintillaLanguageManager.pas). The reason for this includefile is to allow
  easy maintaining (for developers) of this file between versions..
}

{
  Add('blitzbasic');
}
Added src/delphisci/sciAbbrevationManager.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
  Created: 24/11/2004, 18:21:20
  History: 26/11/2004 Initial Release
           09/01/2005 Added expansion of a template inside another (if AllowTemplateMacros is True)
                      Use <^nameoftemplate> to include one template inside another.. It keeps
                      expanding until no more expansion are possible.. If a templatename isn't found
                      it just removes the templateinclusion i.e <^whatever>, and continues expanding the rest..
           10/01/2005 Added the event OnTemplateMacro to match a templatemacro with something builtin.. All of these
                      starts with <^- instead.. Two is implemented here.. PROMPT prompt|caption  and ROW (Returns linenumber).
           15/06/2005 BUG: Fixed a small problem which caused the || to be correctly treated as a |, but the following single | wasn't
                      treated as a position.
                      More preparation to move to a new templatestructure, instead of just simple strings.
                      This is to allow descriptions and such for each template.
      $Id:  $

}
{$Include SciCommonDef.Inc}
unit sciAbbrevationManager;
interface
uses Classes,SciLexerMemo;
type
TSCEvent_templatemacro = procedure(Sender : TObject; const MacroName : String;Params : String;var RetVal : String) of object;
{$Ifdef NEWABBREVS}
  TTemplateItem=class(TCollectionItem)
  private
    FTemplateName : String;
    FTemplate : String;
    FDescription : String;
    procedure SetTemplateName(const Value : String);
    procedure SetTemplate(const Value : String);
    procedure SetDescription(const Value : String);
  protected
    function GetDisplayName: string;override;
  published
    property TemplateName : String read FTemplateName write SetTemplateName;
    property Template : String read FTemplate write SetTemplate;
    property Description : String read FDescription write SetDescription;
  end;

  TTemplateList=class(TOwnedCollection)
  protected
    procedure SetItem(Index:Integer; Value: TTemplateItem);
    function GetItem(Index:Integer): TTemplateItem;
    procedure SetString(Index : Integer;Value : String);
    function GetString(Index : Integer) : String;
  public
    constructor Create(AOwner : TComponent;ItemClass : TCollectionItemClass);
    procedure LoadFromStream(Stream : TStream);
    procedure SaveToStream(Stream : TStream);

    function IndexOf(const TemplateName : String) : Integer;
    property Items[Index : Integer] : TTemplateItem read GetItem write SetItem;default;
    //property Strings[Index : Integer] : String read GetString write SetString;
    function Add: TTemplateItem;
  end;
{$Endif}

TSciAbbrevManager=class(TComponent)
  private
    fEditor : TScintillaMemo;
    fOnTemplateMacro : TSCEvent_templatemacro;
{$Ifndef NEWABBREVS}
    fAbbrevs : TStrings;
{$Else}
    fAbbrevs : TTemplateList;
{$Endif}
    fIgnoreCase : Boolean;
    fAllowTemplateMacros : Boolean;
{$Ifndef NEWABBREVS}
    procedure SetAbbrevs(Value : TStrings);
{$Else}
    procedure SetAbbrevs(Value : TTemplateList);
{$Endif}
    procedure SetIgnoreCase(const Value : Boolean);
    procedure ExpandMatchingTemplates(var s : String);
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
    function ProcessMacro(const MacroName : String;Params : String) : String;virtual;
  public
    procedure ExpandAbbrev;
    constructor Create(AOwner : TComponent);override;
    destructor Destroy;override;
  published
{$Ifndef NEWABBREVS}
    property Abbrevations : TStrings read fAbbrevs write SetAbbrevs;
{$Else}
    property Abbrevations : TTemplateList read fAbbrevs write SetAbbrevs;
{$Endif}
    property Editor : TScintillaMemo read fEditor write fEditor;
    property IgnoreCase : Boolean read fIgnoreCase write SetIgnoreCase default False;
    property AllowTemplateMacros : Boolean read FAllowTemplateMacros write FAllowTemplateMacros default True;
    property OnTemplateMacro : TSCEvent_templatemacro read fOnTemplateMacro write fOnTemplateMacro;
end;

implementation
uses SciSupport,SciLexer,SysUtils,sciUtils,SciResLang,Dialogs,Windows;
{
const
  ABBREVRECSIGNATURE =$ddccff33;
  ABBREVSIGNATURE =$eeffaa11;
type
  TAbbrevHeaderRec=record
    Signature : Cardinal;
    Count : Integer;
  end;

  TAbbrevRec=record
    TemplateName : String;
    Template : String;
    Description : String;
  end;

function ReadAbbrevRec(Stream : TStream;var Rec : TAbbrevRec) : Boolean;
var
  signature : Cardinal;
  function ReadStreamStr(Stream : TStream) : String;
  var
    tmp : String;
    len : Integer;
  begin
    Result:='';
    if Stream.Read(len,SizeOf(Integer))=SizeOf(Integer) then
    begin
      if (len>0) then
      begin
        SetLength(tmp,len);
        Stream.Read(PChar(tmp)^,len);
        Result:=tmp;
      end;
    end;
  end;
begin
  Result:=False;
  if Stream.Read(signature,SizeOf(Cardinal))=SizeOf(Cardinal) then
  begin
    if signature=ABBREVRECSIGNATURE then
    begin
      Rec.TemplateName:=ReadStreamStr(Stream);
      Rec.Template:=ReadStreamStr(Stream);
      Rec.Description:=ReadStreamStr(Stream);
      Result:=True;
      Exit;
    end;
  end;
end;
}
constructor TSciAbbrevManager.Create(AOwner : TComponent);
begin
  inherited;
{$Ifndef NEWABBREVS}
  fAbbrevs:=TMyStringList.Create;
  TMyStringList(fAbbrevs).CaseSensitive:=True;
{$Else}
  fAbbrevs:=TTemplateList.Create(Self,TTemplateItem);
{$Endif}
  fAllowTemplateMacros :=True;
  fIgnoreCase:=False;
end;

destructor TSciAbbrevManager.Destroy;
begin
  if assigned(fAbbrevs) then FreeAndNil(fAbbrevs);
  inherited;
end;

procedure TSciAbbrevManager.Notification(AComponent: TComponent; Operation: TOperation);
begin
  inherited Notification(AComponent,Operation);
  if Operation=opRemove then
  begin
    if AComponent=FEditor then
    begin
      fEditor:=nil;
    end;
  end;
end;

function TSciAbbrevManager.ProcessMacro(const MacroName : String;Params : String) : String;
var
  tmp,maccapt,macprompt,macvar : String;
  ps : Integer;
  parms : String;
begin
  tmp:=Params;
  Result:='';
  if AnsiCompareStr(MacroName,'PROMPT')=0 then
  begin
    parms:=ProcessArgs(PChar(Params),true);
    ps:=Pos(#13,parms);
    if ps<>0 then
    begin
      maccapt:=Copy(parms,ps+1,Length(parms)-ps);
      Delete(parms,ps,Length(parms)-ps+1);
      macprompt:=parms;
    end else
    begin
      maccapt:='Prompt';
      macprompt:=parms;
    end;
    if InputQuery(maccapt,macprompt,macvar) then
    begin
     Result:=macvar;
    end;
  end else if AnsiCompareStr(MacroName,'ROW')=0 then
  begin
    Result:=ToStr(fEditor.GetCurrentLineNumber+1);
  end else if assigned(fOnTemplateMacro) then
  begin
    fOnTemplateMacro(Self,MacroName,Params,Result);
  end;
end;

procedure TSciAbbrevManager.ExpandMatchingTemplates(var s : String);
var
  macStart,macEnd,ps,psend : Integer;
  tmpmac,macname : String;
  tmp,newitm : String;
  abbrev : String;
  tplidx : Integer;
begin
  tmp:=s;
  macStart:=Pos('<^',tmp);
  if macStart=0 then Exit
  else
  begin
    newItm:=Copy(tmp,1,macStart-1);
    Delete(tmp,1,macStart-1);
    macEnd:=Pos('>',tmp);
    if macEnd<>0 then
    begin
      macname:=Copy(tmp,3,macEnd-3);
      Delete(tmp,1,macEnd);
      if macname<>'' then
      begin
        case macname[1] of
          '$': begin
                 Delete(macname,1,1);
                 ps:=Pos('(',macname);
                 if ps<>0 then
                 begin
                   tmpmac:=Copy(macname,ps+1,Length(macname)-ps);
                   Delete(macname,ps,Length(macname)-ps+1);
                   psend:=Length(tmpmac);
                   while(psend>=1) do
                   begin
                     if tmpmac[psend]=')' then
                      break;
                     Dec(psend);
                   end;
                   if psend>=1 then
                   begin
                     Delete(tmpmac,psend,1);
                   end;
                 end;
                 newItm:=newItm+ProcessMacro(macname,tmpmac);
               end;
          else
          begin
{$Ifdef NEWABBREVS}
            tplidx:=fAbbrevs.IndexOf(macname);
            if tplidx<>-1 then
            begin
              abbrev:=fAbbrevs.Items[tplidx].FTemplate;
{$Else}
            tplidx:=fAbbrevs.IndexOfName(macname);
            if tplidx<>-1 then
            begin
              abbrev:=fAbbrevs.Values[macname];
{$Endif}
              abbrev:=Unslash(abbrev);
              newItm:=newItm+abbrev;
            end;

          end;
        end;
      end;
      s:=newItm+tmp;
      ExpandMatchingTemplates(s);
    end else
      newItm:=newItm+tmp;
  end;
end;


procedure TSciAbbrevManager.ExpandAbbrev;
var
  abbrevpos,currentpos,currentlinenum,indent,
  indentExtra,linestart,abbrlen,i,extrainc,iinc,caret_pos,indentsize: Integer;
  abbrev,toabbrev,resultingabbr,linebuf : String;
  c : AnsiChar;
  isIndent,found : Boolean;
  tplidx : Integer;
begin
  if fEditor=nil then
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TSciAbbrevManager']);
  currentpos:=fEditor.GetCaretInLine;
  if currentpos=0 then Exit; // expand only when at end of word.
  isIndent:=True;
  indentExtra:=0;
  indent:=0;
  currentLineNum:=fEditor.GetCurrentLineNumber;
  linestart:=fEditor.PositionFromLine(currentlinenum);
  if currentpos=0 then Exit;
  indentsize:=fEditor.GetIndent;
  SetLength(linebuf,currentpos);
  fEditor.GetRange(linestart,linestart+currentpos,PChar(linebuf));
  found:=False;
  abbrev:='';
  abbrevpos:=0;

  if KeepIndent in fEditor.Indentation then
  begin
    indent := fEditor.GetLineIndentation(currentLineNum);
  end;
  for i:=currentpos downto 0 do
  begin
    if IsWordChar(Integer(linebuf[i]))=False then
      break;
  end;
  if i<>currentpos then
  begin
    abbrevpos:=i;
    toabbrev:=System.Copy(linebuf,abbrevpos+1,currentpos);
    if abbrevpos=-1 then abbrevpos:=0;
{$Ifdef NEWABBREVS}
    tplidx:=fAbbrevs.IndexOf(toabbrev);
    if tplidx<>-1 then
    begin
      abbrev:=fAbbrevs.Items[tplidx].FTemplate;
{$Else}
    tplidx:=fAbbrevs.IndexOfName(toabbrev);
    if tplidx<>-1 then
    begin
      abbrev:=fAbbrevs.Values[toabbrev];
{$Endif}
      abbrev:=Unslash(abbrev);
      found:=True;
    end;
  end;
  if Found then
  begin
    resultingabbr:='';
    fEditor.SetSel(linestart+abbrevpos,linestart+abbrevpos+Length(toabbrev));
    caret_pos:=-1;
    fEditor.BeginUndoAction;
    if FAllowTemplateMacros=True then
    ExpandMatchingTemplates(abbrev);
    abbrlen:=Length(abbrev);
    extrainc:=0;
    for i:=1 to abbrlen do
    begin
      iinc:=i+extrainc;
      if iinc>abbrlen then break;
      resultingabbr:='';
      c:=abbrev[iinc];
      if (isIndent=True) and (c=#9) then
      begin
        Inc(indentExtra);
        fEditor.SetLineIndentation(currentLineNum, indent + (indentsize * indentExtra));
        fEditor.SetCurrentPos(fEditor.GetLineIndentPosition(currentLineNum));
        fEditor.SetSel(fEditor.GetCurrentPos,fEditor.GetCurrentPos);
      end else
      begin
        case c of
        '|': begin
               if (iinc<abbrlen) and (abbrev[iinc+1]='|') then
               begin
                 resultingabbr:='|';
                 Inc(extrainc);
               end else
               if caret_pos=-1 then
               begin
                 resultingabbr:='';
                 if i=0 then
                   caret_pos:=linestart+abbrevpos
                 else
                   caret_pos:=fEditor.GetCurrentPos;
               end;
             end;
        #10: begin
               if (fEditor.EOLStyle=eolCRLF) or (fEditor.EOLStyle=eolCR) then
               resultingabbr:=#13;
               if (fEditor.EOLStyle=eolCRLF) or (fEditor.EOLStyle=eolLF) then
               resultingabbr:=Concat(resultingabbr,#10);
             end;
        else
             resultingabbr:=abbrev[iinc];
        end;
        {$ifdef HASUTFFUNCS}
        if fEditor.GetCodePage=SC_CP_UTF8 then
        begin
          resultingabbr:=AnsiToUTF8(resultingabbr);
        end;
        {$Endif}
        fEditor.ReplaceSel(PChar(resultingabbr));
        if ((resultingabbr<>'') and (c=#10)) then
        begin
          isIndent:=True;
          indentExtra:=0;
          Inc(currentLineNum);
          fEditor.SetLineIndentation(currentLineNum, indent);
          fEditor.SetCurrentPos(fEditor.GetLineIndentPosition(currentLineNum));
          fEditor.SetSel(fEditor.GetCurrentPos,fEditor.GetCurrentPos);
        end else isIndent:=False;
      end;
    end;
    fEditor.EndUndoAction;
    if caret_pos<>-1 then
      fEditor.GotoPos(caret_pos);
  end;
end;

{$Ifndef NEWABBREVS}
procedure TSciAbbrevManager.SetAbbrevs(Value : TStrings);
{$Else}
procedure TSciAbbrevManager.SetAbbrevs(Value : TTemplateList);
{$Endif}
begin
  fAbbrevs.Assign(Value);
end;

procedure TSciAbbrevManager.SetIgnoreCase(const Value : Boolean);
begin
  fIgnoreCase:=Value;
{$Ifndef NEWABBREVS}
    TMyStringList(fAbbrevs).CaseSensitive:=not Value;
{$Endif}
end;

{$Ifdef NEWABBREVS}
constructor TTemplateList.Create(AOwner : TComponent;ItemClass : TCollectionItemClass);
begin
  inherited Create(AOwner,ItemClass);
end;

procedure TTemplateList.SetItem(Index:Integer; Value: TTemplateItem);
begin
  inherited SetItem(Index,Value);
end;

function TTemplateList.GetItem(Index:Integer): TTemplateItem;
begin
  Result:=TTemplateItem(inherited GetItem(Index));
end;

function TTemplateList.Add: TTemplateItem;
begin
  Result:=TTemplateItem(inherited Add);
end;

function TTemplateList.IndexOf(const TemplateName : String) : Integer;
var
  i,cnt : Integer;
  found : Boolean;
  caseignore : Boolean;
begin
  cnt:=Count;
  Result:=-1;
  caseignore :=TSciAbbrevManager(Owner).fIgnoreCase;
  for i:=0 to cnt-1 do
  begin
    if caseignore then
      found:=SameText(Items[i].FTemplateName,TemplateName)
    else
      found:=(Items[i].FTemplateName=TemplateName);
    if found then
    begin
      Result:=i;
      Exit;
    end;
  end;
end;

procedure TTemplateList.SetString(Index : Integer;Value : String);
var
  itm : TTemplateItem;
  ps : Integer;
begin
  itm:=Items[Index];
  if assigned(itm) then
  begin
    ps:=Pos('=',Value);
    if ps<>0 then
    begin
      itm.TemplateName:=Copy(Value,1,ps);
      itm.Template:=Copy(Value,ps,Length(Value)-ps);
    end else
    begin
      itm.TemplateName:=Value;
      itm.Template:='';
    end;
  end;
end;

function TTemplateList.GetString(Index : Integer) : String;
var
  itm : TTemplateItem;
begin
  itm:=Items[Index];
  if assigned(itm) then
  begin
    Result:=itm.TemplateName+'='+itm.Template;
  end else
    Result:='';
end;

procedure TTemplateList.LoadFromStream(Stream : TStream);
var
  lst : TMyStringList;
  cnt,i : Integer;
  itm : TTemplateItem;
  nam,value : String;
begin
  lst:=nil;
  Clear;
  try
    lst:=TMyStringList.Create;
    lst.LoadFromStream(Stream);
    cnt:=lst.Count;
    for i:=0 to (cnt-1) do
    begin
      nam:=lst.Names[i];
      if nam<>'' then
      begin
        value:=lst.Values[nam];
        if value<>'' then
        begin
          itm:=Add;
          itm.TemplateName:=nam;
          itm.Template:=value;
        end;
      end;
    end;

  finally
    if assigned(lst) then FreeAndNil(lst);
  end;
end;

procedure TTemplateList.SaveToStream(Stream : TStream);
var
  lst : TMyStringList;
  cnt,i : Integer;
  buf : String;
  itm : TTemplateItem;
begin
  lst:=nil;
  cnt:=Count;
  try
  if cnt>0 then
  begin
    lst:=TMyStringList.Create;
    for i:=0 to (cnt-1) do
    begin
      itm:=Items[i];
      buf:=itm.TemplateName+'='+itm.Template;
      lst.Add(buf);
    end;
    lst.SaveToStream(Stream);
  end;
  finally
    if assigned(lst) then
      FreeAndNil(lst);
  end;
end;

procedure TTemplateItem.SetTemplateName(const Value : String);
begin
  if Value<>FTemplateName then
  begin
    FTemplateName:=Value;
    Changed(False);
  end;
end;
procedure TTemplateItem.SetTemplate(const Value : String);
begin
  if Value<>FTemplate then
  begin
    FTemplate:=Value;
    Changed(False);
  end;
end;

procedure TTemplateItem.SetDescription(const Value : String);
begin
  if Value<>FDescription then
  begin
    FDescription:=Value;
    Changed(False);
  end;
end;

function TTemplateItem.GetDisplayName: string;
begin
    Result := FTemplateName;
end;

{$Endif}
end.
Added src/delphisci/sciAddLanguageFormUnit.ddp.

cannot compute difference between binary files

Added src/delphisci/sciAddLanguageFormUnit.dfm.


















































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
object sciAddLanguageForm: TsciAddLanguageForm
  Left = 267
  Top = 166
  BorderIcons = [biSystemMenu]
  BorderStyle = bsDialog
  Caption = 'Add Language'
  ClientHeight = 104
  ClientWidth = 255
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clBtnText
  Font.Height = -11
  Font.Name = 'MS Shell Dlg 2'
  Font.Style = []
  OldCreateOrder = False
  Position = poOwnerFormCenter
  PixelsPerInch = 96
  TextHeight = 13
  object BasePanel: TPanel
    Left = 0
    Top = 0
    Width = 255
    Height = 104
    Align = alClient
    BevelOuter = bvNone
    TabOrder = 0
    object Label1: TLabel
      Left = 14
      Top = 13
      Width = 81
      Height = 13
      Caption = 'Language Name:'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ParentFont = False
    end
    object Label2: TLabel
      Left = 31
      Top = 42
      Width = 64
      Height = 13
      Caption = 'Lexer to use:'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ParentFont = False
    end
    object languagename: TEdit
      Left = 99
      Top = 10
      Width = 145
      Height = 21
      Hint = 
        'Name you would line to use to select the language via SelectedLa' +
        'nguage'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ParentFont = False
      ParentShowHint = False
      ShowHint = True
      TabOrder = 0
      OnChange = languagenameChange
    end
    object LexerToUseCB: TComboBox
      Left = 100
      Top = 40
      Width = 145
      Height = 21
      Hint = 'The lexer this language will use to syntaxcolor this language'
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ItemHeight = 13
      ParentFont = False
      ParentShowHint = False
      ShowHint = True
      Sorted = True
      TabOrder = 1
      OnChange = languagenameChange
    end
    object okButton: TBitBtn
      Left = 18
      Top = 72
      Width = 75
      Height = 25
      Enabled = False
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ParentFont = False
      TabOrder = 2
      Kind = bkOK
    end
    object cancelButton: TBitBtn
      Left = 162
      Top = 72
      Width = 75
      Height = 25
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clBtnText
      Font.Height = -11
      Font.Name = 'MS Shell Dlg 2'
      Font.Style = []
      ParentFont = False
      TabOrder = 3
      Kind = bkCancel
    end
  end
end
Added src/delphisci/sciAddLanguageFormUnit.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
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
 Author : hdalis (hdalis@users.sourceforge.net)
 Created: 24/10/2004, 07:55:57
     $Id: sciAddLanguageFormUnit.pas,v 1.2 2004/11/13 04:29:51 hdalis Exp $
 History: 04/10/2004 Initial Release
}
{$Include SciCommonDef.Inc}
unit sciAddLanguageFormUnit;
interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TsciAddLanguageForm = class(TForm)
    BasePanel: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    languagename: TEdit;
    LexerToUseCB: TComboBox;
    okButton: TBitBtn;
    cancelButton: TBitBtn;
    procedure languagenameChange(Sender: TObject);
  private
  public
  end;

var
  sciAddLanguageForm: TsciAddLanguageForm;

implementation
uses EdOptionsWin;
{$R *.dfm}




procedure TsciAddLanguageForm.languagenameChange(Sender: TObject);
begin
  if (Length(languagename.Text)=0) or (LexerToUseCB.ItemIndex<0) then okButton.Enabled:=false
  else okButton.Enabled:=True;
end;

end.
Added src/delphisci/sciPrint.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Thanx to deusi for contributing the basic code for printing a scintilla
  control, and to both he and kiriakos vlahos for suggesting printer support.

  This component is still rather basic however, and not very much tested.
}
{
  Author: Jan Martin Pettersen (hdalis)
  History: 28/05/2005 Initial release
}
{$Include SciCommonDef.Inc}
unit sciPrint;
interface
uses Classes,SciLexer,Graphics,Windows,Dialogs,SciSupport;

type
  scipType=(scipHeader,scipFooter);
  scipColorMode=(sccmNormal,sccmInvertLight,sccmBlackOnWhite,sccmColorOnWhite,sccmColorOnWhiteDefaultBG);
  TSCEvent_margintext = procedure(Sender : TObject; FCurrentPageNumber : Integer;hType : scipType;var TextToPrint : String) of object;
{$Ifndef COMPILER7_UP}
  TPageMeasureUnits = (pmDefault, pmMillimeters, pmInches);
{$Endif}
  TSciPrinter=class(TComponent)
  private
    FCurrentPageNumber: Integer;

    FEditor : TScintillaBase;
    FOnBeforeNextPage : TNotifyEvent;
    FHeaderFont,FFooterFont : TFont;
    FMarginBottom,FMarginTop,FMarginLeft,FMarginRight : Integer;
    FFromPage,FToPage : Integer;
    FUnits : TPageMeasureUnits;
    FPrintRange : TPrintRange;
    FTitle : String;
    FPrintPagenumber : Boolean;
    FOnMarginText : TSCEvent_margintext;
    FOnStartPrinting,
    FOnDonePrinting : TNotifyEvent;
    FColorMode : scipColorMode;
    FMagnification : Integer;
    FWordWrap : TWordWrapType;
    procedure SetEditor(Value : TScintillaBase);
    procedure SetHeaderFont(Value : TFont);
    procedure SetFooterFont(Value : TFont);
    function GetNumPages : Integer;
  protected
    procedure Notification(AComponent: TComponent; Operation: TOperation);override;
    procedure DrawMarginText(Canvas : TCanvas;margin : scipType;r : TRect);
    procedure GetSettingsFor(var fmt : TRangeToFormat);
    procedure DoPrint;
  public
    constructor Create(AOwner : TComponent);override;
    destructor Destroy;override;
    {Readonly property containing the current pagenumber. Or -1 if not printing.}
    property CurrentPageNumber : Integer read FCurrentPageNumber;
    procedure Print;
    property NumberOfPages : Integer read GetNumPages;
  published
    property Editor : TScintillaBase read FEditor write SetEditor;
    property OnBeforeNextPage : TNotifyEvent read FOnBeforeNextPage write FOnBeforeNextPage;
    property MarginTop : Integer read FMarginTop write FMarginTop default 1500;
    property MarginBottom : Integer read FMarginBottom write FMarginBottom default 1500;
    property MarginLeft : Integer read FMarginLeft write FMarginLeft default 1500;
    property MarginRight : Integer read FMarginRight write FMarginRight default 1500;
    property Units: TPageMeasureUnits read FUnits write FUnits default pmDefault;
    property PrintRange : TPrintRange read FPrintRange write FPrintRange default prAllPages;
    property FromPage : Integer read FFromPage write FFromPage default 0;
    property ToPage : Integer read FToPage write FToPage default 0;
    property Title : String read FTitle write FTitle;
    property HeaderFont : TFont read FHeaderFont write SetHeaderFont;
    property FooterFont : TFont read FFooterFont write SetFooterFont;

    property PrintPageNumber : Boolean read FPrintPageNumber write FPrintPageNumber default True;
    property ColorMode : scipColorMode read FColorMode write FColorMode;
    property WordWrap : TWordWrapType read FWordWrap write FWordWrap;
    property Magnification : Integer read FMagnification write FMagnification;
    property OnMarginText : TSCEvent_margintext read FOnMarginText write FOnMarginText;
    property OnStartPrinting : TNotifyEvent read FOnStartPrinting write FOnStartPrinting;
    property OnDonePrinting : TNotifyEvent read FOnDonePrinting write FOnDonePrinting;
  end;

{Sets all pen settings, and then draws a line} 
procedure DrawPenLine(Canvas : TCanvas;startX,startY : Integer;endX : Integer=-1;endY : Integer=-1;PenWidth : Integer=1;PenColor : TColor=clBlack;PenStyle : TPenStyle=psSolid;PenMode : TPenMode=pmCopy);
implementation
uses Math,Printers,SysUtils,sciResLang;

constructor TSciPrinter.Create(AOwner : TComponent);
begin
  FEditor:=nil;
  FMarginLeft := 1500;
  FMarginTop := 1500;
  FMarginRight := 1500;
  FMarginBottom := 1500;
  FCurrentPageNumber:=-1;
  FFromPage:=0;
  FToPage:=0;
  FTitle:='DelphiSci';
  FMagnification:=0;
  FColorMode:=sccmNormal;
  FPrintPageNumber :=True;
  FPrintRange:=prAllPages;
  FFooterFont:=TFont.Create;
  FHeaderFont:=TFont.Create;
  FHeaderFont.Name:='Arial';
  FHeaderFont.Color:=clBlack;
  FHeaderFont.Size:=8;
  FFooterFont.Assign(FHeaderFont);
  inherited;  
end;

destructor TSciPrinter.Destroy;
begin
  FreeAndNil(FHeaderFont);
  FreeAndNil(FFooterFont);
  inherited;
end;

procedure TSciPrinter.Notification(AComponent: TComponent; Operation: TOperation);
begin
  if assigned(AComponent) and (Operation=opRemove) and (AComponent=FEditor) then
    FEditor:=nil
  else
    inherited;
end;

procedure DrawPenLine(Canvas : TCanvas;startX,startY : Integer;endX : Integer;endY : Integer;PenWidth : Integer;PenColor : TColor;PenStyle : TPenStyle;PenMode : TPenMode);
begin
  if endX=-1 then endX:=startX;
  if endY=-1 then endY:=startY;
  Canvas.Pen.Color:=PenColor;
  Canvas.Pen.Mode:=PenMode;
  Canvas.Pen.Width:=PenWidth;
  Canvas.Pen.Style:=PenStyle;
  Canvas.MoveTo(startX, startY);
  Canvas.LineTo(endX, endY);
end;

procedure TSciPrinter.DrawMarginText(Canvas : TCanvas;margin : scipType;r : TRect);
var
  ta: Integer;
  rcw: TRect;
  headerLineHeight: Integer;
  footerLineHeight: Integer;
  s:String;
begin
  Canvas.Brush.Style:=bsClear;
  case margin of
    scipHeader:
      begin
        Canvas.Font:=FHeaderFont;
        headerLineHeight:=Canvas.TextHeight('W');
        ta := SetTextAlign(Canvas.Handle, TA_BOTTOM);
        rcw := Rect(r.left,r.top - headerLineHeight - (headerLineHeight div 2),r.right,r.top - (headerLineHeight div 2));
        rcw.bottom := rcw.top + headerLineHeight;
        if not IsRectEmpty(rcw) then
        begin
          if assigned(FOnMarginText) then
          begin
            s:='';
            FOnMarginText(Self,FCurrentPageNumber,scipHeader,s);
            if s<>'' then
              Canvas.TextRect(rcw,r.left,r.top - (headerLineHeight div 2),s);
          end;
          if FPrintPageNumber then
          begin
            s := Format(sPageNo, [FCurrentPageNumber]);
            Canvas.TextRect(rcw,r.Right - Canvas.TextWidth(s),r.top - (headerLineHeight div 2),s);
          end;
          SetTextAlign(Canvas.Handle, ta);
          DrawPenLine(Canvas,r.left,r.top - headerLineHeight div 4,r.right,-1,2);
        end;
      end;
    scipFooter:
      begin
        footerLineHeight:=Canvas.TextHeight('W');
        Canvas.Font:=FFooterFont;
        ta := SetTextAlign(Canvas.Handle, TA_TOP);
        rcw := Rect(r.left, r.bottom + (footerLineHeight div 2), r.right, r.bottom + footerLineHeight + (footerLineHeight div 2));
        if not IsRectEmpty(rcw) then
        begin
          if assigned(FOnMarginText) then
          begin
            s:='';
            FOnMarginText(Self,FCurrentPageNumber,scipFooter,s);
            if s<>'' then
            Canvas.TextRect(rcw,r.left,r.bottom + (footerLineHeight div 2),s);
          end;
          if FPrintPageNumber then
          begin
            s := Format(sPageNo, [FCurrentPageNumber]);
            Canvas.TextRect(rcw,r.Right - Canvas.TextWidth(s),
                                      r.bottom + (footerLineHeight div 2),s);
          end;
          SetTextAlign(Canvas.Handle, ta);
          DrawPenLine(Canvas,r.left,r.bottom + footerLineHeight div 4,r.right,-1,2);
        end;
      end;
  end;
end;

{ GetSettingsFor:
  Set both rectangles based on the device capabilities and the margins specified.
  Input: TRangeToFormat with AT LEAST a valid hdcTarget member.
  On return: Both rc and rcTarget are filled with valid data. No other members are touched.
}
procedure TSciPrinter.GetSettingsFor(var fmt : TRangeToFormat);
var
  dc: HDC;
  ptDpi, ptPage: TPoint;
  rectMargins, rectSetup,
  rectPhysMargins: TRect;
  locinfo : array[0..3] of Char;
begin
  dc:=fmt.hdcTarget;
  ptDpi.X := GetDeviceCaps(dc, LOGPIXELSX);
  ptDpi.Y := GetDeviceCaps(dc, LOGPIXELSY);
  ptPage.X := GetDeviceCaps(dc, PHYSICALWIDTH);
  ptPage.Y := GetDeviceCaps(dc, PHYSICALHEIGHT);
  rectPhysMargins.Left := GetDeviceCaps(dc,PHYSICALOFFSETX);
  rectPhysMargins.Top := GetDeviceCaps(dc,PHYSICALOFFSETY);
  rectPhysMargins.Right := ptPage.X - GetDeviceCaps(dc,HORZRES) - rectPhysMargins.Left;
  rectPhysMargins.Bottom := ptPage.Y - GetDeviceCaps(dc, VERTRES) - rectPhysMargins.Top;
  if FUnits=pmDefault then
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, locinfo, 3);
  if (FUnits=pmInches) or ((FUnits=pmDefault) and (locinfo[0]='0')) then
  begin
    rectSetup.left := MulDiv (FMarginLeft, ptDpi.x,2540);
    rectSetup.top := MulDiv (FMarginTop,ptDpi.y, 2540);
    rectSetup.right  := MulDiv(FMarginRight, ptDpi.x, 2540);
    rectSetup.bottom  := MulDiv(FMarginBottom, ptDpi.y, 2540);
  end else
  begin
    rectSetup.left := MulDiv (FMarginLeft, ptDpi.x,1000);
    rectSetup.top := MulDiv (FMarginTop,ptDpi.y, 1000);
    rectSetup.right  := MulDiv(FMarginRight, ptDpi.x, 1000);
    rectSetup.bottom  := MulDiv(FMarginBottom, ptDpi.y, 1000);
  end;
  rectMargins.left  := Max(rectPhysMargins.left,rectSetup.left);
  rectMargins.top  := Max(rectPhysMargins.top, rectSetup.top);
  rectMargins.right  := Max(rectPhysMargins.right, rectSetup.right);
  rectMargins.bottom  := Max(rectPhysMargins.bottom, rectSetup.bottom);

  DPtoLP(dc, rectMargins, 2);
  DPtoLP(dc, rectPhysMargins, 2);
  DPtoLP(dc, ptPage, 1);

  fmt.rc.Left := rectMargins.left - rectPhysMargins.left;
  fmt.rc.top := rectMargins.top - rectPhysMargins.top;
  fmt.rc.right := ptPage.x - rectMargins.right -rectPhysMargins.left;
  fmt.rc.bottom := ptPage.y - rectMargins.bottom -rectPhysMargins.top;
  fmt.rcPage.left := 0;
  fmt.rcPage.top := 0;
  fmt.rcPage.right := ptPage.x - rectPhysMargins.left -rectPhysMargins.right - 1;
  fmt.rcPage.bottom := ptPage.y - rectPhysMargins.top - rectPhysMargins.bottom - 1;
end;

function TSciPrinter.GetNumPages : Integer;
var
  fmtRange: TRangeToFormat;
  Canvas : TCanvas;
  lengthDoc,lengthPrinted : Integer;
  cnt : Integer;
begin
  cnt:=0;
  try
    if not assigned(FEditor) then
    begin
      raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TSciPrinter']);
      Exit;
    end;
    FEditor.HandleNeeded;
    lengthDoc:=FEditor.GetLength;
    if LengthDoc=0 then
    begin
      Result:=0;
      Exit;
    end;
    FEditor.SetPrintColourMode(Integer(FColorMode));
    FEditor.SetPrintMagnification(FMagnification);
    FEditor.SetPrintWrapMode(Integer(FWordWrap));
    lengthPrinted:=0;
    //We MUST start the document to allow the FormatRange to do it's thing, as it just returns otherwise.
    Printer.BeginDoc;
    Canvas:=Printer.Canvas;
    fmtRange.hdc := Canvas.Handle;
    fmtRange.hdcTarget := Canvas.Handle;
    fmtRange.chrg.cpMin:=0;
    fmtRange.chrg.cpMax:=lengthDoc;
    GetSettingsFor(fmtRange);
    cnt:=1;
    while (lengthPrinted < lengthDoc) do
    begin
      lengthPrinted := FEditor.FormatRange(false, @fmtRange);
      fmtRange.chrg.cpMin := lengthPrinted;
      if lengthPrinted < lengthDoc then
      begin
        Inc(cnt);
      end;
    end;
  finally
    if Printer.Printing then
      Printer.Abort;
  end;
  Result:=cnt;
end;

procedure TSciPrinter.DoPrint;
var
  fmtRange: TRangeToFormat;
  crange : TCharacterRange;
  lengthPrinted: Integer;
  startPos,endPos,lengthDoc,lengthDocMax : Integer;
  printPage : Boolean;
  Canvas : TCanvas;
begin
  if not assigned(FEditor) then
  begin
    raise Exception.CreateResFmt(@eEditorPropertyNotAssigned,['TSciPrinter']);
    Exit;
  end;
  FEditor.HandleNeeded;
  lengthDoc:=FEditor.GetLength;
  lengthDocMax:=lengthDoc;
  if lengthDoc=0 then
    Exit;
  //Set the scintilla's printerrelated properties of to those of my properties.
  FEditor.SetPrintColourMode(Integer(FColorMode));
  FEditor.SetPrintMagnification(FMagnification);
  FEditor.SetPrintWrapMode(Integer(FWordWrap));
  try
    Printer.BeginDoc;
    Canvas:=Printer.Canvas;
    Printer.Title := FTitle;
    fmtRange.hdc := Canvas.Handle;
    fmtRange.hdcTarget := Canvas.Handle;
    GetSettingsFor(fmtRange);
    startPos:=0;
    endPos:=0;
    crange:=FEditor.GetSelectionRng;
    if FPrintRange=prSelection then
    begin
      startPos:=crange.cpMin;
      endPos:=crange.cpMax;
    end;
    if startPos=endPos then
    begin
      startPos:=0;
      endPos:=lengthDocMax;
    end;
    if startPos>endPos then
    begin
      lengthPrinted:=endPos;
      lengthDoc:=startPos;
    end else
    begin
      lengthPrinted:=startPos;
      lengthDoc:=endPos;
    end;
    if lengthPrinted<0 then lengthPrinted:=0;
    if lengthDoc>lengthDocMax then lengthDoc:=lengthDocMax;
    fmtRange.chrg.cpMin := startPos;
    fmtRange.chrg.cpMax := endPos;

    FCurrentPageNumber := 1;
    Canvas.Brush.Color:=clYellow;
    if assigned(FOnStartPrinting) then
      FOnStartPrinting(Self);

    while (lengthPrinted < lengthDoc) and (Printer.Aborted=False) do
    begin
      printPage := (not(FPrintRange=prPageNums) or (FCurrentPageNumber >= FFromPage) and (FCurrentPageNumber <= FToPage));
      if printPage then
      begin
        if FCurrentPageNumber>1 then Printer.NewPage;
        DrawMarginText(Canvas,scipHeader,fmtRange.rc);
        lengthPrinted := FEditor.FormatRange(true, @fmtRange);
        DrawMarginText(Canvas,scipFooter,fmtRange.rc);
        fmtRange.chrg.cpMin := lengthPrinted;
        if assigned(FOnBeforeNextPage) then
          FOnBeforeNextPage(Self);
      end;
      if (lengthPrinted < lengthDoc) and (not Printer.Aborted) then
      begin
        Inc(FCurrentPageNumber);
      end;
      if (FPrintRange=prPageNums) and (FCurrentPageNumber>FToPage) then
      begin
        break;
      end;
    end;
    FEditor.FormatRange(false, nil);
    Printer.EndDoc;
    if assigned(FOnDonePrinting) then FOnDonePrinting(Self);
    FCurrentPageNumber:=-1;
  except
    on EPrinter do
    begin
      raise;
    end;
  end;
end;
procedure TSciPrinter.Print;
begin
  DoPrint;
end;

procedure TSciPrinter.SetEditor(Value : TScintillaBase);
begin
  FEditor :=Value;
end;

procedure TSciPrinter.SetHeaderFont(Value : TFont);
begin
  FHeaderFont.Assign(Value);
end;

procedure TSciPrinter.SetFooterFont(Value : TFont);
begin
  FFooterFont.Assign(Value);
end;

end.
Added src/delphisci/sciUtils.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis (Jan Martin Pettersen)
  Created: 02/12/2004
      $Id:  $
  Purpose: Assorted functions used by the components

  History: 02/12/2004 First release
           05/01/2005 Added
           15/05/2005 Renamed StrToken to WordBefore, and ReplaceChar to ReplaceAChar because the old names clashed
                      with JVCL.
                      Added ToBool, and ToIntAndCheck.
                      Removed all references to ValueExtract, as it was unneccesary.
}
{$Include SciCommonDef.Inc}
unit sciUtils;
interface
uses Graphics,Classes,SysUtils,SciLexer;
{This class, and functions is a partial support for BCB5 for the CaseSensitive property etc.. It might work, and it might not..}
type
{$IFNDEF COMPILER6_UP}
  TMyStringList=class(TStringList)
    private
    FCaseSensitive : Boolean;
    procedure SetCaseSensitive(Value : Boolean);
    procedure SetValueFromIndex(index : Integer;const Value : String);
    function GetValueFromIndex(index : Integer) : String;
    public
      function Find(const S: string; var Index: Integer): Boolean; override;
      function IndexOf(const S: string): Integer;override;
      function CompareStrings(const S1, S2: string): Integer;
      property ValueFromIndex[Index: Integer]: String read GetValueFromIndex write SetValueFromIndex;

    published
      property CaseSensitive : Boolean read FCaseSensitive write SetCaseSensitive;
  end;
{$Else}
  TMyStringList=class(TStringList);
{$Endif}

{Splits a string into several strings.. Uses #0,#10, and #13 as line separators.}
procedure SplitStrings(const src : String;lst : TStrings);

{Merges several strings into one string.. Uses #0 upto #32 as separators.}
function MergeStrings(lst : TStrings) : String;

{Convert a string to the corresponding TColor, and if s='' then returns defcolor.}
function ColourFromString(const s : String;const defcolor : TColor) : TColor;
{Converts a TColor to a string readable by ColourFromString.}
function ColourToString(const clr : TColor) : String;

{ Converts True/Yes or 1 to True, else returns false}
function StringToBool(const s : String) : Boolean;

{Converts a string to boolean via the above function, or if the string is empty, returns the 'defaultvalue'}
function ToBool(const s : String;const defaultvalue : Boolean=False) : Boolean;

{Converts a bool value to the text True or False}
function BoolToString(const value : Boolean) : String;

{Converts an Integer to string.}
function ToInt(const value : String;const DefValue : Integer=0) : Integer;
{Converts a string to an Integer}
function ToStr(const value : Integer) : String;

{Returns the string 'value' as a integer, and if the string also contains
 nonnumeric, then it strips them before converting.}
function ToIntAndCheck(const value : String) : Integer;

{Compares s1 to s2, if ignorecase is true then the comparing is caseless.
 If maxlen<>-1 then only maxlen chars are compared.}
function CompStr(const s1,s2 : String;ignorecase : Boolean=True;maxlen : Integer=-1) : Integer;

{Returns the string before the separator 'separator', and returns the rest of the
 string in 'S'.}
function WordBefore(var S: AnsiString; const Separator: AnsiChar): AnsiString;

{Replaces all chars 'Source' with the char 'Replace'.}
function ReplaceAChar(const S: AnsiString; const Source, Replace: Char): AnsiString;

{If two or more of any of the characters in 'whitespacechars' are adjacent then
 all but one of them is removed. If both space (#32) and Tab is in the 'whitespacechars' then
 all Tabs are converted to a space before returning the result.}
function AllButOne(const s : String;const whitespacechars : TSysCharSet) : String;

{Converts a string to sentence style. The character after one of the chars in
 'sentenceendings' are uppercased, the rest is lowercased.}
function SentenceString(const s : String;sentenceendings : TSysCharSet) : String;

{Inverts the charactercase of a string}
function InvertCase(const s : String) : String;

{Unslashes C style strings. Doesn't support octals however}
function Unslash(const s : String) : String;

{Slashes C style strings. Doesn't support octals however}
function Slash(const s : String) : String;

{Returns True if the char 'ch' is a word character. old name: iswordcharforsel}
function IsWordChar(const ch : LongInt) : boolean;

{Returns True if the char 'ch' is a filename character. old name: isfilenamecharforsel}
function IsFilenameChar(const ch : LongInt) : boolean;

{Returns true if the char 'ch' is a whitespace. old name: isaspace}
function IsSpace(const ch : LongInt) : boolean;

{Returns the position of the first char 'C', starting from 'StartPos', or 0 if it isn't found.}
function CharPos(const S: AnsiString; const C: AnsiChar; const StartPos: LongInt=1): LongInt;

{Extracts a Integer from a hex byte}
function IntFromHexByte(const hexByte : PChar) : Integer;

{Extracts a Integer from a hex digit}
function IntFromHexDigit(const ch : Char) : Integer;

{Returns the index of the matching string if 's' is found in the list 'lst', compared 'casesensitive'
 otherwise, returns -1.}
function FindStrInList(const s : String;lst : TStrings;const casesensitive : Boolean=true) : Integer;

{Returns true if the word 'searchfor' is within the string 's' where the items are separated by 'separator'}
function IsWordInString(const s : String;const searchfor : String;IgnoreCase : Boolean=True;const separator : AnsiChar=';') : Boolean;

{Returns the string 's' except the word 'exceptwhat'. Items are separated by 'separator'.}
function BuildWordlistExcept(const s : String;const exceptwhat : String;IgnoreCase : Boolean=True;const separator : AnsiChar=';') : String;

{Processes the commandlinelike 'cmd', optionally starting with the first arg.
Handles "arg arg" as one argument. Returns the arguments separated by #13.}
function ProcessArgs(cmd : PChar;startwithfirst : Boolean=false) : String;
{Returns the mask of 'numbits' bits. i.e if the styles uses 5 bits, then call BitsToMask, and it returns $1f}
function BitsToMask(numbits : Integer) : Integer;
{Returns the opposite mask of 'numbits' bits. i.e if the styles uses 5 bits, then call OppositeMask, and it returns $E0}
function OppositeMask(numbits : Integer) : Integer;

{Sorts the collection in the order determined by 'CompareFunc'. See the VCL documentation on the typedefinition
of the required function. If ascending is false, then the collection is sorted descending.}
procedure SortCollection(Collection : TCollection;CompareFunc : TListSortCompare;Ascending : Boolean=True);
function FExists(const fname : String) : Boolean;

function GetEOLString(m : TScintillaBase) : String;
implementation
uses Windows,SciResLang,SciSupport;

{$Ifdef NOBUILTINCLR}
  Type
    { Auxiliary structure to support TColor manipulation }
    TColorRec = packed record
      case Integer of
        0: (Value: LongInt);
        1: (Red, Green, Blue: Byte);
        2: (R, G, B, Flag: Byte);
        3: (Index: Word); // GetSysColor, PaletteIndex
    end;

  //Sets a TColor from RGB.
  function internSetRGBValue(const Red, Green, Blue: Byte): TColor;
  begin
    TColorRec(Result).Red := Red;
    TColorRec(Result).Green := Green;
    TColorRec(Result).Blue := Blue;
    TColorRec(Result).Flag := 0;
  end;
{$Endif}
{Extracts a Integer from a hex digit}
function IntFromHexDigit(const ch : Char) : Integer;
begin
  if ((ch>='0') and (ch<='9')) then
  begin
    Result :=Integer(ch)-Integer('0');
  end else if ((ch >= 'A') and (ch <= 'F')) then
  begin
    Result :=Integer(ch)-Integer('A')+10;
  end else if ((ch >= 'a') and (ch <= 'f')) then
  begin
    Result :=Integer(ch)-Integer('a')+10;
  end  else
  begin
    Result:=0;
  end;
end;

{Extracts a Integer from a hex byte}
function IntFromHexByte(const hexByte : PChar) : Integer;
begin
  Result:=IntFromHexDigit(hexByte[0]) * 16 + IntFromHexDigit(hexByte[1]);
end;

//Convert a string to the corresponding TColor, and if s='' then returns defcolor.
function ColourFromString(const s : String;const defcolor : TColor) : TColor;
var
{$Ifdef NOBUILTINCLR}
  r: Integer;
  g: Integer;
  b: Integer;
{$Else}
  tmp : array [0..10] of Char ;
{$Endif}
begin
  if (Length(s)>0) then
  begin
{$Ifdef NOBUILTINCLR}
    //tmp:=PChar(s);
    r := IntFromHexByte(PChar(s) + 1);
    g := IntFromHexByte(PChar(s) + 3);
    b := IntFromHexByte(PChar(s) + 5);
    Result := internSetRGBValue(r,g,b);
{$Else}
    if s[1]='#' then  //Rotate htmlcolorcode to resemble delphi colorcodes
    begin
      tmp[0]:='$';
      tmp[1]:='0';
      tmp[2]:='0';
      tmp[3]:=s[6];
      tmp[4]:=s[7];
      tmp[5]:=s[4];
      tmp[6]:=s[5];
      tmp[7]:=s[2];
      tmp[8]:=s[3];
      tmp[9]:=#0;
      Result:=StringToColor(tmp);
      Exit;
    end;
    Result:=StringToColor(s);
{$Endif}
  end else
  begin
    Result:=defcolor;
  end;
end;

//Converts a TColor to a string readable by ColourFromString.
function ColourToString(const clr :TColor) : String;
{$Ifndef NOBUILTINCLR}
var
  tmp : String;
  tmp2 : array [0..10] of Char;
{$Endif}
begin
{$Ifdef NOBUILTINCLR}
  Result:=Format('#%2.2x%2.2x%2.2x',[TColorRec(clr).Red,TColorRec(clr).Green,TColorRec(clr).Blue]);
{$Else}
  tmp:=ColorToString(clr);
  if (tmp[1]='$') then  //Rotate string to resemble html colorcodes
  begin
    Delete(tmp,1,3);
    tmp2[0]:='#';
    tmp2[1]:=tmp[5];
    tmp2[2]:=tmp[6];
    tmp2[3]:=tmp[3];
    tmp2[4]:=tmp[4];
    tmp2[5]:=tmp[1];
    tmp2[6]:=tmp[2];
    tmp2[7]:=#0;
    Result:=tmp2;
    Exit;
  end;

  Result:=tmp;
{$Endif}
end;

function ToInt(const value : String;const DefValue : Integer) : Integer;
begin
  Result:=StrToIntDef(value,DefValue);
end;


function ToStr(const value : Integer) : String;
begin
  Result:=IntToStr(value);
end;


//Replaces the all 'source' char with 'replace' char, and returns the result.
function ReplaceAChar(const S: AnsiString; const Source, Replace: Char): AnsiString;
var
  I: Integer;
begin
  Result := S;
  for I := 1 to Length(S) do
    if Result[I] = Source then
      Result[I] := Replace;
end;


//Extracts the string from start to 'separator'. Returns that, and returns the rest of the string
//in 's'
function WordBefore(var S: AnsiString; const Separator: AnsiChar): AnsiString;
var
  I: Integer;
begin
  I := Pos(Separator, S);
  if I <> 0 then
  begin
    Result := Copy(S, 1, I - 1);
    Delete(S, 1, I);
  end else
  begin
    Result := S;
    S := '';
  end;
end;

function IsWordInString(const s : String;const searchfor : String;IgnoreCase : Boolean;const separator : AnsiChar) : Boolean;
var
  tmp : String;
  match : String;
begin
  tmp:=s;
  Result:=False;
  repeat
    match:=WordBefore(tmp,separator);
    if CompStr(match,searchfor,IgnoreCase)=0 then
    begin
      Result:=True;
      Exit;
    end;
  until (tmp='');
end;

function BuildWordlistExcept(const s : String;const exceptwhat : String;IgnoreCase : Boolean;const separator : AnsiChar) : String;
var
  tmp : String;
  match : String;
  newlist : String;
  isfirst : Boolean;
begin
  tmp:=s;
  isfirst:=True;
  repeat
    match:=WordBefore(tmp,separator);
    if CompStr(match,exceptwhat,IgnoreCase)<>0 then
    begin
      if isfirst then
      begin
        newlist:=match;
        isfirst:=False;
      end
      else
        newlist:=newlist+separator+match;
    end;
  until (tmp='');
  Result:=newlist;
end;

function CompStr(const s1,s2 : String;ignorecase : Boolean;maxlen : Integer) : Integer;
begin
  if maxlen=-1 then
  begin
    if ignorecase then
      Result:=StrIComp(PChar(s1),PChar(s2))
    else
      Result:=StrComp(PChar(s1),PChar(s2));
  end else
  begin
    if ignorecase then
      Result:=StrLIComp(PChar(s1),PChar(s2),maxlen)
    else
      Result:=StrLComp(PChar(s1),PChar(s2),maxlen);
  end;
end;

function StringToBool(const s : String) : Boolean;
begin
  if (CompStr(s,sTrue)=0) or (CompStr(s,'1')=0) or (CompStr(s,sYes)=0) then
    Result:=True
  else
    Result:=False;
end;

function BoolToString(const value : Boolean) : String;
begin
  if value=true then Result:=sTrue
  else Result:=sFalse;
end;

function AllButOne(const s : String;const whitespacechars : TSysCharSet) : String;
var
  i,cnt : Integer;
  tmp : String;
  lastwasspace : Boolean;
  c : Char;
  ps : Integer;
begin
  if s='' then
  begin
    Result:=s;
    Exit;
  end;
  tmp:=s;
  lastwasspace:=True;
  cnt:=Length(tmp);
  for i:=cnt downto 1 do
  begin
    c:=tmp[i];
    if c in whitespacechars then
    begin
      if (lastwasspace) then Delete(tmp,i,1);
      lastwasspace:=True;
    end else
      lastwasspace:=False;
  end;
  if (#9 in whitespacechars) and (#32 in whitespacechars) then
  begin
    ps:=Pos(#9,tmp);
    while ps>0 do
    begin
      tmp[ps]:=#32;
      ps:=Pos(#9,tmp);
    end;
  end;
  Result:=tmp;
end;

function SentenceString(const s : String;sentenceendings : TSysCharSet) : String;
var
  tmp : String;
  cnt,i : Integer;
  c : Char;
  lastwasending : Boolean;
begin
  if s='' then
  begin
    Result:=s;
    Exit;
  end;
  tmp:=s;
  cnt:=Length(tmp);
  lastwasending:=True;
  for i:=1 to cnt do
  begin
    c:=tmp[i];
    if c in sentenceendings then lastwasending:=True
    else
    begin
      if c in [#32,#9] then
      begin
        Continue;
      end;
      if lastwasending=True then
      begin
        tmp[i]:=AnsiUpperCase(c)[1];
        lastwasending:=False;
      end else
      begin
        tmp[i]:=AnsiLowerCase(tmp[i])[1];
        lastwasending:=False;
      end;
    end;
  end;
  Result:=tmp;
end;

function InvertCase(const s : String) : String;
var
  tmp : String;
  cnt,i : Integer;
  c : Char;
begin
  if s='' then
  begin
    Result:=s;
    Exit;
  end;
  tmp:=s;
  cnt:=Length(tmp);
  for i:=1 to cnt do
  begin
    c:=tmp[i];
    case c of
      'a'..'z','æ','ø','å': tmp[i]:=AnsiUpperCase(c)[1];
      'A'..'Z','Æ','Ø','Å': tmp[i]:=AnsiLowerCase(c)[1];
    end;
  end;
  Result:=tmp;
end;

function Slash(const s : String) : String;
var
  I: Integer;
  len : Integer;
begin
  Result := '';
  len:=Length(S);
  for I := 1 to len do
  begin
    case S[I] of
      #8:
        Result := Result + '\b';
      #7:
        Result := Result + '\a';
      #13:
        begin
          if not ((I<len) and (S[I+1]=#10)) then //Replaces the sequence #13#10 with only #10 because the AbbrevManager handles '\n' as the current eolmode.
            Result := Result + '\r';
        end;
      #15:
        Result := Result + '\f';
      #10:
        Result := Result + '\n';
      #9:
        Result := Result + '\t';
      #11:
        Result := Result + '\v';
      '\':
        Result := Result + '\\';
      '"':
        Result := Result + '\"';
    else
      if S[I] < #32 then
        Result := Result + Format('\x%.2x',[Integer(S[I])])
      else
        Result := Result + S[I];
    end;
  end;
end;

function Unslash(const s : String) : String;
const
  hexchars = ['0'..'9','a'..'f','A'..'F'];
var
  Len,I : Integer;
  hbuf : array[0..2] of Char;
begin
  Result := '';
  hbuf[2]:=#0;

  I := 1;
  Len := Length(S);
  while I <= Len do
  begin
    if not ((S[I] = '\') and (I < Len)) then
      Result := Result + S[I]
    else
    begin
      Inc(I); // Jump over escape character
      case S[I] of
        'a':
          Result := Result + #7;
        'b':
          Result := Result + #8;
        'f':
          Result := Result + #15;
        'n':
          Result := Result + #10;
        'r':
          Result := Result + #13;
        't':
          Result := Result + #9;
        'v':
          Result := Result + #11;
        '\':
          Result := Result + '\';
        '"':
          Result := Result + '"';
        '''':
          Result := Result + ''''; // Optionally escaped
        '?':
          Result := Result + '?';  // Optionally escaped

        'x': begin
               if I<(Len-1) then
               begin
                 if S[I+1] in hexchars then
                 begin
                   hbuf[0]:=S[I+1];
                   hbuf[1]:=S[I+2];
                   Result:=Result+Chr(IntFromHexByte(hbuf));
                   Inc(i,2);
                 end;
               end else
               begin
                 Result := Result + '\x';
               end;
             end;
      else
        // no escape sequence
        Result := Result + '\' + S[I];
      end;
    end;
    Inc(I);
  end;

end;

function CharPos(const S: AnsiString; const C: AnsiChar; const StartPos: LongInt): LongInt;
var
  P: PAnsiChar;
begin
  Result := 0;
  if (StartPos > 0) and (StartPos <= Length(S)) then
  begin
    P := PAnsiChar(S);
    Result := StartPos - 1;
    Inc(P, Result);
    while P^ <> #0 do
    begin
      Inc(Result);
      if P^ = C then
        Break;
      Inc(P);
    end;
    if P^ = #0 then
      Result := 0;
  end;

end;

function IsSpace(const ch : LongInt) : boolean;
begin
  Result := (Char(ch) in [#9,#10,#13,#32]);
end;

function IsWordChar(const ch : LongInt) : boolean;
begin
  Result := Char(ch) in ['a'..'z','A'..'Z','0'..'9','_'];
  //Result := not (Char(ch) in [#9,#10,#13,#32,'!','"','#','$','%','&','''','(',',',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\',']','^','`','{','|','}','~',']']);
end;

function IsFilenameChar(const ch : LongInt) : boolean;
begin
  result := not (Char(ch) in [#9,#10,#13,#32,'"','*',';','<','>','?','^','|',',','{','}']);
end;

function  ProcessArgs(cmd : PChar;startwithfirst : Boolean) : String;
var
  tmparg,args : String;
  startArg : PChar;
  endArg : PChar;
  argpos : Integer;
begin
  startArg:=cmd;
  argpos:=0;
  while (startArg^<>#0) do
  begin
    while IsSpace(Integer(startArg^)) do Inc(startArg);
    endArg:=startArg;
    if startArg^='"' then
    begin
      Inc(startArg);
      endArg:=startArg;
      while ((endArg^<>#0) and (endArg^<>'"')) do Inc(endArg);
    end else
    begin
      while (endArg^<>#0) and (IsSpace(Integer(endArg^))=False) do Inc(endArg);
    end;
    tmparg:=Copy(startArg,1,endArg-startArg);
    if (startwithfirst=true) or (argpos>0) then
      if args<>'' then
        args:=args+#13+tmparg
      else
        args:=tmparg;
    startArg:=endArg;
    Inc(argpos);
    if (startArg^<>#0) then Inc(startArg);
  end;
  Result:=args;
end;

function FindStrInList(const s : String;lst : TStrings;const casesensitive : Boolean) : Integer;
var
  cnt,i : Integer;
begin
  Result:=-1;
  if(casesensitive) then
  begin
    cnt:=lst.Count;
    if(cnt>0) then
    begin
      for i:=0 to (cnt-1) do
      begin
        if AnsiCompareStr(s,lst.Strings[i])=0 then
        begin
          Result:=i;
          Exit;
        end;
      end;
    end;
  end else
  begin
    Result:=lst.IndexOf(s);
  end;
end;

function ToBool(const s : String;const defaultvalue : Boolean) : Boolean;
begin
  if s='' then
  begin
    Result:=defaultvalue;
    Exit;
  end else
    Result:=StringToBool(s);
end;

function ToIntAndCheck(const value : String) : Integer;
var
  cnt,i,ps : Integer;
  ishex : Boolean;
begin
  cnt:=Length(value);
  if cnt>0 then
    ishex:=(value[1]='$')
  else
  begin
    Result:=0;
    Exit;
  end;
  ps:=-1;
  for i:=1 to cnt do
  begin
    if ishex=True then
    begin
      if not (value[i] in ['$','0'..'9','a'..'f','A'..'F']) then
      begin
        ps:=i;
        break;
      end;
    end else
    begin
      if not (value[i] in ['0'..'9']) then
      begin
        ps:=i;
        break;
      end;
    end;
  end;
  if (ps<>-1) then
  begin
    Result:=StrToIntDef(Copy(value,1,ps-1),0);
  end else
  Result:=StrToIntDef(value,0);
end;

function GetEOLString(m : TScintillaBase) : String;
begin
  case m.GetEOLMode of
    SC_EOL_CRLF: Result:=#13#10;
    SC_EOL_CR: Result:=#13;
    SC_EOL_LF: Result:=#10;
  end;
end;

{$Ifdef BADFILEEXISTS}
function DExists(const fname : String) : Boolean;
var
  dta : TWin32FindData;
  handle : THandle;
begin
  Result:=False;
  handle:=INVALID_HANDLE_VALUE;
  try
    handle:=FindFirstFile(PChar(fname),dta);
    if (handle<>INVALID_HANDLE_VALUE) and ((dta.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) <> 0) then Result:=True;
  finally
    if handle<>INVALID_HANDLE_VALUE then
    begin
      FindClose(handle);
    end;
  end;
end;

function FExists(const fname : String) : Boolean;
var
  dta : TWin32FindData;
  handle : THandle;
begin
  Result:=False;
  handle:=INVALID_HANDLE_VALUE;
  try
    handle:=FindFirstFile(PChar(fname),dta);
    if (handle<>INVALID_HANDLE_VALUE) and ((dta.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) = 0) then Result:=True;
  finally
    if handle<>INVALID_HANDLE_VALUE then
    begin
      FindClose(handle);
    end;
  end;
end;
{$Else}
function FExists(const fname : String) : Boolean;
begin
  Result:=FileExists(fname);
end;
function DExists(const dname : String) : Boolean;
begin
  Result:=DirectoryExists(dname);
end;
{$Endif}

function BitsToMask(numbits : Integer) : Integer;
begin
  Result:=$1f;
  case numbits of
    6: Result:=$3f;
    7: Result:=$7f;
  end;
end;

function OppositeMask(numbits : Integer) : Integer;
begin
  Result:=INDICS_MASK;
  case numbits of
    6: Result:=(INDIC1_MASK and INDIC2_MASK);
    7: Result:=INDIC2_MASK;
  end;
end;

procedure SortCollection(Collection : TCollection;CompareFunc : TListSortCompare;Ascending : Boolean);
var
  lst : TList;
  i,cnt : Integer;
begin
  if (not assigned(Collection)) or (not assigned(CompareFunc)) or (Collection.Count<=1) then Exit;
  lst:=nil;
  try
    try
      lst:=TList.Create;
      cnt:=Collection.Count;
      for i:=0 to (cnt-1) do
      begin
        lst.Add(Collection.Items[i]);
      end;
      lst.Sort(CompareFunc);
      if Ascending then
      begin
        for i:=0 to (cnt-1) do
        begin
          if TCollectionItem(lst.Items[i]).Index<>i then
            TCollectionItem(lst.Items[i]).Index:=i;
        end;
      end else
      begin
        for i:=(cnt-1) downto 0 do
        begin
          if TCollectionItem(lst.Items[i]).Index<>i then
            TCollectionItem(lst.Items[i]).Index:=i;
        end;
      end;
    except

    end;
  finally
    FreeAndNil(lst);
  end;
end;

function MergeStrings(lst : TStrings) : String;
var
  i,cnt : Integer;
  s : String;
  P : PChar;
begin
  cnt:=lst.Count;
  Result:='';
  if cnt=1 then
  begin
    Result:=lst.Strings[0];
    Exit;
  end;
  for i:=0 to (cnt-1) do
  begin
    s:=lst.Strings[i];
    P:=PChar(s);
      while not (P^ in [#0..' ']) do
        Inc(P);
      Result := Result + S + ' ';
  end;
  System.Delete(Result, Length(Result), 1);
end;


procedure SplitStrings(const src : String;lst : TStrings);
var
  P, Start: PChar;
  S: string;
begin
  lst.Clear;
  P := Pointer(src);
  if P <> nil then
  begin
    while P^ <> #0 do
    begin
      Start := P;
      while not (P^ in [#0, #10, #13]) do Inc(P);
      SetString(S, Start, P - Start);
      lst.Add(S);
      if P^ = #13 then Inc(P);
      if P^ = #10 then Inc(P);
    end;
  end;
end;

{$Ifndef COMPILER6_UP}
function TMyStringList.Find(const S: string; var Index: Integer): Boolean;
var
  L, H, I, C: Integer;
begin
  Result := False;
  L := 0;
  H := Count - 1;
  while L <= H do
  begin
    I := (L + H) shr 1;
    C := CompareStrings(Strings[I], S);
    if C < 0 then L := I + 1 else
    begin
      H := I - 1;
      if C = 0 then
      begin
        Result := True;
        if Duplicates <> dupAccept then L := I;
      end;
    end;
  end;
  Index := L;
end;

function TMyStringList.IndexOf(const S: string): Integer;
var
  cnt : Integer;
begin
  if Sorted=True then
  begin
    if not Find(S, Result) then Result := -1;
  end else
  begin
    cnt:=Count;
    for Result := 0 to (cnt - 1) do
      if CompareStrings(Strings[Result], S) = 0 then Exit;
    Result := -1;
  end;
end;

function TMyStringList.CompareStrings(const S1, S2: string): Integer;
begin
  if CaseSensitive then
    Result := AnsiCompareStr(S1, S2)
  else
    Result := AnsiCompareText(S1, S2);
end;

procedure TMyStringList.SetCaseSensitive(Value : Boolean);
begin
  if Value <> FCaseSensitive then
  begin
    FCaseSensitive := Value;
    if Sorted=True then Sort;
  end;
end;

procedure TMyStringList.SetValueFromIndex(Index : Integer;const Value : String);
begin
  if Value <> '' then
  begin
    if (Index<0) then
      Index := Add('');
    Put(Index, Names[Index] + NameValueSeparator + Value);
  end else
    if (Index>=0) then
      Delete(Index);
end;

function TMyStringList.GetValueFromIndex(Index : Integer) : String;
begin
  if Index >= 0 then
    Result := Copy(Get(Index), Length(Names[Index]) + 2, MaxInt)
  else
    Result := '';
end;
{$Endif}

end.
Added src/delphisci/scilexermod.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
{
  Delphi Scintilla Interface Components
  Copyright (C) 2004,2005 Jan Martin Pettersen (hdalis)

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later
  version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free
  Software Foundatifon, Inc., 59 Temple Place, Suite 330, Boston, MA
  02111-1307 USA
}
{
  Author : hdalis
      $Id: scilexermod.pas,v 1.5 2004/11/13 04:29:51 hdalis Exp $
  History: 29/09/2004 Initial Release
           13/10/2004 Added help using ClassExplorer 6.0, Use the helpgenerator to
                      generate the help.
           13/10/2004 Changed the ViewWSpace from boolean to sciWSMode, to allow all settings.
           17/10/2004 Removed LoadSettingsFromStream and SaveSettingsToStream, unnessecary now.
           29/10/2004 Added The TSciHotSpot subclass to manage Active hotspot settings (TScintilla.ActiveHotspotOpts).
           30/10/2004 Added CommentBox and CommentBlock functions.
           10/11/2004 CommentBox and CommentStream now takes a boolean parameter 'includecommentcharsinselection'
                      that if it's True it selects the commenting strings also, if not then the commenting
                      strings are not selected.
           11/11/2004 Added the FlipVars function.
                      Updated the helpdescriptions in helpdescriptions.txt
           18/11/2004 Changed the TSciSynLexer to TSciLanguageManager, and changed all properties etc to reflect that.
                      became more logical eventually.
                      Added a keyboardmanager, is more easy to connect other components that also
                      want a keyboad/calltipclick that way.
                      The TSciLexerAuto component no longer exists. When you need autocomplete drop a
                      TSciAutoComplete component on the form, and set the editor property.
                      Or for Calltips drop a TSciCallTips component.
           19/11/2004 Made a miniversion of this component, TScintillaMemo.. This is the immediate
                      ancestor for TScintilla now. Separated in two files, SciLexerMemo.pas and SciLexerMod.Pas
                      All commentfunctions now uses SetTarget* and ReplaceTarget, instead of SetSel and ReplaceSel.
                      It seems faster to do it that way.
           08/02/2005 Added a LoadLexerLibrary override.. Until now you could load all libraries you wanted, but
                      they didn't appear in the languagemanager.. Now they do..
           09/01/2006 Added the class property FoldMarkers to expose all markers regarding folding,
                      so these can be customized.
           31/01/2006 Made some preparations for TSciLanguageManager standalone component
                      NOTE!! NOT COMPLETE.
           18/05/2006 Fixed a typo in a ifdef statement which resulted in not freeing the languagemanager
                      in the TScintilla component.

}

{$Include SciCommonDef.Inc}
unit SciLexerMod;
interface
uses Classes, Windows, Controls, Messages, SysUtils, Graphics,SciLexer,ScintillaLanguageManager, SciKeyBindings,
SciSupport,SciLexerMemo,SciControllerHandler;

type
  sciFoldDrawFlag=(sciAboveIfExpanded,sciAboveIfNotExpanded,sciBelowIfExpanded,sciBelowIfNotExpanded,sciHexLevels);
  sciFoldDrawFlags=set of sciFoldDrawFlag;

  // Display whitespace?
  sciMarkerType =(sciMarkCircle=0,sciMarkBox=1,sciMarkPlusMinus=2,sciMarkArrows=3,sciMarkCustom=4);
  sciCodeFoldingFlag=(foldFold,foldCompact,foldComment,foldPreprocessor,foldCommentPython,foldQuotesPython,
  foldAtElse,foldHTML,foldHTMLPreProcessor);
  sciCodeFoldingFlags=set of sciCodeFoldingFlag;

  TScintilla =class;



  TSciFoldMarkers=class(TPersistent)
    private
      FMarkerType : sciMarkerType;
      FFoldOpen,FFoldClosed,FFoldSub,
      FFoldTail,FFoldEnd,FFoldOpenMid,
      FFoldMidTail : TSciMarker;

      procedure SetMarkerType(const Value : sciMarkerType);
      procedure SetMarkers(const Value : sciMarkerType);
      procedure SetFoldOpen(Value : TSciMarker);
      procedure SetFoldClosed(Value : TSciMarker);
      procedure SetFoldSub(Value : TSciMarker);
      procedure SetFoldTail(Value : TSciMarker);
      procedure SetFoldEnd(Value : TSciMarker);
      procedure SetFoldOpenMid(Value : TSciMarker);
      procedure SetFoldMidTail(Value : TSciMarker);
    public
      constructor Create(Editor : TScintillaBase);
      destructor Destroy;override;
      procedure Assign(Source: TPersistent); override;
    published
      property MarkerType : sciMarkerType read FMarkerType write SetMarkerType;
      property FoldOpen : TSciMarker read FFoldOpen write SetFoldOpen;
      property FoldClosed : TSciMarker read FFoldClosed write SetFoldClosed;
      property FoldSub : TSciMarker read FFoldSub write SetFoldSub;
      property FoldTail : TSciMarker read FFoldTail write SetFoldTail;
      property FoldEnd : TSciMarker read FFoldEnd write SetFoldEnd;
      property FoldOpenMid : TSciMarker read FFoldOpenMid write SetFoldOpenMid;
      property FoldMidTail : TSciMarker read FFoldMidTail write SetFoldMidTail;
  end;

TScintilla = class(TScintillaMemo)
  private
    fLanguageManager : TSciLanguageManager;
    FCodeFoldingFlags : sciCodeFoldingFlags;
    FFoldDrawFlags : sciFoldDrawFlags;
    FBraceHilite : Boolean;
    FFoldMarkers : TSciFoldMarkers;
{$Ifdef USEXMLAUTOCOMPLETE}
    FAutoCloseTags : Boolean;
{$Endif}
{$Ifdef USENEWLOADLEXER}
    FLibrariesLoaded : TStrings;
{$Endif}

    procedure SetFoldMarkers(Value : TSciFoldMarkers);
    procedure SetLanguageManager(const Value : TSciLanguageManager);
    procedure SetCodeFoldingFlags(const Value : sciCodeFoldingFlags);
    procedure SetFoldDrawFlags(const Value : sciFoldDrawFlags);

  protected
    procedure BoxComment(start_comment,middle_comment,end_comment : String;includecommentcharsinselection : Boolean=True);
    procedure BlockComment(comment : String;commentatlinestart : Boolean);
    procedure StreamComment(start_comment,end_comment : String;includecommentcharsinselection : Boolean=True);
protected
    procedure Expand(var line: Integer; doExpand : Boolean;force: Boolean = false; visLevels: Integer = 0; level : Integer=-1);
    procedure ProcessBraces; virtual;
    procedure doSciUpdateUI;override;
    procedure doSciMarginClick(const modifiers : LongInt; const position : LongInt; const margin : LongInt);override;
    procedure doSciModified(const position : LongInt; const modificationType : LongInt; text : PChar;const length : LongInt; const linesAdded : LongInt; const line : LongInt;const foldLevelNow : LongInt; const foldLevelPrev : LongInt);override;
    procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
    procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED;
    procedure Loaded; override;
{$Ifdef USEXMLAUTOCOMPLETE}
    function HandleXml(ch : Char) : Boolean;
    procedure doSciCharAdded(const ch : Integer); override;
{$Endif}
{$Ifdef LMSTANDALONE}
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
{$Endif}
public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure CopyFrom(Source: TScintillaBase); override;
    procedure FoldAll;
    //Used for brace matching and highlighting
    procedure FindMatchingBracePosition(var braceAtCaret : Integer;var braceOpposite : Integer; var IsInside : boolean; sloppy : boolean=true);
    procedure GoMatchingBrace(Select : boolean; Sloppy : boolean); //Move carret to matching brace
    procedure CommentBox(includecommentcharsinselection : Boolean=True);
    procedure CommentBlock;
    procedure CommentStream(includecommentcharsinselection : Boolean=True);
    procedure ExportToHTML(Stream: TStream; Title : string;UseCurrentEOLMode : Boolean=True;CSSStream: TStream=nil;CSSFileName : String='');
    procedure FlipVars(const equalsign : String='=';spacebeforeandaftereq : Boolean=True;const endstatement : String=';');
{$Ifdef USENEWLOADLEXER}
    procedure LoadLexerLibrary(path : String);
    property  LibrariesLoaded : TStrings read FLibrariesLoaded;
{$Endif}
published
    //Enable or disable brace highlighting
    property BraceHilite : boolean read FBraceHilite write FBraceHilite default True;
    //Enable or disable code folding if supported by the highlighter
    property Folding : sciCodeFoldingFlags read FCodeFoldingFlags write SetCodeFoldingFlags;
    property FoldMarkers : TSciFoldMarkers read FFoldMarkers write SetFoldMarkers;

    //Get or set the Syntax highlighter
    property LanguageManager : TSciLanguageManager read fLanguageManager write SetLanguageManager;
    property FoldDrawFlags : sciFoldDrawFlags read FFoldDrawFlags write SetFoldDrawFlags;
{$Ifdef USEXMLAUTOCOMPLETE}
    property AutoCloseTags : Boolean read FAutoCloseTags write FAutoCloseTags;
{$Endif}
    property KeyCommands;
end;


implementation
uses Math,sciUtils,SciResLang;

const
  DefaultLinenumbersWidth = 4;




constructor TScintilla.Create(AOwner : TComponent);
begin
  inherited;
{$Ifdef USENEWLOADLEXER}
  FLibrariesLoaded:=nil;
{$Endif}
  FBraceHilite := True;
  FFoldMarkers:=TSciFoldMarkers.Create(Self);
{$Ifdef USEXMLAUTOCOMPLETE}
  FAutoCloseTags:=False;
{$Endif}
{$Ifndef LMSTANDALONE}
  fLanguageManager := TSciLanguageManager.Create(Self);
{$Else}
  fLanguageManager:=nil;
{$Endif}
  FFoldDrawFlags:=[sciBelowIfNotExpanded];
  FCodeFoldingFlags:=[foldCompact,foldComment,foldPreprocessor,foldAtElse,foldHTML,foldHTMLPreProcessor];
end;

destructor TScintilla.Destroy;
begin
{$Ifdef USENEWLOADLEXER}
  FreeAndNil(FLibrariesLoaded);
{$Endif}

{$Ifndef LMSTANDALONE}
  FreeAndNil(fLanguageManager);
{$Endif}
  FreeAndNil(FFoldMarkers);
  inherited;
end;

procedure TScintilla.Loaded;
begin
  try
    if assigned(fLanguageManager) then
      fLanguageManager.BeginUpdate;
    inherited;
  finally
    if assigned(fLanguageManager) then
      fLanguageManager.EndUpdate;
  end;
end;

procedure TScintilla.CMFontChanged(var Message: TMessage);
begin
  try
    if assigned(fLanguageManager) then
      fLanguageManager.BeginUpdate;
    inherited CMFontChanged(Message);
  finally
    if assigned(fLanguageManager) then
      fLanguageManager.EndUpdate;
  end;
end;

procedure TScintilla.CMColorChanged(var Message: TMessage);
begin
  try
    if assigned(fLanguageManager) then
      fLanguageManager.BeginUpdate;
    inherited CMColorChanged(Message);
  finally
    if assigned(fLanguageManager) then
      fLanguageManager.EndUpdate;
  end;
end;

procedure TScintilla.CopyFrom(Source: TScintillaBase);
begin
  inherited;
  if Assigned(Source) and (Source is TScintilla) then
  begin
    BraceHilite :=TScintilla(Source).BraceHilite;
    Folding:=TScintilla(Source).Folding;
    FoldMarkers:=TScintilla(Source).FoldMarkers;
    if assigned(fLanguageManager) then
    begin
        fLanguageManager.Assign(TScintilla(Source).LanguageManager);
        fLanguageManager.Update;
    end;
    FoldDrawFlags:=TScintilla(Source).FoldDrawFlags;
  end;
end;

{$Ifdef LMSTANDALONE}
procedure TScintilla.Notification(AComponent: TComponent; Operation: TOperation);
begin
  if (AComponent=fLanguageManager) and (Operation=opRemove) then
  begin
    fLanguageManager.RemoveNotification(Self);
    fLanguageManager:=nil;
  end else
  inherited;
end;
{$Endif}

procedure TScintilla.CommentStream(includecommentcharsinselection : Boolean);
var
  itm : TSciLangItem;
begin
  if not assigned(fLanguageManager) then Exit;

  itm:=fLanguageManager.LanguageList.Find(LanguageManager.SelectedLanguage);
  if itm<>nil then
  begin
   if (itm.CommentStreamStart='') or (itm.CommentStreamEnd='') then
   begin
     raise Exception.CreateRes(@eNoStartOrEndCommentDefined);
   end;
    StreamComment(itm.CommentStreamStart,itm.CommentStreamEnd,includecommentcharsinselection);
  end else
    StreamComment('/*','*/',includecommentcharsinselection);
end;

procedure TScintilla.CommentBox(includecommentcharsinselection : Boolean);
var
  itm : TSciLangItem;
begin
  if not assigned(fLanguageManager) then Exit;
  itm:=fLanguageManager.LanguageList.Find(LanguageManager.SelectedLanguage);
  if itm<>nil then
  begin
    if (itm.CommentBoxStart='') or (itm.CommentBoxMiddle='') or (itm.CommentBoxEnd='') then
    begin
      raise Exception.CreateRes(@eNoStartMiddleOrEndCommentDefined);
    end;
    BoxComment(itm.CommentBoxStart,itm.CommentBoxMiddle,itm.CommentBoxEnd,includecommentcharsinselection);
  end else
    BoxComment('/*','*','*/',includecommentcharsinselection);
end;

procedure TScintilla.CommentBlock;
var
  itm : TSciLangItem;
begin
  if not assigned(fLanguageManager) then Exit;
  itm:=fLanguageManager.LanguageList.Find(LanguageManager.SelectedLanguage);
  if itm<>nil then
  begin
   if (itm.CommentBlock='') then
   begin
     raise Exception.CreateRes(@eNoOneLineCommentDefined);
   end;

    BlockComment(itm.CommentBlock,itm.CommentAtLineStart);
  end else
    BlockComment('//',True);
end;

procedure TScintilla.BlockComment(comment : String;commentatlinestart : Boolean);
var
  caretPosition,selectionStart,selectionEnd,selStartLine,selEndLine,
  firstSelLineStart,numlines,i,lineStart,lineIndent,lineEnd,comment_length,
  curbuflen  : LongInt;
  move_caret : Boolean;
  linebuf,long_comment : String;
begin
  comment:=comment+' ';
  long_comment  :=comment;
  curbuflen:=0;
  comment_length:=Length(comment);
  selectionStart:=GetSelectionStart;
  selectionEnd :=GetSelectionEnd;
  caretPosition :=GetCurrentPos;
  move_caret :=(caretPosition<selectionEnd);
  selStartLine :=LineFromPosition(selectionStart);
  selEndLine :=LineFromPosition(selectionEnd);
  numlines :=selEndLine-selStartLine;
  firstSelLineStart:=PositionFromLine(selStartLine);
  if (numlines>0) and (selectionEnd=PositionFromLine(selEndLine)) then Dec(selEndLine);
  BeginUndoAction;
  for i:=selStartLine to selEndLine do
  begin
    lineStart:=PositionFromLine(i);
    lineIndent:=lineStart;
    lineEnd:=GetLineEndPosition(i);
    if (lineEnd-lineIndent)>=curbuflen then
    begin
      curbuflen:=lineEnd-lineIndent;
      SetLength(linebuf,curbuflen+1);
    end;
    if (commentatlinestart=True) then
      GetRange(lineIndent, lineEnd, PChar(linebuf))
    else
    begin
      lineIndent := GetLineIndentPosition(i);
      GetRange(lineIndent, lineEnd, PChar(linebuf));
    end;
    if Length(linebuf)<1 then Continue;
    // Insert comment removal here.
    if CompareMem(PChar(linebuf),PChar(comment),comment_length-1) then
    begin
      if CompareMem(PChar(linebuf),PChar(long_comment),comment_length) then
      begin
        SetTargetStart(lineIndent);
        SetTargetEnd(lineIndent+comment_length);
        ReplaceTarget(-1,PChar(''));
        if (i=selStartLine) then
          Dec(selectionStart,comment_length);
        Dec(selectionEnd,comment_length);
        Continue;
      end else
      begin
        SetTargetStart(lineIndent);
        SetTargetEnd(lineIndent+(comment_length-1));
        ReplaceTarget(-1,PChar(''));
        if (i=selStartLine) then
          Dec(selectionStart,comment_length-1);
        Dec(selectionEnd,comment_length-1);
        Continue;
      end;
    end;
    Inc(selectionEnd,Length(comment));
    InsertText(lineIndent,PChar(long_comment));
  end;
  if (selectionStart<firstSelLineStart) then
  begin
    if (selectionStart >= (selectionEnd - (Length(comment)- 1))) then
      selectionEnd := firstSelLineStart;
    selectionStart := firstSelLineStart;
  end;
  if move_caret=True then
  begin
    GotoPos(selectionEnd);
    SetCurrentPos(selectionStart);
  end else
    SetSel(selectionStart,selectionEnd);
  EndUndoAction;
end;

procedure TScintilla.BoxComment(start_comment,middle_comment,end_comment : String;includecommentcharsinselection : Boolean);
var
  caretPosition,selectionStart,selectionEnd,selStartLine,selEndLine,numlines,lineStart,lineEnd,i,
  start_comment_length,middle_comment_length,end_comment_length,maxCommentLength,whitespace_length,eollen  : Integer;
  move_caret : Boolean;
  linebuf,whitespace : String;
  tempstring : PChar;
  hasselection : Boolean;
begin
  SetLength(linebuf,1000);
  whitespace :=' ';
  start_comment :=start_comment+whitespace;
  middle_comment:=middle_comment+whitespace;
  selectionStart:=GetSelectionStart;
  selectionEnd :=GetSelectionEnd;
  caretPosition :=GetCurrentPos;
  hasselection :=(selectionStart-selectionEnd)<>0;
  move_caret :=(caretPosition<selectionEnd);
  selStartLine :=LineFromPosition(selectionStart);
  selEndLine :=LineFromPosition(selectionEnd);
  numlines :=selEndLine-selStartLine;
  if (numlines>1) and (selectionEnd=PositionFromLine(selEndLine)) then
  begin
    Dec(selEndLine);
    Dec(numlines);
    selectionEnd:=GetLineEndPosition(selEndLine);
  end;
  if numlines>1 then // More than one line, adjust the selection to the start of selstartline, and end of selendline.
  begin
    selectionStart:=PositionFromLine(selStartLine);
    selectionEnd:=GetLineEndPosition(selEndLine);
    SetSelectionStart(selectionStart);
    SetSelectionEnd(selectionEnd);
  end;
  start_comment_length:=Length(start_comment);
  middle_comment_length:=Length(middle_comment);
  end_comment_length:=Length(end_comment);
  maxCommentLength:=start_comment_length;
  whitespace_length:=Length(whitespace);
  if middle_comment_length>maxCommentLength then
    maxCommentLength:=middle_comment_length;
  if (end_comment_length+whitespace_length)>maxCommentLength then
    maxCommentLength:=end_comment_length+whitespace_length;
  GetMem(tempString,maxCommentLength+1);
  case EOLStyle of
    eolCRLF: begin
               eollen:=2;
             end;
     eolCR:  begin
               eollen:=1;
             end;
    eolLF:   begin
               eollen:=1;
             end;
          else eollen:=2;
  end;

  BeginUndoAction; // Start undoable operation.
  lineStart:=PositionFromLine(selStartLine);
  GetRange(lineStart, lineStart + start_comment_length, PChar(tempString));
  tempString[start_comment_length+1]:=#0;
  if start_comment<>tempString then // If it's not a start_comment, add it.
  begin
    InsertText(lineStart,PChar(start_comment));
    if numlines>1 then //More than one line selected
    begin
      Inc(selectionEnd,start_comment_length);
      if (includecommentcharsinselection=False) then Inc(selectionStart,start_comment_length);
    end else
    begin
      Inc(caretPosition,start_comment_length);
      if (hasselection=True) then
      begin
        Inc(selectionStart,start_comment_length);
        Inc(selectionEnd,start_comment_length);
      end;
    end;
  end else // If it's a start_comment, remove it.
  begin
    SetTargetStart(lineStart);
    SetTargetEnd(lineStart+start_comment_length);
    ReplaceTarget(-1,'');
    if numlines>1 then // More than one line selected
    begin
      Dec(selectionEnd,start_comment_length);
    end else
    begin
      Dec(caretPosition,start_comment_length);
      if (hasselection=True) then
      begin
      Dec(selectionStart,start_comment_length);
      Dec(selectionEnd,start_comment_length);
      end;
    end;
  end;
  if numlines<=1 then // One line or less selected.
  begin
    lineEnd:=GetLineEndPosition(selEndLine);
    GetRange(lineEnd - end_comment_length, lineEnd, PChar(tempString));
    tempString[end_comment_length+1] := #0;
    if (end_comment <> tempString) then // If it's not a end comment, add it.
    begin
      InsertText(lineEnd,PChar(whitespace+end_comment));
    end else // If it's a end comment, remove it.
    begin
      SetTargetStart(lineEnd-end_comment_length-whitespace_length);
      SetTargetEnd(lineEnd);
      ReplaceTarget(-1,'');
    end;
  end else // More than one line selected.
  begin
    for i:=(selStartLine+1) to (selEndLine-1) do
    begin
      lineStart:=PositionFromLine(i);
      GetRange(lineStart, lineStart + middle_comment_length, PChar(tempString));
      tempString[middle_comment_length+1] := #0;
      if (middle_comment <> tempString) then // If it's not a middle comment, add it.
      begin
        InsertText(lineStart,PChar(middle_comment));
        Inc(selectionEnd,middle_comment_length);
      end else // If it's a middle comment, remove it.
      begin
        SetTargetStart(lineStart);
        SetTargetEnd(lineStart+middle_comment_length);
        ReplaceTarget(-1,'');
        Dec(selectionEnd,middle_comment_length);
      end;
    end;
    lineStart:=PositionFromLine(selEndLine);
    GetRange(lineStart, lineStart + end_comment_length, PChar(tempString));
    tempString[end_comment_length+1] := #0;
    if (end_comment <> tempString) then // If it's not a end comment, add it.
    begin
      GetRange(lineStart, lineStart + middle_comment_length, PChar(tempString));
      tempString[middle_comment_length+1] := #0;
      if (middle_comment <> tempString) then
      begin
        InsertText(lineStart,PChar(middle_comment));
        Inc(selectionEnd,middle_comment_length);
      end else
      begin
        SetTargetStart(lineStart);
        SetTargetEnd(lineStart+middle_comment_length);
        ReplaceTarget(-1,'');
        Dec(selectionEnd,middle_comment_length);
      end;
      lineStart:=PositionFromLine(selEndLine+1);
      GetRange(lineStart, lineStart + end_comment_length, PChar(tempString));
      tempString[end_comment_length+1] := #0;
      if (end_comment <> tempString) then // If it's not a end comment, add it.
      begin
        InsertText(lineStart,PChar(end_comment));
        if (includecommentcharsinselection=True) then Inc(selectionEnd,end_comment_length);

        case EOLStyle of // Add the correct linefeed, and increment selectionend
          eolCRLF: begin
                     InsertText(lineStart+end_comment_length,PChar(CrLf));
                   end;
          eolCR:   begin
                     InsertText(lineStart+end_comment_length,PChar(#13));
                   end;
          eolLF:   begin
                     InsertText(lineStart+end_comment_length,PChar(#10));
                   end;
        end;
        if (includecommentcharsinselection=True) then Inc(selectionEnd,eollen);
      end else // If it's a end comment, remove it.
      begin
        SetTargetStart(lineStart);
        SetTargetEnd(lineStart++end_comment_length+eollen);
        ReplaceTarget(-1,'');
        if (includecommentcharsinselection=True) then Dec(selectionEnd,end_comment_length);
        if (includecommentcharsinselection=True) then Dec(selectionEnd,eollen); // Decrement with the length of the correct linefeed
      end;
    end else // If it's a end comment, remove it.
    begin
      SetTargetStart(lineStart);
      SetTargetEnd(lineStart+end_comment_length+eollen);
      ReplaceTarget(-1,'');
      Dec(selectionEnd,end_comment_length+eollen);
    end;
    EndUndoAction; // End undoable operation.
  end;

  if (move_caret=True) then
  begin
    GotoPos(selectionEnd);
    SetCurrentPos(selectionStart);
  end else if (numlines=0) then // If it wasn't selected anything, just move the caret to the corresponding previous position after the line was commented/not commented.
  begin
    if hasselection=True then
      SetSel(selectionStart,selectionEnd)
    else
      GotoPos(caretPosition);
  end else
  SetSel(selectionStart,selectionEnd);
  if assigned(tempString) then
  begin
    FreeMem(tempString);
  end;
end;

procedure TScintilla.StreamComment(start_comment,end_comment : String;includecommentcharsinselection : Boolean);
var
  caretPosition,selectionStart,selectionEnd,lineEnd,current,end_comment_length,start_comment_length,startword,endword,start_counter,end_counter,selLine,lineIndent  : Integer;
  move_caret : Boolean;
  linebuf,whitespace : String;
  temp : PChar;
begin
  whitespace :=' ';
  start_comment :=start_comment+ whitespace;
  whitespace :=whitespace+end_comment;
  end_comment := whitespace;
  start_comment_length:=Length(start_comment);
  end_comment_length:=Length(end_comment);
  selectionStart:=GetSelectionStart;
  selectionEnd  :=GetSelectionEnd;
  caretPosition :=GetCurrentPos;
  move_caret    :=(caretPosition<selectionEnd);
  if selectionEnd-selectionStart<=0 then
  begin
    selLine:=LineFromPosition(selectionStart);
    lineIndent:=GetLineIndentPosition(selLine);
    lineEnd:=GetLineEndPosition(selLine);
    if RangeIsAllWhitespace(lineIndent,lineEnd)=True then
    begin
      Exit;
    end;
    lineBuf:=GetLineS;
    SetLength(lineBuf,1000);
    current:=GetCaretInLine;
    if (CharPos(WordChars,AnsiChar(lineBuf[current]))=0) then
    begin
      Exit;
    end;
    start_counter:=0;
    end_counter:=0;
    startword:=current;
    endword:=current;
    while ((startword > 0) and (CharPos(WordChars,AnsiChar(lineBuf[startword]))<>0)) do
    begin
      Inc(start_counter);
      Dec(startword);
    end;
    if startword=current then
    begin
      Exit;
    end;
    while ((linebuf[endword + 1] <> #0) and (CharPos(WordChars,AnsiChar(lineBuf[endword + 1]))<>0)) do
    begin
      Inc(end_counter);
      Inc(endword);
    end;
    Dec(selectionStart,start_counter);
    Inc(selectionEnd,end_counter);
  end else
  begin
    GetMem(temp,Max(start_comment_length,end_comment_length)+1);
    GetRange(selectionStart, selectionStart + start_comment_length, temp);
    temp[start_comment_length+1]:=#0;
    if temp=start_comment then
    begin
      GetRange(selectionEnd - end_comment_length, selectionEnd, temp);
      temp[end_comment_length+1]:=#0;
      if temp=end_comment then
      begin
        BeginUndoAction;
        SetTargetStart(selectionStart);
        SetTargetEnd(selectionStart+start_comment_length);
        ReplaceTarget(-1,'');
        Dec(selectionEnd,start_comment_length);
        SetTargetStart(selectionEnd-end_comment_length);
        SetTargetEnd(selectionEnd);
        ReplaceTarget(-1,'');
        Dec(selectionEnd,end_comment_Length);
        EndUndoAction;
        if temp<>nil then
        begin
          FreeMem(temp);
        end;
        if move_caret=True then
        begin
          GotoPos(selectionEnd);
          SetCurrentPos(selectionStart);
        end else
        begin
          SetSel(selectionStart,selectionEnd);
        end;
        Exit;
      end;
    end;
    if temp<>nil then
    begin
      FreeMem(temp);
    end;
  end;
  BeginUndoAction;
  InsertText(selectionStart,PChar(start_comment));
  Inc(selectionEnd,start_comment_length);
  if (includecommentcharsinselection=False) then Inc(selectionStart,start_comment_length);
  InsertText(selectionEnd,PChar(end_comment));
  if (includecommentcharsinselection=True) then Inc(selectionEnd,end_comment_length);
  if move_caret=True then
  begin
    GotoPos(selectionEnd);
    SetCurrentPos(selectionStart);
  end else
  begin
    SetSel(selectionStart,selectionEnd);
  end;
  EndUndoAction;
end;

procedure TScintilla.SetFoldMarkers(Value : TSciFoldMarkers);
begin
  fFoldMarkers.Assign(Value);
end;

procedure TScintilla.SetLanguageManager(const Value: TSciLanguageManager);
begin
  {$Ifdef LMSTANDALONE}
  if (Value<>fLanguageManager) then
  begin
    if Assigned(fLanguageManager) then
      fLanguageManager.RemoveNotification(Self);
    fLanguageManager:=Value;
    if Assigned(fLanguageManager) then
    begin
      fLanguageManager.AddNotification(Self);
      fLanguageManager.Update;
    end;
  end;
  {$Else}
    fLanguageManager.Assign(Value);
  {$Endif}
end;

procedure TScintilla.Expand(var line: Integer; doExpand, force: Boolean;
  visLevels, level: Integer);
Var
  lineMaxSubord,LevelLine : Integer;
begin
  lineMaxSubord :=  GetLastChild(line, level and SC_FOLDLEVELNUMBERMASK);
  Inc(Line);
  while (line <= lineMaxSubord) do begin
    if force then
    begin
      if visLevels > 0 then
        ShowLines(line, line)
      else
        HideLines(line, line)
    end else begin
      if doExpand then
        ShowLines(line, line)
    end;
    LevelLine := level;
    if LevelLine = -1 then
      LevelLine := GetFoldLevel(line);
    if (levelLine and SC_FOLDLEVELHEADERFLAG) <> 0 then
    begin
      if force then
      begin
        if visLevels > 1 then
          SetFoldExpanded(line, True)
        else
          SetFoldExpanded(line, False);
        Expand(line, doExpand, force, visLevels - 1);
      end else begin
        if doExpand then
        begin
          if not GetFoldExpanded(line) then
            SetFoldExpanded(line, True);
          Expand(line, true, force, visLevels - 1);
        end else
          Expand(line, false, force, visLevels - 1);
      end;
    end else
      Inc(Line);
  end;
end;

procedure TScintilla.FoldAll;
Var
  MaxLine,LineSeek,Line,Level,LineMaxSubord : Integer;
  Expanding : Boolean;
begin
  Colourise(0, -1);
  MaxLine := GetLineCount;
  Expanding := True;
  for LineSeek := 0 to MaxLine -1 do begin
    if (GetFoldLevel(LineSeek) and  SC_FOLDLEVELHEADERFLAG) > 0 then
    begin
      Expanding := not GetFoldExpanded(LineSeek);
      break;
    end;
  end;
  Line := 0;
  While Line < MaxLine do begin
    level := GetFoldLevel(line);
    if ((level and SC_FOLDLEVELHEADERFLAG) <> 0) and
            (SC_FOLDLEVELBASE = (level and SC_FOLDLEVELNUMBERMASK)) then
    begin
      if expanding then
      begin
        SetFoldExpanded(line, True);
        Expand(line, true, false, 0, level);
        Dec(Line);
      end else begin
        LineMaxSubord := GetLastChild(line, -1);
        SetFoldExpanded(line, False);
        if LineMaxSubord > Line then
          HideLines(line+1, lineMaxSubord);
      end;
    end;
    Inc(Line);
  end;
end;

(**
 * Find if there is a brace next to the caret, checking before caret first, then
 * after caret. If brace found also find its matching brace.
 * @return @c true if inside a bracket pair.
 *)

procedure TScintilla.FindMatchingBracePosition(var braceAtCaret : Integer;
             var braceOpposite : Integer; var IsInside : boolean; sloppy : boolean=true);
Var
  IsAfter,ColonMode : boolean;
  CharBefore, CharAfter: Char;
  LineStart, LineMaxSubord,CaretPos :Integer;
begin
  IsInside := False;
  CaretPos := GetCurrentPos;
  BraceAtCaret := -1;
  BraceOpposite := -1;
  CharBefore := #0;
  if CaretPos > 0 then
    CharBefore := Char(GetCharAt(CaretPos -1));
  // Priority goes to character before caret
  if (CharBefore <> #0) and  (Pos(CharBefore, '[](){}') > 0)  then
    BraceAtCaret := caretPos - 1;

  ColonMode := False;
  if (GetLexer = SCLEX_PYTHON) and (CharBefore = ':') then
  begin
    BraceAtCaret := caretPos - 1;
    ColonMode := true;
  end;

  IsAfter := True;
  If (Sloppy and (BraceAtCaret < 0)) then
  begin
    // No brace found so check other side
    CharAfter := Char(GetCharAt(CaretPos));
    if (CharAfter <> #0) and  (Pos(CharAfter, '[](){}') > 0)  then
    begin
      BraceAtCaret := CaretPos;
      IsAfter := False;
    end;
    if (GetLexer = SCLEX_PYTHON) and (CharAfter = ':') then
    begin
      BraceAtCaret := caretPos;
      ColonMode := true;
    end;
  end;

  if BraceAtCaret >= 0 then
  begin
    if ColonMode then
    begin
      LineStart := LineFromPosition(BraceAtCaret);
      LineMaxSubord := GetLastChild(LineStart, -1);
      BraceOpposite := GetLineEndPosition(LineMaxSubord);
    end else
      BraceOpposite := BraceMatch(BraceAtCaret);

    if BraceOpposite > BraceAtCaret then
      IsInside := IsAfter
    else
      IsInside := not IsAfter;
  end;
end;

procedure TScintilla.GoMatchingBrace(Select: boolean; Sloppy : boolean);
Var
  BraceAtCaret,BraceOpposite : Integer;
  IsInside : Boolean;
begin
  FindMatchingBracePosition(braceAtCaret, braceOpposite, IsInside, Sloppy);
  // Convert the character positions into caret positions based on whether
  // the caret position was inside or outside the braces.
  if BraceOpposite >= 0 then
  begin
    if IsInside then
    begin
      if braceOpposite > braceAtCaret then
        Inc(braceAtCaret)
      else
        Inc(braceOpposite);
    end else begin
      if braceOpposite > braceAtCaret then
        Inc(braceOpposite)
      else
        Inc(braceAtCaret);
    end;

    EnsureRangeVisible(braceOpposite, braceOpposite);
    if Select then
      SetSel(braceAtCaret, braceOpposite)
    else
      SetSel(BraceOpposite, BraceOpposite);
  end;
end;


procedure TScintilla.ProcessBraces;
Var
  ColumnAtCaret, ColumnOpposite,lineStart, indentPos, indentSize,indentPosNext, columnAtCaretNext,BraceAtCaret,BraceOpposite : Integer;
  IsInside : boolean;
  chBrace : char;
begin
  FindMatchingBracePosition(BraceAtCaret, BraceOpposite, IsInside, True);
  if ((BraceAtCaret <> -1) and (BraceOpposite = -1)) then
  begin
    BraceBadLight(braceAtCaret);
    Self.SetHighlightGuide(0);
  end else begin
    chBrace := Char(GetCharAt(BraceAtCaret));
    BraceHighlight(braceAtCaret, braceOpposite);
    columnAtCaret := GetColumn(BraceAtCaret);
    columnOpposite := GetColumn(BraceOpposite);
    if chBrace = ':' then
    begin
      lineStart := LineFromPosition(braceAtCaret);
      indentPos := GetLineIndentPosition(lineStart);
      indentPosNext := GetLineIndentPosition(lineStart + 1);
      columnAtCaret := GetColumn(indentPos);
      columnAtCaretNext := GetColumn(indentPosNext);
      indentSize := Self.GetIndent;
      if (columnAtCaretNext - indentSize > 1) then
        columnAtCaret := columnAtCaretNext - indentSize;
      if (columnOpposite = 0) then  // If the final line of the structure is empty
        columnOpposite := columnAtCaret;
    end;
    Self.SetHighlightGuide(Min(columnAtCaret, columnOpposite));
  end;
end;

procedure TScintilla.ExportToHTML(Stream: TStream; Title : string;UseCurrentEOLMode : Boolean;CSSStream: TStream;CSSFileName : String);
Var
  StyleIsUsed  : array [0..STYLE_MAX+1] of boolean;
  lang : TSciLangItem;
  eolstr : String;
  usecss : Boolean;
  procedure WriteS(const S : String);
  begin
    Stream.Write(S[1], Length(S));
  end;
  procedure WriteCSS(const S : String);
  begin
    if usecss=True then
      CSSStream.Write(S[1], Length(S))
    else
      Stream.Write(S[1], Length(S))
  end;

  function ColorToHTMLColor(Color : TColor): string;
  var
    TempS : string;
  begin
    if Color<0 then
      Color:=ColorToRGB(Color);
    FmtStr(Result, '%s%.6x', ['#', Color]);
    // Now swap Blue and Red
    TempS := Result;
    Result[2] := TempS[6];
    Result[3] := TempS[7];
    Result[6] := TempS[2];
    Result[7] := TempS[3];
  end;

  procedure WriteStyle(const Style : TSciStyle);
  begin
    with Style do begin
      if not StyleIsUsed[StyleNumber] then exit;
      WriteCSS('.S'+IntToStr(StyleNumber)+ ' {'+eolstr);
      if FontName <> '' then
        WriteCSS(#9'font-family:' + FontName + ';'+eolstr);
      if FontSize <> 0 then
        WriteCSS(#9'font-size:' + IntToStr(Fontsize)+ 'pt' + ';'+eolstr);
      if fsItalic in FontStyles then
        WriteCSS(#9'font-style: italic;'+eolstr)
      else
        WriteCSS(#9'font-style: normal;'+eolstr);
      if fsBold in FontStyles then
        WriteCSS(#9'font-weight: 700;'+eolstr)
      else
        WriteCSS(#9'font-weight: 400;'+eolstr);
      if fsUnderline in FontStyles then
         WriteCSS(#9'text-decoration:underline;'+eolstr)
      else
         WriteCSS(#9'text-decoration:none;'+eolstr);
      if ForeColor<>clDefault then
        WriteCSS(#9'color: ' +  ColorToHTMLColor(ForeColor) +';'+eolstr);
      if BackColor<>clDefault then
        WriteCSS(#9'background: ' +  ColorToHTMLColor(BackColor) +';'+eolstr);
      WriteCSS('}'+eolstr);
    end;
  end;

Var
  i, itab,TabSize,Style, StyleCurrent, LengthDoc : Integer;
  ch : char;
begin
  usecss:=False;
  if not assigned(fLanguageManager) then Exit;
  if Assigned(CSSStream) and (CSSFileName<>'') then
    usecss:=True;
  if UseCurrentEOLMode=True then
  begin
  case EOLStyle of
  eolCRLF: eolstr:=CrLf;
  eolCR:eolstr:=#13;
  eolLF:eolstr:=#10;
  end;
  end else eolstr:=CrLf;

  Colourise(0,-1);
  TabSize := TabWidth;
  if TabSize = 0 then
    TabSize := 4;
  lang:=fLanguageManager.LanguageList.Find(fLanguageManager.SelectedLanguage);
  LengthDoc := GetLength;
  for i := 0 to STYLE_MAX + 1 do
    StyleIsUsed[i] := false;
  // check the used styles
  for i := 0 to LengthDoc do
    StyleIsUsed[GetStyleAt(i)] := true;
  StyleIsUsed[STYLE_DEFAULT] := true;

  WriteS('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+eolstr);
  WriteS('<html xmlns="http://www.w3.org/1999/xhtml">'+eolstr);
  WriteS('<head>'+eolstr);
  WriteS('<title>'+Title+'</title>'+eolstr);
  WriteS('<meta name="GENERATOR" content="Delphi Scintilla Interface Components - delphisci.sourceforge.net"/>'+eolstr);
  if CodePage=SC_CP_UTF8 then
    WriteS('<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>' +eolstr);
  if (usecss=False) then
    WriteS('<style type="text/css">'+eolstr);
  WriteCSS('body {background: '+ColorToHTMLColor(Color)+';}');
  // Write default style
  WriteCSS('span {'+eolstr);
  WriteCSS(#9'font-family:' + Font.Name + ';'+eolstr);
  WriteCSS(#9'font-size:' + ToStr(Font.Size)+ 'pt' + ';'+eolstr);
  if fsItalic in Font.Style then
    WriteCSS(#9'font-style: italic;'+eolstr)
  else
    WriteCSS(#9'font-style: normal;'+eolstr);
  if fsBold in Font.Style then
    WriteCSS(#9'font-weight: 700;'+eolstr)
  else
    WriteCSS(#9'font-weight: 400;'+eolstr);
  if fsUnderline in Font.Style then
     WriteCSS(#9'text-decoration:underline;'+eolstr)
  else
     WriteCSS(#9'text-decoration:none;'+eolstr);
  WriteCSS(#9'color: ' +  ColorToHTMLColor(Font.Color) +';'+eolstr);
  WriteCSS(#9'background: ' +  ColorToHTMLColor(Color) +';'+eolstr);
  WriteCSS('}'+eolstr);
  // Write all styles
  for i := 0 to lang.Styles.Count - 1 do
    WriteStyle(lang.Styles.Items[i] as TSciStyle);
  if usecss=False then
    WriteS('</style>'+eolstr)
  else
    WriteS('<link rel="StyleSheet" href="'+ExtractFileName(CSSFileName)+'" type="text/css"/>');
  WriteS('</head>'+eolstr);
  WriteS('<body><div class="mainbody">'+eolstr);

  StyleCurrent := GetStyleAt(0);
//  Line = Self.GetLine(0);
//  Level = (acc.LevelAt(line) & SC_FOLDLEVELNUMBERMASK) - SC_FOLDLEVELBASE;

  WriteS('<span>');
  WriteS('<span class="S'+ ToStr(styleCurrent) + '">');
  for i := 0 to lengthDoc -1 do begin
    ch := Char(GetCharAt(i) and $FF);
    Style := GetStyleAt(i);
    if Style <> StyleCurrent then
    begin
      WriteS('</span>');
      styleCurrent := style; //moved this before the <span writing.. Didn't write the correct style otherwise.
      WriteS('<span class="S'+ ToStr(styleCurrent) + '">');
    end;
    Case Ord(ch) of
      Ord(' ') :
        begin
          if (Char(GetCharAt(i+1) and $FF) <> ' ') or (i+1 >= LengthDoc) then
            // Single space, kept as is
            WriteS(' ')
          else
            WriteS('&nbsp;');
        end;
      $9 :  //Tab
        for itab := 1 to TabSize do WriteS('&nbsp;');
      $D, $A :
        begin
          if not ((ch = #13) and (GetCharAt(i+1) = $A)) then
          begin
            WriteS('<br/>');
            WriteS('</span>');
            StyleCurrent := GetStyleAt(i + 1);
            WriteS(eolstr);
            // we know it's the correct next style
            WriteS('<span class="S'+ IntToStr(styleCurrent) + '">');
          end;
        end;
      Ord('<') : WriteS('&lt;');
      Ord('>') : WriteS('&gt;');
      Ord('&') : WriteS('&amp;');
      Ord('"') : WriteS('&quot;');
      Ord('æ') : WriteS('&aelig;');
      Ord('Æ') : WriteS('&AElig;');
      Ord('ø') : WriteS('&oslash;');
      Ord('Ø') : WriteS('&Oslash;');
      Ord('å') : WriteS('&aring;');
      Ord('Å') : WriteS('&Aring;');
    else
      WriteS(ch);
    end;
  end;
  WriteS('</span>');
  WriteS('</span>');
  WriteS(eolstr+'</div></body>'+eolstr+'</html>'+eolstr);
end;

//FlipVars may have a bug, but I've not been able to redo what caused it..
//To be checked out..
 { TODO 5 -ohdalis -cBug : Check out more throughly whether it's a bug in the FlipVars function. }
procedure TScintilla.FlipVars(const equalsign : String;spacebeforeandaftereq : Boolean;const endstatement : String);
  function SplitString(const src : String;var LeftSide,RightSide : String;const Separator,Eol : String;var notfound : Boolean) : String;
  var
    endstatementpos,eqpos,eollen,seplen : Integer;
  begin
    notfound:=False;
    eqpos:=Pos(Separator,src);
    seplen:=Length(Separator);
    if eqpos=0 then
    begin
      notfound:=True;
      Exit;
    end;
    if Eol='' then endstatementpos:=Length(src)
    else
      endstatementpos:=Pos(Eol,src);
    if endstatementpos=0 then
    begin
      endstatementpos:=Length(src);
      eollen:=0;
    end
    else eollen:=Length(Eol);
    leftside:=System.Copy(src,1,eqpos-1);
    rightside:=System.Copy(src,eqpos+seplen,endstatementpos-(eqpos+seplen));
    Result:=System.Copy(src,endstatementpos+eollen,Length(src));
  end;
var
  caretPosition,selectionStart,selectionEnd,selStartLine,selEndLine,numlines,lineStart,lineEnd,i,lineLength: Integer;
  move_caret,hasselection,notfound : Boolean;
  tmp,linebuf,whitespace,leftpart,rightpart: String;
begin
  SetLength(linebuf,1000);
  whitespace :=' ';
  selectionStart:=GetSelectionStart;
  selectionEnd :=GetSelectionEnd;
  caretPosition :=GetCurrentPos;
  hasselection :=(selectionStart-selectionEnd)<>0;
  if (hasselection=False) then
  begin
    selStartLine:=LineFromPosition(caretPosition);
    selectionStart:=GetLineIndentPosition(selStartLine);
    selectionEnd:=GetLineEndPosition(LineFromPosition(caretPosition));
  end;
  move_caret :=(caretPosition<selectionEnd);
  selStartLine :=LineFromPosition(selectionStart);
  selEndLine :=LineFromPosition(selectionEnd);
  numlines :=selEndLine-selStartLine;
  if (numlines>1) and (selectionEnd=PositionFromLine(selEndLine)) then
  begin
    Dec(selEndLine);
    selectionEnd:=GetLineEndPosition(selEndLine);
  end;
  BeginUndoAction;
  for i:=selStartLine to selEndLine do
  begin
    lineStart:=GetLineIndentPosition(i);
    lineEnd:=GetLineEndPosition(i);
    if hasselection then
    begin
    if lineStart<selectionStart then lineStart:=selectionStart;
    if selectionEnd<lineEnd then lineEnd:=selectionEnd;
    end;
    lineBuf:=GetLineS(i);
    lineLength:=lineEnd-lineStart;
    if lineLength<=0 then Continue;
    SetLength(lineBuf,lineLength);
    GetRange(lineStart,lineEnd,PChar(lineBuf));

    if RangeIsAllWhiteSpace(lineStart,lineEnd)=False then
    begin
      tmp:='';
      repeat
        if notfound=False then
        begin
          if tmp<>'' then tmp:=tmp+' ';
          if spacebeforeandaftereq=True then
            tmp:=tmp+Trim(rightpart)+whitespace+equalsign+whitespace+Trim(leftpart)+endstatement
          else
            tmp:=tmp+Trim(rightpart)+equalsign+Trim(leftpart)+endstatement;
        end;
        lineBuf:=SplitString(lineBuf,leftpart,rightpart,equalsign,endstatement,notfound);
      until(notfound=True);
      if tmp<>'' then
      begin
        Inc(selectionEnd,Length(tmp)-lineLength);
        SetSel(lineStart,lineEnd);
        ReplaceSel(PChar(tmp));
      end;
    end;
  end;
  EndUndoAction;
  if move_caret=True then
  begin
    if hasselection then
    begin
      GotoPos(selectionEnd);
      SetCurrentPos(selectionStart);
    end else GotoPos(caretPosition);
  end else
    if hasselection then
    begin
      SetSel(selectionStart,selectionEnd);
    end else
      GotoPos(caretPosition);
end;

{$Ifdef USENEWLOADLEXER}
procedure TScintilla.LoadLexerLibrary(path : String);
var
  hinst : Cardinal;
  CountFn : GetLexerCountFn;
  NameFn : GetLexerNameFn;
  i,cnt : Integer;
  tmpnamebuf : String;
begin
  if not assigned(fLanguageManager) then
  begin
    Inherited;
    Exit;
  end;
  if assigned(FLibrariesLoaded) then
  begin
    if FLibrariesLoaded.IndexOf(SysUtils.LowerCase(path))<>-1 then
      Exit;
  end;
  if FExists(path) then
  begin
    hinst:=LoadLibrary(PChar(path));
    if(hinst<>0) then
    begin
      CountFn:=GetProcAddress(hinst,'GetLexerCount');
      NameFn:=GetProcAddress(hinst,'GetLexerName');
      if assigned(CountFn) and assigned(NameFn) then
      begin
        cnt:=CountFn;
        for i:=0 to (cnt-1) do
        begin
          tmpnamebuf:='';
          SetLength(tmpnamebuf,200);
          NameFn(i,PChar(tmpnamebuf),200);
          if tmpnamebuf<>'' then
          begin
            if fLanguageManager.HasLexer(tmpnamebuf)=false then
              fLanguageManager.AddLexer(tmpnamebuf);
          end;
        end;
      end;
      inherited LoadLexerLibrary(PChar(path));
      if not assigned(FLibrariesLoaded) then
        FLibrariesLoaded:=TMyStringList.Create;
      FLibrariesLoaded.Add(SysUtils.LowerCase(path));
      FreeLibrary(hinst);
    end;
  end;
end;
{$Endif}

procedure TScintilla.SetCodeFoldingFlags(const Value : sciCodeFoldingFlags);
begin
  FCodeFoldingFlags:=Value;
  if foldFold in Value then
  begin
    Gutter2.Width := 14;
    // Respond to mouse click
    Gutter2.Sensitive:=True;
    //SetMarginSensitiveN(2, True);
    // Tell the lexer that we want folding info
    SetProperty('fold', '1');

    if foldCompact in FCodeFoldingFlags then
      SetProperty('fold.compact', '1')
    else
      SetProperty('fold.compact', '0');

    if foldComment in FCodeFoldingFlags then
      SetProperty('fold.comment', '1')  // Fold multiline comments
    else
      SetProperty('fold.comment', '0');
    if foldPreProcessor in FCodeFoldingFlags then
      SetProperty('fold.preprocessor', '1')
    else
     SetProperty('fold.preprocessor', '0');
    if foldAtElse in FCodeFoldingFlags then
      SetProperty('fold.at.else', '1')
    else
     SetProperty('fold.at.else', '0');
    if foldHTML in FCodeFoldingFlags then
      SetProperty('fold.html', '1')
    else
     SetProperty('fold.html', '0');
    if foldHTMLPreProcessor in FCodeFoldingFlags then
      SetProperty('fold.html.preprocessor', '1')
    else
     SetProperty('fold.html.preprocessor', '0');
    if foldCommentPython in FCodeFoldingFlags then
      SetProperty('fold.comment.python', '1')
    else
     SetProperty('fold.comment.python', '0');
    if foldQuotesPython in FCodeFoldingFlags then
      SetProperty('fold.quotes.python', '1')
    else
     SetProperty('fold.quotes.python', '0');

    //SetFoldFlags(16);
    // Set folding styles
    //SetMarkers(FFoldMarkerType);
    SetMarginMaskN(2,Integer(SC_MASK_FOLDERS));
    //  The following is to handle SC_MOD_CHANGEFOLD in the Modified event handler
    SetModEventMask(GetModEventMask or SC_MOD_CHANGEFOLD);
  end else begin
    SetProperty('fold', '0');
    Gutter2.Width := 0;
  end;
end;

procedure TScintilla.SetFoldDrawFlags(const Value : sciFoldDrawFlags);
var
  tmp : LongInt;
begin
tmp:=0;
  FFoldDrawFlags:=Value;
  if sciAboveIfExpanded in FFoldDrawFlags then
    tmp:=tmp+2;
  if sciAboveIfNotExpanded in FFoldDrawFlags then
    tmp:=tmp+4;
  if sciBelowIfExpanded in FFoldDrawFlags then
    tmp:=tmp+8;
  if sciBelowIfNotExpanded in FFoldDrawFlags then
    tmp:=tmp+16;
  if sciHexLevels in FFoldDrawFlags then
    tmp:=tmp+64;
  SetFoldFlags(tmp);
end;

procedure TScintilla.doSciModified(const position : LongInt; const modificationType : LongInt; text : PChar;
const length : LongInt; const linesAdded : LongInt; const line : LongInt; const foldLevelNow : LongInt; const foldLevelPrev : LongInt);
var
  tmpline : LongInt;
begin
  tmpline:=line;
  if (modificationType and SC_MOD_CHANGEFOLD) <> 0 then
  begin
    if (foldLevelNow and SC_FOLDLEVELHEADERFLAG) <> 0 then
    begin
      if (foldLevelPrev and SC_FOLDLEVELHEADERFLAG) = 0 then
        SetFoldExpanded(line, True);
    end else if (foldLevelPrev and SC_FOLDLEVELHEADERFLAG) <> 0 then
    begin
      if not GetFoldExpanded(line) then
        // Removing the fold from one that has been contracted so should expand
        // otherwise lines are left invisible with no way to make them visible
        Expand(tmpline, true, false, 0, foldLevelPrev);
    end;
    end;
  inherited doSciModified(position,modificationType,text,length,linesAdded,tmpline,foldLevelNow,foldLevelPrev);
end;

procedure TScintilla.doSciMarginClick(const modifiers : LongInt; const position : LongInt; const margin : LongInt);
var
  LineClick,
  LevelClick : Integer;
begin
  if (foldFold in FCodeFoldingFlags) and (Margin = 2) then
    begin
    LineClick := LineFromPosition(Position);
    if (Modifiers and SCMOD_SHIFT <> 0) and (Modifiers and SCMOD_CTRL <> 0) then
      FoldAll
    else begin
      LevelClick := GetFoldLevel(LineClick);
      if (LevelClick and SC_FOLDLEVELHEADERFLAG) <> 0 then
      begin
        if (modifiers and SCMOD_SHIFT) <> 0 then
        begin
          // Ensure all children visible
          SetFoldExpanded(LineClick, True);
          Expand(lineClick, true, true, 100, levelClick);
        end else if (modifiers and SCMOD_CTRL) <> 0 then
        begin
          if GetFoldExpanded(lineClick) then
          begin
            // Contract this line and all children
            SetFoldExpanded(LineClick, False);
            Expand(lineClick, false, true, 0, levelClick);
          end else begin
            // Expand this line and all children
            SetFoldExpanded(LineClick, True);
            Expand(lineClick, true, true, 100, levelClick);
          end;
        end else begin
          // Toggle this line
          ToggleFold(LineClick);
        end;
      end;
    end;
  end;
  //if assigned(FOnmarginclick) then FOnmarginclick(Self, modifiers, position, margin);
  inherited doSciMarginClick(modifiers,position,margin);
end;

procedure TScintilla.doSciUpdateUI;
begin
 if FBraceHilite then ProcessBraces;
  inherited doSciUpdateUI;
end;


{
      DefineMarker(SC_MARKNUM_FOLDEROPEN, SC_MARK_BOXMINUS);
      DefineMarker(SC_MARKNUM_FOLDER, SC_MARK_BOXPLUS);
      DefineMarker(SC_MARKNUM_FOLDERSUB, SC_MARK_VLINE);
      DefineMarker(SC_MARKNUM_FOLDERTAIL, SC_MARK_LCORNER);
      DefineMarker(SC_MARKNUM_FOLDEREND, SC_MARK_BOXPLUSCONNECTED);
      DefineMarker(SC_MARKNUM_FOLDEROPENMID, SC_MARK_BOXMINUSCONNECTED);
      DefineMarker(SC_MARKNUM_FOLDERMIDTAIL, SC_MARK_TCORNER);

}

constructor TSciFoldMarkers.Create(Editor : TScintillaBase);
begin
  inherited Create;
  FFoldOpen:=TSciMarker.Create(Editor,SC_MARKNUM_FOLDEROPEN,SC_MARK_BOXMINUS);
  FFoldClosed:=TSciMarker.Create(Editor,SC_MARKNUM_FOLDER,SC_MARK_BOXPLUS);
  FFoldSub:=TSciMarker.Create(Editor,SC_MARKNUM_FOLDERSUB,SC_MARK_VLINE);
  FFoldTail:=TSciMarker.Create(Editor,SC_MARKNUM_FOLDERTAIL,SC_MARK_LCORNER);
  FFoldEnd:=TSciMarker.Create(Editor,SC_MARKNUM_FOLDEREND,SC_MARK_BOXPLUSCONNECTED);
  FFoldOpenMid:=TSciMarker.Create(Editor,SC_MARKNUM_FOLDEROPENMID,SC_MARK_BOXMINUSCONNECTED);
  FFoldMidTail:=TSciMarker.Create(Editor,SC_MARKNUM_FOLDERMIDTAIL,SC_MARK_TCORNER);
  FMarkerType:=sciMarkBox;
end;

destructor TSciFoldMarkers.Destroy;
begin
  inherited;
  FreeAndNil(FFoldOpen);
  FreeAndNil(FFoldClosed);
  FreeAndNil(FFoldSub);
  FreeAndNil(FFoldTail);
  FreeAndNil(FFoldEnd);
  FreeAndNil(FFoldOpenMid);
  FreeAndNil(FFoldMidTail);
end;

procedure TSciFoldMarkers.Assign(Source: TPersistent);
begin
  if (Source is TSciFoldMarkers) then
  begin
    MarkerType:=TSciFoldMarkers(Source).FMarkerType;
    if MarkerType<>sciMarkCustom then
    begin
      FFoldOpen.Assign(TSciFoldMarkers(Source).FFoldOpen);
      FFoldClosed.Assign(TSciFoldMarkers(Source).FFoldClosed);
      FFoldSub.Assign(TSciFoldMarkers(Source).FFoldSub);
      FFoldTail.Assign(TSciFoldMarkers(Source).FFoldTail);
      FFoldEnd.Assign(TSciFoldMarkers(Source).FFoldEnd);
      FFoldOpenMid.Assign(TSciFoldMarkers(Source).FFoldOpenMid);
      FFoldMidTail.Assign(TSciFoldMarkers(Source).FFoldMidTail);
    end;
  end else
  inherited;
end;

procedure TSciFoldMarkers.SetFoldOpen(Value : TSciMarker);
begin
  FFoldOpen.Assign(Value);
end;

procedure TSciFoldMarkers.SetFoldClosed(Value : TSciMarker);
begin
  FFoldClosed.Assign(Value);
end;

procedure TSciFoldMarkers.SetFoldSub(Value : TSciMarker);
begin
  FFoldSub.Assign(Value);
end;

procedure TSciFoldMarkers.SetFoldTail(Value : TSciMarker);
begin
  FFoldTail.Assign(Value);
end;

procedure TSciFoldMarkers.SetFoldEnd(Value : TSciMarker);
begin
  FFoldEnd.Assign(Value);
end;

procedure TSciFoldMarkers.SetFoldOpenMid(Value : TSciMarker);
begin
  FFoldOpenMid.Assign(Value);
end;

procedure TSciFoldMarkers.SetFoldMidTail(Value : TSciMarker);
begin
  FFoldMidTail.Assign(Value);
end;

procedure TSciFoldMarkers.SetMarkerType(const Value : sciMarkerType);
begin
  if Value<>FMarkerType then
  begin
    FMarkerType:=Value;
    SetMarkers(Value);
  end;
end;

procedure TSciFoldMarkers.SetMarkers(const Value : sciMarkerType);
begin
  case Value of
    sciMarkBox:
      begin
        FFoldOpen.MarkerType:=SC_MARK_BOXMINUS;
        FFoldClosed.MarkerType:=SC_MARK_BOXPLUS;
        FFoldSub.MarkerType:=SC_MARK_VLINE;
        FFoldTail.MarkerType:=SC_MARK_LCORNER;
        FFoldEnd.MarkerType:=SC_MARK_BOXPLUSCONNECTED;
        FFoldOpenMid.MarkerType:=SC_MARK_BOXMINUSCONNECTED;
        FFoldMidTail.MarkerType:=SC_MARK_TCORNER;
      end;
    sciMarkCircle:
      begin
        FFoldOpen.MarkerType:=SC_MARK_CIRCLEMINUS;
        FFoldClosed.MarkerType:=SC_MARK_CIRCLEPLUS;
        FFoldSub.MarkerType:=SC_MARK_VLINE;
        FFoldTail.MarkerType:=SC_MARK_LCORNER;
        FFoldEnd.MarkerType:=SC_MARK_LCORNERCURVE;
        FFoldOpenMid.MarkerType:=SC_MARK_CIRCLEPLUSCONNECTED;
        FFoldMidTail.MarkerType:=SC_MARK_TCORNERCURVE;
      end;
    sciMarkPlusMinus:
      begin
        FFoldOpen.MarkerType:=SC_MARK_MINUS;
        FFoldClosed.MarkerType:=SC_MARK_PLUS;
        FFoldSub.MarkerType:=SC_MARK_EMPTY;
        FFoldTail.MarkerType:=SC_MARK_EMPTY;
        FFoldEnd.MarkerType:=SC_MARK_EMPTY;
        FFoldOpenMid.MarkerType:=SC_MARK_EMPTY;
        FFoldMidTail.MarkerType:=SC_MARK_EMPTY;
      end;
    sciMarkArrows:
      begin
        FFoldOpen.MarkerType:=SC_MARK_ARROWDOWN;
        FFoldClosed.MarkerType:=SC_MARK_ARROW;
        FFoldSub.MarkerType:=SC_MARK_EMPTY;
        FFoldTail.MarkerType:=SC_MARK_EMPTY;
        FFoldEnd.MarkerType:=SC_MARK_EMPTY;
        FFoldOpenMid.MarkerType:=SC_MARK_EMPTY;
        FFoldMidTail.MarkerType:=SC_MARK_EMPTY;
      end;
  end;
end;

{$Ifdef USEXMLAUTOCOMPLETE}
procedure TScintilla.doSciCharAdded(const ch : Integer);
begin
  inherited;
  if (not AutoCActive) and (not CallTipActive) then
  begin
    HandleXml(Char(ch));
  end;
end;

function FindOpenXmlTag(const Sel : PChar;nSize : Integer) : String;
var
  pBegin,pCur : PAnsiChar;
begin
  Result:='';
  if nSize<3 then
    Exit;
  pBegin:=@Sel[0];
  pCur:=@Sel[nSize-1];
  Dec(pCur);
  while(pCur>pBegin) do
  begin
    if pCur^='<' then
      break
    else if pCur^='>' then
      break;
    Dec(pCur);
  end;
  if pCur^='<' then
  begin
    Inc(pCur);
    while (pCur^ in [':','_','-','.']) or
    ((pCur^>='a') and (pCur^<='z')) or
    ((pCur^>='A') and (pCur^<='A')) or
    ((pCur^>='0') and (pCur^<='9')) do
    begin
      Result:=Result+pCur^;
      Inc(pCur);
    end;
  end;
end;

function TScintilla.HandleXml(ch : Char) : Boolean;
var
  itm : TSciLangItem;
  nCaret,nMin : Integer;
  Sel : array of Char;
  strFound,toInsert : String;
begin
  Result:=False;
  try
  if (FAutoCloseTags=False) or (ch<>'>') then Exit;
  itm:=LanguageManager.LanguageList.Find(LanguageManager.SelectedLanguage);
  if assigned(itm) then
    if not (SameText(itm.Lexer,'hypertext')) then
      Exit;
  nCaret:=GetCurrentPos;
  nMin:=nCaret-511;
  if nMin<0 then
    nMin:=0;
  if (nCaret-nMin)<3 then
    Exit;
  SetLength(Sel,512);
  GetRange(nMin, nCaret, PChar(Sel));
  Sel[nCaret-nMin+1]:=#0;
  if Sel[nCaret-nMin-2]='/' then Exit;
  strFound:=FindOpenXmlTag(PChar(Sel),nCaret - nMin);
  if Length(strFound)>0  then
  begin
    BeginUndoAction;
    toInsert:='</'+strFound+'>';
    ReplaceSel(PChar(toInsert));
    SetSel(nCaret,nCaret);
    EndUndoAction;
  end;
  finally
    Sel:=nil;
  end;
end;
{$Endif}
end.
Added src/delphisci/tcFontComboBox.dcr.

cannot compute difference between binary files

Added src/delphisci/tcFontComboBox.res.

cannot compute difference between binary files

Added src/delphisci/tcFontCombobox.dfm.

cannot compute difference between binary files

Added src/delphisci/tcFontCombobox.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
{--------------------------------------------------------------------------------
* Dates : March 2002
* Version : 1.0
* Author : Stefan Cruysberghs
* Email : stefancr@scip.be
* Website : http://www.scip.be
  Visit Stefan's Homepage for other components and tools
--------------------------------------------------------------------------------
* $Archive: /Component Library/SC_Public/scFontCombobox.pas $
* $Author: hdalis $
* $Date: 2004/11/13 04:29:51 $
* $Modtime: 3/09/02 21:53 $
* $Revision: 1.4 $
--------------------------------------------------------------------------------
* This component is free of charge.
* The author doesn't give a warranty for error free running
  of this component and he doesn't give any support.
* Suggestions and bugs can be send by email.
--------------------------------------------------------------------------------
}
{

  History: 29/09/2004 Initial Release with Delphi Scintilla Interface Components
                      Used only in the EdOptionsWin.pas form.
                      Renamed the component for use with the Delphi Scintilla Interface Components
                      project to avoid clashes with other components.
                      Jan Martin Pettersen (hdalis@users.sourceforge.net)
           26/10/2004 Fixed a bug that caused the fontname to overwrite the dropdownbutton.
                      Couldn't get the component to return the proper fontname,
                      it only returned fontname=whatever so
                      created GetFontName to get it to return the fontname alone.
                      hdalis (hdalis@users.sourceforge.net)
      $Id: tcFontCombobox.pas,v 1.4 2004/11/13 04:29:51 hdalis Exp $
}
{$Include SciCommonDef.Inc}
unit tcFontCombobox;
interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  ExtCtrls, StdCtrls;

type
  TFormExampleFont = class(TForm)
    PanelPreview: TPanel;
    PanelFontName: TPanel;
  private
  public
  end;

  TscFontType = (ftTrueTypeAnsi, ftTrueTypeSymbol, ftRaster);
  TscFontTypes = set of TscFontType;

  TtcFontCombobox = class(TCustomComboBox)
  private
    FormExample : TFormExampleFont;
    BitmapTrueTypeAnsi : TBitmap;
    BitmapTrueTypeSymbol : TBitmap;
    BitmapRaster : TBitmap;
    IntCountUsed : Integer;
    BlnDown : Boolean;

    FIntPreviewWidth : Integer;
    FIntPreviewHeight : Integer;
    FStrFontName : String;
    FStrPreviewText : String;
    FBlnMoveUsedToTop : Boolean;
    FIntMaxUsed : Integer;
    FColorUsed : TColor;
    FFontTypes : TscFontTypes;
    FBlnShowPreviewInList: Boolean;
    FBlnShowPreview: Boolean;
    FBlnShowImagesFontType: Boolean;
    FBlnShowPreviewFontName: Boolean;

    procedure SetPopupHeight(const Value: Integer);
    procedure SetPopupWidth(const Value: Integer);
    procedure SetFontName(const Value: String);
    function  GetFontName : String;
    procedure SetPreviewText(const Value: String);
    procedure SetShowPreviewFontName(const Value: Boolean);
  protected
    procedure OnCloseup(var Message: TWMCommand); message CN_COMMAND;
    procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);override;
    procedure ChooseFont;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Loaded; override;

    procedure DropDown; override;
    procedure Click; override;

    // Refill items of listbox depening the fonttypes property
    procedure GetFontNames;
  published
    property OnChange;
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnDropDown;
    property OnEndDrag;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnStartDrag;

    property Anchors;
    property Color;
    property Ctl3D;
    property Cursor;
    property DragCursor;
    property DragMode;
    property DropDownCount;
    property Enabled;
    property Font;
    property Height;
    property HelpContext;
    property Hint;
    property ImeMode;
    property ImeName;
    property ItemHeight;
    property Left;
    property ParentColor;
    property ParentCtl3D;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property Visible;

    // Add used fonts to top of listbox
    property MoveUsedToTop : Boolean read FBlnMoveUsedToTop write FBlnMoveUsedToTop default True;
    property MaxUsed : Integer read FIntMaxUsed write FIntMaxUsed default 5;
    property ColorUsed : TColor read FColorUsed write FColorUsed default clNavy;

    // Preview popup window
    // When previewtext is not specified, AaBbYyZz will be shown
    property PreviewText : String read FStrPreviewText write SetPreviewText;
    property PreviewWidth : Integer read FIntPreviewWidth write SetPopupWidth default 250;
    property PreviewHeight : Integer read FIntPreviewHeight write SetPopupHeight default 45;

    // Get or set font
    property FontName : String read GetFontName write SetFontName;

    // Fonttypes which will be visible (ftTrueTypeAnsi, ftTrueTypeSymbol, ftRaster)
    property FontTypes : TscFontTypes read FFontTypes write FFontTypes;

    // Show preview popup window
    property ShowPreview : Boolean read FBlnShowPreview write FBlnShowPreview default True;
    // Show small panel with fontname in preview popup window
    property ShowPreviewFontName : Boolean read FBlnShowPreviewFontName write SetShowPreviewFontName default True;
    // Show preview of item in listbox
    property ShowPreviewInList : Boolean read FBlnShowPreviewInList write FBlnShowPreviewInList default True;
    // Show small images depending the fonttype
    property ShowImagesFontType : Boolean read FBlnShowImagesFontType write FBlnShowImagesFontType default True;
  end;

implementation

{$R tcFontCombobox.DFM}
{$R tcFontCombobox.res}


//------------------------------------------------------------------------------
constructor TtcFontCombobox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  if not (csDesigning in ComponentState) then
  begin
    FormExample := TFormExampleFont.Create(nil);
    FormExample.Height := 0;
    FormExample.Width := 0;
    FormExample.Color := ClWhite;
    FormExample.Visible := True;
    ShowWindow(FormExample.Handle,SW_HIDE);

    BitmapTrueTypeAnsi := TBitmap.Create;
    BitmapTrueTypeAnsi.LoadFromResourceName(HInstance,'FONTTRUETYPEANSI');
    BitmapTrueTypeAnsi.Transparent:=True;
    BitmapTrueTypeSymbol := TBitmap.Create;
    BitmapTrueTypeSymbol.LoadFromResourceName(HInstance,'FONTTRUETYPESYMBOL');
    BitmapTrueTypeSymbol.Transparent:=True;
    BitmapRaster := TBitmap.Create;
    BitmapRaster.LoadFromResourceName(HInstance,'FONTRASTER');
    BitmapRaster.Transparent:=True;

    FormExample.Width := 240;
    FormExample.Height := 50;
  end;

  FIntPreviewWidth := 240;
  FIntPreviewHeight := 60;
  FFontTypes := [ftTrueTypeAnsi,ftTrueTypeSymbol];
  FBlnMoveUsedToTop := True;
  FIntMaxUsed := 5;
  FColorUsed := clNavy;
  FBlnShowPreviewInList := True;
  FBlnShowPreview := True;
  FBlnShowPreviewFontName := True;
  FBlnShowImagesFontType := True;

  IntCountUsed := 0;
  BlnDown := False;

  Style := csOwnerDrawFixed;
  ItemHeight := 18;
  DropDownCount := 12;
  Width := 200;
  Font.Size := 10;
end;

//------------------------------------------------------------------------------
destructor TtcFontCombobox.Destroy;
begin
  FreeAndNil(BitmapTrueTypeAnsi);
  FreeAndNil(BitmapTrueTypeSymbol);
  FreeAndNil(BitmapRaster);
  FreeAndNil(FormExample);
  inherited Destroy;
end;

function TtcFontCombobox.GetFontName : String;
var
ps : Integer;
begin
  ps:=Pos('=',FStrFontName);
  if (ps>0) then
    Result :=Copy(FStrFontName,1,ps-1)
  else
  Result :=FStrFontName;
end;
//------------------------------------------------------------------------------
procedure TtcFontCombobox.Loaded;
begin
  inherited;
  GetFontNames;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
  StrFont : String;
  StrFontType : String;
  r : TRect;
begin
  if csDesigning in ComponentState then
    Exit;

  with Canvas do
  begin
    StrFont := Items.Names[Index];
    StrFontType := Items.Values[StrFont];
    FillRect(Rect);

    // Show small image depending the fonttype
    if FBlnShowImagesFontType then
    begin
      if (StrFontType = 'TA') then
        Draw(2,Rect.Top+1,BitmapTrueTypeAnsi)
      else
        if (StrFontType = 'TS') then
          Draw(2,Rect.Top+1,BitmapTrueTypeSymbol)
        else
          Draw(2,Rect.Top+1,BitmapRaster);
    end;

    // Color for used itmes can be different
    if (BlnDown) and (Index < IntCountUsed) then
      begin
        if (odFocused in State) then
          Font.Color := clHighlightText
        else
          Font.Color := FColorUsed
      end
    else
    begin
      if (odFocused in State) then
        Font.Color := clHighlightText
      else
        Font.Color := Self.Font.Color;
    end;
    // If property ShowPreviewInList is true the current
    // font will be the fontname of the item
    if FBlnShowPreviewInList then
    begin
      if Items.Values[StrFont] <> 'TS' then
        Font.Name := StrFont
      else
        Font.Name := Self.Font.Name;
    end;
    r:=Rect;

    if FBlnShowImagesFontType then
    begin
      r.Left:=r.Left+15;
      TextRect(r,20,r.Top+1,StrFont);
    end
    else
    begin
      r.Left:=r.Left+4;
      TextRect(r,4,r.Top+1,StrFont);
    end;

    // Show preview popupwindow for focused item
    if (FBlnShowPreview) and (odFocused in State) then
    begin
      if Assigned(FormExample) then
      begin
        FormExample.PanelPreview.Font.Name := StrFont;
        if Trim(FStrPreviewText) = '' then
          FormExample.PanelPreview.Caption := 'AaBbYyZz';

        FormExample.PanelFontName.Caption := StrFont;
      end;
    end;

    // Draw line after used fonts
    if (BlnDown) and (FBlnMoveUsedToTop) and (Index = (IntCountUsed - 1)) then
    begin
      MoveTo(0,Rect.Bottom-1);
      LineTo(Width,Rect.Bottom-1);
    end;
  end;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.DropDown;
var
  Point : TPoint;
begin
  BlnDown := True;

  inherited Dropdown;

  // Set position of preview popup window
  if FBlnShowPreview then
  begin
    Point.x := (Self.Left)+ Self.width;
    Point.y := (Self.Top)+ Self.height ;
    Point := Parent.ClientToScreen(Point);
    FormExample.Top := Point.y;
    FormExample.Left := Point.x;

    if FormExample.Left + FormExample.Width > Screen.Width then
    begin
      Point.x := (Self.Left);
      Point := Parent.ClientToScreen(Point);
      FormExample.Left := Point.x - FormExample.Width;
    end;

    if FormExample.Top + FormExample.Height > Screen.Height then
    begin
      Point.y := (Self.Top);
      Point := Parent.ClientToScreen(Point);
      FormExample.Top := Point.y - FormExample.Height;
    end;

    ShowWindow(FormExample.Handle, SW_SHOWNA);
  end;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.Click;
begin
  if BlnDown = False then
  begin
    FStrFontName := Items.Names[ItemIndex];
    inherited Click;
  end;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.OnCloseup(var Message: TWMCommand);
begin
  if Message.NotifyCode = CBN_CLOSEUP then
  begin
    Self.SetFocus;
    ShowWindow(FormExample.Handle,SW_HIDE);

    ChooseFont;

    inherited Click;
  end
  else
    inherited;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.ChooseFont;
var
  IntIndex : Integer;
  BlnAlreadyUsed : Boolean;
begin
  if ItemIndex = -1 then
    Exit;

  FStrFontName := Items[ItemIndex];
  Text := FStrFontName;

  BlnDown := False;
  if (FBlnMoveUsedToTop = True) and (ItemIndex <> 0) then
  begin

    // Test if font has already been used
    BlnAlreadyUsed := False;
    IntIndex:=0;
    while (not BlnAlreadyUsed) and (IntIndex < IntCountUsed) do
    begin
      BlnAlreadyUsed := (Items[IntIndex] = FStrFontName);
      Inc(IntIndex);
    end;

    // Insert item at top when font is not used yet
    // Otherwise move item from used list to top
    if not BlnAlreadyUsed then
    begin
      Items.Insert(0,FStrFontName);
      Inc(IntCountUsed);
    end
    else
    begin
      Items.Move(IntIndex-1,0);
    end;

    // When maximum used items is reached, delete last item
    if (FIntMaxUsed <> 0) and (IntCountUsed > FIntMaxUsed) then
    begin
      Items.Delete(FIntMaxUsed);
      Dec(IntCountUsed);
    end;

    ItemIndex := 0;
  end;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.GetFontNames;
type
  TFontRec = record
    FontTypes : TscFontTypes;
    FontItems : TStrings;
  end;
var
  DC: HDC;
  FontRec : TFontRec;

  function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric;
    FontType: Integer; Data: Pointer): Integer; stdcall;
  var
    StrType : String;
  begin
    StrType :='';
    if FontType = TRUETYPE_FONTTYPE then
      case LogFont.lfCharset of
        ANSI_CHARSET : StrType := 'TA';
        SYMBOL_CHARSET : StrType := 'TS';
      end
    else
      if FontType = RASTER_FONTTYPE then
        StrType := 'R';

    // Check which fonts have to be added to listbox
    if (LogFont.lfFaceName[0] <> '@')
      and
        (((StrType = 'TA') and (ftTrueTypeAnsi in TFontRec(Data^).FontTypes)) or
         ((StrType = 'TS') and (ftTrueTypeSymbol in TFontRec(Data^).FontTypes)) or
         ((StrType = 'R') and (ftRaster in TFontRec(Data^).FontTypes))) then
    begin
      TStrings(TFontRec(Data^).FontItems).Add(LogFont.lfFaceName+'='+StrType);
    end;

    Result := 1;
  end;
begin
  IntCountUsed := 0;
  Items.Clear;

  // Make record to provide a pointer to the items
  // of the listbox and the property fonttypes
  FontRec.FontItems := Pointer(Items);
  FontRec.FontTypes := FFontTypes;

  DC := GetDC(0);
  try
    EnumFonts(DC, nil, @EnumFontsProc, @FontRec);
  finally
    ReleaseDC(0, DC);
  end;
  Sorted := True;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.SetPopupHeight(const Value: Integer);
begin
  FIntPreviewHeight := Value;
  if Assigned(FormExample) then
    FormExample.Height := Value;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.SetPopupWidth(const Value: Integer);
begin
  FIntPreviewWidth := Value;
  if Assigned(FormExample) then
    FormExample.Width := Value;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.SetFontName(const Value: String);
var
  i : Integer;
begin
  // Run through items to see if font is available in list
  i:=0;
  while i < Items.Count do
  begin
    if Pos(Value+'=',Items[i]) > 0 then
    begin
      ItemIndex := i;
      ChooseFont;
      Exit;
    end;
    inc(i);
  end;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.SetPreviewText(const Value: String);
begin
  FStrPreviewText := Value;
  if Assigned(FormExample) then
    FormExample.PanelPreview.Caption := Value;
end;

//------------------------------------------------------------------------------
procedure TtcFontCombobox.SetShowPreviewFontName(const Value: Boolean);
begin
  FBlnShowPreviewFontName := Value;
  if Assigned(FormExample) then
    FormExample.PanelFontName.Visible := FBlnShowPreviewFontName;
end;

end.