Community
    • Login

    Is it possible to remove bold formatting using PythonScript

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 2 Posters 637 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.
    • Daniel FuchsD
      Daniel Fuchs
      last edited by Daniel Fuchs

      Hi everyone,

      I am trying to remove a bold formatting that comes from an UDL using PythonScript and the EnhancedUDLLexer example which is modified.

      Here is a concrete example

      [TEST]
       ^ this is bold and should be bold
      PARAMETER = VALUE,[:d | smalltalk extension method],
                         ^ this should not be bold, yet it currently is
      PARAMETER2 = VALUE2
      ...
      

      I already got a fitting regular expression ready, albeit being a little hacky:

      \S{1,}.*(\[((?>[^\[\]]+|(?R))*)\])
      

      However I am not able to modify the display of the found texts decoration. Changing the color works well, but isn’t what I want.

      Is there anything I can do about this. If not by PythonScript, then eventually with UDL file modification.

      Bonus points, if it is somehow possible to change syntax highlighting to the pre-installed “Smalltalk” but only inside the aforementioned statement. ;)

      Thanks in advance!
      Daniel

      EkopalypseE 1 Reply Last reply Reply Quote 0
      • EkopalypseE
        Ekopalypse @Daniel Fuchs
        last edited by

        @Daniel-Fuchs

        No, you can’t. The reason is that lexers use styles and the script,
        which by the way there is an updated version here, uses
        indicators.
        Indicators do not have access to all font attributes, well, the only
        access they have is the font foreground color.

        I assume you’ve configured the [ and ] being delimiters with a bold style, correct?

        Is it possible to define two like in this example?

        7027df77-203b-467f-982e-ddb3cd79dc71-image.png

        1 Reply Last reply Reply Quote 3
        • Daniel FuchsD
          Daniel Fuchs
          last edited by

          This is a great idea, @Ekopalypse. Thank you for this one.

          It works quite well, i guess. But I’ve come across an issue: Is there anything I can do to ignore spaces between the opening bracket and the colon, like when I use

          [:i | ... ]
          

          which is the same like

          [   :i | ... ]
          

          P.S.: Sorry for the late reply.

          1 Reply Last reply Reply Quote 3
          • EkopalypseE
            Ekopalypse
            last edited by

            Is there anything I can do to ignore spaces between the opening bracket and the colon,

            I don’t think so, let me think about it.

            1 Reply Last reply Reply Quote 1
            • EkopalypseE
              Ekopalypse
              last edited by

              @Daniel-Fuchs

              I’m sorry, but at the moment I don’t see how this could be solved other than doing the complete lexing with a dedicated plugin. Do you have some reasonable large code which you can share? Together with the information of what should be styled how?

              1 Reply Last reply Reply Quote 0
              • Daniel FuchsD
                Daniel Fuchs
                last edited by

                @Ekopalypse

                OK, thank you for your effort!
                I will try to work my way along your great example script here:
                https://github.com/bruderstein/PythonScript/blob/master/scripts/Samples/EnhancedPythonLexer.py

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