<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/xml.xsl" type="text/xsl"?><feed xmlns="http://www.w3.org/2005/Atom">
  <title>nulog, NULL::something : out of the headphone &gt; 2005 &gt; November &gt; 03 &gt; キーバインドの実装</title>
  <link href="http://lowreal.net/logs/2005/11/03/1"/>
  <icon>http://lowreal.net/img/banner.png</icon>
  <link rel="self" type="application/atom+xml" href="http://lowreal.net/logs/2005/11/03/1.atom"/>
  <link rel="alternate" type="application/xhtml+xml" href="http://lowreal.net/logs/2005/11/03/1.xhtml"/>
  <updated>2005-11-03T11:38:01+09:00</updated>
  <author>
    <name>cho45(砂糖)</name>
  </author>
  <id>http://lowreal.net/2005/11/03/1</id>
  <entry>
    <title>キーバインドの実装</title>
    <link rel="alternate" type="text/html" href="http://lowreal.net/logs/2005/11/03/1.html"/>
    <link rel="alternate" type="application/xml+xhtml" href="http://lowreal.net/logs/2005/11/03/1.xhtml"/>
    <updated>2005-11-03T11:38:01+09:00</updated>
    <published>2005-11-03T11:38:01+09:00</published>
    <id>http://lowreal.net/2005/11/03/1</id>
    <category term="script"/>
    <category term="javascript"/>
    <category term="web"/>
    <content type="xhtml" xml:base="http://lowreal.net/">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p><a href="/2005/xml-text">textarea で動く劣化コピー xml-mode</a> の入力まわりを整理して分離してみた。C-x i とかいうツーストローク以上のキーバインドも可能に。ただ、やっぱり文字入力をキャンセルさせる方法がわからないため、入力された文字をあとから削除する方法になってる。チラつく。</p>
        <p>これである程度自由にキーバインドが変えられるようになった。</p>
        <pre class="ECMAScript" title="初期化処理（一部省略）">function xmlText_initialize() {
    var xml = new xmlText(document.getElementById("xmltext"));
    var kb = new keyBinding(document.getElementById("xmltext"), {
        "C-x i" : function () { xml.indentLine() },
        "TAB"   : function () { xml.indentLine() },
        "C-q"   : function () { xml.indentBuffer() },
        "C-."   : function () { xml.wellClose() },
        "/"     : function () { xml.slash() },
        "="     : function () { xml.equal() },
        "RET"   : function () { xml.newLineAndIndent() }
    });
}

window.addEventListener("load", xmlText_initialize, true);
</pre>
        <p>劣化コピー xml-mode と一緒に使うとき、キャレット位置が若干混乱するのが微妙。なんで混乱するのかよくわからないのだけれど。</p>
        <p>textarea のスクロール位置をセットしなおす方法が分からん。使えないって！</p>
        <ins datetime="2005-11-03T12:45:20+09:00">
          <p><code>event.preventDefault()</code> を使えばキャンセルできるみたいだ。書き換えよう。</p>
        </ins>
        <ins datetime="2005-11-03T12:51:43+09:00">
          <p>あー、しかもブラウザのキーバインド横取りできる。</p>
        </ins>
        <ins datetime="2005-11-03T13:17:48+09:00">
          <p>スクロール問題解決？</p>
        </ins>
        <ins datetime="2005-11-03T19:25:32+09:00">
          <p>Ctrl+記号を入力すると文字が誤認される。</p>
        </ins>
      </div>
    </content>
  </entry>
</feed>
