codetools: added atBracket as atom type for the simple beautifier, from Alexander S. Klenin, bug #12781

git-svn-id: trunk@17785 -
This commit is contained in:
mattias 2008-12-10 17:41:03 +00:00
parent 90510e4cb6
commit 61584bd8e0
7 changed files with 45 additions and 25 deletions

View File

@ -72,7 +72,7 @@ type
TAtomType = (atNone, atKeyword, atIdentifier, atColon, atSemicolon, atComma,
atPoint, atAt, atNumber, atStringConstant, atNewLine,
atSpace, atCommentStart, atDirectiveStart, atCommentEnd,
atSymbol);
atSymbol, atBracket);
TAtomTypes = set of TAtomType;
TBeautifyCodeFlag = (
@ -237,7 +237,7 @@ const
'None', 'Keyword', 'Identifier', 'Colon', 'Semicolon', 'Comma', 'Point',
'At', 'Number', 'StringConstant', 'NewLine', 'Space',
'CommentStart', 'DirectiveStart', 'CommentEnd',
'Symbol'
'Symbol', 'Bracket'
);
WordPolicyNames: array[TWordPolicy] of shortstring = (
@ -1185,9 +1185,14 @@ begin
CurAtomType:=atCommentStart;
end;
end else begin
CurAtomType:=atSymbol;
CurAtomType:=atBracket;
end;
end;
'[', ']', ')':
begin
inc(CurPos);
CurAtomType:=atBracket;
end;
'*': // *) comment end
begin
inc(CurPos);
@ -1233,13 +1238,14 @@ begin
then
inc(CurPos);
end;
if AtomStart+1=CurPos then begin
if c1='.' then CurAtomType:=atPoint
else if c1=',' then CurAtomType:=atComma
else if c1=':' then CurAtomType:=atColon
else if c1=';' then CurAtomType:=atSemicolon
else if c1='@' then CurAtomType:=atAt;
end;
if AtomStart+1=CurPos then
case c1 of
'.': CurAtomType:=atPoint;
',': CurAtomType:=atComma;
':': CurAtomType:=atColon;
';': CurAtomType:=atSemicolon;
'@': CurAtomType:=atAt;
end;
end;
end;
end else

View File

@ -198,6 +198,7 @@ begin
atNewLine: Result:=lisCodeToolsOptsNewLine;
atSpace: Result:=lisCodeToolsOptsSpace;
atSymbol: Result:=lisCodeToolsOptsSymbol;
atBracket: Result:=lisCodeToolsOptsBracket;
else
Result:='???';
end;

View File

@ -5,8 +5,8 @@ inherited CodetoolsLineSplittingOptionsFrame: TCodetoolsLineSplittingOptionsFram
ClientWidth = 558
TabOrder = 0
Visible = False
DesignLeft = 110
DesignTop = 145
DesignLeft = 66
DesignTop = 66
object LineLengthLabel: TLabel[0]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = LineLengthEdit
@ -89,7 +89,11 @@ inherited CodetoolsLineSplittingOptionsFrame: TCodetoolsLineSplittingOptionsFram
ParentFont = False
TabOrder = 3
BookMarkOptions.Xoffset = -18
BookMarkOptions.OnChange = nil
Gutter.Visible = False
Gutter.ShowCodeFolding = True
Gutter.ShowChanges = True
Gutter.ShowLineNumbers = True
Keystrokes = <
item
Command = 3
@ -414,5 +418,7 @@ inherited CodetoolsLineSplittingOptionsFrame: TCodetoolsLineSplittingOptionsFram
Lines.Strings = (
'SplitPreviewSynEdit'
)
SelectedColor.OnChange = nil
BracketHighlightStyle = sbhsBoth
end
end

View File

@ -245,8 +245,9 @@ end;
procedure TCodetoolsLineSplittingOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
const
DoNotSplitAtoms = [atKeyword, atIdentifier, atColon, atSemicolon, atComma,
atPoint, atAt, atNumber, atStringConstant, atSpace, atSymbol];
DoNotSplitAtoms = [
atKeyword, atIdentifier, atColon, atSemicolon, atComma,
atPoint, atAt, atNumber, atStringConstant, atSpace, atSymbol, atBracket];
begin
with LineLengthLabel do
Caption:=dlgMaxLineLength;

View File

@ -1,13 +1,13 @@
object CodetoolsSpaceOptionsFrame: TCodetoolsSpaceOptionsFrame
inherited CodetoolsSpaceOptionsFrame: TCodetoolsSpaceOptionsFrame
Height = 383
Width = 504
ClientHeight = 383
ClientWidth = 504
TabOrder = 0
Visible = False
DesignLeft = 500
DesignTop = 316
object SpacePreviewLabel: TLabel
DesignLeft = 22
DesignTop = 22
object SpacePreviewLabel: TLabel[0]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = DoInsertSpaceInFrontGroupBox
AnchorSideTop.Side = asrBottom
@ -19,7 +19,7 @@ object CodetoolsSpaceOptionsFrame: TCodetoolsSpaceOptionsFrame
Caption = 'SpacePreviewLabel'
ParentColor = False
end
object DoInsertSpaceInFrontGroupBox: TGroupBox
object DoInsertSpaceInFrontGroupBox: TGroupBox[1]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Owner
Height = 150
@ -28,7 +28,7 @@ object CodetoolsSpaceOptionsFrame: TCodetoolsSpaceOptionsFrame
TabOrder = 0
OnClick = UpdateExample
end
object DoInsertSpaceAfterGroupBox: TGroupBox
object DoInsertSpaceAfterGroupBox: TGroupBox[2]
AnchorSideLeft.Control = DoInsertSpaceInFrontGroupBox
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = Owner
@ -43,7 +43,7 @@ object CodetoolsSpaceOptionsFrame: TCodetoolsSpaceOptionsFrame
TabOrder = 1
OnClick = UpdateExample
end
object SpacePreviewSynEdit: TSynEdit
object SpacePreviewSynEdit: TSynEdit[3]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = SpacePreviewLabel
AnchorSideTop.Side = asrBottom
@ -65,6 +65,9 @@ object CodetoolsSpaceOptionsFrame: TCodetoolsSpaceOptionsFrame
BookMarkOptions.Xoffset = -18
BookMarkOptions.OnChange = nil
Gutter.Visible = False
Gutter.ShowCodeFolding = True
Gutter.ShowChanges = True
Gutter.ShowLineNumbers = True
Keystrokes = <
item
Command = 3
@ -390,5 +393,6 @@ object CodetoolsSpaceOptionsFrame: TCodetoolsSpaceOptionsFrame
'SpacePreviewSynEdit'
)
SelectedColor.OnChange = nil
BracketHighlightStyle = sbhsBoth
end
end

View File

@ -172,7 +172,7 @@ const
+'var Var1,Var2:array of const):integer;'#13
+'const i=1+2+3;'#13
+'begin'#13
+' A:=@B.C;D:=3;'#13
+' A:=@B.C;D:=3;E:=X[5];'#13
+' {$I unit1.lrs}'#13
+' {$R-}{$R+}'#13
+'end;';
@ -250,8 +250,9 @@ end;
procedure TCodetoolsSpaceOptionsFrame.Setup(
ADialog: TAbstractOptionsEditorDialog);
const
DoInsertSpaceAtoms = [atKeyword, atIdentifier, atColon, atSemicolon, atComma,
atPoint, atAt, atNumber, atStringConstant, atSymbol];
DoInsertSpaceAtoms = [
atKeyword, atIdentifier, atColon, atSemicolon, atComma,
atPoint, atAt, atNumber, atStringConstant, atSymbol, atBracket];
begin
with DoInsertSpaceInFrontGroupBox do begin
Caption:=dlgInsSpaceFront;

View File

@ -2223,7 +2223,8 @@ resourcestring
lisCodeToolsOptsNewLine = 'Newline';
lisCodeToolsOptsSpace = 'Space';
lisCodeToolsOptsSymbol = 'Symbol';
lisCodeToolsOptsBracket = 'Bracket';
// codetools defines
lisCodeToolsDefsCodeToolsDefinesPreview = 'CodeTools Defines Preview';
lisCodeToolsDefsWriteError = 'Write error';