Jedi code format: replace deprecated TRegIniFile by TIniFile.

This commit is contained in:
DomingoGP 2024-01-28 11:28:29 +01:00
parent 86519acad0
commit 719f66bebf
4 changed files with 41 additions and 18 deletions

View File

@ -57,9 +57,6 @@ type
type
TShowParseTreeOption = (eShowAlways, eShowOnError, eShowNever);
const
REG_ROOT_KEY = '\Software\Jedi\JediCodeFormat';
const
SOURCE_FILE_FILTERS =
'All source|*.pas; *.dpr; *.dpk; *.pp; *.lpr; *.lpk; *.txt|' +

View File

@ -40,7 +40,7 @@ See http://www.gnu.org/licenses/gpl.html
interface
uses
Registry, Classes, SysUtils,
Classes, SysUtils, IniFiles,
{ local }
ConvertTypes;
@ -52,7 +52,7 @@ type
TJCFRegistrySettings = class(TObject)
private
fcReg: TRegIniFile;
fcReg: TIniFile;
fbHasRead: boolean;
{ general settings }
@ -239,7 +239,7 @@ end;
constructor TJCFRegistrySettings.Create;
begin
inherited;
fcReg := TRegIniFile.Create(REG_ROOT_KEY);
fcReg := TIniFile.Create(GetConfigFileNameJcf());
fcExclusionsFiles := TStringList.Create; // Will compare with CompareText.
fcExclusionsFiles.UseLocale := False;
@ -367,7 +367,7 @@ begin
feLogPlace := TLogPlace(fcReg.ReadInteger(REG_LOG_SECTION, REG_LOG_PLACE,
Ord(eLogTempDir)));
fsSpecifiedDirectory := fcReg.ReadString(REG_LOG_SECTION,
REG_SPECIFIED_DIRECTORY, 'c:\');
REG_SPECIFIED_DIRECTORY, {$ifdef Windows} 'c:\' {$else}'/'{$endif});
fbViewLogAfterRun := fcReg.ReadBool(REG_LOG_SECTION, REG_VIEW_LOG_AFTER_RUN, False);
fbLogTime := fcReg.ReadBool(REG_LOG_SECTION, REG_LOG_TIME, False);
fbLogStats := fcReg.ReadBool(REG_LOG_SECTION, REG_LOG_STATS, False);

View File

@ -1,5 +1,6 @@
unit RegistrySettings;
unit RegistrySettings deprecated 'Not used by JPF component';
// Unit not used in any package.
// TODO: delete from jcfbase and delete file.
{(*}
(*------------------------------------------------------------------------------
Delphi Code formatter source code
@ -38,7 +39,7 @@ interface
this object serves as both the root and the section
}
uses
Registry, Classes, SysUtils,
IniFiles, Classes, SysUtils,
{ local }
SettingsStream;
@ -46,7 +47,7 @@ type
TSettingsRegistryOutput = class(TSettingsOutput)
private
fReg: TRegIniFile;
fReg: TIniFile;
fsSection: string;
public
@ -70,13 +71,13 @@ type
TSettingsInputRegistry = class(TSettingsInput)
private
fReg: TRegIniFile;
fReg: TIniFile;
fsSection: string;
fbOwnReg: boolean;
public
constructor Create(const psRootKey: string); overload;
constructor Create(const pcReg: TRegIniFile; const psSection: string); overload;
constructor Create(const pcReg: TIniFile; const psSection: string); overload;
destructor Destroy; override;
@ -107,8 +108,7 @@ begin
Assert(psRootKey <> '');
inherited Create;
fReg := TRegIniFile.Create;
fReg.OpenKey(psRootKey, True);
fReg := TIniFile.Create(psRootKey);
fsSection := '';
end;
@ -182,14 +182,13 @@ begin
Assert(psRootKey <> '');
inherited Create;
fReg := TRegIniFile.Create;
fReg.OpenKey(psRootKey, True);
fReg := TIniFile.Create(psRootKey);
fsSection := '';
fbOwnReg := True;
end;
constructor TSettingsInputRegistry.Create(const pcReg: TRegIniFile;
constructor TSettingsInputRegistry.Create(const pcReg: TIniFile;
const psSection: string);
begin
Assert(psSection <> '');

View File

@ -50,6 +50,8 @@ interface
uses
Classes, SysUtils, JcfStringUtils, lconvencoding;
type
GetConfigFileNameFunction=function:string;
function GetApplicationFolder: string;
@ -65,6 +67,10 @@ function SetFileNameExtension(const psFileName, psExt: string): string;
procedure AdvanceTextPos(const AText: String; var ARow, ACol: integer);
function LastLineLength(const AString: string): integer;
function ReadFileToUTF8String(AFilename: string): string;
function GetConfigFileNameJcf:string;
var
GetConfigFileNameJcfFunction:GetConfigFileNameFunction = nil;
implementation
@ -332,4 +338,25 @@ begin
end;
{$pop}
function JcfApplicationName: string;
begin
Result := 'JediCodeFormat';
end;
function GetConfigFileNameJcf: string;
var
lOld: TGetAppNameEvent;
begin
if Assigned(GetConfigFileNameJcfFunction) then
Exit(GetConfigFileNameJcfFunction());
lOld := OnGetApplicationName;
OnGetApplicationName := @JcfApplicationName;
try
Result := GetAppConfigDir(True) + 'JediCodeFormat.ini';
finally
OnGetApplicationName := lOld;
end;
end;
end.