summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2013-04-09 15:35:10 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2013-04-09 15:35:10 -0400
commitc170cf9e0cfbc4689e636beb198d74771fd59201 (patch)
treea68d497d4e518852534343f13848d7b8caf004ef
parent975e98f6ef680ed917c7d22fde80e918d5bef60e (diff)
downloadeclipse.platform.swt-c170cf9e0cfbc4689e636beb198d74771fd59201.tar.gz
eclipse.platform.swt-c170cf9e0cfbc4689e636beb198d74771fd59201.tar.xz
eclipse.platform.swt-c170cf9e0cfbc4689e636beb198d74771fd59201.zip
Bug 404249 - On Windows 7, Cannot convert Korean charactor to Chinese in StyledText control
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java17
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java21
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java33
7 files changed, 117 insertions, 6 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
index 8970c86150..480b18914e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -5773,9 +5773,20 @@ void handleCompositionOffset (Event event) {
event.count = trailing[0];
}
void handleCompositionSelection (Event event) {
- event.start = selection.x;
- event.end = selection.y;
- event.text = getSelectionText();
+ if (event.start != event.end) {
+ int charCount = getCharCount();
+ event.start = Math.max(0, Math.min(event.start, charCount));
+ event.end = Math.max(0, Math.min(event.end, charCount));
+ if (event.text != null) {
+ setSelection(event.start, event.end);
+ } else {
+ event.text = getTextRange(event.start, event.end - event.start);
+ }
+ } else {
+ event.start = selection.x;
+ event.end = selection.y;
+ event.text = getSelectionText();
+ }
}
void handleCompositionChanged(Event event) {
String text = event.text;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
index 7648cde618..9cc30cb8bc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7410,6 +7410,38 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(ImmDisableTextFrameService)
}
#endif
+#ifndef NO_ImmEscapeA
+JNIEXPORT jintLong JNICALL OS_NATIVE(ImmEscapeA)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jintLongArray arg3)
+{
+ jintLong *lparg3=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, ImmEscapeA_FUNC);
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ rc = (jintLong)ImmEscapeA((HKL)arg0, (HIMC)arg1, arg2, (LPVOID)lparg3);
+fail:
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ OS_NATIVE_EXIT(env, that, ImmEscapeA_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO_ImmEscapeW
+JNIEXPORT jintLong JNICALL OS_NATIVE(ImmEscapeW)
+ (JNIEnv *env, jclass that, jintLong arg0, jintLong arg1, jint arg2, jintLongArray arg3)
+{
+ jintLong *lparg3=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, ImmEscapeW_FUNC);
+ if (arg3) if ((lparg3 = (*env)->GetIntLongArrayElements(env, arg3, NULL)) == NULL) goto fail;
+ rc = (jintLong)ImmEscapeW((HKL)arg0, (HIMC)arg1, arg2, (LPVOID)lparg3);
+fail:
+ if (arg3 && lparg3) (*env)->ReleaseIntLongArrayElements(env, arg3, lparg3, 0);
+ OS_NATIVE_EXIT(env, that, ImmEscapeW_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO_ImmGetCompositionFontA
JNIEXPORT jboolean JNICALL OS_NATIVE(ImmGetCompositionFontA)
(JNIEnv *env, jclass that, jintLong arg0, jobject arg1)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
index 122bfc6fff..c58e122690 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -543,6 +543,8 @@ char * OS_nativeFunctionNames[] = {
"ImmCreateContext",
"ImmDestroyContext",
"ImmDisableTextFrameService",
+ "ImmEscapeA",
+ "ImmEscapeW",
"ImmGetCompositionFontA",
"ImmGetCompositionFontW",
#ifndef JNI64
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
index 5f47247125..b22c7cc825 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -553,6 +553,8 @@ typedef enum {
ImmCreateContext_FUNC,
ImmDestroyContext_FUNC,
ImmDisableTextFrameService_FUNC,
+ ImmEscapeA_FUNC,
+ ImmEscapeW_FUNC,
ImmGetCompositionFontA_FUNC,
ImmGetCompositionFontW_FUNC,
#ifndef JNI64
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index b2f8cdd8cb..a7acfb2431 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -903,6 +903,7 @@ public class OS extends C {
public static final int IME_CMODE_KATAKANA = 0x2;
public static final int IME_CMODE_NATIVE = 0x1;
public static final int IME_CMODE_ROMAN = 0x10;
+ public static final int IME_ESC_HANJA_MODE = 0x1008;
public static final int IMEMOUSE_LDOWN = 1;
public static final int INFINITE = 0xffffffff;
public static final int INPUT_KEYBOARD = 1;
@@ -2022,6 +2023,7 @@ public class OS extends C {
public static final int VK_F7 = 0x76;
public static final int VK_F8 = 0x77;
public static final int VK_F9 = 0x78;
+ public static final int VK_HANJA = 0x19;
public static final int VK_HOME = 0x24;
public static final int VK_INSERT = 0x2d;
public static final int VK_L = 0x4c;
@@ -2922,6 +2924,13 @@ public static final int ImmGetCompositionString (long /*int*/ hIMC, int dwIndex,
return ImmGetCompositionStringA (hIMC, dwIndex, lpBuf, dwBufLen);
}
+public static final long /*int*/ ImmEscape (long /*int*/ hKL,long /*int*/ hIMC, int uEscape, long /*int*/ [] lpData) {
+ if (IsUnicode) {
+ return ImmEscapeW (hKL, hIMC, uEscape, lpData);
+ }
+ return ImmEscapeA (hKL, hIMC, uEscape, lpData);
+}
+
public static final int ImmGetCompositionString (long /*int*/ hIMC, int dwIndex, int [] lpBuf, int dwBufLen) {
if (IsUnicode) {
return ImmGetCompositionStringW (hIMC, dwIndex, lpBuf, dwBufLen);
@@ -4923,6 +4932,18 @@ public static final native long /*int*/ ImmCreateContext ();
public static final native boolean ImmDestroyContext (long /*int*/ hIMC);
/** @method flags=dynamic */
public static final native boolean ImmDisableTextFrameService (int idThread);
+/**
+ * @param hKL cast=(HKL)
+ * @param hIMC cast=(HIMC)
+ * @param lpData cast=(LPVOID)
+ */
+public static final native long /*int*/ ImmEscapeW(long /*int*/ hKL, long /*int*/ hIMC, int uEscape, long /*int*/ [] lpData);
+/**
+ * @param hKL cast=(HKL)
+ * @param hIMC cast=(HIMC)
+ * @param lpData cast=(LPVOID)
+ */
+public static final native long /*int*/ ImmEscapeA(long /*int*/ hKL, long /*int*/ hIMC, int uEscape, long /*int*/ [] lpData);
/** @param hIMC cast=(HIMC) */
public static final native boolean ImmGetCompositionFontW (long /*int*/ hIMC, LOGFONTW lplf);
/** @param hIMC cast=(HIMC) */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
index 11a746c92a..d20d925f0a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -424,6 +424,16 @@ LRESULT WM_INPUTLANGCHANGE (long /*int*/ wParam, long /*int*/ lParam) {
return result;
}
+
+LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+ LRESULT result = super.WM_KEYDOWN (wParam, lParam);
+ if (result != null) return result;
+ if (ime != null) {
+ ime.WM_KEYDOWN (wParam, lParam);
+ }
+ return result;
+}
+
LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
if (ime != null) {
LRESULT result = ime.WM_KILLFOCUS (wParam, lParam);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
index f3b1e26977..3be062505e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/IME.java
@@ -520,6 +520,39 @@ LRESULT WM_IME_ENDCOMPOSITION (long /*int*/ wParam, long /*int*/ lParam) {
return isInlineEnabled () ? LRESULT.ONE : null;
}
+LRESULT WM_KEYDOWN (long /*int*/ wParam, long /*int*/ lParam) {
+ if (wParam == OS.VK_HANJA) {
+ long /*int*/ hKL = OS.GetKeyboardLayout (0);
+ short langID = (short)OS.LOWORD (hKL);
+ if (OS.PRIMARYLANGID (langID) == OS.LANG_KOREAN) {
+ Event event = new Event ();
+ event.detail = SWT.COMPOSITION_SELECTION;
+ sendEvent (SWT.ImeComposition, event);
+ if (event.start == event.end) {
+ event.text = null;
+ event.end = event.start + 1;
+ sendEvent (SWT.ImeComposition, event);
+ }
+ if (event.text != null && event.text.length() > 0) {
+ long /*int*/ hwnd = parent.handle;
+ long /*int*/ hIMC = OS.ImmGetContext (hwnd);
+ long /*int*/ hHeap = OS.GetProcessHeap ();
+ TCHAR buffer = new TCHAR (0, event.text, true);
+ int byteCount = buffer.length () * TCHAR.sizeof;
+ long /*int*/ pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+ OS.MoveMemory (pszText, buffer, byteCount);
+ long /*int*/ [] lpData = new long /*int*/ []{pszText};
+ long /*int*/ rc = OS.ImmEscape(hKL, hIMC, OS.IME_ESC_HANJA_MODE, lpData);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ if (rc != 0) {
+ sendEvent (SWT.ImeComposition, event);
+ }
+ }
+ }
+ }
+ return null;
+}
+
LRESULT WM_KILLFOCUS (long /*int*/ wParam, long /*int*/ lParam) {
if (!isInlineEnabled ()) return null;
long /*int*/ hwnd = parent.handle;