Kate/KDevelop highlighting file for 5.40

Everything else that doesn't fall into one of the other PB categories.
User avatar
Tuireann
User
User
Posts: 10
Joined: Wed Apr 15, 2015 5:42 pm

Kate/KDevelop highlighting file for 5.40

Post by Tuireann »

Wasn't sure where to post this...

Updated the Kate/KDevelop PureBasic highlighting file for 5.40 LTS and added a
few enhancements.

- Updated Function list to match additions and removals in 5.40
- Updated Keyword list and added matching contexts for folding
- Updated Debug Keyword list
- Added Constant list for built in constants auto-completion
- Added Compiler Function list and contexts
- Added Type extension matching context

https://dl.dropboxusercontent.com/u/830 ... ebasic.xml

Just submitted it to the katepart mailing list so it will probably be about a week before it gets pushed to the master.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Kate/KDevelop highlighting file for 5.40

Post by Fred »

Nice !
AZJIO
Addict
Addict
Posts: 2143
Joined: Sun May 14, 2017 1:48 am

Re: Kate/KDevelop highlighting file for 5.40

Post by AZJIO »

After installing Kate, I found code highlighting in "/usr/share/org.kde.syntax-highlighting/syntax-bundled".
I removed the function names since they were 1500 lines long and replaced that with a regular expression.
I added 13 regular expressions. Fixed regular expression for "procedure"
I changed the colors in the editor, maybe they will not be displayed as beautifully as mine. You can set them yourself. You can reference variable colors in <itemDatas>
You can set the color explicitly: <itemData name="ElemStruc" color="#ff33ff" />

Code: Select all

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE language>
<language name="PureBasic" version="10" kateversion="5.0" section="Sources" extensions="*.pb;*.pbi" mimetype="text/x-purebasic" author="Alexander Clay (Tuireann@EpicBasic.org);Sven Langenkamp (ace@kylixforum.de)" license="LGPL" priority="1" >
  <highlighting>
    <list name="keywords">
      <item>Break</item>
      <item>Case</item>
      <item>Continue</item>
      <item>Data</item>
      <item>DataSection</item>
      <item>Declare</item>
      <item>DeclareModule</item>
      <item>Default</item>
      <item>DefType</item>
      <item>Dim</item>
      <item>Else</item>
      <item>ElseIf</item>
      <item>EnableExplicit</item>
      <item>End</item>
      <item>EndDataSection</item>
      <item>EndDeclareModule</item>
      <item>EndEnumeration</item>
      <item>EndIf</item>
      <item>EndInterface</item>
      <item>EndModule</item>
      <item>EndProcedure</item>
      <item>EndSelect</item>
      <item>EndStructure</item>
      <item>Enumeration</item>
      <item>Extends</item>
      <item>FakeReturn</item>
      <item>For</item>
      <item>ForEach</item>
      <item>Global</item>
      <item>Gosub</item>
      <item>Goto</item>
      <item>If</item>
      <item>IncludeBinary</item>
      <item>IncludeFile</item>
      <item>IncludePath</item>
      <item>Interface</item>
      <item>Module</item>
      <item>NewList</item>
      <item>Next</item>
      <item>Not</item>
      <item>Procedure</item>
      <item>ProcedureDLL</item>
      <item>ProcedureReturn</item>
      <item>Protected</item>
      <item>Read</item>
      <item>Repeat</item>
      <item>Restore</item>
      <item>Return</item>
      <item>Select</item>
      <item>Shared</item>
      <item>Static</item>
      <item>Step</item>
      <item>Structure</item>
      <item>To</item>
      <item>Until</item>
      <item>UnuseModule</item>
      <item>UseModule</item>
      <item>Wend</item>
      <item>While</item>
      <item>With</item>
      <item>XIncludeFile</item>
    </list>
    <list name="compiler">
      <item>CompilerIf</item>
      <item>CompilerElse</item>
      <item>CompilerEndIf</item>
      <item>CompilerSelect</item>
      <item>CompilerCase</item>
      <item>CompilerDefault</item>
      <item>CompilerEndSelect</item>
    </list>
    <list name="debug">
      <item>CallDebugger</item>
      <item>Debug</item>
    </list>
    <contexts>
      <context attribute="Normal Text" lineEndContext="#stay" name="Normal">

        <RegExpr attribute="Pointers" context="#stay" String="[*@]\w+\b"	/>
        <RegExpr attribute="ElemStruc" context="#stay" String="(?&lt;!\.\:)\\\w+"	/>
        <RegExpr attribute="ElemStruc" context="#stay" String="(?&lt;=\w\.)\w+"	/>
        <RegExpr attribute="Asm" context="#stay" String="(?m)^[\s]*!.+?$"	/>
        <RegExpr attribute="Type" context="#stay" String="\.[sfdqbliwcapu]\b"	/>
        
        <AnyChar attribute="Operator" String="-+*/%|=!&lt;&gt;!^&amp;~" context="#stay"/>

        <AnyChar attribute="Separator" String=",.:()[]\" context="#stay"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(if)([\s]|$)" insensitive="true" beginRegion="IfRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(endif)([\s]|$)" insensitive="true" endRegion="IfRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(while)([\s]|$)" insensitive="true" beginRegion="WhileRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(wend)([\s]|$)" insensitive="true" endRegion="WhileRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(repeat)([\s]|$)" insensitive="true" beginRegion="RepeatRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(until)([\s]|$)" insensitive="true" endRegion="RepeatRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(select)([\s]|$)" insensitive="true" beginRegion="SelectRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(endselect)([\s]|$)" insensitive="true" endRegion="SelectRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(for|foreach)([\s]|$)" insensitive="true" beginRegion="ForRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(next)([\s]|$)" insensitive="true" endRegion="ForRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(procedure[cdl$]{0,5})([.\s]|$)" insensitive="true" beginRegion="ProcedureRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(endprocedure)([\s]|$)" insensitive="true" endRegion="ProcedureRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(structure)([\s]|$)" insensitive="true" beginRegion="StructureRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(endstructure)([\s]|$)" insensitive="true" endRegion="StructureRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(interface)([\s]|$)" insensitive="true" beginRegion="InterfaceRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(endinterface)([\s]|$)" insensitive="true" endRegion="InterfaceRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(import)([\s]|$)" insensitive="true" beginRegion="ImportRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(endimport)([\s]|$)" insensitive="true" endRegion="ImportRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(enumeration)([\s]|$)" insensitive="true" beginRegion="EnumerationRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(endenumeration)([\s]|$)" insensitive="true" endRegion="EnumerationRegion"/>

        <RegExpr attribute="Keyword" context="#stay" String="\b(datasection)([\s]|$)" insensitive="true" beginRegion="DataSectionRegion"/>
        <RegExpr attribute="Keyword" context="#stay" String="\b(enddatasection)([\s]|$)" insensitive="true" endRegion="DataSectionRegion"/>

        <keyword attribute="Keyword" context="#stay" String="keywords"/>

        <RegExpr attribute="Compiler Keyword" context="#stay" String="\b(compilerif)([\s]|$)" insensitive="true" beginRegion="CompilerIfRegion"/>
        <RegExpr attribute="Compiler Keyword" context="#stay" String="\b(compilerendif)([\s]|$)" insensitive="true" endRegion="CompilerIfRegion"/>

        <RegExpr attribute="Compiler Keyword" context="#stay" String="\b(compilerselect)([\s]|$)" insensitive="true" beginRegion="CompilerSelectRegion"/>
        <RegExpr attribute="Compiler Keyword" context="#stay" String="\b(compilerendselect)([\s]|$)" insensitive="true" endRegion="CompilerEndSelectRegion"/>

        <keyword attribute="Compiler Keyword" context="#stay" String="compiler"/>
        <keyword attribute="Debug Keyword" context="#stay" String="debug"/>

        <RegExpr attribute="ConstStr" context="#stay" String="#+[a-zA-Z_]\w*?\$"/>
        <RegExpr attribute="Constant" context="#stay" String="(?&lt;!\w)\#+[a-zA-Z_]\w*\b"/>
        
        <RegExpr attribute="Hex" context="#stay" String="\$[a-fA-F0-9]++"/>
        <RegExpr attribute="WinAPI" context="#stay" String="\b[a-zA-Z_]\w*_(?=\s*\()"/>
        <RegExpr attribute="Func" context="#stay" String="\b[a-zA-Z_]\w*(?=\s*\()"/>
<!--
        <RegExpr attribute="VarStr" context="#stay" String="\b[\d_a-zA-Z]+\$\b"/>
        <RegExpr attribute="VarStr" context="#stay" String="\b([a-zA-Z]\w*)(?=\s*[,\)=])"/>
-->
        <RegExpr attribute="Char" context="#stay" String="'.*?'"	/>

        <Float attribute="Number" context="#stay"/>
        <Int attribute="Number" context="#stay"/>

        <DetectChar attribute="String" context="String" char="&quot;" />

        <RegExpr attribute="Region Marker" context="#stay" String="^\s*;+\s*BEGIN.*$" beginRegion="marker" column="0"/>
        <RegExpr attribute="Region Marker" context="#stay" String="^\s*;+\s*END.*$" endRegion="marker" column="0"/>

        <DetectChar attribute="Comment" context="Comment1" char=";"/>

      </context>
      <context attribute="String" lineEndContext="#pop" name="String">
        <DetectChar attribute="String" context="#pop" char="&quot;"/>
      </context>
      <context attribute="Comment" lineEndContext="#pop" name="Comment1">
        <DetectSpaces />
        <IncludeRules context="##Comments" />
      </context>
    </contexts>
    <itemDatas>
      <itemData name="Normal Text" defStyleNum="dsNormal"/>
      <itemData name="Operator" defStyleNum="dsOperator"/>
      <itemData name="Separator" defStyleNum="dsOperator"/>
      <itemData name="Keyword" defStyleNum="dsKeyword"/>
      <itemData name="Debug Keyword" defStyleNum="dsKeyword"/>
      <itemData name="Compiler Keyword" defStyleNum="dsKeyword"/>
      <itemData name="Func" defStyleNum="dsFunction"/>
      <itemData name="VarStr" defStyleNum="dsVariable"/>
      <itemData name="WinAPI" defStyleNum="dsBuiltIn"/>
      <itemData name="Constant" defStyleNum="dsDataType"/>
      <itemData name="ConstStr" defStyleNum="dsDataType"/>
      <itemData name="Pointers" defStyleNum="dsDecVal"/>
      <itemData name="Number" defStyleNum="dsDecVal"/>
      <itemData name="Hex" defStyleNum="dsDecVal"/>
      <itemData name="String" defStyleNum="dsString"/>
      <itemData name="Comment" defStyleNum="dsComment"/>
      <itemData name="Type" defStyleNum="dsControlFlow"/>
      <itemData name="ElemStruc" defStyleNum="dsBaseN"/>
      <itemData name="Char" defStyleNum="dsSpecialChar"/>
      <itemData name="Asm" defStyleNum="dsSpecialChar"/>
      <itemData name="Region Marker" defStyleNum="dsRegionMarker"/>
    </itemDatas>
  </highlighting>
  <general>
    <keywords casesensitive="0" />
    <comments>
      <comment name="singleLine" start=";" position="afterwhitespace" />
    </comments>
  </general>
</language>
<!-- // kate: space-indent on; indent-width 3; replace-tabs on; -->
Post Reply