[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Add IME status change support on windows natively

From: Albert
Subject: [PATCH] Add IME status change support on windows natively
Date: Mon, 13 Apr 2020 12:09:00 +0800

    I added some code on src/w32fns.c and src/w32term.h to add IME status change support on windows natively like gVim did. gVim can change IME status to chinese mode  in insert mode and switch back to english mode when in normal mode natively.

   IME status can be changed by dynamic call imm32.dll's function ImmSetOpenStatus_Proc, but we can't change IME status by elisp code only. Because calling imm32.dll's function ImmSetOpenStatus_Proc from lisp thread is not allowed by Windows, IME is attached to window thread and lisp code is executed in lisp thread. We have to set a flag in lisp thread and set a user-defined message to window thread, then processes that message in w32_msg_pump(). I added a function w32-set-ime-open-status which is called by lisp code.

Following is lisp to use w32-set-ime-open-status after evil mode changed

(if (fboundp 'w32-set-ime-open-status)
      (defun emacs-ime-disable ()
        (w32-set-ime-open-status nil))

      (defun emacs-ime-enable ()
        (w32-set-ime-open-status t))

      (add-hook 'evil-insert-state-entry-hook 'emacs-ime-enable)
      (add-hook 'evil-insert-state-exit-hook 'emacs-ime-disable)

Attachment: w32fns.c.patch
Description: Binary data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]