mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 16:20:35 +02:00
IDE: word+identifier completion: toggle replace word or left side on shift
git-svn-id: trunk@52868 -
This commit is contained in:
parent
2be768995c
commit
b26152988c
@ -368,6 +368,7 @@ type
|
|||||||
FExecCommandID: TSynEditorCommand;
|
FExecCommandID: TSynEditorCommand;
|
||||||
FEndOfTokenChr: string;
|
FEndOfTokenChr: string;
|
||||||
FOnCodeCompletion: TCodeCompletionEvent;
|
FOnCodeCompletion: TCodeCompletionEvent;
|
||||||
|
FToggleReplacesWhole: boolean;
|
||||||
procedure Cancel(Sender: TObject);
|
procedure Cancel(Sender: TObject);
|
||||||
procedure Validate(Sender: TObject; KeyChar: TUTF8Char; Shift: TShiftState);
|
procedure Validate(Sender: TObject; KeyChar: TUTF8Char; Shift: TShiftState);
|
||||||
function GetPreviousToken(FEditor: TCustomSynEdit): string;
|
function GetPreviousToken(FEditor: TCustomSynEdit): string;
|
||||||
@ -397,6 +398,7 @@ type
|
|||||||
read FOnCodeCompletion write FOnCodeCompletion;
|
read FOnCodeCompletion write FOnCodeCompletion;
|
||||||
property ExecCommandID: TSynEditorCommand read FExecCommandID write FExecCommandID;
|
property ExecCommandID: TSynEditorCommand read FExecCommandID write FExecCommandID;
|
||||||
property Editor;
|
property Editor;
|
||||||
|
property ToggleReplaceWhole: boolean read FToggleReplacesWhole write FToggleReplacesWhole;// false=shift replaces left side, true=shift replaces whole word
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TSynAutoComplete }
|
{ TSynAutoComplete }
|
||||||
@ -1761,10 +1763,7 @@ begin
|
|||||||
do
|
do
|
||||||
dec(NewBlockBegin.X);
|
dec(NewBlockBegin.X);
|
||||||
//BlockBegin:=NewBlockBegin;
|
//BlockBegin:=NewBlockBegin;
|
||||||
if ssShift in Shift then begin
|
if (ssShift in Shift)=ToggleReplaceWhole then begin
|
||||||
// replace only prefix
|
|
||||||
NewBlockEnd := LogCaret;
|
|
||||||
end else begin
|
|
||||||
// replace the whole word
|
// replace the whole word
|
||||||
NewBlockEnd := LogCaret;
|
NewBlockEnd := LogCaret;
|
||||||
CurLine:=Lines[NewBlockEnd.Y - 1];
|
CurLine:=Lines[NewBlockEnd.Y - 1];
|
||||||
@ -1773,6 +1772,9 @@ begin
|
|||||||
or (CurLine[NewBlockEnd.X] in HighlighterIdentChars))
|
or (CurLine[NewBlockEnd.X] in HighlighterIdentChars))
|
||||||
do
|
do
|
||||||
inc(NewBlockEnd.X);
|
inc(NewBlockEnd.X);
|
||||||
|
end else begin
|
||||||
|
// replace only prefix
|
||||||
|
NewBlockEnd := LogCaret;
|
||||||
end;
|
end;
|
||||||
//debugln('TSynCompletion.Validate B Position=',dbgs(Position));
|
//debugln('TSynCompletion.Validate B Position=',dbgs(Position));
|
||||||
if Position>=0 then begin
|
if Position>=0 then begin
|
||||||
|
@ -2114,13 +2114,16 @@ Begin
|
|||||||
Prefix := CurrentString;
|
Prefix := CurrentString;
|
||||||
case CurrentCompletionType of
|
case CurrentCompletionType of
|
||||||
ctIdentCompletion:
|
ctIdentCompletion:
|
||||||
if not InitIdentCompletionValues(S) then begin
|
if InitIdentCompletionValues(S) then begin
|
||||||
|
ToggleReplaceWhole:=not CodeToolsOpts.IdentComplReplaceIdentifier;
|
||||||
|
end else begin
|
||||||
ItemList.Clear;
|
ItemList.Clear;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ctWordCompletion:
|
ctWordCompletion:
|
||||||
begin
|
begin
|
||||||
|
ToggleReplaceWhole:=not CodeToolsOpts.IdentComplReplaceIdentifier;
|
||||||
ccSelection := '';
|
ccSelection := '';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2240,8 +2243,6 @@ Begin
|
|||||||
|
|
||||||
ctIdentCompletion:
|
ctIdentCompletion:
|
||||||
begin
|
begin
|
||||||
if not CodeToolsOpts.IdentComplReplaceIdentifier then
|
|
||||||
SourceEnd:=Editor.LogicalCaretXY;
|
|
||||||
if Manager.ActiveCompletionPlugin<>nil then
|
if Manager.ActiveCompletionPlugin<>nil then
|
||||||
begin
|
begin
|
||||||
Manager.ActiveCompletionPlugin.Complete(Value,SourceValue,
|
Manager.ActiveCompletionPlugin.Complete(Value,SourceValue,
|
||||||
@ -2296,8 +2297,6 @@ Begin
|
|||||||
// the completion is already in Value
|
// the completion is already in Value
|
||||||
begin
|
begin
|
||||||
ccSelection := '';
|
ccSelection := '';
|
||||||
if not CodeToolsOpts.IdentComplReplaceIdentifier then
|
|
||||||
SourceEnd:=Editor.LogicalCaretXY;
|
|
||||||
if Value<>'' then AWordCompletion.AddWord(Value);
|
if Value<>'' then AWordCompletion.AddWord(Value);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user