[QScintilla] Give QScintilla the current style

Xavier Noëlle gray2style at gmail.com
Tue Dec 4 13:37:31 GMT 2007


Hi,
I'm implementing a lexer for a language which is not built-in for
QScintilla. I then subclassed QsciLexer, implemented the methods which
I thought were mandatory (exhaustive list: language, lexer,
description, autoIndentStyle, autoCompletionFillups,
autoCompletionWordSeparators, blockEnd, blockLookback, blockStart,
blockStartKeyword, braceStyle, caseSensitive, defaultColor,
defaultStyle, wordCharacters, keywords).

I took the CPP (and others, but mostly this one) lexer example and
created an enum with the various styles I thought to:
  enum
  {
     Default = 1,
     Operator = 2,
     Comment = 3,
     Keyword = 4
  };
This is very very temporary, but that's really just the beginning, but
that's not the point.

I implemented defaultColor this way:
   switch (style)
  {
    case Default:
      return Qt::black;

    case Operator:
      return Qt::green;

    case Comment:
      return Qt::red;

    case Keyword:
      return Qt::cyan;

    default:
      return Qt::magenta;
  }

To highlight wrong coloration, I gave the default case (the switch
one, not the first value) the magenta color. And now I get magenta for
every single letter and symbol, which is quite annoying. I (more than)
probably skipped a step or went in the wrong way, but I must admit
that I'm quite lost.

In the CPP lexer implementation, when blockStart (or blockEnd) occurs,
the style gets the Operator value, and in blockStartKeywords the style
gets Keyword. I don't really understand this implementation and I
really think this is part of my problem...

Any help or any hint on where to start or where to search would be
greatly appreciated :-)

Thanks in advance,

-- 
Xavier NOELLE


More information about the QScintilla mailing list