Changeset 3998
- Timestamp:
- 12/14/05 00:17:42 (2 years ago)
- Files:
-
- trunk/lisp/ChangeLog.Meadow (modified) (1 diff)
- trunk/lisp/international/meadow.el (modified) (11 diffs)
- trunk/src/ChangeLog.Meadow (modified) (2 diffs)
- trunk/src/mw32fns.c (modified) (2 diffs)
- trunk/src/mw32ime.c (modified) (18 diffs)
- trunk/src/mw32term.c (modified) (2 diffs)
- trunk/src/mw32term.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lisp/ChangeLog.Meadow
r3990 r3998 1 2005-12-13 Kyotaro HORIGUCHI <horiguti@meadowy.org> 2 3 * international/meadow.el (mw32-ime-cont-on): New variable. 4 (mw32-input-method-noconv-regexp): New variable. 5 (mw32-set-ime-if-available): Initialize MW32-IME. 6 (mw32-ime-sync-state): Changed. 7 (mw32-ime-mode-line-update): Remove redundant parameter. 8 (mw32-ime-initialize): Ressurected. Change doc string. Add 9 treatment for isearch. 10 (mw32-ime-uninitialize): Add treatment for isearch. 11 (mw32-isearch-mode-hook-function): New hook function. 12 (mw32-ime-state-switch): Move IME initialization into 13 mw32-ime-initialize. 14 (): Change registration of MW32-IME. 15 (mw32-input-method): New function to be used for 16 input-method-function. 17 1 18 2005-11-26 MIYOSHI Masanori <miyoshi@meadowy.org> 2 19 trunk/lisp/international/meadow.el
r3945 r3998 1 ;;;;; meadow.el ---- For Meadow.2 1 ;; 3 2 ;; Author H.Miyashita … … 155 154 (defvar mw32-ime-mode-line-format-original nil 156 155 "Original mode line format.") 156 (defvar mw32-ime-cont-on t 157 "It not nil, IME is always on during current-input-method is MW32-IME.") 158 (defvar mw32-input-method-noconv-regexp nil 159 "Regexp represents printable-chars that does not activate IME.") 157 160 158 161 (setq search-highlight t) … … 267 270 (when (and ime (mw32-ime-available)) 268 271 (setq default-input-method (cdr ime)) 272 (mw32-ime-initialize) 269 273 (define-key global-map [kanji] 'toggle-input-method)))) 270 274 … … 327 331 (when mw32-ime-buffer-switch-p 328 332 (with-current-buffer (window-buffer window) 329 (let* ((frame (window-frame window)) 330 (ime-state (fep-get-mode))) 331 (cond 332 ((and (not ime-state) 333 (equal current-input-method "MW32-IME")) 334 (fep-force-on nil) 335 (run-hooks 'mw32-ime-on-hook)) 336 ((and ime-state 337 (not (equal current-input-method "MW32-IME"))) 338 (when (= (w32-ime-undetermined-string-length) 0) 339 (fep-force-off nil) 340 (run-hooks 'mw32-ime-off-hook)))))))) 333 (if (window-minibuffer-p) 334 (fep-force-off) 335 (let* ((frame (window-frame window))) 336 (if (string= current-input-method "MW32-IME") 337 (run-hooks 'mw32-ime-on-hook) 338 (run-hooks 'mw32-ime-off-hook)) 339 (if mw32-ime-cont-on 340 (if (string= current-input-method "MW32-IME") 341 (if (eq input-method-function 'mw32-input-method) 342 (fep-force-on)) 343 (fep-force-off)))))))) 341 344 342 345 (defun mw32-ime-set-selected-window-buffer-hook (oldbuf newwin newbuf) … … 349 352 (cond 350 353 (mw32-ime-show-mode-line 351 (unless (window-minibuffer-p (selected-window))354 (unless (window-minibuffer-p) 352 355 (setq mw32-ime-mode-line-state-indicator 353 356 (nth (if (fep-get-mode) 1 2) … … 384 387 385 388 (defun mw32-ime-initialize () 386 "This is obsoleted function. It is unnecessary to call this 387 function to initialize MW32-IME." 389 "Initialize MW32-IME. It is unnecessary to call this function explicitly." 388 390 (cond 389 391 ((and (eq system-type 'windows-nt) … … 397 399 (mw32-ime-init-mode-line-display) 398 400 (mw32-ime-mode-line-update) 399 (add-hook 'select-window-functions 400 'mw32-ime-select-window-hook) 401 (add-hook 'select-window-functions 'mw32-ime-select-window-hook) 401 402 (add-hook 'set-selected-window-buffer-functions 402 403 'mw32-ime-set-selected-window-buffer-hook) 403 (if coding-system 404 (set-keyboard-coding-system (cdr coding-system))) 405 (define-key global-map [kanji] 'toggle-input-method))))) 406 404 405 (add-hook 'isearch-mode-hook 'mw32-isearch-mode-hook-function) 406 (defadvice isearch-toggle-input-method (after mw32-fep-off activate) 407 "Deactivate fep when mw32-ime-cont-on is not nil." 408 (if mw32-ime-cont-on (fep-force-off))) 409 (defadvice isearch-done (after mw32-fep-on activate) 410 "Deactivate fep when mw32-ime-cont-on is not nil." 411 (if (and mw32-ime-cont-on 412 (string= current-input-method "MW32-IME")) 413 (fep-force-on))))))) 414 415 (defun mw32-isearch-mode-hook-function () 416 (if mw32-ime-cont-on 417 (fep-force-off)) 418 (define-key isearch-mode-map [kanji] 'isearch-toggle-input-method) 419 (define-key isearch-mode-map [compend] 'ignore)) 420 421 407 422 (defun mw32-ime-uninitialize () 408 423 (cond ((and (eq system-type 'windows-nt) … … 415 430 'mw32-ime-select-window-hook) 416 431 (remove-hook 'set-selected-window-buffer-functions 417 'mw32-ime-set-selected-window-buffer-hook)))) 418 432 'mw32-ime-set-selected-window-buffer-hook) 433 (remove-hook 'isearch-mode-hook 'mw32-isearch-mode-hook-function) 434 (defadvice isearch-toggle-input-method (after mw32-fep-off disable)) 435 (defadvice isearch-done (after mw32-fep-on disable))))) 436 419 437 (defun mw32-ime-exit-from-minibuffer () 420 438 (inactivate-input-method) … … 423 441 424 442 (defun mw32-ime-state-switch (&optional arg) 443 (kill-local-variable 'input-method-function) 444 (if (fep-get-mode) 445 (fep-force-off)) 425 446 (if arg 426 447 (progn 427 448 (when (null (memq 'mw32-ime-select-window-hook 428 449 select-window-functions)) 429 (add-hook 'select-window-functions 'mw32-ime-select-window-hook) 430 (add-hook 'set-selected-window-buffer-functions 431 'mw32-ime-set-selected-window-buffer-hook) 432 (mw32-ime-init-mode-line-display)) 433 450 (mw32-ime-initialize)) 434 451 (setq inactivate-current-input-method-function 435 452 'mw32-ime-state-switch) … … 437 454 (run-hooks 'mw32-ime-on-hook) 438 455 (setq describe-current-input-method-function nil) 439 (when ( eq (selected-window) (minibuffer-window))456 (when (window-minibuffer-p) 440 457 (add-hook 'minibuffer-exit-hook 'mw32-ime-exit-from-minibuffer)) 441 (fep-force-on)) 458 (make-local-variable 'input-method-function) 459 (setq input-method-function 'mw32-input-method) 460 (if (and mw32-ime-cont-on 461 (not (window-minibuffer-p))) 462 (fep-force-on))) 442 463 (setq current-input-method nil) 443 464 (run-hooks 'input-method-inactivate-hook) 444 465 (run-hooks 'mw32-ime-off-hook) 445 (setq describe-current-input-method-function nil) 446 (fep-force-off)) 466 (setq describe-current-input-method-function nil)) 447 467 (mw32-ime-mode-line-update)) 448 468 449 (register-input-method "MW32-IME" "Japanese" 'mw32-ime-state-switch " "469 (register-input-method "MW32-IME" "Japanese" 'mw32-ime-state-switch "A " 450 470 "MW32 System IME") 451 471 … … 493 513 (t 'static-color)))) 494 514 515 (defun mw32-input-method (key) 516 "Input method function for IME." 517 (if (or 518 (let ((case-fold-search nil)) 519 (and key 520 mw32-input-method-noconv-regexp 521 (string-match mw32-input-method-noconv-regexp 522 (char-to-string key)))) 523 (fep-get-mode)) 524 (list key) 525 (sit-for 0) 526 (fep-force-on) 527 (let* ((pos (point)) 528 (ov (make-overlay (point) (1+ (point)))) 529 (ret (mw32-ime-input-method-function (char-to-string key))) 530 (result (append (car ret) nil))) 531 ;;; Continue to conversion if composition string cannot be 532 ;;; convert into single ascii character. 533 (unwind-protect 534 (while (or 535 (> (length (cadr ret)) 1) 536 (and 537 (cadr ret) 538 (not (eq (string-to-char (japanese-hankaku (cadr ret))) 539 (caddr ret))))) 540 (insert (car ret)) 541 (move-overlay ov pos (point)) 542 (if input-method-highlight-flag 543 (overlay-put ov 'face 'underline)) 544 (sit-for 0) 545 (setq ret (mw32-ime-input-method-function)) 546 (setq result (append result (append (car ret) nil)))) 547 (if (and (cadr ret) 548 (eq (length (cadr ret)) 1) 549 (eq (string-to-char (japanese-hankaku (cadr ret))) 550 (caddr ret))) 551 (setq unread-input-method-events 552 (cons (caddr ret) unread-input-method-events))) 553 (fep-force-off) 554 (delete-region pos (point)) 555 (delete-overlay ov)) 556 result))) 557 495 558 ;; dummy vals. 496 559 (defun x-server-max-request-size (&optional display) 65535) trunk/src/ChangeLog.Meadow
r3997 r3998 1 2005-12-13 Kyotaro HORIGUCHI <horiguti@meadowy.org> 2 3 * mw32ime.c (IMMGETVIRTUALKEYPROC): New typedef. 4 (ImmGetVirtualKeyProc): New function pointer. 5 (input_method_function_event): New event object. 6 (waiting_on_main_thread): New variable. 7 (input_method_function_string): New variable. 8 (last_ime_keycode): New variable. 9 (last_ime_keymod): New variable. 10 (mw32_ime_get_virtual_key): New function. 11 (mw32_ime_record_keycode): New function. 12 (mw32_ime_set_composition_string): New function. 13 (mw32_get_ime_composition_string): Renamed to 14 mw32_get_ime_result_string. Add process for 15 mw32-ime-input-method-function. 16 (mw32_ime_get_composition_string): New function. 17 (mw32_ime_control_init): Initialize ImmGetVirtualKeyProc and 18 input_method_function_event. 19 (conversion_agent_wndproc<WM_MULE_IMM_GET_COMPOSISION_STRING>): 20 Message renamed to WM_MULE_IMM_GET_RESULT_STRING and ditto about 21 the calling function. 22 (mw32_ime_cancel_input_function): New function. 23 (mw32-ime-input-method-function): New lisp function. 24 (fep-force-on): Detail doc string. 25 (fep-force-off): Ditto. 26 (cmode_list): New static data for imm-get-conversion-status. 27 (imm-get-conversion-status): New lisp function. 28 (w32-set-ime-mode): Changed. 29 30 * mw32term.c (mw32_message_loop<WM_KEYDOWN>): Record virtual 31 keycode of VK_PROCESSKEY. 32 (mw32_message_loop<WM_MULE_IME_REPORT>): Don't enter the loop when 33 lpStr is null. 34 35 * mw32term.h (WM_MULE_IMM_GET_RESULT_STRING): New symbol. 36 (WM_MULE_IMM_GET_SET_MODE): Numerical ID is shifted. 37 38 * mw32fns.c (mw32_WndProc<WM_IME_COMPOSITION>): 39 mw32_get_ime_composition_string() is renamed to 40 mw32_get_ime_result_string(). Cancel input method function when no 41 composition string is left. 42 (mw32_WndProc<WM_WM_MULE_IMM_SET_COMPOSITION_STRING>): New message 43 handler. 44 (mw32_WndProc<WM_WM_MULE_IMM_GET_COMPOSITION_STRING>): New message 45 handler. 46 1 47 2005-12-13 Kyotaro HORIGUCHI <horiguti@meadowy.org> 2 48 … … 73 119 (set-window-configuration): Ditto. 74 120 121 * eval.c (signal): Remove W32_UNBLOCK_INPUT. 122 75 123 2005-12-01 MIYOSHI Masanori <miyoshi@meadowy.org> 76 124 trunk/src/mw32fns.c
r3997 r3998 2448 2448 if (lParam & GCS_RESULTSTR) 2449 2449 { 2450 extern BOOL mw32_get_ime_ composion_string (HWND);2451 if (mw32_get_ime_ composition_string (hwnd))2450 extern BOOL mw32_get_ime_result_string (HWND); 2451 if (mw32_get_ime_result_string (hwnd)) 2452 2452 return 0; 2453 2453 else 2454 2454 break; 2455 2455 } 2456 2457 if (mw32_get_ime_undetermined_string_length (hwnd) == 0) 2458 { /* Cancelling composition string */ 2459 mw32_ime_cancel_input_function (); 2460 } 2461 2456 2462 goto dflt; 2457 2463 } … … 2503 2509 mw32_set_ime_conv_window (hwnd, (struct window *) wParam); 2504 2510 break; 2511 2512 case WM_MULE_IMM_SET_COMPOSITION_STRING: 2513 mw32_ime_set_composition_string (hwnd, (char*) wParam); 2514 break; 2515 2516 case WM_MULE_IMM_GET_COMPOSITION_STRING: 2517 mw32_ime_get_composition_string (hwnd); 2518 break; 2519 2505 2520 #endif /* not MEADOW and IME_CONTROL */ 2506 2521 trunk/src/mw32ime.c
r3996 r3998 144 144 typedef BOOL (WINAPI *IMMISIMEPROC)(HKL); 145 145 IMMISIMEPROC ImmIsIMEProc; 146 typedef UINT (WINAPI *IMMGETVIRTUALKEYPROC)(HWND); 147 IMMGETVIRTUALKEYPROC ImmGetVirtualKeyProc; 146 148 147 149 extern Lisp_Object Vime_control; 148 150 149 151 static WPARAM wIMEOpen; 152 153 static HANDLE input_method_function_event = INVALID_HANDLE_VALUE; 154 static int waiting_on_main_thread = FALSE; 155 static HANDLE input_method_function_string = INVALID_HANDLE_VALUE; 150 156 151 157 Lisp_Object Vime_control; … … 153 159 Lisp_Object Qim_info; 154 160 155 156 161 int IME_event_off_count; 162 static int last_ime_vkeycode; 163 static int last_ime_vkeymod; 164 165 int 166 mw32_ime_get_virtual_key (HWND hwnd) 167 { 168 return (ImmGetVirtualKeyProc)(hwnd); 169 } 170 171 void 172 mw32_ime_record_keycode (int keycode, int keymod) 173 { 174 last_ime_vkeycode = keycode; 175 last_ime_vkeymod = keymod; 176 } 157 177 158 178 void … … 185 205 186 206 void 207 mw32_ime_set_composition_string (HWND hwnd, char* str) 208 { 209 HIMC himc; 210 211 himc = (ImmGetContextProc) (hwnd); 212 (ImmSetCompositionStringProc) (himc, SCS_SETSTR, str, strlen (str), NULL, 0); 213 (ImmReleaseContextProc) (hwnd, himc); 214 } 215 216 void 187 217 mw32_set_ime_status (HWND hwnd, int openp) 188 218 { … … 240 270 241 271 BOOL 242 mw32_get_ime_ composition_string (HWND hwnd)272 mw32_get_ime_result_string (HWND hwnd) 243 273 { 244 274 HIMC hIMC; … … 254 284 size = (ImmGetCompositionStringProc) (hIMC, GCS_RESULTSTR, NULL, 0); 255 285 size += sizeof (TCHAR); 256 himestr = GlobalAlloc (GHND, size); 286 287 input_method_function_string = himestr = GlobalAlloc (GHND, size); 257 288 if (!himestr) abort (); 258 289 lpstr = GlobalLock (himestr); … … 260 291 (ImmGetCompositionStringProc) (hIMC, GCS_RESULTSTR, lpstr, size); 261 292 (ImmReleaseContextProc) (hwnd, hIMC); 293 lpstr [size-1] = 0; 262 294 GlobalUnlock (himestr); 263 f = mw32_window_to_frame (dpyinfo, hwnd); 264 PostMessage (NULL, WM_MULE_IME_REPORT, 265 (WPARAM) himestr, (LPARAM) f); 295 296 if (waiting_on_main_thread) 297 SetEvent (input_method_function_event); 298 else 299 { 300 f = mw32_window_to_frame (dpyinfo, hwnd); 301 PostMessage (NULL, WM_MULE_IME_REPORT, 302 (WPARAM) himestr, (LPARAM) f); 303 } 266 304 return TRUE; 267 305 } 268 306 307 BOOL 308 mw32_ime_get_composition_string (HWND hwnd) 309 { 310 HIMC hIMC; 311 int size; 312 HANDLE himestr; 313 LPSTR lpstr; 314 struct frame *f; 315 struct mw32_display_info *dpyinfo = GET_MW32_DISPLAY_INFO (hwnd); 316 317 hIMC = (ImmGetContextProc) (hwnd); 318 if (!hIMC) return FALSE; 319 320 size = (ImmGetCompositionStringProc) (hIMC, GCS_COMPSTR, NULL, 0); 321 size += sizeof (TCHAR); 322 323 input_method_function_string = himestr = GlobalAlloc (GHND, size); 324 if (!himestr) abort (); 325 lpstr = GlobalLock (himestr); 326 if (!lpstr) abort (); 327 (ImmGetCompositionStringProc) (hIMC, GCS_COMPSTR, lpstr, size); 328 (ImmReleaseContextProc) (hwnd, hIMC); 329 lpstr [size-1] = 0; 330 GlobalUnlock (himestr); 331 332 if (waiting_on_main_thread) 333 SetEvent (input_method_function_event); 334 else 335 { 336 f = mw32_window_to_frame (dpyinfo, hwnd); 337 PostMessage (NULL, WM_MULE_IME_REPORT, 338 (WPARAM) himestr, (LPARAM) f); 339 } 340 return TRUE; 341 } 342 269 343 #ifdef IME_RECONVERSION 270 344 /* TODO: This is dangerous because manipulating buffer contnet in 345 message-thread without synchronizing. This must be fixed. */ 271 346 int 272 347 mw32_get_ime_reconversion_string (HWND hwnd, WPARAM wParam, … … 474 549 GetProcAddress (hImm32, 475 550 "ImmGetHotKey"); 476 477 551 ImmIsIMEProc = 478 552 (IMMISIMEPROC) 479 553 GetProcAddress (hImm32, 480 554 "ImmIsIME"); 481 555 ImmGetVirtualKeyProc = 556 (IMMGETVIRTUALKEYPROC) 557 GetProcAddress (hImm32, 558 "ImmGetVirtualKey"); 482 559 if (ImmGetOpenStatusProc && 483 560 ImmSetOpenStatusProc && … … 499 576 ImmGetCandidateListCountProc && 500 577 ImmGetHotKeyProc && 501 ImmIsIMEProc) 578 ImmIsIMEProc && 579 ImmGetVirtualKeyProc) 502 580 { 503 581 fIME = TRUE; 504 582 Vime_control = Qt; 583 input_method_function_event = CreateEvent (NULL, FALSE, FALSE, NULL); 505 584 } 506 585 } … … 592 671 #endif 593 672 594 case WM_MULE_IMM_GET_ COMPOSITION_STRING:595 return mw32_get_ime_ composition_string (hwnd);673 case WM_MULE_IMM_GET_RESULT_STRING: 674 return mw32_get_ime_result_string (hwnd); 596 675 597 676 case WM_MULE_IMM_NOTIFY: … … 709 788 } 710 789 790 void 791 mw32_ime_cancel_input_function (void) 792 { 793 waiting_on_main_thread = FALSE; 794 795 if (input_method_function_string != INVALID_HANDLE_VALUE) 796 GlobalFree (input_method_function_string); 797 798 input_method_function_string = INVALID_HANDLE_VALUE; 799 800 SetEvent (input_method_function_event); 801 } 802 803 Lisp_Object mw32_ime_input_method_function_unwind (arg) 804 Lisp_Object arg; 805 { 806 mw32_ime_cancel_input_function (); 807 808 if (NILP (arg)) 809 Ffep_force_off (); 810 811 return Qnil; 812 } 711 813 712 814 … … 714 816 Emacs Lisp function entries 715 817 */ 818 819 820 DEFUN ("mw32-ime-input-method-function", 821 Fmw32_ime_input_method_function, Smw32_ime_input_method_function, 822 0, 1, 0, doc: /* Low level input method function for IME. 823 STR is initial composition string. 824 Returns (RESULTSTR COMPSTR LASTCHAR) where RESULTSTR is the conversion result 825 string, COMPSTR is the composition string left behind in conversion, and 826 LASTCHAR is the keycode of the last input during conversion. */) 827 (str) 828 { 829 HWND hwnd; 830 int count = SPECPDL_INDEX (); 831 Lisp_Object resultstr, compstr, result; 832 struct frame *f; 833 struct mw32_display_info *dpyinfo; 834 HANDLE hstr; 835 836 hwnd = FRAME_MW32_WINDOW (XFRAME (selected_frame)); 837 dpyinfo = GET_MW32_DISPLAY_INFO (hwnd); 838 f = mw32_window_to_frame (dpyinfo, hwnd); 839 840 record_unwind_protect (mw32_ime_input_method_function_unwind, 841 Ffep_get_mode ()); 842 waiting_on_main_thread = TRUE; 843 ResetEvent (input_method_function_event); 844 845 result = Qnil; 846 Ffep_force_on (); 847 848 /* If new ascii (expected..) key event comes after this function 849 invoked, get it and add to composition string. */ 850 if (kbd_buffer_events_waiting (0)) 851 { 852 Lisp_Object kseq, args[2]; 853 854 kseq = call5 (intern ("read-key-sequence"), Qnil, Qnil, Qnil, Qnil, Qnil); 855 if (STRINGP (kseq)) 856 { 857 args[0] = str; 858 args[1] = kseq; 859 str = Fconcat (2, args); 860 } 861 } 862 fflush (stdout); 863 if (STRINGP (str)) 864 { 865 str = ENCODE_SYSTEM (str); 866 SendMessage (hwnd, WM_MULE_IMM_SET_COMPOSITION_STRING, 867 (WPARAM)(SDATA (str)), 0); 868 } 869 870 mw32_set_ime_conv_window (hwnd, 871 cursor_in_echo_area ? 872 XWINDOW (f->minibuffer_window): 873 XWINDOW (f->selected_window)); 874 875 /* Rescue from dead block. This may not happen. */ 876 while (WaitForSingleObject (input_method_function_event, 500L) 877 == WAIT_TIMEOUT) 878 QUIT; 879 880 hstr = input_method_function_string; 881 input_method_function_string = INVALID_HANDLE_VALUE; 882 resultstr = compstr = result = Qnil; 883 884 if (hstr != INVALID_HANDLE_VALUE) 885 { 886 char* str = GlobalLock (hstr); 887 if (str) 888 { 889 resultstr = make_string (str, strlen (str)); 890 resultstr = DECODE_SYSTEM (resultstr); 891 } 892 893 GlobalUnlock (hstr); 894 GlobalFree (hstr); 895 } 896 897 waiting_on_main_thread = TRUE; 898 ResetEvent (input_method_function_event); 899 900 SendMessage (hwnd, WM_MULE_IMM_GET_COMPOSITION_STRING, 0, 0); 901 while (WaitForSingleObject (input_method_function_event, 500L) 902 == WAIT_TIMEOUT) 903 QUIT; 904 905 if (hstr != INVALID_HANDLE_VALUE) 906 { 907 char* str = GlobalLock (hstr); 908 if (str) 909 { 910 compstr = make_string (str, strlen (str)); 911 compstr = DECODE_SYSTEM (compstr); 912 } 913 914 GlobalUnlock (hstr); 915 GlobalFree (hstr); 916 } 917 918 result = Fcons (resultstr, 919 Fcons (compstr, 920 Fcons (make_number (last_ime_vkeymod ? 0 921 : last_ime_vkeycode), 922 Qnil))); 923 924 return unbind_to (count, result); 925 } 716 926 717 927 DEFUN ("mw32-ime-available", Fmw32_ime_available, Smw32_ime_available, … … 735 945 736 946 DEFUN ("fep-force-on", Ffep_force_on, Sfep_force_on, 0, 1, 0, 737 doc: /* Force status of IME open. */) 947 doc: /* Force status of IME open. 948 If EVENPT is not nil, this function also creates [kanji] key event. */) 738 949 (eventp) 739 950 Lisp_Object eventp; … … 741 952 if (fIME && !NILP (Vime_control)) 742 953 { 743 HIMC himc;744 954 HWND hwnd; 745 955 … … 759 969 760 970 DEFUN ("fep-force-off", Ffep_force_off, Sfep_force_off, 0, 1, 0, 761 doc: /* Force status of IME close. */) 971 doc: /* Force status of IME close. 972 If EVENTP is not nil, this function also creates [kanji] key event. */) 762 973 (eventp) 763 974 Lisp_Object eventp; … … 765 976 if (fIME && !NILP (Vime_control)) 766 977 { 767 HIMC himc;768 978 HWND hwnd; 769 979 … … 831 1041 } 832 1042 1043 static struct { 1044 DWORD mask; 1045 char* posi_symbol; 1046 char* nega_symbol; 1047 } cmode_list[] = { 1048 {IME_CMODE_SYMBOL, "symbol", "nosymbol"}, 1049 {IME_CMODE_SOFTKBD, "softkbd", "nosoftkbd"}, 1050 {IME_CMODE_ROMAN, "roman", "noroman"}, 1051 {IME_CMODE_NOCONVERSION, "noconversion", "conversion"}, 1052 {IME_CMODE_NATIVE , "native", "nonative"}, 1053 {IME_CMODE_KATAKANA, "katakana", "nokatakana"}, 1054 {IME_CMODE_HANJACONVERT, "hanja", "nohanja"}, 1055 {IME_CMODE_FULLSHAPE, "fullshape", "halfshape"}, 1056 {IME_CMODE_FIXED, "fixed", "nofixed"}, 1057 {IME_CMODE_EUDC, "eudc", "noeudc"}, 1058 {IME_CMODE_CHARCODE, "charcode", "nocharcode"}, 1059 /* compatibility */ 1060 {IME_CMODE_CHARCODE, "code", "nocode"}, 1061 {IME_CMODE_HANJACONVERT, "kanji", "nokanji"}, 1062 {IME_CMODE_KATAKANA, "katakana", "hiragana"}, 1063 {0, NULL} 1064 }; 1065 1066 1067 DEFUN ("imm-get-conversion-status", 1068 Fimm_get_conversion_status, Simm_get_conversion_status, 1069 0, 0, 0, doc: /* not documented */) 1070 () 1071 { 1072 DWORD dwConversion, dwSentence; 1073 HIMC himc; 1074 HWND hwnd; 1075 Lisp_Object ret; 1076 int i, used; 1077 1078 if (! fIME || NILP (Vime_control)) 1079 return Qnil; 1080 1081 hwnd = FRAME_MW32_WINDOW (SELECTED_FRAME ()); 1082 himc = (ImmGetContextProc) (hwnd); 1083 ret = Qnil; 1084 used = 0; 1085 1086 if (ImmGetConversionStatusProc 1087 && ImmGetConversionStatusProc (himc, &dwConversion, &dwSentence)) 1088 { 1089 for (i = 0 ; cmode_list[i].mask ; i++) 1090 { 1091 if (! (used & cmode_list[i].mask)) 1092 { 1093 used |= cmode_list[i].mask; 1094 1095 if (dwConversion & cmode_list[i].mask) 1096 ret = Fcons (intern (cmode_list[i].posi_symbol), ret); 1097 else 1098 ret = Fcons (intern (cmode_list[i].nega_symbol), ret); 1099 } 1100 } 1101 } 1102 1103 (ImmReleaseContextProc) (hwnd, himc); 1104 return ret; 1105 } 1106 1107 833 1108 DEFUN ("w32-set-ime-mode", 834 1109 Fw32_set_ime_mode, … … 852 1127 { 853 1128 HWND hwnd; 854 int ret;1129 int i, done, ret; 855 1130 int newmode, mask; 856 1131 857 1132 newmode = 0; 858 1133 mask = 0; 1134 done = 0; 1135 1136 for (i = 0 ; cmode_list[i].mask ; i++) 1137 { 1138 if (EQ (mode, intern (cmode_list[i].posi_symbol))) 1139 { 1140 newmode |= cmode_list[i].mask; 1141 mask |= cmode_list[i].mask; 1142 done = 1; 1143 } 1144 else if (EQ (mode, intern (cmode_list[i].nega_symbol))) 1145 { 1146 newmode &= ~cmode_list[i].mask; 1147 mask |= cmode_list[i].mask; 1148 done = 1; 1149 } 1150 } 1151 1152 if (! done) 1153 error ("unknown mode!!"); 859 1154 860 1155 hwnd = FRAME_MW32_WINDOW (f); 861 862 if (EQ (mode, intern ("katakana")))863 {864 newmode |= IME_CMODE_KATAKANA;865 mask |= IME_CMODE_KATAKANA;866 }867 else if (EQ (mode, intern ("hiragana")))868 {869 newmode &= ~IME_CMODE_KATAKANA;870 mask |= IME_CMODE_KATAKANA;871 }872 else if (EQ (mode, intern ("kanji")))873 {874 newmode |= IME_CMODE_HANJACONVERT;875 mask |= IME_CMODE_HANJACONVERT;876 }877 else if (EQ (mode, intern ("nokanji")))878 {879 newmode &= ~IME_CMODE_HANJACONVERT;880 mask |= IME_CMODE_HANJACONVERT;881 }882 else if (EQ (mode, intern ("code")))883 {884 newmode |= IME_CMODE_CHARCODE;885 mask |= IME_CMODE_CHARCODE;886 }887 else if (EQ (mode, intern ("nocode")))888 {889 newmode &= ~IME_CMODE_CHARCODE;890 mask |= IME_CMODE_CHARCODE;891 }892 else if (EQ (mode, intern ("noconvert")))893 {894 newmode |= IME_CMODE_NOCONVERSION;895 mask |= IME_CMODE_NOCONVERSION;896 }897 else if (EQ (mode, intern ("convert")))898 {899 newmode &= ~IME_CMODE_NOCONVERSION;900 mask |= IME_CMODE_NOCONVERSION;901 }902 else903 error ("unknown mode!!");904 905 1156 ret = SendMessage (hwnd, WM_MULE_IMM_SET_MODE, 906 1157 (WPARAM) newmode, (LPARAM) mask); … … 1582 1833 DEFVAR_LISP ("ime-control", &Vime_control, doc: /* IME control flag */); 1583 1834 1835 defsubr (&Simm_get_conversion_status); 1836 defsubr (&Smw32_ime_input_method_function); 1584 1837 defsubr (&Smw32_ime_available); 1585 1838 defsubr (&Smw32_input_language_code); trunk/src/mw32term.c
r3997 r3998 4574 4574 int ocount = count; 4575 4575 4576 if (msg.wParam == VK_PROCESSKEY) 4577 { 4578 int vkey = mw32_ime_get_virtual_key (msg.hwnd); 4579 keyflag = 4580 mw32_emacs_translate_message (dpyinfo, 1, vkey, 4581 &keycode, &keymod); 4582 mw32_ime_record_keycode (keycode, keymod); 4583 } 4576 4584 keyflag = mw32_emacs_translate_message (dpyinfo, 1, msg.wParam, 4577 4585 &keycode, &keymod); … … 4661 4669 { 4662 4670 lpStr = GlobalLock (hw32_ime_string); 4663 while ( 1)4671 while (lpStr) 4664 4672 { 4665 4673 EVENT_INIT (buf); trunk/src/mw32term.h
r3997 r3998 1000 1000 #define WM_MULE_IMM_SET_COMPOSITION_STRING (WM_USER+2303) 1001 1001 #define WM_MULE_IMM_GET_COMPOSITION_STRING (WM_USER+2304) 1002 #define WM_MULE_IMM_SET_MODE (WM_USER+2305) 1002 #define WM_MULE_IMM_GET_RESULT_STRING (WM_USER+2305) 1003 #define WM_MULE_IMM_SET_MODE (WM_USER+2306) 1003 1004 #define WM_MULE_IMM_NOTIFY (WM_USER+2310) 1004 1005 #define WM_MULE_IMM_GET_UNDETERMINED_STRING_LENGTH (WM_USER+2320)
