unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* UNICODE WITH MS-IME
@ 2007-03-13 14:32 姚春林
  2007-03-13 17:47 ` KOBAYASHI Yasuhiro
  0 siblings, 1 reply; 2+ messages in thread
From: 姚春林 @ 2007-03-13 14:32 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 4302 bytes --]

I must work on windows and with multi language.
I use windows IME to input multi language.
so emacs must accept unicode MS-IME.

I modified emacs23 to accept unicode MS-IME string.
I only known a little C and don't know emacs construction.
so this patch may have many bugs.
I post it here.hope somebody add unicode ime support in emacs23

===========================================

? cscope.out
Index: w32fns.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32fns.c,v
retrieving revision 1.219.2.39
diff -u -r1.219.2.39 w32fns.c
--- w32fns.c    26 Feb 2007 23:03:29 -0000    1.219.2.39
+++ w32fns.c    13 Mar 2007 14:12:21 -0000
@@ -55,6 +55,8 @@
 #include <winspool.h>

 #include <dlgs.h>
+#include <imm.h>
+
 #define FILE_NAME_TEXT_FIELD edt1

 void syms_of_w32fns ();
@@ -2735,6 +2737,64 @@
     }
 }

+static void ime_input (hwnd, msg, wParam, lParam)
+    HWND hwnd;
+    UINT msg;
+    WPARAM wParam;
+    LPARAM lParam;
+{
+    HIMC hIMC;
+    DWORD dwSize;
+    HGLOBAL hstr;
+    LPWSTR lpstr;
+    W32Msg wmsg;
+    DWORD i=0;
+
+    wmsg.dwModifiers = w32_get_key_modifiers (wParam, lParam);
+    hIMC = ImmGetContext(hwnd);
+
+    if (!hIMC)
+        return;
+    //MyError(ERROR_NULLCONTEXT);
+
+    // Get the size of the result string.
+    dwSize = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
+
+    // increase buffer size for terminating null character,
+    //   maybe it is in UNICODE
+    dwSize += sizeof(WCHAR);
+
+    hstr = GlobalAlloc(GHND,dwSize);
+    if (hstr == NULL)
+    {
+        ImmReleaseContext(hwnd, hIMC);
+        return;
+    }
+
+    lpstr = GlobalLock(hstr);
+    if (lpstr == NULL)
+    {
+        ImmReleaseContext(hwnd, hIMC);
+        GlobalFree(hstr);
+    }
+    //MyError(ERROR_GLOBALLOCK);
+
+    // Get the result strings that is generated by IME into lpstr.
+    ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, lpstr, dwSize);
+    //MessageBoxW(NULL, lpstr , L"inputed", 0);
+    for(i=0; i< dwSize ; i++){
+        if((WCHAR) lpstr[i] == 0x0000){
+            break;
+        }
+        my_post_msg (&wmsg, hwnd, WM_IME_CHAR, lpstr[i], lParam);
+    }
+
+    ImmReleaseContext(hwnd, hIMC);
+
+    // add this string into text buffer of application
+    GlobalUnlock(hstr);
+    GlobalFree(hstr);
+}

 static void
 post_character_message (hwnd, msg, wParam, lParam, modifiers)
@@ -3171,6 +3231,15 @@

       /* Simulate middle mouse button events when left and right buttons
      are used together, but only if user has two button mouse. */
+
+    /*Modified By ChunlinYao 2007-03-12*/
+    case WM_IME_COMPOSITION:
+      if (lParam & GCS_RESULTSTR)
+      {
+          ime_input(hwnd, msg, wParam, lParam);
+          return 0;
+      }
+      goto dflt;
     case WM_LBUTTONDOWN:
     case WM_RBUTTONDOWN:
       if (w32_num_mouse_buttons > 2)
Index: w32term.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32term.c,v
retrieving revision 1.193.4.40
diff -u -r1.193.4.40 w32term.c
--- w32term.c    26 Feb 2007 23:03:29 -0000    1.193.4.40
+++ w32term.c    13 Mar 2007 12:55:24 -0000
@@ -4447,6 +4447,29 @@
         }
       break;

+    case WM_IME_CHAR:
+      f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
+
+      if (f && !f->iconified)
+        {
+          if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)
+          && !EQ (f->tool_bar_window, dpyinfo->mouse_face_window))
+        {
+          clear_mouse_face (dpyinfo);
+          dpyinfo->mouse_face_hidden = 1;
+        }
+
+          if (temp_index == sizeof temp_buffer / sizeof (short))
+        temp_index = 0;
+          temp_buffer[temp_index++] = msg.msg.wParam;
+          inev.kind = MULTIBYTE_CHAR_KEYSTROKE_EVENT;
+          inev.code = msg.msg.wParam;
+          inev.modifiers = msg.dwModifiers;
+          XSETFRAME (inev.frame_or_window, f);
+          inev.timestamp = msg.msg.time;
+        }
+      break;
+
     case WM_MOUSEMOVE:
       /* Ignore non-movement.  */
       {


-- 
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_
/_/      中国   ・  江蘇省  ・  南通
/_/
/_/ 姚春林
/_/
/_/    E-mail: chunlinyao@gmail.com
/_/    MSN  : chunlinyao@gmail.com
/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_

[-- Attachment #1.2: Type: text/html, Size: 7396 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: UNICODE WITH MS-IME
  2007-03-13 14:32 UNICODE WITH MS-IME 姚春林
@ 2007-03-13 17:47 ` KOBAYASHI Yasuhiro
  0 siblings, 0 replies; 2+ messages in thread
From: KOBAYASHI Yasuhiro @ 2007-03-13 17:47 UTC (permalink / raw)
  To: 姚春林; +Cc: emacs-devel

In message UNICODE WITH MS-IME
 on Tue, 13 Mar 2007 23:32:59 +0900
 "姚春林" <chunlinyao@gmail.com> wrote:

> I must work on windows and with multi language.
> I use windows IME to input multi language.
> so emacs must accept unicode MS-IME.

> I modified emacs23 to accept unicode MS-IME string.
> I only known a little C and don't know emacs construction.
> so this patch may have many bugs.
> I post it here.hope somebody add unicode ime support in emacs23

I maintain the IME-patch with some w32 original features for
emacs-csv and emacs-unicode2.
The original version which was written by MIYOSHI Masayoshi
for emacs21 was based on Meadow which is another emacs for w32.

http://homepage3.nifty.com/y3tk/emacs/emacs-unicode-cvs-20070314-IME.patch

Please try it.
After release emacs22 I am planning to post it in this list.

-- 
KOBAYASHI Yasuhiro <kobayays@gmail.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-03-13 17:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-13 14:32 UNICODE WITH MS-IME 姚春林
2007-03-13 17:47 ` KOBAYASHI Yasuhiro

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).