mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 19:19:18 +02:00
ident compl: added sorting, ignoring redefinitions, brackets, properties
git-svn-id: trunk@3025 -
This commit is contained in:
parent
eebaf92196
commit
e40d873bd1
@ -2294,12 +2294,40 @@ end;
|
|||||||
procedure TSourceNotebook.ccComplete(var Value: ansistring; Shift: TShiftState);
|
procedure TSourceNotebook.ccComplete(var Value: ansistring; Shift: TShiftState);
|
||||||
// completion selected -> deactivate completion form
|
// completion selected -> deactivate completion form
|
||||||
// Called when user has selected a completion item
|
// Called when user has selected a completion item
|
||||||
|
|
||||||
|
function CharBehindIdent(const Line: string; StartPos: integer): char;
|
||||||
|
begin
|
||||||
|
while (StartPos<=length(Line))
|
||||||
|
and (Line[StartPos] in ['_','A'..'Z','a'..'z']) do
|
||||||
|
inc(StartPos);
|
||||||
|
while (StartPos<=length(Line)) and (Line[StartPos] in [' ',#9]) do
|
||||||
|
inc(StartPos);
|
||||||
|
if StartPos<=length(Line) then
|
||||||
|
Result:=Line[StartPos]
|
||||||
|
else
|
||||||
|
Result:=#0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function CharInFrontOfIdent(const Line: string; StartPos: integer): char;
|
||||||
|
begin
|
||||||
|
while (StartPos>=1)
|
||||||
|
and (Line[StartPos] in ['_','A'..'Z','a'..'z']) do
|
||||||
|
dec(StartPos);
|
||||||
|
while (StartPos>=1) and (Line[StartPos] in [' ',#9]) do
|
||||||
|
dec(StartPos);
|
||||||
|
if StartPos>=1 then
|
||||||
|
Result:=Line[StartPos]
|
||||||
|
else
|
||||||
|
Result:=#0;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
p1, p2: integer;
|
p1, p2: integer;
|
||||||
ValueType: TIdentComplValue;
|
ValueType: TIdentComplValue;
|
||||||
SrcEdit: TSourceEditor;
|
SrcEdit: TSourceEditor;
|
||||||
NewValue: string;
|
NewValue: string;
|
||||||
CaretXY: TPoint;
|
CaretXY: TPoint;
|
||||||
|
Line: string;
|
||||||
Begin
|
Begin
|
||||||
if CurCompletionControl=nil then exit;
|
if CurCompletionControl=nil then exit;
|
||||||
case CurrentCompletionType of
|
case CurrentCompletionType of
|
||||||
@ -2309,19 +2337,24 @@ Begin
|
|||||||
// add to history
|
// add to history
|
||||||
CodeToolBoss.IdentifierHistory.Add(
|
CodeToolBoss.IdentifierHistory.Add(
|
||||||
CodeToolBoss.IdentifierList.FilteredItems[aCompletion.Position]);
|
CodeToolBoss.IdentifierList.FilteredItems[aCompletion.Position]);
|
||||||
|
SrcEdit:=GetActiveSE;
|
||||||
|
Line:=SrcEdit.EditorComponent.LineText;
|
||||||
|
CaretXY:=SrcEdit.EditorComponent.BlockBegin;
|
||||||
NewValue:=GetIdentCompletionValue(aCompletion,ValueType);
|
NewValue:=GetIdentCompletionValue(aCompletion,ValueType);
|
||||||
|
|
||||||
// ToDo: check if there is no @ in front and no bracket behind
|
|
||||||
|
|
||||||
case ValueType of
|
case ValueType of
|
||||||
icvProcWithParams:
|
icvProcWithParams:
|
||||||
|
if (CharBehindIdent(Line,CaretXY.X)<>'(')
|
||||||
|
and (CharInFrontOfIdent(Line,CaretXY.X)<>'@')
|
||||||
|
then
|
||||||
NewValue:=NewValue+'()';
|
NewValue:=NewValue+'()';
|
||||||
icvIndexedProp:
|
icvIndexedProp:
|
||||||
|
if (CharBehindIdent(Line,CaretXY.X)<>'[')
|
||||||
|
then
|
||||||
NewValue:=NewValue+'[]';
|
NewValue:=NewValue+'[]';
|
||||||
end;
|
end;
|
||||||
SrcEdit:=GetActiveSE;
|
|
||||||
SrcEdit.EditorComponent.SelText:=NewValue;
|
SrcEdit.EditorComponent.SelText:=NewValue;
|
||||||
if ValueType in [icvProcWithParams,icvIndexedProp] then begin
|
if (NewValue<>'') and (NewValue[length(NewValue)] in [')',']']) then
|
||||||
|
begin
|
||||||
CaretXY:=SrcEdit.EditorComponent.BlockEnd;
|
CaretXY:=SrcEdit.EditorComponent.BlockEnd;
|
||||||
dec(CaretXY.X);
|
dec(CaretXY.X);
|
||||||
SrcEdit.EditorComponent.CaretXY:=CaretXY;
|
SrcEdit.EditorComponent.CaretXY:=CaretXY;
|
||||||
|
Loading…
Reference in New Issue
Block a user