Community
    • Login

    Bookmark multi words from multi lines in a text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    27 Posts 5 Posters 4.2k 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.
    • Alan KilbornA
      Alan Kilborn @guy038
      last edited by

      @guy038

      So somewhere between writing the first version of the script, and the changing of it to create the second script, I decided that it made sense to require that the “data” file you want the markings to be shown in should be the active file in the primary view, and the “list” file of tokens/regexes that should be used to do the markings should be the active file in the secondary view, when the script is run. It is an unwritten requirement (except that I just wrote it!).

      The first version of the script, because it was simpler and only one “word” was expected per line in the “list” file, tried to determine which view contained which.

      Aside from that, with the second version of the script, I’m not seeing the problems you mention. Can you give an exact example that replicates the behavior?

      1 Reply Last reply Reply Quote 1
      • guy038G
        guy038
        last edited by guy038

        Hi, @alan-kilborn,

        For instance, with :

        • Your text pasted, in new 1, in the main view

        • A list of four first names, pasted in new 2, in the secondary view

        • Cursor at the very beginning of new 1

        • Focus on new 1 ( the text )

        After running the script, I got :

        802b7bb5-52fb-42a3-8a5e-2305207a0592-image.png

        As you can see, all bookmarks are here, but some red marks are missing ! The script seems to only red-mark the first occurrence of each word of the list !


        In contrast to :

        • Your text, pasted in new 1, in the main view

        • A list of four first names, pasted in new 2, in the secondary view

        • Cursor at the very beginning of new 2

        • Focus on new 2 ( the list )

        After running the script, I got :

        a232e225-5cb0-43e9-a112-3392840f8378-image.png

        This time, everything went fine !

        Cheers,

        guy038

        Alan KilbornA 1 Reply Last reply Reply Quote 0
        • Alan KilbornA
          Alan Kilborn @guy038
          last edited by

          @guy038

          I think I remember something about possibly Notepad++ code itself interfering with scripts that are trying to use indicators?

          Perhaps the code in the script that “selects” an indicator needs to be “tighter” to where the indicator is used?

          Maybe try changing these lines of the script:

                      editor1.setIndicatorCurrent(SCE_UNIVERSAL_FOUND_STYLE)
                      for m in matches:
                          editor1.indicatorFillRange(m[0], m[1] - m[0])
          

          to this instead, and see if it runs differently?:

                      for m in matches:
                          editor1.setIndicatorCurrent(SCE_UNIVERSAL_FOUND_STYLE)
                          editor1.indicatorFillRange(m[0], m[1] - m[0])
          

          (really what this means is just moving the “setting” of the indicator inside the loop, so that it is definitely set each time before a range is “filled” with it)

          Let me know how that goes.

          1 Reply Last reply Reply Quote 1
          • guy038G
            guy038
            last edited by guy038

            @alan-kilborn,

            BINGO ! It works like a charm, whatever the focus is ( The main or the secondary view ) ;-))

            You’re right : placing the indicator’s definition inside the loop is the key point !

            Many thanks, again, for your cooperation :)

            Just to be sure : did you reproduce the issue, too, when focus is in the analyzed text view ?

            BR

            guy038

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

              @guy038 said in Bookmark multi words from multi lines in a text:

              did you reproduce the issue, too, when focus is in the analyzed text view ?

              Mostly it worked okay for me on simpler data sets.
              But I noticed it as an issue when I was looking into a larger-dataset problem, e.g. THIS ONE, and that made me recall an issue where an indicator needs to be set right before a fill, even though the indicator was set earlier and still should remain set.

              1 Reply Last reply Reply Quote 2
              • prahladmifourP
                prahladmifour
                last edited by

                Hello,@BAZ-BAZOOO
                Please follow this information, To Bookmark multi words from multi lines in a text

                Find What:
                (.Query . message.\R.ApplicationGatewayID = 5009.\R.\R.\R)|^(?!.Query . message).\R?
                Replace With:
                $1

                The regex is of the form:** (<YOUR_REGEX_MATCHING_LINES>)|^(?!.<STARTING_PART_OF_REGEX>).\R?.**

                Description:

                • (.Query . message.\R.ApplicationGatewayID = 5009.\R.\R.*\R) - a line with Query and then message words on it, then the next line that has ApplicationGatewayID = 5009 on it and then 2 more lines, captured into Group 1 ($1 refers to this value)

                • | - or

                • ^(?!.Query . message).*\R? - start of a line (^) that has no Query and then message on it, then the whole line and optional linebreak after it are matched and eventually removed.

                I hope this information will be useful to you.
                Thank you.

                1 Reply Last reply Reply Quote -3
                • Alan KilbornA
                  Alan Kilborn
                  last edited by

                  The marker ID used for bookmarks changed in Notepad++ 8.4.6 (and later). It is now 20, instead of 24. So, all references to 24 in this thread and/or its script(s), should be changed to 20.

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