mirror of https://gitlab.com/basile.b/dexed.git
refact, dExtList replaces with several function that test the exts
* hasDlangSyntax * isDlangCompilable * isEditable
This commit is contained in:
parent
6d59b11178
commit
0bbbebd061
|
@ -24,8 +24,6 @@ const
|
||||||
dynExt = {$IFDEF WINDOWS} '.dll' {$ENDIF} {$IFDEF LINUX}'.so'{$ENDIF} {$IFDEF DARWIN}'.dylib'{$ENDIF};
|
dynExt = {$IFDEF WINDOWS} '.dll' {$ENDIF} {$IFDEF LINUX}'.so'{$ENDIF} {$IFDEF DARWIN}'.dylib'{$ENDIF};
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
||||||
dExtList: TStringList;
|
|
||||||
DCompiler: string = 'dmd';
|
DCompiler: string = 'dmd';
|
||||||
|
|
||||||
type
|
type
|
||||||
|
@ -220,6 +218,21 @@ type
|
||||||
*)
|
*)
|
||||||
function commonFolder(const someFiles: TStringList): string;
|
function commonFolder(const someFiles: TStringList): string;
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Returns true if ext matches a file extension whose type is highlightable
|
||||||
|
*)
|
||||||
|
function hasDlangSyntax(const ext: string): boolean;
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Returns true if ext matches a file extension whose type can be passed as source.
|
||||||
|
*)
|
||||||
|
function isDlangCompilable(const ext: string): boolean;
|
||||||
|
|
||||||
|
(**
|
||||||
|
* Returns true if ext matches a file extension whose type is editable in Coedit
|
||||||
|
*)
|
||||||
|
function isEditable(const ext: string): boolean;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
@ -990,18 +1003,36 @@ begin
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function AppIsRunning(const ExeName: string):Boolean;
|
function AppIsRunning(const ExeName: string):Boolean;
|
||||||
begin
|
begin
|
||||||
Result:= internalAppIsRunning(ExeName) > 0;
|
Result:= internalAppIsRunning(ExeName) > 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function hasDlangSyntax(const ext: string): boolean;
|
||||||
|
begin
|
||||||
|
result := false;
|
||||||
|
case ext of
|
||||||
|
'.d', '.di': result := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function isDlangCompilable(const ext: string): boolean;
|
||||||
|
begin
|
||||||
|
result := false;
|
||||||
|
case ext of
|
||||||
|
'.d', '.di', '.dd', '.obj', '.o', '.a', '.lib': result := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function isEditable(const ext: string): boolean;
|
||||||
|
begin
|
||||||
|
result := false;
|
||||||
|
case ext of
|
||||||
|
'.d', '.di', '.dd': result := true;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
dExtList := TStringList.Create;
|
|
||||||
dExtList.AddStrings(['.d', '.di', '.dd']);
|
|
||||||
registerClasses([TCEPersistentShortcut]);
|
registerClasses([TCEPersistentShortcut]);
|
||||||
finalization
|
|
||||||
dExtList.Free;
|
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -828,13 +828,20 @@ end;
|
||||||
procedure TPathsOpts.getOpts(const aList: TStrings);
|
procedure TPathsOpts.getOpts(const aList: TStrings);
|
||||||
var
|
var
|
||||||
str: string;
|
str: string;
|
||||||
|
exts: TStringList;
|
||||||
begin
|
begin
|
||||||
|
exts := TStringList.Create;
|
||||||
|
try
|
||||||
|
exts.AddStrings(['.d', '.di', '.dd']);
|
||||||
for str in fExtraSrcs do
|
for str in fExtraSrcs do
|
||||||
begin
|
begin
|
||||||
str := symbolExpander.get(str);
|
str := symbolExpander.get(str);
|
||||||
if not listAsteriskPath(str, aList, dExtList) then
|
if not listAsteriskPath(str, aList, exts) then
|
||||||
aList.Add(str);
|
aList.Add(str);
|
||||||
end;
|
end;
|
||||||
|
finally
|
||||||
|
exts.Free;
|
||||||
|
end;
|
||||||
for str in fImpMod do
|
for str in fImpMod do
|
||||||
aList.Add('-I'+ symbolExpander.get(str));
|
aList.Add('-I'+ symbolExpander.get(str));
|
||||||
for str in fImpStr do
|
for str in fImpStr do
|
||||||
|
|
|
@ -899,7 +899,6 @@ function openFileFromDmdMessage(const aMessage: string): boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
ident: string;
|
ident: string;
|
||||||
ext: string;
|
|
||||||
begin
|
begin
|
||||||
ident := '';
|
ident := '';
|
||||||
i := 0;
|
i := 0;
|
||||||
|
@ -913,8 +912,7 @@ begin
|
||||||
begin
|
begin
|
||||||
if not fileExists(ident) then
|
if not fileExists(ident) then
|
||||||
exit;
|
exit;
|
||||||
ext := extractFileExt(ident);
|
if not isEditable(extractFileExt(ident)) then
|
||||||
if dExtList.IndexOf(ext) = -1 then
|
|
||||||
exit;
|
exit;
|
||||||
getMultiDocHandler.openDocument(ident);
|
getMultiDocHandler.openDocument(ident);
|
||||||
result := true;
|
result := true;
|
||||||
|
|
|
@ -161,12 +161,9 @@ end;
|
||||||
|
|
||||||
procedure TCENativeProject.addSource(const aFilename: string);
|
procedure TCENativeProject.addSource(const aFilename: string);
|
||||||
var
|
var
|
||||||
relSrc, absSrc, ext: string;
|
relSrc, absSrc: string;
|
||||||
begin
|
begin
|
||||||
ext := ExtractFileExt(aFilename);
|
if not isDlangCompilable(ExtractFileExt(aFilename)) then
|
||||||
if (dExtList.IndexOf(ext) = -1) and
|
|
||||||
(ext <> '.obj') and (ext <> '.o')
|
|
||||||
and (ext <> '.lib') and (ext <> '.a') then
|
|
||||||
exit;
|
exit;
|
||||||
for relSrc in fSrcs do
|
for relSrc in fSrcs do
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -223,8 +223,7 @@ begin
|
||||||
i := fProject.Sources.IndexOf(fname);
|
i := fProject.Sources.IndexOf(fname);
|
||||||
if i > -1 then
|
if i > -1 then
|
||||||
fname := fProject.getAbsoluteSourceName(i);
|
fname := fProject.getAbsoluteSourceName(i);
|
||||||
if dExtList.IndexOf(ExtractFileExt(fname)) <> -1 then
|
if isEditable(ExtractFileExt(fname)) and fileExists(fname) then
|
||||||
if fileExists(fname) then
|
|
||||||
getMultiDocHandler.openDocument(fname);
|
getMultiDocHandler.openDocument(fname);
|
||||||
end
|
end
|
||||||
else if Tree.Selected.Parent = fConfNode then
|
else if Tree.Selected.Parent = fConfNode then
|
||||||
|
@ -267,7 +266,7 @@ end;
|
||||||
|
|
||||||
procedure TCEProjectInspectWidget.btnAddFoldClick(Sender: TObject);
|
procedure TCEProjectInspectWidget.btnAddFoldClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
dir, fname, ext: string;
|
dir, fname: string;
|
||||||
lst: TStringList;
|
lst: TStringList;
|
||||||
i: NativeInt;
|
i: NativeInt;
|
||||||
begin
|
begin
|
||||||
|
@ -289,8 +288,7 @@ begin
|
||||||
for i := 0 to lst.Count-1 do
|
for i := 0 to lst.Count-1 do
|
||||||
begin
|
begin
|
||||||
fname := lst.Strings[i];
|
fname := lst.Strings[i];
|
||||||
ext := extractFileExt(fname);
|
if isDlangCompilable(extractFileExt(fname)) then
|
||||||
if dExtList.IndexOf(ext) <> -1 then
|
|
||||||
fProject.addSource(fname);
|
fProject.addSource(fname);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
|
@ -349,12 +347,10 @@ var
|
||||||
ext: string;
|
ext: string;
|
||||||
begin
|
begin
|
||||||
ext := ExtractFileExt(aFilename);
|
ext := ExtractFileExt(aFilename);
|
||||||
if (dExtList.IndexOf(ext) = -1)
|
if not isDlangCompilable(ext) then
|
||||||
and (ext <> '.obj') and (ext <> '.o')
|
|
||||||
and (ext <> '.a') and (ext <> '.lib') then
|
|
||||||
exit;
|
exit;
|
||||||
fProject.addSource(aFilename);
|
fProject.addSource(aFilename);
|
||||||
if (dExtList.IndexOf(ext) <> -1) then
|
if isEditable(ext) then
|
||||||
getMultiDocHandler.openDocument(aFilename);
|
getMultiDocHandler.openDocument(aFilename);
|
||||||
end;
|
end;
|
||||||
var
|
var
|
||||||
|
|
|
@ -212,7 +212,7 @@ begin
|
||||||
for i := 0 to fProj.Sources.Count-1 do
|
for i := 0 to fProj.Sources.Count-1 do
|
||||||
begin
|
begin
|
||||||
fname := fProj.getAbsoluteSourceName(i);
|
fname := fProj.getAbsoluteSourceName(i);
|
||||||
if dExtList.IndexOf(ExtractFileExt(fname)) = -1 then
|
if not isEditable(ExtractFileExt(fname)) then
|
||||||
continue;
|
continue;
|
||||||
str.Add(fname);
|
str.Add(fname);
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -739,7 +739,7 @@ var
|
||||||
ext: string;
|
ext: string;
|
||||||
begin
|
begin
|
||||||
ext := extractFileExt(aFilename);
|
ext := extractFileExt(aFilename);
|
||||||
if (dExtList.IndexOf(ext) = -1) or (ext = '.dd') then
|
if not hasDlangSyntax(ext) then
|
||||||
Highlighter := TxtSyn;
|
Highlighter := TxtSyn;
|
||||||
Lines.LoadFromFile(aFilename);
|
Lines.LoadFromFile(aFilename);
|
||||||
fFilename := aFilename;
|
fFilename := aFilename;
|
||||||
|
@ -759,7 +759,7 @@ begin
|
||||||
Lines.SaveToFile(aFilename);
|
Lines.SaveToFile(aFilename);
|
||||||
fFilename := aFilename;
|
fFilename := aFilename;
|
||||||
ext := extractFileExt(aFilename);
|
ext := extractFileExt(aFilename);
|
||||||
if dExtList.IndexOf(ext) <> -1 then
|
if hasDlangSyntax(ext) then
|
||||||
Highlighter := fD2Highlighter;
|
Highlighter := fD2Highlighter;
|
||||||
FileAge(fFilename, fFileDate);
|
FileAge(fFilename, fFileDate);
|
||||||
fModified := false;
|
fModified := false;
|
||||||
|
|
Loading…
Reference in New Issue