• Login
Community
  • Login

Lua: cannot add additional styles

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 3 Posters 400 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.
  • T
    Thaoky
    last edited by PeterJones May 3, 2024, 7:49 PM May 3, 2024, 7:14 PM

    Hello, I am trying to add new styles for syntax highlighting, and I can see them in the Style Configurator, but they do not work. I can change the colors, add more words, but they are never highlighted.

    I added these lines to test : (in DarkModeDefault.xml, from %appdata%)
    The style id’s I found here : https://github.com/notepad-plus-plus/notepad-plus-plus/blob/master/lexilla/lexers/LexLua.cxx (can’t post links, sorry :(

    <WordsStyle name="FUNC4" styleID="16" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type3">Test4</WordsStyle>
    <WordsStyle name="FUNC5" styleID="17" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type4">Test5</WordsStyle>
    <WordsStyle name="FUNC6" styleID="18" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type5">Test6</WordsStyle>
    <WordsStyle name="FUNC7" styleID="19" fgColor="FF8000" bgColor="3F3F3F" fontName="" fontStyle="1" fontSize="" keywordClass="type6">Test7</WordsStyle>
    

    And in langs.xml (also from appdata)

    <Keywords name="type3">Lang3</Keywords>
    <Keywords name="type4">Lang4</Keywords>
    <Keywords name="type5">Lang5</Keywords>
    <Keywords name="type6">Lang6</Keywords>
    

    From what I’ve checked, this should work, the code from the lexer even seems to suggest that it is correct, but when I type one of the words I added, it does not get highlighted.

    I only tried with Lua, not with another language.

    Any idea ?

    Thanks in advance,
    Thaoky

    ----
    moderator linkified for you

    P 1 Reply Last reply May 3, 2024, 8:21 PM Reply Quote 1
    • P
      PeterJones @Thaoky
      last edited by PeterJones May 3, 2024, 8:24 PM May 3, 2024, 8:21 PM

      @Thaoky said in Lua: cannot add additional styles:

      From what I’ve checked, this should work, the code from the lexer even seems to suggest that it is correct, but when I type one of the words I added, it does not get highlighted.

      Notepad++ also would be needed to be compiled to send the other four lists.
      As of the most recent commit, ScintillaEditView.h only passes four keyword lists to the Lua lexer, not all 8:

      	void setLuaLexer() {
      		setLexer(L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3);
      	};
      

      Thus, defining them in the XML files isn’t sufficient; Notepad++ would have to be recompiled to send all 8 lists.

      	void setLuaLexer() {
      		setLexer(L_LUA, LIST_0 | LIST_1 | LIST_2 | LIST_3 | LIST_4 | LIST_5 | LIST_6 | LIST_7);
      	};
      

      Once recompiled, then Notepad++ would be able to see the additional keywords, and be able to apply any stylings that were put into the XML.

      I only tried with Lua, not with another language.

      Notepad++ decides on a language-by-language basis how many keyword lists to send to the lexer; sometimes, the number of lists has kept up with improvements in the Lexilla source; other times, it lags behind. (Based on the blame for that section of code, it looks like Notepad++ has only sent four keyword lists to the Lua lexer for at least 15 years)
      1abc2420-2f2d-40f4-8c9a-2c3a44a8dcd0-image.png

      If I have time this weekend, I will try to do a test build to see if I can get that working. Unfortunately, since v8.6.6 is in RC, even if you created an issue and I had the time to do a PR right way, it wouldn’t likely be added – because once a release is in RC-status, “new feature” PR generally wait until after the release before being merged. But if you wanted to put in an issue now, I would claim it… and hopefully it would be able to be in v8.6.7. (When I do a PR, I would also put in entries for stylers.xml, themes\*.xml, and langs.xml so that people with fresh installs would be able to see those new styles and empty keyword lists in the GUI, and be able to add their own keywords.)

      T 1 Reply Last reply May 3, 2024, 8:40 PM Reply Quote 1
      • T
        Thaoky @PeterJones
        last edited by May 3, 2024, 8:40 PM

        @PeterJones Thanks for the reply, I understand your point. No worry about not getting it in the next release, as long as this is looked at and sorted out in the future, I am already happy :)

        Much appreciated !

        T 1 Reply Last reply May 3, 2024, 9:32 PM Reply Quote 0
        • T
          Thaoky @Thaoky
          last edited by May 3, 2024, 9:32 PM

          Here is the link to the issue : https://github.com/notepad-plus-plus/notepad-plus-plus/issues/15081

          P 1 Reply Last reply May 4, 2024, 9:17 PM Reply Quote 2
          • P
            PeterJones @Thaoky
            last edited by PeterJones May 4, 2024, 9:18 PM May 4, 2024, 9:17 PM

            @Thaoky ,

            If you want to try out my attempt, you can go to https://github.com/pryrt/notepad-plus-plus/actions/runs/8953221473 and download the appropriate build. Most likely, you will want the “Notepad++.MSVC.x64.Release ”, which is the normal 64bit build – you will have to scroll to the bottom of that page to see the download links for each build.

            That set of builds has the four remaining Lua keyword lists enabled; langs.model.xml comes prepopulated with one dummy keyword per list; and stylers.model.xml is updated similarly to your excerpt earlier (for the default style, not the DarkModeDefault theme). I will be getting to the other themes eventually (and removing the dummy keywords), but I wanted to share this as soon as I had success.

            14b1ad1b-f43a-4602-906f-fb0e2624b9d7-image.png

            To future readers: GitHub will only keep those artifacts for about a month, so if it’s June 2024 or later, they will likely not be available for download; hopefully by then, the updated Lua keyword lists will at least be queued for the next release, or maybe even be in the released app already.

            M T 2 Replies Last reply May 5, 2024, 3:04 AM Reply Quote 3
            • M
              mpheath @PeterJones
              last edited by May 5, 2024, 3:04 AM

              @PeterJones Very nice. Seems to be working OK in my testing with USER KEYWORD 1.

              Here is a compare for others to see the changes and to possibly copy some of the theme files changes as I did to existing xml files for testing.

              1 Reply Last reply Reply Quote 1
              • T
                Thaoky @PeterJones
                last edited by May 5, 2024, 7:59 AM

                @PeterJones Same here, just tested, and it works as intended !

                Huge thanks :)

                P 1 Reply Last reply May 5, 2024, 2:45 PM Reply Quote 1
                • P
                  PeterJones @Thaoky
                  last edited by May 5, 2024, 2:45 PM

                  @Thaoky , @mpheath ,

                  Thanks for confirming.

                  I submitted PR 15088

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