mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-12 17:19:30 +01:00
IDE: started block completion on char
git-svn-id: trunk@25556 -
This commit is contained in:
parent
b325a63d27
commit
331b05a147
@ -363,6 +363,7 @@ type
|
|||||||
function GuessUnclosedBlock(Code: TCodeBuffer; X,Y: integer;
|
function GuessUnclosedBlock(Code: TCodeBuffer; X,Y: integer;
|
||||||
out NewCode: TCodeBuffer;
|
out NewCode: TCodeBuffer;
|
||||||
out NewX, NewY, NewTopLine: integer): boolean;
|
out NewX, NewY, NewTopLine: integer): boolean;
|
||||||
|
function CompleteBlock(Code: TCodeBuffer; X,Y: integer): boolean;
|
||||||
function CompleteBlock(Code: TCodeBuffer; X,Y: integer;
|
function CompleteBlock(Code: TCodeBuffer; X,Y: integer;
|
||||||
out NewCode: TCodeBuffer;
|
out NewCode: TCodeBuffer;
|
||||||
out NewX, NewY, NewTopLine: integer): boolean;
|
out NewX, NewY, NewTopLine: integer): boolean;
|
||||||
@ -3111,6 +3112,16 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCodeToolManager.CompleteBlock(Code: TCodeBuffer; X, Y: integer
|
||||||
|
): boolean;
|
||||||
|
var
|
||||||
|
NewCode: TCodeBuffer;
|
||||||
|
NewX, NewY, NewTopLine: integer;
|
||||||
|
begin
|
||||||
|
Result:=CompleteBlock(Code,X,Y,NewCode,NewX,NewY,NewTopLine);
|
||||||
|
if (NewCode=nil) and (NewX<0) and (NewY<0) and (NewTopLine<1) then ;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCodeToolManager.CompleteBlock(Code: TCodeBuffer; X, Y: integer; out
|
function TCodeToolManager.CompleteBlock(Code: TCodeBuffer; X, Y: integer; out
|
||||||
NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer): boolean;
|
NewCode: TCodeBuffer; out NewX, NewY, NewTopLine: integer): boolean;
|
||||||
var
|
var
|
||||||
|
|||||||
@ -5598,7 +5598,7 @@ var
|
|||||||
Indent: Integer;
|
Indent: Integer;
|
||||||
CursorBlockInnerIndent, CursorBlockOuterIndent: LongInt;
|
CursorBlockInnerIndent, CursorBlockOuterIndent: LongInt;
|
||||||
CursorBlock: TBlock;
|
CursorBlock: TBlock;
|
||||||
BehindCursorBlock: Boolean; // atom behind cursor block
|
BehindCursorBlock: Boolean; // atom is behind cursor block
|
||||||
InCursorBlock: Boolean;
|
InCursorBlock: Boolean;
|
||||||
NeedCompletion: Boolean;
|
NeedCompletion: Boolean;
|
||||||
InsertPos: LongInt;
|
InsertPos: LongInt;
|
||||||
@ -5857,7 +5857,6 @@ var
|
|||||||
InCursorBlock:=(CursorBlockLvl>=0) and (CursorBlockLvl=Stack.Top)
|
InCursorBlock:=(CursorBlockLvl>=0) and (CursorBlockLvl=Stack.Top)
|
||||||
and (not BehindCursorBlock);
|
and (not BehindCursorBlock);
|
||||||
if LineStart and InCursorBlock then begin
|
if LineStart and InCursorBlock then begin
|
||||||
Indent:=GetLineIndent(Src,CurPos.StartPos);
|
|
||||||
// atom is in same block as cursor (not sub block)
|
// atom is in same block as cursor (not sub block)
|
||||||
// and first atom of a line
|
// and first atom of a line
|
||||||
// => check indent
|
// => check indent
|
||||||
|
|||||||
@ -40,9 +40,9 @@ uses
|
|||||||
{$IFDEF IDE_MEM_CHECK}
|
{$IFDEF IDE_MEM_CHECK}
|
||||||
MemCheck,
|
MemCheck,
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, Math, Controls, LCLProc, LCLType, LResources, LCLIntf,
|
Classes, SysUtils, Math, Controls, LCLProc, LCLType, LResources,
|
||||||
FileUtil, Forms, ComCtrls, Dialogs, StdCtrls, Graphics,
|
LCLIntf, FileUtil, Forms, ComCtrls, Dialogs, StdCtrls, Graphics, Translations,
|
||||||
Translations, ClipBrd, types, Extctrls, Menus, HelpIntfs, LConvEncoding, LDockCtrl,
|
ClipBrd, types, Extctrls, Menus, HelpIntfs, LConvEncoding, LDockCtrl,
|
||||||
// codetools
|
// codetools
|
||||||
BasicCodeTools, CodeBeautifier, CodeToolManager, CodeCache, SourceLog,
|
BasicCodeTools, CodeBeautifier, CodeToolManager, CodeCache, SourceLog,
|
||||||
// synedit
|
// synedit
|
||||||
@ -284,6 +284,7 @@ type
|
|||||||
Category: TAutoCompleteOption): boolean;
|
Category: TAutoCompleteOption): boolean;
|
||||||
function AutoBlockCompleteChar(Char: TUTF8Char; var AddChar: boolean;
|
function AutoBlockCompleteChar(Char: TUTF8Char; var AddChar: boolean;
|
||||||
Category: TAutoCompleteOption; aTextPos: TPoint; Line: string): boolean;
|
Category: TAutoCompleteOption; aTextPos: TPoint; Line: string): boolean;
|
||||||
|
function AutoBlockCompleteChar(Char: TUTF8Char): boolean;
|
||||||
procedure AutoCompleteBlock;
|
procedure AutoCompleteBlock;
|
||||||
|
|
||||||
procedure FocusEditor;// called by TSourceNotebook when the Notebook page
|
procedure FocusEditor;// called by TSourceNotebook when the Notebook page
|
||||||
@ -3015,6 +3016,12 @@ begin
|
|||||||
|
|
||||||
ecNone: ;
|
ecNone: ;
|
||||||
|
|
||||||
|
ecChar:
|
||||||
|
begin
|
||||||
|
if AutoBlockCompleteChar(AChar) then
|
||||||
|
Handled:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
Handled:=false;
|
Handled:=false;
|
||||||
@ -3778,6 +3785,36 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TSourceEditor.AutoBlockCompleteChar(Char: TUTF8Char): boolean;
|
||||||
|
var
|
||||||
|
p: TPoint;
|
||||||
|
x1: integer;
|
||||||
|
x2: integer;
|
||||||
|
Line: String;
|
||||||
|
WordToken: String;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if (not EditorOpts.AutoBlockCompletion)
|
||||||
|
or (not (SyntaxHighlighterType in [lshFreePascal,lshDelphi])) then
|
||||||
|
exit;
|
||||||
|
if (Char='n') or (Char='N') then begin
|
||||||
|
p:=GetCursorTextXY;
|
||||||
|
FEditor.GetWordBoundsAtRowCol(p, x1, x2);
|
||||||
|
Line:=GetLineText;
|
||||||
|
WordToken := copy(Line, x1, x2-x1);
|
||||||
|
if SysUtils.CompareText(WordToken,'begin')<>0 then exit;
|
||||||
|
debugln(['TSourceEditor.AutoBlockCompleteChar ']);
|
||||||
|
// user typed 'begin'
|
||||||
|
if not LazarusIDE.SaveSourceEditorChangesToCodeCache(self) then exit;
|
||||||
|
{FEditor.BeginUndoBlock;
|
||||||
|
try
|
||||||
|
if not CodeToolBoss.CompleteBlock(CodeBuffer,p.X,p.Y) then exit;
|
||||||
|
finally
|
||||||
|
FEditor.EndUndoBlock;
|
||||||
|
end;}
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.AutoCompleteBlock;
|
procedure TSourceEditor.AutoCompleteBlock;
|
||||||
var
|
var
|
||||||
XY: TPoint;
|
XY: TPoint;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user