[Qt-creator] [Q] GlslHighlighter in GLSL plugin

Andy asmaloney at gmail.com
Sun Sep 11 19:21:02 CEST 2016


I'm playing around with writing a language plugin for Creator, so I was
looking at the included plugins since the documentation is kind of sparse...

I ran across something that looks questionable in GlslHighlighter.  In
glslhighlighter.h we have:

    enum Formats {
        GLSLNumberFormat,
        GLSLStringFormat,
        GLSLTypeFormat,
        GLSLKeywordFormat,
        GLSLOperatorFormat,
        GLSLPreprocessorFormat,
        GLSLLabelFormat,
        GLSLCommentFormat,
        GLSLDoxygenCommentFormat,
        GLSLDoxygenTagFormat,
        GLSLVisualWhitespace,
        GLSLReservedKeyword,
        NumGLSLFormats
    };

If I'm reading the code correctly, the order of these needs to match up
with the categories set up using setTextFormatCategories() in the
GlslHighlighter constructor.  But if we look at them:

    if (categories.isEmpty()) {
        categories << C_NUMBER
                   << C_STRING
                   << C_TYPE
                   << C_KEYWORD
                   << C_OPERATOR
                   << C_PREPROCESSOR
                   << C_LABEL
                   << C_COMMENT
                   << C_DOXYGEN_COMMENT
                   << C_DOXYGEN_TAG
                   << C_VISUAL_WHITESPACE
                   << C_REMOVED_LINE;
    }

The last one is C_REMOVED_LINE which I'm guessing has nothing to do with
GLSLReservedKeyword?  Or is it set to this because the developer assumed
the style would be the default colours and wanted to highlight the reserved
words in red?

(Aside: I would suggest that the style in the Nim plugin of using a map is
probably clearer/better than having lists in two files that require order
syncing like this.)

---
Andy Maloney  //  https://asmaloney.com
twitter ~ @asmaloney <https://twitter.com/asmaloney>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20160911/b939f6ff/attachment.html>


More information about the Qt-creator mailing list