ide: add codetools->line splitting frame to the ide options

git-svn-id: trunk@17209 -
This commit is contained in:
paul 2008-11-04 08:19:53 +00:00
parent b7075d613f
commit 133174aae8
11 changed files with 862 additions and 28 deletions

3
.gitattributes vendored
View File

@ -2435,6 +2435,9 @@ ide/frames/options_codetools_codecreation.pas svneol=native#text/pascal
ide/frames/options_codetools_general.lfm svneol=native#text/plain
ide/frames/options_codetools_general.lrs svneol=native#text/pascal
ide/frames/options_codetools_general.pas svneol=native#text/pascal
ide/frames/options_codetools_linesplitting.lfm svneol=native#text/plain
ide/frames/options_codetools_linesplitting.lrs svneol=native#text/pascal
ide/frames/options_codetools_linesplitting.pas svneol=native#text/pascal
ide/frames/options_codetools_wordpolicy.lfm svneol=native#text/plain
ide/frames/options_codetools_wordpolicy.lrs svneol=native#text/pascal
ide/frames/options_codetools_wordpolicy.pas svneol=native#text/pascal

View File

@ -71,7 +71,7 @@ type
{ TCodeToolManager }
TCodeToolManager = class
TCodeToolManager = class(TPersistent)
private
FAbortable: boolean;
FAddInheritedCodeToOverrideMethod: boolean;

View File

@ -83,7 +83,7 @@ type
TBeautifyCodeFlags = set of TBeautifyCodeFlag;
TBeautifyCodeOptions = class
TBeautifyCodeOptions = class(TPersistent)
private
CurLineLen: integer;
LastSplitPos: integer; // last position where splitting is allowed

View File

@ -24,7 +24,7 @@ object CodeToolsOptsDlg: TCodeToolsOptsDlg
Width = 560
Align = alClient
BorderSpacing.Bottom = 6
PageIndex = 1
PageIndex = 3
TabOrder = 0
object GeneralPage: TPage
AnchorSideTop.Control = CodeCreationPage
@ -241,8 +241,8 @@ object CodeToolsOptsDlg: TCodeToolsOptsDlg
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Around = 6
Caption = 'PropertyCompletionGroupBox'
ClientHeight = 105
ClientWidth = 536
ClientHeight = 123
ClientWidth = 540
TabOrder = 6
object PropertyReadIdentPrefixLabel: TLabel
AnchorSideTop.Control = PropertyReadIdentPrefixEdit

View File

@ -10,7 +10,7 @@ LazarusResources.Add('TCodeToolsOptsDlg','FORMDATA',[
+#6#6'0.9.27'#0#9'TNotebook'#8'Notebook'#22'AnchorSideLeft.Control'#7#5'Owner'
+#21'AnchorSideTop.Control'#7#5'Owner'#23'AnchorSideRight.Control'#7#5'Owner'
+#20'AnchorSideRight.Side'#7#9'asrBottom'#6'Height'#3#133#1#5'Width'#3'0'#2#5
+'Align'#7#8'alClient'#20'BorderSpacing.Bottom'#2#6#9'PageIndex'#2#1#8'TabOrd'
+'Align'#7#8'alClient'#20'BorderSpacing.Bottom'#2#6#9'PageIndex'#2#3#8'TabOrd'
+'er'#2#0#0#5'TPage'#11'GeneralPage'#21'AnchorSideTop.Control'#7#16'CodeCreat'
+'ionPage'#7'Caption'#6#11'GeneralPage'#11'ClientWidth'#3'('#2#12'ClientHeigh'
+'t'#3'k'#1#0#9'TGroupBox'#15'SrcPathGroupBox'#22'AnchorSideLeft.Control'#7#11
@ -101,7 +101,7 @@ LazarusResources.Add('TCodeToolsOptsDlg','FORMDATA',[
+#20'AnchorSideRight.Side'#7#9'asrBottom'#21'AnchorSideBottom.Side'#7#9'asrBo'
+'ttom'#4'Left'#2#6#6'Height'#2'{'#3'Top'#3#249#0#5'Width'#3#28#2#7'Anchors'
+#11#5'akTop'#6'akLeft'#7'akRight'#0#20'BorderSpacing.Around'#2#6#7'Caption'#6
+#26'PropertyCompletionGroupBox'#12'ClientHeight'#2'i'#11'ClientWidth'#3#24#2
+#26'PropertyCompletionGroupBox'#12'ClientHeight'#2'{'#11'ClientWidth'#3#28#2
+#8'TabOrder'#2#6#0#6'TLabel'#28'PropertyReadIdentPrefixLabel'#21'AnchorSideT'
+'op.Control'#7#27'PropertyReadIdentPrefixEdit'#18'AnchorSideTop.Side'#7#9'as'
+'rCenter'#23'AnchorSideRight.Control'#7#27'PropertyReadIdentPrefixEdit'#4'Le'

View File

@ -94,11 +94,11 @@ type
procedure ClearGlobalDefineTemplates;
procedure Load;
procedure Save;
procedure AssignTo(Boss: TCodeToolManager);
procedure AssignGlobalDefineTemplatesToTree(Tree: TDefineTree);
property Filename: string read FFilename write SetFilename;
procedure SetLazarusDefaultFilename;
procedure Assign(CodeToolsOpts: TCodeToolsOptions);
procedure Assign(Source: TPersistent); override;
procedure AssignTo(Dest: TPersistent); override;
function IsEqual(CodeToolsOpts: TCodeToolsOptions): boolean;
function CreateCopy: TCodeToolsOptions;
procedure ReadGlobalDefinesTemplatesFromTree(Tree: TDefineTree);
@ -614,9 +614,18 @@ begin
FFilename:=ConfFilename;
end;
procedure TCodeToolsOptions.Assign(CodeToolsOpts: TCodeToolsOptions);
procedure TCodeToolsOptions.Assign(Source: TPersistent);
var
CodeToolsOpts: TCodeToolsOptions absolute Source;
begin
if CodeToolsOpts<>nil then begin
if not ((Source = nil) or (Source is TCodeToolsOptions)) then
begin
inherited Assign(Source);
Exit;
end;
if CodeToolsOpts <> nil then
begin
// General
FSrcPath:=CodeToolsOpts.FSrcPath;
FAdjustTopLineDueToComment:=CodeToolsOpts.FAdjustTopLineDueToComment;
@ -658,9 +667,9 @@ begin
// identifier completion
FIdentComplAddSemicolon:=CodeToolsOpts.FIdentComplAddSemicolon;
FIdentComplAddAssignOperator:=CodeToolsOpts.FIdentComplAddAssignOperator;
end else begin
end
else
Clear;
end;
end;
procedure TCodeToolsOptions.Clear;
@ -772,18 +781,28 @@ begin
end;
end;
procedure TCodeToolsOptions.AssignTo(Boss: TCodeToolManager);
procedure TCodeToolsOptions.AssignTo(Dest: TPersistent);
var
Boss: TCodeToolManager absolute Dest;
BeautifyCodeOptions: TBeautifyCodeOptions absolute Dest;
begin
// General - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SetAdditionalGlobalSrcPathToCodeToolBoss(SrcPath);
Boss.AdjustTopLineDueToComment:=AdjustTopLineDueToComment;
Boss.JumpCentered:=JumpCentered;
Boss.CursorBeyondEOL:=CursorBeyondEOL;
Boss.AddInheritedCodeToOverrideMethod:=AddInheritedCodeToOverrideMethod;
Boss.CompleteProperties:=CompleteProperties;
// CreateCode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
with Boss.SourceChangeCache do begin
if Dest is TCodeToolManager then
begin
// General - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SetAdditionalGlobalSrcPathToCodeToolBoss(SrcPath);
Boss.AdjustTopLineDueToComment:=AdjustTopLineDueToComment;
Boss.JumpCentered:=JumpCentered;
Boss.CursorBeyondEOL:=CursorBeyondEOL;
Boss.AddInheritedCodeToOverrideMethod:=AddInheritedCodeToOverrideMethod;
Boss.CompleteProperties:=CompleteProperties;
// CreateCode - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AssignTo(Boss.SourceChangeCache.BeautifyCodeOptions);
Boss.SetPropertyVariablename:=SetPropertyVariablename;
end
else
if Dest is TBeautifyCodeOptions then
begin
BeautifyCodeOptions.LineLength:=LineLength;
BeautifyCodeOptions.ClassPartInsertPolicy:=ClassPartInsertPolicy;
BeautifyCodeOptions.MixMethodsAndProperties:=MixMethodsAndProperties;
@ -801,8 +820,9 @@ begin
BeautifyCodeOptions.PropertyWriteIdentPrefix:=PropertyWriteIdentPrefix;
BeautifyCodeOptions.PropertyStoredIdentPostfix:=PropertyStoredIdentPostfix;
BeautifyCodeOptions.PrivateVariablePrefix:=PrivateVariablePrefix;
end;
Boss.SetPropertyVariablename:=SetPropertyVariablename;
end
else
inherited AssignTo(Dest);
end;
procedure TCodeToolsOptions.AssignGlobalDefineTemplatesToTree(Tree: TDefineTree

View File

@ -0,0 +1,418 @@
inherited CodetoolsLineSplittingOptionsFrame: TCodetoolsLineSplittingOptionsFrame
Height = 344
Width = 558
ClientHeight = 344
ClientWidth = 558
TabOrder = 0
Visible = False
DesignLeft = 110
DesignTop = 145
object LineLengthLabel: TLabel[0]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = LineLengthEdit
AnchorSideTop.Side = asrCenter
Height = 14
Top = 4
Width = 78
BorderSpacing.Right = 6
Caption = 'LineLengthLabel'
ParentColor = False
end
object SplitPreviewLabel: TLabel[1]
AnchorSideLeft.Control = SplitPreviewSynEdit
AnchorSideBottom.Control = SplitPreviewSynEdit
Left = 262
Height = 14
Top = 15
Width = 84
Anchors = [akLeft, akBottom]
Caption = 'SplitPreviewLabel'
ParentColor = False
end
object LineLengthEdit: TEdit[2]
AnchorSideLeft.Control = LineLengthLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
Left = 84
Height = 23
Width = 50
OnChange = UpdateExample
TabOrder = 0
Text = 'LineLengthEdit'
end
object DoNotSplitLineInFrontGroupBox: TGroupBox[3]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = LineLengthEdit
AnchorSideTop.Side = asrBottom
Height = 153
Top = 29
Width = 256
BorderSpacing.Top = 6
Caption = 'DoNotSplitLineInFrontGroupBox'
TabOrder = 1
OnClick = UpdateExample
end
object DoNotSplitLineAfterGroupBox: TGroupBox[4]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = DoNotSplitLineInFrontGroupBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DoNotSplitLineInFrontGroupBox
AnchorSideRight.Side = asrBottom
Height = 153
Top = 188
Width = 256
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Caption = 'DoNotSplitLineAfterGroupBox'
TabOrder = 2
OnClick = UpdateExample
end
object SplitPreviewSynEdit: TSynEdit[5]
AnchorSideLeft.Control = DoNotSplitLineInFrontGroupBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = DoNotSplitLineInFrontGroupBox
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 262
Height = 315
Top = 29
Width = 296
BorderSpacing.Left = 6
Anchors = [akTop, akLeft, akRight, akBottom]
Font.Height = -16
Font.Name = 'courier'
Font.Pitch = fpFixed
Font.Quality = fqNonAntialiased
ParentColor = False
ParentFont = False
TabOrder = 3
BookMarkOptions.Xoffset = -18
Gutter.Visible = False
Keystrokes = <
item
Command = 3
ShortCut = 38
end
item
Command = 103
ShortCut = 8230
end
item
Command = 211
ShortCut = 16422
end
item
Command = 4
ShortCut = 40
end
item
Command = 104
ShortCut = 8232
end
item
Command = 212
ShortCut = 16424
end
item
Command = 1
ShortCut = 37
end
item
Command = 101
ShortCut = 8229
end
item
Command = 5
ShortCut = 16421
end
item
Command = 105
ShortCut = 24613
end
item
Command = 2
ShortCut = 39
end
item
Command = 102
ShortCut = 8231
end
item
Command = 6
ShortCut = 16423
end
item
Command = 106
ShortCut = 24615
end
item
Command = 10
ShortCut = 34
end
item
Command = 110
ShortCut = 8226
end
item
Command = 14
ShortCut = 16418
end
item
Command = 114
ShortCut = 24610
end
item
Command = 9
ShortCut = 33
end
item
Command = 109
ShortCut = 8225
end
item
Command = 13
ShortCut = 16417
end
item
Command = 113
ShortCut = 24609
end
item
Command = 7
ShortCut = 36
end
item
Command = 107
ShortCut = 8228
end
item
Command = 15
ShortCut = 16420
end
item
Command = 115
ShortCut = 24612
end
item
Command = 8
ShortCut = 35
end
item
Command = 108
ShortCut = 8227
end
item
Command = 16
ShortCut = 16419
end
item
Command = 116
ShortCut = 24611
end
item
Command = 223
ShortCut = 45
end
item
Command = 201
ShortCut = 16429
end
item
Command = 604
ShortCut = 8237
end
item
Command = 502
ShortCut = 46
end
item
Command = 603
ShortCut = 8238
end
item
Command = 501
ShortCut = 8
end
item
Command = 501
ShortCut = 8200
end
item
Command = 504
ShortCut = 16392
end
item
Command = 601
ShortCut = 32776
end
item
Command = 602
ShortCut = 40968
end
item
Command = 509
ShortCut = 13
end
item
Command = 199
ShortCut = 16449
end
item
Command = 201
ShortCut = 16451
end
item
Command = 610
ShortCut = 24649
end
item
Command = 509
ShortCut = 16461
end
item
Command = 510
ShortCut = 16462
end
item
Command = 503
ShortCut = 16468
end
item
Command = 611
ShortCut = 24661
end
item
Command = 604
ShortCut = 16470
end
item
Command = 603
ShortCut = 16472
end
item
Command = 507
ShortCut = 16473
end
item
Command = 506
ShortCut = 24665
end
item
Command = 601
ShortCut = 16474
end
item
Command = 602
ShortCut = 24666
end
item
Command = 301
ShortCut = 16432
end
item
Command = 302
ShortCut = 16433
end
item
Command = 303
ShortCut = 16434
end
item
Command = 304
ShortCut = 16435
end
item
Command = 305
ShortCut = 16436
end
item
Command = 306
ShortCut = 16437
end
item
Command = 307
ShortCut = 16438
end
item
Command = 308
ShortCut = 16439
end
item
Command = 309
ShortCut = 16440
end
item
Command = 310
ShortCut = 16441
end
item
Command = 351
ShortCut = 24624
end
item
Command = 352
ShortCut = 24625
end
item
Command = 353
ShortCut = 24626
end
item
Command = 354
ShortCut = 24627
end
item
Command = 355
ShortCut = 24628
end
item
Command = 356
ShortCut = 24629
end
item
Command = 357
ShortCut = 24630
end
item
Command = 358
ShortCut = 24631
end
item
Command = 359
ShortCut = 24632
end
item
Command = 360
ShortCut = 24633
end
item
Command = 231
ShortCut = 24654
end
item
Command = 232
ShortCut = 24643
end
item
Command = 233
ShortCut = 24652
end
item
Command = 612
ShortCut = 9
end
item
Command = 613
ShortCut = 8201
end
item
Command = 250
ShortCut = 24642
end>
Lines.Strings = (
'SplitPreviewSynEdit'
)
end
end

View File

@ -0,0 +1,83 @@
{ This is an automatically generated lazarus resource file }
LazarusResources.Add('TCodetoolsLineSplittingOptionsFrame','FORMDATA',[
'TPF0'#241'#TCodetoolsLineSplittingOptionsFrame"CodetoolsLineSplittingOptions'
+'Frame'#6'Height'#3'X'#1#5'Width'#3'.'#2#12'ClientHeight'#3'X'#1#11'ClientWi'
+'dth'#3'.'#2#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#2'n'#9'DesignTop'#3
+#145#0#0#242#2#0#6'TLabel'#15'LineLengthLabel'#22'AnchorSideLeft.Control'#7#5
+'Owner'#21'AnchorSideTop.Control'#7#14'LineLengthEdit'#18'AnchorSideTop.Side'
+#7#9'asrCenter'#6'Height'#2#14#3'Top'#2#4#5'Width'#2'N'#19'BorderSpacing.Rig'
+'ht'#2#6#7'Caption'#6#15'LineLengthLabel'#11'ParentColor'#8#0#0#242#2#1#6'TL'
+'abel'#17'SplitPreviewLabel'#22'AnchorSideLeft.Control'#7#19'SplitPreviewSyn'
+'Edit'#24'AnchorSideBottom.Control'#7#19'SplitPreviewSynEdit'#4'Left'#3#6#1#6
+'Height'#2#14#3'Top'#2#15#5'Width'#2'T'#7'Anchors'#11#6'akLeft'#8'akBottom'#0
+#7'Caption'#6#17'SplitPreviewLabel'#11'ParentColor'#8#0#0#242#2#2#5'TEdit'#14
+'LineLengthEdit'#22'AnchorSideLeft.Control'#7#15'LineLengthLabel'#19'AnchorS'
+'ideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'#7#5'Owner'#4'Left'#2
+'T'#6'Height'#2#23#5'Width'#2'2'#8'OnChange'#7#13'UpdateExample'#8'TabOrder'
+#2#0#4'Text'#6#14'LineLengthEdit'#0#0#242#2#3#9'TGroupBox'#29'DoNotSplitLine'
+'InFrontGroupBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Con'
+'trol'#7#14'LineLengthEdit'#18'AnchorSideTop.Side'#7#9'asrBottom'#6'Height'#3
+#153#0#3'Top'#2#29#5'Width'#3#0#1#17'BorderSpacing.Top'#2#6#7'Caption'#6#29
+'DoNotSplitLineInFrontGroupBox'#8'TabOrder'#2#1#7'OnClick'#7#13'UpdateExampl'
+'e'#0#0#242#2#4#9'TGroupBox'#27'DoNotSplitLineAfterGroupBox'#22'AnchorSideLe'
+'ft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#29'DoNotSplitLineInFront'
+'GroupBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'
+#7#29'DoNotSplitLineInFrontGroupBox'#20'AnchorSideRight.Side'#7#9'asrBottom'
+#6'Height'#3#153#0#3'Top'#3#188#0#5'Width'#3#0#1#7'Anchors'#11#5'akTop'#6'ak'
+'Left'#7'akRight'#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#27'DoNotSplitLine'
+'AfterGroupBox'#8'TabOrder'#2#2#7'OnClick'#7#13'UpdateExample'#0#0#242#2#5#8
+'TSynEdit'#19'SplitPreviewSynEdit'#22'AnchorSideLeft.Control'#7#29'DoNotSpli'
+'tLineInFrontGroupBox'#19'AnchorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideT'
+'op.Control'#7#29'DoNotSplitLineInFrontGroupBox'#23'AnchorSideRight.Control'
+#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#24'AnchorSideBottom.Cont'
+'rol'#7#5'Owner'#21'AnchorSideBottom.Side'#7#9'asrBottom'#4'Left'#3#6#1#6'He'
+'ight'#3';'#1#3'Top'#2#29#5'Width'#3'('#1#18'BorderSpacing.Left'#2#6#7'Ancho'
+'rs'#11#5'akTop'#6'akLeft'#7'akRight'#8'akBottom'#0#11'Font.Height'#2#240#9
+'Font.Name'#6#7'courier'#10'Font.Pitch'#7#7'fpFixed'#12'Font.Quality'#7#16'f'
+'qNonAntialiased'#11'ParentColor'#8#10'ParentFont'#8#8'TabOrder'#2#3#23'Book'
+'MarkOptions.Xoffset'#2#238#14'Gutter.Visible'#8#10'Keystrokes'#14#1#7'Comma'
+'nd'#2#3#8'ShortCut'#2'&'#0#1#7'Command'#2'g'#8'ShortCut'#3'& '#0#1#7'Comman'
+'d'#3#211#0#8'ShortCut'#3'&@'#0#1#7'Command'#2#4#8'ShortCut'#2'('#0#1#7'Comm'
+'and'#2'h'#8'ShortCut'#3'( '#0#1#7'Command'#3#212#0#8'ShortCut'#3'(@'#0#1#7
+'Command'#2#1#8'ShortCut'#2'%'#0#1#7'Command'#2'e'#8'ShortCut'#3'% '#0#1#7'C'
+'ommand'#2#5#8'ShortCut'#3'%@'#0#1#7'Command'#2'i'#8'ShortCut'#3'%`'#0#1#7'C'
+'ommand'#2#2#8'ShortCut'#2''''#0#1#7'Command'#2'f'#8'ShortCut'#3''' '#0#1#7
+'Command'#2#6#8'ShortCut'#3'''@'#0#1#7'Command'#2'j'#8'ShortCut'#3'''`'#0#1#7
+'Command'#2#10#8'ShortCut'#2'"'#0#1#7'Command'#2'n'#8'ShortCut'#3'" '#0#1#7
+'Command'#2#14#8'ShortCut'#3'"@'#0#1#7'Command'#2'r'#8'ShortCut'#3'"`'#0#1#7
+'Command'#2#9#8'ShortCut'#2'!'#0#1#7'Command'#2'm'#8'ShortCut'#3'! '#0#1#7'C'
+'ommand'#2#13#8'ShortCut'#3'!@'#0#1#7'Command'#2'q'#8'ShortCut'#3'!`'#0#1#7
+'Command'#2#7#8'ShortCut'#2'$'#0#1#7'Command'#2'k'#8'ShortCut'#3'$ '#0#1#7'C'
+'ommand'#2#15#8'ShortCut'#3'$@'#0#1#7'Command'#2's'#8'ShortCut'#3'$`'#0#1#7
+'Command'#2#8#8'ShortCut'#2'#'#0#1#7'Command'#2'l'#8'ShortCut'#3'# '#0#1#7'C'
+'ommand'#2#16#8'ShortCut'#3'#@'#0#1#7'Command'#2't'#8'ShortCut'#3'#`'#0#1#7
+'Command'#3#223#0#8'ShortCut'#2'-'#0#1#7'Command'#3#201#0#8'ShortCut'#3'-@'#0
+#1#7'Command'#3'\'#2#8'ShortCut'#3'- '#0#1#7'Command'#3#246#1#8'ShortCut'#2
+'.'#0#1#7'Command'#3'['#2#8'ShortCut'#3'. '#0#1#7'Command'#3#245#1#8'ShortCu'
+'t'#2#8#0#1#7'Command'#3#245#1#8'ShortCut'#3#8' '#0#1#7'Command'#3#248#1#8'S'
+'hortCut'#3#8'@'#0#1#7'Command'#3'Y'#2#8'ShortCut'#4#8#128#0#0#0#1#7'Command'
+#3'Z'#2#8'ShortCut'#4#8#160#0#0#0#1#7'Command'#3#253#1#8'ShortCut'#2#13#0#1#7
+'Command'#3#199#0#8'ShortCut'#3'A@'#0#1#7'Command'#3#201#0#8'ShortCut'#3'C@'
+#0#1#7'Command'#3'b'#2#8'ShortCut'#3'I`'#0#1#7'Command'#3#253#1#8'ShortCut'#3
+'M@'#0#1#7'Command'#3#254#1#8'ShortCut'#3'N@'#0#1#7'Command'#3#247#1#8'Short'
+'Cut'#3'T@'#0#1#7'Command'#3'c'#2#8'ShortCut'#3'U`'#0#1#7'Command'#3'\'#2#8
+'ShortCut'#3'V@'#0#1#7'Command'#3'['#2#8'ShortCut'#3'X@'#0#1#7'Command'#3#251
+#1#8'ShortCut'#3'Y@'#0#1#7'Command'#3#250#1#8'ShortCut'#3'Y`'#0#1#7'Command'
+#3'Y'#2#8'ShortCut'#3'Z@'#0#1#7'Command'#3'Z'#2#8'ShortCut'#3'Z`'#0#1#7'Comm'
,'and'#3'-'#1#8'ShortCut'#3'0@'#0#1#7'Command'#3'.'#1#8'ShortCut'#3'1@'#0#1#7
+'Command'#3'/'#1#8'ShortCut'#3'2@'#0#1#7'Command'#3'0'#1#8'ShortCut'#3'3@'#0
+#1#7'Command'#3'1'#1#8'ShortCut'#3'4@'#0#1#7'Command'#3'2'#1#8'ShortCut'#3'5'
+'@'#0#1#7'Command'#3'3'#1#8'ShortCut'#3'6@'#0#1#7'Command'#3'4'#1#8'ShortCut'
+#3'7@'#0#1#7'Command'#3'5'#1#8'ShortCut'#3'8@'#0#1#7'Command'#3'6'#1#8'Short'
+'Cut'#3'9@'#0#1#7'Command'#3'_'#1#8'ShortCut'#3'0`'#0#1#7'Command'#3'`'#1#8
+'ShortCut'#3'1`'#0#1#7'Command'#3'a'#1#8'ShortCut'#3'2`'#0#1#7'Command'#3'b'
+#1#8'ShortCut'#3'3`'#0#1#7'Command'#3'c'#1#8'ShortCut'#3'4`'#0#1#7'Command'#3
+'d'#1#8'ShortCut'#3'5`'#0#1#7'Command'#3'e'#1#8'ShortCut'#3'6`'#0#1#7'Comman'
+'d'#3'f'#1#8'ShortCut'#3'7`'#0#1#7'Command'#3'g'#1#8'ShortCut'#3'8`'#0#1#7'C'
+'ommand'#3'h'#1#8'ShortCut'#3'9`'#0#1#7'Command'#3#231#0#8'ShortCut'#3'N`'#0
+#1#7'Command'#3#232#0#8'ShortCut'#3'C`'#0#1#7'Command'#3#233#0#8'ShortCut'#3
+'L`'#0#1#7'Command'#3'd'#2#8'ShortCut'#2#9#0#1#7'Command'#3'e'#2#8'ShortCut'
+#3#9' '#0#1#7'Command'#3#250#0#8'ShortCut'#3'B`'#0#0#13'Lines.Strings'#1#6#19
+'SplitPreviewSynEdit'#0#0#0#0
]);

View File

@ -0,0 +1,301 @@
{
***************************************************************************
* *
* This source is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This code is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* General Public License for more details. *
* *
* A copy of the GNU General Public License is available on the World *
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
* obtain it by writing to the Free Software Foundation, *
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
***************************************************************************
}
unit options_codetools_linesplitting;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, LResources, Forms, StdCtrls, SynEdit,
SourceChanger, CodeToolsOptions, LazarusIDEStrConsts, IDEOptionsIntf,
EditorOptions;
type
{ TCodetoolsLineSplittingOptionsFrame }
TCodetoolsLineSplittingOptionsFrame = class(TAbstractIDEOptionsEditor)
DoNotSplitLineAfterGroupBox: TGroupBox;
DoNotSplitLineInFrontGroupBox: TGroupBox;
LineLengthEdit: TEdit;
LineLengthLabel: TLabel;
SplitPreviewLabel: TLabel;
SplitPreviewSynEdit: TSynEdit;
procedure UpdateExample(Sender: TObject);
private
BeautifyCodeOptions: TBeautifyCodeOptions;
FHighlighter: TPreviewPasSyn;
procedure CreateAtomCheckBoxes(ParentGroupBox: TGroupBox;
AtomTypes: TAtomTypes; Columns: integer);
procedure SetAtomCheckBoxes(AtomTypes: TAtomTypes; ParentGroupBox: TGroupBox);
function ReadAtomCheckBoxes(ParentGroupBox: TGroupBox): TAtomTypes;
procedure UpdateSplitLineExample;
procedure UpdatePreviewSettings;
procedure WriteBeautifyCodeOptions(Options: TBeautifyCodeOptions);
function GetHighlighter(Options: TEditorOptions): TPreviewPasSyn;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetTitle: String; override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
end;
implementation
{ TCodetoolsLineSplittingOptionsFrame }
procedure TCodetoolsLineSplittingOptionsFrame.UpdateExample(Sender: TObject);
begin
UpdateSplitLineExample;
UpdatePreviewSettings;
end;
procedure TCodetoolsLineSplittingOptionsFrame.CreateAtomCheckBoxes(
ParentGroupBox: TGroupBox; AtomTypes: TAtomTypes; Columns: integer);
var
Count, i, yi, MaxYCount: integer;
a: TAtomType;
X, Y, CurX, CurY, XStep, YStep: integer;
NewCheckBox: TCheckBox;
begin
if Columns < 1 then
Columns := 1;
Count := 0;
for a := Low(TAtomTypes) to High(TAtomTypes) do
if a in AtomTypes then
inc(Count);
if Count = 0 then
Exit;
MaxYCount := ((Count+Columns-1) div Columns);
X:=6;
Y:=1;
XStep:=((ParentGroupBox.ClientWidth-10) div Columns);
YStep:=((ParentGroupBox.ClientHeight-20) div MaxYCount);
CurX:=X;
CurY:=Y;
i:=0;
yi:=0;
for a := Low(TAtomTypes) to High(TAtomTypes) do
begin
if a in AtomTypes then
begin
inc(i);
inc(yi);
NewCheckBox:=TCheckBox.Create(ParentGroupBox);
with NewCheckBox do
begin
Name:=ParentGroupBox.Name+'CheckBox'+IntToStr(i+1);
Parent:=ParentGroupBox;
SetBounds(CurX,CurY,XStep-10,Height);
Caption:=GetTranslatedAtomTypes(a);
OnClick:=@UpdateExample;
Visible:=true;
end;
if yi>=MaxYCount then
begin
inc(X,XStep);
CurX:=X;
CurY:=Y;
yi:=0;
end
else
inc(CurY,YStep);
end;
end;
end;
procedure TCodetoolsLineSplittingOptionsFrame.SetAtomCheckBoxes(
AtomTypes: TAtomTypes; ParentGroupBox: TGroupBox);
var
i: integer;
ACheckBox: TCheckBox;
a: TAtomType;
begin
for i := 0 to ParentGroupBox.ComponentCount - 1 do
begin
if (ParentGroupBox.Components[i] is TCheckBox) then
begin
ACheckBox:=TCheckBox(ParentGroupBox.Components[i]);
a := TranslatedAtomToType(ACheckBox.Caption);
ACheckBox.Checked := (a <> atNone) and (a in AtomTypes);
end;
end;
end;
function TCodetoolsLineSplittingOptionsFrame.ReadAtomCheckBoxes(
ParentGroupBox: TGroupBox): TAtomTypes;
var
i: integer;
ACheckBox: TCheckBox;
a: TAtomType;
begin
Result := [];
for i := 0 to ParentGroupBox.ComponentCount - 1 do
begin
if (ParentGroupBox.Components[i] is TCheckBox) then
begin
ACheckBox := TCheckBox(ParentGroupBox.Components[i]);
a := TranslatedAtomToType(ACheckBox.Caption);
if (a <> atNone) and (ACheckBox.Checked) then
Include(Result, a);
end;
end;
end;
procedure TCodetoolsLineSplittingOptionsFrame.UpdateSplitLineExample;
const
LineSplitExampleText =
'function(Sender: TObject; const Val1, Val2, Val3:char; '
+'var Var1, Var2: array of const): integer;'#13
+'const i=1+2+3;';
begin
if BeautifyCodeOptions = nil then
Exit;
WriteBeautifyCodeOptions(BeautifyCodeOptions);
BeautifyCodeOptions.LineLength := 1;
SplitPreviewSynEdit.Text :=
BeautifyCodeOptions.BeautifyStatement(LineSplitExampleText, 0);
end;
procedure TCodetoolsLineSplittingOptionsFrame.UpdatePreviewSettings;
var
Options: TEditorOptions;
begin
Options := TEditorOptions.Create;
try
if Assigned(OnSaveIDEOptions) then
OnSaveIDEOptions(Self, Options);
SplitPreviewSynEdit.Highlighter := GetHighlighter(Options);
Options.GetSynEditPreviewSettings(SplitPreviewSynEdit);
SplitPreviewSynEdit.Gutter.Visible := False;
SplitPreviewSynEdit.Options := SplitPreviewSynEdit.Options + [eoNoCaret, eoNoSelection];
SplitPreviewSynEdit.ReadOnly := True;
finally
Options.Free;
end;
end;
procedure TCodetoolsLineSplittingOptionsFrame.WriteBeautifyCodeOptions(Options: TBeautifyCodeOptions);
var
ACodeToolsOptions: TCodeToolsOptions;
begin
ACodeToolsOptions := TCodeToolsOptions.Create;
try
if Assigned(OnSaveIDEOptions) then
OnSaveIDEOptions(Self, ACodeToolsOptions);
Options.Assign(ACodeToolsOptions);
finally
ACodeToolsOptions.Free;
end;
end;
function TCodetoolsLineSplittingOptionsFrame.GetHighlighter(
Options: TEditorOptions): TPreviewPasSyn;
begin
if FHighlighter = nil then
begin
FHighlighter := TPreviewPasSyn.Create(Self);
Options.AddSpecialHilightAttribsToHighlighter(FHighlighter);
Options.ReadHighlighterSettings(FHighlighter, '');
end;
Result := FHighlighter;
end;
constructor TCodetoolsLineSplittingOptionsFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
BeautifyCodeOptions := TBeautifyCodeOptions.Create;
UpdateExample(nil);
end;
destructor TCodetoolsLineSplittingOptionsFrame.Destroy;
begin
BeautifyCodeOptions.Free;
inherited Destroy;
end;
function TCodetoolsLineSplittingOptionsFrame.GetTitle: String;
begin
Result := dlgLineSplitting;
end;
procedure TCodetoolsLineSplittingOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
const
DoNotSplitAtoms = [atKeyword, atIdentifier, atColon, atSemicolon, atComma,
atPoint, atAt, atNumber, atStringConstant, atSpace, atSymbol];
begin
with LineLengthLabel do
Caption:=dlgMaxLineLength;
with DoNotSplitLineInFrontGroupBox do begin
Caption:=dlgNotSplitLineFront ;
CreateAtomCheckBoxes(DoNotSplitLineInFrontGroupBox,DoNotSplitAtoms,2);
end;
with DoNotSplitLineAfterGroupBox do begin
Caption:=dlgNotSplitLineAfter ;
CreateAtomCheckBoxes(DoNotSplitLineAfterGroupBox,DoNotSplitAtoms,2);
end;
with SplitPreviewLabel do
Caption:=dlgCDTPreview;
end;
procedure TCodetoolsLineSplittingOptionsFrame.ReadSettings(
AOptions: TAbstractIDEOptions);
begin
with AOptions as TCodetoolsOptions do
begin
LineLengthEdit.Text := IntToStr(LineLength);
SetAtomCheckBoxes(DoNotSplitLineInFront, DoNotSplitLineInFrontGroupBox);
SetAtomCheckBoxes(DoNotSplitLineAfter, DoNotSplitLineAfterGroupBox);
end;
end;
procedure TCodetoolsLineSplittingOptionsFrame.WriteSettings(
AOptions: TAbstractIDEOptions);
begin
with AOptions as TCodetoolsOptions do
begin
LineLength := StrToIntDef(LineLengthEdit.Text, 80);
if LineLength < 5 then
LineLength:=5;
DoNotSplitLineInFront := ReadAtomCheckBoxes(DoNotSplitLineInFrontGroupBox);
DoNotSplitLineAfter := ReadAtomCheckBoxes(DoNotSplitLineAfterGroupBox);
end;
end;
class function TCodetoolsLineSplittingOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass;
begin
Result := TCodetoolsOptions;
end;
initialization
{$I options_codetools_linesplitting.lrs}
RegisterIDEOptionsEditor(GroupCodetools, TCodetoolsLineSplittingOptionsFrame, CdtOptionsLineSplitting);
end.

View File

@ -41,7 +41,7 @@
<PackageName Value="SynEdit"/>
</Item4>
</RequiredPackages>
<Units Count="20">
<Units Count="21">
<Unit0>
<Filename Value="lazarus.pp"/>
<IsPartOfProject Value="True"/>
@ -199,6 +199,14 @@
<ResourceFilename Value="frames\options_codetools_wordpolicy.lrs"/>
<UnitName Value="options_codetools_wordpolicy"/>
</Unit19>
<Unit20>
<Filename Value="frames\options_codetools_linesplitting.pas"/>
<ComponentName Value="CodetoolsLineSplittingOptionsFrame"/>
<IsPartOfProject Value="True"/>
<ResourceBaseClass Value="Frame"/>
<ResourceFilename Value="frames\options_codetools_linesplitting.lrs"/>
<UnitName Value="options_codetools_linesplitting"/>
</Unit20>
</Units>
</ProjectOptions>
<CompilerOptions>

View File

@ -131,7 +131,8 @@ uses
options_backup, options_naming, options_fpdoc,
options_editor_general, options_editor_display, options_editor_keymapping,
options_editor_color, options_editor_codetools, options_editor_codefolding,
options_codetools_general, options_codetools_codecreation, options_codetools_wordpolicy;
options_codetools_general, options_codetools_codecreation,
options_codetools_wordpolicy, options_codetools_linesplitting;
type
TIDEProjectItem =