[uim-commit] r913 - trunk/scm
tkng at freedesktop.org
tkng at freedesktop.org
Fri Jul 1 01:50:13 PDT 2005
Author: tkng
Date: 2005-07-01 01:50:09 -0700 (Fri, 01 Jul 2005)
New Revision: 913
Modified:
trunk/scm/prime-custom.scm
trunk/scm/prime-key-custom.scm
trunk/scm/prime.scm
Log:
* prime.scm, prime-cutsom.scm, prime-key-custom.scm:
- Updated to version 1.0.0 of PRIME.
Modified: trunk/scm/prime-custom.scm
===================================================================
--- trunk/scm/prime-custom.scm 2005-06-27 11:04:29 UTC (rev 912)
+++ trunk/scm/prime-custom.scm 2005-07-01 08:50:09 UTC (rev 913)
@@ -16,10 +16,10 @@
;;; may be used to endorse or promote products derived from this software
;;; without specific prior written permission.
;;;
-;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+;;; THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -31,14 +31,49 @@
(require "i18n.scm")
-
(define prime-im-name-label (N_ "PRIME"))
-(define prime-im-short-desc (N_ "Japanese predictable input method"))
+(define prime-im-short-desc (N_ "Japanese predictive input method"))
(define-custom-group 'prime
- (ugettext prime-im-name-label)
- (ugettext prime-im-short-desc))
+ (ugettext prime-im-name-label)
+ (ugettext prime-im-short-desc))
+(define-custom-group 'prime-advanced
+ (_ "PRIME (advanced)")
+ (_ "Advanced settings for PRIME"))
+
+(define-custom-group 'japanese
+ (_ "Japanese")
+ (_ "Japanese specific settings"))
+
+(define-custom 'prime-custom-default-language 'Japanese
+ '(prime global)
+ (list 'choice
+ (list 'Japanese (_ "Japanese") (_ "Japanese"))
+ (list 'English (_ "English") (_ "English")))
+ (_ "Default language")
+ (_ "long description will be here."))
+
+(define-custom 'prime-auto-register-mode? #t
+ '(prime global)
+ '(boolean)
+ (_ "Enable auto register mode")
+ (_ "long description will be here."))
+
+(define-custom 'prime-custom-japanese-space 'wide
+ '(prime japanese)
+ (list 'choice
+ (list 'wide (_ "Wide width (Zenkaku)") (_ "Wide width (Zenkaku)"))
+ (list 'half (_ "Half width (Hankaku)") (_ "Half width (Hankaku)")))
+ (_ "Space character")
+ (_ "long description will be here."))
+
+(define-custom 'prime-use-unixdomain? #f
+ '(prime advanced)
+ '(boolean)
+ (_ "Use Unix Domain Socket to communicate with PRIME")
+ (_ "long description will be here."))
+
;(define-custom 'prime-use-candidate-window? #t
; '(prime candwin)
; '(boolean)
@@ -52,62 +87,65 @@
; "long description will be here.")
(define-custom 'prime-nr-candidate-max 10
- '(prime candwin)
+ '(prime-advanced candwin)
'(integer 1 20)
(_ "Number of candidates in candidate window at a time")
(_ "long description will be here."))
(define-custom 'prime-always-show-window? #t
- '(prime candwin)
+ '(prime-advanced candwin)
'(boolean)
(_ "Always showing candidate window")
(_ "long description will be here."))
-(define-custom 'prime-auto-register-mode? #t
- '(prime)
+;; If #t a candidate window displays usage examples of candidate words.
+(define-custom 'prime-custom-display-usage? #t
+ '(prime-advanced annotation)
'(boolean)
- (_ "Enable auto register mode")
+ (_ "Show usage examples of candidate words")
(_ "long description will be here."))
-(define-custom 'prime-pseudo-mode-cursor? #f
- '(prime)
+;; If #t a candidate window displays comments of candidate words.
+(define-custom 'prime-custom-display-comment? #t
+ '(prime-advanced annotation)
'(boolean)
- (_ "Enable pseudo mode cursor")
+ (_ "Show candidate annotations")
(_ "long description will be here."))
-(define-custom 'prime-char-annotation? #t
- '(prime)
+;; If #t a candidate window displays forms of candidate words such as
+;; 'l (small L)', 'I (large i)'.
+(define-custom 'prime-custom-display-form? #t
+ '(prime-advanced annotation)
'(boolean)
- (_ "Show candidate annotations")
+ (_ "Show candidate forms")
(_ "long description will be here."))
+;; ------------------------------------------------------------
-;; If #t a candidate window displays usage examples of candidate words.
-(define-custom 'prime-custom-display-usage? #t
- '(prime)
+(define-custom 'prime-custom-number-selection? #f
+ '(prime-advanced special-op)
'(boolean)
- (_ "Show usage examples of candidate words")
+ (_ "Select candidate by numeral keys")
(_ "long description will be here."))
-(define-custom 'prime-use-unixdomain? #f
- '(prime)
+(define-custom 'prime-custom-app-mode-vi? #f
+ '(prime-advanced special-op)
'(boolean)
- (_ "Use Unix Domain Socket to communicate with PRIME")
+ (_ "Friendly for vi user")
(_ "long description will be here."))
-(define-custom 'prime-mask-pending-preedit? #f
- '(prime)
+(define-custom 'prime-pseudo-mode-cursor? #f
+ '(prime-advanced special-op)
'(boolean)
- (_ "Mask preedit strings (For T-Code users)")
+ (_ "Enable pseudo mode cursor")
(_ "long description will be here."))
-;(define-custom 'prime-use-numeral-key-to-select-cand? #t
+;(define-custom 'prime-mask-pending-preedit? #f
; '(prime)
; '(boolean)
-; "Use numeral key to select candidate directly"
-; "long description will be here.")
+; (_ "Mask preedit strings (For T-Code users)")
+; (_ "long description will be here."))
-
;;
;; toolbar
;;
@@ -136,41 +174,46 @@
;;; Input mode
-(define-custom 'default-widget_prime_input_mode 'action_prime_mode_latin
- '(prime toolbar)
- (cons 'choice
- (map indication-alist-entry-extract-choice
- prime-input-mode-indication-alist))
- (_ "Default input mode")
- (_ "long description will be here."))
+(define default-widget_prime_input_mode 'action_prime_mode_latin)
+;; Users don't care this option.
+;; (2005-03-03) <Hiroyuki Komatsu>
+;(define-custom 'default-widget_prime_input_mode 'action_prime_mode_latin
+; '(prime-advanced toolbar)
+; (cons 'choice
+; (map indication-alist-entry-extract-choice
+; prime-input-mode-indication-alist))
+; (_ "Default input mode")
+; (_ "long description will be here."))
-(define-custom 'prime-input-mode-actions
- (map car prime-input-mode-indication-alist)
- '(prime toolbar)
- (cons 'ordered-list
- (map indication-alist-entry-extract-choice
- prime-input-mode-indication-alist))
- (_ "Input mode menu items")
- (_ "long description will be here."))
+(define prime-input-mode-actions (map car prime-input-mode-indication-alist))
+;; Users don't care this option.
+;; (2005-03-03) <Hiroyuki Komatsu>
+;(define-custom 'prime-input-mode-actions
+; (map car prime-input-mode-indication-alist)
+; '(prime-advanced toolbar)
+; (cons 'ordered-list
+; (map indication-alist-entry-extract-choice
+; prime-input-mode-indication-alist))
+; (_ "Input mode menu items")
+; (_ "long description will be here."))
;; value dependency
-(if custom-full-featured?
- (custom-add-hook 'prime-input-mode-actions
- 'custom-set-hooks
- (lambda ()
- (custom-choice-range-reflect-olist-val
- 'default-widget_prime_input_mode
- 'prime-input-mode-actions
- prime-input-mode-indication-alist))))
+;(if custom-full-featured?
+; (custom-add-hook 'prime-input-mode-actions
+; 'custom-set-hooks
+; (lambda ()
+; (custom-choice-range-reflect-olist-val
+; 'default-widget_prime_input_mode
+; 'prime-input-mode-actions
+; prime-input-mode-indication-alist))))
;; dynamic reconfiguration
-(custom-add-hook 'default-widget_prime_input_mode
- 'custom-set-hooks
- (lambda ()
- (prime-configure-widgets)))
+;(custom-add-hook 'default-widget_prime_input_mode
+; 'custom-set-hooks
+; (lambda ()
+; (prime-configure-widgets)))
-(custom-add-hook 'prime-input-mode-actions
- 'custom-set-hooks
- (lambda ()
- (prime-configure-widgets)))
-
+;(custom-add-hook 'prime-input-mode-actions
+; 'custom-set-hooks
+; (lambda ()
+; (prime-configure-widgets)))
Modified: trunk/scm/prime-key-custom.scm
===================================================================
--- trunk/scm/prime-key-custom.scm 2005-06-27 11:04:29 UTC (rev 912)
+++ trunk/scm/prime-key-custom.scm 2005-07-01 08:50:09 UTC (rev 913)
@@ -16,10 +16,10 @@
;;; may be used to endorse or promote products derived from this software
;;; without specific prior written permission.
;;;
-;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+;;; THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -72,37 +72,37 @@
(define-custom 'prime-register-key '("<Control>w")
'(prime-keys1)
'(key)
- (_ "[PRIME] regist a word")
+ (_ "[PRIME] prime-register-key")
(_ "long description will be here"))
(define-custom 'prime-typing-mode-hiragana-key '("F6")
'(prime-keys1 mode-transition)
'(key)
- (_ "[PRIME] hiragana typing mode")
+ (_ "[PRIME] prime-typing-mode-hiragana-key")
(_ "long description will be here"))
(define-custom 'prime-typing-mode-katakana-key '("F7")
'(prime-keys1 mode-transition)
'(key)
- (_ "[PRIME] katakana typing mode")
+ (_ "[PRIME] prime-typing-mode-katakana-key")
(_ "long description will be here"))
(define-custom 'prime-typing-mode-hankana-key '("F8")
'(prime-keys1 mode-transition)
'(key)
- (_ "[PRIME] halfwidth katakana typing mode")
+ (_ "[PRIME] prime-typing-mode-hankana-key")
(_ "long description will be here"))
(define-custom 'prime-typing-mode-wideascii-key '("F9")
'(prime-keys1 mode-transition)
'(key)
- (_ "[PRIME] wide ascii typing mode")
+ (_ "[PRIME] prime-typing-mode-wideascii-key")
(_ "long description will be here"))
(define-custom 'prime-typing-mode-ascii-key '("F10")
'(prime-keys1 mode-transition)
'(key)
- (_ "[PRIME] ascii typing mode")
+ (_ "[PRIME] prime-typing-mode-ascii-key")
(_ "long description will be here"))
;;
Modified: trunk/scm/prime.scm
===================================================================
--- trunk/scm/prime.scm 2005-06-27 11:04:29 UTC (rev 912)
+++ trunk/scm/prime.scm 2005-07-01 08:50:09 UTC (rev 913)
@@ -1,5 +1,5 @@
;;;
-;;; Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
+;;; Copyright (c) 2003,2004 uim Project http://uim.freedesktop.org/
;;;
;;; All rights reserved.
;;;
@@ -15,10 +15,10 @@
;;; may be used to endorse or promote products derived from this software
;;; without specific prior written permission.
;;;
-;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+;;; THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-;;; ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -46,14 +46,6 @@
(require-custom "prime-custom.scm")
(require-custom "prime-key-custom.scm")
-;; configs
-
-(define prime-engine-command-lookup "lookup_compact")
-;(define prime-engine-command-lookup-all "lookup_compact")
-(define prime-engine-command-lookup-all "lookup_compact_all")
-;(define prime-engine-command-lookup "lookup_prefix")
-;(define prime-engine-command-lookup-all "lookup_prefix")
-
;; config function
;; should be replaced with boolean custom variable -- YamaKen 2005-01-15
(define prime-dont-use-numeral-key-to-select-cand
@@ -63,10 +55,32 @@
(and (numeral-char? key)
(control-key-mask key-state))))))
+;; key
+(define-key prime-language-toggle-key? "F11")
+(define-key prime-expand-segment-key? '("<Control>o" "<Shift>right"))
+(define-key prime-shrink-segment-key? '("<Control>i" "<Shift>left"))
+
+(define-key prime-escape-key? '("escape" "<Control>["))
(define-key prime-space-key? '(" "))
(define-key prime-altspace-key? '("<Control> " "<Alt> "))
+(define-key prime-english-next-candidate-key? '("<Control>i" "tab"
+ generic-next-candidate-key?))
+(define-key prime-english-direct-key? '("." "," ":" ";" "(" ")" "\"" "'"
+ "!" "?"))
+;;;; If you're a Vi user, modify the lines below.
+(if prime-custom-app-mode-vi?
+ (begin
+ ;; For Vi users
+ (define-key prime-app-mode-start-key? prime-escape-key?)
+ (define prime-app-mode-end-stroke-list
+ '("i" "I" "a" "A" "o" "O" "C" "s" "S" ("c" . ("l" "w" "e" "c" "G")))))
+ (begin
+ ;; Default
+ (define-key prime-app-mode-start-key? #f)
+ (define prime-app-mode-end-stroke-list #f)))
+
(define prime-cand-select-key?
(lambda (key key-state)
(numeral-char? key)))
@@ -107,6 +121,51 @@
;;;; prime-keymap: Keymaps binding a key stroke to a command.
;;;; ------------------------------------------------------------
+(define prime-keymap-get-keymap
+ (lambda (context key key-state)
+ (let ((mode (prime-context-mode context))
+ (keymap))
+ (cond
+ ((= mode prime-mode-latin)
+ (set! keymap prime-keymap-latin-mode))
+ ((= mode prime-mode-hiragana)
+ (set! keymap (prime-keymap-get-keymap-hiragana context key key-state)))
+ ((= mode prime-mode-wide-latin)
+ (set! keymap prime-keymap-wide-latin-mode))
+ ((= mode prime-mode-application)
+ (set! keymap prime-keymap-app-mode)))
+ keymap)))
+
+(define prime-keymap-get-keymap-hiragana
+ (lambda (context key key-state)
+ (let ((state (prime-context-state context))
+ (language (prime-context-language context))
+ (keymap))
+ (cond
+ ((= state 'prime-state-segment)
+ (set! keymap prime-keymap-segment-state))
+
+ ((= state 'prime-state-modifying)
+ (set! keymap prime-keymap-modify-state))
+
+ ((= state 'prime-state-converting)
+ (if (= language 'Japanese)
+ (set! keymap prime-keymap-conv-state)
+ (set! keymap prime-keymap-english-conv-state)))
+
+ ((= state 'prime-state-preedit)
+ (if (= language 'Japanese)
+ (set! keymap prime-keymap-preedit-state)
+ (set! keymap prime-keymap-english-preedit-state)))
+
+ ((= state 'prime-state-fund)
+ (if (= language 'Japanese)
+ (if (prime-context-parent-context context)
+ (set! keymap prime-keymap-child-fund-state)
+ (set! keymap prime-keymap-fund-state))
+ (set! keymap prime-keymap-english-fund-state))))
+ keymap)))
+
(define prime-keymap-get-command
(lambda (keymap key key-state)
(let ((command-key? (car (car keymap)))
@@ -117,30 +176,58 @@
#f
(prime-keymap-get-command (cdr keymap) key key-state))
))))
-
+
(define prime-keymap-latin-mode
'(
- (prime-on-key? . prime-command-japanese-mode)
- (prime-any-key? . prime-command-latin-input)
+ (prime-on-key? . prime-command-japanese-mode)
+ (prime-app-mode-start-key? . prime-command-app-mode-start)
+ (prime-any-key? . prime-command-commit-raw)
))
+(define prime-subkeymap-child-context
+ '(
+ (prime-prev-candidate-key? . prime-command-fund-cancel)
+ (prime-next-candidate-key? . prime-command-fund-cancel)
+ (prime-backspace-key? . prime-command-fund-backspace)
+ (prime-delete-key? . prime-command-fund-delete)
+ (prime-cancel-key? . prime-command-fund-cancel)
+ (prime-commit-key? . prime-command-child-commit)
+ (prime-go-left-key? . prime-command-fund-cursor-left)
+ (prime-go-right-key? . prime-command-fund-cursor-right)
+ (prime-go-left-edge-key? . prime-command-fund-cursor-left-edge)
+ (prime-go-right-edge-key? . prime-command-fund-cursor-right-edge)
+
+ (prime-space-key? . prime-command-fund-space)
+ (prime-altspace-key? . prime-command-fund-altspace)
+ (prime-with-control-key? . prime-command-pass)
+ (prime-ja-direct-key? . prime-command-fund-commit-ja-direct)
+ (prime-symbol-key? . prime-command-pass)
+ (prime-any-key? . prime-command-commit)
+ ))
+
(define prime-keymap-wide-latin-mode
'(
- (prime-on-key? . prime-command-japanese-mode)
- (prime-normal-key? . prime-command-wide-latin-input)
- (prime-any-key? . prime-command-commit-raw)
+ (prime-on-key? . prime-command-japanese-mode)
+ (prime-app-mode-start-key? . prime-command-app-mode-start)
+ (prime-normal-key? . prime-command-wide-latin-input)
+ (prime-any-key? . prime-command-commit-raw)
))
+(define prime-keymap-app-mode
+ '((prime-any-key? . prime-command-app-mode)))
+
(define prime-keymap-fund-state
'(
- (prime-wide-latin-key? . prime-command-wide-latin-mode)
- (prime-latin-key? . prime-command-latin-mode)
+ (prime-wide-latin-key? . prime-command-wide-latin-mode)
+ (prime-latin-key? . prime-command-latin-mode)
+ (prime-app-mode-start-key? . prime-command-app-mode-start)
;; Typing mode key bindings
(prime-typing-mode-hiragana-key? . prime-command-mode-hiragana)
(prime-typing-mode-katakana-key? . prime-command-mode-katakana)
(prime-typing-mode-hankana-key? . prime-command-mode-hankana)
(prime-typing-mode-wideascii-key? . prime-command-mode-wideascii)
(prime-typing-mode-ascii-key? . prime-command-mode-ascii)
+ (prime-language-toggle-key? . prime-command-language-toggle)
(prime-space-key? . prime-command-fund-space)
(prime-altspace-key? . prime-command-fund-altspace)
@@ -150,30 +237,11 @@
(prime-any-key? . prime-command-fund-input)
))
-(define prime-keymap-register-fund-state
+(define prime-keymap-child-fund-state
'(
- (prime-prev-candidate-key? . prime-command-register-fund-cancel)
- (prime-next-candidate-key? . prime-command-register-fund-cancel)
- (prime-wide-latin-key? . prime-command-wide-latin-mode)
- (prime-latin-key? . prime-command-latin-mode)
-;; FIXME: A register-fund-state also needs the following key bindings
-;; FIMXE: as well as a fund-state.
-;; FIXME: (2004-06-15) <komatsu at taiyaki.org>
-
- (prime-space-key? . prime-command-pass)
- (prime-altspace-key? . prime-command-pass)
-; (prime-space-key? . prime-command-fund-space)
-; (prime-altspace-key? . prime-command-fund-altspace)
-; (prime-ja-direct-key? . prime-command-fund-commit-ja-direct)
- (prime-backspace-key? . prime-command-register-fund-backspace)
- (prime-delete-key? . prime-command-register-fund-delete)
- (prime-cancel-key? . prime-command-register-fund-cancel)
- (prime-commit-key? . prime-command-register-fund-commit)
- (prime-go-left-key? . prime-command-register-fund-cursor-left)
- (prime-go-right-key? . prime-command-register-fund-cursor-right)
- (prime-go-left-edge-key? . prime-command-register-fund-cursor-left-edge)
- (prime-go-right-edge-key? . prime-command-register-fund-cursor-right-edge)
-
+ (prime-wide-latin-key? . prime-command-wide-latin-mode)
+ (prime-latin-key? . prime-command-latin-mode)
+ (prime-app-mode-start-key? . prime-command-app-mode-start)
;; Typing mode key bindings
(prime-typing-mode-hiragana-key? . prime-command-mode-hiragana)
(prime-typing-mode-katakana-key? . prime-command-mode-katakana)
@@ -181,10 +249,23 @@
(prime-typing-mode-wideascii-key? . prime-command-mode-wideascii)
(prime-typing-mode-ascii-key? . prime-command-mode-ascii)
-; (prime-with-control-key? . prime-command-commit-raw)
- (prime-with-control-key? . prime-command-pass)
- (prime-symbol-key? . prime-command-pass)
- (prime-any-key? . prime-command-fund-input)
+ (prime-prev-candidate-key? . prime-command-fund-cancel)
+ (prime-next-candidate-key? . prime-command-fund-cancel)
+ (prime-backspace-key? . prime-command-fund-backspace)
+ (prime-delete-key? . prime-command-fund-delete)
+ (prime-cancel-key? . prime-command-fund-cancel)
+ (prime-commit-key? . prime-command-child-finish)
+ (prime-go-left-key? . prime-command-fund-cursor-left)
+ (prime-go-right-key? . prime-command-fund-cursor-right)
+ (prime-go-left-edge-key? . prime-command-fund-cursor-left-edge)
+ (prime-go-right-edge-key? . prime-command-fund-cursor-right-edge)
+
+ (prime-space-key? . prime-command-fund-space)
+ (prime-altspace-key? . prime-command-fund-altspace)
+ (prime-with-control-key? . prime-command-pass)
+ (prime-ja-direct-key? . prime-command-fund-commit-ja-direct)
+ (prime-symbol-key? . prime-command-pass)
+ (prime-any-key? . prime-command-fund-input)
))
(define prime-keymap-preedit-state
@@ -214,116 +295,186 @@
(prime-any-key? . prime-command-preedit-input)
))
-(define prime-keymap-register-preedit-state
+(define prime-keymap-conv-state
'(
- (prime-begin-conv-key? . prime-command-preedit-convert)
- (prime-next-candidate-key? . prime-command-preedit-convert)
- (prime-prev-candidate-key? . prime-command-preedit-convert-reversely)
- (prime-delete-key? . prime-command-preedit-delete)
- (prime-cancel-key? . prime-command-preedit-cancel)
- (prime-backspace-key? . prime-command-preedit-backspace)
- (prime-commit-key? . prime-command-register-preedit-commit)
- (prime-go-left-edge-key? . prime-command-preedit-cursor-left-edge)
- (prime-go-right-edge-key? . prime-command-preedit-cursor-right-edge)
- (prime-go-left-key? . prime-command-preedit-cursor-left)
- (prime-go-right-key? . prime-command-preedit-cursor-right)
- (prime-cand-select-key? . prime-command-register-preedit-commit-candidate)
- ;; Typing mode key bindings
- (prime-typing-mode-hiragana-key? . prime-command-mode-hiragana)
- (prime-typing-mode-katakana-key? . prime-command-mode-katakana)
- (prime-typing-mode-hankana-key? . prime-command-mode-hankana)
- (prime-typing-mode-wideascii-key? . prime-command-mode-wideascii)
- (prime-typing-mode-ascii-key? . prime-command-mode-ascii)
+ (prime-register-key? . prime-command-register-mode)
+ (prime-next-candidate-key? . prime-command-conv-next)
+ (prime-prev-candidate-key? . prime-command-conv-prev)
+ (prime-cancel-key? . prime-command-conv-cancel)
+ (prime-backspace-key? . prime-command-conv-cancel)
+ (prime-commit-key? . prime-command-conv-commit)
+ (prime-go-left-edge-key? . prime-command-modify-cursor-left-edge)
+ (prime-go-right-edge-key? . prime-command-modify-cursor-right-edge)
+ (prime-go-left-key? . prime-command-modify-cursor-left)
+ (prime-go-right-key? . prime-command-modify-cursor-right)
+ (prime-expand-segment-key? . prime-command-modify-cursor-right)
+ (prime-shrink-segment-key? . prime-command-modify-cursor-left)
+ (prime-cand-select-key? . prime-command-conv-select)
+ ;; Typing mode key bindings
+ (prime-typing-mode-hiragana-key? . prime-command-mode-hiragana)
+ (prime-typing-mode-katakana-key? . prime-command-mode-katakana)
+ (prime-typing-mode-hankana-key? . prime-command-mode-hankana)
+ (prime-typing-mode-wideascii-key? . prime-command-mode-wideascii)
+ (prime-typing-mode-ascii-key? . prime-command-mode-ascii)
+ (prime-symbol-key? . prime-command-pass)
+ (prime-with-control-key? . prime-command-pass)
+ (prime-any-key? . prime-command-conv-input)
+ ))
- (prime-command-key? . prime-command-pass)
- (prime-symbol-key? . prime-command-pass)
- (prime-any-key? . prime-command-preedit-input)
+(define prime-keymap-modify-state
+ '(
+; (prime-register-key? . prime-command-register-mode)
+ (prime-begin-conv-key? . prime-command-modify-convert)
+ (prime-next-candidate-key? . prime-command-modify-convert)
+ (prime-prev-candidate-key? . prime-command-modify-convert-reversely)
+ (prime-cancel-key? . prime-command-conv-cancel)
+; (prime-backspace-key? . prime-command-conv-cancel)
+ (prime-commit-key? . prime-command-modify-commit)
+ (prime-go-left-edge-key? . prime-command-modify-cursor-left-edge)
+ (prime-go-right-edge-key? . prime-command-modify-cursor-right-edge)
+ (prime-go-left-key? . prime-command-modify-cursor-left)
+ (prime-go-right-key? . prime-command-modify-cursor-right)
+ (prime-expand-segment-key? . prime-command-modify-cursor-expand)
+ (prime-shrink-segment-key? . prime-command-modify-cursor-shrink)
+; ;; Typing mode key bindings
+; (prime-typing-mode-hiragana-key? . prime-command-mode-hiragana)
+; (prime-typing-mode-katakana-key? . prime-command-mode-katakana)
+; (prime-typing-mode-hankana-key? . prime-command-mode-hankana)
+; (prime-typing-mode-wideascii-key? . prime-command-mode-wideascii)
+; (prime-typing-mode-ascii-key? . prime-command-mode-ascii)
+ (prime-symbol-key? . prime-command-pass)
+ (prime-with-control-key? . prime-command-pass)
+ (prime-any-key? . prime-command-conv-input)
))
-(define prime-keymap-conv-state
+(define prime-keymap-segment-state
'(
- (prime-register-key? . prime-command-register-mode)
- (prime-next-candidate-key? . prime-command-conv-next)
- (prime-prev-candidate-key? . prime-command-conv-prev)
- (prime-cancel-key? . prime-command-conv-cancel)
- (prime-backspace-key? . prime-command-conv-cancel)
- (prime-commit-key? . prime-command-conv-commit)
- (prime-cand-select-key? . prime-command-conv-select)
- ;; Typing mode key bindings
- (prime-typing-mode-hiragana-key? . prime-command-mode-hiragana)
- (prime-typing-mode-katakana-key? . prime-command-mode-katakana)
- (prime-typing-mode-hankana-key? . prime-command-mode-hankana)
- (prime-typing-mode-wideascii-key? . prime-command-mode-wideascii)
- (prime-typing-mode-ascii-key? . prime-command-mode-ascii)
+ (prime-cancel-key? . prime-command-segment-cancel)
+ (prime-commit-key? . prime-command-modify-commit)
+ (prime-next-candidate-key? . prime-command-segment-next)
+ (prime-prev-candidate-key? . prime-command-segment-prev)
+ (prime-go-left-edge-key? . prime-command-modify-cursor-left-edge)
+ (prime-go-right-edge-key? . prime-command-modify-cursor-right-edge)
+ (prime-go-left-key? . prime-command-modify-cursor-left)
+ (prime-go-right-key? . prime-command-modify-cursor-right)
+ (prime-expand-segment-key? . prime-command-modify-cursor-expand)
+ (prime-shrink-segment-key? . prime-command-modify-cursor-shrink)
+ (prime-symbol-key? . prime-command-pass)
+ (prime-with-control-key? . prime-command-pass)
+ (prime-any-key? . prime-command-conv-input)
+; (prime-any-key? . prime-command-pass)
+ ))
- (prime-symbol-key? . prime-command-pass)
- (prime-with-control-key? . prime-command-pass)
- (prime-any-key? . prime-command-conv-input)
- ))
+;; Keymaps for English
-(define prime-keymap-register-conv-state
+(define prime-keymap-english-fund-state
'(
- (prime-next-candidate-key? . prime-command-register-conv-next)
- (prime-prev-candidate-key? . prime-command-conv-prev)
- (prime-cancel-key? . prime-command-conv-cancel)
- (prime-backspace-key? . prime-command-conv-cancel)
- (prime-commit-key? . prime-command-register-conv-commit)
- (prime-cand-select-key? . prime-command-register-conv-select)
- ;; Typing mode key bindings
- (prime-typing-mode-hiragana-key? . prime-command-mode-hiragana)
- (prime-typing-mode-katakana-key? . prime-command-mode-katakana)
- (prime-typing-mode-hankana-key? . prime-command-mode-hankana)
- (prime-typing-mode-wideascii-key? . prime-command-mode-wideascii)
- (prime-typing-mode-ascii-key? . prime-command-mode-ascii)
- (prime-symbol-key? . prime-command-pass)
- (prime-with-control-key? . prime-command-pass)
- (prime-any-key? . prime-command-register-conv-input)
- ))
+ (prime-space-key? . prime-command-commit-raw)
+ (prime-english-direct-key? . prime-command-commit-raw)
+ (prime-wide-latin-key? . prime-command-wide-latin-mode)
+ (prime-latin-key? . prime-command-latin-mode)
+ (prime-app-mode-start-key? . prime-command-app-mode-start)
+ (prime-language-toggle-key? . prime-command-language-toggle)
+ (prime-with-control-key? . prime-command-commit-raw)
+ (prime-symbol-key? . prime-command-commit-raw)
+ (prime-any-key? . prime-command-fund-input)
+ ))
+
+(define prime-keymap-english-preedit-state
+ '(
+ (prime-space-key? . prime-command-preedit-commit-and-space)
+ (prime-english-direct-key? . prime-command-preedit-commit-and-commit-raw)
+ (prime-begin-conv-key? . prime-command-preedit-convert)
+ (prime-english-next-candidate-key? . prime-command-preedit-convert)
+ (prime-prev-candidate-key? . prime-command-preedit-convert-reversely)
+ (prime-delete-key? . prime-command-preedit-delete)
+ (prime-cancel-key? . prime-command-preedit-cancel)
+ (prime-backspace-key? . prime-command-preedit-backspace)
+ (prime-commit-key? . prime-command-preedit-commit)
+ (prime-go-left-edge-key? . prime-command-preedit-cursor-left-edge)
+ (prime-go-right-edge-key? . prime-command-preedit-cursor-right-edge)
+ (prime-go-left-key? . prime-command-preedit-cursor-left)
+ (prime-go-right-key? . prime-command-preedit-cursor-right)
+ (prime-cand-select-key? . prime-command-preedit-commit-candidate)
+
+ (prime-command-key? . prime-command-pass)
+ (prime-symbol-key? . prime-command-pass)
+ (prime-any-key? . prime-command-preedit-input)
+ ))
+
+(define prime-keymap-english-conv-state
+ '(
+ (prime-space-key? . prime-command-conv-commit-and-space)
+ (prime-english-direct-key? . prime-command-conv-commit-and-commit-raw)
+ (prime-english-next-candidate-key? . prime-command-conv-next)
+ (prime-prev-candidate-key? . prime-command-conv-prev)
+ (prime-cancel-key? . prime-command-conv-cancel)
+ (prime-backspace-key? . prime-command-conv-cancel)
+ (prime-commit-key? . prime-command-conv-commit)
+ (prime-cand-select-key? . prime-command-conv-select)
+ (prime-symbol-key? . prime-command-pass)
+ (prime-with-control-key? . prime-command-pass)
+ (prime-any-key? . prime-command-conv-input)
+ ))
+
;;;; ------------------------------------------------------------
-;;; implementations
+;;; Implementations
-(define prime-mode-latin 0)
-(define prime-mode-hiragana 1)
-(define prime-mode-wide-latin 2)
+(define prime-mode-latin 0)
+(define prime-mode-hiragana 1)
+(define prime-mode-wide-latin 2)
+(define prime-mode-application 3)
(register-action 'action_prime_mode_latin
- (lambda (pc)
+ (lambda (context)
'(figure_prime_mode_latin
- "P"
- "ľÀÜÆþÎÏ"
+ "p[--]"
+ "Ä̾ïÆþÎÏ"
"PRIME¤ò¥ª¥Õ"))
- (lambda (pc)
- (= (prime-context-mode pc)
+ (lambda (context)
+ (= (prime-context-mode context)
prime-mode-latin))
- (lambda (pc)
- (prime-mode-set pc prime-mode-latin)))
+ (lambda (context)
+ (prime-mode-set context prime-mode-latin)))
(register-action 'action_prime_mode_hiragana
- (lambda (pc)
+ (lambda (context)
'(figure_prime_mode_hiragana
- "¤×"
+ "P[¤¢]"
"ÆüËܸì"
"PRIME¤ò¥ª¥ó"))
- (lambda (pc)
- (= (prime-context-mode pc)
+ (lambda (context)
+ (= (prime-context-mode context)
prime-mode-hiragana))
- (lambda (pc)
- (prime-mode-set pc prime-mode-hiragana)))
+ (lambda (context)
+ (prime-mode-set context prime-mode-hiragana)))
(register-action 'action_prime_mode_wide_latin
- (lambda (pc)
+ (lambda (context)
'(figure_prime_mode_wide_latin
- "£Ð"
+ "P[£Á]"
"Á´³Ñ±Ñ¿ô"
"Á´³Ñ¤òÆþÎÏ"))
- (lambda (pc)
- (= (prime-context-mode pc)
+ (lambda (context)
+ (= (prime-context-mode context)
prime-mode-wide-latin))
- (lambda (pc)
- (prime-mode-set pc prime-mode-wide-latin)))
+ (lambda (context)
+ (prime-mode-set context prime-mode-wide-latin)))
+(register-action 'action_prime_mode_application
+ (lambda (context)
+ '(figure_prime_mode_application
+ "P[¡ª]"
+ "Æüì"
+ "¥¢¥×¥ê¥±¡¼¥·¥ç¥ó°Í¸"))
+ (lambda (context)
+ (= (prime-context-mode context)
+ prime-mode-application))
+ (lambda (context)
+ (prime-mode-set context prime-mode-application)))
+
;; Update widget definitions based on action configurations. The
;; procedure is needed for on-the-fly reconfiguration involving the
;; custom API
@@ -334,76 +485,156 @@
(actions-new prime-input-mode-actions))
(context-list-replace-widgets! 'prime prime-widgets)))
+
(define prime-context-rec-spec
(append
context-rec-spec
(list
- (list 'state 'prime-state-no-preedit)
- (list 'learning-word #f)
- (list 'nth 0)
- (list 'candidates ())
- (list 'mode prime-mode-latin)
- (list 'last-word "") ;;PRIME¤äPOBox¤ÎÍѸì¤Ç¤¤¤¦Context
- (list 'session "") ; the actual value is -default or -register.
- (list 'session-default "")
- (list 'session-register "")
- (list 'register-line '(() . ()))
- ;; history = (prev-status, prev-preedition, prev-register-preedtion
- ;; index-of-candidate)
- (list 'history '(prime-state-no-preedit ("" "" "") (() . ()) 0)))))
+ ;; Upper level context which is used for registering a word.
+ (list 'parent-context #f)
+ (list 'display-head '())
+ (list 'display-tail '())
+ (list 'fund-line '(() . ()))
+ (list 'preedit-line '("" "" ""))
+ (list 'state 'prime-state-fund)
+ (list 'nth 0)
+ (list 'candidates ())
+ (list 'mode prime-mode-latin)
+ (list 'last-word "") ;; PRIME¤äPOBox¤ÎÍѸì¤Ç¤¤¤¦Context
+ (list 'session #f) ; the actual value is -default or -register.
+ ; language of the current session.
+ (list 'language prime-custom-default-language)
+ (list 'lang-session-list ()) ; session data of each language
+ (list 'modification '("" "" ""))
+ (list 'segment-nth 0)
+ (list 'segment-candidates ())
+ (list 'history ())
+ (list 'previous-mode prime-mode-latin)
+ (list 'app-mode-key-list ())
+ )))
(define-record 'prime-context prime-context-rec-spec)
(define prime-context-new-internal prime-context-new)
(define prime-context-new
(lambda (id im)
- (print "prime-context-new")
- (let ((context (prime-context-new-internal id im))
- (session1 (prime-engine-session-start))
- (session2 (prime-engine-session-start)))
- (prime-context-set-session! context session1)
- (prime-context-set-session-default! context session1)
- (prime-context-set-session-register! context session2)
+ (let ((context (prime-context-new-internal id im)))
(prime-context-set-widgets! context prime-widgets)
context)))
-(define prime-context-history-set!
+(define prime-context-new2
+ (lambda (id im)
+ (let ((context (prime-context-new-internal id im)))
+ (prime-context-initialize! context)
+ context)))
+
+;; This initializes an empty context, and also initializes the prime server.
+;; This returns context.
+(define prime-context-initialize!
(lambda (context)
- (prime-context-set-history! context (list
- (prime-context-state context)
- (prime-context-copy-preedit-line context)
- (prime-context-copy-register-line context)
- (prime-context-nth context)))))
-(define prime-context-history-get prime-context-history)
+ (print "prime-context-initialize!")
+ (if (null? (prime-context-session context))
+ (begin
+ ;; The prime server is initialized here.
+ (prime-lib-init prime-use-unixdomain?)
+ (let ((session (prime-engine-session-start)))
+ (prime-custom-init)
+ (prime-context-set-fund-line! context (cons (list) (list)))
+ (prime-context-set-session! context session)
+ (prime-context-set-lang-session-list!
+ context
+ (list (cons (prime-engine-session-language-get session) session)))
+ (prime-context-history-update! context))))
+ context))
+
+;; This function pushs the current context-data to the stack of
+;; uim-contexts and create a new context-data.
+(define prime-context-push
+ (lambda (context)
+ (print "prime-context-push")
+ (let* ((im (prime-context-im context))
+ (id (prime-context-id context))
+ (new-context (prime-context-new2 (prime-context-id context) im)))
+
+ (prime-context-set-history! new-context (prime-context-history context))
+ (set-cdr! (assoc 'state (prime-context-history new-context))
+ 'prime-state-pushed)
+ (prime-context-set-parent-context! new-context (cons id (cdr context)))
+ (set-cdr! (find-context id) (cdr new-context))
+ new-context)))
+
+;; This function destories the current context-data and pops the tail
+;; context-data from the stack of uim-contexts.
+(define prime-context-pop
+ (lambda (context)
+ (let ((parent-context (prime-context-parent-context context)))
+ (mapcar
+ (lambda (lang-pair)
+ (prime-engine-session-end (cdr lang-pair)))
+ (prime-context-lang-session-list context))
+ (if parent-context
+ (begin
+ (prime-context-set-history! context
+ (prime-context-history parent-context))
+ (set-cdr! (assoc 'state (prime-context-history context))
+ 'prime-state-poped)
+ (set-cdr! (find-context (prime-context-id context))
+ (cdr parent-context))
+ ))
+ parent-context)))
+
+(define prime-context-history-update!
+ (lambda (context)
+ (let* ((state (prime-context-state context))
+ (selected-index (if (= state 'prime-state-segment)
+ (prime-context-segment-nth context)
+ (prime-context-nth context))))
+ (prime-context-set-history!
+ context
+ (list (cons 'state state)
+ (cons 'preedit-line (prime-context-copy-preedit-line context))
+ (cons 'fund-line (prime-context-copy-fund-line context))
+ (cons 'selected-index selected-index)
+ (cons 'conversion-line (copy-list
+ (prime-context-modification context)))
+ )))))
+
(define prime-context-history-compare
(lambda (context)
- (print "prime-context-history-compare")
- (let ((prev-data (prime-context-history-get context)))
+ (let* ((prev-data (prime-context-history context))
+ (state (prime-context-state context))
+ (selected-index (if (= state 'prime-state-segment)
+ (prime-context-segment-nth context)
+ (prime-context-nth context))))
(cond
- ((not (equal? (prime-context-state context) (nth 0 prev-data)))
+ ((not (equal? state
+ (cdr (assoc 'state prev-data))))
'state)
- ((not (equal? (prime-context-get-preedit-line context) (nth 1 prev-data)))
+ ((not (equal? (prime-context-get-preedit-line context)
+ (cdr (assoc 'preedit-line prev-data))))
'preedit)
- ((not (equal? (prime-context-get-register-line context) (nth 2 prev-data)))
+ ((not (equal? (prime-context-fund-line context)
+ (cdr (assoc 'fund-line prev-data))))
'cursor)
- ((not (equal? (prime-context-nth context) (nth 3 prev-data)))
+ ((not (equal? selected-index
+ (cdr (assoc 'selected-index prev-data))))
'nth)
+ ((not (equal? (prime-context-modification context)
+ (cdr (assoc 'conversion-line prev-data))))
+ 'cursor)
))))
-(define prime-context-reset-register-line!
+(define prime-context-reset-fund-line!
(lambda (context)
- (prime-editor-set-left (prime-context-get-register-line context) '())
- (prime-editor-set-right (prime-context-get-register-line context) '())
+ (prime-editor-set-left (prime-context-fund-line context) '())
+ (prime-editor-set-right (prime-context-fund-line context) '())
))
-(define prime-context-copy-register-line
+(define prime-context-copy-fund-line
(lambda (context)
- (let ((line (prime-context-get-register-line context)))
+ (let ((line (prime-context-fund-line context)))
(cons (copy-list (car line)) (copy-list (cdr line)))
)))
-(define prime-context-get-register-line prime-context-register-line)
-;; prime-context-set-register-line! is implicitly defined by define-record
-
(define prime-context-reset-preedit-line!
(lambda (context)
(prime-engine-edit-erase (prime-context-session context))))
@@ -417,80 +648,29 @@
;; The structure of the list is [left, cursor, right]. ex. ["ab", "c", "de"].
(define prime-context-get-preedit-line
(lambda (context)
- (prime-engine-edit-get-preedition (prime-context-session context))))
+ (prime-context-preedit-line context)))
-
-(define prime-send-command
- (lambda (command)
- (let ((result (prime-lib-send-command command)))
- (let loop ((res result))
- (if (string=? res "")
- (loop (prime-lib-send-command ""))
- res
- )))))
-
(define prime-preedit-reset!
(lambda (context)
- (print "prime-preedit-reset!")
-
- (prime-context-set-state! context 'prime-state-no-preedit)
+ (prime-context-set-state! context 'prime-state-fund)
(prime-context-reset-preedit-line! context)
(prime-context-set-nth! context 0)
))
(define prime-get-nth-candidate
(lambda (context n)
- (print "prime-get-nth-candidate")
(if (>= n (prime-get-nr-candidates context))
#f
- (nth 1 (nth n (prime-context-candidates context))))))
+ (car (nth n (prime-context-candidates context))))))
-;; This returns the data sepecified by key of the N th word.
-;; This is called by prime-get-nth-usage and prime-get-nth-annotation.
-(define prime-get-nth-word-data
- (lambda (context n key)
- (if (> n (prime-get-nr-candidates context))
- #f
- (cadr (assoc key
- (nth 2 (nth n (prime-context-candidates context))))))))
-
-(define prime-get-nth-usage
- (lambda (context n)
- (print "prime-get-nth-usage")
- (prime-get-nth-word-data context n "usage")))
-
-(define prime-get-nth-annotation
- (lambda (context n)
- (print "prime-get-nth-annotation")
- (prime-get-nth-word-data context n "annotation")))
-
(define prime-get-nr-candidates
(lambda (context)
(length (prime-context-candidates context))))
(define prime-get-current-candidate
(lambda (context)
- (print "prime-get-current-candidate")
(prime-get-nth-candidate context (prime-context-nth context))))
-(define prime-get-candidates! ;;¤â¤¦¤Á¤ç¤Ã¤È´Ø¿ô̾¤ò¤É¤¦¤Ë¤«¤·¤¿¤¤
- (lambda (context preedit prime-context)
- (print "prime-get-candidates!")
- (prime-engine-set-context prime-context)
- (prime-context-set-candidates!
- context
- (prime-engine-lookup prime-engine-command-lookup preedit))
- ))
-
-(define prime-get-all-candidates! ;;¤³¤ì¤â¤â¤¦¤Á¤ç¤Ã¤È´Ø¿ô̾¤ò¤É¤¦¤Ë¤«¤·¤¿¤¤
- (lambda (context preedit prime-context)
- (prime-engine-set-context prime-context)
- (prime-context-set-candidates!
- context
- (prime-engine-lookup prime-engine-command-lookup-all preedit))
- ))
-
-
;;;; ------------------------------------------------------------
;;;; prime-util: General purpose functions
;;;; ------------------------------------------------------------
@@ -518,20 +698,39 @@
;; The second argument separator must be a single character string.
(define prime-util-string-split
(lambda (string separator)
- (if (string? string)
- (let ((result (list))
- (node-string ""))
- (map (lambda (target)
- (if (equal? target separator)
- (begin
- (set! result (cons node-string result))
- (set! node-string ""))
- (set! node-string (string-append node-string target))))
- (reverse (string-to-list string)))
- (set! result (cons node-string result))
- (reverse result))
- "")))
+ (let ((result (list))
+ (node-string ""))
+ (map (lambda (target)
+ (if (equal? target separator)
+ (begin
+ (set! result (cons node-string result))
+ (set! node-string ""))
+ (set! node-string (string-append node-string target))))
+ (reverse (string-to-list string)))
+ (set! result (cons node-string result))
+ (reverse result))))
+(define prime-util-string-to-integer
+ (lambda (string)
+ (let ((integer 0)
+ (figure 1))
+ (mapcar
+ (lambda (digit-string)
+ (if (string=? digit-string "-")
+ (set! integer (- integer))
+ (set! integer (+ integer (* (- (string->charcode digit-string)
+ (string->charcode "0"))
+ figure))))
+ (set! figure (* figure 10)))
+ (string-to-list string))
+ integer)))
+
+;; This returns #t, if the argument command like "<Control>j" reflects
+;; a pair of key and key-state. The type of both key and key-stae is integer.
+(define prime-util-command-match?
+ (lambda (command key key-state)
+ ((make-key-predicate (modify-key-strs-implicitly command)) key key-state)))
+
;;;; ------------------------------------------------------------
;;;; prime-uim:
;;;; ------------------------------------------------------------
@@ -548,6 +747,14 @@
;;;; prime-engine: Functions to connect with a prime server.
;;;; ------------------------------------------------------------
+(define prime-send-command
+ (lambda (command)
+ (let ((result (prime-lib-send-command command)))
+ (let loop ((buffer result))
+ (if (string=? buffer "")
+ (loop (prime-lib-send-command ""))
+ buffer)))))
+
;; Don't append "\n" to arg-list in this function. That will cause a
;; problem with unix domain socket.
(define prime-engine-send-command
@@ -558,36 +765,110 @@
(prime-util-string-concat arg-list "\t"))
"\n"))))
-(define prime-engine-lookup
- (lambda (command string)
- (print "prime-engine-lookup")
- (mapcar
- (lambda (string-line)
- (let ((word-data (prime-util-string-split string-line "\t")))
- (list (nth 0 word-data) ; reading
- (nth 1 word-data) ; literal
- (prime-util-assoc-list (nthcdr 2 word-data)))))
- (prime-engine-send-command (list command string)))))
+(define prime-engine-conv-predict
+ (lambda (prime-session)
+ (cdr (prime-engine-conv-convert-internal prime-session "conv_predict"))))
-(define prime-engine-set-context
- (lambda (prime-context)
- (if (string=? prime-context "")
- (prime-engine-reset-context)
- (prime-engine-send-command (list "set_context" prime-context)))))
+(define prime-engine-conv-convert
+ (lambda (prime-session)
+ (cdr (prime-engine-conv-convert-internal prime-session "conv_convert"))))
-(define prime-engine-reset-context
- (lambda ()
- (prime-engine-send-command (list "reset_context"))))
+(define prime-engine-conv-convert-internal
+ (lambda (prime-session command)
+ (let* ((result
+ (prime-engine-send-command (list command prime-session)))
+ (index (prime-util-string-to-integer (car result)))
+ (words (mapcar
+ (lambda (string-line)
+ (let ((word-data (prime-util-string-split string-line
+ "\t")))
+ (list (car word-data) ; literal
+ (prime-util-assoc-list (cdr word-data)))))
+ (cdr result))))
+ (cons index words))))
+(define prime-engine-conv-select
+ (lambda (prime-session index-no)
+ (prime-engine-send-command (list "conv_select"
+ prime-session
+ (digit->string index-no)))))
+
+;; This sends a conv_commit command to the server and returns the commited
+;; string.
+(define prime-engine-conv-commit
+ (lambda (prime-session)
+ (car (prime-engine-send-command (list "conv_commit" prime-session)))))
+
+(define prime-engine-modify-cursor-internal
+ (lambda (prime-session command)
+ (prime-util-string-split
+ (car (prime-engine-send-command (list command prime-session)))
+ "\t")))
+
+(define prime-engine-modify-cursor-right
+ (lambda (prime-session)
+ (prime-engine-modify-cursor-internal prime-session "modify_cursor_right")))
+(define prime-engine-modify-cursor-left
+ (lambda (prime-session)
+ (prime-engine-modify-cursor-internal prime-session "modify_cursor_left")))
+(define prime-engine-modify-cursor-right-edge
+ (lambda (prime-session)
+ (prime-engine-modify-cursor-internal prime-session
+ "modify_cursor_right_edge")))
+(define prime-engine-modify-cursor-left-edge
+ (lambda (prime-session)
+ (prime-engine-modify-cursor-internal prime-session
+ "modify_cursor_left_edge")))
+(define prime-engine-modify-cursor-expand
+ (lambda (prime-session)
+ (prime-engine-modify-cursor-internal prime-session
+ "modify_cursor_expand")))
+(define prime-engine-modify-cursor-shrink
+ (lambda (prime-session)
+ (prime-engine-modify-cursor-internal prime-session
+ "modify_cursor_shrink")))
+
+(define prime-engine-segment-select
+ (lambda (prime-session index-no)
+ (prime-util-string-split
+ (car (prime-engine-send-command (list "segment_select"
+ prime-session
+ (digit->string index-no))))
+ "\t")))
+
+(define prime-engine-segment-reconvert
+ (lambda (prime-session)
+ (prime-engine-conv-convert-internal prime-session "segment_reconvert")))
+
+(define prime-engine-context-reset
+ (lambda (prime-session)
+ (prime-engine-send-command (list "context_reset" prime-session))))
+
+
;; session operations
(define prime-engine-session-start
(lambda ()
(car (prime-engine-send-command (list "session_start")))))
-
(define prime-engine-session-end
(lambda (prime-session)
(prime-engine-send-command (list "session_end" prime-session))))
+(define prime-engine-session-language-set
+ (lambda (language)
+ (let ((language-string (if (= language 'English) "English" "Japanese")))
+ (car (prime-engine-send-command
+ (list "session_start" language-string))))))
+
+(define prime-engine-session-language-get
+ (lambda (prime-session)
+ (let ((language-string
+ (nth 1 (prime-util-string-split
+ (car (prime-engine-send-command
+ (list "session_get_env" prime-session "language")))
+ "\t"))))
+ (if (string=? language-string "English")
+ 'English 'Japanese))))
+
;; composing operations
(define prime-engine-edit-insert
(lambda (prime-session string)
@@ -602,6 +883,12 @@
(lambda (prime-session)
(prime-engine-send-command (list "edit_erase" prime-session))))
+;; This sends a edit_commit command to the server and returns the commited
+;; string.
+(define prime-engine-edit-commit
+ (lambda (prime-session)
+ (car (prime-engine-send-command (list "edit_commit" prime-session)))))
+
;; cursor operations
(define prime-engine-edit-cursor-left
(lambda (prime-session)
@@ -634,7 +921,6 @@
(define prime-engine-preedit-convert-input
(lambda (string)
- (print "prime-engine-preedit-convert-input")
(if (string=? string "")
'("")
(let ((conversion (car (prime-engine-send-command
@@ -659,7 +945,6 @@
(define prime-engine-get-env
(lambda (env-name)
-; (print "prime-engine-get-env")
(let* ((result (prime-util-string-split
(car (prime-engine-send-command (list "get_env" env-name)))
"\t"))
@@ -679,7 +964,6 @@
(define prime-engine-get-env-typing-method
(lambda ()
-; (print "prime-engine-get-env-typing-method")
(prime-engine-get-env "typing_method")
))
@@ -690,16 +974,22 @@
(lambda (context key key-state)
#t))
+(define prime-command-commit
+ (lambda (context key key-state)
+ (prime-commit-without-learning context (charcode->string key))))
+
(define prime-command-commit-raw
(lambda (context key key-state)
- (prime-commit-raw context)))
+ (if (prime-context-parent-context context)
+ (prime-proc-call-command prime-subkeymap-child-context
+ context key key-state)
+ (prime-commit-raw context))))
;;;; prime-command: modes
;; This changes the typing mode specified by mode-string.
(define prime-mode-set-mode
(lambda (context mode-string)
- (print "prime-mode-set-mode")
(if (= (prime-context-state context) 'prime-state-converting)
(prime-convert-cancel context))
(prime-engine-edit-set-mode (prime-context-session context) mode-string)))
@@ -729,8 +1019,16 @@
(lambda (context key key-state)
(prime-mode-set-mode context "raw")))
+(define prime-command-language-toggle
+ (lambda (context key key-state)
+ (let ((next-language (if (= (prime-context-language context) 'English)
+ 'Japanese 'English)))
+ (prime-mode-language-set context next-language))))
+
(define prime-command-japanese-mode
(lambda (context key key-state)
+ (prime-context-initialize! context)
+ (prime-mode-language-set context (prime-context-language context))
(prime-mode-set context prime-mode-hiragana)))
(define prime-command-wide-latin-mode
@@ -744,24 +1042,18 @@
(define prime-command-register-mode
(lambda (context key key-state)
+ (print "prime-command-register-mode")
(prime-register-mode-on context)))
;;;; ------------------------------------------------------------
-;;;; prime-command-latin: User commands in a latin-mode
-;;;; ------------------------------------------------------------
-(define prime-command-latin-input
- (lambda (context key key-state)
- (prime-command-commit-raw context key key-state)))
-
-;;;; ------------------------------------------------------------
;;;; prime-command-wide-latin: User commands in a wide-latin-mode
;;;; ------------------------------------------------------------
(define prime-command-wide-latin-input
(lambda (context key key-state)
(let ((wide-char (ja-wide (charcode->string key))))
(if wide-char
- (im-commit context wide-char)
+ (prime-commit-without-learning context wide-char)
(prime-command-commit-raw context key key-state)))))
;;;; ------------------------------------------------------------
@@ -772,23 +1064,13 @@
(prime-convert-selection-move context (+ 1 (prime-context-nth context)))
))
-(define prime-command-register-conv-next
- (lambda (context key key-state)
- (prime-context-set-nth! context (+ 1 (prime-context-nth context)))
- (cond
- ((prime-get-current-candidate context)
- #f)
- (else
- (prime-context-set-nth! context 0)))
- ))
-
(define prime-command-conv-prev
(lambda (context key key-state)
(if (> (prime-context-nth context) 0)
- (prime-context-set-nth! context
- (- (prime-context-nth context) 1))
- (prime-context-set-nth! context
- (- (prime-get-nr-candidates context) 1)))
+ (prime-convert-selection-move context
+ (- (prime-context-nth context) 1))
+ (prime-convert-selection-move context
+ (- (prime-get-nr-candidates context) 1)))
))
(define prime-command-conv-cancel
@@ -797,20 +1079,20 @@
(define prime-command-conv-commit
(lambda (context key key-state)
- (print "prime-command-conv-commit")
- (prime-commit-candidate context (prime-context-nth context))
- ))
+ (prime-commit-conversion context)))
-(define prime-command-register-conv-commit
+(define prime-command-conv-commit-and-commit-raw
(lambda (context key key-state)
- (print "prime-command-register-conv-commit")
- (prime-commit-to-register-buffer context
- (prime-get-current-candidate context))
- ))
+ (prime-commit-conversion context)
+ (prime-command-commit-raw context key key-state)))
+(define prime-command-conv-commit-and-space
+ (lambda (context key key-state)
+ (prime-commit-conversion context)
+ (prime-commit-string context " ")))
+
(define prime-command-conv-select
(lambda (context key key-state)
- (print "prime-command-conv-select")
(let* ((nth0 (number->candidate-index (numeral-char->number key)))
(cand-range (prime-uim-candwin-get-range context))
(nth (min (+ (car cand-range) nth0) (cdr cand-range)))
@@ -819,34 +1101,129 @@
(prime-commit-candidate context nth))
)))
-(define prime-command-register-conv-select
- (lambda (context key key-state)
- (print "prime-command-conv-select")
- (let* ((nth0 (number->candidate-index (numeral-char->number key)))
- (cand-range (prime-uim-candwin-get-range context))
- (nth (min (+ (car cand-range) nth0) (cdr cand-range)))
- (cand (prime-get-nth-candidate context nth)))
- (if cand
- (begin
- (prime-context-set-nth! context nth)
- (prime-commit-to-register-buffer context cand)))
- )))
-
(define prime-command-conv-input
(lambda (context key key-state)
- (print "prime-command-conv-input")
(prime-commit-candidate context (prime-context-nth context))
- (prime-push-key context key key-state)
+ (prime-command-fund-input context key key-state)
))
-(define prime-command-register-conv-input
+;;;; ------------------------------------------------------------
+;;;; prime-command-modify: User commands in a modification state.
+;;;; ------------------------------------------------------------
+
+(define prime-command-modify-commit
(lambda (context key key-state)
- (print "prime-command-register-conv-input")
- (prime-commit-to-register-buffer context (prime-get-current-candidate context))
- (prime-push-key context key key-state)
+ (prime-commit-conversion context)))
+
+(define prime-command-modify-convert
+ (lambda (context key key-state)
+ (prime-context-set-state! context 'prime-state-segment)
+ (let ((conversion (prime-engine-segment-reconvert
+ (prime-context-session context))))
+ (prime-context-set-segment-nth! context (car conversion))
+ (prime-context-set-segment-candidates! context (cdr conversion)))))
+
+(define prime-command-modify-convert-reversely
+ (lambda (context key key-state)
+ (prime-command-modify-convert context key key-state)
+ (prime-command-segment-prev context key key-state)))
+
+(define prime-command-modify-cursor-right
+ (lambda (context key key-state)
+ (prime-modify-reset! context)
+ (prime-context-set-modification!
+ context
+ (prime-engine-modify-cursor-right (prime-context-session context)))
))
+(define prime-command-modify-cursor-left
+ (lambda (context key key-state)
+ (prime-modify-reset! context)
+ (prime-context-set-modification!
+ context
+ (prime-engine-modify-cursor-left (prime-context-session context)))
+ ))
+
+(define prime-command-modify-cursor-right-edge
+ (lambda (context key key-state)
+ (prime-modify-reset! context)
+ (prime-context-set-modification!
+ context
+ (prime-engine-modify-cursor-right-edge (prime-context-session context)))
+ ))
+
+(define prime-command-modify-cursor-left-edge
+ (lambda (context key key-state)
+ (prime-modify-reset! context)
+ (prime-context-set-modification!
+ context
+ (prime-engine-modify-cursor-left-edge (prime-context-session context)))
+ ))
+
+(define prime-command-modify-cursor-expand
+ (lambda (context key key-state)
+ (prime-modify-reset! context)
+ (prime-context-set-modification!
+ context
+ (prime-engine-modify-cursor-expand (prime-context-session context)))
+ ))
+
+(define prime-command-modify-cursor-shrink
+ (lambda (context key key-state)
+ (prime-modify-reset! context)
+ (prime-context-set-modification!
+ context
+ (prime-engine-modify-cursor-shrink (prime-context-session context)))
+ ))
+
+(define prime-modify-reset!
+ (lambda (context)
+ (prime-context-set-state! context 'prime-state-modifying)
+ (prime-context-set-segment-nth! context 0)
+ (prime-context-set-segment-candidates! context ())))
+
;;;; ------------------------------------------------------------
+;;;; prime-command-segment: User commands in a segment state.
+;;;; ------------------------------------------------------------
+(define prime-command-segment-cancel
+ (lambda (context key key-state)
+ (prime-modify-reset! context)))
+
+(define prime-command-segment-commit
+ (lambda (context key key-state)
+ (prime-commit-segment context)))
+
+(define prime-command-segment-next
+ (lambda (context key key-state)
+ (prime-segment-selection-move context
+ (+ (prime-context-segment-nth context) 1))))
+
+(define prime-command-segment-prev
+ (lambda (context key key-state)
+ (prime-segment-selection-move context
+ (- (prime-context-segment-nth context) 1))))
+
+;; TODO: Add a auto-register-mode function.
+;; TODO: (2005-01-12) <Hiroyuki Komatsu>
+(define prime-segment-selection-move
+ (lambda (context selection-index)
+ (cond
+ ((< selection-index 0)
+ (set! selection-index (- (prime-segment-get-candidates-length context)
+ 1)))
+ ((>= selection-index (prime-segment-get-candidates-length context))
+ (set! selection-index 0)))
+ (prime-context-set-segment-nth! context selection-index)
+ (prime-context-set-modification! context
+ (prime-engine-segment-select
+ (prime-context-session context)
+ selection-index))))
+
+(define prime-segment-get-candidates-length
+ (lambda (context)
+ (length (prime-context-segment-candidates context))))
+
+;;;; ------------------------------------------------------------
;;;; prime-command-preedit: User commands in a preedit state.
;;;; ------------------------------------------------------------
@@ -864,18 +1241,18 @@
(define prime-command-preedit-commit
(lambda (context key key-state)
- (let* ((word-committed (prime-preedit-get-string-label context))
- (word-data (list (list "basekey" word-committed)
- (list "base" word-committed))))
- (prime-commit-word-data context word-data)
- )))
+ (prime-commit-preedition context)))
-(define prime-command-register-preedit-commit
+(define prime-command-preedit-commit-and-commit-raw
(lambda (context key key-state)
- (let ((word-committed (prime-preedit-get-string-label context)))
- (prime-commit-to-register-buffer context word-committed)
- )))
+ (prime-commit-preedition context)
+ (prime-command-commit-raw context key key-state)))
+(define prime-command-preedit-commit-and-space
+ (lambda (context key key-state)
+ (prime-commit-preedition context)
+ (prime-commit-string context " ")))
+
(define prime-command-preedit-cursor-left-edge
(lambda (context key key-state)
(prime-engine-edit-cursor-left-edge (prime-context-session context))))
@@ -894,14 +1271,12 @@
(define prime-command-preedit-input
(lambda (context key key-state)
- (print "prime-command-preedit-input")
(prime-engine-edit-insert (prime-context-session context)
(charcode->string key))))
(define prime-command-preedit-commit-candidate
(lambda (context key key-state)
- (print "prime-command-preedit-commit-candidate")
- (if #f
+ (if prime-custom-number-selection?
(let* ((nth (number->candidate-index (numeral-char->number key)))
(cand (prime-get-nth-candidate context nth)))
(if cand
@@ -911,30 +1286,14 @@
(prime-command-preedit-input context key key-state))
)))
-(define prime-command-register-preedit-commit-candidate
- (lambda (context key key-state)
- (print "prime-command-register-preedit-commit-candidate")
- (if #f
- (let* ((nth (number->candidate-index (numeral-char->number key)))
- (cand (prime-get-nth-candidate context nth)))
- (if cand
- (begin
- (prime-context-set-nth! context nth)
- (prime-commit-to-register-buffer context cand)))
- )
- (if (prime-normal-key? key key-state)
- (prime-command-preedit-input context key key-state))
- )))
-
(define prime-command-preedit-convert
(lambda (context key key-state)
- (print "prime-command-preedit-convert")
- (prime-begin-conversion context)
+ (prime-convert-start context)
))
(define prime-command-preedit-convert-reversely
(lambda (context key key-state)
- (prime-begin-conversion-reversely context)
+ (prime-convert-start-reversely context)
))
;;;; ------------------------------------------------------------
@@ -942,22 +1301,27 @@
;;;; ------------------------------------------------------------
(define prime-command-fund-input
(lambda (context key key-state)
- (print "prime-command-fund-input")
(prime-context-set-state! context 'prime-state-preedit)
(prime-command-preedit-input context key key-state)
))
(define prime-command-fund-space
(lambda (context key key-state)
- (let ((space (ja-direct " ")))
- (prime-commit-without-learning context space)
- )))
+ (cond
+ ((= (prime-context-language context) 'Japanese)
+ (let ((space (if (= prime-custom-japanese-space 'wide) "¡¡" " ")))
+ (prime-commit-without-learning context space)))
+ (t
+ (prime-commit-without-learning context " ")))))
(define prime-command-fund-altspace
(lambda (context key key-state)
- (let ((space (if (string=? (ja-direct " ") " ") "¡¡" " ")))
- (prime-commit-without-learning context space)
- )))
+ (cond
+ ((= (prime-context-language context) 'Japanese)
+ (let ((space (if (= prime-custom-japanese-space 'wide) " " "¡¡")))
+ (prime-commit-without-learning context space)))
+ (t
+ (prime-commit-without-learning context " ")))))
(define prime-command-fund-commit-ja-direct
(lambda (context key key-state)
@@ -968,64 +1332,110 @@
;;;; ------------------------------------------------------------
;;;; prime-command-register-fund: User commands in a register fundamental state
;;;; ------------------------------------------------------------
-(define prime-command-register-fund-backspace
+(define prime-command-fund-backspace
(lambda (context key key-state)
- (prime-editor-backspace-char (prime-context-get-register-line context))
+ (prime-editor-backspace-char (prime-context-fund-line context))
))
-(define prime-command-register-fund-delete
+(define prime-command-fund-delete
(lambda (context key key-state)
- (prime-editor-delete-char (prime-context-get-register-line context))
+ (prime-editor-delete-char (prime-context-fund-line context))
))
-(define prime-command-register-fund-cancel
+(define prime-command-fund-cancel
(lambda (context key key-state)
- (prime-register-mode-off context)
-
- (prime-context-set-nth! context 0)
- (prime-context-set-state! context 'prime-state-preedit)
+ (prime-context-pop context)
))
-;; This registers the specified word to the PRIME dictionary and
-;; reset the status to the normal fund mode.
-(define prime-command-register-fund-commit
+(define prime-command-child-finish
(lambda (context key key-state)
- (print "prime-command-register-fund-commit")
- (let* ((learning-word (prime-context-learning-word context))
- (registered (prime-register-get-string-label context)))
- (if (not (string=? registered ""))
- (let ((word-data (list (list "basekey" learning-word)
- (list "base" registered))))
- (prime-commit-word-data context word-data)
- (prime-register-mode-off context)
- (prime-command-preedit-cancel context key key-state))))
- ))
+ (let ((parent-context (prime-context-parent-context context)))
+ (if parent-context
+ (let* ((reading (prime-preedit-get-string-label parent-context))
+ (literal (prime-fund-get-line-string context))
+ (word-data (list (list "basekey" reading)
+ (list "base" literal))))
+ (prime-commit-word-data parent-context word-data)
+ (prime-context-pop context)))
+ )))
-(define prime-command-register-fund-cursor-left-edge
+(define prime-command-fund-cursor-left-edge
(lambda (context key key-state)
(prime-editor-cursor-move-left-edge
- (prime-context-get-register-line context))))
+ (prime-context-fund-line context))))
-(define prime-command-register-fund-cursor-right-edge
+(define prime-command-fund-cursor-right-edge
(lambda (context key key-state)
(prime-editor-cursor-move-right-edge
- (prime-context-get-register-line context))))
+ (prime-context-fund-line context))))
-(define prime-command-register-fund-cursor-left
+(define prime-command-fund-cursor-left
(lambda (context key key-state)
- (prime-editor-cursor-move (prime-context-get-register-line context) -1)))
+ (prime-editor-cursor-move (prime-context-fund-line context) -1)))
-(define prime-command-register-fund-cursor-right
+(define prime-command-fund-cursor-right
(lambda (context key key-state)
- (prime-editor-cursor-move (prime-context-get-register-line context) 1)))
+ (prime-editor-cursor-move (prime-context-fund-line context) 1)))
+;; ------------------------------------------------------------
+;; prime-command-app: commands for specific applications
+;; ------------------------------------------------------------
+
+(define prime-command-app-mode-start
+ (lambda (context key key-state)
+ (print "prime-command-app-mode-start")
+ (prime-context-set-previous-mode! context (prime-context-mode context))
+ (prime-context-set-app-mode-key-list! context
+ prime-app-mode-end-stroke-list)
+ (prime-mode-set context prime-mode-application)
+ (prime-commit-raw context)))
+
+(define prime-command-app-mode-end
+ (lambda (context key key-state)
+ (prime-mode-set context (prime-context-previous-mode context))
+ (prime-context-set-previous-mode! context prime-mode-latin)))
+
+(define prime-command-app-mode
+ (lambda (context key key-state)
+ (print "prime-command-app-mode")
+ (prime-command-app-mode-internal
+ context key key-state
+ (prime-context-app-mode-key-list context))))
+
+(define prime-command-app-mode-internal
+ (lambda (context key key-state key-list)
+ (let ((key-data (car key-list)))
+ (cond
+ ;; there's no speficied command then pressed key is passed.
+ ((= key-list '())
+ (prime-context-set-app-mode-key-list! context
+ prime-app-mode-end-stroke-list)
+ (prime-commit-raw context))
+
+ ;; key-data is a string like "i" then this app-mode ends.
+ ((and (string? key-data)
+ (prime-util-command-match? key-data key key-state))
+ (prime-command-app-mode-end context key key-state)
+ (prime-commit-raw context))
+
+ ;; key-data is a stroke of keys like ("c" . ("l" "w" ...))
+ ;; then the key-list data goes to a next stage.
+ ((and (list? key-data)
+ (prime-util-command-match? (car key-data) key key-state))
+ (prime-context-set-app-mode-key-list! context (cdr key-data))
+ (prime-commit-raw context))
+
+ ;; call this command recursively.
+ (t
+ (prime-command-app-mode-internal context
+ key key-state (cdr key-list)))))))
+
;;;; ------------------------------------------------------------
-;;;; prime-proc:
+;;;; prime-proc: procedure
;;;; ------------------------------------------------------------
(define prime-proc-call-command
(lambda (keymap context key key-state)
- (print "prime-proc-call-command")
(let ((command (prime-keymap-get-command keymap key key-state)))
(if command
(begin
@@ -1033,38 +1443,6 @@
#t)
#f))))
-(define prime-push-key
- (lambda (context key key-state)
- (print "prime-push-key")
- (let* ((state (prime-context-state context))
- (mode (prime-context-mode context))
- (learning-word (prime-context-learning-word context))
- (keymap))
- (cond
- ((= state 'prime-state-converting)
- (print ":prime-push-key: converting")
- (if learning-word
- (set! keymap prime-keymap-register-conv-state)
- (set! keymap prime-keymap-conv-state)))
-
- ((= mode prime-mode-latin)
- (set! keymap prime-keymap-latin-mode))
- ((= mode prime-mode-wide-latin)
- (set! keymap prime-keymap-wide-latin-mode))
- ((= mode prime-mode-hiragana)
- (if (prime-preedit-exist? context)
- (if learning-word
- (set! keymap prime-keymap-register-preedit-state)
- (set! keymap prime-keymap-preedit-state))
- (if learning-word
- (set! keymap prime-keymap-register-fund-state)
- (set! keymap prime-keymap-fund-state))))
- )
- (prime-proc-call-command keymap context key key-state)
-
- (prime-update context)
- )))
-
;;;; ------------------------------------------------------------
;;;; prime-preedit:
;;;; ------------------------------------------------------------
@@ -1072,16 +1450,25 @@
(define prime-editor-get-left (lambda (line) (car line)))
(define prime-editor-set-left (lambda (line new-line-left)
(set-car! line new-line-left)))
+(define prime-editor-get-left-string
+ (lambda (line)
+ (string-list-concat (prime-editor-get-left line))))
(define prime-editor-get-right (lambda (line) (cdr line)))
(define prime-editor-set-right (lambda (line new-line-right)
(set-cdr! line new-line-right)))
+(define prime-editor-get-right-string
+ (lambda (line)
+ (string-list-concat (reverse (prime-editor-get-right line)))))
(define prime-editor-get-line
(lambda (line)
(append
(reverse (prime-editor-get-right line))
(prime-editor-get-left line))))
+(define prime-editor-get-line-string
+ (lambda (line)
+ (string-list-concat (prime-editor-get-line line))))
(define prime-editor-cursor-move-right-edge
(lambda (line)
@@ -1134,8 +1521,7 @@
;; This returns a preediting string.
(define prime-preedit-get-string-label
(lambda (context)
- (apply string-append (prime-engine-edit-get-preedition
- (prime-context-session context)))))
+ (apply string-append (prime-context-preedit-line context))))
;; This returns #t if the preediting string is not empty. Or #f.
(define prime-preedit-exist?
@@ -1148,12 +1534,10 @@
(prime-engine-edit-get-query-string (prime-context-session context))))
;; This returns a commited string of register mode.
-(define prime-register-get-string-label
+(define prime-fund-get-line-string
(lambda (context)
- (let ((line (prime-context-get-register-line context)))
- (string-append
- (string-list-concat (prime-editor-get-left line))
- (string-list-concat (reverse (prime-editor-get-right line)))))))
+ (let ((line (prime-context-fund-line context)))
+ (prime-editor-get-line-string line))))
;;;; ------------------------------------------------------------
;;;; prime-custom
@@ -1161,16 +1545,13 @@
(define prime-custom-init
(lambda ()
-; (print "prime-custom-init")
(let ((typing-method (prime-engine-get-env-typing-method)))
(cond
((string=? typing-method "kana")
(prime-dont-use-numeral-key-to-select-cand))
((string=? typing-method "tcode")
(prime-dont-use-numeral-key-to-select-cand)
- (set! prime-mask-pending-preedit? #t)
- (set! prime-engine-command-lookup "lookup")
- (set! prime-engine-command-lookup-all "lookup_all")
+; (set! prime-mask-pending-preedit? #t)
)
))
))
@@ -1181,48 +1562,84 @@
(define prime-commit-raw
(lambda (context)
- (print "prime-commit-raw")
- (im-commit-raw context)
- (prime-context-set-last-word! context "")
- (prime-preedit-reset! context)
- ))
+ (if (member (prime-context-mode context)
+ (list prime-mode-latin prime-mode-application))
+ (im-commit-raw context)
+ (begin
+ ;; Reset the current prime-context
+ (prime-engine-context-reset (prime-context-session context))
+ (im-commit-raw context)
+ (prime-context-set-last-word! context "")
+ (prime-preedit-reset! context)
+ ))))
+
(define prime-commit-without-learning
- (lambda (context word)
- (im-commit context word)
+ (lambda (context string)
+ ;; Reset the current prime-context
+ (prime-engine-context-reset (prime-context-session context))
+
+ (if (prime-context-parent-context context)
+ (prime-commit-to-fund-line context string)
+ (im-commit context string))
(prime-context-set-last-word! context "")
))
+(define prime-commit-string
+ (lambda (context string)
+ (if (prime-context-parent-context context)
+ (prime-commit-to-fund-line context string)
+ (im-commit context string))
+ (prime-preedit-reset! context)))
+
+;; obsolete
(define prime-commit-word-data
(lambda (context word-data)
- (print "prime-commit-word-data")
- (im-commit context
- (string-append (or (cadr (assoc "base" word-data)) "")
- (or (cadr (assoc "conjugation" word-data)) "")
- (or (cadr (assoc "suffix" word-data)) "")))
(prime-learn-word context word-data)
- (prime-preedit-reset! context)))
+ (prime-commit-string
+ context
+ (string-append (or (cadr (assoc "base" word-data)) "")
+ (or (cadr (assoc "conjugation" word-data)) "")
+ (or (cadr (assoc "suffix" word-data)) "")))))
+(define prime-commit-preedition
+ (lambda (context)
+ (let ((commited-string (prime-engine-edit-commit
+ (prime-context-session context))))
+ (prime-commit-string context commited-string))))
+
+(define prime-commit-conversion
+ (lambda (context)
+ (let ((commited-string (prime-engine-conv-commit
+ (prime-context-session context))))
+ (prime-commit-string context commited-string))))
+
+(define prime-commit-segment
+ (lambda (context)
+; (prime-engine-modify-commit (prime-context-session-default context))
+ (prime-context-set-state! context 'prime-state-modifying)))
+
+(define prime-commit-segment-nth
+ (lambda (context selection-index)
+ (prime-segment-selection-move context selection-index)
+ (prime-commit-segment context)))
+
(define prime-commit-candidate
- (lambda (context n)
- (print "prime-commit-candidate")
- (let ((word-data
- (nth 2 (nth n (prime-context-candidates context)))))
- (prime-commit-word-data context word-data))))
+ (lambda (context index-no)
+ (prime-engine-conv-select (prime-context-session context) index-no)
+ (prime-commit-conversion context)))
-(define prime-commit-to-register-buffer
+(define prime-commit-to-fund-line
(lambda (context word)
- (let ((line (prime-context-get-register-line context)))
+ (let ((line (prime-context-fund-line context)))
(prime-editor-set-left line (append (string-to-list word)
(prime-editor-get-left line)))
- (prime-preedit-reset! context)
)))
;;;; ------------------------------------------------------------
(define prime-learn-word
(lambda (context assoc-list)
- (print "prime-learn-word")
(let ((key (or (cadr (assoc "basekey" assoc-list)) ""))
(value (or (cadr (assoc "base" assoc-list)) ""))
(part (or (cadr (assoc "part" assoc-list)) ""))
@@ -1235,36 +1652,26 @@
(string-append value suffix rest))
)))
-;; This function moves the cursor of candidate words. If the cursor is out of
-;; the range and the variable prime-auto-register-mode? is #t, the mode is
-;; changed to register-mode.
-(define prime-convert-selection-move
- (lambda (context selection-index)
- (prime-context-set-nth! context selection-index)
- (if (prime-get-current-candidate context)
- #f
- (if prime-auto-register-mode?
- (prime-register-mode-on context)
- (prime-context-set-nth! context 0)))
- ))
-;; This resets the converting mode and goes to the preediting mode.
-(define prime-convert-cancel
+;;;; ------------------------------------------------------------
+;;;; prime-convert
+;;;; ------------------------------------------------------------
+
+(define prime-convert-start
(lambda (context)
- (print "prime-convert-cancel")
- (prime-context-set-state! context 'prime-state-preedit)
- (prime-context-set-nth! context 0)))
+ (prime-convert-start-internal context 0)))
+(define prime-convert-start-reversely
+ (lambda (context)
+ (let ((last-idx (- (prime-get-nr-candidates context)
+ 1)))
+ (prime-convert-start-internal context last-idx))))
-(define prime-begin-conversion-internal
+(define prime-convert-start-internal
(lambda (context init-idx)
- (print "prime-begin-conversion-internal")
(let ((res))
- (prime-get-all-candidates! context
- (prime-preedit-get-string-raw context)
- (prime-context-last-word context))
+ (prime-convert-get-conversion context)
(set! res (prime-get-nth-candidate context init-idx))
- (print res)
(if res
(begin
(prime-context-set-nth! context init-idx)
@@ -1273,16 +1680,43 @@
(prime-convert-selection-move context init-idx)
)))
-(define prime-begin-conversion-reversely
+
+;; This function moves the cursor of candidate words. If the cursor is out of
+;; the range and the variable prime-auto-register-mode? is #t, the mode is
+;; changed to register-mode.
+(define prime-convert-selection-move
+ (lambda (context selection-index)
+ (prime-context-set-nth! context selection-index)
+ (if (prime-get-current-candidate context)
+ ;; If the selection-index is a valid number, sends the number
+ ;; to the server.
+ (prime-engine-conv-select (prime-context-session context)
+ selection-index)
+ (begin
+ (prime-context-set-nth! context 0)
+ (prime-engine-conv-select (prime-context-session context) 0)
+ (if prime-auto-register-mode?
+ (prime-register-mode-on context))))))
+
+;; This resets the converting mode and goes to the preediting mode.
+(define prime-convert-cancel
(lambda (context)
- (let ((last-idx (- (prime-get-nr-candidates context)
- 1)))
- (prime-begin-conversion-internal context last-idx))))
+ (prime-context-set-state! context 'prime-state-preedit)
+ (prime-context-set-nth! context 0)))
-(define prime-begin-conversion
+;; This executes 'conv_predict' to predict candidate words and stores them.
+(define prime-convert-get-prediction
(lambda (context)
- (prime-begin-conversion-internal context 0)))
+ (prime-context-set-candidates! ;; FIXME: candidates -> conversions
+ context
+ (prime-engine-conv-predict (prime-context-session context)))))
+;; This executes 'conv_convert' to get candidate words and stores them.
+(define prime-convert-get-conversion
+ (lambda (context)
+ (prime-context-set-candidates! ;; FIXME: candidates -> conversions
+ context
+ (prime-engine-conv-convert (prime-context-session context)))))
;;;; ------------------------------------------------------------
;;;; prime-commit
@@ -1290,98 +1724,177 @@
(define prime-update
(lambda (context)
- (print "prime-update")
- (print (prime-context-state context))
+ (prime-update-key-press context)
+ (prime-update-key-release context)))
- (prime-update-state context)
- (prime-update-prediction context)
-
- (prime-update-candidate-window context)
- (prime-update-preedit context)
+(define prime-update-key-press
+ (lambda (context)
+ (let ((session (prime-context-session context)))
+ (cond
+ ((null? session)
+ #f) ;; Do nothing.
- (prime-update-history context)
- ))
+ (#t
+ ;; Store the current preedition into the context
+ (prime-context-set-preedit-line!
+ context
+ (prime-engine-edit-get-preedition session))
+ (prime-update-state context)
+ (prime-update-preedit context)
+ )))))
+
+(define prime-update-key-release
+ (lambda (context)
+ (let ((session (prime-context-session context)))
+ (cond
+ ((null? session)
+ #f) ;; Do nothing.
+
+ (#t
+ (prime-update-prediction context)
+ (prime-update-candidate-window context)
+ (prime-update-history context)
+ )))))
+
(define prime-update-state
(lambda (context)
(if (not (prime-preedit-exist? context))
- (begin
- (print " prime-update-state: set-state no-preedit")
- (prime-context-set-state! context 'prime-state-no-preedit)))
- ))
+ (prime-context-set-state! context 'prime-state-fund))))
(define prime-update-history
(lambda (context)
- (print "prime-update-history")
- (prime-context-history-set! context)))
+ (prime-context-history-update! context)))
+(define prime-update-prediction
+ (lambda (context)
+ (let ((diff (prime-context-history-compare context)))
+ (cond
+ ((= diff 'state)
+ (let ((state (prime-context-state context))
+ (last-word (prime-context-last-word context)))
+ (cond
+ ((= state 'prime-state-preedit)
+ (prime-convert-get-prediction context))
+ ((= state 'prime-state-converting)
+ ;; Do nothing. (prime-convert-get-conversion context) had been
+ ;; already executed at prime-convert-start-internal
+ )
+ ((= state 'prime-state-fund)
+ (prime-context-set-candidates! context '()))
+ )))
+ ((= diff 'preedit)
+ (prime-convert-get-prediction context))
+ ))))
+
+(define prime-update-candidate-window
+ (lambda (context)
+ (let ((diff (prime-context-history-compare context)))
+ (cond
+ ((= diff 'state)
+ (let ((state (prime-context-state context)))
+ (cond
+ ((= state 'prime-state-fund)
+ (im-deactivate-candidate-selector context))
+
+ ((= state 'prime-state-preedit)
+ (if (> (prime-get-nr-candidates context) 0)
+ (im-activate-candidate-selector
+ context
+ (prime-get-nr-candidates context)
+ 3)))
+; prime-nr-candidate-max)))
+
+ ((= state 'prime-state-converting)
+ (im-activate-candidate-selector
+ context (prime-get-nr-candidates context) prime-nr-candidate-max)
+ (im-select-candidate context (prime-context-nth context)))
+
+ ((= state 'prime-state-modifying)
+ (im-deactivate-candidate-selector context))
+
+ ((= state 'prime-state-segment)
+ (im-activate-candidate-selector
+ context
+ (prime-segment-get-candidates-length context)
+ prime-nr-candidate-max)
+ (im-select-candidate context (prime-context-segment-nth context)))
+ )))
+
+ ((= diff 'nth)
+ (if (= (prime-context-state context) 'prime-state-segment)
+ (im-select-candidate context (prime-context-segment-nth context))
+ (im-select-candidate context (prime-context-nth context))))
+
+ ((= diff 'preedit)
+ (if (> (prime-get-nr-candidates context) 0)
+ (im-activate-candidate-selector
+ context (prime-get-nr-candidates context) prime-nr-candidate-max)
+ (im-deactivate-candidate-selector context)))
+ ))))
+
(define prime-update-preedit
(lambda (context)
- (print "prime-update-preedit")
-
(if (prime-context-history-compare context)
- (let ((learning-word (prime-context-learning-word context)))
+ (begin
(im-clear-preedit context)
- (prime-display-preedit
- context
- (if learning-word
- (prime-register-state-update-preedit context)
- (prime-preedit-state-update-preedit context)))
+ (prime-display-preedit context
+ (prime-update-preedit-internal context))
(im-update-preedit context)
- ))
- ))
+ ))))
-(define prime-register-state-update-preedit
+(define prime-update-preedit-internal
(lambda (context)
- (print "prime-register-state-update-preedit")
- (let* ((learning-word (prime-context-learning-word context))
- (line (prime-context-get-register-line context))
- (register-left (prime-editor-get-left line))
- (register-right (reverse (prime-editor-get-right line))))
+ (let* ((line (prime-context-fund-line context))
+ (line-left (prime-editor-get-left-string line))
+ (line-right (prime-editor-get-right-string line)))
(append
- (list
- (cons 'register-label "ñ¸ìÅÐÏ¿")
- (cons 'register-border "[")
- (cons 'register-word learning-word)
- (cons 'register-border "|")
- (cons 'committed (string-list-concat register-left)))
-
+ (prime-context-display-head context)
+ (if line-left (list (cons 'committed line-left)))
(prime-preedit-state-update-preedit context)
- (list
- (cons 'committed (string-list-concat register-right))
- (cons 'register-border "]"))))))
+ (if line-right (list (cons 'committed line-right)))
+ (prime-context-display-tail context)))))
(define prime-preedit-state-update-preedit
(lambda (context)
- (print "prime-preedit-state-update-preedit")
- (let* ((state (prime-context-state context))
- (line (prime-context-get-preedit-line context))
- (left (car line))
- (right (apply string-append (cdr line)))
- )
+ (let* ((state (prime-context-state context)))
(cond
((= state 'prime-state-converting)
- (list (cons 'converting (prime-get-current-candidate context))))
+ (list (cons 'converting (prime-get-current-candidate context))
+ (cons 'cursor "")))
+ ((or (= state 'prime-state-modifying)
+ (= state 'prime-state-segment))
+ (let* ((line (prime-context-modification context)))
+ (list (cons 'segment (nth 0 line))
+ (cons 'segment-highlight (nth 1 line))
+ (cons 'cursor "")
+ (cons 'segment (nth 2 line)))))
+
((prime-preedit-exist? context)
- (list (cons 'preedit left)
- (cons 'cursor "")
- (cons 'preedit right)))
+ (let* ((line (prime-context-get-preedit-line context))
+ (left (car line))
+ (right (apply string-append (cdr line))))
+ (list (cons 'preedit left)
+ (cons 'cursor "")
+ (cons 'preedit right))))
+
(else
(list (cons 'cursor "")))))))
(define prime-display-preedit-format
- (list (cons 'committed preedit-none)
- (cons 'cursor preedit-cursor)
- (cons 'pseudo-cursor preedit-reverse)
- (cons 'preedit preedit-underline)
- (cons 'converting preedit-reverse)
- (cons 'register-border preedit-reverse)
- (cons 'register-label preedit-reverse)
- (cons 'register-word preedit-reverse)
+ (list (cons 'committed preedit-none)
+ (cons 'cursor preedit-cursor)
+ (cons 'pseudo-cursor preedit-reverse)
+ (cons 'preedit preedit-underline)
+ (cons 'converting preedit-underline)
+ (cons 'segment preedit-underline)
+ (cons 'segment-highlight preedit-reverse)
+ (cons 'register-border preedit-reverse)
+ (cons 'register-label preedit-reverse)
+ (cons 'register-word preedit-reverse)
))
-
(define prime-display-preedit
(lambda (context preedit-list)
(if preedit-list
@@ -1402,115 +1915,82 @@
context (cdr (assoc 'cursor prime-display-preedit-format)) "")
(if (and prime-pseudo-mode-cursor?
(= (prime-context-mode context) prime-mode-hiragana)
- (eq? (prime-context-state context) 'prime-state-no-preedit))
+ (eq? (prime-context-state context) 'prime-state-fund))
(im-pushback-preedit context
(cdr (assoc 'pseudo-cursor
prime-display-preedit-format))
" "))
))
-(define prime-update-prediction
- (lambda (context)
- (print "prime-update-prediction")
- (let ((diff (prime-context-history-compare context)))
- (cond
- ((= diff 'state)
- (let ((state (prime-context-state context))
- (last-word (prime-context-last-word context)))
- (cond
- ((= state 'prime-state-preedit)
- (prime-get-candidates! context
- (prime-preedit-get-string-raw context)
- (prime-context-last-word context)))
- ((= state 'prime-state-converting)
- (prime-get-all-candidates! context
- (prime-preedit-get-string-raw context)
- (prime-context-last-word context)))
- ((= state 'prime-state-no-preedit)
- (prime-context-set-candidates! context '()))
- )))
- ((= diff 'preedit)
- (prime-get-candidates! context
- (prime-preedit-get-string-raw context)
- (prime-context-last-word context)))
- ))))
-
-(define prime-update-candidate-window
- (lambda (context)
- (print "prime-update-candidate-window")
- (let ((diff (prime-context-history-compare context)))
- (cond
- ((= diff 'state)
- (let ((state (prime-context-state context)))
- (cond
- ((= state 'prime-state-no-preedit)
- (im-deactivate-candidate-selector context))
- ((= state 'prime-state-preedit)
- (if (> (prime-get-nr-candidates context) 0)
- (im-activate-candidate-selector
- context
- (prime-get-nr-candidates context)
- 3)))
-; prime-nr-candidate-max)))
- ((= state 'prime-state-converting)
- (im-activate-candidate-selector
- context (prime-get-nr-candidates context) prime-nr-candidate-max)
- (im-select-candidate context (prime-context-nth context)))
- )))
- ((= diff 'nth)
- (im-select-candidate context (prime-context-nth context)))
- ((= diff 'preedit)
- (if (> (prime-get-nr-candidates context) 0)
- (im-activate-candidate-selector
- context (prime-get-nr-candidates context) prime-nr-candidate-max)
- (im-deactivate-candidate-selector context)))
- ))))
-
;;;; ------------------------------------------------------------
(define prime-register-mode-on
(lambda (context)
(print "prime-register-mode-on")
- (prime-context-set-learning-word! context
- (prime-preedit-get-string-label context))
- (prime-context-set-session! context
- (prime-context-session-register context))
- ))
+ (let* ((reading (prime-preedit-get-string-label context))
+ ;; Header and footer strings for a preedition line.
+ (current-display-head (prime-context-display-head context))
+ (current-display-tail (prime-context-display-tail context))
+ ;; Committed line in the current session.
+ (current-line (prime-context-fund-line context))
+ (current-line-left (prime-editor-get-left-string current-line))
+ (current-line-right (prime-editor-get-right-string current-line))
+ (new-context (prime-context-push context)))
+ (prime-context-set-display-head!
+ new-context
+ (append current-display-head
+ (if current-line-left
+ (list (cons 'committed current-line-left)))
+ (list (cons 'register-label "ñ¸ìÅÐÏ¿")
+ (cons 'register-border "[")
+ (cons 'register-word reading)
+ (cons 'register-border "|"))))
+ (prime-context-set-display-tail!
+ new-context
+ (append (list (cons 'register-border "]"))
+ (if current-line-right
+ (list (cons 'committed current-line-right)))
+ current-display-tail))
+ ;; Go to Japanese mode immediately.
+ (prime-mode-set context prime-mode-hiragana)
+ )))
-(define prime-register-mode-off
- (lambda (context)
- (prime-context-reset-register-line! context)
- (prime-context-set-learning-word! context #f)
- (prime-context-set-session! context
- (prime-context-session-default context))
- ))
-
+;; This just returns the empty context between this client and a prime
+;; server. However the prime server may not be initialized yet. The
+;; server will be initialized in prime-context-initialize! after a
+;; user turn on the prime mode.
(define prime-init-handler
(lambda (id im arg)
- (if (prime-lib-init prime-use-unixdomain?)
- (let ((context (prime-context-new id im)))
- (prime-custom-init)
- context)
- #f)))
+ (prime-context-new id im)))
(define prime-release-handler
(lambda (context)
- (prime-engine-session-end (prime-context-session-default context))
- (prime-engine-session-end (prime-context-session-register context))
+ (print "prime-release-handler")
+ (let ((session (prime-context-session context)))
+ (if session
+ (prime-engine-session-end session)))
))
(define prime-press-key-handler
- (lambda (context key state)
+ (lambda (context key key-state)
(if (control-char? key)
(im-commit-raw context)
- (prime-push-key context key state))))
+ (let ((keymap (prime-keymap-get-keymap context key key-state)))
+ (prime-proc-call-command keymap context key key-state)
+ (prime-update-key-press context)
+ ))))
(define prime-release-key-handler
- (lambda (context key state)
+ (lambda (context key key-state)
+ (print "prime-release-key-handler")
(if (or (control-char? key)
(= (prime-context-mode context)
prime-mode-latin))
- (im-commit-raw context))))
+ (im-commit-raw context)
+ ;; else
+ ;; FIXME: update candidate words.
+ (prime-update-key-release context)
+ )))
(define prime-reset-handler
(lambda (context)
@@ -1520,49 +2000,98 @@
(define prime-mode-set
(lambda (context mode)
(prime-context-set-mode! context mode)
- (prime-preedit-reset! context)
- (prime-update context)
+ ;; FIXME: I don't wanna use prime-context-session here.
+ ;; FIXME: (2005-02-25) <Hiroyuki Komatsu>
+ ;; If the session is #f, the PRIME mode has never been turned on.
+ (if (prime-context-session context)
+ (begin
+ (prime-preedit-reset! context)
+ (prime-update context)
+ ))
))
+(define prime-mode-language-set
+ (lambda (context language)
+ (let* ((lang-session-list (prime-context-lang-session-list context))
+ (session (cdr (assoc language lang-session-list))))
+ (if (not session)
+ (begin
+ (set! session (prime-engine-session-language-set language))
+ (prime-context-set-lang-session-list!
+ context
+ (cons (cons language session) lang-session-list))))
+ (prime-context-set-language! context language)
+ (prime-context-set-session! context session))))
+
(define prime-get-candidate-handler
- (lambda (context idx accel-enum-hint)
- (let* ((cand (prime-get-nth-candidate context idx))
- (usage (prime-get-nth-usage context idx))
- (annotation (prime-get-nth-annotation context idx)))
- (if (and prime-char-annotation?
- annotation
- (= (prime-context-state context) 'prime-state-converting))
- (set! cand (string-append cand " (" annotation ")")))
+ (lambda (context index-no accel-enum-hint)
+ (let ((candidate
+ (if (= (prime-context-state context) 'prime-state-segment)
+ (nth index-no (prime-context-segment-candidates context))
+ (nth index-no (prime-context-candidates context)))))
+ ;; The return value is a list with a candidate string and the next index.
+ (list (prime-candidate-combine-string context candidate)
+ (digit->string (+ index-no 1))))))
+
+(define prime-candidate-combine-string
+ (lambda (context candidate)
+ (let ((string (prime-candidate-get-literal candidate))
+ (usage (prime-candidate-get-data candidate "usage"))
+ (comment (prime-candidate-get-data candidate "comment"))
+ (form (prime-candidate-get-data candidate "form"))
+ (state (prime-context-state context)))
+ (if (and prime-custom-display-form?
+ form
+ (or (= state 'prime-state-converting)
+ (= state 'prime-state-segment)))
+ (set! string (string-append string " (" form ")")))
(if (and prime-custom-display-usage?
usage
- (= (prime-context-state context) 'prime-state-converting))
- (set! cand (string-append cand "\t¢¦" usage)))
+ (or (= state 'prime-state-converting)
+ (= state 'prime-state-segment)))
+ (set! string (string-append string "\t¢¦" usage)))
+ (if (and prime-custom-display-comment?
+ comment
+ (or (= state 'prime-state-converting)
+ (= state 'prime-state-segment)))
+ (set! string (string-append string "\t<" comment ">")))
+ string)))
- ;; The return value is a list with a candidate string and the next index.
- (list cand (digit->string (+ idx 1))))))
+(define prime-candidate-get-literal
+ (lambda (candidate)
+ (car candidate)))
+(define prime-candidate-get-data
+ (lambda (candidate key)
+ (cadr (assoc key (nth 1 candidate)))))
+
(define prime-set-candidate-index-handler
(lambda (context selection-index)
(print "prime-set-candidate-index-handler")
- (prime-convert-selection-move context selection-index)
- (prime-update context)
- ))
+ (if (prime-context-session context)
+ (begin
+ (if (= (prime-context-state context) 'prime-state-segment)
+ (prime-commit-segment-nth context selection-index)
+ (prime-commit-candidate context selection-index))
+ (prime-update context)
+ ))))
(prime-configure-widgets)
(register-im
- 'prime
- "ja"
- "EUC-JP"
- prime-im-name-label
- prime-im-short-desc
- #f
- prime-init-handler
- #f
- context-mode-handler
- prime-press-key-handler
- prime-release-key-handler
- prime-reset-handler
- prime-get-candidate-handler
- prime-set-candidate-index-handler
- context-prop-activate-handler)
+ 'prime ;; name
+ "ja" ;; lang
+ "EUC-JP" ;; encoding
+ prime-im-name-label ;; name-label
+ prime-im-short-desc ;; short-dest
+ #f ;; init-arg
+ prime-init-handler ;; init
+ prime-release-handler ;; release
+ context-mode-handler ;; mode
+ prime-press-key-handler ;; key-press
+ prime-release-key-handler ;; key-release
+ prime-reset-handler ;; reset
+ prime-get-candidate-handler ;; get-candidate
+ prime-set-candidate-index-handler ;; set-candidate-index
+ context-prop-activate-handler ;; prop
+)
More information about the uim-commit
mailing list