<?xml version="1.0"?>

<bindings id="htmlBindings"
   xmlns="http://www.mozilla.org/xbl"
   xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
 
  <binding name="inputFields" extends="resource:/chrome/htmlBindings.xml#inputFieldsBase">
    <handlers>

    <!-- Emacsish single-line motion and delete keys -->
    <handler type="keypress" id="key_home" key="a" control="true"
        command="cmd_beginLine"/>
    <handler type="keypress" id="key_end" key="e" control="true"
        command="cmd_endLine"/>
    <handler type="keypress" id="key_left" key="b" control="true"
        command="cmd_charPrevious"/>
    <handler type="keypress" id="key_right" key="f" control="true"
        command="cmd_charNext"/>
    <handler type="keypress" id="key_delback" key="h" control="true"
        command="cmd_deleteCharBackward"/>
    <handler type="keypress" id="key_delforw" key="d" control="true"
        command="cmd_deleteCharForward"/>
    <handler type="keypress" id="key_delwback" key="w" control="true"
        command="cmd_deleteWordBackward"/>
    <handler type="keypress" id="key_del_bol" key="u" control="true"
        command="cmd_deleteToBeginningOfLine"/>
    <handler type="keypress" id="key_del_eol" key="k" control="true"
        command="cmd_deleteToEndOfLine"/>

    <!-- Windows copy/paste/undo/redo keys -->
    <handler type="keypress" id="key_wincopy" key="c" control="true"
        command="cmd_copy"/>
    <handler type="keypress" id="key_wincut" key="x" control="true"
        command="cmd_cut"/>
    <handler type="keypress" id="key_winundo" key="z" control="true"
        command="cmd_undo"/>
    <handler type="keypress" id="key_winredo" key="r" control="true"
        command="cmd_redo"/>
    <handler type="keypress" id="key_altwincut" keycode="VK_DELETE" shift="true" control="false" alt="false"
        command="cmd_cut"/>
    <handler type="keypress" id="key_altwincopy" keycode="VK_INSERT" control="true" shift="false" alt="false"
        command="cmd_copy"/>
    <handler type="keypress" id="key_altwinpaste" keycode="VK_INSERT" shift="true" control="false" alt="false"
        command="cmd_paste"/>

    <!-- navigating by word keys -->
    <handler type="keypress" id="key_home" keycode="VK_HOME" alt="false" shift="false" control="false"
        command="cmd_beginLine"/>
    <handler type="keypress" id="key_end" keycode="VK_END" alt="false" shift="false" control="false"
        command="cmd_endLine"/>
    <handler type="keypress" id="key_homeshift" keycode="VK_HOME" shift="true" alt="false" control="false"
        command="cmd_selectBeginLine"/>
    <handler type="keypress" id="key_endshift" keycode="VK_END" shift="true" alt="false" control="false"
        command="cmd_selectEndLine"/>
    <handler type="keypress" id="key_leftcontrol" keycode="VK_LEFT" control="true" alt="false" shift="false"
        command="cmd_wordPrevious"/>
    <handler type="keypress" id="key_rightcontrol" keycode="VK_RIGHT" control="true" alt="false" shift="false"
        command="cmd_wordNext"/>
    <handler type="keypress" id="key_leftshiftcontrol" keycode="VK_LEFT" shift="true" control="true" alt="false" 
        command="cmd_selectWordPrevious"/>
    <handler type="keypress" id="key_rightshiftcontrol" keycode="VK_RIGHT" shift="true" control="true" alt="false" 
        command="cmd_selectWordNext"/>
    <handler type="keypress" id="key_redo" key="y" primary="true"
        command="cmd_redo"/>
    </handlers>
  </binding>

  <binding name="textAreas" extends="resource:/chrome/htmlBindings.xml#textAreasBase">
    <handlers>

    <!-- Emacsish single-line motion and delete keys -->
    <handler type="keypress" id="key_home" key="a" control="true"
        command="cmd_beginLine"/>
    <handler type="keypress" id="key_end" key="e" control="true"
        command="cmd_endLine"/>
    <handler type="keypress" id="key_left" key="b" control="true"
        command="cmd_charPrevious"/>
    <handler type="keypress" id="key_right" key="f" control="true"
        command="cmd_charNext"/>
    <handler type="keypress" id="key_delback" key="h" control="true"
        command="cmd_deleteCharBackward"/>
    <handler type="keypress" id="key_delforw" key="d" control="true"
        command="cmd_deleteCharForward"/>
    <handler type="keypress" id="key_delwback" key="w" control="true"
        command="cmd_deleteWordBackward"/>
    <handler type="keypress" id="key_del_bol" key="u" control="true"
        command="cmd_deleteToBeginningOfLine"/>
    <handler type="keypress" id="key_del_eol" key="k" control="true"
        command="cmd_deleteToEndOfLine"/>

    <!-- Windows copy/paste/undo/redo keys -->
    <handler type="keypress" id="key_wincopy" key="c" control="true"
        command="cmd_copy"/>
    <handler type="keypress" id="key_wincut" key="x" control="true"
        command="cmd_cut"/>
    <handler type="keypress" id="key_winundo" key="z" control="true"
        command="cmd_undo"/>
    <handler type="keypress" id="key_winredo" key="r" control="true"
        command="cmd_redo"/>
    <handler type="keypress" id="key_altwincut" keycode="VK_DELETE" shift="true" control="false" alt="false"
        command="cmd_cut"/>
    <handler type="keypress" id="key_altwincopy" keycode="VK_INSERT" control="true" shift="false" alt="false"
        command="cmd_copy"/>
    <handler type="keypress" id="key_altwinpaste" keycode="VK_INSERT" shift="true" control="false" alt="false"
        command="cmd_paste"/>

    <!-- Emacsish multi-line motion and delete keys -->
    <handler type="keypress" id="key_linedown" key="n" control="true"
        command="cmd_lineNext"/>
    <handler type="keypress" id="key_lineup" key="p" control="true"
        command="cmd_linePrevious"/>

    <!-- handle home/end/arrow keys and redo -->
    <handler type="keypress" id="key_home" keycode="VK_HOME" alt="false" shift="false" control="false"
        command="cmd_beginLine"/>
    <handler type="keypress" id="key_end" keycode="VK_END" alt="false" shift="false" control="false"
        command="cmd_endLine"/>
    <handler type="keypress" id="key_homeshift" keycode="VK_HOME" shift="true" alt="false" control="false"
        command="cmd_selectBeginLine"/>
    <handler type="keypress" id="key_endshift" keycode="VK_END" shift="true" alt="false" control="false"
        command="cmd_selectEndLine"/>
    <handler type="keypress" id="key_leftcontrol" keycode="VK_LEFT" control="true" alt="false" shift="false" 
        command="cmd_wordPrevious"/>
    <handler type="keypress" id="key_rightcontrol" keycode="VK_RIGHT" control="true" alt="false" shift="false" 
        command="cmd_wordNext"/>
    <handler type="keypress" id="key_leftshiftcontrol" keycode="VK_LEFT" shift="true" control="true" alt="false"
        command="cmd_selectWordPrevious"/>
    <handler type="keypress" id="key_rightshiftcontrol" keycode="VK_RIGHT" shift="true" control="true" alt="false"
        command="cmd_selectWordNext"/>
    <handler type="keypress" id="key_redo" key="y" primary="true"
        command="cmd_redo"/>
    </handlers>
  </binding>

</bindings>
