• Login
Community
  • Login

Old Pythonscript stopped working

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 415 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.
  • B
    Bérci Róbert
    last edited by Jan 6, 2020, 12:57 PM

    Hello
    I had an old script from here for Pythonscript(1.3.0.0) witch was working fine till Notepad++ reached 7.7.
    I’m in need of this function once more and can’t get it to work.
    I’m not a huge Python guru so pls help.

    The original source of the script:
    https://community.notepad-plus-plus.org/topic/14992/show-count-of-occurrences-of-a-selected-string

    Cheers

    A 1 Reply Last reply Jan 6, 2020, 1:17 PM Reply Quote 0
    • A
      Alan Kilborn @Bérci Róbert
      last edited by Jan 6, 2020, 1:17 PM

      @Bérci-Róbert

      I don’t know about the script that stopped working, but I’d be inclined to do it this way instead; make it an on-demand thing (tied to a keycombo to run it):

      # -*- coding: utf-8 -*-
      
      from Npp import editor, notepad
      
      def main():
          matches = []
          if editor.getSelections() == 1 and not editor.getSelectionEmpty():
              try:
                  editor.research(r'\Q' + editor.getSelText() + r'\E', lambda m: matches.append(1))
              except:
                  matches = []
              notepad.messageBox('{} occurrence(s) of selected text'.format(len(matches)), '')
      
      main()
      

      Note: Definitely borrows heavily from the linked-to posting’s script.

      1 Reply Last reply Reply Quote 1
      • B
        Bérci Róbert
        last edited by Jan 6, 2020, 1:35 PM

        @Alan-Kilborn
        I really liked that I only needed to double tap the variable names and see if it was used or just declared.
        Your’s works but can you work it with the double click highlights and no extra commands needed?

        1 Reply Last reply Reply Quote 0
        • E
          Ekopalypse
          last edited by Jan 6, 2020, 7:43 PM

          If you are using a newer npp version you need to update the python
          script plugin version as well as the newer npp version did introduce
          a newer and changed scintilla version which affected the notification structure.
          Depending on your currently used version of npp the installation procedure is different but if you are using the most recent version,
          you should be able to reinstall PS via the plugin admin.

          a47d2550-424d-4edb-b102-1a4476c7b5a4-image.png

          1 Reply Last reply Reply Quote 2
          • B
            Bérci Róbert
            last edited by Jan 9, 2020, 8:48 AM

            @Ekopalypse
            Thanks. That did the trick.

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