From 118b747ef7558df9b75f142667ea036dffd21b8c Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 10 Nov 2014 11:08:00 +0100 Subject: [PATCH] generalized usage of dExtList --- src/ce_common.pas | 13 ++++++------- src/ce_dmdwrap.pas | 2 +- src/ce_messages.pas | 16 ++++++++++------ src/ce_projinspect.pas | 2 +- src/ce_synmemo.pas | 2 +- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index 7b533a07..b7fe0a7d 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -18,7 +18,7 @@ const libExt = {$IFDEF WINDOWS} '.lib' {$ELSE} '.a' {$ENDIF}; var - DExtList: TStringList; + dExtList: TStringList; DCompiler: string = 'dmd'; type @@ -136,7 +136,7 @@ type * Reduces a filename if its length is over the threshold defined by charThresh. * Even if the result is not usable anymore, it avoids any "visually-overloaded" MRU menu. *) - function shortenPath(const aPath: string; charThresh: Word = 80): string; + function shortenPath(const aPath: string; charThresh: Word = 60): string; (** * Returns the folder Coedit documents and settings. @@ -482,7 +482,7 @@ begin {$HINTS ON}{$WARNINGS ON} end; -function shortenPath(const aPath: string; charThresh: Word = 80): string; +function shortenPath(const aPath: string; charThresh: Word = 60): string; var i: NativeInt; sepCnt: NativeInt; @@ -728,9 +728,8 @@ end; initialization RegisterClasses([TMRUList, TMRUFileList]); - DExtList := TStringList.Create; - DExtList.Add('.d'); - DExtList.Add('.di'); + dExtList := TStringList.Create; + dExtList.AddStrings(['.d', '.D', '.di', '.DI', '.Di', '.dI']); finalization - DExtList.Free; + dExtList.Free; end. diff --git a/src/ce_dmdwrap.pas b/src/ce_dmdwrap.pas index db37ee04..6e4d927e 100644 --- a/src/ce_dmdwrap.pas +++ b/src/ce_dmdwrap.pas @@ -817,7 +817,7 @@ begin for str in fSrcs do if str <> '' then begin if not - listAsteriskPath(str, aList, DExtList) + listAsteriskPath(str, aList, dExtList) then aList.Add(str); end; diff --git a/src/ce_messages.pas b/src/ce_messages.pas index dd6fa250..914b845f 100644 --- a/src/ce_messages.pas +++ b/src/ce_messages.pas @@ -92,7 +92,7 @@ type TMessageKind = (msgkUnknown, msgkInfo, msgkHint, msgkWarn, msgkError); - function semanticMsgAna2(const aMessg: string): TCEAppMessageKind; + function guessMessageKind(const aMessg: string): TCEAppMessageKind; function getLineFromDmdMessage(const aMessage: string): TPoint; function openFileFromDmdMessage(const aMessage: string): boolean; @@ -360,7 +360,7 @@ var item: TTreeNode; begin if aKind = amkAuto then - aKind := semanticMsgAna2(aValue); + aKind := guessMessageKind(aValue); dt := new(PMessageData); dt^.data := aData; dt^.ctxt := aCtxt; @@ -474,7 +474,7 @@ begin end; end; -function semanticMsgAna2(const aMessg: string): TCEAppMessageKind; +function guessMessageKind(const aMessg: string): TCEAppMessageKind; var pos: Nativeint; idt: string; @@ -585,12 +585,16 @@ begin while(true) do begin inc(i); - if i > length(aMessage) then exit; + if i > length(aMessage) then + exit; if aMessage[i] = '(' then begin - if not fileExists(ident) then exit; + if not fileExists(ident) then + exit; ext := extractFileExt(ident); - if not (ext = '.d') or (ext = '.di') then exit; + // import(file) : ext may be different + if not dExtList.IndexOf(ext) = -1 then + exit; CEMainForm.openFile(ident); result := true; end; diff --git a/src/ce_projinspect.pas b/src/ce_projinspect.pas index 77f6da72..633dba73 100644 --- a/src/ce_projinspect.pas +++ b/src/ce_projinspect.pas @@ -227,7 +227,7 @@ begin begin fname := lst.Strings[i]; ext := extractFileExt(fname); - if (ext = '.d') or (ext = '.di') then + if dExtList.IndexOf(ext) <> -1 then fProject.addSource(fname); end; finally diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 64c2fd73..bd1fb7bc 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -154,7 +154,7 @@ var ext: string; begin ext := extractFileExt(aFilename); - if (ext <> '.d') and (ext <> '.di') then + if dExtList.IndexOf(ext) = -1 then Highlighter := nil; Lines.LoadFromFile(aFilename); fFilename := aFilename;