Googleで漢字を調べるプラグイン@Vimperator

Googleを使って漢字を調べるVimperatorプラグインを書いてみた。
人間様が正解を選ばないといけないけど、漢字辞書に載っていないようなもの向け?

「:gkanji うぶめ」として、Enter。
すると、
http://www.kurinton.net/~snca/blogfiles/gk2.jpg
こんな風に候補がでるので、選択するとクリップボードにコピーされる。
ひらがなを検索して、検索結果から漢字の一覧を取り出し、出現回数の多い順に候補としている。

ちょっと候補選択部分とかが変梃な作りかもしれない。
http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/googlekanji.js

2008/07/08

漢字を取り出す正規表現を修正

2008/07/26

codereposに移動

テキストをクリップボードへコピー

function copyToClipboard (copytext) {
  const supstr = Components.classes["@mozilla.org/supports-string;1"].
                   createInstance(Components.interfaces.nsISupportsString);
  const transferable = Components.classes["@mozilla.org/widget/transferable;1"].
                  createInstance(Components.interfaces.nsITransferable);
  const iClipboard = Components.interfaces.nsIClipboard;
  const clipboard = Components.classes["@mozilla.org/widget/clipboard;1"].
                      getService(iClipboard);

  supstr.data = copytext;

  transferable.addDataFlavor("text/unicode");
  transferable.setTransferData("text/unicode", supstr, copytext.length * 2);

  return clipboard.setData(transferable, null, iClipboard.kGlobalClipboard);
}

copyToClipboard('hogehoge');