출처 : http://blog.naver.com/ohama100/130003094279
scintilla/scite 를 하다가 한글이 제자리에서 고쳐지지 않는 문제를 발견했다.
이것을 수정하였다.
IME 에 대한 자료를 찾기가 어려웠다.
http://www.winapi.co.kr/ 의 "당근"프로젝트에 대한 설명이 많은 도움이 되었다.
scintilla 에서 ScintillaWin.cxx 를 다음과 같이 수정하였다.
==============================================================
@@ -262,6 +262,9 @@
}
private:
+ // for hangul composition
+ bool onComposition;
+
// For use in creating a system caret
bool HasCaretSizeChanged();
BOOL CreateSystemCaret();
@@ -470,6 +473,11 @@
LONG bytes = ::ImmGetCompositionStringW(hIMC,
GCS_RESULTSTR, wcs, (maxLenInputIME-1)*2);
int wides = bytes / 2;
+ if (onComposition) {
+ // delete the previous composition character.
+ DelCharBack (false);
+ onComposition = false;
+ }
if (IsUnicodeMode()) {
char utfval[maxLenInputIME * 3];
unsigned int len = UTF8Length(wcs, wides);
@@ -494,6 +502,43 @@
::ImmReleaseContext(MainHWND(), hIMC);
}
return 0;
+ } else if (lParam & GCS_COMPSTR) {
+ HIMC hIMC = ::ImmGetContext(MainHWND());
+ if (hIMC) {
+ const int maxLenInputIME = 200;
+ wchar_t wcs[maxLenInputIME];
+ LONG bytes = ::ImmGetCompositionStringW(hIMC,
+ GCS_COMPSTR, wcs, (maxLenInputIME-1)*2);
+ int wides = bytes / 2;
+ if (onComposition) {
+ // delete the previous composition character.
+ DelCharBack (false);
+ }
+ onComposition = (wides != 0);
+ if (IsUnicodeMode()) {
+ char utfval[maxLenInputIME * 3];
+ unsigned int len = UTF8Length(wcs, wides);
+ UTF8FromUCS2(wcs, wides, utfval, len);
+ utfval[len] = '\0';
+ AddCharUTF(utfval, len);
+ } else {
+ char dbcsval[maxLenInputIME * 2];
+ int size = ::WideCharToMultiByte(InputCodePage(),
+ 0, wcs, wides, dbcsval, sizeof(dbcsval) - 1, 0, 0);
+ for (int i=0; i<size; i++) {
+ AddChar(dbcsval[i]);
+ }
+ }
+ // Set new position after converted
+ Point pos = LocationFromPosition(currentPos);
+ COMPOSITIONFORM CompForm;
+ CompForm.dwStyle = CFS_POINT;
+ CompForm.ptCurrentPos.x = pos.x;
+ CompForm.ptCurrentPos.y = pos.y;
+ ::ImmSetCompositionWindow(hIMC, &CompForm);
+ ::ImmReleaseContext(MainHWND(), hIMC);
+ }
+ return 0;
}
return ::DefWindowProc(MainHWND(), WM_IME_COMPOSITION, wParam, lParam);
#endif
@@ -535,6 +580,8 @@
switch (iMessage) {
case WM_CREATE:
+ onComposition = false; // for hangul composition
+
ctrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(wMain.GetID()));
// Get Intellimouse scroll line parameters
GetIntelliMouseParameters();
=====================================================================
오형 | SciTEGlobal.properties 내용을 적당히 수정해주면 코딩을 바꿀 필요없이 정상작동! 이 파일에서 code.page 를 찾아서 #을 떼고 아래와 같이 고처준다. 한글 code page : 949, 한글 character set : 129 code.page=949 character.set=129 |
오형 | #은 주석행을 뜻하는 글자 |
덧글을 달아 주세요