Community
    • Login

    Custom Api highlighting (for Lua. And other languages?)

    Scheduled Pinned Locked Moved General Discussion
    1 Posts 1 Posters 2.3k Views 1 Watching
    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.
    • Marshall FloydM Offline
      Marshall Floyd
      last edited by

      I have been trying to add some additional highlighting for a specific Lua API keywords. I found that doing the following mostly works:

      1. In langs.xml in the “lua” Language node I can add
        <Keywords name=“type3”>[Keywords from api 1]</Keywords>
        <Keywords name=“type4”>[Keywords from api 2]</Keywords>

      2. In stylers.xml in the “lua” LexerType node I can add
        <WordsStyle name=“API 1” styleID=“16” fgColor=“FF0000” bgColor=“FFFFFF” fontName=“” fontStyle=“2” fontSize=“” keywordClass=“type3” />
        <WordsStyle name=“API 2” styleID=“17” fgColor=“0000FF” bgColor=“FFFFFF” fontName=“” fontStyle=“4” fontSize=“” keywordClass=“type4” />

      Doing the above makes the new highlighting options and related keywords to appear under “Settings/Style Configurator/Lua”.

      PROBLEM: These new keywords are never actually highlighted properly. Looking in the source code this SHOULD work in the Lua lexer everywhere except a single line in the file PowerEditor/src/ScitillaComponent/ScintillaEditView.h, line 708, only a max of four lists are hardcoded to be read:

      setLexer(SCLEX_LUA, L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3);

      If it were changed to

      setLexer(SCLEX_LUA, L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3|LIST_4|LIST_5);

      then I think it would work. I haven’t compiled it to see because I really don’t want to customize NPP at that level (yet) and have to continually add that feature after future updates to NPP.

      Can such a thing be added to NPP? I can see that similar things occur with many of the built-in lexers. It would be nice if there were a more general way across the board to add new highlighting styles and keywords easily added by a user or through the Style Configurator itself.

      I know there are workarounds such as

      • re-using existing keyword groups and adding user keywords to them. But then you can’t differentiate highlighting between default keywords and the “new” keywords.
      • Creating a user defined language with the desired keywords and highlighting. But then you have to re-implement all the default languages features as well and might not be able to duplicate some of the nuances that are in the scintilla lexer.
      1 Reply Last reply Reply Quote 0

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors