• Login
Community
  • Login

Is it possible to remove bold formatting using PythonScript

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 2 Posters 642 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.
  • D
    Daniel Fuchs
    last edited by Daniel Fuchs Aug 17, 2020, 3:00 PM Aug 17, 2020, 2:58 PM

    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

    E 1 Reply Last reply Aug 17, 2020, 5:58 PM Reply Quote 0
    • E
      Ekopalypse @Daniel Fuchs
      last edited by Aug 17, 2020, 5:58 PM

      @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
      • D
        Daniel Fuchs
        last edited by Sep 3, 2020, 12:51 PM

        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
        • E
          Ekopalypse
          last edited by Sep 6, 2020, 1:20 PM

          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
          • E
            Ekopalypse
            last edited by Sep 8, 2020, 10:54 AM

            @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
            • D
              Daniel Fuchs
              last edited by Sep 9, 2020, 12:10 PM

              @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