From 107a955dd6f8eca3ae0c38e561ca44f6dc32603c Mon Sep 17 00:00:00 2001 From: mattias Date: Sat, 18 Jun 2005 09:22:56 +0000 Subject: [PATCH] fixed syncompletion for UTF8 keypress git-svn-id: trunk@7248 - --- components/synedit/syncompletion.pas | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/components/synedit/syncompletion.pas b/components/synedit/syncompletion.pas index 890a5a46cf..de6fc74c6a 100644 --- a/components/synedit/syncompletion.pas +++ b/components/synedit/syncompletion.pas @@ -62,6 +62,8 @@ type TValidateEvent = procedure(Sender: TObject; Shift: TShiftState) of object; TSynBaseCompletionSearchPosition = procedure(var Position :integer) of object; + { TSynBaseCompletionForm } + TSynBaseCompletionForm = class(TForm) protected FCurrentString: string; @@ -83,6 +85,7 @@ type FOnKeyCompletePrefix: TNotifyEvent; FTextColor: TColor; FTextSelectedColor: TColor; + procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override; {$ENDIF} procedure SetCurrentString(const Value: string); procedure KeyDown(var Key: Word; Shift: TShiftState); override; @@ -559,6 +562,25 @@ begin Position := Position - 1; end; +{$IFDEF SYN_LAZARUS} +procedure TSynBaseCompletionForm.UTF8KeyPress(var UTF8Key: TUTF8Char); +begin + if UTF8Key=#8 then begin + if Assigned(OnUTF8KeyPress) then OnUTF8KeyPress(Self, UTF8Key); + end else if (length(UTF8Key)>=1) and (not (UTF8Key[1] in [#33..'z'])) then + begin + if Assigned(OnCancel) then + OnCancel(Self); + end else begin + if Assigned(OnUTF8KeyPress) then + OnUTF8KeyPress(Self, UTF8Key); + if UTF8Key<>'' then + CurrentString := CurrentString + UTF8Key; + end; + UTF8Key:=''; +end; +{$ENDIF} + procedure TSynBaseCompletionForm.SetCurrentString(const Value: string); var i: integer;