IDE: added option to enable codetools auto indent

git-svn-id: trunk@22402 -
This commit is contained in:
mattias 2009-11-03 13:00:36 +00:00
parent 8c75e5f632
commit 38a3e64177
5 changed files with 81 additions and 31 deletions

View File

@ -93,6 +93,7 @@ type
FIdentComplAutoStartAfterPoint: boolean;
// auto indentation
FIndentationEnabled: boolean;
fIndentationFilename: String;
FIndentContextSensitive: boolean;
@ -186,6 +187,8 @@ type
write FIdentComplAutoStartAfterPoint;
// indentation
property IndentationEnabled: boolean read FIndentationEnabled
write FIndentationEnabled;
property IndentationFileName: String
read fIndentationFileName write fIndentationFileName;
property IndentContextSensitive: boolean read FIndentContextSensitive
@ -410,12 +413,13 @@ begin
'CodeToolsOptions/IdentifierCompletion/AutoStartAfterPoint',true);
// indentation
FIndentationEnabled :=
XMLConfig.GetValue('CodeToolsOptions/Indentation/Enabled',true);
fIndentationFilename :=
XMLConfig.GetValue('CodeToolsOptions/Indentation/FileName'
, TrimFilename(GetPrimaryConfigPath + PathDelim +DefaultIndentationFilename));
FIndentContextSensitive :=
XMLConfig.GetValue('CodeToolsOptions/Indentation/ContextSensitive'
, true);
XMLConfig.GetValue('CodeToolsOptions/Indentation/ContextSensitive',true);
XMLConfig.Free;
except
@ -524,6 +528,8 @@ begin
FIdentComplAutoStartAfterPoint,true);
// indentation
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/Enabled'
, FIndentationEnabled, true);
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/FileName'
, fIndentationFilename, '');
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/ContextSensitive'
@ -661,6 +667,7 @@ begin
FIdentComplAutoStartAfterPoint:=true;
// indentation
FIndentationEnabled:=true;
fIndentationFilename:=
TrimFilename(GetPrimaryConfigPath+PathDelim+DefaultIndentationFilename);
FIndentContextSensitive:=true;

View File

@ -5,8 +5,8 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
ClientWidth = 552
TabOrder = 0
Visible = False
DesignLeft = 293
DesignTop = 278
DesignLeft = 303
DesignTop = 326
object SrcPathGroupBox: TGroupBox[0]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
@ -106,13 +106,13 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
end
object IndentationGroupBox: TGroupBox[2]
Left = 0
Height = 87
Height = 115
Top = 204
Width = 552
Align = alTop
AutoSize = True
Caption = 'IndentationGroupBox'
ClientHeight = 68
ClientHeight = 96
ClientWidth = 548
TabOrder = 2
object IndentFileLabel: TLabel
@ -121,7 +121,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 11
Top = 39
Width = 95
BorderSpacing.Left = 6
Caption = 'IndentFileLabel'
@ -135,7 +135,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideRight.Control = IndentFileButton
Left = 107
Height = 27
Top = 7
Top = 35
Width = 320
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
@ -145,12 +145,13 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
Text = 'IndentFileEdit'
end
object IndentFileButton: TButton
AnchorSideTop.Control = IndentationGroupBox
AnchorSideTop.Control = IndentEnabledCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = IndentationGroupBox
AnchorSideRight.Side = asrBottom
Left = 427
Height = 29
Top = 6
Top = 34
Width = 115
Anchors = [akTop, akRight]
AutoSize = True
@ -167,11 +168,23 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 40
Top = 68
Width = 235
BorderSpacing.Around = 6
Caption = 'IndentContextSensitiveCheckBox'
TabOrder = 2
end
object IndentEnabledCheckBox: TCheckBox
AnchorSideLeft.Control = IndentationGroupBox
AnchorSideTop.Control = IndentationGroupBox
Left = 6
Height = 22
Top = 6
Width = 178
BorderSpacing.Around = 6
Caption = 'IndentEnabledCheckBox'
OnChange = IndentEnabledCheckBoxChange
TabOrder = 3
end
end
end

View File

@ -3,7 +3,7 @@
LazarusResources.Add('TCodetoolsGeneralOptionsFrame','FORMDATA',[
'TPF0'#241#29'TCodetoolsGeneralOptionsFrame'#28'CodetoolsGeneralOptionsFrame'
+#6'Height'#3#147#1#5'Width'#3'('#2#12'ClientHeight'#3#147#1#11'ClientWidth'#3
+'('#2#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#3'%'#1#9'DesignTop'#3#22#1
+'('#2#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#3'/'#1#9'DesignTop'#3'F'#1
+#0#242#2#0#9'TGroupBox'#15'SrcPathGroupBox'#22'AnchorSideLeft.Control'#7#5'O'
+'wner'#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRight.Control'#7#5
+'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2'+'#3
@ -38,29 +38,34 @@ LazarusResources.Add('TCodetoolsGeneralOptionsFrame','FORMDATA',[
+'CheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#22#3
+'Top'#2'l'#5'Width'#3#244#0#17'BorderSpacing.Top'#2#6#20'BorderSpacing.Aroun'
+'d'#2#6#7'Caption'#6#31'SkipForwardDeclarationsCheckBox'#8'TabOrder'#2#3#0#0
+#0#242#2#2#9'TGroupBox'#19'IndentationGroupBox'#4'Left'#2#0#6'Height'#2'W'#3
+#0#242#2#2#9'TGroupBox'#19'IndentationGroupBox'#4'Left'#2#0#6'Height'#2's'#3
+'Top'#3#204#0#5'Width'#3'('#2#5'Align'#7#5'alTop'#8'AutoSize'#9#7'Caption'#6
+#19'IndentationGroupBox'#12'ClientHeight'#2'D'#11'ClientWidth'#3'$'#2#8'TabO'
+#19'IndentationGroupBox'#12'ClientHeight'#2'`'#11'ClientWidth'#3'$'#2#8'TabO'
+'rder'#2#2#0#6'TLabel'#15'IndentFileLabel'#22'AnchorSideLeft.Control'#7#19'I'
+'ndentationGroupBox'#21'AnchorSideTop.Control'#7#14'IndentFileEdit'#18'Ancho'
+'rSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#18#3'Top'#2#11#5'Widt'
+'h'#2'_'#18'BorderSpacing.Left'#2#6#7'Caption'#6#15'IndentFileLabel'#11'Pare'
+'ntColor'#8#0#0#5'TEdit'#14'IndentFileEdit'#22'AnchorSideLeft.Control'#7#15
+'rSideTop.Side'#7#9'asrCenter'#4'Left'#2#6#6'Height'#2#18#3'Top'#2''''#5'Wid'
+'th'#2'_'#18'BorderSpacing.Left'#2#6#7'Caption'#6#15'IndentFileLabel'#11'Par'
+'entColor'#8#0#0#5'TEdit'#14'IndentFileEdit'#22'AnchorSideLeft.Control'#7#15
+'IndentFileLabel'#19'AnchorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Co'
+'ntrol'#7#16'IndentFileButton'#18'AnchorSideTop.Side'#7#9'asrCenter'#23'Anch'
+'orSideRight.Control'#7#16'IndentFileButton'#4'Left'#2'k'#6'Height'#2#27#3'T'
+'op'#2#7#5'Width'#3'@'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#18'Bo'
+'rderSpacing.Left'#2#6#17'BorderSpacing.Top'#2#6#20'BorderSpacing.Bottom'#2#6
+#8'TabOrder'#2#0#4'Text'#6#14'IndentFileEdit'#0#0#7'TButton'#16'IndentFileBu'
+'tton'#21'AnchorSideTop.Control'#7#19'IndentationGroupBox'#23'AnchorSideRigh'
+'t.Control'#7#19'IndentationGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'
+#4'Left'#3#171#1#6'Height'#2#29#3'Top'#2#6#5'Width'#2's'#7'Anchors'#11#5'akT'
+'op'#7'akRight'#0#8'AutoSize'#9#17'BorderSpacing.Top'#2#6#19'BorderSpacing.R'
+'ight'#2#6#20'BorderSpacing.Bottom'#2#6#7'Caption'#6#16'IndentFileButton'#7
+'OnClick'#7#21'IndentFileButtonClick'#8'TabOrder'#2#1#0#0#9'TCheckBox'#30'In'
+'dentContextSensitiveCheckBox'#22'AnchorSideLeft.Control'#7#19'IndentationGr'
+'oupBox'#21'AnchorSideTop.Control'#7#14'IndentFileEdit'#18'AnchorSideTop.Sid'
+'e'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#22#3'Top'#2'('#5'Width'#3#235#0#20
+'BorderSpacing.Around'#2#6#7'Caption'#6#30'IndentContextSensitiveCheckBox'#8
+'TabOrder'#2#2#0#0#0#0
+'op'#2'#'#5'Width'#3'@'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#18'B'
+'orderSpacing.Left'#2#6#17'BorderSpacing.Top'#2#6#20'BorderSpacing.Bottom'#2
+#6#8'TabOrder'#2#0#4'Text'#6#14'IndentFileEdit'#0#0#7'TButton'#16'IndentFile'
+'Button'#21'AnchorSideTop.Control'#7#21'IndentEnabledCheckBox'#18'AnchorSide'
+'Top.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#19'IndentationGroupB'
+'ox'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#171#1#6'Height'#2#29#3
+'Top'#2'"'#5'Width'#2's'#7'Anchors'#11#5'akTop'#7'akRight'#0#8'AutoSize'#9#17
+'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#20'BorderSpacing.Bottom'
+#2#6#7'Caption'#6#16'IndentFileButton'#7'OnClick'#7#21'IndentFileButtonClick'
+#8'TabOrder'#2#1#0#0#9'TCheckBox'#30'IndentContextSensitiveCheckBox'#22'Anch'
+'orSideLeft.Control'#7#19'IndentationGroupBox'#21'AnchorSideTop.Control'#7#14
+'IndentFileEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#6#6'Height'
+#2#22#3'Top'#2'D'#5'Width'#3#235#0#20'BorderSpacing.Around'#2#6#7'Caption'#6
+#30'IndentContextSensitiveCheckBox'#8'TabOrder'#2#2#0#0#9'TCheckBox'#21'Inde'
+'ntEnabledCheckBox'#22'AnchorSideLeft.Control'#7#19'IndentationGroupBox'#21
+'AnchorSideTop.Control'#7#19'IndentationGroupBox'#4'Left'#2#6#6'Height'#2#22
,#3'Top'#2#6#5'Width'#3#178#0#20'BorderSpacing.Around'#2#6#7'Caption'#6#21'In'
+'dentEnabledCheckBox'#8'OnChange'#7#27'IndentEnabledCheckBoxChange'#8'TabOrd'
+'er'#2#3#0#0#0#0
]);

View File

@ -35,6 +35,7 @@ type
TCodetoolsGeneralOptionsFrame = class(TAbstractIDEOptionsEditor)
AdjustTopLineDueToCommentCheckBox: TCheckBox;
IndentEnabledCheckBox: TCheckBox;
IndentContextSensitiveCheckBox: TCheckBox;
IndentFileButton: TButton;
CursorBeyondEOLCheckBox: TCheckBox;
@ -46,8 +47,10 @@ type
SkipForwardDeclarationsCheckBox: TCheckBox;
SrcPathEdit: TEdit;
SrcPathGroupBox: TGroupBox;
procedure IndentEnabledCheckBoxChange(Sender: TObject);
procedure IndentFileButtonClick(Sender: TObject);
private
procedure VisualizeIndentEnabled;
public
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
@ -76,6 +79,23 @@ begin
end;
end;
procedure TCodetoolsGeneralOptionsFrame.VisualizeIndentEnabled;
var
e: Boolean;
begin
e:=IndentEnabledCheckBox.Checked;
IndentFileLabel.Enabled:=e;
IndentFileEdit.Enabled:=e;
IndentFileButton.Enabled:=e;
IndentContextSensitiveCheckBox.Enabled:=e;
end;
procedure TCodetoolsGeneralOptionsFrame.IndentEnabledCheckBoxChange(
Sender: TObject);
begin
VisualizeIndentEnabled;
end;
function TCodetoolsGeneralOptionsFrame.GetTitle: String;
begin
Result := lisMenuInsertGeneral;
@ -101,6 +121,7 @@ begin
SkipForwardDeclarationsCheckBox.Caption:=dlgSkipForwardDeclarations;
IndentationGroupBox.Caption:=lisIndentation;
IndentEnabledCheckBox.Caption:=dlgMouseFoldEnabled;
IndentFileLabel.Caption:=lisExampleFile;
IndentFileButton.Caption:=lisPathEditBrowse;
IndentContextSensitiveCheckBox.Caption:=lisContextSensitive;
@ -119,9 +140,11 @@ begin
JumpCenteredCheckBox.Checked := JumpCentered;
CursorBeyondEOLCheckBox.Checked := CursorBeyondEOL;
SkipForwardDeclarationsCheckBox.Checked := SkipForwardDeclarations;
IndentEnabledCheckBox.Checked:=IndentationEnabled;
IndentFileEdit.Text:=IndentationFileName;
IndentContextSensitiveCheckBox.Checked:=IndentContextSensitive;
end;
VisualizeIndentEnabled;
end;
procedure TCodetoolsGeneralOptionsFrame.WriteSettings(
@ -134,6 +157,7 @@ begin
JumpCentered := JumpCenteredCheckBox.Checked;
CursorBeyondEOL := CursorBeyondEOLCheckBox.Checked;
SkipForwardDeclarations := SkipForwardDeclarationsCheckBox.Checked;
IndentationEnabled:=IndentEnabledCheckBox.Checked;
IndentationFileName:=IndentFileEdit.Text;
IndentContextSensitive:=IndentContextSensitiveCheckBox.Checked;
end;

View File

@ -6799,6 +6799,7 @@ begin
{$IFNDEF EnableIndenter}
exit;
{$ENDIF}
if not CodeToolsOpts.IndentationEnabled then exit;
if not (SrcEdit.SyntaxHighlighterType in [lshFreePascal, lshDelphi]) then
exit;
case Reason of