| 1 | unit UFormSourceCode;
|
|---|
| 2 |
|
|---|
| 3 | {$mode delphi}{$H+}
|
|---|
| 4 |
|
|---|
| 5 | interface
|
|---|
| 6 |
|
|---|
| 7 | uses
|
|---|
| 8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
|
|---|
| 9 | SynEdit, SynHighlighterPas, USource, ULDModuleBasic;
|
|---|
| 10 |
|
|---|
| 11 | type
|
|---|
| 12 |
|
|---|
| 13 | { TFormSourceCode }
|
|---|
| 14 |
|
|---|
| 15 | TFormSourceCode = class(TForm)
|
|---|
| 16 | SynEditSource: TSynEdit;
|
|---|
| 17 | SynPasSyn1: TSynPasSyn;
|
|---|
| 18 | procedure SynEditSourceChange(Sender: TObject);
|
|---|
| 19 | private
|
|---|
| 20 | FSource: TSource;
|
|---|
| 21 | FOnChange: TNotifyEvent;
|
|---|
| 22 | procedure SetSource(AValue: TSource);
|
|---|
| 23 | public
|
|---|
| 24 | property Source: TSource read FSource write SetSource;
|
|---|
| 25 | procedure Save;
|
|---|
| 26 | procedure UpdateInterface;
|
|---|
| 27 | property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
|---|
| 28 | end;
|
|---|
| 29 |
|
|---|
| 30 | var
|
|---|
| 31 | FormSourceCode: TFormSourceCode;
|
|---|
| 32 |
|
|---|
| 33 | implementation
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 | {$R *.lfm}
|
|---|
| 37 |
|
|---|
| 38 | { TFormSourceCode }
|
|---|
| 39 |
|
|---|
| 40 | procedure TFormSourceCode.SynEditSourceChange(Sender: TObject);
|
|---|
| 41 | begin
|
|---|
| 42 | Save;
|
|---|
| 43 | if Assigned(FOnChange) then
|
|---|
| 44 | FOnChange(Self);
|
|---|
| 45 | end;
|
|---|
| 46 |
|
|---|
| 47 | procedure TFormSourceCode.SetSource(AValue: TSource);
|
|---|
| 48 | begin
|
|---|
| 49 | if FSource = AValue then Exit;
|
|---|
| 50 | FSource := AValue;
|
|---|
| 51 | if Assigned(Source) and (Source is TSourceText) then
|
|---|
| 52 | SynEditSource.Lines.Text := TSourceText(Source).Content.Text
|
|---|
| 53 | else SynEditSource.ClearAll;
|
|---|
| 54 | end;
|
|---|
| 55 |
|
|---|
| 56 | procedure TFormSourceCode.Save;
|
|---|
| 57 | begin
|
|---|
| 58 | { if Assigned(ProjectFile) then
|
|---|
| 59 | ProjectFile.Source.Assign(SynEditSource.Lines);}
|
|---|
| 60 | end;
|
|---|
| 61 |
|
|---|
| 62 | procedure TFormSourceCode.UpdateInterface;
|
|---|
| 63 | begin
|
|---|
| 64 | // SynEditSource.Enabled := Assigned(DataModule1.Project);
|
|---|
| 65 | // if not Assigned(DataModule1.Project) then SynEditSource.ClearAll;
|
|---|
| 66 | end;
|
|---|
| 67 |
|
|---|
| 68 | end.
|
|---|
| 69 |
|
|---|