renamed ce_common member getDocPath

This commit is contained in:
Basile Burg 2014-12-29 04:24:51 +01:00
parent 02af01a612
commit 0881fe9cec
7 changed files with 63 additions and 31 deletions

View File

@ -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;

View File

@ -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.
*)

View File

@ -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;

View File

@ -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}

View File

@ -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;

View File

@ -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]);

View File

@ -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;