IDE: added option to enabled indent on line break and indent on paste

git-svn-id: trunk@22423 -
This commit is contained in:
mattias 2009-11-04 11:32:10 +00:00
parent 586f1a284b
commit 3c0eb0f5c6
6 changed files with 93 additions and 62 deletions

View File

@ -93,7 +93,8 @@ type
FIdentComplAutoStartAfterPoint: boolean;
// auto indentation
FIndentationEnabled: boolean;
FIndentOnLineBreak: boolean;
FIndentOnPaste: boolean;
fIndentationFilename: String;
FIndentContextSensitive: boolean;
@ -187,8 +188,9 @@ type
write FIdentComplAutoStartAfterPoint;
// indentation
property IndentationEnabled: boolean read FIndentationEnabled
write FIndentationEnabled;
property IndentOnLineBreak: boolean read FIndentOnLineBreak
write FIndentOnLineBreak;
property IndentOnPaste: boolean read FIndentOnPaste write FIndentOnPaste;
property IndentationFileName: String
read fIndentationFileName write fIndentationFileName;
property IndentContextSensitive: boolean read FIndentContextSensitive
@ -413,8 +415,10 @@ begin
'CodeToolsOptions/IdentifierCompletion/AutoStartAfterPoint',true);
// indentation
FIndentationEnabled :=
XMLConfig.GetValue('CodeToolsOptions/Indentation/Enabled',true);
FIndentOnLineBreak :=
XMLConfig.GetValue('CodeToolsOptions/Indentation/OnLineBreak/Enabled',true);
FIndentOnPaste :=
XMLConfig.GetValue('CodeToolsOptions/Indentation/OnPaste/Enabled',true);
fIndentationFilename :=
XMLConfig.GetValue('CodeToolsOptions/Indentation/FileName'
, TrimFilename(GetPrimaryConfigPath + PathDelim +DefaultIndentationFilename));
@ -528,8 +532,10 @@ begin
FIdentComplAutoStartAfterPoint,true);
// indentation
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/Enabled'
, FIndentationEnabled, true);
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/OnLineBreak/Enabled'
, FIndentOnLineBreak, true);
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/OnPaste/Enabled'
, FIndentOnPaste, true);
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/FileName'
, fIndentationFilename, '');
XMLConfig.SetDeleteValue('CodeToolsOptions/Indentation/ContextSensitive'
@ -667,7 +673,8 @@ begin
FIdentComplAutoStartAfterPoint:=true;
// indentation
FIndentationEnabled:=true;
FIndentOnLineBreak:=true;
FIndentOnPaste:=true;
fIndentationFilename:=
TrimFilename(GetPrimaryConfigPath+PathDelim+DefaultIndentationFilename);
FIndentContextSensitive:=true;

View File

@ -5,21 +5,21 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
ClientWidth = 552
TabOrder = 0
Visible = False
DesignLeft = 303
DesignTop = 326
DesignLeft = 308
DesignTop = 350
object SrcPathGroupBox: TGroupBox[0]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 0
Height = 43
Height = 58
Top = 0
Width = 552
Align = alTop
AutoSize = True
Caption = 'SrcPathGroupBox'
ClientHeight = 24
ClientHeight = 39
ClientWidth = 548
TabOrder = 0
object SrcPathEdit: TEdit
@ -44,7 +44,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideRight.Side = asrBottom
Left = 0
Height = 155
Top = 49
Top = 64
Width = 552
Align = alTop
AutoSize = True
@ -106,13 +106,13 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
end
object IndentationGroupBox: TGroupBox[2]
Left = 0
Height = 115
Top = 204
Height = 144
Top = 219
Width = 552
Align = alTop
AutoSize = True
Caption = 'IndentationGroupBox'
ClientHeight = 96
ClientHeight = 125
ClientWidth = 548
TabOrder = 2
object IndentFileLabel: TLabel
@ -121,7 +121,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideTop.Side = asrCenter
Left = 6
Height = 18
Top = 39
Top = 95
Width = 95
BorderSpacing.Left = 6
Caption = 'IndentFileLabel'
@ -135,7 +135,7 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
AnchorSideRight.Control = IndentFileButton
Left = 107
Height = 27
Top = 35
Top = 91
Width = 320
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 6
@ -145,13 +145,13 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
Text = 'IndentFileEdit'
end
object IndentFileButton: TButton
AnchorSideTop.Control = IndentEnabledCheckBox
AnchorSideTop.Control = IndentContextSensitiveCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = IndentationGroupBox
AnchorSideRight.Side = asrBottom
Left = 427
Height = 29
Top = 34
Top = 90
Width = 115
Anchors = [akTop, akRight]
AutoSize = True
@ -164,27 +164,39 @@ inherited CodetoolsGeneralOptionsFrame: TCodetoolsGeneralOptionsFrame
end
object IndentContextSensitiveCheckBox: TCheckBox
AnchorSideLeft.Control = IndentationGroupBox
AnchorSideTop.Control = IndentFileEdit
AnchorSideTop.Control = IndentOnPasteCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 68
Top = 62
Width = 235
BorderSpacing.Around = 6
Caption = 'IndentContextSensitiveCheckBox'
TabOrder = 2
end
object IndentEnabledCheckBox: TCheckBox
object IndentOnLineBreakCheckBox: TCheckBox
AnchorSideLeft.Control = IndentationGroupBox
AnchorSideTop.Control = IndentationGroupBox
Left = 6
Height = 22
Top = 6
Width = 178
Width = 208
BorderSpacing.Around = 6
Caption = 'IndentEnabledCheckBox'
OnChange = IndentEnabledCheckBoxChange
Caption = 'IndentOnLineBreakCheckBox'
OnChange = IndentOnLineBreakCheckBoxChange
TabOrder = 3
end
object IndentOnPasteCheckBox: TCheckBox
AnchorSideLeft.Control = IndentationGroupBox
AnchorSideTop.Control = IndentOnLineBreakCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 22
Top = 34
Width = 180
BorderSpacing.Around = 6
Caption = 'IndentOnPasteCheckBox'
TabOrder = 4
end
end
end

View File

@ -3,12 +3,12 @@
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'F'#1
+'('#2#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#3'4'#1#9'DesignTop'#3'^'#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
+'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2':'#3
+'Top'#2#0#5'Width'#3'('#2#5'Align'#7#5'alTop'#8'AutoSize'#9#7'Caption'#6#15
+'SrcPathGroupBox'#12'ClientHeight'#2#24#11'ClientWidth'#3'$'#2#8'TabOrder'#2
+'SrcPathGroupBox'#12'ClientHeight'#2''''#11'ClientWidth'#3'$'#2#8'TabOrder'#2
+#0#0#5'TEdit'#11'SrcPathEdit'#22'AnchorSideLeft.Control'#7#15'SrcPathGroupBo'
+'x'#23'AnchorSideRight.Control'#7#15'SrcPathGroupBox'#20'AnchorSideRight.Sid'
+'e'#7#9'asrBottom'#4'Left'#2#6#6'Height'#2#27#3'Top'#2#6#5'Width'#3#24#2#7'A'
@ -17,7 +17,7 @@ LazarusResources.Add('TCodetoolsGeneralOptionsFrame','FORMDATA',[
+'gGroupBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7
+#15'SrcPathGroupBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRigh'
+'t.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#0#6
+'Height'#3#155#0#3'Top'#2'1'#5'Width'#3'('#2#5'Align'#7#5'alTop'#8'AutoSize'
+'Height'#3#155#0#3'Top'#2'@'#5'Width'#3'('#2#5'Align'#7#5'alTop'#8'AutoSize'
+#9#17'BorderSpacing.Top'#2#6#7'Caption'#6#15'JumpingGroupBox'#12'ClientHeigh'
+'t'#3#136#0#11'ClientWidth'#3'$'#2#8'TabOrder'#2#1#0#9'TCheckBox!AdjustTopLi'
+'neDueToCommentCheckBox'#22'AnchorSideLeft.Control'#7#15'JumpingGroupBox'#21
@ -38,34 +38,39 @@ 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'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'`'#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''''#5'Wid'
+#0#242#2#2#9'TGroupBox'#19'IndentationGroupBox'#4'Left'#2#0#6'Height'#3#144#0
+#3'Top'#3#219#0#5'Width'#3'('#2#5'Align'#7#5'alTop'#8'AutoSize'#9#7'Caption'
+#6#19'IndentationGroupBox'#12'ClientHeight'#2'}'#11'ClientWidth'#3'$'#2#8'Ta'
+'bOrder'#2#2#0#6'TLabel'#15'IndentFileLabel'#22'AnchorSideLeft.Control'#7#19
+'IndentationGroupBox'#21'AnchorSideTop.Control'#7#14'IndentFileEdit'#18'Anch'
+'orSideTop.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'#'#5'Width'#3'@'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#18'B'
+'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
+'Button'#21'AnchorSideTop.Control'#7#30'IndentContextSensitiveCheckBox'#18'A'
+'nchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#19'Indentat'
+'ionGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#171#1#6'Heig'
+'ht'#2#29#3'Top'#2'Z'#5'Width'#2's'#7'Anchors'#11#5'akTop'#7'akRight'#0#8'Au'
+'toSize'#9#17'BorderSpacing.Top'#2#6#19'BorderSpacing.Right'#2#6#20'BorderSp'
+'acing.Bottom'#2#6#7'Caption'#6#16'IndentFileButton'#7'OnClick'#7#21'IndentF'
+'ileButtonClick'#8'TabOrder'#2#1#0#0#9'TCheckBox'#30'IndentContextSensitiveC'
+'heckBox'#22'AnchorSideLeft.Control'#7#19'IndentationGroupBox'#21'AnchorSide'
+'Top.Control'#7#21'IndentOnPasteCheckBox'#18'AnchorSideTop.Side'#7#9'asrBott'
+'om'#4'Left'#2#6#6'Height'#2#22#3'Top'#2'>'#5'Width'#3#235#0#20'BorderSpacin'
+'g.Around'#2#6#7'Caption'#6#30'IndentContextSensitiveCheckBox'#8'TabOrder'#2
+#2#0#0#9'TCheckBox'#25'IndentOnLineBreakCheckBox'#22'AnchorSideLeft.Control'
+#7#19'IndentationGroupBox'#21'AnchorSideTop.Control'#7#19'IndentationGroupBo'
,'x'#4'Left'#2#6#6'Height'#2#22#3'Top'#2#6#5'Width'#3#208#0#20'BorderSpacing.'
+'Around'#2#6#7'Caption'#6#25'IndentOnLineBreakCheckBox'#8'OnChange'#7#31'Ind'
+'entOnLineBreakCheckBoxChange'#8'TabOrder'#2#3#0#0#9'TCheckBox'#21'IndentOnP'
+'asteCheckBox'#22'AnchorSideLeft.Control'#7#19'IndentationGroupBox'#21'Ancho'
+'rSideTop.Control'#7#25'IndentOnLineBreakCheckBox'#18'AnchorSideTop.Side'#7#9
+'asrBottom'#4'Left'#2#6#6'Height'#2#22#3'Top'#2'"'#5'Width'#3#180#0#20'Borde'
+'rSpacing.Around'#2#6#7'Caption'#6#21'IndentOnPasteCheckBox'#8'TabOrder'#2#4
+#0#0#0#0
]);

View File

@ -35,7 +35,8 @@ type
TCodetoolsGeneralOptionsFrame = class(TAbstractIDEOptionsEditor)
AdjustTopLineDueToCommentCheckBox: TCheckBox;
IndentEnabledCheckBox: TCheckBox;
IndentOnPasteCheckBox: TCheckBox;
IndentOnLineBreakCheckBox: TCheckBox;
IndentContextSensitiveCheckBox: TCheckBox;
IndentFileButton: TButton;
CursorBeyondEOLCheckBox: TCheckBox;
@ -47,7 +48,7 @@ type
SkipForwardDeclarationsCheckBox: TCheckBox;
SrcPathEdit: TEdit;
SrcPathGroupBox: TGroupBox;
procedure IndentEnabledCheckBoxChange(Sender: TObject);
procedure IndentOnLineBreakCheckBoxChange(Sender: TObject);
procedure IndentFileButtonClick(Sender: TObject);
private
procedure VisualizeIndentEnabled;
@ -83,14 +84,14 @@ procedure TCodetoolsGeneralOptionsFrame.VisualizeIndentEnabled;
var
e: Boolean;
begin
e:=IndentEnabledCheckBox.Checked;
e:=IndentOnLineBreakCheckBox.Checked;
IndentFileLabel.Enabled:=e;
IndentFileEdit.Enabled:=e;
IndentFileButton.Enabled:=e;
IndentContextSensitiveCheckBox.Enabled:=e;
end;
procedure TCodetoolsGeneralOptionsFrame.IndentEnabledCheckBoxChange(
procedure TCodetoolsGeneralOptionsFrame.IndentOnLineBreakCheckBoxChange(
Sender: TObject);
begin
VisualizeIndentEnabled;
@ -121,7 +122,8 @@ begin
SkipForwardDeclarationsCheckBox.Caption:=dlgSkipForwardDeclarations;
IndentationGroupBox.Caption:=lisIndentation;
IndentEnabledCheckBox.Caption:=dlgMouseFoldEnabled;
IndentOnLineBreakCheckBox.Caption:=lisOnBreakLineIEReturnOrEnterKey;
IndentOnPasteCheckBox.Caption:=lisOnPasteFromClipboard;
IndentFileLabel.Caption:=lisExampleFile;
IndentFileButton.Caption:=lisPathEditBrowse;
IndentContextSensitiveCheckBox.Caption:=lisContextSensitive;
@ -140,7 +142,8 @@ begin
JumpCenteredCheckBox.Checked := JumpCentered;
CursorBeyondEOLCheckBox.Checked := CursorBeyondEOL;
SkipForwardDeclarationsCheckBox.Checked := SkipForwardDeclarations;
IndentEnabledCheckBox.Checked:=IndentationEnabled;
IndentOnLineBreakCheckBox.Checked:=IndentOnLineBreak;
IndentOnPasteCheckBox.Checked:=IndentOnPaste;
IndentFileEdit.Text:=IndentationFileName;
IndentContextSensitiveCheckBox.Checked:=IndentContextSensitive;
end;
@ -157,7 +160,8 @@ begin
JumpCentered := JumpCenteredCheckBox.Checked;
CursorBeyondEOL := CursorBeyondEOLCheckBox.Checked;
SkipForwardDeclarations := SkipForwardDeclarationsCheckBox.Checked;
IndentationEnabled:=IndentEnabledCheckBox.Checked;
IndentOnLineBreak:=IndentOnLineBreakCheckBox.Checked;
IndentOnPaste:=IndentOnPasteCheckBox.Checked;
IndentationFileName:=IndentFileEdit.Text;
IndentContextSensitive:=IndentContextSensitiveCheckBox.Checked;
end;

View File

@ -4512,6 +4512,8 @@ resourcestring
+'of current unit, project or package';
lisAddPackageRequirement = 'Add package requirement?';
lisAddPackageToProject = 'Add package %s to project?';
lisOnBreakLineIEReturnOrEnterKey = 'On break line (i.e. return or enter key)';
lisOnPasteFromClipboard = 'On paste from clipboard';
implementation

View File

@ -6797,14 +6797,15 @@ begin
Reason, SetIndentProc);
if Result then exit;
end;
if not CodeToolsOpts.IndentationEnabled then exit;
if (SrcEdit.SyncroEdit<>nil) and SrcEdit.SyncroEdit.Active then exit;
if not (SrcEdit.SyntaxHighlighterType in [lshFreePascal, lshDelphi]) then
exit;
case Reason of
ecLineBreak: ;
ecLineBreak:
if not CodeToolsOpts.IndentOnLineBreak then exit;
ecPaste:
begin
if not CodeToolsOpts.IndentOnPaste then exit;
if SrcEdit.EditorComponent.SelectionMode<>smNormal then exit;
if LogCaret.X>1 then
inc(FirstLinePos);