source: trunk/IDE/Forms/FormSourceCode.pas

Last change on this file was 75, checked in by chronos, 6 months ago
  • Modified: Removed U prefix from unit names.
  • Modified: Updated Common package.
File size: 1.9 KB
Line 
1unit FormSourceCode;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
7 SynEdit, SynHighlighterPas, Project;
8
9type
10
11 { TFormSourceCode }
12
13 TFormSourceCode = class(TForm)
14 SynEditSource: TSynEdit;
15 SynPasSyn1: TSynPasSyn;
16 procedure SynEditSourceChange(Sender: TObject);
17 private
18 FProjectFile: TProjectFile;
19 procedure SetProjectFile(const AValue: TProjectFile);
20 public
21 property ProjectFile: TProjectFile read FProjectFile write SetProjectFile;
22 procedure Save;
23 procedure UpdateInterface;
24 procedure SelectFile(FileName: string; Position: TPoint);
25 end;
26
27
28implementation
29
30uses
31 FormMain, Core;
32
33{$R *.lfm}
34
35{ TFormSourceCode }
36
37procedure TFormSourceCode.SynEditSourceChange(Sender: TObject);
38begin
39 Save;
40 if Assigned(Core.Core.Project) and Assigned(ProjectFile) then
41 ProjectFile.Modified := True;
42end;
43
44procedure TFormSourceCode.SetProjectFile(const AValue: TProjectFile);
45begin
46 if FProjectFile = AValue then Exit;
47 FProjectFile := AValue;
48 if Assigned(AValue) then
49 SynEditSource.Lines.Assign(FProjectFile.Source)
50 else SynEditSource.ClearAll;
51end;
52
53procedure TFormSourceCode.Save;
54begin
55 if Assigned(ProjectFile) then
56 ProjectFile.Source.Assign(SynEditSource.Lines);
57end;
58
59procedure TFormSourceCode.UpdateInterface;
60begin
61 SynEditSource.Enabled := Assigned(Core.Core.Project);
62 if not Assigned(Core.Core.Project) then SynEditSource.ClearAll;
63end;
64
65procedure TFormSourceCode.SelectFile(FileName: string; Position: TPoint);
66var
67 ProjectFile: TProjectFile;
68begin
69 with Core.Core do begin
70 ProjectFile := Project.Files.SearchFile(FileName);
71 if Assigned(ProjectFile) then
72 SynEditSource.Lines.Assign(ProjectFile.Source)
73 else if FileExists(FileName) then
74 SynEditSource.Lines.LoadFromFile(FileName);
75 SynEditSource.CaretXY := Position;
76 TForm(SynEditSource.Owner).Show;
77 SynEditSource.SetFocus;
78 end;
79end;
80
81end.
82
Note: See TracBrowser for help on using the repository browser.