-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit1.pas
745 lines (667 loc) · 20.2 KB
/
unit1.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
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, LazHelpHTML,
ComCtrls, SynEdit, SynHighlighterPas, SynHighlighterJScript,
SynHighlighterXML, SynHighlighterHTML, SynHighlighterMulti,
SynEditHighlighter, SynHighlighterCpp, SynCompletion, SynHighlighterLFM,
PrintersDlgs, SynEditTypes, SynHighlighterMakefile;
type
{ THighlighterData }
THighlighterData = class(TComponent)
private
FHighlighter: TSynCustomHighLighter;
FMenuItem: TMenuItem;
procedure SetHighlighter(AValue: TSynCustomHighLighter);
procedure SetMenuItem(AValue: TMenuItem);
protected
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
public
published
property MenuItem: TMenuItem read FMenuItem write SetMenuItem;
property Highlighter: TSynCustomHighLighter read FHighlighter write SetHighlighter;
end;
{ THighlighterSwitch }
THighlighterSwitch = class(TComponent)
private
FIL: TList;
FItemIndex: Integer;
function GetItemList: TList;
procedure ReadItems(Reader: TReader);
procedure WriteItems(Writer: TWriter);
private
FSaveDialog: TSaveDialog;
FSynEdit: TSynEdit;
function GetItemCount: Integer;
function GetItems(AnIndex: Integer): THighlighterData; overload;
procedure SetItemIndex(AValue: Integer);
procedure SetSaveDialog(AValue: TSaveDialog);
procedure SetSynEdit(AValue: TSynEdit);
property ItemList: TList read GetItemList;
protected
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure DefineProperties(Filer: TFiler); override;
public
destructor Destroy; override;
procedure AddItem(AnItem: TMenuItem; AHighlighter: TSynCustomHighLighter);
function GetItems(AnItem: TMenuItem): THighlighterData; overload;
procedure Switch(AnItem: TMenuItem); overload;
procedure Switch(AnIndex: Integer); overload;
property ItemCount: Integer read GetItemCount;
property Items[AnIndex: Integer]: THighlighterData read GetItems;
published
property ItemIndex: Integer read FItemIndex write SetItemIndex;
property SaveDialog: TSaveDialog read FSaveDialog write SetSaveDialog;
property SynEdit: TSynEdit read FSynEdit write SetSynEdit;
end;
type
{ TForm1 }
TForm1 = class(TForm)
FontDialog: TFontDialog;
HTMLBrowserHelpViewer: THTMLBrowserHelpViewer;
HTMLHelpDatabase: THTMLHelpDatabase;
MainMenu: TMainMenu;
HelpMenu: TMenuItem;
MenuItem1: TMenuItem;
EnvItem: TMenuItem;
ToolsMenu: TMenuItem;
ViewMakefile: TMenuItem;
ViewFreePascal: TMenuItem;
PrintDialog: TPrintDialog;
StatusBar: TStatusBar;
SynCompletion: TSynCompletion;
SynFreePascalSyn: TSynFreePascalSyn;
SynLFmSyn: TSynLFMSyn;
ViewLFm: TMenuItem;
N1: TMenuItem;
MenuItem10: TMenuItem;
FileExit: TMenuItem;
MenuItem11: TMenuItem;
MenuItem12: TMenuItem;
MenuItem13: TMenuItem;
EditCut: TMenuItem;
EditCopy: TMenuItem;
EditPaste: TMenuItem;
MenuItem14: TMenuItem;
MenuItem15: TMenuItem;
HelpLicense: TMenuItem;
MenuItem17: TMenuItem;
MenuItem18: TMenuItem;
MenuItem19: TMenuItem;
FileMenu: TMenuItem;
MenuItem20: TMenuItem;
MenuItem21: TMenuItem;
MenuItem22: TMenuItem;
MenuItem23: TMenuItem;
HelpAbout: TMenuItem;
PrinterSetupDialog: TPrinterSetupDialog;
ViewMenu: TMenuItem;
FileClose: TMenuItem;
FormsMenu: TMenuItem;
FormsNew: TMenuItem;
FormsTile: TMenuItem;
FormsCascade: TMenuItem;
FormsAdjust: TMenuItem;
MenuItem31: TMenuItem;
FormsHide: TMenuItem;
FormsShow: TMenuItem;
SynCppSyn: TSynCppSyn;
SynMultiSyn: TSynMultiSyn;
ViewMulti: TMenuItem;
ViewCpp: TMenuItem;
ViewText: TMenuItem;
ViewHTML: TMenuItem;
SynHTMLSyn: TSynHTMLSyn;
ViewXML: TMenuItem;
SynXMLSyn: TSynXMLSyn;
ViewPas: TMenuItem;
ViewJS: TMenuItem;
SynJScriptSyn: TSynJScriptSyn;
HelpContents: TMenuItem;
MenuItem4: TMenuItem;
EditMenu: TMenuItem;
MenuItem6: TMenuItem;
NewItem: TMenuItem;
OpenItem: TMenuItem;
SaveItem: TMenuItem;
SaveAsItem: TMenuItem;
MenuItem7: TMenuItem;
FilePrint: TMenuItem;
FilePrinterSetup: TMenuItem;
OpenDialog: TOpenDialog;
SaveDialog: TSaveDialog;
SynEdit: TSynEdit;
SynPasSyn: TSynPasSyn;
procedure EditCopyClick(Sender: TObject);
procedure EditCutClick(Sender: TObject);
procedure EditPasteClick(Sender: TObject);
procedure FileExitClick(Sender: TObject);
procedure FileCloseClick(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure FormCloseQuery(Sender: TObject; var CanClose: boolean);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormDropFiles(Sender: TObject; const FileNames: array of String);
procedure FormsAdjustClick(Sender: TObject);
procedure FormsCascadeClick(Sender: TObject);
procedure FormsNewClick(Sender: TObject);
procedure FormsShowClick(Sender: TObject);
procedure FormsTileClick(Sender: TObject);
procedure HelpAboutClick(Sender: TObject);
procedure FilePrintClick(Sender: TObject);
procedure FilePrinterSetupClick(Sender: TObject);
procedure HelpLicenseClick(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure FormsHideClick(Sender: TObject);
procedure HelpContentsClick(Sender: TObject);
procedure NewItemClick(Sender: TObject);
procedure OpenItemClick(Sender: TObject);
procedure SaveAsItemClick(Sender: TObject);
procedure SaveItemClick(Sender: TObject);
procedure SynEditStatusChange(Sender: TObject; Changes: TSynStatusChanges);
procedure ViewSynClick(Sender: TObject);
procedure XMLPropStorageRestoreProperties(Sender: TObject);
procedure XMLPropStorageRestoringProperties(Sender: TObject);
private
FFileName: string;
procedure SetFileName(Value: string);
public
SynHighlighterMakefile: TSynMakefileSyn;
function GetConfigFileName: string;
procedure OpenFile(AFileName: string);
function Save: Boolean;
function SaveAs: Boolean;
function GuessHighlighter: TSynCustomHighLighter;
procedure PrintTestPage;
published
HLSwitch: THighlighterSwitch;
property FileName: string read FFileName write SetFileName;
end;
var
Form1: TForm1;
implementation
uses About, FormEx, HeadFm, HelpIntfs, LazHelpIntf, LCLIntf, Patch, Printers,
Streaming2, Types;
{$R *.lfm}
{ THighlighterSwitch }
function THighlighterSwitch.GetItemList: TList;
begin
if not Assigned(FIL) then FIL := TList.Create;
Result := FIL
end;
procedure THighlighterSwitch.ReadItems(Reader: TReader);
begin
Reader.ReadListBegin;
while not Reader.EndOfList do
ItemList.Add(Reader.ReadComponent(THighlighterData.Create(Self)));
Reader.ReadListEnd;
end;
procedure THighlighterSwitch.WriteItems(Writer: TWriter);
var
i: Integer;
begin
Writer.WriteListBegin;
for i := 0 to ItemCount - 1 do Writer.WriteComponent(Items[i]);
Writer.WriteListEnd;
end;
function THighlighterSwitch.GetItems(AnIndex: Integer): THighlighterData;
begin
Pointer(Result) := ItemList[AnIndex]
end;
procedure THighlighterSwitch.SetItemIndex(AValue: Integer);
begin
if FItemIndex=AValue then Exit;
{Switch(AValue);}
FItemIndex:=AValue;
end;
procedure THighlighterSwitch.SetSaveDialog(AValue: TSaveDialog);
begin
if FSaveDialog = AValue then Exit;
FSaveDialog := AValue;
if Assigned(AValue) then AValue.FreeNotification(Self)
end;
function THighlighterSwitch.GetItemCount: Integer;
begin
Result := ItemList.Count
end;
procedure THighlighterSwitch.SetSynEdit(AValue: TSynEdit);
begin
if FSynEdit = AValue then Exit;
FSynEdit := AValue;
if Assigned(AValue) then AValue.FreeNotification(Self);
end;
procedure THighlighterSwitch.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if Assigned(AComponent) then
case Operation of
opRemove: if AComponent = FSynEdit then FSynEdit := nil
else if AComponent = FSaveDialog then FSaveDialog := nil;
end;
end;
procedure THighlighterSwitch.DefineProperties(Filer: TFiler);
begin
inherited DefineProperties(Filer);
Filer.DefineProperty('Items', @ReadItems, @WriteItems, ItemCount > 0)
end;
destructor THighlighterSwitch.Destroy;
begin
FIL.Free;
inherited Destroy;
end;
function THighlighterSwitch.GetItems(AnItem: TMenuItem): THighlighterData;
var
i: Integer;
begin
for i := 0 to ItemCount - 1 do
if Items[i].MenuItem = AnItem then begin
Result := Items[i];
Exit
end;
Result := nil
end;
procedure THighlighterSwitch.AddItem(AnItem: TMenuItem;
AHighlighter: TSynCustomHighLighter);
var
HD: THighlighterData;
begin
HD := THighlighterData.Create(Self);
HD.MenuItem := AnItem;
HD.Highlighter := AHighLighter;
ItemList.Add(HD)
end;
procedure THighlighterSwitch.Switch(AnItem: TMenuItem);
var
i: Integer;
begin
for i := 0 to ItemCount - 1 do
if Items[i].MenuItem = AnItem then begin
Switch(i);
Exit
end;
end;
procedure THighlighterSwitch.Switch(AnIndex: Integer);
var
i: Integer;
begin
if Assigned(SynEdit) then SynEdit.HighLighter := Items[AnIndex].Highlighter;
if Assigned(Items[AnIndex].Highlighter) then
if Assigned(SaveDialog) then SaveDialog.Filter := Items[AnIndex].Highlighter.DefaultFilter;
for i := 0 to ItemCount - 1 do
if i = AnIndex then begin
Items[i].MenuItem.Checked := True;
ItemIndex := i
end
else Items[i].MenuItem.Checked := False;
end;
{ THighliterData }
procedure THighlighterData.SetHighlighter(AValue: TSynCustomHighLighter);
begin
if FHighlighter = AValue then Exit;
FHighlighter := AValue;
if Assigned(AValue) then FreeNotification(AValue)
end;
procedure THighlighterData.SetMenuItem(AValue: TMenuItem);
begin
if FMenuItem = AValue then Exit;
FMenuItem := AValue;
if Assigned(AValue) then FreeNotification(AValue)
end;
procedure THighlighterData.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if AComponent <> nil then
case Operation of
opRemove:
if AComponent = FHighlighter then FHighLighter := nil
else if AComponent = FMenuItem then FMenuItem := nil;
end;
end;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
var
i, SlaveIndex: Integer;
F: TForm1;
begin
SynHighlighterMakefile := TSynMakefileSyn.Create(Self);
FormAdjust(Self);
HLSwitch := THighlighterSwitch.Create(Self);
HLSwitch.SynEdit := SynEdit;
HLSwitch.SaveDialog := SaveDialog;
with HLSwitch do begin
AddItem(ViewJS, SynJScriptSyn);
AddItem(ViewPas, SynPasSyn);
AddItem(ViewXML, SynXMLSyn);
AddItem(ViewHTML, SynHTMLSyn);
AddItem(ViewMulti, SynMultiSyn);
AddItem(ViewCpp, SynCppSyn);
AddItem(ViewText, nil);
AddItem(ViewLFm, SynLFmSyn);
AddItem(ViewFreePascal, SynFreePascalSyn);
AddItem(ViewMakefile, SynHighlighterMakefile);
Switch(ViewFreePascal)
end;
with HTMLHelpDataBase do begin
{$ifdef Darwin}
BaseURL := 'file://' + ExtractFilePath(Application.ExeName) + 'help'
{$else}
{$ifndef UNIX}
BaseURL := ExtractFilePath(Application.ExeName) + 'help'
{$endif}
{$endif}
end;
SlaveIndex := HeadForm.AddSlave(Sender as TForm1);
if SlaveIndex = 0 then begin
if Application.ParamCount > 0 then
if FileExists(Application.Params[1]) then begin
SynEdit.Lines.LoadFromFile(Application.Params[1]);
FileName := Application.Params[1]
end;
for i := 2 to Application.ParamCount do
if FileExists(Application.Params[i]) then begin
F := TForm1.Create(Application);
F.SynEdit.Lines.LoadFromFile(Application.Params[i]);
F.FileName := Application.Params[i];
HeadForm.AddSlave(F)
end;
end;
HeadForm.SendToBack;
HeadForm.Hide
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
HeadForm.RemoveSlave(Sender as TForm1);
{ShowMessageFmt('Formulare: %d', [MasterForm.SlaveCount])}
end;
procedure TForm1.FormDropFiles(Sender: TObject; const FileNames: array of String
);
var
i: Integer;
begin
if Save then SynEdit.Lines.LoadFromFile(Filenames[Low(Filenames)]);
for i := Low(FileNames) + 1 to High(FileNames) do
TForm1.Create(Application).SynEdit.Lines.LoadFromFile(FileNames[i]);
end;
procedure TForm1.FormsAdjustClick(Sender: TObject);
begin
HeadForm.AdjustSlaves
end;
procedure TForm1.FormsCascadeClick(Sender: TObject);
begin
HeadForm.CascadeSlaves
end;
procedure TForm1.FormsNewClick(Sender: TObject);
begin
TForm1.Create(HeadForm).Name := '';
end;
procedure TForm1.FormsShowClick(Sender: TObject);
begin
HeadForm.SlaveSelDlg.Execute
end;
procedure TForm1.FormsTileClick(Sender: TObject);
begin
HeadForm.TileSlaves
end;
procedure TForm1.HelpAboutClick(Sender: TObject);
begin
AboutBox.ShowModal
end;
procedure TForm1.FilePrintClick(Sender: TObject);
begin
if PrintDialog.Execute then begin
PrintTestPage
end;
end;
procedure TForm1.FilePrinterSetupClick(Sender: TObject);
begin
PrinterSetupDialog.Execute
end;
procedure TForm1.HelpLicenseClick(Sender: TObject);
var
NewWindow: TForm1;
begin
{OpenDocument(ExtractFilePath(Application.ExeName) + 'LICENSE')}
NewWindow := TForm1.Create(Application);
with NewWindow do begin
HLSwitch.Switch(ViewText);
OpenFile(ExtractFilePath(Application.ExeName) + 'LICENSE');
SynEdit.ReadOnly := True;
Show
end;
end;
procedure TForm1.MenuItem1Click(Sender: TObject);
begin
if FontDialog.Execute then SynEdit.Font := FontDialog.Font;
end;
procedure TForm1.FormsHideClick(Sender: TObject);
begin
Hide
end;
procedure TForm1.HelpContentsClick(Sender: TObject);
var
ErrMsg: string;
R: TShowHelpResult;
begin
R := HTMLHelpDatabase.ShowHelpFile(nil, nil, 'Inhaltsverzeichnis', 'index.html', ErrMsg);
case R of
shrSuccess:;
else ShowMessageFmt('%d: %s', [R, ErrMsg]);
end;
end;
procedure TForm1.FileExitClick(Sender: TObject);
begin
HeadForm.Close
end;
procedure TForm1.FileCloseClick(Sender: TObject);
begin
Close
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
CloseAction := caFree
end;
procedure TForm1.EditCopyClick(Sender: TObject);
begin
SynEdit.CopyToClipboard
end;
procedure TForm1.EditCutClick(Sender: TObject);
begin
SynEdit.CutToClipboard
end;
procedure TForm1.EditPasteClick(Sender: TObject);
begin
SynEdit.PasteFromClipboard
end;
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: boolean);
var
x: string;
begin
if SynEdit.Modified then begin
if FileName = '' then x := 'Die Datei'
else x := FileName;
case MessageDlg(Format('%s wurde noch nicht gespeichert. Soll sie jetzt gespeichert werden?', [x]),
mtConfirmation, mbYesNoCancel, 0) of
mrYes: CanClose := Save;
mrNo: CanClose := True ;
mrCancel: CanClose := False;
end
end
else CanClose := True
end;
procedure TForm1.NewItemClick(Sender: TObject);
var
x: string;
begin
if SynEdit.Modified then begin
if FileName = '' then x := 'Die Datei'
else x := FileName;
case MessageDlg(Format('%s wurde noch nicht gespeihert. Soll die Datei jetzt gespeichert werden?', [x]),
mtConfirmation, mbYesNoCancel, 0) of
mrYes:
if Save then begin
SynEdit.Clear;
FileName := '';
end;
mrNo: begin
SynEdit.Clear;
FileName := ''
end;
end
end
else begin
SynEdit.Clear;
FileName := ''
end;
end;
procedure TForm1.OpenItemClick(Sender: TObject);
var
x: string;
begin
if SynEdit.Modified then begin
if FileName = '' then x := 'Die Datei'
else x := FileName;
case MessageDlg(Format('%s wurde noch nicht gespeichert. Soll die Datei jetzt gespeichert werden?', [x]),
mtConfirmation, mbYesNoCancel, 0) of
mrYes:
if Save then
if OpenDialog.Execute then begin
SynEdit.Lines.LoadFromFile(OpenDialog.FileName);
FileName := OpenDialog.FileName
end;
mrNo:
if OpenDialog.Execute then begin
SynEdit.Lines.LoadFromFile(OpenDialog.FileName);
FileName := OpenDialog.FileName
end;
end;
end
else begin
if OpenDialog.Execute then begin
SynEdit.Lines.LoadFromFile(OpenDialog.FileName);
FileName := OpenDialog.FileName
end;
end;
end;
procedure TForm1.SaveAsItemClick(Sender: TObject);
begin
SaveAs
end;
procedure TForm1.SaveItemClick(Sender: TObject);
begin
Save
end;
procedure TForm1.SynEditStatusChange(Sender: TObject; Changes: TSynStatusChanges
);
const
Counter: Integer = 0;
var
P: TPoint;
begin
if scModified in Changes then
if (Sender as TSynEdit).Modified then StatusBar.Panels[0].Text := 'Geändert'
else StatusBar.Panels[0].Text := '';
P := Point(Counter, Counter div 2);
StatusBar.Panels[1].Text := Format('%d:%d', [P.X, P.Y]);
Inc(Counter)
end;
procedure TForm1.ViewSynClick(Sender: TObject);
begin
HLSwitch.Switch(Sender as TMenuItem)
end;
procedure TForm1.XMLPropStorageRestoreProperties(Sender: TObject);
begin
{HLSwitch.Switch(HLSwitch.ItemIndex);}
end;
procedure TForm1.XMLPropStorageRestoringProperties(Sender: TObject);
begin
HLSwitch.Switch(HLSwitch.ItemIndex)
end;
procedure TForm1.SetFileName(Value: string);
begin
FFileName := Value;
if Value <> '' then Caption := Value
else Caption := 'Free Pascal Editor'
end;
function TForm1.GetConfigFileName: string;
begin
Result := BuildFileName(Application.EnvironmentVariable['HOME'], '.config/fpe');
ForceDirectories(Result);
Result := ChangeFileExt(BuildFileName(Result, Name), '.cfg');
end;
procedure TForm1.OpenFile(AFileName: string);
begin
SynEdit.Lines.LoadFromFile(AFileName);
FileName := AFileName
end;
function TForm1.Save: Boolean;
begin
Result := not SynEdit.Modified;
if SynEdit.Modified then
if FileName = '' then Result := SaveAs
else begin
SynEdit.Lines.SaveToFile(FileName);
SynEdit.Modified := False;
Result := True
end
end;
function TForm1.SaveAs: Boolean;
begin
Result := False;
if SaveDialog.Execute then begin
SynEdit.Lines.SaveToFile(SaveDialog.FileName);
FileName := SaveDialog.FileName;
SynEdit.Modified := False;
Result := True
end
end;
function TForm1.GuessHighlighter: TSynCustomHighLighter;
begin
Result := nil;
end;
procedure TForm1.PrintTestPage;
const
TestText = 'Hallo, Drucker!';
var
TW, TH, X, Y: Integer;
begin
Printer.BeginDoc;
Printer.BeginPage;
TH := Printer.Canvas.TextHeight(TestText);
TW := Printer.Canvas.TextWidth(TestText);
X := (Printer.PageWidth - TW) div 2;
Y := (Printer.PageHeight - TH) div 2;
Printer.Canvas.TextOut(X, Y, TestText);
Printer.EndPage;
Printer.EndDoc
end;
initialization
RegisterForStreaming(TForm1);
RegisterForStreaming(THighlighterData);
RegisterForStreaming(TFontDialog);
RegisterForStreaming(THTMLBrowserHelpViewer);
RegisterForStreaming(THTMLHelpDatabase);
RegisterForStreaming(TMainMenu);
RegisterForStreaming(TMenuItem);
RegisterForStreaming(TPrintDialog);
RegisterForStreaming(TStatusBar);
RegisterForStreaming(TSynCompletion);
RegisterForStreaming(TSynFreePascalSyn);
RegisterForStreaming(TSynLFMSyn);
RegisterForStreaming(TPrinterSetupDialog);
RegisterForStreaming(TSynCppSyn);
RegisterForStreaming(TSynMultiSyn);
RegisterForStreaming(TSynHTMLSyn);
RegisterForStreaming(TSynXMLSyn);
RegisterForStreaming(TSynJScriptSyn);
RegisterForStreaming(TOpenDialog);
RegisterForStreaming(TSaveDialog);
RegisterForStreaming(TSynEdit);
RegisterForStreaming(TSynPasSyn);
RegisterForStreaming(TSynMakefileSyn);
RegisterForStreaming(THighlighterSwitch);
end.