IMEを制御したい その2

ブックマークでコメントを頂いたのでちょっと修正しました。


ime.0.0.1.xpi


修正内容
linux でも 動きそうな感じに修正(未検証


対応状況を見た感じでは、gIMEController.enabled(getter,setter)しか動作しないっぽいです。
今後のFlashPlayerのバージョンアップに期待です。


> { ime-mode: inactive; } じゃ駄目なんかな

IME ONのまま asciiモードが欲しかったので、inactiveは要件を満たしていないのですが、
サンプルとして今一つなので サンプル追加です


IME の ON/OFF

(function(){
  mappings.addUserMap([modes.INSERT,modes.COMMAND_LINE],["<C-j>"],"ime on",function() gIMEController.enabled = !gIMEController.enabled);
})()
;


IMEの状態を statusbarに表示

(function(self){
  const status_id="liberator-statusline";
  const id=status_id + "-field-ime";
  const o_id = "@"+self.NAME;
  const eventName = "input";//"keypress";

  let(obj=userContext[o_id]){
    obj && obj.uninstall && obj.uninstall();
  }

  //あ,3042,ア,30a2,A,ff21,ア,ff71
  const res ={
    ALPHANUMERIC_HALF      : "-A",
    JAPANESE_HIRAGANA      : "\u3042",//あ
    JAPANESE_KATAKANA_FULL : "\u30a2",//ア
    ALPHANUMERIC_FULL      : "\uff21",//A
    JAPANESE_KATAKANA_HALF : "-\uff71",//-ア
    UNKNOWN                : "??",
    KOREAN                 : "KR",
    CHINESE                : "CN",
  };
  elm = document.createElement("label");
  elm.setAttribute("id", id);
  elm.setAttribute("class", "plain");
  document.getElementById(status_id).appendChild(elm);

  let obj = {
    install:function(){
      function update_imestatus(event){
        elm.setAttribute("value", gIMEController.enabled
          ? "[" + res[gIMEController.conversion] + "]" : "[--]");
      }
      window.addEventListener(eventName, update_imestatus, true);
      this.uninstall=function(){
        elm.parentNode.removeChild(elm);
        window.removeEventListener(eventName, update_imestatus, true);
        liberator.echo("uninstall");
      };
      update_imestatus();
      return this;
    }
  };
  userContext[o_id] = obj.install();
})(this);

SKKIMEだと conversion(getter)がUNKNOWNしか返さないので、
IMEのON/OFFしか確認しておりません。