Community
    • Login

    [ALPHA] Upcoming Plugin: HiddenLexers

    Scheduled Pinned Locked Moved Notepad++ & Plugin Development
    14 Posts 2 Posters 427 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic was forked from Using Notepad++ to Organize Game Guides and Documentation PeterJones
    This topic has been deleted. Only users with topic management privileges can see it.
    • PeterJonesP Offline
      PeterJones
      last edited by

      NOTE: I split this out from the Using Notepad++ to Organize Game Guides and Documentation because it distracts from the original conversation, and is really about something separate from that discussion.

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

        Updated artifacts: https://github.com/pryrt/NppPlugin-HiddenLexers/actions/runs/31041591210 (again, limited time availability, only for alpha testing)

        • Got rid of the “Hello” actions. ;-)
        • Added About box
        • Added Edit Config File to open the correct JSON file
        • Added Reread Config to reload the settings from the JSON
          • when you are editing the JSON in Notepad++, when you save that file, it should automatically reread the config. (you will have to activate the tab with the example file to see the update in highlighting)

        This build should make it much easier for incremental changes to the JSON, without having to reload Notepad++ every time. :-)


        Also, now I’ve updated the README at https://github.com/pryrt/NppPlugin-HiddenLexers


        Call For Testers

        It seems to be basically working at this point. If @mpheath and others could give it a test, that would be appreciated. I don’t personally need this plugin, as I don’t have any hidden lexers I want to activate, so I don’t know if I’ve missed anything critical or obvious. But from my tests with STATA (one of the languages that the original HiddenLexers.py handled) and ASCIIDoc (per the start of this conversation), I think it’s working reasonably.

        I know that Lexilla has various config-variables for some of the lexers. If not having config variables available is a deal breaker for you, let me know which lexer you need it for, and give an example file and JSON to show me why that option is critical, and I can prioritize getting it added before I do the v1.0 release. Otherwise, the lexilla-options will probably not be included until a future version.

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

          I was able to find an example lexer that had an option that I could see the effect of, so was able to confirm that I seemed to be processing correctly.

          v0.0.1.1-dev

          • add options processing

          example JSON:

          {
            "extensions": {
              "md": "markdown",
              "markdown": "markdown"
            },
            "lexers": {
              "markdown": {
                  "0  SCE_MARKDOWN_DEFAULT"    : { "fgColor": "", "bgColor": "", "fontStyle": "0" },
                  "1  SCE_MARKDOWN_LINE_BEGIN" : { "fgColor": "DADADA", "bgColor": "", "fontStyle": "0" },
                  "2  SCE_MARKDOWN_STRONG1"    : { "fgColor": "EECCAA", "bgColor": "", "fontStyle": "1" },
                  "3  SCE_MARKDOWN_STRONG2"    : { "fgColor": "EECCAA", "bgColor": "4F4F4F", "fontStyle": "1" },
                  "4  SCE_MARKDOWN_EM1"        : { "fgColor": "AADDFF", "bgColor": "", "fontStyle": "2" },
                  "5  SCE_MARKDOWN_EM2"        : { "fgColor": "AADDFF", "bgColor": "4F4F4F", "fontStyle": "2" },
                  "6  SCE_MARKDOWN_HEADER1"    : { "fgColor": "FFFFFF", "bgColor": "8F8F8F", "fontStyle": "1" },
                  "7  SCE_MARKDOWN_HEADER2"    : { "fgColor": "CCffff", "bgColor": "7F7F7F", "fontStyle": "1" },
                  "8  SCE_MARKDOWN_HEADER3"    : { "fgColor": "CCbbbb", "bgColor": "6F6F6F", "fontStyle": "1" },
                  "9  SCE_MARKDOWN_HEADER4"    : { "fgColor": "CC7777", "bgColor": "5F5F5F", "fontStyle": "1" },
                  "10 SCE_MARKDOWN_HEADER5"    : { "fgColor": "CC3333", "bgColor": "4F4F4F", "fontStyle": "1" },
                  "11 SCE_MARKDOWN_HEADER6"    : { "fgColor": "CC0000", "bgColor": "3F3F3F", "fontStyle": "1" },
                  "12 SCE_MARKDOWN_PRECHAR"    : { "fgColor": "5F5F5F", "bgColor": "4F4F4F", "fontStyle": "0" },
                  "13 SCE_MARKDOWN_ULIST_ITEM" : { "fgColor": "0000CC", "bgColor": "4F4F4F", "fontStyle": "0" },
                  "14 SCE_MARKDOWN_OLIST_ITEM" : { "fgColor": "0000CC", "bgColor": "4F4F4F", "fontStyle": "0" },
                  "15 SCE_MARKDOWN_BLOCKQUOTE" : { "fgColor": "00CC00", "bgColor": "4F4F4F", "fontStyle": "0" },
                  "16 SCE_MARKDOWN_STRIKEOUT"  : { "fgColor": "6F6F6F", "bgColor": "", "fontStyle": "0" },
                  "17 SCE_MARKDOWN_HRULE"      : { "fgColor": "FFFFFF", "bgColor": "0020C0", "fontStyle": "0" },
                  "18 SCE_MARKDOWN_LINK"       : { "fgColor": "8F8FFF", "bgColor": "", "fontStyle": "4" },
                  "19 SCE_MARKDOWN_CODE"       : { "fgColor": "FFFF00", "bgColor": "6F6F6F", "fontStyle": "0" },
                  "20 SCE_MARKDOWN_CODE2"      : { "fgColor": "FFFF00", "bgColor": "6F6F6F", "fontStyle": "0" },
                  "21 SCE_MARKDOWN_CODEBK"     : { "fgColor": "FFFF00", "bgColor": "6F6F6F", "fontStyle": "0" },
                  "options": { "lexer.markdown.header.eolfill": "1" },
                  "keywords": [ "", "", "", "", "", "", "", "", "" ]
              }
            }
          }
          

          I verified the functionality using AllStyles.md from the lexilla test suite in N++ codebase; I can change from "1" to "0" and watch the header lines change:

          • “1”: 7a8b4e58-b893-4fb8-bb9a-6e5ca3f67618-image.jpeg
          • “0”: 3c97a3c7-7586-4d10-9666-625450717e3d-image.jpeg

          So I believe that options are implemented now.

          Also, this one is in a release tag, so you can either find the artifacts as before, or you can download a normal PluginsAdmin-style zipfile which can be unzipped and the DLL installed, as with any normal manual plugin installation.

          mpheathM 1 Reply Last reply Reply Quote 1
          • mpheathM Offline
            mpheath @PeterJones
            last edited by mpheath

            @PeterJones You have enabled the lexer property of lexer.markdown.header.eolfill though the styles are not using it as I see in the images. For clarity, I am focussing on eolfilled on the style id rather then the property itself so could an extra attribute not available currently.

            Here is a example in SciTE on the level 1 header:

            eolfilled.png

            As the styling shows:

            {6}# Tools
            {1}
            {0}Lua scripts that can be executed by dofile.{1}
            
            
            {7}## Ideas
            {1}
            

            there is nothing preventing style id 6 to fill the whole line with the background colour if the eolfilled style is used.

            I added this to SciTE’s Option -> Open User Options File

            # SCE_MARKDOWN_HEADER1: "#" - Level-one header
            style.markdown.6=fore:#FF7766,bold,back:#700000,eolfilled
            

            The json file could have eolFilled attribute setting like the fontStyle attribute so is applied for the style id.

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

              @mpheath said:

              @PeterJones You have enabled the lexer property of lexer.markdown.header.eolfill though the styles are not using it as I see in the images.

              Well, it partially used it, in that the style went to the end of the header text instead of just the end of the ### symbols.

              The json file could have eolFilled attribute setting like the fontStyle attribute so is applied for the style id.

              I didn’t know/remember that SCI_STYLESETEOLFILLED existed until your post made me go look for it. I will have to add that attribute to the style info in the JSON

              mpheathM 1 Reply Last reply Reply Quote 1
              • mpheathM Offline
                mpheath @PeterJones
                last edited by mpheath

                @PeterJones I just did an edit before you replied. The property does change the processing of headers the eolfilled though on the style itself is absent.

                PeterJonesP 2 Replies Last reply Reply Quote 0
                • PeterJonesP Offline
                  PeterJones @mpheath
                  last edited by

                  v0.0.1.2-dev

                  • Add the "eolFilled": "1" attribute to the JSON (expected values: not supplied, "","0","1"). This will allow lexers that support the SCI_STYLESETEOLFILLED style to fill the styling to the end of the window instead of the end of the text.

                  e40ab72a-6d2e-40b0-978d-e0fe127a46b2-image.jpeg

                          "6  SCE_MARKDOWN_HEADER1"    : { "fgColor": "FFFFFF", "bgColor": "8F8F8F", "fontStyle": "1", "eolFilled": "1" },
                          "7  SCE_MARKDOWN_HEADER2"    : { "fgColor": "CCffff", "bgColor": "7F7F7F", "fontStyle": "1", "eolFilled": "1" },
                          "8  SCE_MARKDOWN_HEADER3"    : { "fgColor": "CCbbbb", "bgColor": "6F6F6F", "fontStyle": "1", "eolFilled": "1" },
                          "9  SCE_MARKDOWN_HEADER4"    : { "fgColor": "CC7777", "bgColor": "5F5F5F", "fontStyle": "1", "eolFilled": "1" },
                          "10 SCE_MARKDOWN_HEADER5"    : { "fgColor": "CC3333", "bgColor": "4F4F4F", "fontStyle": "1", "eolFilled": "1" },
                          "11 SCE_MARKDOWN_HEADER6"    : { "fgColor": "CC0000", "bgColor": "474747", "fontStyle": "1", "eolFilled": "1" },
                  
                  1 Reply Last reply Reply Quote 1
                  • PeterJonesP Offline
                    PeterJones @mpheath
                    last edited by

                    @mpheath ,

                    I am curious: do you think it’s enough to warrant trying to get v1 in Plugins Admin for the upcoming v8.9.8 RC? Or should I give more time for more people to test? (Or do you think it’s really worth publishing at all?)

                    (And secondary question: for getting the styler output from SciTE, are you just running TestLexers.exe from a N++ or just-scintilla build? or is there another way of generating that? I have my PythonScript styleDebugger script for doing it inside N++, but was curious if there was an easy way to do it directly from SciTE)

                    mpheathM 2 Replies Last reply Reply Quote 0
                    • mpheathM Offline
                      mpheath @PeterJones
                      last edited by

                      @PeterJones said:

                      @mpheath ,

                      I am curious: do you think it’s enough to warrant trying to get v1 in Plugins Admin for the upcoming v8.9.8 RC? Or should I give more time for more people to test? (Or do you think it’s really worth publishing at all?)

                      Rushing anything can lead to a buggy release. You may want to make sure decisions like file format with the json … is good which is important. If OK, then release. I cannot come up with anything that prevents it. I do not see anyone desperate for a rushed release so you choose.

                      (And secondary question: for getting the styler output from SciTE, are you just running TestLexers.exe from a N++ or just-scintilla build? or is there another way of generating that? I have my PythonScript styleDebugger script for doing it inside N++, but was curious if there was an easy way to do it directly from SciTE)

                      I do it from Notepad++ with PythonScript, SciTE with Lua or if want to do it the hard way, with TestLexers.exe.

                      TestLexers.exe should be used for actual Lexilla lexer changes as it does additional things like checking CRLF/LF modes … so is official for Lexilla contributions. From SciTE, I use a Lua script to output the data to the console pane. In my previous comment where I posted the styling information was printed from a Lua function that uses CharAt and StyleIndexAt to know where to insert the {N} style ids.

                      I did a quick hack as my script has MsgBoxes and other incompatable code for an uncustomized SciTE.

                      File: printStyles.lua in same directory as SciTE:

                      -- about: Print Style IDs for the current document.
                      
                      do
                          local lastID = -1
                          local text = ''
                          local startPos = 0
                          local endPos = editor.Length
                      
                          -- Set to selection positions.
                          if editor.SelectionEnd > editor.SelectionStart then
                              startPos = editor.SelectionStart
                              endPos = editor.SelectionEnd
                          end
                      
                          -- Process each char.
                          for i = startPos, endPos do
                              local ch = editor.CharAt[i]
                      
                              if ch < 0 then
                                  ch = ch + 256
                              end
                      
                              local character = string.char(ch)
                              local styleId = editor.StyleIndexAt[i]
                      
                              if styleId ~= lastID then
                                  text = text .. '{' .. tostring(styleId) .. '}'
                              end
                      
                              text = text .. character
                      
                              lastID = styleId
                          end
                      
                          -- Output the reformatted text.
                          if text ~= '' then
                              print(text)
                          end
                      end
                      

                      and add to the User Options File:

                      # 01 PrintDocStyles similar to TestLexers.exe
                      command.name.1.*.*=PrintDocStyles
                      command.1.*.*=dofile $(SciteDefaultHome)\printStyles.lua
                      command.subsystem.1.*.*=3
                      command.save.before.1.*.*=2
                      

                      or if using Sc1, can just add it to the Global Options File to save in same directory as the Sc1 executable file.

                      In the SciTE Tools menu drop down, should then show an item named PrintDocStyles or press Ctrl+1 keys to run the function.

                      1 Reply Last reply Reply Quote 1
                      • mpheathM Offline
                        mpheath @PeterJones
                        last edited by

                        @PeterJones Looking through the readme.md. Perhaps could make it easier for users to have a properties list for the lexer options, like possibly from

                        https://github.com/mpheath/xconfig-for-notepad-plus-plus/blob/bed2f415648623b6ce0f49b6ed333fbedfdba8be/xconfig.properties#L122-L585

                        Possibly, a little bit of your regex tricks could rearrange to get the list of options into a file for users to view.

                        SciTE Doc has a good lexer property listing:
                        https://scintilla.org/SciTEDoc.html#property-xml.auto.close.tags
                        which is where the source of information can be viewed in HTML.

                        Getting all the information to insert into the json file is the challenge.

                        I just thought of the Nim lexer. Notepad++ still uses the deprecated Nimrod lexer though I do not use Nim. You can see some of the hackery I had to do to recognize the Nim lexer from the Nimrod lexer here with PythonScript. Nim users who want an improved Nim lexer can access it with the HiddenLexers plugin. So benefits exist for those with the interest in the hidden lexers.

                        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