mirror of https://gitlab.com/basile.b/dexed.git
ce_synmemo: support for external modification tracking
This commit is contained in:
parent
a1fbd92fdb
commit
2cc2ad3b9d
|
@ -121,7 +121,11 @@ begin
|
||||||
curr := getCurrentEditor;
|
curr := getCurrentEditor;
|
||||||
macRecorder.Editor := curr;
|
macRecorder.Editor := curr;
|
||||||
fSyncEdit.Editor := curr;
|
fSyncEdit.Editor := curr;
|
||||||
|
if curr <> nil then
|
||||||
|
begin
|
||||||
identifierToD2Syn(curr);
|
identifierToD2Syn(curr);
|
||||||
|
curr.checkFileDate;
|
||||||
|
end;
|
||||||
//
|
//
|
||||||
if pageControl.ActivePageIndex <> -1 then
|
if pageControl.ActivePageIndex <> -1 then
|
||||||
mainForm.docFocusedNotify(Self, pageControl.ActivePageIndex);
|
mainForm.docFocusedNotify(Self, pageControl.ActivePageIndex);
|
||||||
|
|
|
@ -6,7 +6,7 @@ interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, SynEdit, SynMemo, ce_d2syn,
|
Classes, SysUtils, SynEdit, SynMemo, ce_d2syn,
|
||||||
SynPluginSyncroEdit, SynEditKeyCmds, ce_project;
|
SynPluginSyncroEdit, SynEditKeyCmds, ce_project, ce_common;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
|
@ -14,13 +14,17 @@ type
|
||||||
private
|
private
|
||||||
fFilename: string;
|
fFilename: string;
|
||||||
fModified: boolean;
|
fModified: boolean;
|
||||||
|
fNoDateCheck: boolean;
|
||||||
|
fFileDate: double;
|
||||||
fAssocProject: TCEProject;
|
fAssocProject: TCEProject;
|
||||||
function getIfDSource: Boolean;
|
function getIfDSource: Boolean;
|
||||||
function getIfConfig: Boolean;
|
function getIfConfig: Boolean;
|
||||||
|
procedure setFilename(const aValue: string);
|
||||||
public
|
public
|
||||||
constructor Create(aOwner: TComponent); override;
|
constructor Create(aOwner: TComponent); override;
|
||||||
|
procedure checkFileDate;
|
||||||
//
|
//
|
||||||
property fileName: string read fFilename write fFilename;
|
property fileName: string read fFilename write setFilename;
|
||||||
property modified: boolean read fModified write fModified;
|
property modified: boolean read fModified write fModified;
|
||||||
property project: TCEProject read fAssocProject write fAssocProject;
|
property project: TCEProject read fAssocProject write fAssocProject;
|
||||||
//
|
//
|
||||||
|
@ -34,7 +38,7 @@ var
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
graphics, ce_main;
|
graphics, ce_main, controls;
|
||||||
|
|
||||||
constructor TCESynMemo.Create(aOwner: TComponent);
|
constructor TCESynMemo.Create(aOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
|
@ -57,6 +61,33 @@ begin
|
||||||
Highlighter := D2Syn;
|
Highlighter := D2Syn;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCESynMemo.setFilename(const aValue: string);
|
||||||
|
begin
|
||||||
|
if fFilename = aValue then exit;
|
||||||
|
fNoDateCheck := false;
|
||||||
|
fFilename := aValue;
|
||||||
|
FileAge(fFilename, fFileDate);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCESynMemo.checkFileDate;
|
||||||
|
var
|
||||||
|
newDate: double;
|
||||||
|
begin
|
||||||
|
if not FileAge(fFilename, newDate) then exit;
|
||||||
|
if fFileDate = newDate then exit;
|
||||||
|
if fFileDate <> 0.0 then
|
||||||
|
begin
|
||||||
|
if dlgOkCancel(format('"%s" has been modified by another program, load the new version ?',
|
||||||
|
[shortenPath(fFilename)])) = mrOk then
|
||||||
|
begin
|
||||||
|
Lines.LoadFromFile(fFilename);
|
||||||
|
fModified := false;
|
||||||
|
end
|
||||||
|
else fNoDateCheck := true;
|
||||||
|
end;
|
||||||
|
fFileDate := newDate;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCESynMemo.getIfDSource: Boolean;
|
function TCESynMemo.getIfDSource: Boolean;
|
||||||
begin
|
begin
|
||||||
exit(Highlighter = D2Syn);
|
exit(Highlighter = D2Syn);
|
||||||
|
|
Loading…
Reference in New Issue