Community
    • Login

    Pascal multi line string highlight

    Scheduled Pinned Locked Moved General Discussion
    2 Posts 2 Posters 45 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.
    • Ertan KüçükogluE
      Ertan Küçükoglu
      last edited by

      Hello,

      Delphi (Object Pascal) supports multi-line strings in its recent versions.
      It would be nice to have it visualized as string in Notepad++

      Three single quote characters starts multi-line. Three single quote characters finish multi-line.
      Starting cannot have any string after quote characters
      Finishing cannot have any string before quote characters

      Sample multi-line

          LColorQuery.SQL.Text := '''
          select name from colors where autoinc=:id
          ''';
      

      What is displayed in Notepad++ is like below now
      ba51f724-9a97-4648-b140-0558915a2359-image.png

      How regular strings are displayed is like below (“picture path” is string)
      bf792b3c-1474-4dea-aacf-aa6586e8b7e3-image.png

      Thank you for your consideration.

      Regards,
      Ertan

      P.S. Forum highlighter correctly displayed multi-line in different color.

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Ertan Küçükoglu
        last edited by

        @Ertan-Küçükoglu said in Pascal multi line string highlight:

        It would be nice to have it visualized as string in Notepad++

        Notepad++ uses a library called “Lexilla” to handle deciding what characters in a document to syntax highlight. When I use their testbed “SciTE” editor, it is showing that it’s treating the line ending with ''' as an “unterminated string”. But it apparently doesn’t know that Delphi recently added multi-line strings with the triple-quote syntax.

        The Lexilla project has ome reported issues about Pascal and Delphi – you can look through those, and see if any mention the multi-line strings. If not, you might want to request that they add it. Once they add it, and Notepad++ updates its Lexilla library, then Notepad++ could add that new styleID to the Style Configurator options for Pascal. But until they add the support, there’s nothing Notepad++ can do about the official lexing of the language.

        However, as a workaround, there is a plugin called “EnhanceAnyLexer”, which allows you to add regex-based foreground colors. Doing multi-line stuff with a regex is risky if there’s a mismatched triple-quote somewhere, but once you install EnhanceAnyLexer, open your Delphi/Pascal file, use Plugins > EnhanceAnyLexer > Enhance current language, which will open up a [pascal] section in the EnhanceAnyLexerConfig.ini. Set it to the following

        [pascal]
        ; Everything between pairs of triple-ticks is colored cyan
        0xCCCC00 = (?s)'''.*?'''
        ;excluded_styles = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,20,21,22,23
        

        (make sure you use the ; or # to coment out the excluded_styles, otherwise it won’t color properly; you can, of course, pick any 0xBBGGRR values you want to choose your own color, as described in the comments of the INI file.)

        With that INI saved, it will mean that from now on, the EnhanceAnyLexer plugin will color triple-quote multi-line strings in Delphi/Pascal files. like this example:
        5ba5abdd-c30f-4536-b470-290f55647f1a-image.png

        Since some people aren’t clear when I’ve given such instructions: once you save the EnhanceAnyLexerSettings.ini, the EnhanceAnyLexer will always apply that regex-based coloring to Pascal/Delphi files (you don’t have to run Enhance current language every time you want to turn it on; with the plugin installed, and the ini saved, it will be automatic).

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