Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to write my own syntax highlighting for gtksourceview. If it's done it should highlight guitar chords in a text file. This is my unfinished file:

<?xml version="1.0" encoding="UTF-8"?>
<language id="tab" _name="Tab" version="2.0" _section="Others">
  <metadata>
    <property name="mimetypes">text/plain</property>
    <property name="globs">*.txt;*.tab</property>
  </metadata>

  <styles>
    <style id="chord" _name="Chord" foreground="blue" bold="true"/>
  </styles>

  <definitions>

    <context id="chord" style-ref="chord" class="no-spell-check">
      <match>[A-H]</match>
    </context>

    <context id="tab">
      <include>
        <context ref="chord"/>
      </include>
    </context>

  </definitions>
</language>

I would expect every capital A to H to be blue and bold in the highlighted text. Is saved the file to /usr/share/gtksourceview-3.0/language-specs and I am able to select it in GEdit. But nothing is highlighted in the text.

Can anyone tell me what I am doing wrong?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Turns out I can't define the style in the .lang file. In the <style> tag there I can only refer to a style that is defined in the files in /usr/share/gtksourceview-3.0/styles. E.g. to the style used for keywords in programming languages:

<style id="chord" _name="Chord" map-to="def:keyword"/>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.