JCF: Fix the option to confirm the formatting of a unit. Patch from Balázs.

git-svn-id: trunk@55497 -
This commit is contained in:
juha 2017-07-13 19:19:00 +00:00
parent 0982e734bb
commit e297288037
5 changed files with 12 additions and 20 deletions

View File

@ -84,7 +84,7 @@ uses
{ jcf }
JcfStringUtils,
{ local }
fAbout, frFiles, JcfRegistrySettings{, fRegistrySettings};
fAbout, frFiles, JcfSettings;
function FileIsAllowedType(const psFileName: string): boolean;
@ -116,12 +116,9 @@ begin
end;
function TJcfIdeMain.CanFormat(const AMsg: String): Boolean;
var
JCFRegistrySettings: TJCFRegistrySettings;
begin
Result := True;
JCFRegistrySettings := GetRegSettings;
if JCFRegistrySettings.ConfirmFormat then
if FormattingSettings.ConfirmFormat then
if MessageDlg(AMsg, mtConfirmation, [mbYes, mbNo], 0) <> mrYes then
Result := False
end;

View File

@ -58,7 +58,7 @@ type
TShowParseTreeOption = (eShowAlways, eShowOnError, eShowNever);
const
OLD_REG_ROOT_KEY = 'Software\Jedi\JediCodeFormat';
OLD_REG_ROOT_KEY = '\Software\Jedi\JediCodeFormat';
{$IFDEF FPC} REG_ROOT_KEY = OLD_REG_ROOT_KEY; {$ENDIF}
{$IFDEF DELPHI1} REG_ROOT_KEY = '\Software\Borland\Delphi\1.0\Jedi\JCF'; {$ENDIF}
{$IFDEF DELPHI2} REG_ROOT_KEY = '\Software\Borland\Delphi\2.0\Jedi\JCF'; {$ENDIF}

View File

@ -60,10 +60,10 @@ type
fShowParseTreeOption: TShowParseTreeOption;
{ ui settings }
fsFormatConfigFileName: string;
fsFormatConfigFileName: string;
fbFormatConfigNameSpecified: boolean;
fsLastSettingsPage: string;
fsLastSettingsPage: string;
feFormatFileWriteOption: TFormatFileWriteOption;
{notepad settings }
@ -96,7 +96,6 @@ type
fbEditorIntegration: boolean;
fbFormatBeforeSave: boolean;
fbFormatAfterLoad: boolean;
fbConfirmFormat: boolean;
procedure ReadMRUFiles;
procedure WriteMRUFiles;
@ -181,7 +180,6 @@ type
Write fbEditorIntegration;
property FormatBeforeSave: boolean Read fbFormatBeforeSave Write fbFormatBeforeSave;
property FormatAfterLoad: boolean Read fbFormatAfterLoad Write fbFormatAfterLoad;
property ConfirmFormat: boolean Read fbConfirmFormat Write fbConfirmFormat;
end;
function GetRegSettings: TJCFRegistrySettings;
@ -230,7 +228,6 @@ const
REG_EDITOR_INTEGRATION = 'EditorIntegration';
REG_FORMAT_BEFORE_SAVE = 'FormatBeforeSave';
REG_FORMAT_AFTER_LOAD = 'FormatAfterLoad';
REG_CONFIRM_FORMAT = 'ConfirmFormat';
{
file-based settings, ie
@ -438,7 +435,6 @@ begin
fbEditorIntegration := fcReg.ReadBool(REG_IDE_SECTION, REG_EDITOR_INTEGRATION, False);
fbFormatBeforeSave := fcReg.ReadBool(REG_IDE_SECTION, REG_FORMAT_BEFORE_SAVE, False);
fbFormatAfterLoad := fcReg.ReadBool(REG_IDE_SECTION, REG_FORMAT_AFTER_LOAD, False);
fbConfirmFormat := fcReg.ReadBool(REG_IDE_SECTION, REG_CONFIRM_FORMAT, True);
fbHasRead := True;
end;
@ -488,7 +484,6 @@ begin
fcReg.WriteBool(REG_IDE_SECTION, REG_EDITOR_INTEGRATION, fbEditorIntegration);
fcReg.WriteBool(REG_IDE_SECTION, REG_FORMAT_BEFORE_SAVE, fbFormatBeforeSave);
fcReg.WriteBool(REG_IDE_SECTION, REG_FORMAT_AFTER_LOAD, fbFormatAfterLoad);
fcReg.WriteBool(REG_IDE_SECTION, REG_CONFIRM_FORMAT, fbConfirmFormat);
end;
function TJCFRegistrySettings.CanClearMRU: boolean;

View File

@ -78,6 +78,7 @@ type
fsDescription: string;
fdtWriteDateTime: TDateTime;
fsWriteVersion: string;
fsConfirmFormat: Boolean;
procedure FromStream(const pcStream: TSettingsInput);
public
@ -125,6 +126,7 @@ type
property WriteOnExit: boolean Read fbWriteOnExit Write fbWriteOnExit;
property Dirty: boolean Read fbDirty Write fbDirty;
property HasRead: boolean read fbHasRead write fbHasRead;
property ConfirmFormat: boolean read fsConfirmFormat write fsConfirmFormat;
end;
function FormattingSettings: TFormattingSettings;
@ -267,6 +269,7 @@ const
REG_VERSION = 'WriteVersion';
REG_WRITE_DATETIME = 'WriteDateTime';
REG_DESCRIPTION = 'Description';
REG_CONFIRM_FORMAT = 'ConfirmFormat';
procedure TFormattingSettings.Read;
var
@ -397,6 +400,7 @@ begin
pcStream.Write(REG_VERSION, PROGRAM_VERSION);
pcStream.Write(REG_WRITE_DATETIME, Now);
pcStream.Write(REG_DESCRIPTION, Description);
pcStream.Write(REG_CONFIRM_FORMAT, fsConfirmFormat);
WriteToStream(fcObfuscate);
WriteToStream(fcClarify);
@ -464,6 +468,7 @@ begin
try
fsWriteVersion := pcStream.Read(REG_VERSION, '');
fsDescription := pcStream.Read(REG_DESCRIPTION, '');
fsConfirmFormat := pcStream.Read(REG_CONFIRM_FORMAT, True);
fdtWriteDateTime := pcStream.Read(REG_WRITE_DATETIME, 0.0);
ReadFromStream(fcObfuscate);

View File

@ -72,7 +72,7 @@ begin
lcSet := GetRegSettings;
cbConfirmFormat.Caption := lisFrFileConfirmFormat;
cbConfirmFormat.Checked := lcSet.ConfirmFormat;
cbConfirmFormat.Checked := FormattingSettings.ConfirmFormat;
lblFormatFileName.Caption := Format(lisFrFilesFormatFileIs, [lcSet.FormatConfigFileName]);
//lblFormatFileName.Caption := PathCompactPath(lblFormatFileName.Canvas.Handle, 'Format file is ' + lcSet.FormatConfigFileName, 450, cpCenter);
@ -110,14 +110,9 @@ begin
end;
procedure TfFiles.WriteSettings(AOptions: TAbstractIDEOptions);
var
lcSet: TJCFRegistrySettings;
begin
FormattingSettings.Description := mDescription.Text;
lcSet := GetRegSettings;
lcSet.ConfirmFormat := cbConfirmFormat.Checked;
lcSet.WriteAll;
FormattingSettings.ConfirmFormat := cbConfirmFormat.Checked;
end;
procedure TfFiles.FrameResize(Sender: TObject);