[SOLVED] Can't get library name to highlight with keywords.txt

I'm creating a library for a chip I'm using, and everything works fine except for keyword highlighting.

Function names (KEYWORD2) work properly, but the class name (KEYWORD1) doesn't.

My class name is "SR74595". I'm thinking it might have something to do with the fact that the second letter isn't lower case, but the tutorial here has a class named "LED13", so that wouldn't make any sense.

Here's a screenshot so you can see that I've followed the instructions:

I'm using the 0021 version of the IDE.

Are the two columns separated by a single tab or spaces?

Separated by tabs. I used multiple tabs for the "write" function and it still highlights properly. You can see that in the screenshot.

There's not much documentation on "keywords.txt". Is the specification a single tab? Or just "tabs not spaces"? Multiple tabs seem to work for KEYWORD2, so I would assume the same is true for KEYWORD1.

Do you know where I can find the specs for keywords.txt? If they're not anywhere public, I'd like to find out what they are, and add them to the wiki.

jferguson:
You can see that in the screenshot.

I can? Sort of all looks like white-space from here.

Is the specification a single tab?

That's what I've always used. If I remember correctly, spaces alone do not work.

Multiple tabs seem to work for KEYWORD2, so I would assume the same is true for KEYWORD1.

I assume so, too.

Do you know where I can find the specs for keywords.txt?

Nope.

Have you restarted the Arduino IDE since the last time you changed keywords.txt? Is there anything after "KEYWORD1"? Perhaps a trailing space or tab?

I have a feeling that multiple TABs, whilst making keywords.txt itself look pretty, don't actually work
try just one TAB

Working now. It seems the rules in keywords.txt are applied inconsistently. I can only have a single tab for KEYWORD1, but I can have an arbitrary number of tabs for KEYWORD2.

I had a look through the source for 0021, and found this function in /app/src/processing/app/syntax/PdeKeywords.java:

  static private void getKeywords(InputStream input) throws Exception {
    InputStreamReader isr = new InputStreamReader(input);
    BufferedReader reader = new BufferedReader(isr);

    String line = null;
    while ((line = reader.readLine()) != null) {
      //System.out.println("line is " + line);
      // in case there's any garbage on the line
      //if (line.trim().length() == 0) continue;

      String pieces[] = processing.core.PApplet.split(line, '\t');
      if (pieces.length >= 2) {
        //int tab = line.indexOf('\t');
        // any line with no tab is ignored
        // meaning that a comment is any line without a tab
        //if (tab == -1) continue;

        String keyword = pieces[0].trim();
        //String keyword = line.substring(0, tab).trim();
        //String second = line.substring(tab + 1);
        //tab = second.indexOf('\t');
        //String coloring = second.substring(0, tab).trim();
        //String htmlFilename = second.substring(tab + 1).trim();
        String coloring = pieces[1].trim();

        if (coloring.length() > 0) {
          // text will be KEYWORD or LITERAL
          boolean isKey = (coloring.charAt(0) == 'K');
          // KEYWORD1 -> 0, KEYWORD2 -> 1, etc
          int num = coloring.charAt(coloring.length() - 1) - '1';
          byte id = (byte)
            ((isKey ? Token.KEYWORD1 : Token.LITERAL1) + num);
          //System.out.println("got " + (isKey ? "keyword" : "literal") +
          // (num+1) + " for " + keyword);
          keywordColoring.add(keyword, id);
        }
        if (pieces.length >= 3) {
          String htmlFilename = pieces[2].trim();
          if (htmlFilename.length() > 0) {
            keywordToReference.put(keyword, htmlFilename);
          }
        }
      }
    }
    reader.close();
  }

It seems to be the only code containing the string "KEYWORD1" that is looking for tab characters, then doing something. I haven't touched java in years, so it's looking a bit like mandarin at the moment. I wouldn't be able to say why there's a difference in what's allowed between KEYWORD1 and KEYWORD2.

This seems like a fixable problem.

bug report filed:
http://code.google.com/p/arduino/issues/detail?id=546

We'll see what happens.