<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd"
[
  <!ENTITY file  "(====|\*\*\*|\-\-\-|diff|Only in .*:).*$">
  <!ENTITY chunk "(\@\@|\d).*$">
  <!ENTITY csep  "(\+\+\+|\-\-\-).*$">
]>
<!--
    2006-08-02: 1.10 Matthew Woehlke <mw_triad@sourceforge.net>
      Added folding. Context diff changes are now identified as old/new (using
      seperate attributes). Recognize 'Only in' from 'diff -r' output.
      There is currently a bug (KATE limitation?) where regions may sometimes
      pick up one line too many.
-->
<language name="Diff" version="1.10" kateversion="2.1" section="Other" extensions="*.diff;*patch" mimetype="text/x-diff">

  <highlighting>

    <contexts>

      <context attribute="Normal Text" lineEndContext="#stay" name="Normal">
        <RegExpr attribute="Header" context="Chunk" String="&chunk;" beginRegion="chunk" column="0"/>
        <RegExpr attribute="Header" context="RChunk" String="\*+$" beginRegion="chunk" column="0"/>
        <RegExpr attribute="File" context="#stay" String="Only in .*:.*$" column="0"/>
        <RegExpr attribute="File" context="RFile" String="diff.*$" beginRegion="file" column="0"/>
        <RegExpr attribute="File" context="File" String="(====|\*\*\*|\-\-\-).*$" beginRegion="file" column="0"/>
        <IncludeRules context="FindDiff"/>
        <DetectChar attribute="Changed line" context="ChangedOld" char="!" column="0"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="FindDiff">
        <RegExpr attribute="Header" context="#stay" String="&csep;" column="0"/>
        <AnyChar attribute="Added line" context="Added" String="+&gt;" column="0"/>
        <AnyChar attribute="Removed line" context="Removed" String="-&lt;" column="0"/>
      </context>

      <!-- block contexts -->
      <context attribute="Normal Text" lineEndContext="#stay" name="File">
        <RegExpr attribute="Header" context="ChunkInFile" String="&chunk;" beginRegion="chunk" column="0"/>
        <RegExpr attribute="Header" context="RChunkInFile" String="\*+$" beginRegion="block" column="0"/>
        <RegExpr attribute="File" context="#pop" String="&file;" endRegion="block" lookAhead="true" column="0"/>
        <DetectChar attribute="Changed line (old)" context="ChangedOld" char="!" column="0"/>
        <IncludeRules context="FindDiff"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="Chunk">
        <RegExpr attribute="Header" context="#pop" String="&chunk;" endRegion="block" lookAhead="true" column="0"/>
        <DetectChar attribute="Changed line (old)" context="ChangedOld" char="!" column="0"/>
        <IncludeRules context="FindDiff"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="ChunkInFile">
        <RegExpr attribute="Header" context="#pop" String="&chunk;" endRegion="block" lookAhead="true" column="0"/>
        <RegExpr attribute="File" context="#pop" String="&file;" endRegion="block" lookAhead="true" column="0"/>
        <DetectChar attribute="Changed line (old)" context="ChangedOld" char="!" column="0"/>
        <IncludeRules context="FindDiff"/>
      </context>

      <!-- block contexts (diff -r) -->
      <context attribute="Normal Text" lineEndContext="#stay" name="RFile">
        <RegExpr attribute="File" context="#pop" String="(diff|Only in .*:).*$" endRegion="block" lookAhead="true" column="0"/>
        <RegExpr attribute="Header" context="#stay" String="&file;" column="0"/>
        <RegExpr attribute="Header" context="RChunkInFile" String="\*+$" beginRegion="block" column="0"/>
        <IncludeRules context="File"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="RChunk">
        <RegExpr attribute="Header" context="#stay" String="\*\*\* .* \*\*\*\*$" column="0"/>
        <RegExpr attribute="Header" context="RChunkNew" String="\-\-\- .* \-\-\-\-$" column="0"/>
        <IncludeRules context="Chunk"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="RChunkInFile">
        <RegExpr attribute="Header" context="#stay" String="\*\*\* .* \*\*\*\*$" column="0"/>
        <RegExpr attribute="Header" context="RChunkInFileNew" String="\-\-\- .* \-\-\-\-$" column="0"/>
        <IncludeRules context="ChunkInFile"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="RChunkNew">
        <RegExpr attribute="Header" context="#pop#pop" String="&chunk;" lookAhead="true" column="0"/>
        <DetectChar attribute="Changed line (new)" context="ChangedNew" char="!" column="0"/>
        <IncludeRules context="FindDiff"/>
      </context>

      <context attribute="Normal Text" lineEndContext="#stay" name="RChunkInFileNew">
        <RegExpr attribute="Header" context="#pop#pop" String="&chunk;" lookAhead="true" column="0"/>
        <RegExpr attribute="File" context="#pop#pop" String="&file;" endRegion="block" lookAhead="true" column="0"/>
        <DetectChar attribute="Changed line (new)" context="ChangedNew" char="!" column="0"/>
        <IncludeRules context="FindDiff"/>
      </context>

      <!-- line contexts -->
      <context attribute="File" lineEndContext="#pop" name="File"/>
      <context attribute="Removed line" lineEndContext="#pop" name="Removed"/>
      <context attribute="Added line" lineEndContext="#pop" name="Added"/>
      <context attribute="Changed line (old)" lineEndContext="#pop" name="ChangedOld"/>
      <context attribute="Changed line (new)" lineEndContext="#pop" name="ChangedNew"/>

    </contexts>

    <itemDatas>
      <itemData name="Normal Text" defStyleNum="dsNormal"/>
      <itemData name="File"  defStyleNum="dsKeyword"/>
      <itemData name="Header"  defStyleNum="dsDataType"/>
      <itemData name="Removed line"  defStyleNum="dsOthers" color="#FF0000"/>
      <itemData name="Added line"  defStyleNum="dsString" color="#0000FF"/>
      <itemData name="Changed line (old)"  defStyleNum="dsOthers" color="#FF0000"/>
      <itemData name="Changed line (new)"  defStyleNum="dsString" color="#0000FF"/>
    </itemDatas>

  </highlighting>

</language>
