;; ja-anthy.mim -- Japanese input method using Anthy as a conversion server.
;; Copyright (C) 2003, 2004, 2005, 2006
;;   National Institute of Advanced Industrial Science and Technology (AIST)
;;   Registration Number H15PRO112

;; This file is part of the m17n library.

;; The m17n library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public License
;; as published by the Free Software Foundation; either version 2.1 of
;; the License, or (at your option) any later version.

;; The m17n library is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
;; Lesser General Public License for more details.

;; You should have received a copy of the GNU Lesser General Public
;; License along with the m17n library; if not, write to the Free
;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

(input-method ja anthy)

(description "Japanese input method with Anthy as a kana-kanji converter.
Typed roma-ji is at first converted to Hiragana,
and Space key converts the Hiragana sequences
to Kanji-Hiragana mixed sequence.

This input method uses the loadable module libmimx-anthy.so to
communicate with Anthy.  For more detail about Anthy, see the page
  <http://sourceforge.jp/projects/anthy/>.
")

(variable
 (input-mode 
  "Hiragana or Katakana (not yet implemented)
Select Hiragana or Katakana"
  hiragana
  hiragana katakana)
 (zen-han
  "Zenkaku or Hankaku (not yet implemented)"
  zenkaku
  hankaku zenkaku))

(command
 (convert) (commit))

(title "aあ")

(map
 (starter
  ("a") ("i") ("u") ("e") ("o")
  ("k") ("s") ("t") ("n") ("h") ("m") ("y") ("r") ("l") ("w")
  ("g") ("z") ("d") ("b") ("p")
  ("c") ("j") ("f") ("x") ("v") ("z")
  ("1") ("2") ("3") ("4") ("5") ("6") ("7") ("8") ("9") ("0")
  ("!") ("@") ("#") ("$") ("%") ("^") ("&") ("*") ("(") (")")
  ("-") ("=") ("`") ("\\") ("|") ("_") ("+") ("~") ("[") ("]")
  ("{") ("}") (":") (";") ("\"") ("'") (".") (",") ("<") (">")
  ("?") ("/"))

 (ordinary
  ( "a" "あ") ( "i" "い") ( "u" "う") ( "e" "え") ( "o" "お")
  ("ka" "か") ("ki" "き") ("ku" "く") ("ke" "け") ("ko" "こ")
  ("sa" "さ") ("si" "し") ("su" "す") ("se" "せ") ("so" "そ")
  ("ta" "た") ("ti" "ち") ("tu" "つ") ("te" "て") ("to" "と")
  ("na" "な") ("ni" "に") ("nu" "ぬ") ("ne" "ね") ("no" "の")
  ("ha" "は") ("hi" "ひ") ("hu" "ふ") ("he" "へ") ("ho" "ほ")
  ("ma" "ま") ("mi" "み") ("mu" "む") ("me" "め") ("mo" "も")
  ("ya" "や")             ("yu" "ゆ")             ("yo" "よ")
  ("ra" "ら") ("ri" "り") ("ru" "る") ("re" "れ") ("ro" "ろ")
  ("la" "ら") ("li" "り") ("lu" "る") ("le" "れ") ("lo" "ろ")
  ("wa" "わ") ("wi" "ゐ") ("wu" "う") ("we" "ゑ") ("wo" "を")
  ("ga" "が") ("gi" "ぎ") ("gu" "ぐ") ("ge" "げ") ("go" "ご")
  ("za" "ざ") ("zi" "じ") ("zu" "ず") ("ze" "ぜ") ("zo" "ぞ")
  ("da" "だ") ("di" "ぢ") ("du" "づ") ("de" "で") ("do" "ど")
  ("ba" "ば") ("bi" "び") ("bu" "ぶ") ("be" "べ") ("bo" "ぼ")
  ("pa" "ぱ") ("pi" "ぴ") ("pu" "ぷ") ("pe" "ぺ") ("po" "ぽ")

  ("kya" "きゃ") ("kyu" "きゅ") ("kye" "きぇ") ("kyo" "きょ")
  ("sya" "しゃ") ("syu" "しゅ") ("sye" "しぇ") ("syo" "しょ")
  ("sha" "しゃ") ("shu" "しゅ") ("she" "しぇ") ("sho" "しょ")
  ("cha" "ちゃ") ("chu" "ちゅ") ("che" "ちぇ") ("cho" "ちょ")
  ("tya" "ちゃ") ("tyu" "ちゅ") ("tye" "ちぇ") ("tyo" "ちょ")
  ("nya" "にゃ") ("nyu" "にゅ") ("nye" "にぇ") ("nyo" "にょ")
  ("hya" "ひゃ") ("hyu" "ひゅ") ("hye" "ひぇ") ("hyo" "ひょ")
  ("mya" "みゃ") ("myu" "みゅ") ("mye" "みぇ") ("myo" "みょ")
  ("rya" "りゃ") ("ryu" "りゅ") ("rye" "りぇ") ("ryo" "りょ")
  ("lya" "りゃ") ("lyu" "りゅ") ("lye" "りぇ") ("lyo" "りょ")
  ("gya" "ぎゃ") ("gyu" "ぎゅ") ("gye" "ぎぇ") ("gyo" "ぎょ")
  ("zya" "じゃ") ("zyu" "じゅ") ("zye" "じぇ") ("zyo" "じょ")
  ("jya" "じゃ") ("jyu" "じゅ") ("jye" "じぇ") ("jyo" "じょ")
  ( "ja" "じゃ") ( "ju" "じゅ") ( "je" "じぇ") ( "jo" "じょ")
  ("bya" "びゃ") ("byu" "びゅ") ("bye" "びぇ") ("byo" "びょ")
  ("pya" "ぴゃ") ("pyu" "ぴゅ") ("pye" "ぴぇ") ("pyo" "ぴょ")

  ("kwa" "くゎ") ("kwi" "くぃ") ("kwe" "くぇ") ("kwo" "くぉ")
  ("tsa" "つぁ") ("tsi" "つぃ") ("tse" "つぇ") ("tso" "つぉ")
  ( "fa" "ふぁ") ( "fi" "ふぃ") ( "fe" "ふぇ") ( "fo" "ふぉ")
  ("gwa" "ぐゎ") ("gwi" "ぐぃ") ("gwe" "ぐぇ") ("gwo" "ぐぉ")

  ("dyi" "でぃ") ("dyu" "どぅ") ("dye" "でぇ") ("dyo" "どぉ")
  ("xwi" "うぃ")                ("xwe" "うぇ") ("xwo" "うぉ")

  ("shi" "し") ("tyi" "てぃ") ("chi" "ち") ("tsu" "つ") ("ji" "じ")
  ("fu"  "ふ")
  ("ye" "いぇ")

  ("va" "ヴぁ") ("vi" "ヴぃ") ("vu" "ヴ") ("ve" "ヴぇ") ("vo" "ヴぉ")

  ("xa"  "ぁ") ("xi"  "ぃ") ("xu"  "ぅ") ("xe"  "ぇ") ("xo"  "ぉ")
  ("xtu" "っ") ("xya" "ゃ") ("xyu" "ゅ") ("xyo" "ょ") ("xwa" "ゎ")
  ("xka" "ヵ") ("xke" "ヶ"))

 (alnum
  ("1" "１") ("2" "２") ("3" "３") ("4" "４") ("5" "５")
  ("6" "６") ("7" "７") ("8" "８") ("9" "９") ("0" "０")

  ("!" "！") ("@" "＠") ("#" "＃") ("$" "＄") ("%" "％")
  ("^" "＾") ("&" "＆") ("*" "＊") ("(" "（") (")" "）")
  ("-" "ー") ("=" "＝") ("`" "｀") ("\\" "￥") ("|" "｜")
  ("_" "＿") ("+" "＋") ("~" "￣") ("[" "「") ("]" "」")
  ("{" "｛") ("}" "｝") (":" "：") (";" "；") ("\""  "”")
  ("'" "’") ("." "。") ("," "、") ("<" "＜") (">" "＞")
  ("?" "？") ("/" "／"))

 (symbol
  ("z1" "○") ("z!" "●")
  ("z2" "▽") ("z@" "▼")
  ("z3" "△") ("z#" "▲")
  ("z4" "□") ("z$" "■")
  ("z5" "◇") ("z%" "◆")
  ("z6" "☆") ("z^" "★")
  ("z7" "◎") ("z&" "£")
  ("z8" "¢") ("z*" "×")
  ("z9" "♂") ("z(" "【")
  ("z0" "♀") ("z)" "】")
  ("z-" "〜") ("z_" "∴")
  ("z=" "≠") ("z+" "±")
  ("z\\" "＼") ("z|" "‖")
  ("z`" "´") ("z~" "¨")

  ("zq" "《") ("zQ" "〈")
  ("zw" "》") ("zW" "〉")
  ("zr" "々") ("zR" "仝")
  ("zt" "〆") ("zT" "§")
  ("zp" "〒") ("zP" "↑")
  ("z[" "『") ("z{" "〔")
  ("z]" "』") ("z}" "〕")

  ("zs" "ヽ") ("zS" "ヾ")
  ("zd" "ゝ") ("zD" "ゞ")
  ("zf" "〃") ("zF" "→")
  ("zg" "‐") ("zG" "―")
  ("zh" "←")
  ("zj" "↓")
  ("zk" "↑")
  ("zl" "→")
  ("z;" "゛") ("z:" "゜")
  ("z\'" "‘") ("z\"" "“")

  ("zx" ":-") ("zX" ":-)")
  ("zc" "〇") ("zC" "℃")
  ("zv" "※") ("zV" "÷")
  ("zb" "°") ("zB" "←")
  ("zn" "′") ("zN" "↓")
  ("zm" "″") ("zM" "〓")
  ("z," "‥") ("z<" "≦")
  ("z." "…") ("z>" "≧")
  ("z/" "・") ("z?" "∞"))

 (hatsuon
  ("n" "n"))

 (sokuon
  ("kk")
  ("ss")
  ("tt")
  ("hh")
  ("mm")
  ("rr")
  ("ll")
  ("ww")
  ("gg")
  ("zz")
  ("dd")
  ("bb")
  ("pp")
  ("cc")
  ("jj")
  ("ff"))

 (henkan
  (convert))

 (kakutei
  (commit))

 (backspace
  ((BackSpace)))

 (edit
  ((Delete) (delete @+))
  ((BackSpace) (delete @-))
  ((Left) (move @-))
  ((Right) (move @+)))

 (henkan-edit
  ((Left) (move @[))
  ((Right) (move @]))
  ((S-Left) (call libmimx-anthy resize t))
  ((S-Right) (call libmimx-anthy resize nil)))

 (choose
  ("1" (select 0))
  ("2" (select 1))
  ("3" (select 2))
  ("4" (select 3))
  ("5" (select 4))
  ("6" (select 5))
  ("7" (select 6))
  ("8" (select 7))
  ("9" (select 8))
  ("0" (select 9)))

 (change-candidate
  ((C-A) (select @<))
  ((C-P) (select @[))
  ((C-B) (select @-))
  ((Up) (select @-))
  (" " (select @+))
  ((C-F) (select @+))
  ((Down) (select @+))
  ((C-N) (select @]))
  ((C-E) (select @>)))
 )

(module
 (libmimx-anthy convert resize change commit init fini))

(state
 (init
  "aあ"
  (starter (pushback 1) (shift pre-henkan)))

 (pre-henkan
  (ordinary)
  (alnum)
  (symbol)
  (hatsuon (shift hatsuon))
  (sokuon (insert "っ") (pushback 1))
  (henkan (call libmimx-anthy convert) (shift henkan))
  (kakutei (shift init))
  (backspace (pushback 1) (shift edit))
  (nil (shift fail)))

 (hatsuon
  (hatsuon (delete @-) (delete @-) (insert "ん") (shift pre-henkan))
  (nil (delete @-) (insert "ん") (shift pre-henkan)))

 (henkan
  "漢"
  (t (set K @@) (sub K 1))
  (henkan-edit)
  (change-candidate (call libmimx-anthy change) (show) (shift henkan2))
  (choose (hide) (shift init))
  (kakutei (call libmimx-anthy commit) (shift init))
  (backspace (undo K))
  (nil (call libmimx-anthy commit) (shift init)))

 (henkan2
  "漢"
  (change-candidate (call libmimx-anthy change) (show))
  (backspace (undo K))
  (nil (hide) (shift henkan)))

 (fail
  (backspace (undo))
  (starter (pushback 1) (shift pre-henkan))
  (nil (shift edit)))

 (edit
  (edit (set C @0) (< C 0 ((shift init))))
  (starter (pushback 1) (shift pre-henkan))
  (henkan (call libmimx-anthy convert) (shift henkan))
  (kakutei (shift init))))

;; Local Variables:
;; mode: lisp
;; coding: utf-8
;; End:
