dcd, port num can be set in the option editor

This commit is contained in:
Basile Burg 2016-02-05 13:25:02 +01:00
parent 5f8cb1a679
commit 0c4510cad4
2 changed files with 21 additions and 1 deletions

View File

@ -12,6 +12,8 @@ uses
ce_common, ce_writableComponent, ce_interfaces, ce_observer, ce_synmemo;
type
(**
* Wrap the dcd-server and dcd-client processes.
*
@ -24,7 +26,7 @@ type
fTempLines: TStringList;
fInputSource: string;
fImportCache: TStringList;
//fPortNum: Word;
fPortNum: Word;
fServerWasRunning: boolean;
fClient, fServer: TProcess;
fAvailable: boolean;
@ -48,6 +50,8 @@ type
procedure docFocused(aDoc: TCESynMemo);
procedure docChanged(aDoc: TCESynMemo);
procedure docClosing(aDoc: TCESynMemo);
published
property port: word read fPortNum write fPortNum default 0;
public
constructor create(aOwner: TComponent); override;
destructor destroy; override;
@ -70,12 +74,19 @@ implementation
const
clientName = 'dcd-client' + exeExt;
serverName = 'dcd-server' + exeExt;
optsname = 'dcdoptions.txt';
{$REGION Standard Comp/Obj------------------------------------------------------}
constructor TCEDcdWrapper.create(aOwner: TComponent);
var
fname: string;
begin
inherited;
//
fname := getCoeditDocPath + optsname;
if fname.fileExists then
loadFromFile(fname);
//
fAvailable := exeInSysPath(clientName) and exeInSysPath(serverName);
if not fAvailable then
exit;
@ -93,6 +104,8 @@ begin
{$IFNDEF DEBUG}
fServer.ShowWindow := swoHIDE;
{$ENDIF}
if fPortNum <> 0 then
fServer.Parameters.Add('-p' + intToStr(port));
end;
fTempLines := TStringList.Create;
fImportCache := TStringList.Create;
@ -111,6 +124,7 @@ end;
destructor TCEDcdWrapper.destroy;
begin
saveToFile(getCoeditDocPath + optsname);
EntitiesConnector.removeObserver(self);
fImportCache.Free;
if fTempLines.isNotNil then

View File

@ -379,11 +379,13 @@ type
fReloadLastDocuments: boolean;
fMaxRecentProjs: integer;
fMaxRecentDocs: integer;
fDcdPort: word;
function getDubCompiler: TCECompiler;
function getNativeProjecCompiler: TCECompiler;
procedure setDubCompiler(value: TCECompiler);
procedure setNativeProjecCompiler(value: TCECompiler);
published
property dcdPort: word read fDcdPort write fDcdPort;
property floatingWidgetOnTop: boolean read fFloatingWidgetOnTop write fFloatingWidgetOnTop;
property reloadLastDocuments: boolean read fReloadLastDocuments write fReloadLastDocuments;
property maxRecentProjects: integer read fMaxRecentProjs write fMaxRecentProjs;
@ -464,8 +466,10 @@ begin
begin
fMaxRecentProjs:= CEMainForm.fProjMru.maxCount;
fMaxRecentDocs:= CEMainForm.fFileMru.maxCount;
fDcdPort := DcdWrapper.port;
end else if src = fBackup then
begin
fDcdPort:=fBackup.fDcdPort;
fMaxRecentDocs:= fBackup.fMaxRecentDocs;
fMaxRecentProjs:= fBackup.fMaxRecentProjs;
fReloadLastDocuments:=fBackup.fReloadLastDocuments;
@ -481,12 +485,14 @@ begin
CEMainForm.fProjMru.maxCount := fMaxRecentProjs;
CEMainForm.fFileMru.maxCount := fMaxRecentDocs;
CEMainForm.updateFloatingWidgetOnTop(fFloatingWidgetOnTop);
DcdWrapper.port:=fDcdPort;
end else if dst = fBackup then
begin
fBackup.fMaxRecentDocs:= fMaxRecentDocs;
fBackup.fMaxRecentProjs:= fMaxRecentProjs;
fBackup.fReloadLastDocuments:=fReloadLastDocuments;
fBackup.fFloatingWidgetOnTop:=fFloatingWidgetOnTop;
fBackup.fDcdPort:=fDcdPort;
end
else inherited;
end;