diff --git a/components/codetools/basiccodetools.pas b/components/codetools/basiccodetools.pas index 52702501c5..fa3078d740 100644 --- a/components/codetools/basiccodetools.pas +++ b/components/codetools/basiccodetools.pas @@ -120,7 +120,7 @@ function ReadRawNextPascalAtom(const Source:string; //---------------------------------------------------------------------------- // comments function FindNextNonSpace(const ASource: string; StartPos: integer - ): integer; + ): integer; function FindCommentEnd(const ASource: string; StartPos: integer; NestedComments: boolean): integer; function FindNextCompilerDirective(const ASource: string; StartPos: integer; diff --git a/components/codetools/keywordfunclists.pas b/components/codetools/keywordfunclists.pas index 6f92b0ced7..5c9e2bbfa2 100644 --- a/components/codetools/keywordfunclists.pas +++ b/components/codetools/keywordfunclists.pas @@ -577,6 +577,7 @@ begin with IsKeyWordProcedureBracketSpecifier do begin Add('ALIAS' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('PUBLIC' ,{$ifdef FPC}@{$endif}AllwaysTrue); + Add('EXTERNAL' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('INTERNPROC' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('INTERNCONST' ,{$ifdef FPC}@{$endif}AllwaysTrue); Add('SAVEREGISTERS',{$ifdef FPC}@{$endif}AllwaysTrue); diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index 29fe3cdf4f..e1a983735a 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -52,8 +52,11 @@ type protected procedure RemoveCorrespondingProcNodes(Tree1, Tree2: TAVLTree; KeepTree1: boolean); + procedure IntersectProcNodes(Tree1, Tree2: TAVLTree; AddLink: boolean); function FindProcNodeInTreeWithName(ATree: TAVLTree; const UpperProcName: string): TCodeTreeNode; + function FindAVLNodeWithNode(AVLTree: TAVLTree; + Node: TCodeTreeNode): TAVLTreeNode; public function FindJumpPoint(CursorPos: TCodeXYPosition; var NewPos: TCodeXYPosition; var NewTopLine: integer; @@ -118,6 +121,45 @@ begin end; end; +procedure TMethodJumpingCodeTool.IntersectProcNodes(Tree1, Tree2: TAVLTree; + AddLink: boolean); +var + AVLNode1, NextAVLNode1, AVLNode2: TAVLTreeNode; + NodeExt1, NodeExt2: TCodeTreeNodeExtension; + cmp: integer; +begin + AVLNode1:=Tree1.FindLowest; + AVLNode2:=Tree2.FindLowest; + while AVLNode1<>nil do begin + NextAVLNode1:=Tree1.FindSuccessor(AVLNode1); + NodeExt1:=TCodeTreeNodeExtension(AVLNode1.Data); + if AVLNode2<>nil then begin + NodeExt2:=TCodeTreeNodeExtension(AVLNode2.Data); + cmp:=CompareTextIgnoringSpace(NodeExt1.Txt,NodeExt2.Txt,false); + if cmp<0 then begin + // node of tree1 does not exists in tree2 + // -> delete + Tree1.FreeAndDelete(AVLNode1); + end else if cmp=0 then begin + // node of tree1 exists in tree2 + if AddLink then + NodeExt1.Data:=AVLNode2; + AVLNode2:=Tree2.FindSuccessor(AVLNode2); + end else begin + // node of tree2 does not exists in tree1 + // -> skip node of tree2 + AVLNode2:=Tree2.FindSuccessor(AVLNode2); + continue; + end; + end else begin + // node of tree1 does not exists in tree2 + // -> delete + Tree1.FreeAndDelete(AVLNode1); + end; + AVLNode1:=NextAVLNode1; + end; +end; + function TMethodJumpingCodeTool.FindProcNodeInTreeWithName(ATree: TAVLTree; const UpperProcName: string): TCodeTreeNode; var AnAVLNode: TAVLTreeNode; @@ -136,6 +178,18 @@ begin Result:=nil; end; +function TMethodJumpingCodeTool.FindAVLNodeWithNode(AVLTree: TAVLTree; + Node: TCodeTreeNode): TAVLTreeNode; +begin + if (AVLTree=nil) or (Node=nil) then begin + Result:=nil; + exit; + end; + Result:=AVLTree.FindLowest; + while (Result<>nil) and (TCodeTreeNodeExtension(Result.Data).Node<>Node) do + Result:=AVLTree.FindSuccessor(Result); +end; + function TMethodJumpingCodeTool.FindJumpPoint(CursorPos: TCodeXYPosition; var NewPos: TCodeXYPosition; var NewTopLine: integer; var RevertableJump: boolean): boolean; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index 9cfc9bf5ab..05fe089bb5 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -239,6 +239,7 @@ type function NodeHasParentOfType(ANode: TCodeTreeNode; NodeDesc: TCodeTreeNodeDesc): boolean; function NodeIsInAMethod(Node: TCodeTreeNode): boolean; + function NodeIsMethodBody(ProcNode: TCodeTreeNode): boolean; function NodeIsFunction(ProcNode: TCodeTreeNode): boolean; function NodeIsPartOfTypeDefinition(ANode: TCodeTreeNode): boolean; function PropertyIsDefault(PropertyNode: TCodeTreeNode): boolean; @@ -1307,7 +1308,7 @@ begin CurPos.StartPos,CurPos.EndPos-CurPos.StartPos) then RaiseKeyWordExampleExpected; - if UpAtomIs('INTERNPROC') then + if UpAtomIs('INTERNPROC') or UpAtomIs('EXTERNAL') then HasForwardModifier:=true; ReadNextAtom; if CurPos.Flag in [cafColon,cafEdgedBracketClose] then @@ -3567,18 +3568,29 @@ begin Result:=false; while (Node<>nil) do begin if (Node.Desc=ctnProcedure) then begin + if NodeIsMethodBody(Node) then begin + Result:=true; + exit; + end; + end; + Node:=Node.Parent; + end; +end; - // ToDo: ppu, ppw, dcu +function TPascalParserTool.NodeIsMethodBody(ProcNode: TCodeTreeNode): boolean; +begin + Result:=false; + if (ProcNode<>nil) and (ProcNode.Desc=ctnProcedure) then begin - MoveCursorToNodeStart(Node.FirstChild); // ctnProcedureHead - ReadNextAtom; - if not AtomIsIdentifier(false) then continue; - ReadNextAtom; - if (CurPos.Flag<>cafPoint) then continue; - Result:=true; - exit; - end else - Node:=Node.Parent; + // ToDo: ppu, ppw, dcu + + MoveCursorToNodeStart(ProcNode.FirstChild); // ctnProcedureHead + ReadNextAtom; + if not AtomIsIdentifier(false) then exit; + ReadNextAtom; + if (CurPos.Flag<>cafPoint) then exit; + Result:=true; + exit; end; end; diff --git a/components/codetools/sourcechanger.pas b/components/codetools/sourcechanger.pas index c62371b484..333c8dc5c8 100644 --- a/components/codetools/sourcechanger.pas +++ b/components/codetools/sourcechanger.pas @@ -207,9 +207,11 @@ const ClassPartInsertPolicyNames: array[TClassPartInsertPolicy] of shortstring = ( 'Alphabetically', 'Last' ); + MethodInsertPolicyNames: array[TMethodInsertPolicy] of shortstring = ( 'Alphabetically', 'Last', 'ClassOrder' ); + ForwardProcInsertPolicyNames: array[TForwardProcInsertPolicy] of shortstring = ('Last', 'InFrontOfMethods', 'BehindMethods'); diff --git a/ide/codetoolsoptions.pas b/ide/codetoolsoptions.pas index 68dfd92dc3..ecb7ca10ed 100644 --- a/ide/codetoolsoptions.pas +++ b/ide/codetoolsoptions.pas @@ -55,6 +55,9 @@ type FCompleteProperties: boolean; FLineLength: integer; FClassPartInsertPolicy: TClassPartInsertPolicy; + FMixMethodsAndPorperties: boolean; + FForwardProcInsertPolicy: TForwardProcInsertPolicy; + FKeepForwardProcOrder: boolean; FMethodInsertPolicy: TMethodInsertPolicy; FKeyWordPolicy : TWordPolicy; FIdentifierPolicy: TWordPolicy; @@ -98,6 +101,12 @@ type property LineLength: integer read FLineLength write FLineLength; property ClassPartInsertPolicy: TClassPartInsertPolicy read FClassPartInsertPolicy write FClassPartInsertPolicy; + property MixMethodsAndPorperties: boolean + read FMixMethodsAndPorperties write FMixMethodsAndPorperties; + property ForwardProcInsertPolicy: TForwardProcInsertPolicy + read FForwardProcInsertPolicy write FForwardProcInsertPolicy; + property KeepForwardProcOrder: boolean + read FKeepForwardProcOrder write FKeepForwardProcOrder; property MethodInsertPolicy: TMethodInsertPolicy read FMethodInsertPolicy write FMethodInsertPolicy; property KeyWordPolicy : TWordPolicy @@ -137,9 +146,10 @@ type // Code Creation ClassPartInsertPolicyRadioGroup: TRadioGroup; + MixMethodsAndPorpertiesCheckBox: TCheckBox; MethodInsertPolicyRadioGroup: TRadioGroup; - KeyWordPolicyRadioGroup: TRadioGroup; - IdentifierPolicyRadioGroup: TRadioGroup; + ForwardProcsInsertPolicyRadioGroup: TRadioGroup; + ForwardProcsKeepOrderCheckBox: TCheckBox; PropertyCompletionGroupBox: TGroupBox; PropertyCompletionCheckBox: TCheckBox; PropertyReadIdentPrefixLabel: TLabel; @@ -153,6 +163,10 @@ type SetPropertyVariablenameLabel: TLabel; SetPropertyVariablenameEdit: TEdit; + // words + KeyWordPolicyRadioGroup: TRadioGroup; + IdentifierPolicyRadioGroup: TRadioGroup; + // Line Splitting LineLengthLabel: TLabel; LineLengthEdit: TEdit; @@ -178,12 +192,14 @@ type private FOnGetSynEditSettings: TNotifyEvent; BeautifyCodeOptions: TBeautifyCodeOptions; - procedure SetupGeneralPage; - procedure SetupCodeCreationPage; - procedure SetupLineSplittingPage; - procedure SetupSpacePage; + procedure SetupGeneralPage(PageID: integer); + procedure SetupCodeCreationPage(PageID: integer); + procedure SetupWordsPage(PageID: integer); + procedure SetupLineSplittingPage(PageID: integer); + procedure SetupSpacePage(PageID: integer); procedure ResizeGeneralPage; procedure ResizeCodeCreationPage; + procedure ResizeWordsPage; procedure ResizeLineSplittingPage; procedure ResizeSpacePage; procedure CreateAtomCheckBoxes(ParentGroupBox: TGroupBox; @@ -336,6 +352,14 @@ begin FClassPartInsertPolicy:=ClassPartPolicyNameToPolicy(XMLConfig.GetValue( 'CodeToolsOptions/ClassPartInsertPolicy/Value', ClassPartInsertPolicyNames[cpipAlphabetically])); + FMixMethodsAndPorperties:=XMLConfig.GetValue( + 'CodeToolsOptions/MixMethodsAndPorperties/Value',false); + FForwardProcInsertPolicy:=ForwardProcInsertPolicyNameToPolicy( + XMLConfig.GetValue('CodeToolsOptions/ForwardProcInsertPolicy/Value', + ForwardProcInsertPolicyNames[fpipInFrontOfMethods])); + FKeepForwardProcOrder:=XMLConfig.GetValue( + 'CodeToolsOptions/KeepForwardProcOrder/Value',true); + FMethodInsertPolicy:=MethodInsertPolicyNameToPolicy(XMLConfig.GetValue( 'CodeToolsOptions/MethodInsertPolicy/Value', MethodInsertPolicyNames[mipClassOrder])); @@ -399,6 +423,12 @@ begin 'CodeToolsOptions/LineLengthXMLConfig/Value',FLineLength); XMLConfig.SetValue('CodeToolsOptions/ClassPartInsertPolicy/Value', ClassPartInsertPolicyNames[FClassPartInsertPolicy]); + XMLConfig.SetValue( + 'CodeToolsOptions/MixMethodsAndPorperties/Value',FMixMethodsAndPorperties); + XMLConfig.SetValue('CodeToolsOptions/ForwardProcInsertPolicy/Value', + ForwardProcInsertPolicyNames[FForwardProcInsertPolicy]); + XMLConfig.SetValue( + 'CodeToolsOptions/KeepForwardProcOrder/Value',FKeepForwardProcOrder); XMLConfig.SetValue('CodeToolsOptions/MethodInsertPolicy/Value', MethodInsertPolicyNames[FMethodInsertPolicy]); XMLConfig.SetValue('CodeToolsOptions/KeyWordPolicy/Value', @@ -464,6 +494,9 @@ begin // CodeCreation FLineLength:=CodeToolsOpts.FLineLength; FClassPartInsertPolicy:=CodeToolsOpts.FClassPartInsertPolicy; + FMixMethodsAndPorperties:=CodeToolsOpts.MixMethodsAndPorperties; + FForwardProcInsertPolicy:=CodeToolsOpts.ForwardProcInsertPolicy; + FKeepForwardProcOrder:=CodeToolsOpts.KeepForwardProcOrder; FMethodInsertPolicy:=CodeToolsOpts.FMethodInsertPolicy; FKeyWordPolicy:=CodeToolsOpts.FKeyWordPolicy; FIdentifierPolicy:=CodeToolsOpts.FIdentifierPolicy; @@ -495,6 +528,9 @@ begin FCompleteProperties:=true; FLineLength:=80; FClassPartInsertPolicy:=cpipLast; + FMixMethodsAndPorperties:=false; + FForwardProcInsertPolicy:=fpipInFrontOfMethods; + FKeepForwardProcOrder:=true; FMethodInsertPolicy:=mipClassOrder; FKeyWordPolicy:=wpLowerCase; FIdentifierPolicy:=wpNone; @@ -523,6 +559,9 @@ begin // CodeCreation and (FLineLength=CodeToolsOpts.FLineLength) and (FClassPartInsertPolicy=CodeToolsOpts.FClassPartInsertPolicy) + and (FMixMethodsAndPorperties=CodeToolsOpts.MixMethodsAndPorperties) + and (FForwardProcInsertPolicy=CodeToolsOpts.ForwardProcInsertPolicy) + and (FKeepForwardProcOrder=CodeToolsOpts.KeepForwardProcOrder) and (FMethodInsertPolicy=CodeToolsOpts.FMethodInsertPolicy) and (FKeyWordPolicy=CodeToolsOpts.FKeyWordPolicy) and (FIdentifierPolicy=CodeToolsOpts.FIdentifierPolicy) @@ -559,6 +598,9 @@ begin with Boss.SourceChangeCache do begin BeautifyCodeOptions.LineLength:=LineLength; BeautifyCodeOptions.ClassPartInsertPolicy:=ClassPartInsertPolicy; + BeautifyCodeOptions.MixMethodsAndPorperties:=MixMethodsAndPorperties; + BeautifyCodeOptions.ForwardProcInsertPolicy:=ForwardProcInsertPolicy; + BeautifyCodeOptions.KeepForwardProcOrder:=KeepForwardProcOrder; BeautifyCodeOptions.MethodInsertPolicy:=MethodInsertPolicy; BeautifyCodeOptions.KeyWordPolicy:=KeyWordPolicy; BeautifyCodeOptions.IdentifierPolicy:=IdentifierPolicy; @@ -594,17 +636,19 @@ begin if PageCount>0 then Pages[0]:=lisMenuInsertGeneral else - Pages.Add(lisMenuInsertGeneral);;//by VVI - using first phrase, otherwise we''ll encounter a problem with .po + Pages.Add(lisMenuInsertGeneral);//by VVI - using first phrase, otherwise we''ll encounter a problem with .po Pages.Add(dlgCodeCreation); - Pages.Add(dlgLineSplitting ); + Pages.Add(dlgWordsPolicies); + Pages.Add(dlgLineSplitting); Pages.Add(dlgSpaceNotCosmos); end; - SetupGeneralPage; - SetupCodeCreationPage; - SetupLineSplittingPage; - SetupSpacePage; + SetupGeneralPage(0); + SetupCodeCreationPage(1); + SetupWordsPage(2); + SetupLineSplittingPage(3); + SetupSpacePage(4); NoteBook.Show; @@ -645,12 +689,12 @@ begin inherited Destroy; end; -procedure TCodeToolsOptsDlg.SetupGeneralPage; +procedure TCodeToolsOptsDlg.SetupGeneralPage(PageID: integer); begin SrcPathGroupBox:=TGroupBox.Create(Self); with SrcPathGroupBox do begin Name:='SrcPathGroupBox'; - Parent:=NoteBook.Page[0]; + Parent:=NoteBook.Page[PageID]; SetBounds(8,7,Self.ClientWidth-20,51); Caption:=dlgAdditionalSrcPath ; Visible:=true; @@ -667,7 +711,7 @@ begin JumpingGroupBox:=TGroupBox.Create(Self); with JumpingGroupBox do begin Name:='JumpingGroupBox'; - Parent:=NoteBook.Page[0]; + Parent:=NoteBook.Page[PageID]; SetBounds(8,SrcPathGroupBox.Top+SrcPathGroupBox.Height+7, SrcPathGroupBox.Width,95); Caption:=dlgJumpingETC; @@ -707,15 +751,14 @@ begin end; end; -procedure TCodeToolsOptsDlg.SetupCodeCreationPage; +procedure TCodeToolsOptsDlg.SetupCodeCreationPage(PageID: integer); begin ClassPartInsertPolicyRadioGroup:=TRadioGroup.Create(Self); with ClassPartInsertPolicyRadioGroup do begin Name:='ClassPartInsertPolicyRadioGroup'; - Parent:=NoteBook.Page[1]; - SetBounds(8,6, - (Self.ClientWidth div 2)-12,80); - Caption:=dlgClassInsertPolicy ; + Parent:=NoteBook.Page[PageID]; + SetBounds(8,6,(Self.ClientWidth div 2)-12,70); + Caption:=dlgClassInsertPolicy; with Items do begin BeginUpdate; Add(dlgAlphabetically); @@ -724,17 +767,28 @@ begin end; Visible:=true; end; + + MixMethodsAndPorpertiesCheckBox:=TCheckBox.Create(Self); + with MixMethodsAndPorpertiesCheckBox do begin + Name:='MixMethodsAndPorpertiesCheckBox'; + Parent:=NoteBook.Page[PageID]; + SetBounds(ClassPartInsertPolicyRadioGroup.Left, + ClassPartInsertPolicyRadioGroup.Top+ClassPartInsertPolicyRadioGroup.Height+5, + ClassPartInsertPolicyRadioGroup.Width,Height); + Caption:=dlgMixMethodsAndProperties; + Visible:=true; + end; MethodInsertPolicyRadioGroup:=TRadioGroup.Create(Self); with MethodInsertPolicyRadioGroup do begin Name:='MethodInsertPolicyRadioGroup'; - Parent:=NoteBook.Page[1]; - SetBounds(ClassPartInsertPolicyRadioGroup.Left - +ClassPartInsertPolicyRadioGroup.Width+8, - ClassPartInsertPolicyRadioGroup.Top, + Parent:=NoteBook.Page[PageID]; + SetBounds(ClassPartInsertPolicyRadioGroup.Left, + MixMethodsAndPorpertiesCheckBox.Top + +MixMethodsAndPorpertiesCheckBox.Height+10, ClassPartInsertPolicyRadioGroup.Width, - ClassPartInsertPolicyRadioGroup.Height); - Caption:=dlgMethodInsPolicy ; + 100); + Caption:=dlgMethodInsPolicy; with Items do begin BeginUpdate; Add(dlgAlphabetically); @@ -745,55 +799,45 @@ begin Visible:=true; end; - KeyWordPolicyRadioGroup:=TRadioGroup.Create(Self); - with KeyWordPolicyRadioGroup do begin - Name:='KeyWordPolicyRadioGroup'; - Parent:=NoteBook.Page[1]; - SetBounds(ClassPartInsertPolicyRadioGroup.Left, - ClassPartInsertPolicyRadioGroup.Top - +ClassPartInsertPolicyRadioGroup.Height+7, - (Self.ClientWidth div 2)-12,100); - Caption:=dlgKeywordPolicy ; + ForwardProcsInsertPolicyRadioGroup:=TRadioGroup.Create(Self); + with ForwardProcsInsertPolicyRadioGroup do begin + Name:='ForwardProcsInsertPolicyRadioGroup'; + Parent:=NoteBook.Page[PageID];; + SetBounds(ClassPartInsertPolicyRadioGroup.Left + +ClassPartInsertPolicyRadioGroup.Width+8, + ClassPartInsertPolicyRadioGroup.Top, + ClassPartInsertPolicyRadioGroup.Width,100); + Caption:=dlgForwardProcsInsertPolicy; with Items do begin BeginUpdate; - Add(dlgEnvNone); - Add(dlgCDTLower); - Add(dlgCDTUPPERCASE); - Add(dlg1UP2low); + Add(dlgLast); + Add(dlgInFrontOfMethods); + Add(dlgBehindMethods); EndUpdate; end; - OnClick:=@UpdateExamples; - Visible:=true; - end; - - IdentifierPolicyRadioGroup:=TRadioGroup.Create(Self); - with IdentifierPolicyRadioGroup do begin - Name:='IdentifierPolicyRadioGroup'; - Parent:=NoteBook.Page[1]; - SetBounds(KeyWordPolicyRadioGroup.Left+KeyWordPolicyRadioGroup.Width+8, - KeyWordPolicyRadioGroup.Top, - KeyWordPolicyRadioGroup.Width,KeyWordPolicyRadioGroup.Height); - Caption:=dlgIdentifierPolicy; - with Items do begin - BeginUpdate; - Add(dlgEnvNone); - Add(dlgCDTLower); - Add(dlgCDTUPPERCASE); - Add(dlg1UP2low); - EndUpdate; - end; - OnClick:=@UpdateExamples; Visible:=true; end; + ForwardProcsKeepOrderCheckBox:=TCheckBox.Create(Self); + with ForwardProcsKeepOrderCheckBox do begin + Name:='ForwardProcsKeepOrderCheckBox'; + Parent:=NoteBook.Page[PageID];; + SetBounds(ForwardProcsInsertPolicyRadioGroup.Left, + ForwardProcsInsertPolicyRadioGroup.Top + +ForwardProcsInsertPolicyRadioGroup.Height+5, + ForwardProcsInsertPolicyRadioGroup.Width,Height); + Caption:=dlgForwardProcsKeepOrder; + Visible:=true; + end; + PropertyCompletionGroupBox:=TGroupBox.Create(Self); with PropertyCompletionGroupBox do begin Name:='PropertyCompletionGroupBox'; - Parent:=NoteBook.Page[1]; - SetBounds(KeyWordPolicyRadioGroup.Left, - KeyWordPolicyRadioGroup.Top+KeyWordPolicyRadioGroup.Height+7, + Parent:=NoteBook.Page[PageID]; + SetBounds(ClassPartInsertPolicyRadioGroup.Left, + MethodInsertPolicyRadioGroup.Top+MethodInsertPolicyRadioGroup.Height+7, Self.ClientWidth-20,125); - Caption:=dlgPropertyCompletion ; + Caption:=dlgPropertyCompletion; Visible:=true; end; @@ -906,12 +950,54 @@ begin end; end; -procedure TCodeToolsOptsDlg.SetupLineSplittingPage; +procedure TCodeToolsOptsDlg.SetupWordsPage(PageID: integer); +begin + KeyWordPolicyRadioGroup:=TRadioGroup.Create(Self); + with KeyWordPolicyRadioGroup do begin + Name:='KeyWordPolicyRadioGroup'; + Parent:=NoteBook.Page[PageID]; + SetBounds(8,6, + (Self.ClientWidth div 2)-12,120); + Caption:=dlgKeywordPolicy ; + with Items do begin + BeginUpdate; + Add(dlgEnvNone); + Add(dlgCDTLower); + Add(dlgCDTUPPERCASE); + Add(dlg1UP2low); + EndUpdate; + end; + OnClick:=@UpdateExamples; + Visible:=true; + end; + + IdentifierPolicyRadioGroup:=TRadioGroup.Create(Self); + with IdentifierPolicyRadioGroup do begin + Name:='IdentifierPolicyRadioGroup'; + Parent:=NoteBook.Page[PageID]; + SetBounds(KeyWordPolicyRadioGroup.Left+KeyWordPolicyRadioGroup.Width+8, + KeyWordPolicyRadioGroup.Top, + KeyWordPolicyRadioGroup.Width,KeyWordPolicyRadioGroup.Height); + Caption:=dlgIdentifierPolicy; + with Items do begin + BeginUpdate; + Add(dlgEnvNone); + Add(dlgCDTLower); + Add(dlgCDTUPPERCASE); + Add(dlg1UP2low); + EndUpdate; + end; + OnClick:=@UpdateExamples; + Visible:=true; + end; +end; + +procedure TCodeToolsOptsDlg.SetupLineSplittingPage(PageID: integer); begin LineLengthLabel:=TLabel.Create(Self); with LineLengthLabel do begin Name:='LineLengthLabel'; - Parent:=NoteBook.Page[2]; + Parent:=NoteBook.Page[PageID]; SetBounds(8,7,Canvas.TextWidth('Max line length: '),Height); Caption:=dlgMaxLineLength ; Visible:=true; @@ -931,7 +1017,7 @@ begin DoNotSplitLineInFrontGroupBox:=TGroupBox.Create(Self); with DoNotSplitLineInFrontGroupBox do begin Name:='DoNotSplitLineInFrontGroupBox'; - Parent:=NoteBook.Page[2]; + Parent:=NoteBook.Page[PageID]; SetBounds(6,LineLengthLabel.Top+LineLengthLabel.Height+7, (Self.ClientWidth-24) div 2,150); Caption:=dlgNotSplitLineFront ; @@ -943,7 +1029,7 @@ begin DoNotSplitLineAfterGroupBox:=TGroupBox.Create(Self); with DoNotSplitLineAfterGroupBox do begin Name:='DoNotSplitLineAfterGroupBox'; - Parent:=NoteBook.Page[2]; + Parent:=NoteBook.Page[PageID]; SetBounds(DoNotSplitLineInFrontGroupBox.Left, DoNotSplitLineInFrontGroupBox.Top+DoNotSplitLineInFrontGroupBox.Height+7, DoNotSplitLineInFrontGroupBox.Width, @@ -957,7 +1043,7 @@ begin SplitPreviewGroupBox:=TGroupBox.Create(Self); with SplitPreviewGroupBox do begin Name:='SplitPreviewGroupBox'; - Parent:=NoteBook.Page[2]; + Parent:=NoteBook.Page[PageID]; Left:=DoNotSplitLineInFrontGroupBox.Left +DoNotSplitLineInFrontGroupBox.Width+8; Top:=LineLengthLabel.Top; @@ -976,12 +1062,12 @@ begin end; end; -procedure TCodeToolsOptsDlg.SetupSpacePage; +procedure TCodeToolsOptsDlg.SetupSpacePage(PageID: integer); begin DoInsertSpaceInFrontGroupBox:=TGroupBox.Create(Self); with DoInsertSpaceInFrontGroupBox do begin Name:='DoInsertSpaceInFrontGroupBox'; - Parent:=NoteBook.Page[3]; + Parent:=NoteBook.Page[PageID]; SetBounds(6,6, (Self.ClientWidth-24) div 2,150); Caption:=dlgInsSpaceFront ; @@ -993,7 +1079,7 @@ begin DoInsertSpaceAfterGroupBox:=TGroupBox.Create(Self); with DoInsertSpaceAfterGroupBox do begin Name:='DoInsertSpaceAfterGroupBox'; - Parent:=NoteBook.Page[3]; + Parent:=NoteBook.Page[PageID]; SetBounds(DoInsertSpaceInFrontGroupBox.Left +DoInsertSpaceInFrontGroupBox.Width+8, DoInsertSpaceInFrontGroupBox.Top, @@ -1008,7 +1094,7 @@ begin SpacePreviewGroupBox:=TGroupBox.Create(Self); with SpacePreviewGroupBox do begin Name:='SpacePreviewGroupBox'; - Parent:=NoteBook.Page[3]; + Parent:=NoteBook.Page[PageID]; Left:=DoInsertSpaceInFrontGroupBox.Left; Top:=DoInsertSpaceInFrontGroupBox.Top+DoInsertSpaceInFrontGroupBox.Height+7; Width:=Self.ClientWidth-10-Left; @@ -1062,34 +1148,41 @@ end; procedure TCodeToolsOptsDlg.ResizeCodeCreationPage; begin with ClassPartInsertPolicyRadioGroup do begin - SetBounds(8,6, - (Self.ClientWidth div 2)-12,80); + SetBounds(8,6,(Self.ClientWidth div 2)-12,70); + end; + + with MixMethodsAndPorpertiesCheckBox do begin + SetBounds(ClassPartInsertPolicyRadioGroup.Left, + ClassPartInsertPolicyRadioGroup.Top + +ClassPartInsertPolicyRadioGroup.Height+5, + ClassPartInsertPolicyRadioGroup.Width,Height); end; with MethodInsertPolicyRadioGroup do begin - SetBounds(ClassPartInsertPolicyRadioGroup.Left - +ClassPartInsertPolicyRadioGroup.Width+8, - ClassPartInsertPolicyRadioGroup.Top, - ClassPartInsertPolicyRadioGroup.Width, - ClassPartInsertPolicyRadioGroup.Height); - end; - - with KeyWordPolicyRadioGroup do begin SetBounds(ClassPartInsertPolicyRadioGroup.Left, - ClassPartInsertPolicyRadioGroup.Top - +ClassPartInsertPolicyRadioGroup.Height+7, - (Self.ClientWidth div 2)-12,100); + MixMethodsAndPorpertiesCheckBox.Top + +MixMethodsAndPorpertiesCheckBox.Height+10, + ClassPartInsertPolicyRadioGroup.Width, + 100); end; - with IdentifierPolicyRadioGroup do begin - SetBounds(KeyWordPolicyRadioGroup.Left+KeyWordPolicyRadioGroup.Width+8, - KeyWordPolicyRadioGroup.Top, - KeyWordPolicyRadioGroup.Width,KeyWordPolicyRadioGroup.Height); + with ForwardProcsInsertPolicyRadioGroup do begin + SetBounds(ClassPartInsertPolicyRadioGroup.Left + +ClassPartInsertPolicyRadioGroup.Width+8, + ClassPartInsertPolicyRadioGroup.Top, + ClassPartInsertPolicyRadioGroup.Width,100); + end; + + with ForwardProcsKeepOrderCheckBox do begin + SetBounds(ForwardProcsInsertPolicyRadioGroup.Left, + ForwardProcsInsertPolicyRadioGroup.Top + +ForwardProcsInsertPolicyRadioGroup.Height+5, + ForwardProcsInsertPolicyRadioGroup.Width,Height); end; with PropertyCompletionGroupBox do begin - SetBounds(KeyWordPolicyRadioGroup.Left, - KeyWordPolicyRadioGroup.Top+KeyWordPolicyRadioGroup.Height+7, + SetBounds(ClassPartInsertPolicyRadioGroup.Left, + MethodInsertPolicyRadioGroup.Top+MethodInsertPolicyRadioGroup.Height+7, Self.ClientWidth-20,125); end; @@ -1152,6 +1245,19 @@ begin end; end; +procedure TCodeToolsOptsDlg.ResizeWordsPage; +begin + with KeyWordPolicyRadioGroup do begin + SetBounds(8,6,(Self.ClientWidth div 2)-12,120); + end; + + with IdentifierPolicyRadioGroup do begin + SetBounds(KeyWordPolicyRadioGroup.Left+KeyWordPolicyRadioGroup.Width+8, + KeyWordPolicyRadioGroup.Top, + KeyWordPolicyRadioGroup.Width,KeyWordPolicyRadioGroup.Height); + end; +end; + procedure TCodeToolsOptsDlg.ResizeLineSplittingPage; begin with LineLengthLabel do begin @@ -1224,6 +1330,7 @@ begin ResizeGeneralPage; ResizeCodeCreationPage; + ResizeWordsPage; ResizeLineSplittingPage; ResizeSpacePage; @@ -1317,6 +1424,15 @@ begin // cpipLast ClassPartInsertPolicyRadioGroup.ItemIndex:=1; end; + MixMethodsAndPorpertiesCheckBox.Checked:=Options.MixMethodsAndPorperties; + case Options.ForwardProcInsertPolicy of + fpipLast: ForwardProcsInsertPolicyRadioGroup.ItemIndex:=0; + fpipInFrontOfMethods: ForwardProcsInsertPolicyRadioGroup.ItemIndex:=1; + else + // fpipBehindMethods + ForwardProcsInsertPolicyRadioGroup.ItemIndex:=2; + end; + ForwardProcsKeepOrderCheckBox.Checked:=Options.KeepForwardProcOrder; case Options.MethodInsertPolicy of mipAlphabetically: MethodInsertPolicyRadioGroup.ItemIndex:=0; @@ -1376,6 +1492,13 @@ begin 0: Options.ClassPartInsertPolicy:=cpipAlphabetically; 1: Options.ClassPartInsertPolicy:=cpipLast; end; + Options.MixMethodsAndPorperties:=MixMethodsAndPorpertiesCheckBox.Checked; + case ForwardProcsInsertPolicyRadioGroup.ItemIndex of + 0: Options.ForwardProcInsertPolicy:=fpipLast; + 1: Options.ForwardProcInsertPolicy:=fpipInFrontOfMethods; + 2: Options.ForwardProcInsertPolicy:=fpipBehindMethods; + end; + Options.KeepForwardProcOrder:=ForwardProcsKeepOrderCheckBox.Checked; case MethodInsertPolicyRadioGroup.ItemIndex of 0: Options.MethodInsertPolicy:=mipAlphabetically; 1: Options.MethodInsertPolicy:=mipLast; @@ -1479,6 +1602,13 @@ begin 0: Options.ClassPartInsertPolicy:=cpipAlphabetically; 1: Options.ClassPartInsertPolicy:=cpipLast; end; + Options.MixMethodsAndPorperties:=MixMethodsAndPorpertiesCheckBox.Checked; + case ForwardProcsInsertPolicyRadioGroup.ItemIndex of + 0: Options.ForwardProcInsertPolicy:=fpipLast; + 1: Options.ForwardProcInsertPolicy:=fpipInFrontOfMethods; + 2: Options.ForwardProcInsertPolicy:=fpipBehindMethods; + end; + Options.KeepForwardProcOrder:=ForwardProcsKeepOrderCheckBox.Checked; case MethodInsertPolicyRadioGroup.ItemIndex of 0: Options.MethodInsertPolicy:=mipAlphabetically; 1: Options.MethodInsertPolicy:=mipLast; diff --git a/ide/lazarusidestrconsts.pas b/ide/lazarusidestrconsts.pas index 22ce027ade..e9a8dcb9d5 100644 --- a/ide/lazarusidestrconsts.pas +++ b/ide/lazarusidestrconsts.pas @@ -435,6 +435,7 @@ resourcestring //CodeTools dialogue dlgCodeToolsOpts = 'CodeTools Options'; dlgCodeCreation = 'Code Creation'; + dlgWordsPolicies = 'Words'; dlgLineSplitting = 'Line Splitting'; dlgSpaceNotCosmos{:)} = 'Space'; dlgAdditionalSrcPath = 'Additional Source search path for all projects (.pp;.pas)'; @@ -445,6 +446,12 @@ resourcestring dlgClassInsertPolicy = 'Class part insert policy'; dlgAlphabetically = 'Alphabetically'; dlgCDTLast = 'Last'; + dlgMixMethodsAndProperties = 'Mix methods and properties'; + dlgForwardProcsInsertPolicy = 'Procedure insert policy'; + dlgLast = 'Last (i.e. at end of source)'; + dlgInFrontOfMethods = 'In front of methods'; + dlgBehindMethods = 'Behind methods'; + dlgForwardProcsKeepOrder = 'Keep order of procedures'; dlgMethodInsPolicy = 'Method insert policy'; dlgCDTClassOrder = 'Class order'; dlgKeywordPolicy = 'Keyword policy';