라자루스IDE의 컴포넌트 목록에 기본으로 포함되어 있는 SynEdit 컴포넌트는 라자루스IDE의 자체 기본 에디터에서 사용하는 컴포넌트이기도 합니다. 이 SynEdit 컴포넌트 소스파일들을 살펴보면 IM 처리 유닛 파일들 중 윈도우용과 유닉스용(리눅스 포함)이 있습니다.
/components/synedit/lazsynimm.pas
-> 윈도우용 다국어 IME 처리 유닛입니다. 다국어 입력을 위한 IME 처리 설계가 다 되어있고 일부 미흡한 부분에 대해서는 점차 개선시켜 나가면 될 것 같습니다.
/components/synedit/lazsyngtk2imm.pas
-> 리눅스 등 유닉스 계열에서 다국어 처리를 위한 GTK IM 유닛입니다. IM처리 설계를 위한 기본적인 골격만 준비되어 있는 것으로 보이는데 lazsynimm.pas와 비교하면 메쏘드는 WMImeComposition 하나뿐이며 그 외엔 아무것도 되어있지 않습니다.
다음은 lazsyngtk2imm.pas의 소스코드입니다.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | unit LazSynGtk2IMM; {$mode objfpc}{$H+} interface uses {$ifdef LCLGtk2} gtk2, Gtk2Globals, {$endif} Classes, SysUtils, Messages, LMessages, LazSynIMMBase, SynEditKeyCmds; type { LazSynImeGtk2 } LazSynImeGtk2 = class(LazSynIme) private FIMESelText: string; public procedure WMImeComposition(var Message: TMessage); override; end; implementation uses SynEdit; { LazSynImeGtk2 } procedure LazSynImeGtk2.WMImeComposition(var Message: TMessage); {$IFDEF WITH_GTK2_IM} var IMStr:string; i:Integer; {$ENDIF} begin {$IFDEF WITH_GTK2_IM} if (not FriendEdit.ReadOnly) then begin // set candidate position if (Message.WParam and (GTK_IM_FLAG_START or GTK_IM_FLAG_PREEDIT))<>0 then IM_Context_Set_Cursor_Pos(FriendEdit.CaretXPix,FriendEdit.CaretYPix+FriendEdit.LineHeight); // valid string at composition & commit if (Message.WParam and (GTK_IM_FLAG_COMMIT or GTK_IM_FLAG_PREEDIT)<>0) then begin // save selected text if Message.WParam and GTK_IM_FLAG_REPLACE=0 then FIMESelText:=FriendEdit.SelText; // insert preedit or commit string IMStr:=pchar(Message.LParam); // for IBUS IM if (Length(IMStr)=0) and (Message.WParam and GTK_IM_FLAG_REPLACE<>0) then TSynEdit(FriendEdit).CommandProcessor(ecDeleteChar,#0,nil) else for i:=1 to Length(IMStr) do TSynEdit(FriendEdit).CommandProcessor(ecChar,IMStr[i],nil); // select last preedit if (Message.WParam and GTK_IM_FLAG_COMMIT=0) then begin if Length(IMStr)>0 then for i:=1 to Length(UTF8Decode(IMStr)) do TSynEdit(FriendEdit).CommandProcessor(ecSelLeft,#0,nil); end else FIMESelText:=''; end; // end composition and complete composition // To Do : skip insert saved selection after commit with ibus. if (Message.WParam and GTK_IM_FLAG_END<>0) and (FIMESelText<>'') then begin TSynEdit(FriendEdit).ClearSelection; // restore selection before preedit. for i:=1 to Length(FIMESelText) do TSynEdit(FriendEdit).CommandProcessor(ecChar,FIMESelText[i],nil); FIMESelText:=''; end; end; {$ENDIF} end; end. |
댓글 0