IDE+codetools: implemented complete blocks in statements

git-svn-id: trunk@20108 -
This commit is contained in:
mattias 2009-05-21 16:49:01 +00:00
parent f8012d194e
commit 9bd290d86e
8 changed files with 454 additions and 129 deletions

View File

@ -69,6 +69,7 @@ function FindMainUnitHint(const ASource: string; out Filename: string): boolean;
procedure GetLineStartEndAtPosition(const Source:string; Position:integer;
var LineStart,LineEnd:integer);
function GetLineIndent(const Source: string; Position: integer): integer;
function GetPosInLine(const Source: string; Position: integer): integer;
function GetBlockMinIndent(const Source: string;
StartPos, EndPos: integer): integer;
function GetIndentStr(Indent: integer): string;
@ -3526,6 +3527,15 @@ begin
until false;
end;
function GetPosInLine(const Source: string; Position: integer): integer;
begin
Result:=0;
while (Position>1) and (not (Source[Position] in [#10,#13])) do begin
inc(Result);
dec(Position);
end;
end;
function GetBlockMinIndent(const Source: string;
StartPos, EndPos: integer): integer;
var

View File

@ -979,6 +979,7 @@ begin
if (CurPos.EndPos-CurPos.StartPos=3)
and (Src[CurPos.StartPos+1] in ['n','N'])
and (Src[CurPos.StartPos+2] in ['d','D'])
and ((CurPos.StartPos=1) or (Src[CurPos.StartPos-1]<>'@'))
then
CurPos.Flag:=cafEnd;
'r','R':

View File

@ -5086,32 +5086,338 @@ end;
function TStandardCodeTool.CompleteBlock(const CursorPos: TCodeXYPosition;
SourceChangeCache: TSourceChangeCache;
out NewPos: TCodeXYPosition; out NewTopLine: integer): boolean;
{ begin: end;
asm: end;
try: finally end;
finally: end;
except: end;
repeat: until ;
case of: end;
case :: ;
case else: end;
(: )
[: ]
record: end;
class: end;
object: end;
interface: end;
{ For example:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
begin
|
...
something
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if then begin
|
...
something
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
begin
|
procedure
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ToDo:
if then begin
|
else
while do begin
|
foo;
bar;
Statements:
begin: end;
asm: end;
try: finally end;
finally: end;
except: end;
repeat: until ;
case of: end;
case :: ;
case else: end;
(: )
[: ]
Types:
(: )
[: ]
record: end;
class: end;
object: end;
interface: end;
}
type
TBlockType = (
btNone,
btBegin,
btAsm,
btEdgedBracket,
btRoundBracket,
btTry,
btFinally,
btExcept,
btCase,
btCaseOf,
btCaseColon,
btCaseElse,
btRepeat,
btClass,
btInterface,
btObject,
btRecord
);
TBlock = record
Typ: TBlockType;
StartPos: integer;
end;
PBlock = ^TBlock;
TBlockStack = record
Stack: PBlock;
Capacity: integer;
Top: integer;
end;
var
CleanCursorPos: integer;
Node: TCodeTreeNode;
StartNode: TCodeTreeNode;
procedure InitStack(out Stack: TBlockStack);
begin
FillByte(Stack,SizeOf(Stack),0);
Stack.Top:=-1;
end;
procedure FreeStack(var Stack: TBlockStack);
begin
ReAllocMem(Stack.Stack,0);
Stack.Capacity:=0;
Stack.Top:=-1;
end;
procedure BeginBlock(var Stack: TBlockStack; Typ: TBlockType;
StartPos: integer);
var
Block: PBlock;
begin
inc(Stack.Top);
if Stack.Top>=Stack.Capacity then begin
if Stack.Capacity=0 then
Stack.Capacity:=16
else
Stack.Capacity:=Stack.Capacity*2;
ReAllocMem(Stack.Stack,SizeOf(TBlock)*Stack.Capacity);
end;
Block:=@Stack.Stack[Stack.Top];
Block^.Typ:=Typ;
Block^.StartPos:=StartPos;
end;
procedure EndBlock(var Stack: TBlockStack);
begin
dec(Stack.Top);
end;
function TopBlockType(const Stack: TBlockStack): TBlockType;
begin
if Stack.Top>=0 then
Result:=Stack.Stack[Stack.Top].Typ
else
Result:=btNone;
end;
function ReadStatements(var Stack: TBlockStack): Boolean;
var
CursorBlockLvl: Integer; // the stack level of the cursor
LastPos: Integer;
LineStart: boolean; // Atom is first atom of a line in cursor block (not in sub block)
Indent: Integer;
CursorBlockIndent: LongInt;
CursorBlock: TBlock;
BehindCursorBlock: Boolean; // atom behind cursor block
InCursorBlock: Boolean;
NeedCompletion: Boolean;
InsertPos: LongInt;
NewCode: String;
function EndBlockIsOk: boolean;
begin
//DebugLn(['EndBlockIsOk ']);
EndBlock(Stack);
Result:=true;
if (not BehindCursorBlock) and (Stack.Top<CursorBlockLvl) then
BehindCursorBlock:=true;
end;
begin
Result:=false;
MoveCursorToNodeStart(StartNode);
CursorBlockLvl:=-2;
LastPos:=-1;
CursorBlockIndent:=0;
Indent:=0;
CursorBlock.StartPos:=0;
BehindCursorBlock:=false;
NeedCompletion:=false;
repeat
ReadNextAtom;
//DebugLn(['ReadStatements Atom=',GetAtom,' TopTyp=',ord(TopBlockType(Stack)),' Top=',Stack.Top]);
// check if cursor reached
if (CurPos.StartPos>=CleanCursorPos) and (CursorBlockLvl<0) then begin
// reached cursor
CursorBlockLvl:=Stack.Top;
if CursorBlockLvl<0 then
CursorBlockIndent:=GetLineIndent(Src,CurPos.StartPos)
else begin
CursorBlock:=Stack.Stack[CursorBlockLvl];
CursorBlockIndent:=GetLineIndent(Src,CursorBlock.StartPos);
end;
//DebugLn(['ReadStatements CursorBlockLvl=',CursorBlockLvl,' Indent=',CursorBlockIndent]);
end;
// check if end of node
if (CurPos.StartPos>SrcLen) or (CurPos.StartPos>=StartNode.EndPos) then
break;
// check if line start
InCursorBlock:=(CursorBlockLvl=Stack.Top) and (not BehindCursorBlock);
LineStart:=InCursorBlock and (LastPos>0)
and not PositionsInSameLine(Src,LastPos,CurPos.StartPos);
if LineStart then
Indent:=GetLineIndent(Src,CurPos.StartPos);
if LineStart then begin
// atom is in same block as cursor (not sub block)
// and first atom of a line
// => check indent
if Indent<CursorBlockIndent then begin
//DebugLn(['ReadStatements Indent=',Indent,' < CursorBlockIndent=',CursorBlockIndent]);
NeedCompletion:=true;
end;
end;
// check block starts/ends
case CurPos.Flag of
cafEnd:
begin
case TopBlockType(Stack) of
btBegin,btFinally,btExcept,btCase,btCaseOf,btCaseColon,btCaseElse:
if not EndBlockIsOk then exit;
btAsm:
if (CurPos.StartPos>1) and (Src[CurPos.StartPos-1]<>'@') then begin
if not EndBlockIsOk then exit;
end;
else
// missing begin
exit;
end;
end;
cafEdgedBracketOpen:
BeginBlock(Stack,btEdgedBracket,CurPos.StartPos);
cafEdgedBracketClose:
if TopBlockType(Stack)=btEdgedBracket then begin
if not EndBlockIsOk then exit;
end else begin
// missing [
exit;
end;
cafRoundBracketOpen:
BeginBlock(Stack,btRoundBracket,CurPos.StartPos);
cafRoundBracketClose:
if TopBlockType(Stack)=btRoundBracket then begin
if not EndBlockIsOk then exit;
end else begin
// missing (
exit;
end;
cafColon:
if TopBlockType(Stack)=btCaseOf then
BeginBlock(Stack,btCaseColon,CurPos.StartPos);
cafSemicolon:
if TopBlockType(Stack)=btCaseColon then
if not EndBlockIsOk then exit;
cafBegin:
BeginBlock(Stack,btBegin,CurPos.StartPos);
cafWord:
if TopBlockType(Stack)<>btAsm then begin
if UpAtomIs('TRY') then
BeginBlock(Stack,btTry,CurPos.StartPos)
else if UpAtomIs('FINALLY') then
BeginBlock(Stack,btFinally,CurPos.StartPos)
else if UpAtomIs('EXCEPT') then
BeginBlock(Stack,btExcept,CurPos.StartPos)
else if UpAtomIs('REPEAT') then
BeginBlock(Stack,btRepeat,CurPos.StartPos)
else if UpAtomIs('UNTIL') then begin
if TopBlockType(Stack)=btRepeat then begin
if not EndBlockIsOk then exit;
end else begin
// until without repeat
end;
end else if UpAtomIs('ASM') then begin
BeginBlock(Stack,btAsm,CurPos.StartPos);
end else if UpAtomIs('CASE') then begin
BeginBlock(Stack,btCase,CurPos.StartPos)
end else if UpAtomIs('OF') then begin
if TopBlockType(Stack)=btCase then
BeginBlock(Stack,btCaseOf,CurPos.StartPos);
end else if UpAtomIs('ELSE') then begin
if TopBlockType(Stack)=btCaseOf then begin
if not EndBlockIsOk then exit;
BeginBlock(Stack,btCaseElse,CurPos.StartPos);
end;
end;
end;
end;
LastPos:=CurPos.StartPos;
until false;
//DebugLn(['ReadStatements END Stack.Top=',Stack.Top,' CursorBlockLvl=',CursorBlockLvl,' BehindCursorBlock=',BehindCursorBlock]);
if (not NeedCompletion) and (Stack.Top>=0)
and (not BehindCursorBlock) and (CursorBlockLvl=Stack.Top) then begin
NeedCompletion:=true;
end;
if NeedCompletion then begin
InsertPos:=CleanCursorPos;
Indent:=CursorBlockIndent;
NewCode:='';
case CursorBlock.Typ of
btBegin,btFinally,btExcept,btAsm,btCaseOf,btCaseElse:
NewCode:='end;';
btRepeat:
NewCode:='until ;';
btTry:
NewCode:='finally'+SourceChangeCache.BeautifyCodeOptions.LineEnd
+'end;';
end;
if NewCode<>'' then begin
NewCode:=SourceChangeCache.BeautifyCodeOptions.BeautifyStatement(
NewCode,Indent,[bcfIndentExistingLineBreaks]);
if not SourceChangeCache.Replace(gtNewLine,gtNewLine,
InsertPos,InsertPos,NewCode) then exit;
if not SourceChangeCache.Apply then exit;
end;
end;
Result:=true;
end;
var
Stack: TBlockStack;
begin
Result:=false;
NewPos:=CursorPos;
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
[{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]);
Node:=FindDeepestNodeAtPos(CleanCursorPos,true);
StartNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
SourceChangeCache.MainScanner:=Scanner;
InitStack(Stack);
try
//DebugLn(['TStandardCodeTool.CompleteBlock ',StartNode.DescAsString]);
DebugLn(['TStandardCodeTool.CompleteBlock ',Node.DescAsString]);
if StartNode.Desc in AllPascalStatements then begin
if (StartNode.Parent<>nil)
and (StartNode.Parent.Desc in AllPascalStatements) then
StartNode:=StartNode.Parent;
if not ReadStatements(Stack) then exit;
end;
finally
FreeStack(Stack);
end;
Result:=true;
end;
function TStandardCodeTool.GuessMisplacedIfdefEndif(

View File

@ -5,16 +5,17 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
ClientWidth = 492
TabOrder = 0
Visible = False
DesignTop = 25
DesignLeft = 398
DesignTop = 291
object AutoDelayMaxLabel: TLabel[0]
AnchorSideTop.Control = AutoDelayTrackBar
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 360
Left = 365
Height = 18
Top = 182
Width = 132
Width = 127
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 2
@ -28,7 +29,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 18
Top = 182
Width = 128
Width = 123
BorderSpacing.Top = 2
Caption = 'AutoDelayMinLabel'
ParentColor = False
@ -40,7 +41,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 18
Top = 204
Width = 104
Width = 101
BorderSpacing.Top = 24
Caption = 'AutoDelayLabel'
ParentColor = False
@ -52,7 +53,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 18
Top = 354
Width = 180
Width = 171
BorderSpacing.Top = 2
Caption = 'MarkupWordDelayMinLabel'
ParentColor = False
@ -62,10 +63,10 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 308
Left = 317
Height = 18
Top = 354
Width = 184
Width = 175
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Top = 2
@ -79,7 +80,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 18
Top = 376
Width = 156
Width = 149
BorderSpacing.Top = 24
Caption = 'MarkupWordDelayLabel'
ParentColor = False
@ -90,10 +91,10 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Control = MarkupWordFullCheckBox
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = MarkupWordFullLenSpin
Left = 239
Left = 230
Height = 18
Top = 258
Width = 164
Width = 156
BorderSpacing.Left = 45
BorderSpacing.Top = 6
Caption = 'MarkupWordFullLenLabel'
@ -105,7 +106,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 22
Top = 0
Width = 252
Width = 245
Caption = 'AutoIdentifierCompletionCheckBox'
TabOrder = 0
end
@ -116,7 +117,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 22
Top = 28
Width = 255
Width = 251
BorderSpacing.Top = 6
Caption = 'AutoRemoveEmptyMethodsOnSave'
TabOrder = 1
@ -128,32 +129,31 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 22
Top = 56
Width = 235
Width = 227
BorderSpacing.Top = 6
Caption = 'AutoToolTipSymbToolsCheckBox'
TabOrder = 2
end
object AutoCodeParametersCheckBox: TCheckBox[10]
object AutoCompleteBlockCheckBox: TCheckBox[10]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = AutoToolTipSymbToolsCheckBox
AnchorSideTop.Side = asrBottom
Left = 0
Height = 22
Top = 84
Width = 226
Width = 213
BorderSpacing.Top = 6
Caption = 'AutoCodeParametersCheckBox'
Enabled = False
Caption = 'AutoCompleteBlockCheckBox'
TabOrder = 3
end
object AutoToolTipExprEvalCheckBox: TCheckBox[11]
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = AutoCodeParametersCheckBox
AnchorSideTop.Control = AutoCompleteBlockCheckBox
AnchorSideTop.Side = asrBottom
Left = 0
Height = 22
Top = 112
Width = 222
Width = 213
BorderSpacing.Top = 6
Caption = 'AutoToolTipExprEvalCheckBox'
TabOrder = 4
@ -201,7 +201,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 22
Top = 256
Width = 194
Width = 185
BorderSpacing.Top = 6
Caption = 'MarkupWordFullCheckBox'
TabOrder = 7
@ -213,7 +213,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 22
Top = 284
Width = 180
Width = 172
BorderSpacing.Top = 6
Caption = 'MarkupWordNoKeyword'
TabOrder = 8
@ -225,11 +225,10 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 409
Left = 392
Height = 27
Top = 254
Width = 48
AutoSize = True
BorderSpacing.Left = 6
BorderSpacing.Top = 6
TabOrder = 9
@ -241,7 +240,7 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
Left = 0
Height = 22
Top = 228
Width = 227
Width = 219
BorderSpacing.Top = 6
Caption = 'MarkupWordNoTimerCheckBox'
TabOrder = 10
@ -249,10 +248,10 @@ inherited EditorCodetoolsOptionsFrame: TEditorCodetoolsOptionsFrame
object MarkupWordTrim: TCheckBox[18]
AnchorSideLeft.Control = MarkupWordFullLenLabel
AnchorSideTop.Control = MarkupWordNoKeyword
Left = 239
Left = 230
Height = 22
Top = 284
Width = 134
Width = 128
Caption = 'MarkupWordTrim'
TabOrder = 11
end

View File

@ -3,66 +3,66 @@
LazarusResources.Add('TEditorCodetoolsOptionsFrame','FORMDATA',[
'TPF0'#241#28'TEditorCodetoolsOptionsFrame'#27'EditorCodetoolsOptionsFrame'#6
+'Height'#3#184#1#5'Width'#3#240#1#12'ClientHeight'#3#180#1#11'ClientWidth'#3
+#236#1#8'TabOrder'#2#0#7'Visible'#8#9'DesignTop'#2#25#0#242#2#0#6'TLabel'#17
+'AutoDelayMaxLabel'#21'AnchorSideTop.Control'#7#17'AutoDelayTrackBar'#18'Anc'
+'horSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'Owner'#20'A'
+'nchorSideRight.Side'#7#9'asrBottom'#4'Left'#3'h'#1#6'Height'#2#18#3'Top'#3
+#182#0#5'Width'#3#132#0#9'Alignment'#7#14'taRightJustify'#7'Anchors'#11#5'ak'
+'Top'#7'akRight'#0#17'BorderSpacing.Top'#2#2#7'Caption'#6#17'AutoDelayMaxLab'
+'el'#11'ParentColor'#8#0#0#242#2#1#6'TLabel'#17'AutoDelayMinLabel'#22'Anchor'
+'SideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#17'AutoDelayTrackB'
+'ar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#18#3'Top'
+#3#182#0#5'Width'#3#128#0#17'BorderSpacing.Top'#2#2#7'Caption'#6#17'AutoDela'
+'yMinLabel'#11'ParentColor'#8#0#0#242#2#2#6'TLabel'#14'AutoDelayLabel'#22'An'
+'chorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#17'AutoDelayTr'
+'ackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#18#3
+'Top'#3#204#0#5'Width'#2'h'#17'BorderSpacing.Top'#2#24#7'Caption'#6#14'AutoD'
+'elayLabel'#11'ParentColor'#8#0#0#242#2#3#6'TLabel'#18'MarkupWordMinLabel'#22
+'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#22'MarkupWor'
+'dTimeTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2
+#18#3'Top'#3'b'#1#5'Width'#3#180#0#17'BorderSpacing.Top'#2#2#7'Caption'#6#23
+'MarkupWordDelayMinLabel'#11'ParentColor'#8#0#0#242#2#4#6'TLabel'#18'MarkupW'
+'ordMaxLabel'#21'AnchorSideTop.Control'#7#22'MarkupWordTimeTrackBar'#18'Anch'
+'orSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'Owner'#20'An'
+'chorSideRight.Side'#7#9'asrBottom'#4'Left'#3'4'#1#6'Height'#2#18#3'Top'#3'b'
+#1#5'Width'#3#184#0#9'Alignment'#7#14'taRightJustify'#7'Anchors'#11#5'akTop'
+#7'akRight'#0#17'BorderSpacing.Top'#2#2#7'Caption'#6#23'MarkupWordDelayMaxLa'
+'bel'#11'ParentColor'#8#0#0#242#2#5#6'TLabel'#20'MarkupWordDelayLabel'#22'An'
+'chorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#22'MarkupWordT'
+'imeTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2
+#18#3'Top'#3'x'#1#5'Width'#3#156#0#17'BorderSpacing.Top'#2#24#7'Caption'#6#20
+'MarkupWordDelayLabel'#11'ParentColor'#8#0#0#242#2#6#6'TLabel'#22'MarkupWord'
+'FullLenLabel'#22'AnchorSideLeft.Control'#7#22'MarkupWordFullCheckBox'#19'An'
+'chorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'#7#22'MarkupWord'
+'FullCheckBox'#18'AnchorSideTop.Side'#7#9'asrCenter'#23'AnchorSideRight.Cont'
+'rol'#7#21'MarkupWordFullLenSpin'#4'Left'#3#239#0#6'Height'#2#18#3'Top'#3#2#1
+#5'Width'#3#164#0#18'BorderSpacing.Left'#2'-'#17'BorderSpacing.Top'#2#6#7'Ca'
+'ption'#6#22'MarkupWordFullLenLabel'#11'ParentColor'#8#0#0#242#2#7#9'TCheckB'
+'ox AutoIdentifierCompletionCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'
+#21'AnchorSideTop.Control'#7#5'Owner'#4'Left'#2#0#6'Height'#2#22#3'Top'#2#0#5
+'Width'#3#252#0#7'Caption'#6' AutoIdentifierCompletionCheckBox'#8'TabOrder'#2
+#0#0#0#242#2#8#9'TCheckBox'#28'AutoRemoveEmptyMethodsOnSave'#22'AnchorSideLe'
+'ft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7' AutoIdentifierCompletio'
+'nCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#22
+#3'Top'#2#28#5'Width'#3#255#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#28'Auto'
+'RemoveEmptyMethodsOnSave'#8'TabOrder'#2#1#0#0#242#2#9#9'TCheckBox'#28'AutoT'
+'oolTipSymbToolsCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSid'
+'eTop.Control'#7#28'AutoRemoveEmptyMethodsOnSave'#18'AnchorSideTop.Side'#7#9
+'asrBottom'#4'Left'#2#0#6'Height'#2#22#3'Top'#2'8'#5'Width'#3#235#0#17'Borde'
+'rSpacing.Top'#2#6#7'Caption'#6#28'AutoToolTipSymbToolsCheckBox'#8'TabOrder'
+#2#2#0#0#242#2#10#9'TCheckBox'#26'AutoCodeParametersCheckBox'#22'AnchorSideL'
+'eft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#28'AutoToolTipSymbTools'
+'CheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#22#3
+'Top'#2'T'#5'Width'#3#226#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#26'AutoCo'
+'deParametersCheckBox'#7'Enabled'#8#8'TabOrder'#2#3#0#0#242#2#11#9'TCheckBox'
+#27'AutoToolTipExprEvalCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'An'
+'chorSideTop.Control'#7#26'AutoCodeParametersCheckBox'#18'AnchorSideTop.Side'
+#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#22#3'Top'#2'p'#5'Width'#3#222#0#17'B'
+'orderSpacing.Top'#2#6#7'Caption'#6#27'AutoToolTipExprEvalCheckBox'#8'TabOrd'
+'er'#2#4#0#0#242#2#12#9'TTrackBar'#17'AutoDelayTrackBar'#22'AnchorSideLeft.C'
+'ontrol'#7#5'Owner'#21'AnchorSideTop.Control'#7#27'AutoToolTipExprEvalCheckB'
+'ox'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5'O'
+'wner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2'('#3
+#236#1#8'TabOrder'#2#0#7'Visible'#8#10'DesignLeft'#3#142#1#9'DesignTop'#3'#'
+#1#0#242#2#0#6'TLabel'#17'AutoDelayMaxLabel'#21'AnchorSideTop.Control'#7#17
+'AutoDelayTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight'
+'.Control'#7#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3'm'#1
+#6'Height'#2#18#3'Top'#3#182#0#5'Width'#2''#9'Alignment'#7#14'taRightJustif'
+'y'#7'Anchors'#11#5'akTop'#7'akRight'#0#17'BorderSpacing.Top'#2#2#7'Caption'
+#6#17'AutoDelayMaxLabel'#11'ParentColor'#8#0#0#242#2#1#6'TLabel'#17'AutoDela'
+'yMinLabel'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7
+#17'AutoDelayTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'H'
+'eight'#2#18#3'Top'#3#182#0#5'Width'#2'{'#17'BorderSpacing.Top'#2#2#7'Captio'
+'n'#6#17'AutoDelayMinLabel'#11'ParentColor'#8#0#0#242#2#2#6'TLabel'#14'AutoD'
+'elayLabel'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7
+#17'AutoDelayTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'H'
+'eight'#2#18#3'Top'#3#204#0#5'Width'#2'e'#17'BorderSpacing.Top'#2#24#7'Capti'
+'on'#6#14'AutoDelayLabel'#11'ParentColor'#8#0#0#242#2#3#6'TLabel'#18'MarkupW'
+'ordMinLabel'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'
+#7#22'MarkupWordTimeTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2
+#0#6'Height'#2#18#3'Top'#3'b'#1#5'Width'#3#171#0#17'BorderSpacing.Top'#2#2#7
+'Caption'#6#23'MarkupWordDelayMinLabel'#11'ParentColor'#8#0#0#242#2#4#6'TLab'
+'el'#18'MarkupWordMaxLabel'#21'AnchorSideTop.Control'#7#22'MarkupWordTimeTra'
+'ckBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5
+'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3'='#1#6'Height'#2#18
+#3'Top'#3'b'#1#5'Width'#3#175#0#9'Alignment'#7#14'taRightJustify'#7'Anchors'
+#11#5'akTop'#7'akRight'#0#17'BorderSpacing.Top'#2#2#7'Caption'#6#23'MarkupWo'
+'rdDelayMaxLabel'#11'ParentColor'#8#0#0#242#2#5#6'TLabel'#20'MarkupWordDelay'
+'Label'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#22
+'MarkupWordTimeTrackBar'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6
+'Height'#2#18#3'Top'#3'x'#1#5'Width'#3#149#0#17'BorderSpacing.Top'#2#24#7'Ca'
+'ption'#6#20'MarkupWordDelayLabel'#11'ParentColor'#8#0#0#242#2#6#6'TLabel'#22
+'MarkupWordFullLenLabel'#22'AnchorSideLeft.Control'#7#22'MarkupWordFullCheck'
+'Box'#19'AnchorSideLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'#7#22
+'MarkupWordFullCheckBox'#18'AnchorSideTop.Side'#7#9'asrCenter'#23'AnchorSide'
+'Right.Control'#7#21'MarkupWordFullLenSpin'#4'Left'#3#230#0#6'Height'#2#18#3
+'Top'#3#2#1#5'Width'#3#156#0#18'BorderSpacing.Left'#2'-'#17'BorderSpacing.To'
+'p'#2#6#7'Caption'#6#22'MarkupWordFullLenLabel'#11'ParentColor'#8#0#0#242#2#7
+#9'TCheckBox AutoIdentifierCompletionCheckBox'#22'AnchorSideLeft.Control'#7#5
+'Owner'#21'AnchorSideTop.Control'#7#5'Owner'#4'Left'#2#0#6'Height'#2#22#3'To'
+'p'#2#0#5'Width'#3#245#0#7'Caption'#6' AutoIdentifierCompletionCheckBox'#8'T'
+'abOrder'#2#0#0#0#242#2#8#9'TCheckBox'#28'AutoRemoveEmptyMethodsOnSave'#22'A'
+'nchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7' AutoIdentifi'
+'erCompletionCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'H'
+'eight'#2#22#3'Top'#2#28#5'Width'#3#251#0#17'BorderSpacing.Top'#2#6#7'Captio'
+'n'#6#28'AutoRemoveEmptyMethodsOnSave'#8'TabOrder'#2#1#0#0#242#2#9#9'TCheckB'
+'ox'#28'AutoToolTipSymbToolsCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'
+#21'AnchorSideTop.Control'#7#28'AutoRemoveEmptyMethodsOnSave'#18'AnchorSideT'
+'op.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#22#3'Top'#2'8'#5'Width'#3
+#227#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#28'AutoToolTipSymbToolsCheckBo'
+'x'#8'TabOrder'#2#2#0#0#242#2#10#9'TCheckBox'#25'AutoCompleteBlockCheckBox'
+#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#28'AutoTo'
+'olTipSymbToolsCheckBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6
+'Height'#2#22#3'Top'#2'T'#5'Width'#3#213#0#17'BorderSpacing.Top'#2#6#7'Capti'
+'on'#6#25'AutoCompleteBlockCheckBox'#8'TabOrder'#2#3#0#0#242#2#11#9'TCheckBo'
+'x'#27'AutoToolTipExprEvalCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21
+'AnchorSideTop.Control'#7#25'AutoCompleteBlockCheckBox'#18'AnchorSideTop.Sid'
+'e'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#22#3'Top'#2'p'#5'Width'#3#213#0#17
+'BorderSpacing.Top'#2#6#7'Caption'#6#27'AutoToolTipExprEvalCheckBox'#8'TabOr'
+'der'#2#4#0#0#242#2#12#9'TTrackBar'#17'AutoDelayTrackBar'#22'AnchorSideLeft.'
+'Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#27'AutoToolTipExprEvalCheck'
+'Box'#18'AnchorSideTop.Side'#7#9'asrBottom'#23'AnchorSideRight.Control'#7#5
+'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2'('#3
+'Top'#3#140#0#5'Width'#3#236#1#9'Frequency'#3#250#0#3'Max'#3#160#15#3'Min'#3
+#244#1#8'Position'#3#244#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#17
,'BorderSpacing.Top'#2#6#8'TabOrder'#2#5#0#0#242#2#13#9'TTrackBar'#22'MarkupW'
@ -75,24 +75,24 @@ LazarusResources.Add('TEditorCodetoolsOptionsFrame','FORMDATA',[
+#9'TCheckBox'#22'MarkupWordFullCheckBox'#22'AnchorSideLeft.Control'#7#5'Owne'
+'r'#21'AnchorSideTop.Control'#7#25'MarkupWordNoTimerCheckBox'#18'AnchorSideT'
+'op.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#22#3'Top'#3#0#1#5'Width'#3
+#194#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#22'MarkupWordFullCheckBox'#8'T'
+#185#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#22'MarkupWordFullCheckBox'#8'T'
+'abOrder'#2#7#0#0#242#2#15#9'TCheckBox'#19'MarkupWordNoKeyword'#22'AnchorSid'
+'eLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#22'MarkupWordFullChec'
+'kBox'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'#2#22#3'To'
+'p'#3#28#1#5'Width'#3#180#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#19'Markup'
+'p'#3#28#1#5'Width'#3#172#0#17'BorderSpacing.Top'#2#6#7'Caption'#6#19'Markup'
+'WordNoKeyword'#8'TabOrder'#2#8#0#0#242#2#16#9'TSpinEdit'#21'MarkupWordFullL'
+'enSpin'#22'AnchorSideLeft.Control'#7#22'MarkupWordFullLenLabel'#19'AnchorSi'
+'deLeft.Side'#7#9'asrBottom'#21'AnchorSideTop.Control'#7#22'MarkupWordFullLe'
+'nLabel'#18'AnchorSideTop.Side'#7#9'asrCenter'#23'AnchorSideRight.Control'#7
+#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#153#1#6'Height'#2
+#27#3'Top'#3#254#0#5'Width'#2'0'#8'AutoSize'#9#18'BorderSpacing.Left'#2#6#17
+'BorderSpacing.Top'#2#6#8'TabOrder'#2#9#0#0#242#2#17#9'TCheckBox'#25'MarkupW'
+'ordNoTimerCheckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.'
+'Control'#7#14'AutoDelayLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'
+#2#0#6'Height'#2#22#3'Top'#3#228#0#5'Width'#3#227#0#17'BorderSpacing.Top'#2#6
+#7'Caption'#6#25'MarkupWordNoTimerCheckBox'#8'TabOrder'#2#10#0#0#242#2#18#9
+'TCheckBox'#14'MarkupWordTrim'#22'AnchorSideLeft.Control'#7#22'MarkupWordFul'
+'lLenLabel'#21'AnchorSideTop.Control'#7#19'MarkupWordNoKeyword'#4'Left'#3#239
+#0#6'Height'#2#22#3'Top'#3#28#1#5'Width'#3#134#0#7'Caption'#6#14'MarkupWordT'
+'rim'#8'TabOrder'#2#11#0#0#0
+#5'Owner'#20'AnchorSideRight.Side'#7#9'asrBottom'#4'Left'#3#136#1#6'Height'#2
+#27#3'Top'#3#254#0#5'Width'#2'0'#18'BorderSpacing.Left'#2#6#17'BorderSpacing'
+'.Top'#2#6#8'TabOrder'#2#9#0#0#242#2#17#9'TCheckBox'#25'MarkupWordNoTimerChe'
+'ckBox'#22'AnchorSideLeft.Control'#7#5'Owner'#21'AnchorSideTop.Control'#7#14
+'AutoDelayLabel'#18'AnchorSideTop.Side'#7#9'asrBottom'#4'Left'#2#0#6'Height'
+#2#22#3'Top'#3#228#0#5'Width'#3#219#0#17'BorderSpacing.Top'#2#6#7'Caption'#6
+#25'MarkupWordNoTimerCheckBox'#8'TabOrder'#2#10#0#0#242#2#18#9'TCheckBox'#14
+'MarkupWordTrim'#22'AnchorSideLeft.Control'#7#22'MarkupWordFullLenLabel'#21
+'AnchorSideTop.Control'#7#19'MarkupWordNoKeyword'#4'Left'#3#230#0#6'Height'#2
+#22#3'Top'#3#28#1#5'Width'#3#128#0#7'Caption'#6#14'MarkupWordTrim'#8'TabOrde'
+'r'#2#11#0#0#0
]);

View File

@ -32,7 +32,7 @@ type
{ TEditorCodetoolsOptionsFrame }
TEditorCodetoolsOptionsFrame = class(TAbstractIDEOptionsEditor)
AutoCodeParametersCheckBox: TCheckBox;
AutoCompleteBlockCheckBox: TCheckBox;
AutoDelayLabel: TLabel;
AutoDelayMaxLabel: TLabel;
AutoDelayMinLabel: TLabel;
@ -73,7 +73,7 @@ end;
procedure TEditorCodetoolsOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog);
begin
AutoIdentifierCompletionCheckBox.Caption := dlgEdIdComlet;
AutoCodeParametersCheckBox.Caption := dlgEdCodeParams;
AutoCompleteBlockCheckBox.Caption := dlgEdCompleteBlocks;
AutoToolTipExprEvalCheckBox.Caption := dlgTooltipEval;
AutoToolTipSymbToolsCheckBox.Caption := dlgTooltipTools;
AutoRemoveEmptyMethodsOnSave.Caption := dlgAutoRemoveEmptyMethods;
@ -97,7 +97,7 @@ begin
with AOptions as TEditorOptions do
begin
AutoIdentifierCompletionCheckBox.Checked := AutoIdentifierCompletion;
AutoCodeParametersCheckBox.Checked := AutoCodeParameters;
AutoCompleteBlockCheckBox.Checked := AutoBlockCompletion;
AutoToolTipExprEvalCheckBox.Checked := AutoToolTipExprEval;
AutoToolTipSymbToolsCheckBox.Checked := AutoToolTipSymbTools;
AutoDelayTrackBar.Position := AutoDelayInMSec;
@ -116,7 +116,7 @@ begin
with AOptions as TEditorOptions do
begin
AutoIdentifierCompletion := AutoIdentifierCompletionCheckBox.Checked;
AutoCodeParameters := AutoCodeParametersCheckBox.Checked;
AutoBlockCompletion := AutoCompleteBlockCheckBox.Checked;
AutoToolTipExprEval := AutoToolTipExprEvalCheckBox.Checked;
AutoToolTipSymbTools := AutoToolTipSymbToolsCheckBox.Checked;
AutoDelayInMSec := AutoDelayTrackBar.Position;

View File

@ -1222,7 +1222,7 @@ resourcestring
dlgEdOff = 'Off';
dlgEdInvert = 'Invert';
dlgEdIdComlet = 'Identifier completion';
dlgEdCodeParams = 'Code parameters';
dlgEdCompleteBlocks = 'Complete blocks';
dlgTooltipEval = 'Tooltip expression evaluation';
dlgTooltipTools = 'Tooltip symbol Tools';
dlgMarkupWordFull = 'Current Word match word boundaries';

View File

@ -1550,10 +1550,8 @@ begin
if AutoCompleteChar(aChar,AddChar,acoLineBreak) then ;
//DebugLn(['TSourceEditor.ProcessCommand ecLineBreak AddChar=',AddChar]);
if not AddChar then Command:=ecNone;
{$IFDEF EnableCompleteBlock}
if EditorOpts.AutoBlockCompletion then
AutoCompleteBlock;
{$ENDIF}
end;
ecPrevBookmark: // Note: book mark commands lower than ecUserFirst must be handled here
@ -2342,10 +2340,21 @@ var
begin
if not LazarusIDE.SaveSourceEditorChangesToCodeCache(PageIndex) then exit;
XY:=FEditor.LogicalCaretXY;
if not CodeToolBoss.CompleteBlock(CodeBuffer,XY.X,XY.Y,
NewCode,NewX,NewY,NewTopLine) then exit;
if (NewCode<>CodeBuffer) or (NewX<>XY.X) or (NewY<>XY.Y) or (NewTopLine>0)
then ;
FEditor.BeginUndoBlock;
try
if not CodeToolBoss.CompleteBlock(CodeBuffer,XY.X,XY.Y,
NewCode,NewX,NewY,NewTopLine) then exit;
XY:=FEditor.LogicalCaretXY;
//DebugLn(['TSourceEditor.AutoCompleteBlock XY=',dbgs(XY),' NewX=',NewX,' NewY=',NewY]);
if (NewCode<>CodeBuffer) or (NewX<>XY.X) or (NewY<>XY.Y) or (NewTopLine>0)
then begin
XY.X:=NewX;
XY.Y:=NewY;
FEditor.LogicalCaretXY:=XY;
end;
finally
FEditor.EndUndoBlock;
end;
end;
Procedure TSourceEditor.CreateEditor(AOwner: TComponent; AParent: TWinControl);