Community
    • Login

    php additional syntax highlighting

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LarphoidL
      Larphoid
      last edited by

      Hi,

      First of all, big thanks for this great editor !

      I’m trying to add a WordsStyle named KEYWORD to distinguish between PHP functions and keywords like “class”, “function”, “break”, “return” etc.
      To start of with just a few keywords, I’ve added <Keywords name=“type1”>break class function</Keywords> to langs.xml and removed those keywords from <Keywords name=“instre1”> and added <WordsStyle name=“KEYWORD” styleID=“16” fgColor=“FFFF00” bgColor=“FEFCF5” fontName=“” fontStyle=“7” fontSize=“” keywordClass=“type1” /> to stylers.xml.
      The WordStyle KEYWORD is now visible in np++ (Settings > Style Configurator -> php) but the syntax coloring isn’t applied to the keywords, in fact, they have no syntax coloring at all now, just the default black color. When I add more keywords in np++, they get added to stylers.xml but they also don’t get highlighted. I’ve also tried keywordClass=“instre2” and tried a few different styleIDs, but nothing happens to the highlighting.

      Please advice ! Is it at all possible to add to php syntax highlighting, i.e. some combination of keywordClass and styleID that will work, or am I waisting time ?

      Thanks.

      1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones
        last edited by

        What categories there are available for a given language are defined by that language’s lexer; unfortunately, you cannot add new categories. (Well, like you saw, you can add anything you like to stylers.xml… but if the php lexer isn’t programmed to match words in that category, and to pass on the category to scintilla to mark it with a particular style, nothing will happen.)

        Many of the languages allow adding new keywords to a given category; in php, if you wait long enough on the WORD style, it pops up the default and user-defined keyword lists, so you could add words to that category – however, I don’t see that it’s implemented any other styles of keywords.

        So, with the builtin lexer, I don’t think you’re going to be able to add a separate style/category of keywords, sorry.

        You might be able to come up with a UDL to highlight the words as you desire (but UDL highlighting often falls short in areas that the custom lexers excel in, so you may have to give up something in order to get the two different categories of keywords).

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors