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

View File

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

View File

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

View File

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

View File

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