Reply to topic

Writing syntax highlighting files for Kate/KWrite & regions

Registered Member
I am currently attempting to write my own syntax highlighting file.

I want to highlight a configuration format and as such I want to make valid keywords match the section in which they are used.

The documentation is vague about the usage of beginRegion and endRegion. I figured the name given to them would allow me to distinguish between scopes and switch contexts accordingly.

Keyword1 {
MyVar = Value
MyVar2 = { something here }

Since MyVar and MyVar2 are only valid inside KeyWord1 I only want to highlight them there. If a user would type them outside the scope of Keyword1, they would be displayed as normal text.

Currently I am doing this:
Code: Select all
<context attribute="Main Body" lineEndContext="#pop" name="Main Body" >
   <RegExpr String="^\s*Keyword1\s*" beginRegion="MyRegion" context="keyword1-section"/>
<context attribute="Keyword" lineEndContext="#stay" name="keyword1-section">
   <keyword attribute="Keyword" context="#stay" String="KeywordSectionKeywords" />
   <DetectChar context="#stay" char="{" beginRegion="InternalRegion"/>
   <DetectChar context="#stay" char="}" endRegion="InternalRegion"/>
   <DetectChar context="#pop" char="}" endRegion="MyRegion"/>

I was hoping that the context switch would start a region named "MyRegion" and further brackets will generate "InternalRegion" regions. After each closing bracket, each region is closed until finally there are no "InternalRegion" regions left. Then the "MyRegion" rule would match and the context switches back to the Main Body.

Unfortunately it matches either rule holding the bracket (whichever is specified first) making me believe that the name is in fact not used at all...

User avatar bcooksley
If you do not recieve a response here, posting to the kde-devel or kde-core-devel mailing lists ( both at ) may help.

KDE Sysadmin

Reply to topic


Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Gregstrq, grosser, magkoc, martinknopp, mirass, mrvldmr, mutterhunt, orcuan, Sogou [Bot], Yahoo [Bot]