1 unit frComments;
2 
3 {(*}
4 (*------------------------------------------------------------------------------
5  Delphi Code formatter source code
6 
7 The Original Code is frComments.pas, released Nov 2003.
8 The Initial Developer of the Original Code is Anthony Steele.
9 Portions created by Anthony Steele are Copyright (C) 1999-2008 Anthony Steele.
10 All Rights Reserved.
11 Contributor(s): Anthony Steele.
12 
13 The contents of this file are subject to the Mozilla Public License Version 1.1
14 (the "License"). you may not use this file except in compliance with the License.
15 You may obtain a copy of the License at http://www.mozilla.org/NPL/
16 
17 Software distributed under the License is distributed on an "AS IS" basis,
18 WITHOUT WARRANTY OF ANY KIND, either express or implied.
19 See the License for the specific language governing rights and limitations
20 under the License.
21 
22 Alternatively, the contents of this file may be used under the terms of
23 the GNU General Public License Version 2 or later (the "GPL")
24 See http://www.gnu.org/licenses/gpl.html
25 ------------------------------------------------------------------------------*)
26 {*)}
27 
28 {$I JcfGlobal.inc}
29 
30 interface
31 
32 uses
33   StdCtrls, ExtCtrls, Classes,
34   IDEOptionsIntf, IDEOptEditorIntf;
35 
36 type
37   { TfComments }
38 
39   TfComments = class(TAbstractIDEOptionsEditor)
40     cbRemoveEmptyDoubleSlashComments: TCheckBox;
41     cbRemoveEmptyCurlyBraceComments: TCheckBox;
42     rgImbalancedCommentAction: TRadioGroup;
43   public
44     constructor Create(AOwner: TComponent); override;
45 
GetTitlenull46     function GetTitle: String; override;
47     procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
48     procedure ReadSettings({%H-}AOptions: TAbstractIDEOptions); override;
49     procedure WriteSettings({%H-}AOptions: TAbstractIDEOptions); override;
SupportedOptionsClassnull50     class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
51   end;
52 
53 implementation
54 
55 {$R *.lfm}
56 
57 uses
58   JcfSettings, JcfUIConsts, SetComments;
59 
60 constructor TfComments.Create(AOwner: TComponent);
61 begin
62   inherited;
63   //fiHelpContext := HELP_CLARIFY_COMMENTS;
64 end;
65 
GetTitlenull66 function TfComments.GetTitle: String;
67 begin
68   Result := lisAlignComments;
69 end;
70 
71 procedure TfComments.Setup(ADialog: TAbstractOptionsEditorDialog);
72 begin
73   cbRemoveEmptyDoubleSlashComments.Caption := lisCommentsRemoveEmptySlashComments;
74   cbRemoveEmptyCurlyBraceComments.Caption := lisCommentsRemoveEmptyCurlyBracesComments;
75   FormattingSettings.Comments.GetImbalancedCommentActions(rgImbalancedCommentAction.Items);
76 end;
77 
78 procedure TfComments.ReadSettings(AOptions: TAbstractIDEOptions);
79 begin
80   with FormattingSettings.Comments do
81   begin
82     cbRemoveEmptyDoubleSlashComments.Checked := RemoveEmptyDoubleSlashComments;
83     cbRemoveEmptyCurlyBraceComments.Checked  := RemoveEmptyCurlyBraceComments;
84     rgImbalancedCommentAction.ItemIndex      := Ord(ImbalancedCommentAction);
85   end;
86 end;
87 
88 procedure TfComments.WriteSettings(AOptions: TAbstractIDEOptions);
89 begin
90   with FormattingSettings.Comments do
91   begin
92     RemoveEmptyDoubleSlashComments := cbRemoveEmptyDoubleSlashComments.Checked;
93     RemoveEmptyCurlyBraceComments  := cbRemoveEmptyCurlyBraceComments.Checked;
94     ImbalancedCommentAction        := TImbalancedCommentAction(rgImbalancedCommentAction.ItemIndex);
95   end;
96 end;
97 
TfComments.SupportedOptionsClassnull98 class function TfComments.SupportedOptionsClass: TAbstractIDEOptionsClass;
99 begin
100   Result := TFormattingSettings;
101 end;
102 
103 initialization
104   RegisterIDEOptionsEditor(JCFOptionsGroup, TfComments, JCFOptionComments, JCFOptionClarify);
105 end.
106