5

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?

1 Answer 1

5

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"/>
1
  • What a shame... Where is the absolute freedom? Commented Jan 7, 2018 at 13:01

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.