summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-09-18 17:08:33 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-09-18 17:08:33 +0200
commit351f990e605d7a338745f66d8ca1efb4b3e1f012 (patch)
tree1180085d383c575211e1424e8982aa3f336a5a09 /examples
parent02dccf6a12edbe0da005f635c01ef48e6967d55e (diff)
downloadfpGUI-351f990e605d7a338745f66d8ca1efb4b3e1f012.tar.xz
Integrated TFileMonitor with the IDE. All open files are now monitored.
Diffstat (limited to 'examples')
-rw-r--r--examples/apps/ide/src/frm_main.pas21
1 files changed, 20 insertions, 1 deletions
diff --git a/examples/apps/ide/src/frm_main.pas b/examples/apps/ide/src/frm_main.pas
index 177ab181..76d90565 100644
--- a/examples/apps/ide/src/frm_main.pas
+++ b/examples/apps/ide/src/frm_main.pas
@@ -7,7 +7,8 @@ interface
uses
SysUtils, Classes, fpg_base, fpg_main, fpg_form, fpg_menu, fpg_panel,
fpg_button, fpg_splitter, fpg_tab, fpg_memo, fpg_label, fpg_grid,
- fpg_tree, fpg_textedit, fpg_mru, synregexpr;
+ fpg_tree, fpg_textedit, fpg_mru, synregexpr,
+ filemonitor;
type
@@ -58,6 +59,8 @@ type
FRecentFiles: TfpgMRU;
FRegex: TRegExpr;
FKeywordFont: TfpgFont;
+ FFileMonitor: TFileMonitor;
+ procedure MonitoredFileChanged(Sender: TObject; AData: TFileMonitorEventData);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
procedure btnQuitClicked(Sender: TObject);
@@ -472,7 +475,10 @@ var
begin
u := TUnit(ATabSheet.TagPointer);
if Assigned(u) then
+ begin
+ FFileMonitor.RemoveFile(u.FileName);
u.Opened := False;
+ end;
end;
procedure TMainForm.BuildTerminated(Sender: TObject);
@@ -613,6 +619,7 @@ begin
TfpgTextEdit(pcEditor.Pages[i].Components[0]).Lines.EndUpdate;
pcEditor.ActivePageIndex := i;
ts := pcEditor.ActivePage;
+ AddMessage('File reloaded: ' + s);
end
else
begin
@@ -637,6 +644,7 @@ begin
end;
ts.Realign;
pcEditor.ActivePage := ts;
+ FFileMonitor.AddFile(AFilename);
end;
ts.Hint := s;
Result := ts;
@@ -802,6 +810,11 @@ begin
// writeln('------');
end;
+procedure TMainForm.MonitoredFileChanged(Sender: TObject; AData: TFileMonitorEventData);
+begin
+ OpenEditorPage(AData.FileName);
+end;
+
procedure TMainForm.FormShow(Sender: TObject);
var
lErrPos: integer;
@@ -822,6 +835,8 @@ begin
TextEditor.Clear;
TextEditor.SetFocus;
+
+ FFileMonitor.Resume;
{$IFDEF DEBUGSVR}SendMethodExit('TMainForm.FormShow');{$ENDIF}
end;
@@ -842,10 +857,14 @@ begin
{$IFDEF DEBUGSVR}
SendDebug('TMainForm.Create');
{$ENDIF}
+ FFileMonitor := TFileMonitor.CreateCustom;
+ FFileMonitor.OnFileChanged := @MonitoredFileChanged;
end;
destructor TMainForm.Destroy;
begin
+ FFileMonitor.Terminate;
+ FFileMonitor.Free;
FRegex.Free;
FKeywordFont.Free;
inherited Destroy;