<?xml version='1.0' encoding='UTF-8'?>
<!--
  Copyright 2002-2004 The Apache Software Foundation or its licensors,
  as applicable.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<configuration name="Forrest Common"
  xsi:schemaLocation="http://www.xmlmind.com/xmleditor/schema/configuration
                      xsd/configuration.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://www.xmlmind.com/xmleditor/schema/configuration"
  xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration">

  <include location="toolBar.xml" />
  
  <documentResources>
    <resource path="//img/@src"/>
    <resource path="//figure/@src"/>
    <resource path="//icon/@src"/>
  </documentResources>
  
  <elementTemplate xmlns="" name="tableHeaded">
    <table>
      <tr>
        <th>Column 1</th>
        <th>Column 2</th>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
    </table>
  </elementTemplate>

  <elementTemplate xmlns="" name="tableUnheaded">
    <table>
      <tr>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
    </table>
  </elementTemplate>
  
  <elementTemplate xmlns="" name="tableRow">
    <tr>
      <td></td>
      <td></td>
    </tr>
  </elementTemplate>
  
  <!-- Bindings =========================================================== -->
  <!--   modified from xhtml & docbook config files =============== -->

  <!-- attempt to behave like a word-processor. -->

  <binding>
    <keyPressed code="ENTER" />
    <command name="forrest.splitOrInsertNewLine" />
  </binding>

  <binding>
    <keyPressed code="DELETE" />
    <command name="forrest.joinOrDeleteChar" />
  </binding>

  <binding>
    <keyPressed code="BACK_SPACE" />
    <command name="forrest.joinOrDeleteChar" parameter="backwards" />
  </binding>

  <command name="forrest.splitOrInsertNewLine">
    <macro trace="false">
      <choice>
        <command name="insertControlChar" parameter="\n" />
        <sequence>
          <command name="selectNode" parameter="ancestorOrSelf[implicitElement] p td th li" />
          <command name="split" />
        </sequence>
      </choice>
    </macro>
  </command>

  <command name="forrest.joinOrDeleteChar">
    <macro trace="false">
      <choice>
        <sequence>
          <test expression="($dot/ancestor::p or $dot/ancestor::li or $dot/ancestor::td or $dot/ancestor::th) and not($selected) and not($mark)" />
          <command name="deleteSelectionOrJoinOrDeleteChar" parameter="%0" />
        </sequence>
        <command name="deleteSelectionOrDeleteChar" parameter="%0" />
      </choice>
    </macro>
  </command>

  <!-- An easy way to insert a table row -->
  <binding>
    <keyPressed code="ENTER" modifiers="mod"/>
    <command name="add" parameter="after[implicitElement] #template(tr,tableRow)" />
  </binding>


  <!-- An easy way to insert a br -->
  <binding>
    <keyPressed code="ENTER" modifiers="shift" />
    <command name="forrest.insertLineBreak" />
  </binding>

  <command name="forrest.insertLineBreak">
    <macro>
      <sequence>
        <command name="insert" parameter="into br" />
        <!-- harmless if macro fails starting from here -->
        <command name="insertNode" parameter="textAfter" />
        <command name="cancelSelection" />
      </sequence>
    </macro>
  </command>

</configuration>
