Subversion Repositories fastphp

Compare Revisions

Regard whitespace Rev 70 → Rev 71

/trunk/EditorMain.pas
951,6 → 951,8
end;
end;
 
var
FormShowRanOnce: boolean;
procedure TForm1.FormShow(Sender: TObject);
var
ScrapFile: string;
957,6 → 959,9
tmpFontSize: integer;
opts: TSynEditorOptions;
begin
if FormShowRanOnce then exit; // If the theme is changed from normal to dark, OnShow will be called another time
FormShowRanOnce := true;
 
ScrapFile := GetScrapFile;
if ScrapFile = '' then
begin
979,9 → 984,9
 
if FileExists(ScrapFile) then
begin
if hMutex = 0 then // If the theme is changed from normal to dark, OnShow will be called another time
if hMutex = 0 then
begin
hMutex := CreateMutex(nil, True, PChar('FastPHP'+IntToStr(StrHash(ScrapFile))));
hMutex := CreateMutex(nil, True, PChar('FastPHP'+md5(ScrapFile)));
if GetLastError = ERROR_ALREADY_EXISTS then
begin
// TODO: It would be great if the window of that FastPHP instance would switched to foreground
/trunk/Functions.pas
22,12 → 22,13
function GetTempDir: string;
function GetSpecialFolder(const aCSIDL: Integer): string;
function GetMyDocumentsFolder: string;
function StrHash(const st:string): cardinal;
function md5(value: string): string;
 
implementation
 
uses
ShlObj; // Needed for the CSIDL constants
ShlObj, // Needed for the CSIDL constants
IdGlobal, IdHash, IdHashMessageDigest; // used for MD5 calculation
 
function GetDosOutput(CommandLine: string; Work: string = ''; ContentCallBack: TContentCallBack=nil): string;
var
327,14 → 328,17
Result := GetSpecialFolder(CSIDL_PERSONAL);
end;
 
function StrHash(const st:string): cardinal;
function md5(value: string): string;
var
i:integer;
hashMessageDigest5 : TIdHashMessageDigest5;
begin
// https://stackoverflow.com/a/41400477/488539
result := 0;
for i := 1 to length(st) do
result := result*$20844 xor byte(st[i]);
hashMessageDigest5 := nil;
try
hashMessageDigest5 := TIdHashMessageDigest5.Create;
Result := IdGlobal.IndyLowerCase(hashMessageDigest5.HashStringAsHex(value));
finally
hashMessageDigest5.Free;
end;
end;
 
end.