diff --git a/src/u_common.pas b/src/u_common.pas index 7ed74bec..dae92e48 100644 --- a/src/u_common.pas +++ b/src/u_common.pas @@ -351,6 +351,9 @@ type // Converts the delta between two calls to GetTickCount64 to a string indicating a duration. function formatTicksAsDuration(ticks: UInt64): string; + // Returns wether runing in a dark DE + function isDarkDE(): boolean; + (** * Compares two TPoints. *) @@ -1562,6 +1565,11 @@ begin result += value[p .. value.length]; end; +function isDarkDE(): boolean; +begin + result := clBackground < clCaptionText; +end; + {$IFDEF DEBUG} initialization diff --git a/src/u_dcd.pas b/src/u_dcd.pas index 5e507abc..70d372b3 100644 --- a/src/u_dcd.pas +++ b/src/u_dcd.pas @@ -38,7 +38,6 @@ type fProj: ICommonProject; fPortAsProcParam: string; fVersion: TSemVer; - fCanRemove: boolean; procedure killServer; procedure terminateClient; {$IFNDEF DEBUG}inline;{$ENDIF} procedure waitClient; {$IFNDEF DEBUG}inline;{$ENDIF} @@ -105,7 +104,7 @@ var begin inherited; - fVersion.init('v0.0.0'); + fVersion.init('v0.0.0', false); fname := getDocPath + optsname; if fname.fileExists then loadFromFile(fname); @@ -137,16 +136,6 @@ begin fTempLines := TStringList.Create; fImportCache := TStringHashSet.Create; - fClient.Parameters.Add('--version'); - fClient.Execute; - processOutputToStrings(fClient, fTempLines); - while fClient.Running do ; - fVersion.init(fTempLines.strictText); - r.major := 0; - r.minor := 9; - r.patch := 10; - fCanRemove := fVersion > r; - if fServer.isAssigned then begin fServer.Execute; @@ -442,8 +431,6 @@ end; procedure TDcdWrapper.remImportFolder(const folder: string); begin - if not fCanRemove then - exit; if not fAvailable or not fServerListening or not fImportCache.contains(folder) then exit; @@ -460,8 +447,6 @@ var i: string; c: integer; begin - if not fCanRemove then - exit; if not fAvailable or not fServerListening then exit; diff --git a/src/u_dubproject.pas b/src/u_dubproject.pas index 3295a85b..45a3c895 100644 --- a/src/u_dubproject.pas +++ b/src/u_dubproject.pas @@ -326,9 +326,9 @@ var begin v := new(PSemVer); if value = 'vmaster' then - v^.init('v0.0.0-master') + v^.init('v0.0.0-master', false) else try - v^.init(value); + v^.init(value, true); except dispose(v); exit; @@ -1726,18 +1726,18 @@ procedure TDubProject.updateImportPathsFromJson; p := '0.0.0'; end else if (p = 'master') or (v = '~master') then - q.init('v0.0.0-master') + q.init('v0.0.0-master', false) else begin try - q.init('v' + p); + q.init('v' + p, true); except // while editing a DUB project from the DUB project editor, // '', i.e "undefined JSON value" can be found here. // So get DUB to fetch the most recent if the 'autoFetch' IDE option // is ON, even if another version is set later. o := '>='; - q.init('v0.0.0'); + q.init('v0.0.0', false); end; end; diff --git a/src/u_semver.pas b/src/u_semver.pas index 32d82051..afa1c004 100644 --- a/src/u_semver.pas +++ b/src/u_semver.pas @@ -20,7 +20,7 @@ type public // Initializes with the semVer text. // When throw is set to true an Exception is raised if the format is not compliant. - procedure init(const text: string; throw: boolean = true); + procedure init(const text: string; throw: boolean); // Indicates wether the version is not a final release. function isPreRelease: boolean; @@ -58,7 +58,7 @@ implementation var v1, v2: TSemVer; {$ENDIF} -procedure TSemVer.init(const text: string; throw: boolean = true); +procedure TSemVer.init(const text: string; throw: boolean); procedure resetFields(); begin @@ -84,12 +84,12 @@ begin if throw and (r.front <> 'v') then error('Invalid semVer format, the text must start with "v"'); r.popFront; - fMajor := r.takeUntil('.').yield.ToInteger; + fMajor := StrToInt64Def(r.takeUntil('.').yield, 0); if throw and r.empty then error('Invalid semVer format, minor and patch miss'); - fMinor := r.popFront^.takeUntil('.').yield.ToInteger; + fMinor := StrToInt64Def(r.popFront^.takeUntil('.').yield, 0); if not r.empty then - fPatch := r.popFront^.takeWhile(['0'..'9']).yield.ToInteger; + fPatch := StrToInt64Def(r.popFront^.takeWhile(['0'..'9']).yield, 0); if not r.empty then fAdditional := r.popFront^.takeUntil(#0).yield; fValid := true;