mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-05 01:35:58 +02:00
IDE: identifier completion: use word completion if not in pascal source
git-svn-id: trunk@23501 -
This commit is contained in:
parent
9e02d5824f
commit
742caab46a
@ -222,6 +222,7 @@ type
|
|||||||
procedure OnCodeBufferChanged(Sender: TSourceLog;
|
procedure OnCodeBufferChanged(Sender: TSourceLog;
|
||||||
SrcLogEntry: TSourceLogEntry);
|
SrcLogEntry: TSourceLogEntry);
|
||||||
procedure StartIdentCompletionBox(JumpToError: boolean);
|
procedure StartIdentCompletionBox(JumpToError: boolean);
|
||||||
|
procedure StartWordCompletionBox(JumpToError: boolean);
|
||||||
|
|
||||||
procedure LinesInserted(sender: TObject; FirstLine, Count: Integer);
|
procedure LinesInserted(sender: TObject; FirstLine, Count: Integer);
|
||||||
procedure LinesDeleted(sender: TObject; FirstLine, Count: Integer);
|
procedure LinesDeleted(sender: TObject; FirstLine, Count: Integer);
|
||||||
@ -656,7 +657,8 @@ type
|
|||||||
procedure OnSynCompletionUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
procedure OnSynCompletionUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
|
||||||
procedure OnSynCompletionPositionChanged(Sender: TObject);
|
procedure OnSynCompletionPositionChanged(Sender: TObject);
|
||||||
function StartIdentCompletionBox(SrcEdit: TSourceEditor; JumpToError: boolean;
|
function StartIdentCompletionBox(SrcEdit: TSourceEditor; JumpToError: boolean;
|
||||||
var s: string; var BoxX, BoxY: integer): boolean;
|
var s: string; var BoxX, BoxY: integer;
|
||||||
|
var UseWordCompletion: boolean): boolean;
|
||||||
function InitIdentCompletionValues(S: TStrings): boolean;
|
function InitIdentCompletionValues(S: TStrings): boolean;
|
||||||
|
|
||||||
procedure EditorMouseMove(Sender: TObject; Shift: TShiftstate;
|
procedure EditorMouseMove(Sender: TObject; Shift: TShiftstate;
|
||||||
@ -1706,11 +1708,7 @@ Procedure TSourceEditor.ProcessUserCommand(Sender: TObject;
|
|||||||
// these are the keys above ecUserFirst
|
// these are the keys above ecUserFirst
|
||||||
// define all extra keys here, that should not be handled by synedit
|
// define all extra keys here, that should not be handled by synedit
|
||||||
var
|
var
|
||||||
I: Integer;
|
|
||||||
P: TPoint;
|
|
||||||
Texts, Texts2: String;
|
|
||||||
Handled: boolean;
|
Handled: boolean;
|
||||||
LogCaret: TPoint;
|
|
||||||
Begin
|
Begin
|
||||||
//debugln('TSourceEditor.ProcessUserCommand A ',dbgs(Command));
|
//debugln('TSourceEditor.ProcessUserCommand A ',dbgs(Command));
|
||||||
Handled:=true;
|
Handled:=true;
|
||||||
@ -1727,27 +1725,7 @@ Begin
|
|||||||
SourceNotebook.StartShowCodeContext(true);
|
SourceNotebook.StartShowCodeContext(true);
|
||||||
|
|
||||||
ecWordCompletion :
|
ecWordCompletion :
|
||||||
if not TCustomSynEdit(Sender).ReadOnly then begin
|
StartWordCompletionBox(true);
|
||||||
SourceNotebook.CreateCompletionForm;
|
|
||||||
CurrentCompletionType:=ctWordCompletion;
|
|
||||||
TextS := FEditor.LineText;
|
|
||||||
LogCaret:=FEditor.LogicalCaretXY;
|
|
||||||
i := LogCaret.X - 1;
|
|
||||||
if i > length(TextS) then
|
|
||||||
TextS2 := ''
|
|
||||||
else begin
|
|
||||||
while (i > 0) and (TextS[i] in ['a'..'z','A'..'Z','0'..'9','_']) do
|
|
||||||
dec(i);
|
|
||||||
TextS2 := Trim(copy(TextS, i + 1, LogCaret.X - i - 1));
|
|
||||||
end;
|
|
||||||
with TCustomSynEdit(Sender) do begin
|
|
||||||
P := Point(CaretXPix - length(TextS2)*CharWidth,CaretYPix + LineHeight + 1);
|
|
||||||
P.X:=Max(0,Min(P.X,ClientWidth-aCompletion.Width));
|
|
||||||
P := ClientToScreen(p);
|
|
||||||
end;
|
|
||||||
aCompletion.Editor:=TCustomSynEdit(Sender);
|
|
||||||
aCompletion.Execute(TextS2,P.X,P.Y);
|
|
||||||
end;
|
|
||||||
|
|
||||||
ecFind:
|
ecFind:
|
||||||
StartFindAndReplace(false);
|
StartFindAndReplace(false);
|
||||||
@ -2793,6 +2771,7 @@ var
|
|||||||
P: TPoint;
|
P: TPoint;
|
||||||
TextS, TextS2: String;
|
TextS, TextS2: String;
|
||||||
LogCaret: TPoint;
|
LogCaret: TPoint;
|
||||||
|
UseWordCompletion: Boolean;
|
||||||
begin
|
begin
|
||||||
{$IFDEF VerboseIDECompletionBox}
|
{$IFDEF VerboseIDECompletionBox}
|
||||||
debugln(['TSourceEditor.StartIdentCompletionBox JumpToError: ',JumpToError]);
|
debugln(['TSourceEditor.StartIdentCompletionBox JumpToError: ',JumpToError]);
|
||||||
@ -2818,9 +2797,12 @@ begin
|
|||||||
P.X:=Max(0,Min(P.X,ClientWidth-aCompletion.Width));
|
P.X:=Max(0,Min(P.X,ClientWidth-aCompletion.Width));
|
||||||
P := ClientToScreen(p);
|
P := ClientToScreen(p);
|
||||||
end;
|
end;
|
||||||
|
UseWordCompletion:=false;
|
||||||
if not SourceNotebook.StartIdentCompletionBox(Self,JumpToError,TextS2,
|
if not SourceNotebook.StartIdentCompletionBox(Self,JumpToError,TextS2,
|
||||||
P.X,P.Y)
|
P.X,P.Y,UseWordCompletion)
|
||||||
then exit;
|
then exit;
|
||||||
|
if UseWordCompletion then
|
||||||
|
CurrentCompletionType:=ctWordCompletion;
|
||||||
|
|
||||||
aCompletion.Execute(TextS2,P.X,P.Y);
|
aCompletion.Execute(TextS2,P.X,P.Y);
|
||||||
{$IFDEF VerboseIDECompletionBox}
|
{$IFDEF VerboseIDECompletionBox}
|
||||||
@ -2828,6 +2810,37 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TSourceEditor.StartWordCompletionBox(JumpToError: boolean);
|
||||||
|
var
|
||||||
|
TextS: String;
|
||||||
|
LogCaret: TPoint;
|
||||||
|
i: Integer;
|
||||||
|
TextS2: String;
|
||||||
|
P: TPoint;
|
||||||
|
begin
|
||||||
|
if (FEditor.ReadOnly) or (CurrentCompletionType<>ctNone) then exit;
|
||||||
|
SourceNotebook.CreateCompletionForm;
|
||||||
|
CurrentCompletionType:=ctWordCompletion;
|
||||||
|
TextS := FEditor.LineText;
|
||||||
|
LogCaret:=FEditor.LogicalCaretXY;
|
||||||
|
aCompletion.Editor:=FEditor;
|
||||||
|
aCompletion.TheForm.Font := FEditor.Font;
|
||||||
|
i := LogCaret.X - 1;
|
||||||
|
if i > length(TextS) then
|
||||||
|
TextS2 := ''
|
||||||
|
else begin
|
||||||
|
while (i > 0) and (TextS[i] in ['a'..'z','A'..'Z','0'..'9','_']) do
|
||||||
|
dec(i);
|
||||||
|
TextS2 := Trim(copy(TextS, i + 1, LogCaret.X - i - 1));
|
||||||
|
end;
|
||||||
|
with FEditor do begin
|
||||||
|
P := Point(CaretXPix - length(TextS2)*CharWidth,CaretYPix + LineHeight + 1);
|
||||||
|
P.X:=Max(0,Min(P.X,ClientWidth-aCompletion.Width));
|
||||||
|
P := ClientToScreen(p);
|
||||||
|
end;
|
||||||
|
aCompletion.Execute(TextS2,P.X,P.Y);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TSourceEditor.IncreaseIgnoreCodeBufferLock;
|
procedure TSourceEditor.IncreaseIgnoreCodeBufferLock;
|
||||||
begin
|
begin
|
||||||
inc(FIgnoreCodeBufferLock);
|
inc(FIgnoreCodeBufferLock);
|
||||||
@ -4176,7 +4189,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TSourceNotebook.StartIdentCompletionBox(SrcEdit: TSourceEditor;
|
function TSourceNotebook.StartIdentCompletionBox(SrcEdit: TSourceEditor;
|
||||||
JumpToError: boolean; var s: string; var BoxX, BoxY: integer): boolean;
|
JumpToError: boolean; var s: string; var BoxX, BoxY: integer;
|
||||||
|
var UseWordCompletion: boolean): boolean;
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
Plugin: TSourceEditorCompletionPlugin;
|
Plugin: TSourceEditorCompletionPlugin;
|
||||||
@ -4197,6 +4211,9 @@ begin
|
|||||||
exit(true);
|
exit(true);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if not (SrcEdit.SyntaxHighlighterType in [lshFreePascal, lshDelphi]) then
|
||||||
|
UseWordCompletion:=true;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user