mirror of https://gitlab.com/basile.b/dexed.git
added HL for editor project file when proj is DUB json
fix, project file not in sync with current proj when auto reloaded in an editor
This commit is contained in:
parent
1bf9097758
commit
e3656f0d54
|
@ -15,7 +15,7 @@ type
|
|||
|
||||
{ TCEEditorWidget }
|
||||
|
||||
TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler)
|
||||
TCEEditorWidget = class(TCEWidget, ICEMultiDocObserver, ICEMultiDocHandler, ICEProjectObserver)
|
||||
mnuedCallTip: TMenuItem;
|
||||
mnuedDdoc: TMenuItem;
|
||||
mnuedCopy: TMenuItem;
|
||||
|
@ -47,6 +47,7 @@ type
|
|||
pageControl: TCEPageControl;
|
||||
fKeyChanged: boolean;
|
||||
fDoc: TCESynMemo;
|
||||
fProj: ICECommonProject;
|
||||
fTokList: TLexTokenList;
|
||||
fErrList: TLexErrorList;
|
||||
fModStart: boolean;
|
||||
|
@ -69,6 +70,12 @@ type
|
|||
procedure docFocused(aDoc: TCESynMemo);
|
||||
procedure docChanged(aDoc: TCESynMemo);
|
||||
//
|
||||
procedure projNew(aProject: ICECommonProject);
|
||||
procedure projChanged(aProject: ICECommonProject);
|
||||
procedure projClosing(aProject: ICECommonProject);
|
||||
procedure projFocused(aProject: ICECommonProject);
|
||||
procedure projCompiling(aProject: ICECommonProject);
|
||||
//
|
||||
function SingleServiceName: string;
|
||||
function documentCount: Integer;
|
||||
function getDocument(index: Integer): TCESynMemo;
|
||||
|
@ -196,6 +203,31 @@ begin
|
|||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
{$REGION ICECommonProject ------------------------------------------------------}
|
||||
procedure TCEEditorWidget.projNew(aProject: ICECommonProject);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TCEEditorWidget.projChanged(aProject: ICECommonProject);
|
||||
begin
|
||||
end;
|
||||
|
||||
procedure TCEEditorWidget.projClosing(aProject: ICECommonProject);
|
||||
begin
|
||||
if fProj = aProject then
|
||||
fProj := nil;
|
||||
end;
|
||||
|
||||
procedure TCEEditorWidget.projFocused(aProject: ICECommonProject);
|
||||
begin
|
||||
fProj := aProject;
|
||||
end;
|
||||
|
||||
procedure TCEEditorWidget.projCompiling(aProject: ICECommonProject);
|
||||
begin
|
||||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
{$REGION ICEMultiDocHandler ----------------------------------------------------}
|
||||
function TCEEditorWidget.SingleServiceName: string;
|
||||
begin
|
||||
|
@ -236,6 +268,13 @@ begin
|
|||
end;
|
||||
doc := TCESynMemo.Create(nil);
|
||||
fDoc.loadFromFile(aFilename);
|
||||
if assigned(fProj) and (fProj.filename = fDoc.fileName) then
|
||||
begin
|
||||
if fProj.getFormat = pfNative then
|
||||
fDoc.Highlighter := LfmSyn
|
||||
else
|
||||
fDoc.Highlighter := JsSyn;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCEEditorWidget.closeDocument(index: Integer): boolean;
|
||||
|
|
|
@ -549,16 +549,30 @@ end;
|
|||
procedure TCELastDocsAndProjs.AssignTo(aDestination: TPersistent);
|
||||
var
|
||||
itf: ICECommonProject = nil;
|
||||
dst: TCEMainForm;
|
||||
hdl: ICEMultiDocHandler;
|
||||
mem: TCESynMemo = nil;
|
||||
begin
|
||||
if aDestination is TCEMainForm then
|
||||
begin
|
||||
if TCEMainForm(aDestination).fProjFromCommandLine then
|
||||
dst := TCEMainForm(aDestination);
|
||||
if dst.fProjFromCommandLine then
|
||||
exit;
|
||||
itf := TCEMainForm(aDestination).fProjectInterface;
|
||||
itf := dst.fProjectInterface;
|
||||
if (itf <> nil) and (itf.filename = fProject) then
|
||||
exit;
|
||||
if fProject.isNotEmpty and FileExists(fProject) then
|
||||
TCEMainForm(aDestination).openProj(fProject);
|
||||
if fProject.isNotEmpty and fProject.fileExists then
|
||||
begin
|
||||
dst.openProj(fProject);
|
||||
hdl := getMultiDocHandler;
|
||||
if assigned(hdl) then
|
||||
mem := hdl.findDocument(dst.fProjectInterface.filename);
|
||||
if mem.isNotNil then
|
||||
if dst.fProjectInterface.getFormat = pfNative then
|
||||
mem.Highlighter := LfmSyn
|
||||
else
|
||||
mem.Highlighter := JsSyn;
|
||||
end;
|
||||
end else
|
||||
inherited;
|
||||
end;
|
||||
|
@ -583,7 +597,7 @@ begin
|
|||
begin
|
||||
document := docHandler.document[i];
|
||||
str := document.fileName;
|
||||
if (str <> document.tempFilename) and FileExists(str) then
|
||||
if (str <> document.tempFilename) and str.fileExists then
|
||||
begin
|
||||
fDocuments.Add(str);
|
||||
if document.Focused then
|
||||
|
@ -606,7 +620,7 @@ begin
|
|||
for i := 0 to fDocuments.Count-1 do
|
||||
begin
|
||||
str := fDocuments.Strings[i];
|
||||
if FileExists(str) then
|
||||
if str.fileExists then
|
||||
begin
|
||||
docHandler.openDocument(str);
|
||||
if i = fDocIndex then
|
||||
|
@ -614,11 +628,8 @@ begin
|
|||
end;
|
||||
end;
|
||||
//
|
||||
if focusedName <> '' then
|
||||
if focusedName.isNotEmpty then
|
||||
docHandler.openDocument(focusedName);
|
||||
|
||||
// TODO-cbugfix: if project file is reloaded to an editor it won't be linked to the matching project (e.g save file and project editor widget directly updated)
|
||||
// same with MRU file or mini-explorer.
|
||||
end;
|
||||
{$ENDREGION}
|
||||
|
||||
|
@ -1511,7 +1522,7 @@ end;
|
|||
|
||||
procedure TCEMainForm.saveFile(aDocument: TCESynMemo);
|
||||
begin
|
||||
if aDocument.Highlighter = LfmSyn then
|
||||
if (aDocument.Highlighter = LfmSyn) or (aDocument.Highlighter = JsSyn) then
|
||||
saveProjSource(aDocument)
|
||||
else if fileExists(aDocument.fileName) then
|
||||
aDocument.save;
|
||||
|
@ -2323,8 +2334,10 @@ begin
|
|||
if not fileExists(fProjectInterface.filename) then exit;
|
||||
//
|
||||
openFile(fProjectInterface.filename);
|
||||
//TODO-cDUB: add json highligher to edit json project in CE
|
||||
fDoc.Highlighter := LfmSyn;
|
||||
if fProjectInterface.getFormat = pfNative then
|
||||
fDoc.Highlighter := LfmSyn
|
||||
else
|
||||
fDoc.Highlighter := JsSyn;
|
||||
end;
|
||||
|
||||
procedure TCEMainForm.actProjOptViewExecute(Sender: TObject);
|
||||
|
|
|
@ -8,7 +8,7 @@ uses
|
|||
Classes, SysUtils, controls,lcltype, Forms, graphics, ExtCtrls, crc,
|
||||
SynEdit, SynPluginSyncroEdit, SynCompletion, SynEditKeyCmds, LazSynEditText,
|
||||
SynHighlighterLFM, SynEditHighlighter, SynEditMouseCmds, SynEditFoldedView,
|
||||
SynEditMarks, SynEditTypes,
|
||||
SynEditMarks, SynEditTypes, SynHighlighterJScript,
|
||||
ce_common, ce_observer, ce_writableComponent, ce_d2syn, ce_txtsyn, ce_dialogs,
|
||||
ce_sharedres;
|
||||
|
||||
|
@ -229,8 +229,10 @@ const
|
|||
|
||||
var
|
||||
D2Syn: TSynD2Syn; // used as model to set the options when no editor exists.
|
||||
LfmSyn: TSynLfmSyn; // used to highlight the native project format.
|
||||
TxtSyn: TSynTxtSyn; // used as model to set the options when no editor exists.
|
||||
LfmSyn: TSynLfmSyn; // used to highlight the native projects.
|
||||
JsSyn: TSynJScriptSyn; // used to highlight the DUB JSON projects.
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -1216,7 +1218,7 @@ end;
|
|||
|
||||
procedure TCESynMemo.MouseMove(Shift: TShiftState; X, Y: Integer);
|
||||
var
|
||||
dX, dY: Integer;
|
||||
dx, dy: Integer;
|
||||
begin
|
||||
hideDDocs;
|
||||
hideCallTips;
|
||||
|
@ -1333,11 +1335,21 @@ initialization
|
|||
D2Syn := TSynD2Syn.create(nil);
|
||||
LfmSyn := TSynLFMSyn.Create(nil);
|
||||
TxtSyn := TSynTxtSyn.create(nil);
|
||||
JsSyn := TSynJScriptSyn.Create(nil);
|
||||
//
|
||||
LfmSyn.KeyAttri.Foreground := clNavy;
|
||||
LfmSyn.KeyAttri.Style := [fsBold];
|
||||
LfmSyn.NumberAttri.Foreground := clMaroon;
|
||||
LfmSyn.StringAttri.Foreground := clBlue;
|
||||
LfmSyn.SymbolAttribute.Foreground:= clPurple;
|
||||
LfmSyn.SymbolAttribute.Style := [fsBold];
|
||||
//
|
||||
JsSyn.KeyAttri.Foreground := clNavy;
|
||||
JsSyn.KeyAttri.Style := [fsBold];
|
||||
JsSyn.NumberAttri.Foreground := clMaroon;
|
||||
JsSyn.StringAttri.Foreground := clBlue;
|
||||
JsSyn.SymbolAttribute.Foreground:= clPurple;
|
||||
JsSyn.SymbolAttribute.Style := [fsBold];
|
||||
//
|
||||
TCEEditorHintWindow.FontSize := 10;
|
||||
//
|
||||
|
@ -1346,6 +1358,7 @@ finalization
|
|||
D2Syn.Free;
|
||||
LfmSyn.Free;
|
||||
TxtSyn.Free;
|
||||
JsSyn.Free;
|
||||
//
|
||||
TCESynMemo.cleanCache;
|
||||
end.
|
||||
|
|
Loading…
Reference in New Issue