Community
    • Login

    Regex] Rounding numbers python script does not run properly

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    28 Posts 4 Posters 5.6k Views 2 Watching
    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.
    • EkopalypseE Offline
      Ekopalypse @Alan Kilborn
      last edited by

      @Alan-Kilborn

      what about using a hidden scintilla instance?

      Alan KilbornA 2 Replies Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn @Ekopalypse
        last edited by

        @Ekopalypse said:

        what about using a hidden scintilla instance?

        That also sounds “messy” (or “involved”) but if you have some snippet to show me it is not so bad…?

        EkopalypseE 2 Replies Last reply Reply Quote 0
        • EkopalypseE Offline
          Ekopalypse @Alan Kilborn
          last edited by

          @Alan-Kilborn

          I used it here.

          1 Reply Last reply Reply Quote 2
          • EkopalypseE Offline
            Ekopalypse @Alan Kilborn
            last edited by

            @Alan-Kilborn

            just be careful about notepad.destroyScintilla(self.hidden_scintilla)
            Currently npp crashes when using this and then request another buffer.
            There is already a merged fix but only available on next release.

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

              @Ekopalypse

              This is the issue, I assume: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/4487

              EkopalypseE 1 Reply Last reply Reply Quote 1
              • EkopalypseE Offline
                Ekopalypse @Alan Kilborn
                last edited by

                @Alan-Kilborn

                correct, that is the one.

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

                  @Ekopalypse said:

                  what about using a hidden scintilla instance?

                  So, like this: hidden = notepad.createScintilla()

                  That is actually a nice solution. The hidden instance’s entire text can be set to the matched text from the editor.research(). Then the hidden.rereplace() can be called and the result of the replacement read out into a Python string variable. Thanks, Eko; clearly I would not have thought of this technique without your pointer.

                  just be careful about notepad.destroyScintilla()

                  This is not a problem as I will do this near the top of the script, and never do a “destroy”:

                  try:
                      hidden
                  except NameError:
                      hidden = notepad.createScintilla()
                  

                  and never do a “destroy”

                  Alan KilbornA EkopalypseE 2 Replies Last reply Reply Quote 2
                  • Alan KilbornA Offline
                    Alan Kilborn @Alan Kilborn
                    last edited by

                    @Alan-Kilborn said:

                    I will do this near the top of the script, and never do a “destroy”:

                    and never do a “destroy”

                    There really is an “echo” in here, or just me repeating myself and not noticing.

                    1 Reply Last reply Reply Quote 0
                    • EkopalypseE Offline
                      Ekopalypse @Alan Kilborn
                      last edited by

                      @Alan-Kilborn

                      and never do a “destroy”

                      :-D never ever - don’t even THINK about it unless your npp version is > 7.7.1 :-D

                      The hidden instance’s entire text can be set to the matched text from the editor.research(). Then the hidden.rereplace() can b

                      I guess, hidden.rereplace() is enough if you keep the text from editor and hidden in sync.
                      The replace function gets a match object which contains the position of the text to be replaced so from the replace function you could start the dialog, or?

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

                        @Ekopalypse

                        No, I’m not trying to “parallel” the text in the real editor and the hidden. If I set as the hidden editor’s entire text the match from the search, doing the replace on that guarantees the replace will succeed and the entire text left in the hidden editor’s buffer will be the replacement preview text. Long to explain but it seems to work.

                        1 Reply Last reply Reply Quote 3

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post
                        The Community of users of the Notepad++ text editor.
                        Powered by NodeBB | Contributors