<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language>
<language
  version="2"
  kateversion="5.79"
  name="XKeyboardConfig"
  alternativeNames="XKB"
  section="Configuration"
  extensions="*.xkb"
  license="MIT"
  author="Jonathan Poelen (jonathan.poelen@gmail.com)"
>
<!--
  https://xkbcommon.org/doc/current/user-configuration.html
  https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html
-->
<highlighting>

  <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#keywords -->
  <!-- case-sensitive -->
  <list name="keywords">
    <item>action</item>
    <item>alias</item>
    <item>default</item>
    <item>group</item>
    <item>hidden</item>
    <item>include</item>
    <item>indicator</item>
    <item>interpret</item>
    <item>key</item>
    <item>keys</item>
    <item>logo</item>
    <item>mod_map</item>
    <item>modmap</item>
    <item>modifier_map</item>
    <item>outline</item>
    <item>overlay</item>
    <item>partial</item>
    <item>row</item>
    <item>section</item>
    <item>shape</item>
    <item>solid</item>
    <item>text</item>
    <item>type</item>
    <item>virtual_modifiers</item>
    <item>virtual</item>

    <!-- other keywords -->
    <item>allowExplicit</item>
    <item>controls</item>
    <item>groups</item>
    <item>maximum</item>
    <item>minimum</item>
    <item>symbols</item>
    <item>actions</item>
    <item>all</item>

    <!-- in xkb_geometry (ignored by xkb config) -->
    <item>approx</item>
    <item>baseColor</item>
    <item>color</item>
    <item>corner</item>
    <item>cornerRadius</item>
    <item>description</item>
    <item>gap</item>
    <item>height</item>
    <item>labelColor</item>
    <item>left</item>
    <item>model</item>
    <item>offColor</item>
    <item>onColor</item>
    <item>outline</item>
    <item>priority</item>
    <item>shape</item>
    <item>text</item>
    <item>top</item>
    <item>width</item>
    <item>xfont</item>
  </list>

  <list name="xkb sections">
    <item>xkb_compat_map</item>
    <item>xkb_compat</item>
    <item>xkb_compatibility_map</item>
    <item>xkb_compatibility</item>
    <item>xkb_geometry</item>
    <item>xkb_keycodes</item>
    <item>xkb_keymap</item>
    <item>xkb_layout</item>
    <item>xkb_semantics</item>
    <item>xkb_symbols</item>
    <item>xkb_types</item>
  </list>

  <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#merge-mode-def -->
  <list name="merge mode keywords">
    <item>augment</item>
    <item>override</item>
    <item>replace</item>
    <item>alternate</item>
  </list>

  <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#section-flags-def -->
  <!-- Generic flags -->
  <list name="flags">
    <item>partial</item>
    <item>default</item>
    <item>hidden</item>
  </list>
  <!-- Symbols flags -->
  <list name="keygroups">
    <item>alphanumeric_keys</item>
    <item>modifier_keys</item>
    <item>keypad_keys</item>
    <item>function_keys</item>
    <item>alternate_group</item>
  </list>

  <!-- case-insensitive -->
  <list name="xkb statement">
    <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#key-type-statement -->
    <item>level_name</item>
    <item>modifiers</item>
    <item>map</item>
    <item>preserve</item>
    <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#the-xkb_compat-section -->
    <item>useModMapMods</item>
    <item>virtualModifier</item>
    <item>repeat</item>
    <item>action</item>
    <item>whichModState</item>
    <item>groups</item>
    <item>whichGroupState</item>
    <item>name</item>
    <item>groupName</item>
  </list>

  <!-- case-insensitive -->
  <list name="xkb functions">
    <item>AnyOfOrNone</item>
    <item>AnyOf</item>
    <item>Any</item>
    <item>NoneOf</item>
    <item>AllOf</item>
    <item>Exactly</item>
    <item>LockGroup</item>
    <item>LockMods</item>
    <item>SetGroup</item>
    <item>SetMods</item>
    <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#key-actions -->
    <item>NoAction</item>
    <item>VoidAction</item>
    <item>SetMods</item>
    <item>LatchMods</item>
    <item>LockMods</item>
    <item>SetGroup</item>
    <item>LatchGroup</item>
    <item>LockGroup</item>
    <item>MovePointer</item>
    <item>MovePtr</item>
    <item>PointerButton</item>
    <item>PtrBtn</item>
    <item>LockPointerButton</item>
    <item>LockPtrBtn</item>
    <item>SetPointerDefault</item>
    <item>SetPtrDflt</item>
    <item>SetControls</item>
    <item>LockControls</item>
    <item>TerminateServer</item>
    <item>Terminate</item>
    <item>SwitchScreen</item>
    <item>Private</item>
    <!-- Unsupported legacy action -->
    <!--
    <item>RedirectKey</item>
    <item>Redirect</item>
    <item>ISOLock</item>
    <item>DeviceButton</item>
    <item>DevBtn</item>
    <item>LockDeviceButton</item>
    <item>LockDevBtn</item>
    <item>DeviceValuator</item>
    <item>DevVal</item>
    <item>MessageAction</item>
    <item>Message</item>
    -->
  </list>

  <!-- case-insensitive -->
  <list name="boolean">
    <item>true</item>
    <item>yes</item>
    <item>on</item>
    <item>false</item>
    <item>no</item>
    <item>off</item>
  </list>

  <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#usual-modifiers-keysyms -->
  <list name="modifier states">
    <!-- special value -->
    <item>None</item>
    <item>Shift</item>
    <item>Lock</item>
    <item>Control</item>
    <item>Alt</item>
    <item>Meta</item>
    <item>Super</item>
    <item>Hyper</item>
    <item>ScrollLock</item>
    <item>NumLock</item>
    <item>LevelThree</item>
    <item>LevelFive</item>
    <item>Kana_Lock</item>
    <!-- <item>Square</item> -->
    <!-- <item>Cross</item> -->
    <!-- <item>Circle</item> -->
    <!-- <item>Triangle</item> -->
  </list>
  <list name="modifiers">
    <include>modifier states</include>
    <item>Shift_L</item>
    <item>Shift_R</item>
    <item>ISO_Level2_Latch</item>
    <item>Caps_Lock</item>
    <item>Control_L</item>
    <item>Control_R</item>
    <item>Alt_L</item>
    <item>Alt_R</item>
    <item>Meta_L</item>
    <item>Meta_R</item>
    <item>Super_L</item>
    <item>Super_R</item>
    <item>Hyper_L</item>
    <item>Hyper_R</item>
    <item>Scroll_Lock</item>
    <item>Num_Lock</item>
    <item>ISO_Level5_Lock</item>
    <item>ISO_Level3_Shift</item>
    <item>ISO_Level3_Latch</item>
    <item>ISO_Level3_Lock</item>
    <item>ISO_Level5_Shift</item>
    <item>ISO_Level5_Latch</item>
    <item>ISO_Level5_Lock</item>
    <item>Mod1</item>
    <item>Mod2</item>
    <item>Mod3</item>
    <item>Mod4</item>
    <item>Mod5</item>
    <item>Level1</item>
    <item>Level2</item>
    <item>Level3</item>
    <item>Level4</item>
    <item>Level5</item>
    <item>Level6</item>
    <item>Level7</item>
    <item>Level8</item>
    <!-- special value of SetMods -->
    <item>modMapMods</item>
  </list>

  <!-- /usr/include/xkbcommon/xkbcommon-keysyms.h -->
  <!-- https://xkbcommon.org/doc/current/xkbcommon-keysyms_8h.html -->
  <!--
  <list name="key">
  </list>
  -->

  <contexts>

<context name="Normal" attribute="Normal Text" lineEndContext="#stay">
  <DetectSpaces/>
  <AnyChar attribute="Assign Symbol" String="="/>
  <AnyChar attribute="Not Symbol" String="!"/>
  <AnyChar attribute="Separator Symbol" String=",;"/>
  <AnyChar attribute="Operator" String="+-"/>
  <AnyChar attribute="Square Brace" String="[]"/>
  <AnyChar attribute="Parenthesis" String="()"/>
  <DetectChar attribute="String" context="String" char='"'/>
  <DetectChar attribute="Curly Brace" char="{" beginRegion="Brace1"/>
  <DetectChar attribute="Curly Brace" char="}" endRegion="Brace1"/>
  <StringDetect attribute="Comment" context="Comment" String="//"/>
  <StringDetect attribute="Comment" context="Comment" String="#"/>
  <Float attribute="Float"/>
  <HlCHex attribute="Hex"/>
  <Int attribute="Decimal"/> <!-- or simple name in some section -->

  <WordDetect attribute="Include Keyword" String="include" context="MaybeMergeString"/>
  <keyword attribute="Keyword" String="keywords" weakDeliminator="-"
           context="MaybeSelectState"/>
  <keyword attribute="XKB Statetement" String="xkb statement" insensitive="1"
           context="MaybeSelectState"/>
  <keyword attribute="Modifier" String="modifiers"/>
  <keyword attribute="XKB Section" String="xkb sections" weakDeliminator="-"
           context="MaybeMergeString"/>
  <keyword attribute="Function" String="xkb functions" insensitive="1"/>
  <keyword attribute="Key Group" String="keygroups" weakDeliminator="-"/>
  <keyword attribute="Flag" String="flags"/>
  <keyword attribute="Merge Mode Keyword" String="merge mode keywords" weakDeliminator="-"
           context="MaybeMergeString"/>
  <keyword attribute="Boolean" String="boolean" insensitive="1"/>

  <DetectChar char="U" context="MaybeUnicode" lookAhead="1"/>
  <DetectIdentifier/>

  <!-- Ascii char without space nor > -->
  <RegExpr attribute="Types" String="&lt;[!-=?-~]+&gt;"/>
</context>


<context name="MaybeMergeString" attribute="String" lineEndContext="#pop" fallthroughContext="#pop">
  <DetectSpaces/>
  <DetectChar attribute="String" context="#pop!MergeString" char='"'/>
</context>


<!--
  @{ Unicode
-->

<context name="MaybeUnicode" attribute="Normal Text" lineEndContext="#pop" fallthroughContext="#pop">
  <RegExpr attribute="Unicode Value Prefix" String="\bU(?=[0-9a-fA-F]{4,6}\b)"
           context="Unicode"/>
  <DetectIdentifier context="#pop"/>
</context>

<context name="Unicode" attribute="Unicode Value" lineEndContext="#pop#pop" fallthroughContext="#pop#pop">
  <DetectIdentifier attribute="Unicode Value" context="#pop#pop"/>
  <Int additionalDeliminator="U"/>
</context>

<!--
  @} Unicode
-->


<!--
  @{ State List
  - level_name[Level1]
              ~      ~  Container Symbol
               ~~~~~~   Associated Modifier State
  - map[Shift+Lock]
       ~          ~     Container Symbol
        ~~~~~ ~~~~      Modifier State
             ~          Modifier State Separator
  - name[Group1]
        ~      ~        Container Symbol
         ~~~~~~         State
  - layout[1]
          ~ ~           Container Symbol
           ~            Decimal
-->

<context name="MaybeSelectState" attribute="String" lineEndContext="#pop" fallthroughContext="#pop">
  <DetectChar char="[" context="SelectState" lookAhead="1"/>
</context>

<context name="SelectState" attribute="String" fallthroughContext="#pop#pop">
  <RegExpr attribute="Container Symbol" String="\[(?=[a-zA-Z0-9+\s]+\])"
           context="StateList" />
</context>

<context name="StateList" attribute="Modifier State Separator">
  <DetectChar attribute="Modifier State Separator" char="+"/>
  <DetectChar attribute="Container Symbol" char="]" context="#pop#pop"/>
  <keyword attribute="Modifier State" String="modifier states"/>
  <keyword attribute="Associated Modifier State" String="modifiers"/>
  <DetectIdentifier attribute="State"/>
  <Int attribute="Decimal"/>
</context>

<!--
  @} State List
-->


<!--
  @{ String
  https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#literals
-->

<context name="String" attribute="String" lineEndContext="#pop">
  <DetectChar attribute="String" context="#pop" char='"'/>
  <DetectIdentifier/>
  <DetectChar char="\" context="StringEscape" lookAhead="1"/>
</context>

<context name="MergeString" attribute="String" lineEndContext="#pop">
  <IncludeRules context="String"/>
  <!-- https://xkbcommon.org/doc/current/keymap-text-format-v1-v2.html#xkb-include -->
  <AnyChar attribute="Merge Mode Symbol" String="|+^"/>
  <StringDetect attribute="%-expansion" String="%%"/>
  <StringDetect attribute="%-expansion" String="%H"/>
  <StringDetect attribute="%-expansion" String="%S"/>
  <StringDetect attribute="%-expansion" String="%E"/>
  <StringDetect attribute="Error" String="%"/>
</context>

<context name="StringEscape" attribute="String" lineEndContext="#pop">
  <RegExpr attribute="String Char" context="#pop"
           String='\\([\\"befnrtv]|[0-7]{1,4}|u\{([0-9a-fA-F]{4,6})?\})'/>
  <RegExpr attribute="Error" context="#pop"
           String='\\(u(\{[0-9a-fA-F]{0,7}\}?)?)?'/>
</context>

<!--
  @} String
-->


<!--
  Comment
-->
<context name="Comment" attribute="Comment" lineEndContext="#pop">
  <DetectSpaces/>
  <LineContinue attribute="Comment" context="#stay"/>
  <IncludeRules context="##Comments"/>
  <DetectIdentifier/>
</context>

  </contexts>

  <itemDatas>
    <itemData name="Normal Text" defStyleNum="dsNormal"/>
    <itemData name="Comment"     defStyleNum="dsComment"/>
    <itemData name="Keyword"     defStyleNum="dsKeyword"/>
    <itemData name="Key Group"   defStyleNum="dsKeyword"/>
    <itemData name="XKB Section" defStyleNum="dsFunction"/>
    <itemData name="XKB Statetement" defStyleNum="dsKeyword"/>
    <itemData name="Include Keyword" defStyleNum="dsImport"/>
    <itemData name="Merge Mode Keyword" defStyleNum="dsImport"/>
    <itemData name="Merge Mode Symbol"  defStyleNum="dsImport"/>
    <itemData name="Modifier"     defStyleNum="dsPreprocessor"/>
    <itemData name="Flag"         defStyleNum="dsAttribute"/>
    <itemData name="Boolean"      defStyleNum="dsBuiltIn"/>
    <itemData name="Function"     defStyleNum="dsFunction"/>
    <itemData name="String"       defStyleNum="dsString"/>
    <itemData name="String Char"  defStyleNum="dsChar"/>
    <itemData name="%-expansion"  defStyleNum="dsSpecialChar"/>
    <itemData name="Decimal"      defStyleNum="dsDecVal"/>
    <itemData name="Hex"          defStyleNum="dsBaseN"/>
    <itemData name="Float"        defStyleNum="dsFloat"/>
    <itemData name="Unicode Value"        defStyleNum="dsVariable"/>
    <itemData name="Unicode Value Prefix" defStyleNum="dsVariable" bold="1"/>
    <itemData name="Not Symbol"       defStyleNum="dsExtension"/>
    <itemData name="Assign Symbol"    defStyleNum="dsOperator"/>
    <itemData name="Operator"         defStyleNum="dsOperator"/>
    <itemData name="Separator Symbol" defStyleNum="dsNormal"/>
    <itemData name="Curly Brace"  defStyleNum="dsNormal"/>
    <itemData name="Square Brace" defStyleNum="dsNormal"/>
    <itemData name="Parenthesis"  defStyleNum="dsNormal"/>
    <itemData name="Container Symbol"          defStyleNum="dsFunction" bold="1"/>
    <itemData name="Modifier State"            defStyleNum="dsPreprocessor"/>
    <itemData name="Modifier State Separator"  defStyleNum="dsOperator"/>
    <itemData name="Associated Modifier State" defStyleNum="dsPreprocessor"/>
    <itemData name="State"                     defStyleNum="dsFunction"/>
    <itemData name="Types"        defStyleNum="dsDataType"/>
    <itemData name="Error"        defStyleNum="dsError"/>
  </itemDatas>

</highlighting>

<general>
 <comments>
  <comment name="singleLine" start="//"/>
 </comments>
 <keywords casesensitive="1"/>
</general>

</language>
<!-- kate: space-indent on; indent-width 2; replace-tabs on; -->
