Community
    • Login

    Perl language syntax highlighting troubles (bug or limitation ?)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    112 Posts 6 Posters 44.0k 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.
    • PeterJonesP
      PeterJones
      last edited by

      @Gilles-Maisonneuve said:

      But the here document syntax coloring is more annoying : ‘<<’ should be colored either as the other separators or keywords according to me

      Yeah. I wouldn’t say keywords; I would think either operators or punctuation would be the appropriate place for the << to get its coloring from.

      @Ekopalypse ,
      Thanks for the SciTE comparison. I’d say in that test doc, it was highlighting in a reasonable manner; maybe not exactly what I thought would be, but at least it’s recognizing and highlighting the syntax

      Since you have access to the SciTE, I’d like to see how it renders these examples of heredoc syntax, if you have time:

      # for completeness, << as shift operator
      $b = (1 << 5);
      
      # heredoc with quotes
      $x =<<"EOX";
      Something with embedded $y
      EOX
      
      # heredoc without quotes
      $z =<<EOZ;
      Plain text here
      EOZ
      
      # heredoc with space highlights as operator in Notepad++
      $z =<< EOZ;
      Plain text here
      EOZ
      
      # all the heredoc text formats as Notepad++ default, rather than any of the Perl-specific style categories
      

      I’m curious which of those << that SciTE will color, and which it won’t.

      Thanks.

      Alan KilbornA 1 Reply Last reply Reply Quote 2
      • EkopalypseE
        Ekopalypse
        last edited by

        1 Reply Last reply Reply Quote 2
        • PeterJonesP
          PeterJones
          last edited by

          @Ekopalypse ,

          Wow, lightning fast. :-)

          Except for the last, that’s what I’d actually hope for.

          I just learned something: according to perlop, in order to allow the space between the << and the EOZ, it actually has to be quoted.

          There may not be a space between the << and the identifier, unless the identifier is explicitly quoted.

          Before reading that, I was going to say that the lexer was missing that functionality. But I guess we’d have to check

          $z =<< "EOZ";
          Plain text here
          EOZ
          

          to see if it knows that exception.

          So, the updated perl lexer in scintilla definitely handles perl highlighting better than the version that’s in Notepad++.

          EkopalypseE 1 Reply Last reply Reply Quote 2
          • EkopalypseE
            Ekopalypse @PeterJones
            last edited by

            @PeterJones

            Is it only me or is the server acting strange today?
            I get 503 and 4s and no updates - have to manually refresh the page …

            Meta ChuhM 1 Reply Last reply Reply Quote 2
            • Meta ChuhM
              Meta Chuh moderator @Ekopalypse
              last edited by

              @Ekopalypse

              Is it only me or is the server acting strange today?
              I get 503 and 4s and no updates - have to manually refresh the page …

              yes, the downtimes today are higher than usual.
              i hope it’s not another ddos attack.
              anyone who knows more, please keep us informed.

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

                By using these regexes, I know they aren’t optimal yet, we could get something like
                this npp snipped picture. Note, I just used the blue color for showing the difference to error text.
                What is a nice regex way to do something like if ( then ) or if [ then ] or if { then } ??
                And of course by creating match groups we could divide the quoting operators from the following “correct” text which then would be colored differently - if wanted.

                I have to stay up early tomorrow - so chrchrchr… :-)

                \b(q|qq|qr|qw|qx|tr|y)\b
                \b(q|qq|qr|qw|qx|tr|y)\b([\W]).*?\2
                \b(q|qq|qr|qw|qx|tr|y)\b(\().*?\)
                \b(q|qq|qr|qw|qx|tr|y)\b(\[).*?\]
                \b(q|qq|qr|qw|qx|tr|y)\b(\{).*?\}
                \b(q|qq|qr|qw|qx|tr|y)\b\h+(\w).*?\2
                

                1 Reply Last reply Reply Quote 2
                • Alan KilbornA
                  Alan Kilborn @PeterJones
                  last edited by

                  @PeterJones said:

                  Since you have access to the SciTE…

                  Doesn’t everyone have access to it ?

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

                    @Alan-Kilborn said:

                    Doesn’t everyone have access to it ?

                    I was originally going to phrase it as “easy access (ie, already installed/available on your machine)”. But what I really should have said was “I am just about to leave for the day, and don’t feel like downloading another piece of software and mussing about with getting it installed or otherwise running, and figuring out how to get it to behave in the manner that Eko has already proved he knows how to make it work”, so stuck with the shorthand of “have access to”. :-)

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

                      Using this pythonscript results in something like the attached picture
                      using Obsidian theme

                      # -*- coding: utf-8 -*-
                      
                      from Npp import editor, editor1, editor2, notepad, NOTIFICATION, SCINTILLANOTIFICATION, INDICATORSTYLE
                      from collections import OrderedDict
                      regexes = OrderedDict()
                      
                      # ------------------------------------------------- configuration area ---------------------------------------------------
                      # id which is returned by editor.getLexer()
                      BUILTIN_LEXER_ID = 6  # perl
                      
                      # Definition of colors and regular expressions
                      #   Note, the order in which regular expressions will be processed is determined by its creation,
                      #   that is, the first definition is processed first, then the 2nd, and so on
                      #
                      #   The basic structure always looks like this
                      #
                      #   regexes[(a, b)] = (c, d)
                      #
                      #   regexes = an ordered dictionary which ensures that the regular expressions are always processed in the same order
                      #   a = a unique number - suggestion, start with 0 and always increase by one
                      #   b = color is either in the form of (r,g,b) or a single integer without round brackets.
                      #       It is assumed that a single integer reflects an existing style id of the current lexer
                      #       as defined in stylers.xml -> benefit it works with different themes flawlessly (as long as the theme is correct, of course)
                      #   c = raw byte string, describes the regular expression. Example r'\w+'
                      #   d = list of ingegers -> using different match group results per regex
                      
                      # examples for enhancing the perl lexer
                      # color every word instance of q|qq|qr|qw|qx|tr|y
                      # with the same color as defined by style id 5 using result from matchgroup 0
                      regexes[(1, 5)] = (r'\bq[rwqx]{0,1}\b([^\h]).*?\1|(\bq[rwqx]{0,1}\b\h+(\w).*?\3)', [0])
                      regexes[(2, 5)] = (r'\bq[rwqx]{0,1}\b\h*(\(.+?\)|\[.+?\]|\{.+?\})', [0])
                      # in the same color as defined by style id 5 using results from matchgroup 1 and 4
                      regexes[(3, (130,130,170))] = (r'(?s)((<<)"*(\w+?)"*;.*?\3)', [2])
                      regexes[(4, (130,130,170))] = (r'(?s)((<<)\h+"(\w+?)";.*?\3)', [2,3])
                      
                      # Definition of which area should not be styled
                      # One needs to check the stylers.xml (or THEMENAME.xml) to be able to see which
                      # ids are defined by the lexer in use and what there purposes are
                      # Example: perl defines ids 0 to 21 (without 11, 15, and 16) (??? - historical reasons ???)
                              # <LexerType name="perl" desc="Perl" ext="">
                                  # <WordsStyle name="DEFAULT" styleID="0" fgColor="FF0000" ...
                                  # <WordsStyle name="ERROR" styleID="1" fgColor="FF80C0" ...
                                  # <WordsStyle name="COMMENT LINE" styleID="2" fgColor="008000" ...
                                  # <WordsStyle name="POD" styleID="3" fgColor="000000" 
                                  # <WordsStyle name="NUMBER" styleID="4" fgColor="FF0000" 
                                  # <WordsStyle name="INSTRUCTION WORD" styleID="5" fgColor="0000FF"
                                  # <WordsStyle name="STRING" styleID="6" fgColor="808080" 
                                  # <WordsStyle name="CHARACTER" styleID="7" fgColor="808080" 
                                  # <WordsStyle name="PUNCTUATION" styleID="8" fgColor="804000" 
                                  # <WordsStyle name="PREPROCESSOR" styleID="9" fgColor="804000" 
                                  # <WordsStyle name="OPERATOR" styleID="10" fgColor="000080" 
                                  # <WordsStyle name="SCALAR" styleID="12" fgColor="FF8000" 
                                  # <WordsStyle name="ARRAY" styleID="13" fgColor="CF34CF" 
                                  # <WordsStyle name="HASH" styleID="14" fgColor="8080C0" 
                                  # <WordsStyle name="SYMBOL TABLE" styleID="15" fgColor="FF0000" 
                                  # <WordsStyle name="REGEX" styleID="17" fgColor="8080FF" 
                                  # <WordsStyle name="REGSUBST" styleID="18" fgColor="8080C0" 
                                  # <WordsStyle name="LONGQUOTE" styleID="19" fgColor="FF8000" 
                                  # <WordsStyle name="BACKTICKS" styleID="20" fgColor="FFFF00" 
                                  # <WordsStyle name="DATASECTION" styleID="21" fgColor="808080" 
                              # </LexerType>
                      
                      # by definining 1 and 2 means, that a regex match would be ignored if the
                      # position, which should be colored, has been styled as ERROR or COMMENT LINE
                      excluded_styles = [1, 2]
                      
                      # ------------------------------------------------ /configuration area ---------------------------------------------------
                      
                      try:
                          EnhanceBuiltinLexer().main()
                      except NameError:
                      
                          SC_INDICVALUEBIT = 0x1000000
                          SC_INDICFLAG_VALUEFORE = 1
                      
                      
                          class SingletonEnhanceBuiltinLexer(type):
                              '''
                                  Ensures, more or less, that only one
                                  instance of the main class can be instantiated
                              '''
                              _instance = None
                              def __call__(cls, *args, **kwargs):
                                  if cls._instance is None:
                                      cls._instance = super(SingletonEnhanceBuiltinLexer, cls).__call__(*args, **kwargs)
                                  return cls._instance
                      
                      
                          class EnhanceBuiltinLexer(object):
                              '''
                                  Provides additional color options and should be used in conjunction with the built-in UDL function.
                                  An indicator is used to avoid style collisions.
                                  Although the Scintilla documentation states that indicators 0-7 are reserved for the lexers,
                                  indicator 0 is used because UDL uses none internally.
                      
                                  Even when using more than one regex, it is not necessary to define more than one indicator
                                  because the class uses the flag SC_INDICFLAG_VALUEFORE.
                                  See https://www.scintilla.org/ScintillaDoc.html#Indicators for more information on that topic
                              '''
                              __metaclass__ = SingletonEnhanceBuiltinLexer
                      
                              def __init__(self):
                                  '''
                                      Instantiated the class,
                                      because of __metaclass__ = ... usage, is called once only.
                                  '''
                                  editor.callbackSync(self.on_updateui, [SCINTILLANOTIFICATION.UPDATEUI])
                                  notepad.callback(self.on_langchanged, [NOTIFICATION.LANGCHANGED])
                                  notepad.callback(self.on_bufferactivated, [NOTIFICATION.BUFFERACTIVATED])
                                  self.doc_is_of_interest = False
                                  self.lexer_id = BUILTIN_LEXER_ID
                                  self.configure()
                      
                      
                              @staticmethod
                              def rgb(r, g, b):
                                  '''
                                      Helper function
                                      Retrieves rgb color triple and converts it
                                      into its integer representation
                      
                                      Args:
                                          r = integer, red color value in range of 0-255
                                          g = integer, green color value in range of 0-255
                                          b = integer, blue color value in range of 0-255
                                      Returns:
                                          integer
                                  '''
                                  return (b << 16) + (g << 8) + r
                      
                      
                              @staticmethod
                              def paint_it(color, matchgroups, match):
                                  '''
                                      This is where the actual coloring takes place.
                                      Color, matchgroups and match object must be provided.
                                      Matchgroups define which group(s) is(are) of interest
                                      Coloring occurs only if the position is not within the excluded range.
                      
                                      Args:
                                          color = integer, expected in range of 0-16777215
                                          matchgroups = list of integers
                                          match = python re.match object
                                      Returns:
                                          None
                                  '''
                                  for group in matchgroups:
                                      pos = match.span(group)[0]
                                      if pos < 0 or editor.getStyleAt(pos) in excluded_styles:
                                          continue
                                      editor.setIndicatorCurrent(0)
                                      editor.setIndicatorValue(color)
                                      editor.indicatorFillRange(pos, match.span(group)[1] - pos)
                      
                      
                              def style(self):
                                  '''
                                      Calculates the text area to be searched for in the current document.
                                      Deletes the old indicators before setting new ones and
                                      calls the defined regexes.
                      
                                      Args:
                                          None
                                      Returns:
                                          None
                                  '''
                                  start_line = editor.docLineFromVisible(editor.getFirstVisibleLine())
                                  end_line = editor.docLineFromVisible(start_line + editor.linesOnScreen())
                                  start_position = editor.positionFromLine(start_line)
                                  end_position = editor.getLineEndPosition(end_line)
                                  editor.setIndicatorCurrent(0)
                                  editor.indicatorClearRange(0, editor.getTextLength())
                                  for color, regex in self.regexes.items():
                                      editor.research(regex[0],
                                                      lambda match: self.paint_it(color[1],
                                                                                  regex[1],
                                                                                  match),
                                                      0,
                                                      start_position,
                                                      end_position)
                      
                      
                              def configure(self):
                                  '''
                                      Define basic indicator settings and reformat needed regexes.
                      
                                      Args:
                                          None
                                      Returns:
                                          None
                                  '''
                                  editor1.indicSetStyle(0, INDICATORSTYLE.TEXTFORE)
                                  editor1.indicSetFlags(0, SC_INDICFLAG_VALUEFORE)
                                  editor2.indicSetStyle(0, INDICATORSTYLE.TEXTFORE)
                                  editor2.indicSetFlags(0, SC_INDICFLAG_VALUEFORE)
                      
                                  regex_list = []
                                  for k, v in regexes.items():
                                      if isinstance(k[1], tuple):
                                          fg_color = k[1]
                                      else:
                                          fg_color = editor.styleGetFore(k[1])
                                      regex_list.append(((k[0], self.rgb(*fg_color) | SC_INDICVALUEBIT), v))
                      
                                  self.regexes = OrderedDict(regex_list)
                      
                      
                      
                              def check_lexer(self):
                                  '''
                                      Checks if the current document is of interest
                                      and sets the flag accordingly
                      
                                      Args:
                                          None
                                      Returns:
                                          None
                                  '''
                                  self.doc_is_of_interest = True if editor.getLexer() == self.lexer_id else False
                      
                      
                              def on_bufferactivated(self, args):
                                  '''
                                      Callback which gets called every time one switches a document.
                                      Triggers the check if the document is of interest.
                      
                                      Args:
                                          provided by notepad object but none are of interest
                                      Returns:
                                          None
                                  '''
                                  self.check_lexer()
                      
                      
                              def on_updateui(self, args):
                                  '''
                                      Callback which gets called every time scintilla
                                      (aka the editor) changed something within the document.
                      
                                      Triggers the styling function if the document is of interest.
                      
                                      Args:
                                          provided by scintilla but none are of interest
                                      Returns:
                                          None
                                  '''
                                  if self.doc_is_of_interest:
                                      self.style()
                      
                      
                              def on_langchanged(self, args):
                                  '''
                                      Callback gets called every time one uses the Language menu to set a lexer
                                      Triggers the check if the document is of interest
                      
                                      Args:
                                          provided by notepad object but none are of interest
                                      Returns:
                                          None
                                  '''
                                  self.check_lexer()
                      
                      
                              def main(self):
                                  '''
                                      Main function entry point.
                                      Simulates two events to enforce detection of current document
                                      and potential styling.
                      
                                      Args:
                                          None
                                      Returns:
                                          None
                                  '''
                                  self.on_bufferactivated(None)
                                  self.on_updateui(None)
                      
                          EnhanceBuiltinLexer().main()
                      
                      

                      Gilles MaisonneuveG 1 Reply Last reply Reply Quote 3
                      • Gilles MaisonneuveG
                        Gilles Maisonneuve @Ekopalypse
                        last edited by

                        @Ekopalypse
                        Woaw! that seems wonderful.

                        Small question however, as I don’t have a clue about all what you wrote: how do I make this work for me? I don’t know Python, have no Python IDE or language installed on my machine. What should I do to make n++ uses this Python “trick” ?

                        Thanks anyway for the work.

                        EkopalypseE Meta ChuhM 2 Replies Last reply Reply Quote 3
                        • EkopalypseE
                          Ekopalypse @Gilles Maisonneuve
                          last edited by Ekopalypse

                          @Gilles-Maisonneuve

                          may I ask you to post your debug info? (available under ? menu)
                          to see which version of npp you are using and how you have set it up?
                          This would make it easier to describe what needs to be done.

                          Gilles MaisonneuveG 1 Reply Last reply Reply Quote 2
                          • Meta ChuhM
                            Meta Chuh moderator @Gilles Maisonneuve
                            last edited by

                            @Gilles-Maisonneuve

                            What should I do to make n++ uses this Python “trick” ?

                            if you are already on notepad++ 7.6.3 or 7.6.4, the first thing you have to do, is to install the pythonscript plugin ,
                            by following the Guide: How to install the PythonScript plugin on Notepad++ 7.6.3, 7.6.4 and above:

                            Gilles MaisonneuveG 1 Reply Last reply Reply Quote 2
                            • Gilles MaisonneuveG
                              Gilles Maisonneuve @Ekopalypse
                              last edited by

                              @Ekopalypse
                              Here it is :
                              Notepad++ v7.3.2 (32-bit)
                              Build time : Feb 12 2017 - 23:15:39
                              Path : C:\Program Files (x86)\Notepad++\notepad++.exe
                              Admin mode : OFF
                              Local Conf mode : OFF
                              OS : Windows 7 (64-bit)
                              Plugins : ComparePlugin.dll CustomizeToolbar.dll DSpellCheck.dll HTMLTag_unicode.dll MathPad.dll MenuIcons.dll mimeTools.dll NppCCompletionPlugin.dll NppColumnSort.dll NppExec.dll NppExport.dll NppSaveAsAdmin.dll NppTextFX.dll PluginManager.dll regrexplace.dll SessionMgr.dll

                              1 Reply Last reply Reply Quote 2
                              • Gilles MaisonneuveG
                                Gilles Maisonneuve @Meta Chuh
                                last edited by

                                @Meta-Chuh

                                All right I am going to migrate right away and I come back to give back my new debug info

                                @Ekopalypse : please do not take into account my previous information for the moment.

                                Meta ChuhM 1 Reply Last reply Reply Quote 0
                                • Meta ChuhM
                                  Meta Chuh moderator @Gilles Maisonneuve
                                  last edited by Meta Chuh

                                  @Gilles-Maisonneuve

                                  note that if you update your old 7.3.2 version with the 7.6.4 installer from >>> here <<<, you will need to reinstall your plugins using the new built in plugins admin menu.

                                  (or migrate your old plugins manually, or with a script, what ever you decide to be the easiest for you. we will help you with that)

                                  if you go for the batch script variant, the best script would be @dinkumoil 's MigrateNppPlugins.cmd, as it will migrate all past notepad++ releases, with all the different plugin folder structures that have existed.

                                  you can find his MigrateNppPlugins.cmd script >>> here <<<

                                  1 Reply Last reply Reply Quote 2
                                  • Gilles MaisonneuveG
                                    Gilles Maisonneuve
                                    last edited by Gilles Maisonneuve

                                    Notepad++ v7.6.4 (64-bit)
                                    Build time : Mar 6 2019 - 02:58:24
                                    Path : C:\Program Files\Notepad++\notepad++.exe
                                    Admin mode : OFF
                                    Local Conf mode : OFF
                                    OS : Windows 7 (64-bit)
                                    Plugins : ComparePlugin.dll DSpellCheck.dll HTMLTag.dll mimeTools.dll NppConverter.dll PluginManager.dll _CustomizeToolbar.dll

                                    Note that the plugins installed by the additional plugin manager under C:\Users\gm\AppData\Roaming\Notepad++\plugins are not listed here. Only the ones installed under C:\Program Files\Notepad++\plugins are listed in debug info.

                                    Additional plugins are :

                                    total 3824
                                    drw-rw-rw-   7 gm 0   12288 2019-03-15 01:55 config
                                    drw-rw-rw-   3 gm 0       0 2019-03-15 01:44 doc
                                    -rw-rw-rw-   1 gm 0  708096 2019-03-15 01:45 HexEditor.dll
                                    drw-rw-rw-  15 gm 0    4096 2019-03-15 01:44 MenuIcons
                                    -rw-rw-rw-   1 gm 0  125952 2019-03-15 01:45 MenuIcons.dll
                                    -rw-rw-rw-   1 gm 0  368128 2019-03-15 01:55 NppSaveAsAdmin.dll
                                    -rw-rw-rw-   1 gm 0  611328 2019-03-15 01:47 PluginManager.dll
                                    drw-rw-rw-   4 gm 0       0 2019-03-15 01:44 PythonScript
                                    -rw-rw-rw-   1 gm 0 1655808 2019-03-15 01:45 PythonScript.dll
                                    -rw-rw-rw-   1 gm 0  130048 2019-03-15 01:45 RunMe.dll
                                    -rw-rw-rw-   1 gm 0  287744 2019-03-15 01:45 SessionMgr.dll
                                    

                                    Let me know if you need more information. It’s late now (>2AM) for me in Europe, I might not answer you until tomorrow.

                                    Have a pleasant night.

                                    Gilles

                                    1 Reply Last reply Reply Quote 3
                                    • Gilles MaisonneuveG
                                      Gilles Maisonneuve
                                      last edited by

                                      PS: corrected the python script installation: remove all from AppData, installed new under n++ install dire as explained by Meta Chuh:

                                      +$ ls -l "C:\Program Files\Notepad++"\py*
                                      -rw-rw-rw-  1 gm 0 3428352 2018-04-30 18:44 C:\Program Files\Notepad++\python27.dll
                                      +$ ls -lr "C:\Program Files\Notepad++\plugins\PythonScript"
                                      total 1684
                                      drw-rw-rw-   3 gm 0       0 2019-03-15 02:11 scripts
                                      -rw-rw-rw-   1 gm 0 1655808 2018-10-09 20:19 PythonScript.dll
                                      drw-rw-rw-  18 gm 0   65536 2019-03-15 02:11 lib
                                      

                                      Is that all right ?

                                      Meta ChuhM EkopalypseE 2 Replies Last reply Reply Quote 2
                                      • Meta ChuhM
                                        Meta Chuh moderator @Gilles Maisonneuve
                                        last edited by

                                        @Gilles-Maisonneuve

                                        Note that the plugins installed by the additional plugin manager under C:\Users\gm\AppData\Roaming\Notepad++\plugins are not listed here. Only the ones installed under C:\Program Files\Notepad++\plugins are listed in debug info.

                                        yes, see the post above yours.

                                        additional info:
                                        the old plugin manager is not compatible with any notepad++ versions above 7.5.9. do not migrate or use this plugin, as it will write to the wrong folder locations.
                                        for all newer plugins, please use the new built in plugins admin.
                                        (plugins which are not listed in plugins admin will have to be installed manually, as they either have not been submitted to the official list by the plugin author, or they are trickier to install, like the pythonscript plugin, requiring python27.dll in the notepad++ binary folder)

                                        1 Reply Last reply Reply Quote 2
                                        • EkopalypseE
                                          Ekopalypse @Gilles Maisonneuve
                                          last edited by Ekopalypse

                                          @Gilles-Maisonneuve

                                          looks good - now to make this work I would do the following.
                                          Goto Plugins->Python Script->New Script, give it a meaningful name
                                          and copy/paste the posted script. Save.
                                          Next, set the PythonScript Initialisation from LAZY to ATSTARTUP
                                          (Plugins->Python Script->Configuration)
                                          While having the configuration window open, you see the new script in the
                                          Scripts area if User Scripts is checked.
                                          In addition you see two sections, Menu items and Toolbar icons.
                                          If you add it to one or both of it, it will appear in the main Plugin->PythonScript menu
                                          and at the toolbar (after npp restart)
                                          This setting would allow it to manually start the script and do its job. Only one start
                                          is needed and every document with an active perl lexer should be handled.

                                          There is an additional step to be done if you want to have the script started automatically
                                          every time npp starts. If you want to do this, then create another new script and
                                          name it startup.py (name is important and DO NOT USE the already available
                                          startup.py as this file might be overwritten once you update pythonscript plugin).
                                          In the NEWLY created startup.py put one line of code
                                          import NAME_OF_THE_SCRIPT_WITHOUT_EXTENSION
                                          like
                                          import EnhancePerlLexer (note, python is case sensitive).

                                          If you want to modify/extend the script it should be only needed to change/add
                                          something within the configuration area.
                                          For example you want to change the color, add another regex or modify an existing one.

                                          As usual, I failed doing a proper documentation. The line
                                          # in the same color as defined by style id 5 using results from matchgroup 1 and 4
                                          doesn’t make sense anymore.
                                          Should be something like # own defined color and non-default match group(s) used

                                          If there is anything unclear or you need help to modify the script to your needs or the
                                          script is not exactly working as you like, do not hesitate to ask. Just a side note, npp
                                          uses a PCRE2 compatible regex engine, it is not the exact perl regex version, so don’t
                                          be confused when there are slightly different syntactical differences.

                                          Have fun.

                                          Gilles MaisonneuveG 1 Reply Last reply Reply Quote 2
                                          • EkopalypseE
                                            Ekopalypse
                                            last edited by Ekopalypse

                                            Short note before leaving home - a quick way to identify which style/color is used at a
                                            certain position is to use this two commands in either a script or at the console
                                            (if used within a script, put a print before each line)

                                            editor.getStyleAt(editor.getCurrentPos())
                                            editor.styleGetFore(editor.getStyleAt(editor.getCurrentPos()))
                                            

                                            In the example the caret was set at line 2 just before the shift operator.
                                            Note, caret needs to be set before or within a word but not at the end.
                                            And note, this doesn’t return what the enhancement script does as this is
                                            using indicators and not style api.

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