From: Thomas M. <tw...@us...> - 2006-11-05 15:33:03
|
Update of /cvsroot/gexperts/gexperts/unstable/Src/Formatter In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv18826 Modified Files: GX_CodeFormatterConfig.dfm GX_CodeFormatterConfig.pas GX_CodeFormatterConfigHandler.pas GX_CodeFormatterEditCapitalization.dfm GX_CodeFormatterEditCapitalization.pas Log Message: * bugfix in capitalization editor: if the change edit was empty, an exception occurred * The capitalization list can now be stored either in the registry or hin a file. Index: GX_CodeFormatterEditCapitalization.dfm =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/GX_CodeFormatterEditCapitalization.dfm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- GX_CodeFormatterEditCapitalization.dfm 19 Dec 2005 16:51:43 -0000 1.3 +++ GX_CodeFormatterEditCapitalization.dfm 5 Nov 2006 15:32:54 -0000 1.4 @@ -33,31 +33,49 @@ object b_Help: TButton Left = 8 Top = 8 - Width = 93 + Width = 75 Height = 25 Caption = '&Help' - TabOrder = 0 + TabOrder = 2 OnClick = b_HelpClick end object b_Ok: TButton - Left = 240 + Left = 288 Top = 8 - Width = 93 + Width = 75 Height = 25 Caption = 'OK' Default = True ModalResult = 1 - TabOrder = 1 + TabOrder = 0 end object b_Cancel: TButton - Left = 344 + Left = 369 Top = 8 - Width = 93 + Width = 75 Height = 25 Cancel = True Caption = 'Cancel' ModalResult = 2 - TabOrder = 2 + TabOrder = 1 + end + object b_Import: TButton + Left = 104 + Top = 8 + Width = 75 + Height = 25 + Caption = 'Import ...' + TabOrder = 3 + OnClick = b_ImportClick + end + object b_Export: TButton + Left = 185 + Top = 8 + Width = 75 + Height = 25 + Caption = 'Export ...' + TabOrder = 4 + OnClick = b_ExportClick end end object p_Upper: TPanel @@ -68,9 +86,6 @@ Align = alClient BevelOuter = bvNone TabOrder = 1 - DesignSize = ( - 452 - 308) object l_Select: TLabel Left = 8 Top = 8 @@ -114,67 +129,82 @@ OnChange = ed_ChangeChange end object b_UpperCase: TButton - Left = 240 + Left = 252 Top = 64 - Width = 93 + Width = 89 Height = 25 Caption = 'UpperCase' TabOrder = 3 OnClick = b_UpperCaseClick end object b_LowerCase: TButton - Left = 344 + Left = 347 Top = 64 - Width = 93 + Width = 89 Height = 25 Caption = 'LowerCase' TabOrder = 4 OnClick = b_LowerCaseClick end object b_FirstCharUp: TButton - Left = 240 + Left = 252 Top = 96 - Width = 93 + Width = 89 Height = 25 Caption = 'First Char Up' TabOrder = 5 OnClick = b_FirstCharUpClick end object b_FirstCharLow: TButton - Left = 344 - Top = 96 - Width = 93 + Left = 347 + Top = 95 + Width = 89 Height = 25 Caption = 'First Char Low' TabOrder = 6 OnClick = b_FirstCharLowClick end object b_AddIdentifier: TButton - Left = 240 + Left = 252 Top = 144 - Width = 93 + Width = 89 Height = 26 Caption = 'Add Identifier' TabOrder = 7 OnClick = b_AddIdentifierClick end object b_Delete: TButton - Left = 240 + Left = 252 Top = 176 - Width = 93 + Width = 89 Height = 25 Caption = 'Delete' TabOrder = 8 OnClick = b_DeleteClick end object b_ToggleComment: TButton - Left = 240 + Left = 252 Top = 208 - Width = 93 + Width = 89 Height = 25 Caption = 'Toggle comment' TabOrder = 9 OnClick = b_ToggleCommentClick end end + object od_Import: TOpenDialog + DefaultExt = 'txt' + Filter = 'text files (*.txt)|*.txt|all files (*.*)|*.*' + FilterIndex = 0 + Options = [ofHideReadOnly, ofPathMustExist, ofFileMustExist, ofEnableSizing] + Left = 248 + Top = 256 + end + object sd_Export: TSaveDialog + DefaultExt = 'txt' + Filter = 'text files (*.txt)|*.txt|all files (*.*)|*.*' + Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing] + Left = 328 + Top = 256 + end end Index: GX_CodeFormatterConfigHandler.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/GX_CodeFormatterConfigHandler.pas,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- GX_CodeFormatterConfigHandler.pas 19 Feb 2006 21:26:49 -0000 1.12 +++ GX_CodeFormatterConfigHandler.pas 5 Nov 2006 15:32:54 -0000 1.13 @@ -141,8 +141,13 @@ ES: TCodeFormatterEngineSettings; begin ASettings.ShowDoneDialog := AReader.ReadBool('ShowDoneDialog', True); + ASettings.UseCapitalizationFile := AReader.ReadBool('UseCapitalizationFile', False); + ASettings.CapitalizationFile := AReader.ReadString('CapitalizationFile', ''); ASettings.CapNames.Clear; - AReader.ReadStrings('Capitalization', ASettings.CapNames); + if ASettings.UseCapitalizationFile and (ASettings.CapitalizationFile <> '') and FileExists(ASettings.CapitalizationFile) then + ASettings.CapNames.LoadFromFile(ASettings.CapitalizationFile) + else + AReader.ReadStrings('Capitalization', ASettings.CapNames); ES := ASettings.Settings; ES.SpaceOperators := ReadSpaceSet('SpaceOperators', ES.SpaceOperators); @@ -236,7 +241,7 @@ AWriter.WriteBool('FeedEachUnit', ASettings.FeedEachUnit); //: Boolean; AWriter.WriteBool('NoFeedBeforeThen', ASettings.NoFeedBeforeThen); //: Boolean; AWriter.WriteBool('FeedElseIf', ASettings.FeedElseIf); //: Boolean; - AWriter.WriteInteger('FillNewWords', CapfileModeToInt(ASettings.FillNewWords)); + AWriter.WriteInteger('FillNewWords', CapfileModeToInt(ASettings.FillNewWords)); AWriter.WriteBool('FeedAfterSemiColon', ASettings.FeedAfterSemiColon); //: Boolean; AWriter.WriteString('StartCommentOut', ASettings.StartCommentOut); //: TCommentArray; AWriter.WriteString('EndCommentOut', ASettings.EndCommentOut); //: TCommentArray; @@ -250,7 +255,17 @@ AWriter.WriteBool('AlignVar', ASettings.AlignVar); //: Boolean; AWriter.WriteBool('ShowDoneDialog', ASettings.ShowDoneDialog); - AWriter.WriteStrings('Capitalization', ASettings.CapNames); + AWriter.WriteBool('UseCapitalizationFile', ASettings.UseCapitalizationFile); + AWriter.WriteString('CapitalizationFile', ASettings.CapitalizationFile); + + if ASettings.UseCapitalizationFile and (ASettings.CapitalizationFile <> '') then begin + try + ASettings.CapNames.SaveToFile(ASettings.CapitalizationFile); + except + // ignore, file might be readonly + end; + end else + AWriter.WriteStrings('Capitalization', ASettings.CapNames); end; class procedure TCodeFormatterConfigHandler.ExportToFile(const AFilename: string; ASettings: TCodeFormatterSettings); Index: GX_CodeFormatterEditCapitalization.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/GX_CodeFormatterEditCapitalization.pas,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- GX_CodeFormatterEditCapitalization.pas 19 Feb 2006 21:26:49 -0000 1.3 +++ GX_CodeFormatterEditCapitalization.pas 5 Nov 2006 15:32:54 -0000 1.4 @@ -42,6 +42,10 @@ b_Help: TButton; b_Ok: TButton; b_Cancel: TButton; + b_Import: TButton; + b_Export: TButton; + od_Import: TOpenDialog; + sd_Export: TSaveDialog; procedure FormShow(Sender: TObject); procedure lb_ItemsClick(Sender: TObject); procedure ed_ChangeChange(Sender: TObject); @@ -56,6 +60,8 @@ procedure b_ToggleCommentClick(Sender: TObject); procedure b_DeleteClick(Sender: TObject); procedure b_HelpClick(Sender: TObject); + procedure b_ImportClick(Sender: TObject); + procedure b_ExportClick(Sender: TObject); private FisChanged: Boolean; procedure ChangeSelected(AnAction: TCapitalizationAction); @@ -79,8 +85,8 @@ procedure TfmCodeFormatterEditCapitalization.ListToForm(AWordList: TStrings); var - S: string; - i: integer; + s: string; + i: Integer; begin // l_FileName.Caption := AFileName; ed_Search.Text := ''; @@ -89,8 +95,8 @@ lb_Items.Sorted := False; for i := 0 to AWordList.Count - 1 do begin s := AWordList[i]; - if S <> '' then - lb_Items.Items.Add(S); + if s <> '' then + lb_Items.Items.Add(s); end; lb_Items.Sorted := True; end; @@ -124,7 +130,7 @@ procedure TfmCodeFormatterEditCapitalization.ed_ChangeChange(Sender: TObject); var - Idx: integer; + Idx: Integer; begin Idx := lb_Items.ItemIndex; if Idx < 0 then begin @@ -143,46 +149,49 @@ procedure TfmCodeFormatterEditCapitalization.ChangeSelected(AnAction: TCapitalizationAction); var - I: Integer; + i: Integer; - function Change(S: string): string; + function Change(s: string): string; var Ch: Char; begin - case AnAction of - acUpperCase: Result := UpperCase(S); - acLowerCase: Result := LowerCase(S); - acFirstUp: begin - Result := S; - Result[1] := UpCase(Result[1]); - end; - acFirstLow: begin - Result := S; - Ch := Result[1]; - if (Ch >= 'A') and (Ch <= 'Z') then - Inc(Result[1], 32); - end; - acCommentOut: - if S[1] = '*' then - Result := Copy(S, 2, Length(S)) - else - Result := '*' + S; + Result := s; + if s <> '' then begin + case AnAction of + acUpperCase: Result := UpperCase(s); + acLowerCase: Result := LowerCase(s); + acFirstUp: begin + Result := s; + Result[1] := UpCase(Result[1]); + end; + acFirstLow: begin + Result := s; + Ch := Result[1]; + if (Ch >= 'A') and (Ch <= 'Z') then + Inc(Result[1], 32); + end; + acCommentOut: + if s[1] = '*' then + Result := Copy(s, 2, Length(s)) + else + Result := '*' + s; + end; end; - IsChanged := IsChanged or (S <> Result); + IsChanged := IsChanged or (s <> Result); end; begin - IsChanged := true; + IsChanged := True; if ed_Change.Enabled then begin if ed_Change.SelLength = 0 then ed_Change.Text := Change(ed_Change.Text) else ed_Change.SelText := Change(ed_Change.SelText); end else begin - for I := 0 to lb_Items.Count - 1 do begin - if lb_Items.Selected[I] then begin - lb_Items.Items[I] := Change(lb_Items.Items[I]); - lb_Items.Selected[I] := True; + for i := 0 to lb_Items.Count - 1 do begin + if lb_Items.Selected[i] then begin + lb_Items.Items[i] := Change(lb_Items.Items[i]); + lb_Items.Selected[i] := True; end; end; if (AnAction = acCommentOut) then begin @@ -210,17 +219,17 @@ procedure TfmCodeFormatterEditCapitalization.ed_SearchChange(Sender: TObject); var SearchEditText: string; - I, J, Lasti: Integer; + i, J, Lasti: Integer; begin SearchEditText := ed_Search.Text; J := 1; Lasti := 0; - for I := 0 to lb_Items.Count - 1 do begin - if (StrLIComp(PChar(SearchEditText), PChar(lb_Items.Items[I]), J) = 0) then begin + for i := 0 to lb_Items.Count - 1 do begin + if (StrLIComp(PChar(SearchEditText), PChar(lb_Items.Items[i]), J) = 0) then begin Inc(J); - Lasti := I; + Lasti := i; end; - lb_Items.Selected[I] := False; + lb_Items.Selected[i] := False; end; lb_Items.OnClick := nil; lb_Items.Selected[Lasti] := True; @@ -246,7 +255,7 @@ procedure TfmCodeFormatterEditCapitalization.ed_SearchKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); - procedure HandleUpDown(ADirection: integer); + procedure HandleUpDown(ADirection: Integer); begin lb_Items.Selected[lb_Items.ItemIndex] := False; lb_Items.ItemIndex := lb_Items.ItemIndex + ADirection; @@ -265,13 +274,13 @@ procedure TfmCodeFormatterEditCapitalization.b_AddIdentifierClick(Sender: TObject); var - I: Integer; + i: Integer; begin IsChanged := True; lb_Items.Items.Add('<New Identifier>'); lb_Items.ItemIndex := lb_Items.Items.IndexOf('<New Identifier>'); - for I := 0 to lb_Items.Count - 1 do - lb_Items.Selected[I] := False; + for i := 0 to lb_Items.Count - 1 do + lb_Items.Selected[i] := False; lb_Items.Selected[lb_Items.ItemIndex] := True; lb_ItemsClick(nil); end; @@ -283,15 +292,22 @@ procedure TfmCodeFormatterEditCapitalization.b_DeleteClick(Sender: TObject); var - I: Integer; + i: Integer; begin - for I := lb_Items.Count - 1 downto 0 do - if lb_Items.Selected[I] then begin - lb_Items.Items.Delete(I); - IsChanged := true; + for i := lb_Items.Count - 1 downto 0 do + if lb_Items.Selected[i] then begin + lb_Items.Items.Delete(i); + IsChanged := True; end; end; +procedure TfmCodeFormatterEditCapitalization.b_ExportClick(Sender: TObject); +begin + if not sd_Export.Execute then + Exit; + lb_Items.Items.SaveToFile(sd_Export.FileName); +end; + procedure TfmCodeFormatterEditCapitalization.b_HelpClick(Sender: TObject); //var // S: string; @@ -305,5 +321,12 @@ // end; end; +procedure TfmCodeFormatterEditCapitalization.b_ImportClick(Sender: TObject); +begin + if not od_Import.Execute then + Exit; + lb_Items.Items.LoadFromFile(od_Import.FileName); +end; + end. Index: GX_CodeFormatterConfig.dfm =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/GX_CodeFormatterConfig.dfm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- GX_CodeFormatterConfig.dfm 16 Oct 2006 18:39:10 -0000 1.8 +++ GX_CodeFormatterConfig.dfm 5 Nov 2006 15:32:54 -0000 1.9 @@ -120,9 +120,6 @@ end object ts_Spacing: TTabSheet Caption = 'Spacing' - DesignSize = ( - 470 - 357) object grid_Spacing: TStringGrid Left = 8 Top = 8 @@ -334,13 +331,6 @@ Height = 13 Caption = 'Capitalize' end - object Label11: TLabel - Left = 8 - Top = 136 - Width = 124 - Height = 13 - Caption = 'User defined capitalization' - end object Label14: TLabel Left = 8 Top = 18 @@ -399,30 +389,71 @@ 'Only first up' 'Unchanged') end - object FillNewWordsCombo: TComboBox - Left = 8 - Top = 152 - Width = 265 + object EditButton: TButton + Left = 392 + Top = 276 + Width = 75 + Height = 25 + Anchors = [akTop, akRight] + Caption = 'Edit ...' + TabOrder = 4 + OnClick = EditButtonClick + end + object rb_CapitalizationInRegistry: TRadioButton + Left = 16 + Top = 280 + Width = 238 + Height = 17 + Caption = 'Stored in Registry' + Checked = True + TabOrder = 6 + TabStop = True + OnClick = rb_CapitalizationInRegistryClick + end + object rb_CapitalizationInFile: TRadioButton + Left = 16 + Top = 303 + Width = 238 + Height = 17 + Caption = 'Stored in File' + TabOrder = 7 + OnClick = rb_CapitalizationInFileClick + end + object ed_CapitalizationFile: TEdit + Left = 32 + Top = 326 + Width = 354 Height = 21 - Style = csDropDownList - ItemHeight = 13 - TabOrder = 5 + Anchors = [akLeft, akTop, akRight] + Enabled = False + TabOrder = 8 + end + object b_CapitalizationSelect: TButton + Left = 392 + Top = 324 + Width = 75 + Height = 25 + Anchors = [akTop, akRight] + Caption = 'Select ...' + Enabled = False + TabOrder = 9 + OnClick = b_CapitalizationSelectClick + end + object rg_Capitalization: TRadioGroup + Left = 8 + Top = 121 + Width = 246 + Height = 134 + Caption = 'User defined capitalization' Items.Strings = ( - 'Do not use file' + 'Do not use list' 'Add new words only' - 'Use file' - 'Use file (except standard directives)' + 'Use list' + 'Use list (except standard directives)' 'Add and use' 'Add and use (except standard directives)') - end - object EditButton: TButton - Left = 280 - Top = 152 - Width = 53 - Height = 21 - Caption = 'Edit' - TabOrder = 4 - OnClick = EditButtonClick + TabOrder = 5 + TabStop = True end end object ts_Align: TTabSheet @@ -430,14 +461,14 @@ object Label16: TLabel Left = 12 Top = 35 - Width = 49 + Width = 51 Height = 13 Caption = 'At position' end object Label17: TLabel Left = 12 Top = 115 - Width = 49 + Width = 51 Height = 13 Caption = 'At position' end @@ -549,9 +580,6 @@ ImageIndex = 6 OnResize = ts_PreviewResize OnShow = ts_PreviewShow - DesignSize = ( - 470 - 357) object l_Before: TLabel Left = 6 Top = 0 @@ -620,9 +648,6 @@ Height = 41 Align = alBottom TabOrder = 1 - DesignSize = ( - 478 - 41) object b_Help: TButton Left = 8 Top = 8 @@ -675,8 +700,8 @@ Top = 7 end object pm_Extra: TPopupMenu - Left = 284 - Top = 264 + Left = 400 + Top = 64 object mi_ResetTo: TMenuItem Caption = 'Reset to' object mi_ResetToDefault: TMenuItem @@ -696,13 +721,21 @@ object od_Import: TOpenDialog Filter = 'INI-Files (*.ini)|*.ini|all files (*.*)|*.*' Options = [ofHideReadOnly, ofFileMustExist, ofEnableSizing, ofDontAddToRecent] - Left = 168 - Top = 294 + Left = 400 + Top = 176 end object sd_Export: TSaveDialog Filter = 'INI-Files (*.ini)|*.ini|all files (*.*)|*.*' Options = [ofOverwritePrompt, ofHideReadOnly, ofPathMustExist, ofNoReadOnlyReturn, ofEnableSizing, ofDontAddToRecent] - Left = 220 - Top = 295 + Left = 400 + Top = 120 + end + object od_CapitalizationFile: TOpenDialog + DefaultExt = 'txt' + Filter = 'text files (*.txt)|*.txt|all files (*.*)|*.*' + FilterIndex = 0 + Options = [ofHideReadOnly, ofPathMustExist, ofEnableSizing] + Left = 288 + Top = 344 end end Index: GX_CodeFormatterConfig.pas =================================================================== RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Formatter/GX_CodeFormatterConfig.pas,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- GX_CodeFormatterConfig.pas 22 Oct 2006 14:01:44 -0000 1.16 +++ GX_CodeFormatterConfig.pas 5 Nov 2006 15:32:54 -0000 1.17 @@ -32,8 +32,8 @@ protected function GetEditStyle(ACol: Integer; ARow: Integer): TEditStyle; override; function CreateEditor: TInplaceEdit; override; - function CanEditModify: boolean; override; - function CanEditShow: boolean; override; + function CanEditModify: Boolean; override; + function CanEditShow: Boolean; override; procedure OnGetSpacingOptions(ACol, ARow: Integer; Items: TStrings); public constructor Create(AOwner: TComponent); override; @@ -69,7 +69,6 @@ Label10: TLabel; StartCommentOutEdit: TEdit; EndCommentOutEdit: TEdit; - Label11: TLabel; OpenDialog: TOpenDialog; WrapLinesCheck: TCheckBox; Label13: TLabel; @@ -91,7 +90,6 @@ Label17: TLabel; AlignVarPosEdit: TEdit; AlignVarPosUpDown: TUpDown; - FillNewWordsCombo: TComboBox; FeedElseIfCheck: TCheckBox; NoFeedBeforeThenCheck: TCheckBox; NoIndentElseIfCheck: TCheckBox; @@ -124,6 +122,12 @@ GroupBox3: TGroupBox; Label2: TLabel; FeedRoundTryCombo: TComboBox; + rb_CapitalizationInRegistry: TRadioButton; + rb_CapitalizationInFile: TRadioButton; + ed_CapitalizationFile: TEdit; + b_CapitalizationSelect: TButton; + rg_Capitalization: TRadioGroup; + od_CapitalizationFile: TOpenDialog; procedure b_HelpClick(Sender: TObject); procedure EditButtonClick(Sender: TObject); procedure ts_PreviewShow(Sender: TObject); @@ -140,6 +144,9 @@ procedure mi_ResetToDefaultClick(Sender: TObject); procedure mi_ImportClick(Sender: TObject); procedure mi_ExportClick(Sender: TObject); + procedure rb_CapitalizationInRegistryClick(Sender: TObject); + procedure rb_CapitalizationInFileClick(Sender: TObject); + procedure b_CapitalizationSelectClick(Sender: TObject); private FCapitalization: TStringList; procedure EngineSettingsToForm(const AEngineSettings: TCodeFormatterEngineSettings); @@ -149,7 +156,7 @@ procedure FillPreview; procedure AddSpaceRow(RowNo: Integer; StrCol1, StrCol2: string; Space: TSpaceSet); - function GetSpaceItem(I: Integer): TSpaceSet; + function GetSpaceItem(i: Integer): TSpaceSet; procedure SetDefault(AWhich: string); public constructor Create(AOwner: TComponent); override; @@ -177,7 +184,7 @@ constructor TfmCodeFormatterConfig.Create(AOwner: TComponent); var st: TStringList; - i: integer; + i: Integer; mi: TMenuItem; begin inherited; @@ -204,26 +211,26 @@ inherited; end; -function TfmCodeFormatterConfig.GetSpaceItem(I: Integer): TSpaceSet; +function TfmCodeFormatterConfig.GetSpaceItem(i: Integer): TSpaceSet; var - S: string; + s: string; begin - S := grid_Spacing.Cells[2, I]; + s := grid_Spacing.Cells[2, i]; Result := spNone; - if S = str_Before then + if s = str_Before then Result := [spBefore] - else if S = str_after then + else if s = str_after then Result := [spAfter] - else if S = str_BeforeAfter then + else if s = str_BeforeAfter then Result := spBoth; end; procedure TfmCodeFormatterConfig.AddSpaceRow(RowNo: Integer; StrCol1, StrCol2: string; Space: TSpaceSet); - procedure SetColText(_Col: integer; const _s: string; _Offset: integer = 4); + procedure SetColText(_Col: Integer; const _s: string; _Offset: Integer = 4); var - w: integer; + w: Integer; begin grid_Spacing.Cells[_Col, RowNo] := _s; w := grid_Spacing.Canvas.TextWidth(_s) + _Offset; @@ -232,7 +239,7 @@ end; begin - SetColText(0, Strcol1); + SetColText(0, StrCol1); SetColText(1, StrCol2); if Space = spNone then @@ -303,7 +310,7 @@ ASettings.NoIndentElseIf := NoIndentElseIfCheck.Checked; ASettings.FeedBeforeEnd := FeedBeforeEndCheck.Checked; ASettings.FeedAfterSemiColon := FeedAfterSemiColonCheck.Checked; - ASettings.FillNewWords := IntToCapfileMode(FillNewWordsCombo.ItemIndex); + ASettings.FillNewWords := IntToCapfileMode(rg_Capitalization.ItemIndex); ASettings.StartCommentOut := Trim(StartCommentOutEdit.Text); ASettings.EndCommentOut := Trim(EndCommentOutEdit.Text); ASettings.FeedRoundBegin := TFeedBegin(FeedRoundBeginCombo.ItemIndex); @@ -316,6 +323,8 @@ begin ASettings.CapNames.Assign(FCapitalization); ASettings.ShowDoneDialog := chk_ShowDone.Checked; + ASettings.UseCapitalizationFile := rb_CapitalizationInFile.Checked; + ASettings.CapitalizationFile := ed_CapitalizationFile.Text; FormToEngineSettings(Settings); ASettings.Settings := Settings; @@ -360,7 +369,7 @@ AddSpaceRow(2, str_MathOperators, str_MathOperatorsExample, AEngineSettings.SpaceOperators); AddSpaceRow(3, str_Colon, ':', AEngineSettings.SpaceColon); - AddSpaceRow(4, str_Semicolon, ';', AEngineSettings.SpaceSemiColon); + AddSpaceRow(4, str_SemiColon, ';', AEngineSettings.SpaceSemiColon); AddSpaceRow(5, str_Comma, ',', AEngineSettings.SpaceComma); AddSpaceRow(6, str_LeftParenthesis, '(', AEngineSettings.SpaceLeftBr); AddSpaceRow(7, str_RightParenthesis, ')', AEngineSettings.SpaceRightBr); @@ -382,7 +391,7 @@ AlignCommentPosUpDown.Position := AEngineSettings.AlignCommentPos; AlignVarCheck.Checked := AEngineSettings.AlignVar; AlignVarPosUpDown.Position := AEngineSettings.AlignVarPos; - FillNewWordsCombo.ItemIndex := CapfileModeToInt(AEngineSettings.FillNewWords); + rg_Capitalization.ItemIndex := CapfileModeToInt(AEngineSettings.FillNewWords); StartCommentOutEdit.Text := string(AEngineSettings.StartCommentOut); EndCommentOutEdit.Text := string(AEngineSettings.EndCommentOut); FeedRoundBeginCombo.ItemIndex := Integer(AEngineSettings.FeedRoundBegin); @@ -397,6 +406,8 @@ procedure TfmCodeFormatterConfig.SettingsToForm(const ASettings: TCodeFormatterSettings); begin chk_ShowDone.Checked := ASettings.ShowDoneDialog; + rb_CapitalizationInFile.Checked := ASettings.UseCapitalizationFile; + ed_CapitalizationFile.Text := ASettings.CapitalizationFile; FCapitalization.Assign(ASettings.CapNames); EngineSettingsToForm(ASettings.Settings); @@ -426,6 +437,33 @@ ts_PreviewShow(nil); end; +procedure TfmCodeFormatterConfig.b_CapitalizationSelectClick(Sender: TObject); +var + s: string; +begin + od_CapitalizationFile.FileName := ed_CapitalizationFile.Text; + if not od_CapitalizationFile.Execute then + Exit; + + s := od_CapitalizationFile.FileName; + if FileExists(s) then begin + if FCapitalization.Count > 0 then begin + if mrYes <> MessageDlg( + 'Your current capitalization list is not empty and the file already exists.'#13#10 + + 'If you continue, your list will be discarded and the selected file loaded instead.'#13#10 + + 'Continue?', mtWarning, [mbYes, mbNo], 0) then + Exit; + end; + FCapitalization.LoadFromFile(s); + end else begin + if FCapitalization.Count > 0 then begin + FCapitalization.SaveToFile(s); + end; + end; + + ed_CapitalizationFile.Text := s; +end; + procedure TfmCodeFormatterConfig.b_HelpClick(Sender: TObject); var HlpFile: string; @@ -507,6 +545,18 @@ m_PreviewBeforeClick(nil); end; +procedure TfmCodeFormatterConfig.rb_CapitalizationInFileClick(Sender: TObject); +begin + ed_CapitalizationFile.Enabled := True; + b_CapitalizationSelect.Enabled := True; +end; + +procedure TfmCodeFormatterConfig.rb_CapitalizationInRegistryClick(Sender: TObject); +begin + ed_CapitalizationFile.Enabled := False; + b_CapitalizationSelect.Enabled := False; +end; + procedure TfmCodeFormatterConfig.FormShow(Sender: TObject); begin FillPreview; @@ -537,7 +587,7 @@ var Point: TPoint; begin - Point.x := b_Tools.Width; + Point.X := b_Tools.Width; Point.Y := 0; Point := b_Tools.ClientToScreen(Point); pm_Extra.Popup(Point.X, Point.Y); @@ -641,12 +691,12 @@ inherited; end; -function TStringGrid.CanEditModify: boolean; +function TStringGrid.CanEditModify: Boolean; begin Result := False; end; -function TStringGrid.CanEditShow: boolean; +function TStringGrid.CanEditShow: Boolean; begin Result := (Col = 2); end; |