From 0881fe9cec846de74535aaedecf57af58ceab83e Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 29 Dec 2014 04:24:51 +0100 Subject: [PATCH] renamed ce_common member getDocPath --- src/ce_common.pas | 16 +++++++++++++--- src/ce_dcd.pas | 4 ++-- src/ce_libman.pas | 28 +++++++++++++++++++++++++--- src/ce_main.pas | 32 ++++++++++++++++---------------- src/ce_staticmacro.pas | 4 ++-- src/ce_synmemo.pas | 4 ++-- src/ce_tools.pas | 6 +++--- 7 files changed, 63 insertions(+), 31 deletions(-) diff --git a/src/ce_common.pas b/src/ce_common.pas index d9c83142..1c92ea9b 100644 --- a/src/ce_common.pas +++ b/src/ce_common.pas @@ -159,10 +159,15 @@ type *) function shortenPath(const aPath: string; charThresh: Word = 60): string; + (** + * Returns the user data dir. + *) + function getUserDocPath: string; + (** * Returns the folder Coedit documents and settings. *) - function getDocPath: string; + function getCoeditDocPath: string; (** * Fills aList with the names of the files located in aPath. @@ -574,7 +579,7 @@ begin exit( format('%s%s...%s',[drv,directorySeparator,pth1]) ); end; -function getDocPath: string; +function getUserDocPath: string; {$IFDEF WINDOWS} var PIDL : PItemIDList; @@ -592,7 +597,12 @@ begin {$IFDEF UNIX} result := ExpandFileName('~/'); {$ENDIF} - result += directorySeparator + 'Coedit' + directorySeparator; + result += directorySeparator; +end; + +function getCoeditDocPath: string; +begin + result := getUserDocPath + 'Coedit' + directorySeparator; end; function isFolder(sr: TSearchRec): boolean; diff --git a/src/ce_dcd.pas b/src/ce_dcd.pas index 264a320a..08815010 100644 --- a/src/ce_dcd.pas +++ b/src/ce_dcd.pas @@ -10,9 +10,9 @@ uses type (** - * Wrap the dcd-server and dcd-clients processes. + * Wrap the dcd-server and dcd-client processes. * - * Projects folder are automatically imported: ICEProjectObserver. + * Projects folders are automatically imported: ICEProjectObserver. * Completion, hints and declaration finder automatically work on the current * document: ICEMultiDocObserver. *) diff --git a/src/ce_libman.pas b/src/ce_libman.pas index 16286f08..fb7257d6 100644 --- a/src/ce_libman.pas +++ b/src/ce_libman.pas @@ -31,6 +31,7 @@ type private fCol: TCollection; procedure setCol(const aValue: TCollection); + procedure addDubPackages; protected procedure afterLoad; override; published @@ -59,14 +60,14 @@ var begin inherited; fCol := TCollection.Create(TLibraryItem); - fname := getDocPath + libFname; + fname := getCoeditDocPath + libFname; if fileExists(fname) then loadFromFile(fname); end; destructor TLibraryManager.destroy; begin - forceDirectory(getDocPath); - LibMan.saveToFile(getDocPath + libFname); + forceDirectory(getCoeditDocPath); + LibMan.saveToFile(getCoeditDocPath + libFname); fCol.Free; inherited; end; @@ -76,6 +77,27 @@ begin fCol.assign(aValue); end; +procedure TLibraryManager.addDubPackages; +var + path: string; +begin + if not exeInSysPath('dub' + exeExt) then exit; + // + path := getUserDocPath + 'dub' + DirectorySeparator + 'packages'; + { + get folders + foreach folder in folders + begin + if find src/import/source then + add libman entry with this folder (dcd completion, static explorer will use this) + if find lib with matching libname then + add lib file to the new libman item (runnable module can use it, alias can be specified in project) + end + + set the dubpackage entries readonly, since they'll be regenerated for each cession + } +end; + procedure TLibraryManager.updateDCD; var itm: TLibraryItem; diff --git a/src/ce_main.pas b/src/ce_main.pas index 9667ce68..f28608d0 100644 --- a/src/ce_main.pas +++ b/src/ce_main.pas @@ -530,8 +530,8 @@ var fname2: string; opts: TCEOptions; begin - fname1 := getDocPath + 'options2.txt'; - fname2 := getDocPath + 'options2.bak'; + fname1 := getCoeditDocPath + 'options2.txt'; + fname2 := getCoeditDocPath + 'options2.bak'; opts := TCEOptions.create(nil); try if fileExists(fname1) then @@ -558,8 +558,8 @@ begin exit; opts := TCEOptions.create(nil); try - forceDirectory(getDocPath); - opts.saveToFile(getDocPath + 'options2.txt'); + forceDirectory(getCoeditDocPath); + opts.saveToFile(getCoeditDocPath + 'options2.txt'); finally opts.Free; end; @@ -581,8 +581,8 @@ begin end; if not Visible then exit; // - forceDirectory(getDocPath); - xcfg := TXMLConfigStorage.Create(getDocPath + 'docking.xml',false); + forceDirectory(getCoeditDocPath); + xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'docking.xml',false); try DockMaster.SaveLayoutToConfig(xcfg); xcfg.WriteToDisk; @@ -590,7 +590,7 @@ begin xcfg.Free; end; // - xcfg := TXMLConfigStorage.Create(getDocPath + 'dockingopts.xml',false); + xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'dockingopts.xml',false); try DockMaster.SaveSettingsToConfig(xcfg); xcfg.WriteToDisk; @@ -604,9 +604,9 @@ var xcfg: TXMLConfigStorage; str: TMemoryStream; begin - if fileExists(getDocPath + 'docking.xml') then + if fileExists(getCoeditDocPath + 'docking.xml') then begin - xcfg := TXMLConfigStorage.Create(getDocPath + 'docking.xml', true); + xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'docking.xml', true); try try DockMaster.LoadLayoutFromConfig(xcfg, false); @@ -616,7 +616,7 @@ begin str := TMemoryStream.Create; try xcfg.SaveToStream(str); - str.saveToFile(getDocPath + 'docking.bak') + str.saveToFile(getCoeditDocPath + 'docking.bak') finally str.Free; end; @@ -624,9 +624,9 @@ begin xcfg.Free; end; end; - if fileExists(getDocPath + 'dockingopts.xml') then + if fileExists(getCoeditDocPath + 'dockingopts.xml') then begin - xcfg := TXMLConfigStorage.Create(getDocPath + 'dockingopts.xml', true); + xcfg := TXMLConfigStorage.Create(getCoeditDocPath + 'dockingopts.xml', true); try try DockMaster.LoadSettingsFromConfig(xcfg); @@ -636,7 +636,7 @@ begin str := TMemoryStream.Create; try xcfg.SaveToStream(str); - str.saveToFile(getDocPath + 'dockingopts.bak') + str.saveToFile(getCoeditDocPath + 'dockingopts.bak') finally str.Free; end; @@ -1523,7 +1523,7 @@ begin // lst := TStringList.Create; try - listFiles(lst, getDocPath + 'layouts' + DirectorySeparator); + listFiles(lst, getCoeditDocPath + 'layouts' + DirectorySeparator); for i := 0 to lst.Count-1 do begin itm := TMenuItem.Create(self); @@ -1540,7 +1540,7 @@ end; procedure TCEMainForm.layoutMnuItemClick(sender: TObject); begin - layoutLoadFromFile(getDocPath + 'layouts' + DirectorySeparator + + layoutLoadFromFile(getCoeditDocPath + 'layouts' + DirectorySeparator + TMenuItem(sender).Caption + '.xml'); end; @@ -1555,7 +1555,7 @@ begin fname := extractFileName(fname); if extractFileExt(fname) <> '.xml' then fname += '.xml'; - layoutSaveToFile(getDocPath + 'layouts' + DirectorySeparator + fname); + layoutSaveToFile(getCoeditDocPath + 'layouts' + DirectorySeparator + fname); layoutUpdateMenu; end; {$ENDREGION} diff --git a/src/ce_staticmacro.pas b/src/ce_staticmacro.pas index 647b7e7a..a122d666 100644 --- a/src/ce_staticmacro.pas +++ b/src/ce_staticmacro.pas @@ -82,7 +82,7 @@ begin fMacros.Delimiter := '='; assert(fCompletor.ShortCut <> 0); // - fname := getDocPath + macFname; + fname := getCoeditDocPath + macFname; if fileExists(fname) then loadFromFile(fname); addDefaults; // @@ -94,7 +94,7 @@ end; destructor TCEStaticEditorMacro.destroy; begin - saveToFile(getDocPath + macFname); + saveToFile(getCoeditDocPath + macFname); EntitiesConnector.removeObserver(Self); // fMacros.Free; diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 9bf991c4..eb3e9d92 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -203,7 +203,7 @@ begin tempn := fMemo.fileName; if not fileExists(tempn) then exit; // - fname := getDocPath + 'editorcache' + DirectorySeparator; + fname := getCoeditDocPath + 'editorcache' + DirectorySeparator; ForceDirectories(fname); chksm := crc32(0, nil, 0); chksm := crc32(chksm, @tempn[1], length(tempn)); @@ -220,7 +220,7 @@ begin tempn := fMemo.fileName; if not fileExists(tempn) then exit; // - fname := getDocPath + 'editorcache' + DirectorySeparator; + fname := getCoeditDocPath + 'editorcache' + DirectorySeparator; chksm := crc32(0, nil, 0); chksm := crc32(chksm, @tempn[1], length(tempn)); fname := fname + format('%.8X.txt', [chksm]); diff --git a/src/ce_tools.pas b/src/ce_tools.pas index e82f0c2d..2d25ff5e 100644 --- a/src/ce_tools.pas +++ b/src/ce_tools.pas @@ -137,7 +137,7 @@ var begin inherited; fTools := TCollection.Create(TCEToolItem); - fname := getDocPath + toolsFname; + fname := getCoeditDocPath + toolsFname; if fileExists(fname) then loadFromFile(fname); // EntitiesConnector.addObserver(self); @@ -147,8 +147,8 @@ destructor TCETools.destroy; begin EntitiesConnector.removeObserver(self); // - forceDirectory(getDocPath); - saveToFile(getDocPath + toolsFname); + forceDirectory(getCoeditDocPath); + saveToFile(getCoeditDocPath + toolsFname); fTools.Free; inherited; end;